]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/trigger/AliHLTEmcalElectronMonitorComponent.cxx
48bdc689bda209204eb1904af0d9ef0b4ed6ab30
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTEmcalElectronMonitorComponent.cxx
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 {
119       if (fVerbose)  HLTWarning("FastJet Monitor: Data block does not contain event stats - check if flag is set for histograming for AliHLTTriggerFastJet \n");
120     }
121     
122     specification |= iter->fSpecification;
123     fHistoPtr->MakeHisto(scalarPtr);
124   }
125
126   fLocalEventCount++;
127     
128   TFile rootHistFile(fRootFileName, "RECREATE");
129   
130   fHistoPtr->GetHistograms()->Write();
131
132   if (fLocalEventCount%fPushFraction == 0) {
133     if (fVerbose) cout << "Emcal Electron Monitor: pushback done at " << fLocalEventCount << " evens " << endl;
134     PushBack(fHistoPtr->GetHistograms(), kAliHLTDataTypeTObjArray | kAliHLTDataOriginEMCAL, specification);
135   }
136   
137   return 0;
138 }
139 //____________________________________________________________________________________________________________
140
141 AliHLTComponent* AliHLTEmcalElectronMonitorComponent::Spawn()
142 {
143   // spawn
144
145   return new AliHLTEmcalElectronMonitorComponent();
146
147 }