]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/EMCAL/AliHLTEMCALRawHistoMakerComponent.cxx
test macro to run the EMCAL HLT chain in AliRoot
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALRawHistoMakerComponent.cxx
1
2
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        *
5  * All rights reserved.                                                   *
6  * INFN, Laboratori Nazionali di Frascati                                 *
7  * Primary Authors: Federico Ronchetti                                    *
8  *                                                                        *
9  * Permission to use, copy, modify and distribute this software and its   *
10  * documentation strictly for non-commercial purposes is hereby granted   *
11  * without fee, provided that the above copyright notice appears in all   *
12  * copies and that both the copyright notice and this permission notice   *
13  * appear in the supporting documentation. The authors make no claims     *
14  * about the suitability of this software for any purpose. It is          *
15  * provided "as is" without express or implied warranty.                  *
16  **************************************************************************/
17
18 #include "AliHLTEMCALRawHistoMakerComponent.h"
19 #include "AliHLTEMCALRawHistoMaker.h"
20
21 #include "AliHLTCaloChannelDataHeaderStruct.h"
22 #include "AliHLTCaloChannelDataStruct.h"
23
24 // root stuff
25 #include "TFile.h"
26 #include "TProfile2D.h"
27 #include "TH1F.h"
28 #include "TH2F.h"
29 #include <sys/stat.h>
30 #include <sys/types.h>
31
32 #include "AliCDBEntry.h"
33 #include "AliCDBManager.h"
34 #include "AliCDBPath.h"
35 /** 
36  * @file   AliHLTEMCALRawHistoMakerComponent.cxx
37  * @author Federico Ronchetti
38  * @date   
39  * @brief  A component to pusk back histograms for EMCAL HLT
40  */
41
42 //FIXME
43 AliHLTEMCALRawHistoMakerComponent gAliHLTEMCALRawHistoMakerComponent;
44
45 AliHLTEMCALRawHistoMakerComponent::AliHLTEMCALRawHistoMakerComponent() :
46                                   AliHLTCaloProcessor(),
47                                   fRawHistoMakerPtr(0),
48                                   fPushFraction(10),
49                                   fLocalEventCount(0),
50                                   fRootFileName("histofile_local.root"),
51                                   fBeVerbose(0)
52 {
53         //see header file for documentation
54 }
55
56
57 AliHLTEMCALRawHistoMakerComponent::~AliHLTEMCALRawHistoMakerComponent()
58 {
59         //see header file for documentation
60 }
61
62 int 
63 AliHLTEMCALRawHistoMakerComponent::Deinit()
64
65         //see header file for documentation
66         if(fRawHistoMakerPtr)
67         {
68                 delete fRawHistoMakerPtr;
69                 fRawHistoMakerPtr = 0;
70         }
71
72         return 0;
73 }
74
75 const char*
76 AliHLTEMCALRawHistoMakerComponent::GetComponentID()
77 {
78         //see header file for documentation
79         return "EmcalRawHistoMaker";
80 }
81
82
83 void
84 AliHLTEMCALRawHistoMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
85
86         //see header file for documentation
87         list.clear();
88         list.push_back(AliHLTEMCALDefinitions::fgkChannelDataType);
89 }
90
91 AliHLTComponentDataType 
92 AliHLTEMCALRawHistoMakerComponent::GetOutputDataType()
93 {
94         //see header file for documentation
95         return kAliHLTDataTypeHistogram | kAliHLTDataOriginEMCAL;
96 }
97
98 void 
99 AliHLTEMCALRawHistoMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
100 {
101         //see header file for documentation
102         constBase = 0;
103         // to be reviewed later
104         inputMultiplier = 100;
105 }
106
107 int 
108 AliHLTEMCALRawHistoMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
109                 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
110                 std::vector<AliHLTComponentBlockData>& outputBlocks)
111 {
112         //see header file for documentation
113         UInt_t mysize           = 0;
114         Int_t ret               = 0;
115
116
117         AliHLTUInt8_t* outBPtr;
118         outBPtr = outputPtr;
119         const AliHLTComponentBlockData* iter = 0;
120         unsigned long ndx;
121
122         UInt_t specification = 0;
123         AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
124
125
126         for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
127         {
128                 iter = blocks+ndx;
129
130                 if (fBeVerbose) {
131                         PrintComponentDataTypeInfo(iter->fDataType);
132                         cout << "I-RAWHISTOMAKERCOMPONENT: verbose mode enabled:  " << fBeVerbose << endl;
133                 }
134
135                 if(iter->fDataType != AliHLTEMCALDefinitions::fgkChannelDataType)
136                 {
137
138                         if (fBeVerbose)
139                                 HLTWarning("I-RAWHISTOMAKERCOMPONENT: Data block is not of type fgkChannelDataType");
140                         else
141                                 HLTDebug("I-RAWHISTOMAKERCOMPONENT: Data block is not of type fgkChannelDataType");
142
143                         continue;
144                 }
145
146                 specification |= iter->fSpecification;
147                 tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
148
149                 if (fBeVerbose)
150                 HLTWarning ("I-RAWHISTOMAKERCOMPONENT: channel number %d",tmpChannelData->fNChannels);
151
152                 ret = fRawHistoMakerPtr->MakeHisto(tmpChannelData, iter, outputPtr, size, fBeVerbose);
153
154                 //if(ret == -1)
155                 //{
156                 //  HLTError("Trying to write over buffer size");
157                 //  return -ENOBUFS;
158                 //}
159                 //digitCount += ret;
160         }
161
162         fLocalEventCount++;
163
164         TFile rootHistFile(fRootFileName,"recreate");
165
166         fRawHistoMakerPtr->GetHistograms()->Write();
167
168         if (fLocalEventCount%fPushFraction == 0) {
169
170                 if (fBeVerbose)
171                         cout << "I-RAWHISTOMAKERCOMPONENT: pushback done at " << fLocalEventCount << " events " << endl;
172
173                 PushBack(fRawHistoMakerPtr->GetHistograms(), kAliHLTDataTypeTObjArray | kAliHLTDataOriginEMCAL , specification);
174         }
175
176         size = mysize;
177
178         return 0;
179 }
180
181
182 int
183 AliHLTEMCALRawHistoMakerComponent::DoInit(int argc, const char** argv )
184 {
185         //see header file for documentation
186
187         fRawHistoMakerPtr = new AliHLTEMCALRawHistoMaker();
188
189         for(int i = 0; i < argc; i++)
190         {
191                 if(!strcmp("-roothistofilename", argv[i]))
192                         fRootFileName = argv[i+1];
193
194                 if(!strcmp("-pushfraction", argv[i]))
195                         fPushFraction = atoi(argv[i+1]);
196
197                 if(!strcmp("-beverbose", argv[i]))
198                         fBeVerbose = atoi(argv[i+1]);
199
200         }
201
202         if (fBeVerbose)
203                 cout << "I-RAWHISTOMAKERCOMPONENT: local root file name is: " << fRootFileName << endl;
204
205         return 0;
206 }
207
208
209 AliHLTComponent*
210 AliHLTEMCALRawHistoMakerComponent::Spawn()
211 {
212         //see header file for documentation
213         return new AliHLTEMCALRawHistoMakerComponent();
214 }