00001 00035 #define STAR_TRACKING 1 00036 00037 00038 #include <stdlib.h> 00039 #include <stdio.h> 00040 #include "TROOT.h" 00041 #include "TError.h" 00042 #include "TBrowser.h" 00043 #include "TBenchmark.h" 00044 #include "TSystem.h" 00045 #include "StChain.h" 00046 #include "StEvtHddr.h" 00047 #include "StMessMgr.h" 00048 #include "StMemStat.h" 00049 #include "StCloseFileOnTerminate.h" 00050 #include "TApplication.h" 00051 ClassImp(StChain) 00052 00053 //_____________________________________________________________________________ 00054 StChain::StChain(const char *name, const Bool_t UseOwnHeader): 00055 StMaker(name),m_EvtHddr(0) 00056 { 00057 m_Version = 100; //StChain version number and release date 00058 m_VersionDate = 180698; 00059 mNTotal = 0; mNFailed = 0; 00060 if ( UseOwnHeader || !(dynamic_cast<StEvtHddr*>(GetDataSet("EvtHddr")))) 00061 m_EvtHddr = new StEvtHddr(m_ConstSet); 00062 00063 } 00064 00065 //_____________________________________________________________________________ 00066 StChain::~StChain() 00067 { 00068 } 00069 //_____________________________________________________________________________ 00070 void StChain::Streamer(TBuffer &) 00071 { Error("Streamer"," attempt to write %s\n ",GetName()); 00072 assert(0); 00073 } 00074 //_____________________________________________________________________________ 00075 void StChain::Clear(Option_t *option) 00076 { 00077 // StartTimer(); 00078 StMaker::Clear(option); 00079 // TCollection::EmptyGarbageCollection(); 00080 // StopTimer(); 00081 } 00082 //_____________________________________________________________________________ 00083 Int_t StChain::Finish(){ 00084 // StartTimer(); 00085 if (TestBIT(kFiniEnd)){ 00086 Warning("Finish","chain %s.%s Finished twice, Ignore it" 00087 ,GetName(),ClassName()); 00088 return 1; 00089 } 00090 TCollection::StartGarbageCollection(); 00091 Int_t res = StMaker::Finish(); 00092 // TCollection::EmptyGarbageCollection(); 00093 SetBIT (kFiniEnd); 00094 // StopTimer(); 00095 PrintTotalTime(); 00096 // delete gMessMgr; gMessMgr = 0; 00097 return res; 00098 } 00099 //_____________________________________________________________________________ 00100 Int_t StChain::Init() 00101 { 00102 // StartTimer(); 00103 Int_t res = StMaker::Init(); 00104 // StopTimer(); 00105 return res; 00106 } 00107 //_____________________________________________________________________________ 00108 Int_t StChain::Make() { 00109 // StartTimer(); 00110 if (m_EvtHddr) m_EvtHddr->SetProdDateTime(); 00111 Int_t res = StMaker::Make(); 00112 // StopTimer(); 00113 return res; 00114 } 00115 //_____________________________________________________________________________ 00116 Int_t StChain::MakeEvent() 00117 { 00118 // Make next event from the TBrowser TContextMenu 00119 Clear(); 00120 return StMaker::IMake(GetNumber()+1); 00121 } 00122 //_____________________________________________________________________________ 00123 const StChainOpt *StChain::GetChainOpt() const 00124 { 00125 if (mChainOpt) return mChainOpt; 00126 return StMaker::GetChainOpt(); 00127 } 00128 //_____________________________________________________________________________ 00129 Int_t StChain::EventLoop(Int_t jBeg,Int_t jEnd, StMaker *outMk) 00130 { 00131 TBenchmark evnt; 00132 int jCur=0,iMake=0; 00133 #ifdef STAR_TRACKING 00134 #ifdef OLDTRACKING 00135 // Add a record to MySQL tracking Db 00136 LOG_QA << "Events=" << mNTotal 00137 << ",Failed=" << mNFailed 00138 << ",StepEventId=" << "'Start'" 00139 << ",StepContext=" << "'MemUsed'," << "MessageId='='" 00140 << ",ProgrammMessage='" << int(StMemStat::Used()) 00141 << "'" << endm; 00142 00143 LOG_QA << "Events=" << mNTotal 00144 << ",Failed=" << mNFailed 00145 << ",StepEventId=" << "'Start'" 00146 << ",StepContext=" << "'ProgSize'," << "MessageId='='" 00147 << ",ProgrammMessage='" << int(StMemStat::ProgSize()) 00148 << "'" << endm; 00149 #else 00150 // Add a record to MySQL tracking Db 00151 // LOG_QA << "SequenceValue="<< mNTotal 00152 LOG_UCM 00153 << "StageID=" << "'1'" 00154 << ",MessageKey=" << "'MemUsed'" 00155 << ",MessageValue='" << int(StMemStat::Used()) 00156 << "'" << endm; 00157 00158 // LOG_QA << "SequenceValue="<<mNTotal 00159 LOG_UCM 00160 << "StageID=" << "'1'" 00161 << ",MessageKey=" << "'ProgSize'" 00162 << ",MessageValue='" << int(StMemStat::ProgSize()) 00163 << "'" << endm; 00164 #endif 00165 #endif 00166 if (jBeg > 1) Skip(jBeg-1); 00167 // End of the event loop as soon as the application receives TERM (-15) system signal 00168 class teminator : public StTerminateNotified { 00169 Bool_t fEnd_of_time; 00170 public: 00171 teminator() : StTerminateNotified(), fEnd_of_time(kFALSE) {} 00172 Bool_t Notify() {return ! fEnd_of_time;} 00173 void SetNotifiedCallBack() { 00174 fEnd_of_time = true; 00175 fgStChain->Error(__FUNCTION__," Job will be terminated soon by the external signal . . . . "); 00176 if (GetTopChain()) { 00177 fgStChain->Error(__FUNCTION__," Forced Finish . . . . "); 00178 GetTopChain()->Finish(); 00179 } 00180 fgStChain->Error(__FUNCTION__,"Terminating . . . . "); 00181 gApplication->Terminate(15); 00182 } 00183 } endOfTime; 00184 for (jCur=jBeg; jCur<=jEnd; jCur++) { 00185 evnt.Reset(); evnt.Start("QAInfo:"); 00186 00187 Clear(); 00188 iMake = Make(jCur); 00189 00190 if (outMk && iMake == kStErr) {/*outMk->IMake(jCur);*/ mNFailed++;} 00191 if (iMake%10 == kStEOF || iMake%10==kStFatal) break; 00192 mNTotal++; 00193 evnt.Stop("QAInfo:"); 00194 // evnt.Show("QAInfo:"); 00195 LOG_QA << Form 00196 /*printf */ ("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", 00197 jCur,GetRunNumber(),GetEventNumber(),GetDate(), GetTime(), 00198 iMake,evnt.GetRealTime("QAInfo:"),evnt.GetCpuTime("QAInfo:")) 00199 << endm; 00200 #ifdef STAR_TRACKING 00201 #ifdef OLDTRACKING 00202 // Add a record to MySQL tracking Db 00203 LOG_QA << "Events=" << mNTotal 00204 << ",Failed=" << mNFailed 00205 << ",StepEventId=" << "'EventFinish'" 00206 << ",StepContext=" << "'Cpu'," << "MessageId='='" 00207 << ",ProgrammMessage='" << evnt.GetCpuTime("QAInfo:") 00208 << "'" << endm; 00209 00210 LOG_QA << "Events=" << mNTotal 00211 << ",Failed=" << mNFailed 00212 << ",StepEventId=" << "'EventFinish'" 00213 << ",StepContext=" << "'RealTime'," << "MessageId='='" 00214 << ",ProgrammMessage='" << evnt.GetRealTime("QAInfo:") 00215 << "'" << endm; 00216 #else 00217 // Add a record to MySQL tracking Db 00218 // LOG_QA << "SequenceValue=" << mNTotal 00219 // LOG_UCM 00220 // << "StageID=" << "'3'" 00221 // << ",MessageKey=" << "'Cpu'" 00222 // << ",MessageValue='" << evnt.GetCpuTime("QAInfo:") 00223 // << "'" << endm; 00224 00225 // LOG_QA << "SequenceValue=" << mNFailed 00226 // LOG_UCM 00227 // << "StageID=" << "'3'" 00228 // << ",MessageKey=" << "'RealTime'" 00229 // << ",MessageValue='" << evnt.GetRealTime("QAInfo:") 00230 // << "'" << endm; 00231 #endif 00232 #endif 00233 } 00234 00235 LOG_QA << Form 00236 /*printf */ ("QAInfo:EventLoop completed code %d",iMake) 00237 << endm; 00238 gSystem->Exec("date"); 00239 TDatime t; 00240 LOG_QA << Form 00241 /* printf */ ("QAInfo:Run is finished at Date/Time %i/%i; Total events processed :%i and not completed: %i", 00242 t.GetDate(),t.GetTime(),mNTotal,mNFailed) 00243 << endm; 00244 00245 #ifdef STAR_TRACKING 00246 // Add a record to MySQL tracking Db 00247 #ifdef OLDTRACKING 00248 LOG_QA << "Events=" << mNTotal 00249 << ",Failed=" << mNFailed 00250 << ",StepEventId=" << "'Finish'" 00251 << ",StepContext=" << "'MemUsed'," << "MessageId='='" 00252 << ",ProgrammMessage='" << int(StMemStat::Used()) 00253 << "'" << endm; 00254 00255 LOG_QA << "Events=" << mNTotal 00256 << ",Failed=" << mNFailed 00257 << ",StepEventId=" << "'Finish'" 00258 << ",StepContext=" << "'ProgSize'," << "MessageId='='" 00259 << ",ProgrammMessage='" << int(StMemStat::ProgSize()) 00260 << "'" << endm; 00261 #else 00262 // Add a record to MySQL tracking Db 00263 00264 // LOG_QA << "SequenceValue=" << mNTotal 00265 // LOG_UCM 00266 // << "StageID=" << "'3'" 00267 // << ",MessageKey=" << "'MemUsed'" 00268 // << ",MessageValue='" << int(StMemStat::Used()) 00269 // << "'" << endm; 00270 00271 // LOG_QA << "SequenceValue=" << mNFailed 00272 // LOG_UCM 00273 // << "StageID=" << "'3'" 00274 // << ",MessageKey=" << "'ProgSize'" 00275 // << ",MessageValue='" << int(StMemStat::ProgSize()) 00276 // << "'" << endm; 00277 #endif 00278 if (GetLogger()) GetLogger()->Close(); 00279 00280 #endif 00281 fflush(stdout); 00282 return iMake; 00283 } 00284 00285 00286 // $Id: StChain.cxx,v 1.81 2013/07/18 14:05:25 fisyak Exp $ 00287 // $Log: StChain.cxx,v $ 00288 // Revision 1.81 2013/07/18 14:05:25 fisyak 00289 // Open garbage can at Finish 00290 // 00291 // Revision 1.80 2011/10/13 20:06:53 perev 00292 // Put removed UCM messages back(req JL) 00293 // 00294 // Revision 1.79 2011/10/11 16:01:48 perev 00295 // Remove redundant printouts 00296 // 00297 // Revision 1.78 2011/06/20 15:13:50 fisyak 00298 // Force to call Finish with SIGTERM signal obtained from condor_vacate_job after time limit reached 00299 // 00300 // Revision 1.77 2010/04/27 21:31:44 fine 00301 // remove the logger destruction side effect 00302 // 00303 // Revision 1.76 2010/04/23 22:40:08 fine 00304 // RT #1911. Close the local logger at Finish 00305 // 00306 // Revision 1.75 2010/03/02 23:09:24 fine 00307 // Simplify Close/Terminate interface 00308 // 00309 // Revision 1.74 2010/03/01 23:37:41 fine 00310 // Terminate StChain::EventLoop with the extrenal TERM 15 signal 00311 // 00312 // Revision 1.73 2009/06/23 19:37:33 fine 00313 // replace QA logger with the dedicated UCM one 00314 // 00315 // Revision 1.72 2009/03/17 20:03:36 perev 00316 // Back to StMemSet version 00317 // 00318 // Revision 1.70 2009/01/26 14:32:33 fisyak 00319 // rename TMemStat => StMemStat due clash with ROOT class 00320 // 00321 // Revision 1.69 2008/06/03 22:33:14 fisyak 00322 // Add geometries for y2005g, y2006g and y2007g; use ROOT convention for variable definitions 00323 // 00324 // Revision 1.68 2008/03/05 00:01:51 fisyak 00325 // Move Skip method in base class 00326 // 00327 // Revision 1.67 2007/10/19 16:18:32 fine 00328 // new Db schema from TxCorp 00329 // 00330 // Revision 1.66 2007/10/17 18:54:04 fine 00331 // new Db tracking schema from TxCorp 00332 // 00333 // Revision 1.65 2007/09/18 20:42:35 fine 00334 // Fix the message typo 00335 // 00336 // Revision 1.64 2007/04/26 20:36:49 perev 00337 // Some ChainOpt fixes 00338 // 00339 // Revision 1.63 2006/07/03 04:13:38 fine 00340 // new Job tracking Db activated 00341 // 00342 // Revision 1.62 2006/07/01 01:19:16 fine 00343 // Add new jiob tracking option code 00344 // 00345 // Revision 1.61 2006/06/05 00:20:59 fine 00346 // class the new StMessMgr method to flush the logger buffers 00347 // 00348 // Revision 1.60 2006/06/04 22:59:00 fine 00349 // Change the wonr event tracking code : Finish with the proper EventFinish 00350 // 00351 // Revision 1.59 2006/05/24 17:33:43 fine 00352 // remove the redundant Db fields 00353 // 00354 // Revision 1.58 2006/05/16 18:54:23 fine 00355 // fix StChain and MySql 00356 // 00357 // Revision 1.57 2006/05/12 18:48:48 fine 00358 // reshape jobn tracking. remove the redundand table columns 00359 // 00360 // Revision 1.56 2006/05/12 18:08:14 fine 00361 // fix the MySQLAppender problem and re-shape the trakDb messages 00362 // 00363 // Revision 1.55 2006/05/09 23:31:20 fine 00364 // Reshape the job tracking Db tables and add a few LOQ_QA message to record it with the Job tracking Db 00365 // 00366 // Revision 1.54 2006/03/28 02:09:19 fine 00367 // Add SIMS_USER SUMS_AUTHENTICATED_USER SUMS_JOBNAME 00368 // 00369 // Revision 1.53 2006/02/05 01:41:23 fine 00370 // Add the tracking information from the STAR chain 00371 // 00372 // Revision 1.52 2005/08/29 21:42:20 fisyak 00373 // switch from fBits to fStatus for StMaker control bits 00374 // 00375 // Revision 1.51 2005/08/12 21:27:31 perev 00376 // Remove call output in the case or read error 00377 // 00378 // Revision 1.50 2004/11/04 22:26:38 fine 00379 // populate the package with save/restore the logger and edit some messages 00380 // 00381 // Revision 1.49 2004/08/03 17:18:46 perev 00382 // EventLoop corrected according to current policy 00383 // 00384 // Revision 1.48 2002/11/26 02:16:39 perev 00385 // EventLoop added 00386 // 00387 // Revision 1.47 2002/03/12 21:19:00 fisyak 00388 // Set only one StEvtHddr as default option (due to Embedding) 00389 // 00390 // Revision 1.46 2002/02/02 23:31:13 jeromel 00391 // doxygenized. Added some text for the Make() method. 00392 // 00393 // Revision 1.45 2001/04/10 21:38:49 perev 00394 // Maki(int) --> IMake(int) 00395 // 00396 // Revision 1.44 2000/11/27 13:31:23 fisyak 00397 // Add Production time set 00398 // 00399 // Revision 1.43 2000/03/23 00:15:21 fine 00400 // Adjusted to libSTAR for ROOT 2.24 00401 // 00402 // Revision 1.42 1999/12/06 01:57:29 fine 00403 // Time statistic fixed 00404 // 00405 // Revision 1.41 1999/12/03 01:24:39 fine 00406 // Advanced timer has been introduced 00407 // 00408 // Revision 1.40 1999/07/14 15:26:18 fine 00409 // Context menu MakeEvent method has been introduced 00410 // 00411 // Revision 1.39 1999/07/13 02:19:33 perev 00412 // GetCVS,StEvtHddr,etc... 00413 // 00414 // Revision 1.38 1999/07/11 20:40:35 perev 00415 // Move Clear from StChain to StMaker 00416 // 00417 // Revision 1.37 1999/06/11 17:45:56 perev 00418 // assert StMaker::Streamer to forbid to write it 00419 // 00420 // Revision 1.36 1999/03/19 20:30:48 perev 00421 // GetCVSTag introduced 00422 // 00423 // Revision 1.35 1999/03/11 01:23:58 perev 00424 // new schema StChain 00425 // 00426 // Revision 1.23 1998/12/21 19:42:50 fisyak 00427 // Move ROOT includes to non system 00428 // 00429 // Revision 1.22 1998/11/29 20:01:09 fisyak 00430 // Fix typo with Run/run 00431 // 00432 // Revision 1.21 1998/11/25 21:58:21 fisyak 00433 // Cleanup 00434 // 00435 // Revision 1.20 1998/11/22 18:28:05 fisyak 00436 // Add name of tag 00437 // 00438 // Revision 1.19 1998/11/19 01:23:56 fine 00439 // StChain::MakeDoc has been introduced, StChain::MakeDoc has been fixed (see macros/bfc_doc.C macro 00440 // 00441 // Revision 1.18 1998/10/31 00:21:30 fisyak 00442 // Makers take care about branches 00443 // 00444 // Revision 1.17 1998/10/07 18:43:57 perev 00445 // Add Spy classes for Farm Monitor 00446 // 00447 // Revision 1.16 1998/10/06 18:00:26 perev 00448 // cleanup 00449 // 00450 // Revision 1.15 1998/09/23 20:22:51 fisyak 00451 // Prerelease SL98h 00452 // 00453 // Revision 1.14 1998/09/16 14:29:33 love 00454 // St_DataSetIter.h added 00455 // 00456 // Revision 1.13 1998/08/26 12:15:08 fisyak 00457 // Remove asu & dsl libraries 00458 // 00459 // Revision 1.12 1998/08/18 14:05:01 fisyak 00460 // Add to bfc dst 00461 // 00462 // Revision 1.11 1998/08/07 19:34:53 fisyak 00463 // Add St_run_Maker 00464 // 00465 // Revision 1.10 1998/07/23 21:03:30 fisyak 00466 // Add more comments 00467 // 00468 // Revision 1.9 1998/07/23 11:32:11 fisyak 00469 // Add comments 00470 // 00471 // Revision 1.8 1998/07/20 15:08:08 fisyak 00472 // Add tcl and tpt 00473 // 00474 // Revision 1.7 1998/07/19 21:16:29 fisyak 00475 // add log information 00476 // 00477 // Revision 1.6 1998/07/19 21:14:48 fisyak 00478 // add log information 00479 //