]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/EVE/AliHLTEveCalo.cxx
coverity warning fix
[u/mrichter/AliRoot.git] / HLT / EVE / AliHLTEveCalo.cxx
CommitLineData
33791895 1/**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Primary Authors: Svein Lindal <slindal@fys.uio.no > *
6 * for The ALICE HLT Project. *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17/// @file AliHLTEveCalo.cxx
18/// @author Svein Lindal <slindal@fys.uio.no>
19/// @brief Calorimeter base class for the HLT EVE display
20
fd2adb88 21#include "TCollection.h"
22#include "TObjArray.h"
33791895 23#include "AliHLTEveCalo.h"
24#include "AliHLTHOMERBlockDesc.h"
25#include "TCanvas.h"
26#include "AliHLTEveBase.h"
27#include "TEveBoxSet.h"
28#include "AliPHOSGeometry.h"
29#include "TVector3.h"
fd2adb88 30#include "AliEveHLTEventManager.h"
33791895 31#include "TEveManager.h"
32#include "AliHLTCaloDigitDataStruct.h"
33#include "AliHLTCaloClusterDataStruct.h"
34#include "AliHLTCaloClusterReader.h"
35#include "TEveTrans.h"
36#include "TString.h"
e77bc5e0 37#include "TH2F.h"
38#include "TH1F.h"
fd2adb88 39#include "TRefArray.h"
40#include "AliESDEvent.h"
41#include "AliESDCaloCluster.h"
33791895 42
43ClassImp(AliHLTEveCalo);
44
45AliHLTEveCalo::AliHLTEveCalo(Int_t nm, TString name) :
fd2adb88 46 AliHLTEveBase(name),
9374a7f9 47 fBoxSetDigits(NULL),
48 fBoxSetClusters(NULL),
33791895 49 fNModules(nm),
fd2adb88 50 fClustersArray(NULL),
3d600a8b 51 fName(name),
3fe4881e 52 fPadTitles(NULL),
2aac76d5 53 fInvMassCanvas(NULL),
54 fClusterReader(NULL)
33791895 55{
56 // Constructor.
3d600a8b 57
c0fbdcad 58 SetMaxHistograms(9);
3d600a8b 59
60 fPadTitles = new TString[GetMaxHistograms()];
3fe4881e 61
3d600a8b 62 for(int i = 0; i < GetMaxHistograms(); i++) {
e77bc5e0 63 fPadTitles[i] = "";
64 }
3fe4881e 65
fd2adb88 66 fClustersArray = new TRefArray();
2aac76d5 67 fClusterReader = new AliHLTCaloClusterReader();
68
69
70
e77bc5e0 71
33791895 72}
73
74AliHLTEveCalo::~AliHLTEveCalo()
75{
76 //Destructor
9374a7f9 77 if(fBoxSetDigits)
78 delete fBoxSetDigits;
79 fBoxSetDigits = NULL;
bc1a13f1 80
9374a7f9 81 if(fBoxSetClusters)
82 delete fBoxSetClusters;
83 fBoxSetClusters = NULL;
33791895 84
3fe4881e 85
86 if(fPadTitles)
87 delete [] fPadTitles;
88 fPadTitles = NULL;
89
2aac76d5 90
91 if(fClusterReader)
92 delete fClusterReader;
93 fClusterReader = NULL;
94
33791895 95}
96
97
98void AliHLTEveCalo::ProcessBlock(AliHLTHOMERBlockDesc * block) {
99 //See header file for documentation
100
101 if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) {
102 ProcessHistogram(block);
103
104 } else {
105
33791895 106
107 if ( block->GetDataType().CompareTo("CALOCLUS") == 0 ){
108 //cout <<"Skipping calo clusters"<<endl;
109 ProcessClusters( block );
fd7a3071 110 } else if ( block->GetDataType().CompareTo("DIGITTYP") == 0 ) {
db76648f 111 //ProcessDigits( block);
112 //
fd7a3071 113 } else if ( block->GetDataType().CompareTo("CHANNELT") == 0 ) {
114 //ProcessClusters( block );
115 } else if (!block->GetDataType().CompareTo("ALIESDV0")) {
116 ProcessEsdBlock(block);
db76648f 117 }
33791895 118 }
119}
120
121void AliHLTEveCalo::ProcessHistogram(AliHLTHOMERBlockDesc * block ) {
122 //See header file for documentation
123
124 if(!fCanvas) {
125 fCanvas = CreateCanvas(Form("%s QA", fName.Data()), Form("%s QA", fName.Data()));
36424df2 126 fCanvas->Divide(3, 3);
33791895 127 }
128
3fe4881e 129 if(!fInvMassCanvas) {
130 fInvMassCanvas = CreateCanvas(Form("%s IM", fName.Data()), Form("%s IM", fName.Data()));
131 fInvMassCanvas->Divide(3, 2);
132 }
133
134
33791895 135 AddHistogramsToCanvas(block, fCanvas, fHistoCount);
136
137
138}
139
140
9374a7f9 141// void AliHLTEveCalo::ProcessDigits(AliHLTHOMERBlockDesc* block) {
142// //See header file for documentation
33791895 143
9374a7f9 144// AliHLTCaloDigitDataStruct *ds = reinterpret_cast<AliHLTCaloDigitDataStruct*> (block->GetData());
145// UInt_t nDigits = block->GetSize()/sizeof(AliHLTCaloDigitDataStruct);
33791895 146
147
9374a7f9 148// for(UInt_t i = 0; i < nDigits; i++, ds++) {
33791895 149
9374a7f9 150// Float_t x = (ds->fX - 32)* 2.2;
151// Float_t z = (ds->fZ - 28) * 2.2;
33791895 152
33791895 153
9374a7f9 154// fBoxSetDigits[4-ds->fModule].AddBox(x, 0, z, 2.2, ds->fEnergy*200, 2.2);
155// fBoxSetDigits[4-ds->fModule].DigitValue(static_cast<Int_t>(ds->fEnergy*10));
156// }
33791895 157
9374a7f9 158// }
33791895 159
fd7a3071 160void AliHLTEveCalo::ProcessEsdBlock(AliHLTHOMERBlockDesc * block) {
161 AliESDEvent * event = dynamic_cast<AliESDEvent*>(block->GetTObject());
162 if (event) {
163 ProcessEvent(event);
164 } else {
165 cout << "problem getting the event!"<<endl;
166 }
167
168}
169
fd2adb88 170void AliHLTEveCalo::ProcessEvent(AliESDEvent * event) {
171 //see header file for documentation
172
173
174
175 Int_t nClusters = GetClusters(event, fClustersArray);
176 for(int ic = 0; ic < nClusters; ic++) {
177 AliESDCaloCluster * cluster = dynamic_cast<AliESDCaloCluster*>(fClustersArray->At(ic));
178 ProcessESDCluster(cluster);
179 }
180
181}
182
33791895 183
184void AliHLTEveCalo::ProcessClusters(AliHLTHOMERBlockDesc* block) {
185 //See header file for documentation
186
33791895 187 AliHLTCaloClusterHeaderStruct *dh = reinterpret_cast<AliHLTCaloClusterHeaderStruct*> (block->GetData());
2aac76d5 188 fClusterReader->SetMemory(dh);
33791895 189
190 AliHLTCaloClusterDataStruct * ds;
191
2aac76d5 192 while( (ds = fClusterReader->NextCluster()) ){
db76648f 193 AddClusters(ds->fGlobalPos, ds->fModule, ds->fEnergy);
33791895 194 }
195
2aac76d5 196 AliHLTCaloDigitDataStruct *dg = fClusterReader->GetDigits();
197 UInt_t nDigits = fClusterReader->GetNDigits();;
33791895 198 for(UInt_t i = 0; i < nDigits; i++, dg++) {
199 AddDigits(dg->fX, dg->fZ, dg->fModule, dg->fEnergy);
200 }
201}
202
203void AliHLTEveCalo::UpdateElements() {
204 //See header file for documentation
205 if(fCanvas) fCanvas->Update();
3fe4881e 206 if(fInvMassCanvas) fInvMassCanvas->Update();
207
33791895 208
9374a7f9 209 if(fBoxSetDigits) {
210 for(int im = 0; im < fNModules; im++) {
211 fBoxSetDigits[im].ElementChanged();
212 }
213 }
214
215 if(fBoxSetClusters) {
33791895 216 for(int im = 0; im < fNModules; im++) {
9374a7f9 217 fBoxSetClusters[im].ElementChanged();
33791895 218 }
219 }
9374a7f9 220
33791895 221}
222
223void AliHLTEveCalo::ResetElements(){
224 //See header file for documentation
225 fHistoCount = 0;
226
9374a7f9 227 if ( fBoxSetDigits ){
33791895 228 for(int im = 0; im < fNModules; im++){
9374a7f9 229 fBoxSetDigits[im].Reset();
33791895 230 }
231 }
9374a7f9 232
233 if ( fBoxSetClusters ){
234 for(int im = 0; im < fNModules; im++){
235 fBoxSetClusters[im].Reset();
236 }
237 }
238
33791895 239}
e77bc5e0 240
241Int_t AliHLTEveCalo::GetPadNumber(TString name) {
242
243
3d600a8b 244 for(int i = 0; i < GetMaxHistograms(); i++) {
e77bc5e0 245 if (!fPadTitles[i].CompareTo(name)){
246 return i+1;
247 }
248 else if (!fPadTitles[i].CompareTo("")) {
3d600a8b 249 //cout <<"in empty title"<<endl;
e77bc5e0 250 fPadTitles[i] = name;
251 return i+1;
252 }
253 }
254
c0fbdcad 255 cout << "AliHLTEveCalo()->GetPadNUmber():returning one"<<endl;
e77bc5e0 256 return 1;
257
258}
259
3fe4881e 260void AliHLTEveCalo::DrawInvMassHistogram(TH1F * histo) {
261
262 fInvMassCanvas->cd(++fHistoCount);
263
264 histo->SetAxisRange(histo->GetXaxis()->GetBinLowEdge(histo->FindFirstBinAbove(0, 1) - 3), histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
fcbd8645 265 //histo->Fit("gaus", "", "", histo->GetXaxis()->GetBinLowEdge(histo->FindFirstBinAbove(0, 1)), histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1)));
3fe4881e 266
267 histo->Draw();
268
269}
270
9328177e 271void AliHLTEveCalo::AddHistogramsToCanvas(AliHLTHOMERBlockDesc * block, TCanvas * canvas, Int_t &/*cdCount*/) {
e77bc5e0 272 //See header file for documentation
273
274 if ( ! block->GetClassName().CompareTo("TObjArray")) {
275 TIter next((TObjArray*)(block->GetTObject()));
276 TObject *object;
e77bc5e0 277
3d600a8b 278
3fe4881e 279
280 while (( object = (TObject*) next())) {
e77bc5e0 281
3fe4881e 282 TString name = static_cast<TH1*>(object)->GetName();
283 if(name.Contains("InvMass")){
284 DrawInvMassHistogram(static_cast<TH1F*>(object));
e77bc5e0 285
3fe4881e 286 } else {
e77bc5e0 287
3fe4881e 288
289 Int_t iPad = GetPadNumber(name);
290 canvas->cd(iPad);
291
292
293 //Check if histo is 2D histo
294 TH2F* histo2 = dynamic_cast<TH2F*>(object);
295 if(histo2){
e77bc5e0 296
3fe4881e 297 Int_t lb = histo2->FindLastBinAbove(0,1);
298 if(lb > -1) {
299 histo2->SetAxisRange(0, histo2->GetXaxis()->GetBinUpEdge(histo2->FindLastBinAbove(0, 1) + 3), "X");
300 histo2->SetAxisRange(0, histo2->GetYaxis()->GetBinUpEdge(histo2->FindLastBinAbove(0, 2) + 3), "Y");
e77bc5e0 301 }
3fe4881e 302
303 histo2->Draw("COLZ");
304 }
305
306
307 //Must be 1D histo
308 else {
309 TH1F* histo = dynamic_cast<TH1F*>(object);
310 if (histo) {
311
1039df55 312 TString name2 = histo->GetName();
3fe4881e 313
1039df55 314 if(name2.Contains("Energy")) {
3fe4881e 315 histo->SetAxisRange(0, histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
316 }
317
318
319 histo->Draw();
320 } else {
321 cout <<"AliHLTEveCaloBase::AddHistogramsTocCanvas: Histogram neither TH1F nor TH2F"<<endl;
e77bc5e0 322 }
e77bc5e0 323 }
324 }
325 }
3d600a8b 326
327 } else if ( ! block->GetClassName().CompareTo("TH1F")) {
e77bc5e0 328
329 TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
3d600a8b 330 if(histo) {
331
332 Int_t iPad = GetPadNumber(histo->GetName());
333 canvas->cd(iPad);
334 histo->Draw();
335 }
e77bc5e0 336
3d600a8b 337
338 } else if ( ! block->GetClassName().CompareTo("TH2F")) {
339
e77bc5e0 340 TH2F *histo = reinterpret_cast<TH2F*>(block->GetTObject());
3d600a8b 341 if(histo) {
342
343 Int_t iPad = GetPadNumber(histo->GetName());
344 canvas->cd(iPad);
345 histo->Draw();
e77bc5e0 346 }
e77bc5e0 347
3d600a8b 348
349 }
350
e77bc5e0 351 canvas->cd();
352}
353