35 #define STAR_TRACKING 1
43 #include "TBenchmark.h"
44 #include <sys/times.h>
48 #include "StEvtHddr.h"
49 #include "StMessMgr.h"
50 #include "StMemStat.h"
51 #include "StCloseFileOnTerminate.h"
52 #include "TApplication.h"
57 StMaker(name),m_EvtHddr(0),mChainOpt(0)
60 m_VersionDate = 180698;
61 mNTotal = 0; mNFailed = 0;
62 if ( UseOwnHeader || !(dynamic_cast<StEvtHddr*>(GetDataSet(
"EvtHddr"))))
72 void StChain::Streamer(TBuffer &)
87 if (TestBIT(kFiniEnd)){
88 Warning(
"Finish",
"chain %s.%s Finished twice, Ignore it"
92 TCollection::StartGarbageCollection();
102 Int_t StChain::Init()
105 Int_t res = StMaker::Init();
112 if (m_EvtHddr) m_EvtHddr->SetProdDateTime();
118 Int_t StChain::MakeEvent()
125 const StChainOpt *StChain::GetChainOpt()
const
127 if (mChainOpt)
return mChainOpt;
128 return StMaker::GetChainOpt();
131 Int_t StChain::EventLoop(Int_t jBeg,Int_t jEnd,
StMaker *outMk)
135 Double_t userCpuTime=0;
136 Double_t systemCpuTime=0;
137 Double_t childUserCpuTime=0;
138 Double_t childSystemCpuTime=0;
139 Double_t gTicks = (Double_t) sysconf(_SC_CLK_TCK);
145 LOG_QA <<
"Events=" << mNTotal
146 <<
",Failed=" << mNFailed
147 <<
",StepEventId=" <<
"'Start'"
148 <<
",StepContext=" <<
"'MemUsed'," <<
"MessageId='='"
152 LOG_QA <<
"Events=" << mNTotal
153 <<
",Failed=" << mNFailed
154 <<
",StepEventId=" <<
"'Start'"
155 <<
",StepContext=" <<
"'ProgSize'," <<
"MessageId='='"
162 <<
"StageID=" <<
"'1'"
163 <<
",MessageKey=" <<
"'MemUsed'"
169 <<
"StageID=" <<
"'1'"
170 <<
",MessageKey=" <<
"'ProgSize'"
175 if (jBeg > 1) Skip(jBeg-1);
181 Bool_t Notify() {
return ! fEnd_of_time;}
182 void SetNotifiedCallBack() {
184 fgStChain->Error(__FUNCTION__,
" Job will be terminated soon by the external signal . . . . ");
186 fgStChain->Error(__FUNCTION__,
" Forced Finish . . . . ");
189 fgStChain->Error(__FUNCTION__,
"Terminating . . . . ");
190 gApplication->Terminate(15);
193 for (jCur=jBeg; jCur<=jEnd; jCur++) {
194 evnt.Reset(); evnt.Start(
"QAInfo:");
195 gTicks = (Double_t) sysconf(_SC_CLK_TCK);
197 userCpuTime = ((Double_t) cpt.tms_utime) / gTicks;
198 systemCpuTime = ((Double_t) cpt.tms_stime) / gTicks;
199 childUserCpuTime = ((Double_t) cpt.tms_cutime) / gTicks;
200 childSystemCpuTime = ((Double_t) cpt.tms_cstime) / gTicks;
201 clock_gettime(CLOCK_PROCESS_CPUTIME_ID,&ts);
202 time_t start_tv_sec = ts.tv_sec;
203 long start_tv_nsec = ts.tv_nsec;
208 if (outMk && iMake ==
kStErr) { mNFailed++;}
211 evnt.Stop(
"QAInfo:");
214 userCpuTime = ((Double_t) cpt.tms_utime) / gTicks - userCpuTime;
215 systemCpuTime = ((Double_t) cpt.tms_stime) / gTicks - systemCpuTime;
216 childUserCpuTime = ((Double_t) cpt.tms_cutime) / gTicks - childUserCpuTime;
217 childSystemCpuTime = ((Double_t) cpt.tms_cstime) / gTicks - childSystemCpuTime;
218 clock_gettime(CLOCK_PROCESS_CPUTIME_ID,&ts);
219 time_t stop_tv_sec = ts.tv_sec;
220 long stop_tv_nsec = ts.tv_nsec;
221 if (stop_tv_nsec < start_tv_nsec) { stop_tv_nsec += 1000000000; stop_tv_sec -= 1; }
222 stop_tv_nsec -= start_tv_nsec;
223 stop_tv_sec -= start_tv_sec;
224 double tv_diff = ((double) stop_tv_sec) + (((double) stop_tv_nsec)*1e-9);
233 (
"QAInfo: Done with Event [no. %d/run %d/evt. %d/Date.Time %d.%d/sta %d] Real Time = %10.2f seconds Cpu Time = %10.2f seconds",
234 jCur,
GetRunNumber(),GetEventNumber(),GetDate(), GetTime(),
235 iMake,evnt.GetRealTime(
"QAInfo:"),evnt.GetCpuTime(
"QAInfo:"))
237 LOG_QA << Form(
"QAInfo: Cpu Times: user / system / user children / system children = %8.2f / %8.2f / %8.2f / %8.2f seconds (tick = %8.2f, cps = %ld)",
238 userCpuTime,systemCpuTime,childUserCpuTime,childSystemCpuTime,gTicks,CLOCKS_PER_SEC) << endm;
239 LOG_QA << Form(
"QAInfo: Cpu Times: all threads = %15.9f seconds",tv_diff) << endm;
244 LOG_QA <<
"Events=" << mNTotal
245 <<
",Failed=" << mNFailed
246 <<
",StepEventId=" <<
"'EventFinish'"
247 <<
",StepContext=" <<
"'Cpu'," <<
"MessageId='='"
248 <<
",ProgrammMessage='" << evnt.GetCpuTime(
"QAInfo:")
251 LOG_QA <<
"Events=" << mNTotal
252 <<
",Failed=" << mNFailed
253 <<
",StepEventId=" <<
"'EventFinish'"
254 <<
",StepContext=" <<
"'RealTime'," <<
"MessageId='='"
255 <<
",ProgrammMessage='" << evnt.GetRealTime(
"QAInfo:")
277 (
"QAInfo:EventLoop completed code %d",iMake)
279 gSystem->Exec(
"date");
282 (
"QAInfo:Run is finished at Date/Time %i/%i; Total events processed :%i and not completed: %i",
283 t.GetDate(),t.GetTime(),mNTotal,mNFailed)
289 LOG_QA <<
"Events=" << mNTotal
290 <<
",Failed=" << mNFailed
291 <<
",StepEventId=" <<
"'Finish'"
292 <<
",StepContext=" <<
"'MemUsed'," <<
"MessageId='='"
296 LOG_QA <<
"Events=" << mNTotal
297 <<
",Failed=" << mNFailed
298 <<
",StepEventId=" <<
"'Finish'"
299 <<
",StepContext=" <<
"'ProgSize'," <<
"MessageId='='"
319 if (GetLogger()) GetLogger()->Close();
Class StTerminateNotified is a abstract visitor to propagate the termination signal It is to provide ...
virtual Int_t GetNumber() const
STAR methods.
virtual void Clear(Option_t *option="")
User defined functions.
virtual void Clear(Option_t *option="")
User defined functions.
virtual void SetBIT(EMakerStatus k)
Maker Status Bits.
static StMaker * fgStChain
pointer to top StChain
virtual const char * GetName() const
special overload
virtual Int_t GetRunNumber() const
Returns the current RunNumber.
static Double_t ProgSize()