]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/global/physics/AliHLTCaloHistoComponent.cxx
-Moved PHOS Physics histogram producers to HLT/global/physics
[u/mrichter/AliRoot.git] / HLT / global / physics / AliHLTCaloHistoComponent.cxx
1 //-*- Mode: C++ -*-
2  /**************************************************************************
3  * This file is property of and copyright by the ALICE HLT Project        *
4  * All rights reserved.                                                   *
5  *                                                                        *
6  * Primary Authors: Svein Lindal, Oeystein Djuvsland                      * 
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /** 
17  * @file   AliHLTCaloHistoComponent.cxx
18  * @author Svein Lindal
19  * @date   
20  * @brief  A physics histogram producer component for Calo HLT
21 */
22
23 #if __GNUC__>= 3
24 using namespace std;
25 #endif
26
27
28
29 #include "AliHLTCaloHistoComponent.h"
30 #include "AliHLTCaloHistoCellEnergy.h"
31 #include "AliHLTCaloHistoClusterEnergy.h"
32 #include "AliHLTCaloHistoInvMass.h"
33 #include "AliHLTCaloHistoMatchedTracks.h"
34 #include "AliESDEvent.h"
35 #include "TRefArray.h"
36
37 // see below for class documentation
38 // or
39 // refer to README to build package
40 // or
41 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
42
43
44 ClassImp(AliHLTCaloHistoComponent);
45
46 AliHLTCaloHistoComponent::AliHLTCaloHistoComponent() :
47   AliHLTProcessor(),
48   fEmcalClustersArray(NULL),
49   fPhosClustersArray(NULL),
50   fDoPhos(kFALSE), 
51   fDoEmcal(kFALSE),
52   fDoCellEnergy(kFALSE),
53   fDoClusterEnergy(kFALSE),
54   fDoInvariantMass(kFALSE),
55   fDoMatchedTracks(kFALSE),
56   fPhosCellEnergyHistProducer(NULL),
57   fEmcalCellEnergyHistProducer(NULL),
58   fPhosClusterEnergyHistProducer(NULL),
59   fEmcalClusterEnergyHistProducer(NULL),
60   fPhosInvariantMassHistProducer(NULL),
61   fEmcalInvariantMassHistProducer(NULL),
62   fPhosMatchedTracksHistProducer(NULL),
63   fEmcalMatchedTracksHistProducer(NULL)
64 {
65   //see header file for documentation
66 }
67
68 AliHLTCaloHistoComponent::~AliHLTCaloHistoComponent() 
69 {
70   //see header file for documentation
71   //Deinit();
72 }
73
74 Int_t AliHLTCaloHistoComponent::DoInit(int argc, const char** argv ) {
75   //see header file for documentation
76   
77
78   
79   for(int i = 0; i < argc; i++) {
80     if(!strcmp("-cellenergy", argv[i+1])) fDoCellEnergy = true;
81     if(!strcmp("-clusterenergy", argv[i+1])) fDoClusterEnergy = true;
82     if(!strcmp("-invariantmass", argv[i+1])) fDoInvariantMass= true;
83     if(!strcmp("-matchedtracks", argv[i+1])) fDoMatchedTracks = true;
84     if(!strcmp("-phos", argv[i+1])) fDoPhos = true;
85     if(!strcmp("-emcal", argv[i+1])) fDoEmcal = true;
86   }
87
88   
89   
90   //PHOS
91   if(fDoPhos){
92
93     fPhosClustersArray = new TRefArray();
94     
95     if(fDoInvariantMass) 
96       fPhosInvariantMassHistProducer = new AliHLTCaloHistoInvMass("PHOS");
97     
98     
99     if(fDoMatchedTracks)
100       fPhosMatchedTracksHistProducer = new AliHLTCaloHistoMatchedTracks("PHOS");
101   
102   
103     if(fDoClusterEnergy)
104       fPhosClusterEnergyHistProducer = new AliHLTCaloHistoClusterEnergy("PHOS");
105   
106   
107     if(fDoCellEnergy) 
108       fPhosCellEnergyHistProducer = new AliHLTCaloHistoCellEnergy("PHOS");
109
110   }
111   
112
113   //EMCAL
114   if(fDoEmcal) {
115
116     fEmcalClustersArray = new TRefArray();
117   
118     if(fDoInvariantMass)
119       fEmcalInvariantMassHistProducer = new AliHLTCaloHistoInvMass("EMCAL");
120
121     
122     if(fDoMatchedTracks)
123       fEmcalMatchedTracksHistProducer = new AliHLTCaloHistoMatchedTracks("EMCAL");
124
125   
126     if(fDoClusterEnergy)
127       fEmcalClusterEnergyHistProducer = new AliHLTCaloHistoClusterEnergy("EMCAL");
128     
129
130     if(fDoCellEnergy) 
131       fEmcalCellEnergyHistProducer = new AliHLTCaloHistoCellEnergy("EMCAL");
132     
133   }
134   
135   return 0;
136 }
137
138
139 Int_t AliHLTCaloHistoComponent::DoDeinit()
140
141   //see header file for documentation
142
143
144   //Clusters Arrays
145   if(fEmcalClustersArray)
146     delete fEmcalClustersArray;
147   fEmcalClustersArray = NULL;
148
149   if(fPhosClustersArray)
150     delete fPhosClustersArray;
151   fPhosClustersArray = NULL;
152
153
154   //CellEnergy
155   if(fPhosCellEnergyHistProducer)
156     delete fPhosCellEnergyHistProducer;
157   fPhosCellEnergyHistProducer = NULL;
158
159
160   if(fEmcalCellEnergyHistProducer)
161     delete fEmcalCellEnergyHistProducer;
162   fEmcalCellEnergyHistProducer = NULL;
163
164
165   //ClusterEnergy
166   if(fPhosClusterEnergyHistProducer)
167     delete fPhosClusterEnergyHistProducer;
168   fPhosClusterEnergyHistProducer = NULL;
169
170   if(fEmcalClusterEnergyHistProducer)
171     delete fEmcalClusterEnergyHistProducer;
172   fEmcalClusterEnergyHistProducer = NULL;
173
174
175   //Invariant mass histogram producers
176   if(fPhosInvariantMassHistProducer)
177     delete  fPhosInvariantMassHistProducer;
178   fPhosInvariantMassHistProducer = NULL;
179
180   if(fEmcalInvariantMassHistProducer)
181     delete  fEmcalInvariantMassHistProducer;
182   fEmcalInvariantMassHistProducer = NULL;
183
184
185   //Matched track histogram producers
186   if(fEmcalMatchedTracksHistProducer)
187     delete fEmcalMatchedTracksHistProducer;
188   fEmcalMatchedTracksHistProducer = NULL;
189
190   if(fPhosMatchedTracksHistProducer)
191     delete fPhosMatchedTracksHistProducer;
192   fPhosMatchedTracksHistProducer = NULL;
193
194
195   return 0;
196 }
197
198 const char* AliHLTCaloHistoComponent::GetComponentID()
199 {
200   //see header file for documentation
201   return "CaloPhysicsHistos";
202 }
203
204
205 void
206 AliHLTCaloHistoComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
207
208   //see header file for documentation
209   list.clear();
210   list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut );
211   //   list.push_back(AliHLTPHOSDefinitions::fgkClusterDataType);
212 //   list.push_back(AliHLTPHOSDefinitions::fgkESDCaloClusterDataType);
213 //   list.push_back(AliHLTPHOSDefinitions::fgkESDCaloCellsDataType);
214
215 }
216
217 AliHLTComponentDataType AliHLTCaloHistoComponent::GetOutputDataType()
218 {
219   //see header file for documentation
220   return kAliHLTDataTypeHistogram  | kAliHLTDataOriginOut;
221 }
222
223
224 void AliHLTCaloHistoComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
225 {
226   //see header file for documentation
227   constBase = 30;
228   inputMultiplier = 5;
229 }
230
231 AliHLTComponent* AliHLTCaloHistoComponent::Spawn() {
232   //see header file for documentation
233   return new AliHLTCaloHistoComponent();
234 }
235
236 Int_t AliHLTCaloHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) {
237
238   //see header file for documentation
239   if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
240     return 0;
241   
242 //   if( fUID == 0 ){
243 //     TTimeStamp t;
244 //     fUID = ( gSystem->GetPid() + t.GetNanoSec())*10 + evtData.fEventID;
245 //   }
246
247
248   for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) {
249     AliESDEvent *event = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
250
251     
252     //EMCAL
253     if(fDoEmcal){
254  
255       Int_t nec = event->GetEMCALClusters(fEmcalClustersArray);
256       
257       if(fDoMatchedTracks)
258         fEmcalMatchedTracksHistProducer->FillHistograms(nec, fEmcalClustersArray);
259       
260       if(fDoInvariantMass)
261         fEmcalInvariantMassHistProducer->FillHistograms(nec, fEmcalClustersArray);
262     
263       if(fDoClusterEnergy)
264         fEmcalClusterEnergyHistProducer->FillHistograms(nec, fEmcalClustersArray);
265    
266       if(fDoCellEnergy)
267         fEmcalCellEnergyHistProducer->FillHistograms(nec, fEmcalClustersArray);;
268    
269     }
270
271
272     //PHOS
273     if(fDoPhos){
274       
275       Int_t npc = event->GetPHOSClusters(fPhosClustersArray);
276       
277       if(fDoMatchedTracks)
278         fPhosMatchedTracksHistProducer->FillHistograms(npc, fPhosClustersArray);
279       
280       if(fDoInvariantMass)
281         fPhosInvariantMassHistProducer->FillHistograms(npc, fPhosClustersArray);
282
283       if(fDoClusterEnergy)
284         fPhosClusterEnergyHistProducer->FillHistograms(npc, fPhosClustersArray);
285
286       if(fDoCellEnergy)
287         fPhosCellEnergyHistProducer->FillHistograms(npc, fPhosClustersArray);
288    
289     }
290       
291   }
292
293   
294   //Push histos
295   
296   //PHOS
297   if(fDoPhos){
298     
299     if(fDoInvariantMass)
300       PushBack(fPhosInvariantMassHistProducer->GetHistograms(), kAliHLTDataTypeHistogram);
301     
302     if(fDoMatchedTracks)
303       PushBack(fPhosMatchedTracksHistProducer->GetHistograms(), kAliHLTDataTypeHistogram);
304
305     if(fDoClusterEnergy) 
306       PushBack(fPhosClusterEnergyHistProducer->GetHistograms(), kAliHLTDataTypeHistogram);
307
308     if(fDoCellEnergy)
309       PushBack(fPhosCellEnergyHistProducer->GetHistograms(), kAliHLTDataTypeHistogram);
310     
311   }
312
313   //EMCAL
314   if(fDoEmcal) {
315
316     if(fDoInvariantMass) 
317       PushBack(fEmcalInvariantMassHistProducer->GetHistograms(), kAliHLTDataTypeHistogram);
318         
319     if(fDoMatchedTracks) 
320       PushBack(fEmcalMatchedTracksHistProducer->GetHistograms(), kAliHLTDataTypeHistogram);
321   
322     if(fDoClusterEnergy) 
323       PushBack(fEmcalClusterEnergyHistProducer->GetHistograms(), kAliHLTDataTypeHistogram);
324     
325     if(fDoCellEnergy)
326       PushBack(fEmcalCellEnergyHistProducer->GetHistograms(), kAliHLTDataTypeHistogram);
327     
328   }
329
330   return 0;
331
332 }
333
334
335
336