]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/physics/AliHLTCaloHistoComponent.cxx
changed logging levels of calo histo producer init
[u/mrichter/AliRoot.git] / HLT / global / physics / AliHLTCaloHistoComponent.cxx
CommitLineData
766aafea 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
24using namespace std;
25#endif
26
27
766aafea 28#include "AliHLTCaloHistoComponent.h"
29#include "AliHLTCaloHistoCellEnergy.h"
30#include "AliHLTCaloHistoClusterEnergy.h"
31#include "AliHLTCaloHistoInvMass.h"
32#include "AliHLTCaloHistoMatchedTracks.h"
33#include "AliESDEvent.h"
34#include "TRefArray.h"
e0cde76d 35#include "AliHLTCaloClusterDataStruct.h"
36#include "AliHLTCaloClusterReader.h"
ce063697 37#include "TObjArray.h"
766aafea 38
39// see below for class documentation
40// or
41// refer to README to build package
42// or
43// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
44
45
ce063697 46AliHLTCaloHistoComponent gAliHLTCaloHistoComponent;
47
766aafea 48ClassImp(AliHLTCaloHistoComponent);
49
50AliHLTCaloHistoComponent::AliHLTCaloHistoComponent() :
51 AliHLTProcessor(),
ce063697 52 fClusterReader(NULL),
766aafea 53 fEmcalClustersArray(NULL),
54 fPhosClustersArray(NULL),
ce063697 55 fPhosHistogramArray(NULL),
56 fEmcalHistogramArray(NULL),
766aafea 57 fDoEmcal(kFALSE),
ce063697 58 fDoPhos(kFALSE)
766aafea 59{
60 //see header file for documentation
61}
62
63AliHLTCaloHistoComponent::~AliHLTCaloHistoComponent()
64{
65 //see header file for documentation
66 //Deinit();
67}
68
69Int_t AliHLTCaloHistoComponent::DoInit(int argc, const char** argv ) {
70 //see header file for documentation
71
766aafea 72
ce063697 73 fEmcalHistogramArray = new TObjArray();
74 fEmcalHistogramArray->SetOwner(kTRUE);
75 fPhosHistogramArray = new TObjArray();
76 fPhosHistogramArray->SetOwner(kTRUE);
766aafea 77
ce063697 78 bool doPhos = true;
79 bool doEmcal = true;
766aafea 80
766aafea 81
ce063697 82 for(int i = 0; i < argc; i++) {
766aafea 83
ce063697 84 if(!strcmp("-phos", argv[i])) {
85 fDoPhos = kTRUE;
86 doPhos = true;
87 doEmcal = false;
88 }
89 if(!strcmp("-emcal", argv[i])) {
90 fDoEmcal = kTRUE;
91 doEmcal = true;
92 doPhos = false;
93 }
94 if(!strcmp("-both", argv[i])) {
95 fDoEmcal = kTRUE;
96 fDoPhos = kTRUE;
97 doEmcal = true;
98 doPhos = true;
99 }
766aafea 100
ce063697 101 if(!strcmp("-clusterenergy", argv[i])){
102 if(doEmcal){
103 AliHLTCaloHistoClusterEnergy * histo = new AliHLTCaloHistoClusterEnergy("EMCAL");
104 fEmcalHistogramArray->AddLast(dynamic_cast<TObject*>(histo));
34788787 105 HLTImportant("Adding EMCAL cluster energy histogram");
ce063697 106 }
107 if(doPhos){
108 AliHLTCaloHistoClusterEnergy * histo = new AliHLTCaloHistoClusterEnergy("PHOS");
109 fPhosHistogramArray->AddLast(dynamic_cast<TObject*>(histo));
34788787 110 HLTImportant("Adding PHOS cluster energy histogram");
ce063697 111 }
112 }
113
114 if(!strcmp("-invariantmass", argv[i])){
115 if(doEmcal){
116 AliHLTCaloHistoInvMass * histo = new AliHLTCaloHistoInvMass("EMCAL");
117 fEmcalHistogramArray->AddLast(dynamic_cast<TObject*>(histo));
34788787 118 HLTImportant("Adding EMCAL invariant mass histogram");
ce063697 119 }
120 if(doPhos){
121 AliHLTCaloHistoInvMass * histo = new AliHLTCaloHistoInvMass("PHOS");
122 fPhosHistogramArray->AddLast(dynamic_cast<TObject*>(histo));
34788787 123 HLTImportant("Adding PHOS invariant mass histogram");
ce063697 124 }
125 }
126
127 if(!strcmp("-matchedtracks", argv[i])) {
128 if(doEmcal){
129 AliHLTCaloHistoMatchedTracks * histo = new AliHLTCaloHistoMatchedTracks("EMCAL");
130 fEmcalHistogramArray->AddLast(dynamic_cast<TObject*>(histo));
34788787 131 HLTImportant("Adding EMCAL track-matching histograms");
ce063697 132 }
133 if(doPhos){
134 AliHLTCaloHistoMatchedTracks * histo = new AliHLTCaloHistoMatchedTracks("PHOS");
135 fPhosHistogramArray->AddLast(dynamic_cast<TObject*>(histo));
34788787 136 HLTImportant("Adding PHOS track-matching histograms");
ce063697 137 }
138 }
766aafea 139 }
ce063697 140
141 if(fDoPhos)
142 fPhosClustersArray = new TRefArray();
143 if(fDoEmcal)
144 fEmcalClustersArray = new TRefArray();
766aafea 145
e0cde76d 146 fClusterReader = new AliHLTCaloClusterReader();
ce063697 147
766aafea 148 return 0;
149}
150
151
152Int_t AliHLTCaloHistoComponent::DoDeinit()
153{
154 //see header file for documentation
155
766aafea 156 if(fEmcalClustersArray)
157 delete fEmcalClustersArray;
158 fEmcalClustersArray = NULL;
159
160 if(fPhosClustersArray)
161 delete fPhosClustersArray;
162 fPhosClustersArray = NULL;
163
ce063697 164 //Deleting these should also destroy histograms!!?
165 if(fEmcalHistogramArray)
166 delete fEmcalHistogramArray;
167 fEmcalHistogramArray = NULL;
168
169 if(fPhosHistogramArray)
170 delete fPhosHistogramArray;
171 fPhosHistogramArray = NULL;
172
766aafea 173 return 0;
174}
175
176const char* AliHLTCaloHistoComponent::GetComponentID()
177{
178 //see header file for documentation
179 return "CaloPhysicsHistos";
180}
181
182
183void
184AliHLTCaloHistoComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
185{
186 //see header file for documentation
187 list.clear();
9a0e0257 188 list.push_back( kAliHLTDataTypeESDObject | kAliHLTDataOriginOut );
2a24cbbe 189 list.push_back( kAliHLTDataTypeCaloCluster | kAliHLTDataOriginEMCAL );
9a0e0257 190 list.push_back( kAliHLTDataTypeCaloCluster | kAliHLTDataOriginPHOS );
2a24cbbe 191
766aafea 192 // list.push_back(AliHLTPHOSDefinitions::fgkClusterDataType);
2a24cbbe 193 // list.push_back(AliHLTPHOSDefinitions::fgkESDCaloClusterDataType);
194 // list.push_back(AliHLTPHOSDefinitions::fgkESDCaloCellsDataType);
766aafea 195
196}
197
198AliHLTComponentDataType AliHLTCaloHistoComponent::GetOutputDataType()
199{
200 //see header file for documentation
2a24cbbe 201 return kAliHLTDataTypeHistogram | kAliHLTDataOriginAny ;
766aafea 202}
203
204
205void AliHLTCaloHistoComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
206{
207 //see header file for documentation
208 constBase = 30;
209 inputMultiplier = 5;
210}
211
212AliHLTComponent* AliHLTCaloHistoComponent::Spawn() {
213 //see header file for documentation
214 return new AliHLTCaloHistoComponent();
215}
216
217Int_t AliHLTCaloHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) {
218
219 //see header file for documentation
e0cde76d 220 Int_t iResult = 0;
221
222
766aafea 223 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
224 return 0;
9a0e0257 225
9a0e0257 226
227 if (fDoEmcal) {
74085fad 228 // HLTInfo("Processing EMCAL blocks");
e0cde76d 229 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock( kAliHLTDataTypeCaloCluster | kAliHLTDataOriginEMCAL ); pBlock!=NULL; pBlock=GetNextInputBlock()) {
ce063697 230 ProcessBlocks(pBlock, fEmcalHistogramArray);
e0cde76d 231 }
232 }
9a0e0257 233
e0cde76d 234 if (fDoPhos) {
74085fad 235 //HLTInfo("Processing PHOS blocks");
e0cde76d 236 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock( kAliHLTDataTypeCaloCluster | kAliHLTDataOriginPHOS ); pBlock!=NULL; pBlock=GetNextInputBlock()) {
ce063697 237 ProcessBlocks(pBlock, fPhosHistogramArray);
e0cde76d 238 }
9a0e0257 239 }
240
ce063697 241 //Push histos
242 for(int ih = 0; ih < fPhosHistogramArray->GetEntriesFast(); ih++) {
74085fad 243 //HLTInfo("Pushing PHOS histograms");
ce063697 244 PushBack(static_cast<AliHLTCaloHistoProducer*>(fPhosHistogramArray->At(ih))->GetHistograms(), kAliHLTDataTypeHistogram | kAliHLTDataOriginPHOS );
245 }
246 for(int ih = 0; ih < fEmcalHistogramArray->GetEntriesFast(); ih++) {
74085fad 247 //HLTInfo("Pushing EMCAL histograms");
ce063697 248 PushBack(static_cast<AliHLTCaloHistoProducer*>(fEmcalHistogramArray->At(ih))->GetHistograms(), kAliHLTDataTypeHistogram | kAliHLTDataOriginEMCAL );
249 }
9a0e0257 250
ce063697 251 return iResult;
9a0e0257 252
ce063697 253}
9a0e0257 254
9a0e0257 255
ce063697 256Int_t AliHLTCaloHistoComponent::ProcessBlocks(const AliHLTComponentBlockData * pBlock, TObjArray * histoArray) {
9a0e0257 257
ce063697 258 Int_t iResult = 0;
259
260 AliHLTCaloClusterDataStruct * clusterStruct;
261 vector<AliHLTCaloClusterDataStruct*> clustersVector;
2a24cbbe 262
ce063697 263 AliHLTCaloClusterHeaderStruct *clusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
264 fClusterReader->SetMemory(clusterHeader);
265
266 if ( (clusterHeader->fNClusters) < 0) {
267 HLTError("Event has negative number of clusters: %d! Very bad for vector resizing", (Int_t) (clusterHeader->fNClusters));
268 return -1;
269 }
766aafea 270
ce063697 271 clustersVector.resize((int) (clusterHeader->fNClusters));
272 Int_t nClusters = 0;
766aafea 273
ce063697 274 while( (clusterStruct = fClusterReader->NextCluster()) != 0) {
275 clustersVector[nClusters++] = clusterStruct;
766aafea 276 }
766aafea 277
ce063697 278 nClusters = clusterHeader->fNClusters;
279
280 for(int ih = 0; ih < histoArray->GetEntriesFast(); ih++) {
281 iResult = static_cast<AliHLTCaloHistoProducer*>(histoArray->At(ih))->FillHistograms(nClusters, clustersVector);
766aafea 282 }
ce063697 283
284 return iResult;
766aafea 285}