00001 #ifndef EVENT_LOOP_WORKER_HH
00002 #define EVENT_LOOP_WORKER_HH
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00018
00019
00020
00021 #include <EventLoop/Global.h>
00022
00023 #include <map>
00024 #include <memory>
00025 #include <vector>
00026 #include <Rtypes.h>
00027 #include <TList.h>
00028 #include <SampleHandler/Global.h>
00029
00030 class TFile;
00031 class TH1;
00032 class TString;
00033 class TTree;
00034 class TStopwatch;
00035
00036 namespace D3PDReader
00037 {
00038 class Event;
00039 }
00040
00041 namespace xAOD
00042 {
00043 class TEvent;
00044 class TStore;
00045 }
00046
00047 namespace EL
00048 {
00049 class Worker
00050 {
00051
00052
00053
00054
00057 public:
00058 void testInvariant () const;
00059
00060
00064 public:
00065 virtual ~Worker ();
00066
00067
00077 public:
00078 void addOutput (TObject *output_swallow);
00079
00080
00091 public:
00092 void addOutputList (const std::string& name, TObject *output_swallow);
00093
00094
00104 public:
00105 TH1 *getOutputHist (const std::string& name) const;
00106
00107
00117 public:
00118 TFile *getOutputFile (const std::string& label) const;
00119
00120
00134 public:
00135 TFile *getOutputFileNull (const std::string& label) const;
00136
00137
00142 public:
00143 const SH::MetaObject *metaData () const;
00144
00145
00148 public:
00149 TTree *tree () const;
00150
00151
00154 public:
00155 Long64_t treeEntry () const;
00156
00157
00160 public:
00161 TFile *inputFile () const;
00162
00163
00168 public:
00169 std::string inputFileName () const;
00170
00171
00176 public:
00177 TTree *triggerConfig () const;
00178
00179
00185 public:
00186 D3PDReader::Event *d3pdreader () const;
00187
00188
00194 public:
00195 xAOD::TEvent *xaodEvent () const;
00196 xAOD::TStore *xaodStore () const;
00197
00198
00202 public:
00203 bool hasD3pdreader () const;
00204
00205
00210 public:
00211 EL::Algorithm *getAlg (const std::string& name) const;
00212
00213
00221 public:
00222 void skipEvent ();
00223
00224
00225
00226
00227
00228
00229
00237 protected:
00238 Worker (const SH::MetaObject *val_metaData, TList *output);
00239
00240
00246 protected:
00247 void addOutputFile (const std::string& label, TFile *file_swallow);
00248 void addOutputWriter (const std::string& label,
00249 SH::DiskWriter *writer_swallow);
00250
00251
00256 protected:
00257 void addAlg (EL::Algorithm *alg_swallow);
00258
00259
00267 protected:
00268 void algsChangeInput ();
00269
00270
00277 protected:
00278 void algsExecute ();
00279
00280
00292 protected:
00293 void algsEndOfFile ();
00294
00295
00301 protected:
00302 void algsFinalize ();
00303
00304
00306 protected:
00307 void treeEntry (Long64_t val_treeEntry);
00308
00309
00318 protected:
00319 void setInputFile (TFile *val_inputFile);
00320
00321
00331 protected:
00332 void setTreeProofOnly (TTree *val_tree);
00333
00334
00339 protected:
00340 Long64_t inputFileNumEntries () const;
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00355 private:
00356 const SH::MetaObject *m_metaData = nullptr;
00357
00359 private:
00360 TFile *m_inputFile = nullptr;
00361
00363 private:
00364 TTree *m_tree = nullptr;
00365
00366 private:
00367 Long64_t m_treeEntry;
00368
00370 private:
00371 TList *m_output = nullptr;
00372
00373
00375 private:
00376 typedef std::map<std::string,TH1*>::const_iterator OutputHistMapIter;
00377 std::map<std::string,TH1*> m_outputHistMap;
00378
00379
00381 private:
00382 typedef std::map<std::string,SH::DiskWriter*>::const_iterator outputFilesIter;
00383 std::map<std::string,SH::DiskWriter*> m_outputFiles;
00384
00385
00387 private:
00388 typedef std::vector<EL::Algorithm*>::const_iterator algsIter;
00389 std::vector<EL::Algorithm*> m_algs;
00390
00391
00393 private:
00394 TH1 *m_eventCount = nullptr;
00395
00396
00398 private:
00399 TH1 *m_runTime = nullptr;
00400
00401
00404 private:
00405 TTree *m_fileExecutedTree = nullptr;
00406
00409 private:
00410 TString *m_fileExecutedName = nullptr;
00411
00412
00414 private:
00415 bool m_skipEvent;
00416
00417
00419 private:
00420 std::unique_ptr<TStopwatch> m_stopwatch;
00421
00422
00424 private:
00425 enum AlgInitState
00426 {
00429 AIS_NEW,
00430
00433 AIS_HIST_INITIALIZED,
00434
00437 AIS_INITIALIZED,
00438
00441 AIS_FINALIZED,
00442
00445 AIS_HIST_FINALIZED,
00446
00450 AIS_NONE
00451 };
00452
00454 private:
00455 AlgInitState m_initState;
00456
00457
00459 private:
00460 enum AlgExecState
00461 {
00464 AES_BLANK,
00465
00468 AES_FILE_EXECUTED,
00469
00472 AES_INPUT_CHANGED,
00473
00477 AES_NONE
00478 };
00479
00481 private:
00482 AlgExecState m_execState;
00483
00484
00486 private:
00487 enum InputState
00488 {
00490 VALID_NONE,
00491
00494 VALID_FILE,
00495
00497 VALID_EVENT
00498 };
00499
00500
00507 private:
00508 void changeAlgState (AlgInitState targetInit, AlgExecState targetExec,
00509 InputState inputState);
00510 };
00511 }
00512
00513 #endif