Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
OTFReader.cxx
1/*
2 * OTFReader.cxx
3 *
4 * Created on: 28 maj 2022
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "OTFReader.h"
11#include "OTFComplexEvent.h"
12#include "OTFMcEvent.h"
13#include "OTFRecoEvent.h"
14
15#include "Cout.h"
16#include "DataManager.h"
17#include "Event.h"
18#include "McTrack.h"
19#include "OTFData.h"
20#include "Std.h"
21
22#include <TDatabasePDG.h>
23#include <TLorentzVector.h>
24#include <TMath.h>
25#include <TMathBase.h>
26#include <TParticlePDG.h>
27#include <TRandom.h>
28#include <TString.h>
29
30namespace HalOTF {
31 Reader::Reader() : fMcEvent(nullptr), fRecoEvent(nullptr) {}
32
33 Hal::Task::EInitFlag Reader::Init() {
34 fMcEvent = new OTF::McEvent();
35 fRecoEvent = new OTF::RecoEvent();
36 Hal::DataManager* mng = Hal::DataManager::Instance();
37 if (mng->GetObject("OTF::McEvent.")) { // branch exists
38 fMcEvent = (OTF::McEvent*) mng->GetObject("OTF::McEvent.");
39 fRecoEvent = (OTF::RecoEvent*) mng->GetObject("OTF::RecoEvent.");
40 }
41 if (!fMcEvent) {
42 Hal::Cout::PrintInfo(Form("%s %d lack of mc-event", __FILE__, __LINE__), Hal::EInfo::kError);
43 return Hal::Task::EInitFlag::kERROR;
44 }
45 if (!fRecoEvent) {
46 Hal::Cout::PrintInfo(Form("%s %d lack of reco-event", __FILE__, __LINE__), Hal::EInfo::kError);
47 return Hal::Task::EInitFlag::kERROR;
48 }
49
50 switch (fTranslate) {
51 case ETranslate::kMc: {
52 if (mng->GetObject("HalOTF::McEvent.")) {
53 return Hal::Task::EInitFlag::kERROR;
54 } else {
55 fHalMcEvent = new HalOTF::McEvent();
56 mng->Register("HalEvent.", "HalEvents", fHalMcEvent, kFALSE);
57 fTranslateInterface = fHalMcEvent->CreateInterface();
58 }
59 } break;
60 case ETranslate::kReco: {
61 if (mng->GetObject("HalOTF::RecoEvent.")) {
62 return Hal::Task::EInitFlag::kERROR;
63 } else {
64 fHalRecoEvent = new HalOTF::RecoEvent();
65 mng->Register("HalEvent.", "HalEvents", fHalRecoEvent, kFALSE);
66 fTranslateInterface = fHalRecoEvent->CreateInterface();
67 }
68 } break;
69 case ETranslate::kComplex: {
70 if (mng->GetObject("HalOTF::ComplexEvent.")) {
71 return Hal::Task::EInitFlag::kERROR;
72 } else {
73 fHalComplexEvent = new HalOTF::ComplexEvent();
74 mng->Register("HalEvent.", "HalEvents", fHalComplexEvent, kFALSE);
75 fTranslateInterface = fHalComplexEvent->CreateInterface();
76 }
77 } break;
78 default: break;
79 }
80 if (fTranslateInterface) fTranslateInterface->ConnectToTree(Hal::EventInterface::eMode::kRead);
81 return Hal::Task::EInitFlag::kSUCCESS;
82 }
83
84 void Reader::Exec(Option_t* /*opt*/) {
85 if (fTranslate != ETranslate::kNone) {
86 switch (fTranslate) {
87 case ETranslate::kMc: {
88 fHalMcEvent->Update(fTranslateInterface);
89 } break;
90 case ETranslate::kReco: {
91 fHalRecoEvent->Update(fTranslateInterface);
92 } break;
93 case ETranslate::kComplex: {
94 fHalComplexEvent->Update(fTranslateInterface);
95 } break;
96 default: break;
97 }
98 }
99 }
100
101 Reader::~Reader() {}
102
103 void Reader::Translate(TString opt) {
104 Int_t flag = 0;
105 if (Hal::Std::FindParam(opt, "sim")) { flag = 1; }
106 if (Hal::Std::FindParam(opt, "reco")) { flag += 2; }
107 switch (flag) {
108 case 1: fTranslate = ETranslate::kMc; break;
109 case 2: fTranslate = ETranslate::kReco; break;
110 case 3: fTranslate = ETranslate::kComplex; break;
111 }
112 }
113
114} // namespace HalOTF
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370
void Register(const char *name, const char *folderName, TNamed *obj, Bool_t toFile)