]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/EMCAL/AliHLTEMCALRawHistoMakerComponent.cxx
merged cluster and channel data
[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 #include "AliHLTCaloDefinitions.h"
25
26 #include "TString.h"
27
28
29
30 // root stuff
31 #include "TFile.h"
32 #include "TProfile2D.h"
33 #include "TH1F.h"
34 #include "TH2F.h"
35 #include <sys/stat.h>
36 #include <sys/types.h>
37
38 #include "AliCDBEntry.h"
39 #include "AliCDBManager.h"
40 #include "AliCDBPath.h"
41 /** 
42  * @file   AliHLTEMCALRawHistoMakerComponent.cxx
43  * @author Federico Ronchetti
44  * @date   
45  * @brief  A component to pusk back histograms for EMCAL HLT
46  */
47
48 //FIXME
49 AliHLTEMCALRawHistoMakerComponent gAliHLTEMCALRawHistoMakerComponent;
50
51 AliHLTEMCALRawHistoMakerComponent::AliHLTEMCALRawHistoMakerComponent() :
52                                   AliHLTCaloProcessor(),
53                                   fRawHistoMakerPtr(0),
54                                   fPushFraction(10),
55                                   fLocalEventCount(0),
56                                   fRootFileName("histofile_local.root"),
57                                   fBeVerbose(0)
58 {
59         //see header file for documentation
60 }
61
62
63 AliHLTEMCALRawHistoMakerComponent::~AliHLTEMCALRawHistoMakerComponent()
64 {
65         //see header file for documentation
66 }
67
68
69 int
70 AliHLTEMCALRawHistoMakerComponent::DoInit(int argc, const char** argv )
71 {
72         //see header file for documentation
73
74         fRawHistoMakerPtr = new AliHLTEMCALRawHistoMaker();
75
76         for(int i = 0; i < argc; i++)
77         {
78                 if(!strcmp("-roothistofilename", argv[i]))
79                         fRootFileName = argv[i+1];
80
81                 if(!strcmp("-pushfraction", argv[i]))
82                         fPushFraction = atoi(argv[i+1]);
83
84                 if(!strcmp("-beverbose", argv[i]))
85                         fBeVerbose = atoi(argv[i+1]);
86
87         }
88
89         if (fBeVerbose)
90                 cout << "I-RAWHISTOMAKERCOMPONENT: local root file name is: " << fRootFileName << endl;
91
92         return 0;
93 }
94
95
96 int 
97 AliHLTEMCALRawHistoMakerComponent::Deinit()
98
99         //see header file for documentation
100         if(fRawHistoMakerPtr)
101         {
102                 delete fRawHistoMakerPtr;
103                 fRawHistoMakerPtr = 0;
104         }
105
106         return 0;
107 }
108
109 const char*
110 AliHLTEMCALRawHistoMakerComponent::GetComponentID()
111 {
112         //see header file for documentation
113         return "EmcalRawHistoMaker";
114 }
115
116
117 void
118 AliHLTEMCALRawHistoMakerComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
119
120         //see header file for documentation
121         list.clear();
122         list.push_back(AliHLTEMCALDefinitions::fgkChannelDataType);
123 }
124
125 AliHLTComponentDataType 
126 AliHLTEMCALRawHistoMakerComponent::GetOutputDataType()
127 {
128         //see header file for documentation
129         return kAliHLTDataTypeHistogram | kAliHLTDataOriginEMCAL;
130 }
131
132 void 
133 AliHLTEMCALRawHistoMakerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
134 {
135         //see header file for documentation
136         constBase = 0;
137         // to be reviewed later
138         inputMultiplier = 100;
139 }
140
141 int 
142 AliHLTEMCALRawHistoMakerComponent::DoEvent(const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
143                 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size,
144                 std::vector<AliHLTComponentBlockData>& outputBlocks)
145 {
146         //see header file for documentation
147         UInt_t mysize           = 0;
148         Int_t ret               = 0;
149
150
151         AliHLTUInt8_t* outBPtr;
152         outBPtr = outputPtr;
153         const AliHLTComponentBlockData* iter = 0;
154         unsigned long ndx;
155
156         UInt_t specification = 0;
157         
158         AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
159         
160         AliHLTCaloClusterHeaderStruct *caloClusterHeaderPtr = 0;
161
162         for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
163         {
164                 iter = blocks+ndx;
165                 
166                 if (fBeVerbose) {
167                         PrintComponentDataTypeInfo(iter->fDataType);
168                         cout << "\nI-RAWHISTOMAKERCOMPONENT: verbose mode enabled:  " << fBeVerbose << endl;
169                 }
170
171                 
172                 if(iter->fDataType == kAliHLTDataTypeCaloCluster)
173                   {
174                     
175                     cout << "\nI-RAWHISTOMAKERCOMPONENT: cluster data handling HERE !" <<  endl;
176                     
177                     //specification |= iter->fSpecification;
178                     caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(iter->fPtr);
179                     cout << " --------------------> cluster pointer here !!!!!!!! ->>>>>>>>>>>>>>>>>>>>>: " << caloClusterHeaderPtr << endl;
180                   } 
181
182                 else 
183
184                   {
185                     
186                     if (fBeVerbose)
187                       HLTWarning("\nI-RAWHISTOMAKERCOMPONENT: Data block does not contain clusters\n");
188                     else
189                       HLTDebug("\nI-RAWHISTOMAKERCOMPONENT: Data block does not contain clusters\n");
190                     
191                     // continue;
192
193                   }
194
195
196                 if (iter->fDataType == AliHLTEMCALDefinitions::fgkChannelDataType)
197                   {
198                   
199
200                     tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
201                     cout << " --------------------> channel  pointer here !!!!!!!! ->>>>>>>>>>>>>>>>>>>>>: " << tmpChannelData  << endl;
202                     
203                     if (fBeVerbose)
204                       HLTWarning ("\nI-RAWHISTOMAKERCOMPONENT: reading channel number %d\n",tmpChannelData->fNChannels);
205
206                 
207                   } 
208                 
209                 else
210                   
211                   {
212                     if (fBeVerbose)
213                       HLTWarning("\nI-RAWHISTOMAKERCOMPONENT: Data block does not contain signal amplitude\n");
214                     else
215                       HLTDebug("\nI-RAWHISTOMAKERCOMPONENT: Data block does not contain signal amplitude\n");
216
217                     continue;
218           }
219
220         
221                 specification |= iter->fSpecification;
222                 ret = fRawHistoMakerPtr->MakeHisto(tmpChannelData, caloClusterHeaderPtr, fBeVerbose);
223
224         }
225
226         fLocalEventCount++;
227
228         TFile rootHistFile(fRootFileName,"recreate");
229         
230         fRawHistoMakerPtr->GetHistograms()->Write();
231         
232         if (fLocalEventCount%fPushFraction == 0) {
233           
234           if (fBeVerbose)
235             cout << "I-RAWHISTOMAKERCOMPONENT: pushback done at " << fLocalEventCount << " events " << endl;
236           
237           PushBack(fRawHistoMakerPtr->GetHistograms(), kAliHLTDataTypeTObjArray | kAliHLTDataOriginEMCAL , specification);
238         }
239         
240         size = mysize;
241         
242         return 0;
243 }
244
245
246 AliHLTComponent*
247 AliHLTEMCALRawHistoMakerComponent::Spawn()
248 {
249         //see header file for documentation
250         return new AliHLTEMCALRawHistoMakerComponent();
251 }