]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/EMCAL/AliHLTEMCALRawHistoMakerComponent.cxx
ALIROOT-5836 AliESDpid not respecting the AliVTrack interface (patch from Mihaela)
[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 << "\nI-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         for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
159         {
160           
161                 AliHLTCaloClusterHeaderStruct *caloClusterHeaderPtr = 0;
162                 AliHLTCaloChannelDataHeaderStruct* tmpChannelData = 0;
163
164                 iter = blocks+ndx;
165                 
166                 if (fBeVerbose) 
167                   PrintComponentDataTypeInfo(iter->fDataType);
168                 
169                 
170                 if (iter->fDataType == AliHLTEMCALDefinitions::fgkChannelDataType)
171                   {
172                   
173                     tmpChannelData = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(iter->fPtr);
174                                     
175                     if (fBeVerbose)
176                       printf ("\nI-RAWHISTOMAKERCOMPONENT: Number of active channels in block: %d\n",tmpChannelData->fNChannels);
177                     
178                   } 
179
180                 else if (iter->fDataType == kAliHLTDataTypeCaloCluster)
181                   caloClusterHeaderPtr = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(iter->fPtr);
182                     
183                 else
184                   
185                   {
186                     if (fBeVerbose)
187                       HLTWarning("\nI-RAWHISTOMAKERCOMPONENT: Data block does not of channel or cluster type \n");
188                     else
189                       HLTDebug("\nI-RAWHISTOMAKERCOMPONENT: Data block does not of channel or cluster type \n");
190                     continue;
191                   }
192
193         
194                 specification |= iter->fSpecification;
195                 ret = fRawHistoMakerPtr->MakeHisto(tmpChannelData, caloClusterHeaderPtr, fBeVerbose);
196
197         }
198
199
200         fLocalEventCount++;
201
202         TFile rootHistFile(fRootFileName,"recreate");
203         
204         fRawHistoMakerPtr->GetHistograms()->Write();
205         
206         if (fLocalEventCount%fPushFraction == 0) {
207           
208           if (fBeVerbose)
209             cout << "\nI-RAWHISTOMAKERCOMPONENT: pushback done at " << fLocalEventCount << " events " << endl;
210           
211           PushBack(fRawHistoMakerPtr->GetHistograms(), kAliHLTDataTypeTObjArray | kAliHLTDataOriginEMCAL , specification);
212         }
213         
214         size = mysize;
215         
216         return 0;
217 }
218
219
220 AliHLTComponent*
221 AliHLTEMCALRawHistoMakerComponent::Spawn()
222 {
223         //see header file for documentation
224         return new AliHLTEMCALRawHistoMakerComponent();
225 }