]>
Commit | Line | Data |
---|---|---|
93654f63 | 1 | #include "AliHLTEmcalElectronMonitorComponent.h" |
2 | #include "AliHLTEmcalElectronMonitor.h" | |
3 | #include "AliHLTScalars.h" | |
4 | ||
5 | #include "TFile.h" | |
6 | #include "TString.h" | |
7 | ||
8 | AliHLTEmcalElectronMonitorComponent::AliHLTEmcalElectronMonitorComponent() : | |
9 | fRootFileName("EmcalElectrontrigger_histos.root"), | |
10 | fPushFraction(10), | |
11 | fLocalEventCount(0), | |
12 | fVerbose(0), | |
13 | fHistoPtr(NULL) | |
14 | { | |
15 | ||
16 | // default constructor | |
17 | ||
18 | } | |
19 | //____________________________________________________________________________________________________________ | |
20 | ||
21 | AliHLTEmcalElectronMonitorComponent::~AliHLTEmcalElectronMonitorComponent() | |
22 | { | |
23 | ||
24 | // default destructor | |
25 | ||
26 | } | |
27 | //____________________________________________________________________________________________________________ | |
28 | ||
29 | int AliHLTEmcalElectronMonitorComponent::DoInit(int argc, const char **argv) | |
30 | { | |
31 | // initialize | |
32 | ||
33 | fHistoPtr = new AliHLTEmcalElectronMonitor(); | |
34 | for (int i = 0; i < argc; i++) { | |
35 | if (!strcmp("-roothistofilename", argv[i])) | |
36 | fRootFileName = argv[i+1]; | |
37 | if (!strcmp("-pushfraction", argv[i])) | |
38 | fPushFraction = atoi(argv[i+1]); | |
39 | if (!strcmp("-verbose", argv[i])) | |
40 | fVerbose = atoi(argv[i+1]); | |
41 | } | |
42 | ||
43 | return 0; | |
44 | ||
45 | } | |
46 | //____________________________________________________________________________________________________________ | |
47 | ||
48 | int AliHLTEmcalElectronMonitorComponent::Deinit() | |
49 | { | |
50 | // de-initialize | |
51 | ||
52 | if (fHistoPtr) { | |
53 | delete fHistoPtr; | |
54 | fHistoPtr = NULL; | |
55 | } | |
56 | return 0; | |
57 | ||
58 | } | |
59 | //____________________________________________________________________________________________________________ | |
60 | const char* AliHLTEmcalElectronMonitorComponent::GetComponentID() | |
61 | { | |
62 | // component id | |
63 | ||
64 | return "EmcalElectronMonitor"; | |
65 | ||
66 | } | |
67 | //____________________________________________________________________________________________________________ | |
68 | ||
69 | void AliHLTEmcalElectronMonitorComponent::GetInputDataTypes(vector<AliHLTComponentDataType> &list) | |
70 | { | |
71 | // define input data types | |
72 | ||
73 | list.clear(); | |
74 | list.push_back(kAliHLTDataTypeEventStatistics|kAliHLTDataOriginHLT); | |
75 | ||
76 | } | |
77 | //____________________________________________________________________________________________________________ | |
78 | ||
79 | AliHLTComponentDataType AliHLTEmcalElectronMonitorComponent::GetOutputDataType() | |
80 | { | |
81 | ||
82 | // return output data types | |
83 | ||
84 | return kAliHLTDataTypeHistogram | kAliHLTDataOriginEMCAL; | |
85 | ||
86 | } | |
87 | //____________________________________________________________________________________________________________ | |
88 | ||
89 | void AliHLTEmcalElectronMonitorComponent::GetOutputDataSize(unsigned long &constBase, double &inputMultiplier) | |
90 | { | |
91 | ||
92 | // calculate output data size | |
93 | ||
94 | constBase = 0; | |
95 | inputMultiplier = 100; | |
96 | ||
97 | } | |
98 | //____________________________________________________________________________________________________________ | |
99 | ||
100 | int AliHLTEmcalElectronMonitorComponent::DoEvent(const AliHLTComponentEventData &evtData, const AliHLTComponentBlockData *blocks, | |
101 | AliHLTComponentTriggerData &/*trigData*/, AliHLTUInt8_t */*outputPtr*/, AliHLTUInt32_t &/*size*/, | |
102 | std::vector<AliHLTComponentBlockData> &/*outputBlocks*/) | |
103 | { | |
104 | ||
105 | // do event | |
106 | ||
107 | const AliHLTComponentBlockData *iter = NULL; | |
108 | UInt_t specification = 0; | |
109 | ||
110 | for (unsigned long ij = 0; ij < evtData.fBlockCnt; ij++) { | |
111 | AliHLTScalars *scalarPtr = NULL; | |
112 | iter = blocks + ij; | |
113 | if (fVerbose) PrintComponentDataTypeInfo(iter->fDataType); | |
114 | ||
115 | if (iter->fDataType == kAliHLTDataTypeEventStatistics) { | |
116 | scalarPtr = reinterpret_cast<AliHLTScalars*>(iter->fPtr); | |
117 | } | |
118 | else { | |
93bfb33c | 119 | if (fVerbose) HLTWarning("Electron Monitor: Data block does not contain event stats - check if flag is set for histograming for AliHLTEmcalElectronTrigger \n"); |
93654f63 | 120 | } |
121 | ||
122 | specification |= iter->fSpecification; | |
93bfb33c | 123 | |
124 | if (scalarPtr) | |
125 | fHistoPtr->MakeHisto(scalarPtr); | |
93654f63 | 126 | } |
127 | ||
128 | fLocalEventCount++; | |
129 | ||
130 | TFile rootHistFile(fRootFileName, "RECREATE"); | |
131 | ||
132 | fHistoPtr->GetHistograms()->Write(); | |
133 | ||
134 | if (fLocalEventCount%fPushFraction == 0) { | |
135 | if (fVerbose) cout << "Emcal Electron Monitor: pushback done at " << fLocalEventCount << " evens " << endl; | |
136 | PushBack(fHistoPtr->GetHistograms(), kAliHLTDataTypeTObjArray | kAliHLTDataOriginEMCAL, specification); | |
137 | } | |
138 | ||
139 | return 0; | |
140 | } | |
141 | //____________________________________________________________________________________________________________ | |
142 | ||
143 | AliHLTComponent* AliHLTEmcalElectronMonitorComponent::Spawn() | |
144 | { | |
145 | // spawn | |
146 | ||
147 | return new AliHLTEmcalElectronMonitorComponent(); | |
148 | ||
149 | } |