1 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
2 #include "StEmcSimulatorMaker/StEmcSimulatorMaker.h"
3 #include "St_db_Maker/St_db_Maker.h"
8 #include "StGammaScheduleMaker.h"
15 StGammaScheduleMaker::StGammaScheduleMaker(
const char *name):
StMaker(name)
21 void StGammaScheduleMaker::addTimestamp(
int date,
int time,
double weight)
25 currentStamp.date = date;
26 currentStamp.time = time;
27 currentStamp.weight = weight;
29 mStamps.push_back(currentStamp);
37 void StGammaScheduleMaker::rearrange()
40 StMaker *simulator = GetMakerInheritsFrom(
"StEmcSimulatorMaker");
43 LOG_WARN <<
"rearrange() - No StEmcSimulatorMaker found in the chain!" << endm;
47 TList *makerList = this->GetParentChain()->GetMakeList();
49 makerList->Remove(dynamic_cast<StMaker*>(
this));
50 makerList->AddBefore(simulator, dynamic_cast<StMaker*>(
this));
57 Int_t StGammaScheduleMaker::Init()
64 LOG_WARN <<
"Init() - No StMuDstMaker found in the chain!" << endm;
68 mTotalEvents = muDstMaker->
tree()->GetEntries();
75 LOG_INFO <<
"Init() - Distributing status tables across " << mTotalEvents <<
" events" << endm;
78 double totalWeight = 0;
80 vector<stamp>::iterator it;
82 for(it = mStamps.begin(); it != mStamps.end(); ++it)
84 totalWeight += (*it).weight;
88 double usedEvents = 0;
89 for(it = mStamps.begin(); it != mStamps.end(); ++it)
91 double newEvents = ((*it).weight / totalWeight) * mTotalEvents;
92 (*it).event = usedEvents;
93 usedEvents += newEvents;
96 LOG_INFO <<
"Init() - Using the timestamps" << endm;
97 LOG_INFO <<
"Init() - \tDate\t\tTime\tWeight\tInitial Event" << endm;
98 for(it = mStamps.begin(); it != mStamps.end(); ++it)
100 LOG_INFO <<
"Init() - \t" << it->date <<
"\t" << it->time <<
"\t" << it->weight <<
"\t" << it->event << endm;
106 LOG_INFO <<
"Init() - Using the default timestamp" << endm;
109 return StMaker::Init();
124 LOG_WARN <<
"Make() - No St_db_Maker found in the chain!" << endm;
129 vector<stamp>::iterator it;
131 for(it = mStamps.begin(); it != mStamps.end(); ++it)
136 double diff = mCurrentEvent - it->event;
137 if(!mCurrentEvent) diff = 0.5;
139 if(diff > 0 && diff < 1)
141 LOG_INFO <<
"Make() - Setting time stamp to Date = " << it->date <<
", Time = " << it->time
142 <<
" (Index " << mStampIndex + 1 <<
") at event " << mCurrentEvent + 1 << endm;
143 database->SetDateTime(it->date, it->time);
TTree * tree()
Returns pointer to the current TTree, the top level io structure that holds the event, track, v0, etc. information in branches of that tree.