3 #include "StChargedPionMaker.h"
8 #include "TClonesArray.h"
12 #include "SystemOfUnits.h"
15 #include "StMuDSTMaker/COMMON/StMuDst.h"
16 #include "StMuDSTMaker/COMMON/StMuEvent.h"
17 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
18 #include "StMuDSTMaker/COMMON/StMuDst.h"
19 #include "StMuDSTMaker/COMMON/StMuTrack.h"
20 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
23 #include "StMessMgr.h"
26 #include "StChargedPionEvent.h"
27 #include "StChargedPionVertex.h"
28 #include "StChargedPionTrack.h"
29 #include "StChargedPionJet.h"
30 #include "StChargedPionJetParticle.h"
31 #include "StChargedPionMcEvent.h"
32 #include "StChargedPionHelpers.h"
33 #include "StChargedPionTypes.h"
36 #include "StDetectorDbMaker/StDetectorDbTriggerID.h"
39 #include "StSpinPool/StJetSkimEvent/StJetSkimEvent.h"
40 #include "StSpinPool/StJets/StJets.h"
41 #include "StSpinPool/StJets/StJet.h"
42 #include "StJetMaker/StJetMaker.h"
45 #include "StSpinPool/StSpinDbMaker/StSpinDbMaker.h"
48 #include "StEmcTriggerMaker/StEmcTriggerMaker.h"
51 #include "StTriggerUtilities/StTriggerSimuMaker.h"
52 #include "StTriggerUtilities/StTriggerSimuResult.h"
59 #include "tables/St_g2t_event_Table.h"
60 #include "tables/St_particle_Table.h"
61 #include "tables/St_g2t_pythia_Table.h"
64 #include "StMcEvent/StMcEvent.hh"
71 LOG_INFO <<
"calling constructor" << endm;
73 mFile =
new TFile(outputfile,
"RECREATE");
75 mBadTracks =
new TH1D(
"badTracks",
"tracks failing quality cuts",4,0.5,4.5);
80 sprintf(title,
"created %s", ctime(&rawtime));
81 mTree =
new TTree(
"tree",title);
83 bool isMonteCarlo = GetMakerInheritsFrom(
"StEmcSimulatorMaker") ?
true:
false;
84 LOG_INFO <<
"Are we running on Monte Carlo? " << isMonteCarlo << endm;
88 mTree->Branch(
"event",
"StChargedPionMcEvent", &mEvent);
92 mTree->Branch(
"event",
"StChargedPionEvent", &mEvent);
95 Long64_t autosave = 1000000000;
96 mTree->SetAutoSave(autosave);
97 mTree->SetMaxTreeSize(autosave);
116 LOG_INFO <<
"finished constructor" << endm;
119 StChargedPionMaker::~StChargedPionMaker() {
120 LOG_DEBUG <<
"calling destructor" << endm;
122 if(mEvent)
delete mEvent;
124 if(mJetFile) mJetFile->Close();
128 if(mMiniMcFile) mMiniMcFile->Close();
131 LOG_DEBUG <<
"finished destructor" << endm;
134 void StChargedPionMaker::Clear(
const char*) {
137 if(data) data->Clear();
138 if(simu) simu->Clear();
142 Int_t StChargedPionMaker::Init() {
144 GetMakerInheritsFrom(
"StMuDstMaker"));
146 GetMakerInheritsFrom(
"StSpinDbMaker"));
148 GetMakerInheritsFrom(
"StEmcTriggerMaker"));
150 GetMakerInheritsFrom(
"StJetMaker"));
152 GetMakerInheritsFrom(
"StTriggerSimuMaker"));
155 if( dynamic_cast<StChargedPionMcEvent*>(mEvent) ) {
157 mPyJets = mJetMk->getStJets(
"PythiaConeJets");
158 LOG_INFO <<
"loaded mPyJets at " << mPyJets << endm;
164 LOG_INFO <<
"init OK" << endm;
165 return StMaker::Init();
168 Int_t StChargedPionMaker::InitRun(
int runnumber) {
170 LOG_INFO <<
"found StJetMaker in the chain" << endm;
171 if(
StJets* stjets = mJetMk->getStJets(
"ConeJets")) {
173 LOG_INFO <<
"found Jets in Run 5 branch " << mJets << endm;
175 else if(
StJets* stjets = mJetMk->getStJets(
"ConeJets12")) {
177 LOG_INFO <<
"found Jets in Run 6 branch " << mJets << endm;
180 mJets = mJetMk->getStJets(
"ConeJets12_0.7");
181 LOG_INFO <<
"found ConeJets12_0.7 branch " << mJets << endm;
185 LOG_INFO <<
"trying to get the jets off disk" << endm;
186 std::ostringstream os;
187 if(runnumber < 7000000) {
188 os <<
"/star/institutions/mit/common/run5/jets/jets_" << runnumber <<
".tree.root";
192 os <<
"/star/institutions/mit/common/run6/jets/jets_" << runnumber <<
".tree.root";
195 if(mJetFile) mJetFile->Close();
197 mJetFile = TFile::Open(os.str().c_str());
198 if(mJetFile) mJetTree = (TTree*) mJetFile->Get(
"jet");
200 if(runnumber < 7000000) {
201 mJetTree->SetBranchAddress(
"ConeJets", &mJets);
204 mJetTree->SetBranchAddress(
"ConeJets12", &mJets);
206 mJetTree->BuildIndex(
"mRunId",
"mEventId");
210 return StMaker::InitRun(runnumber);
219 TString inputFile(mMuDstMk->
chain()->GetFile()->GetName());
220 if(mCurrentFile != inputFile){
221 mCurrentFile = inputFile;
222 const char *baseName = strrchr(mCurrentFile.Data(),
'/');
223 mEvent->setMuDstName( baseName );
226 TString minimcFile = inputFile.ReplaceAll(
"MuDst",
"minimc");
227 mMiniMcFile = TFile::Open(minimcFile);
229 LOG_INFO <<
"opened minimc file at " << minimcFile << endm;
230 mMiniMcTree =
dynamic_cast<TTree*
> (mMiniMcFile->Get(
"StMiniMcTree"));
231 mMiniMcTree->BuildIndex(
"mEventId");
232 mMiniMcTree->SetBranchAddress(
"StMiniMcEvent", &mMiniMcEvent);
235 LOG_WARN <<
"problem opening minimc at " << minimcFile << endm;
241 StChargedPionHelpers::translateMuDst(data);
246 for (map<int,float>::iterator it=m.begin(); it!=m.end(); ++it) {
247 int trigId = it->first;
248 data->setPrescale(trigId, it->second);
250 if(
StMuDst::event()->triggerIdCollection().nominal().isTrigger(trigId) ) {
251 data->addTrigger(trigId);
254 mTriggers.push_back(trigId);
257 makeTriggerSimu(data);
262 data->setPolValid( mSpDbMk->
isValid() );
265 data->setBxingMasked( mSpDbMk->isMaskedUsingBX48(bx48) );
266 data->setBxingOffset( mSpDbMk->offsetBX48minusBX7(bx48, data->bx7()) );
270 StChargedPionHelpers::translateMuDst(simu);
272 makeTriggerSimu(simu);
275 simu->setProcessId( mcEvent->subProcessId() );
280 St_g2t_pythia* PyPtr = (St_g2t_pythia *) geantDstI(
"g2t_pythia");
281 g2t_pythia_st *g2t_pythia = PyPtr->GetTable();
282 simu->setHardP( g2t_pythia->hard_p );
283 simu->setX1( g2t_pythia->bjor_1 );
285 St_particle *particleTabPtr = (St_particle *) geantDstI(
"particle");
286 particle_st* particleTable = particleTabPtr->GetTable();
288 simu->isr1().SetXYZT(
289 particleTable[2].phep[0],
290 particleTable[2].phep[1],
291 particleTable[2].phep[2],
292 particleTable[2].phep[3]
295 simu->isr2().SetXYZT(
296 particleTable[3].phep[0],
297 particleTable[3].phep[1],
298 particleTable[3].phep[2],
299 particleTable[3].phep[3]
302 simu->parton1().SetXYZT(
303 particleTable[4].phep[0],
304 particleTable[4].phep[1],
305 particleTable[4].phep[2],
306 particleTable[4].phep[3]
309 simu->parton2().SetXYZT(
310 particleTable[5].phep[0],
311 particleTable[5].phep[1],
312 particleTable[5].phep[2],
313 particleTable[5].phep[3]
316 simu->parton3().SetXYZT(
317 particleTable[6].phep[0],
318 particleTable[6].phep[1],
319 particleTable[6].phep[2],
320 particleTable[6].phep[3]
323 simu->parton4().SetXYZT(
324 particleTable[7].phep[0],
325 particleTable[7].phep[1],
326 particleTable[7].phep[2],
327 particleTable[7].phep[3]
330 simu->setFlavor(1, particleTable[4].idhep);
331 simu->setFlavor(2, particleTable[5].idhep);
332 simu->setFlavor(3, particleTable[6].idhep);
333 simu->setFlavor(4, particleTable[7].idhep);
336 for(
int i = 8; i < particleTabPtr->GetNRows(); ++i)
338 if(particleTable[i].isthep == 1 && particleTable[i].phep[3] > 2.0)
341 r.id = particleTable[i].idhep;
342 r.vec = StChargedPionLorentzVector(particleTable[i].phep[0],
343 particleTable[i].phep[1],
344 particleTable[i].phep[2],
345 particleTable[i].phep[3]);
346 simu->pythiaRecord().push_back(r);
350 int bytesRead = mMiniMcTree->GetEntryWithIndex(simu->eventId());
352 StChargedPionHelpers::translateMinimc(mMiniMcEvent, simu);
357 StChargedPionHelpers::translateJets(mPyJets, simu);
360 int ok = mJetTree->GetEntryWithIndex(simu->runId(), simu->eventId());
361 if(ok > 0) StChargedPionHelpers::translateJets(mJets, simu);
367 StChargedPionHelpers::translateJets(mJets, mEvent);
370 int ok = mJetTree->GetEntryWithIndex(mEvent->runId(), mEvent->eventId());
371 if(ok > 0) StChargedPionHelpers::translateJets(mJets, mEvent);
384 LOG_INFO <<
"finished OK"<<endm;
390 for (
unsigned i=0; i<mTriggers.size(); ++i) {
391 int trigId = mTriggers[i];
393 if( mTrgSimuMk->isTrigger(trigId) ) {
394 ev->addSimuTrigger(trigId);
398 for(
unsigned i=0; i<result.highTowerIds().size(); i++) {
399 int tid = result.highTowerIds().at(i);
402 for(
unsigned i=0; i<result.triggerPatchIds().size(); i++) {
403 int tid = result.triggerPatchIds().at(i);
406 for(
unsigned i=0; i<result.jetPatchIds().size(); i++) {
407 int tid = result.jetPatchIds().at(i);
410 ev->setL2Result(result.
l2Result(kJet),
true);
416 bool eastBBC(
false), westBBC(
false);
417 for (
int pmt=0;pmt<Npmt;pmt++){
419 if(pmt<16) eastBBC =
true;
420 if(pmt>23 && pmt<40) westBBC =
true;
423 if(eastBBC && westBBC) {
424 ev->addSimuTrigger(96011);
425 ev->addSimuTrigger(117011);
428 for (
unsigned i=0; i<mTriggers.size(); ++i) {
429 int trigId = mTriggers[i];
432 ev->addSimuTrigger(trigId);
436 for(map<int,int>::const_iterator iter=m.begin(); iter!=m.end(); iter++) {
437 ev->addHighTower(iter->first, iter->second);
441 for(map<int,int>::const_iterator iter=m.begin(); iter!=m.end(); iter++) {
442 ev->addTriggerPatch(iter->first, iter->second);
446 for(map<int,int>::const_iterator iter=m.begin(); iter!=m.end(); iter++) {
447 ev->addJetPatch(iter->first, iter->second);
map< Int_t, Float_t > getTotalPrescales()
bool isPolDirTrans()
true if all needed DB tables were found
bool isValid()
dump spinDb content for current time stamp
int jetPatchAdc(short jetPatchId) const
returns DSM ADC if above trigger threshold, otherwise -1
virtual void Clear(Option_t *option="")
User defined functions.
int highTowerAdc(short towerId) const
returns DSM ADC if above trigger threshold, otherwise -1
int spin4usingBX48(int bx48)
8bit spin information
Top level class for the MiniMcTree, containing event-wise information and the McTrack, and all TrackPair collections.
map< int, int > barrelTriggerPatchesAboveThreshold(int trigId)
map contains (key,value) = (patchId,ADC) of all TP above DSM threshold. map is empty if threshold = 0...
map< int, int > barrelJetPatchesAboveThreshold(int trigId)
map contains (key,value) = (patchId,ADC) of all JP above DSM threshold. map is empty if threshold = 0...
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
TChain * chain()
In read mode, returns pointer to the chain of .MuDst.root files that where selected.
map< int, int > barrelTowersAboveThreshold(int trigId)
map contains (key,value) = (softId,ADC) of all towers above DSM threshold. map is empty if threshold ...
for simplicity, this contains both the rc and mc track information.
const StTriggerSimuResult & detailedResult(int trigId)
returns object containing detailed information about simulation of given trigger
int triggerPatchAdc(short patchId) const
returns DSM ADC if above trigger threshold, otherwise -1
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...
const unsigned int * l2Result(L2ResultType algo, int year=2006) const
returns address of specific L2 result struct – cast it yourself
int isTrigger(int trigId)
1==Yes,0==No,-1==Don't Know. Same convention holds for other methods where appropriate.
Persistent MC track class.
bool isPolDirLong()
Returns true if beams are transversely polarized, false otherwise.