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