]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/EVE/AliHLTEveCalo.cxx
Coverity fixes
[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),
53 fInvMassCanvas(NULL)
33791895 54{
55 // Constructor.
3d600a8b 56
c0fbdcad 57 SetMaxHistograms(9);
3d600a8b 58
59 fPadTitles = new TString[GetMaxHistograms()];
3fe4881e 60
3d600a8b 61 for(int i = 0; i < GetMaxHistograms(); i++) {
e77bc5e0 62 fPadTitles[i] = "";
63 }
3fe4881e 64
fd2adb88 65 fClustersArray = new TRefArray();
e77bc5e0 66
33791895 67}
68
69AliHLTEveCalo::~AliHLTEveCalo()
70{
71 //Destructor
9374a7f9 72 if(fBoxSetDigits)
73 delete fBoxSetDigits;
74 fBoxSetDigits = NULL;
bc1a13f1 75
9374a7f9 76 if(fBoxSetClusters)
77 delete fBoxSetClusters;
78 fBoxSetClusters = NULL;
33791895 79
3fe4881e 80
81 if(fPadTitles)
82 delete [] fPadTitles;
83 fPadTitles = NULL;
84
33791895 85}
86
87
88void AliHLTEveCalo::ProcessBlock(AliHLTHOMERBlockDesc * block) {
89 //See header file for documentation
90
91 if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) {
92 ProcessHistogram(block);
93
94 } else {
95
33791895 96
97 if ( block->GetDataType().CompareTo("CALOCLUS") == 0 ){
98 //cout <<"Skipping calo clusters"<<endl;
99 ProcessClusters( block );
fd7a3071 100 } else if ( block->GetDataType().CompareTo("DIGITTYP") == 0 ) {
db76648f 101 //ProcessDigits( block);
102 //
fd7a3071 103 } else if ( block->GetDataType().CompareTo("CHANNELT") == 0 ) {
104 //ProcessClusters( block );
105 } else if (!block->GetDataType().CompareTo("ALIESDV0")) {
106 ProcessEsdBlock(block);
db76648f 107 }
33791895 108 }
109}
110
111void AliHLTEveCalo::ProcessHistogram(AliHLTHOMERBlockDesc * block ) {
112 //See header file for documentation
113
114 if(!fCanvas) {
115 fCanvas = CreateCanvas(Form("%s QA", fName.Data()), Form("%s QA", fName.Data()));
36424df2 116 fCanvas->Divide(3, 3);
33791895 117 }
118
3fe4881e 119 if(!fInvMassCanvas) {
120 fInvMassCanvas = CreateCanvas(Form("%s IM", fName.Data()), Form("%s IM", fName.Data()));
121 fInvMassCanvas->Divide(3, 2);
122 }
123
124
33791895 125 AddHistogramsToCanvas(block, fCanvas, fHistoCount);
126
127
128}
129
130
9374a7f9 131// void AliHLTEveCalo::ProcessDigits(AliHLTHOMERBlockDesc* block) {
132// //See header file for documentation
33791895 133
9374a7f9 134// AliHLTCaloDigitDataStruct *ds = reinterpret_cast<AliHLTCaloDigitDataStruct*> (block->GetData());
135// UInt_t nDigits = block->GetSize()/sizeof(AliHLTCaloDigitDataStruct);
33791895 136
137
9374a7f9 138// for(UInt_t i = 0; i < nDigits; i++, ds++) {
33791895 139
9374a7f9 140// Float_t x = (ds->fX - 32)* 2.2;
141// Float_t z = (ds->fZ - 28) * 2.2;
33791895 142
33791895 143
9374a7f9 144// fBoxSetDigits[4-ds->fModule].AddBox(x, 0, z, 2.2, ds->fEnergy*200, 2.2);
145// fBoxSetDigits[4-ds->fModule].DigitValue(static_cast<Int_t>(ds->fEnergy*10));
146// }
33791895 147
9374a7f9 148// }
33791895 149
fd7a3071 150void AliHLTEveCalo::ProcessEsdBlock(AliHLTHOMERBlockDesc * block) {
151 AliESDEvent * event = dynamic_cast<AliESDEvent*>(block->GetTObject());
152 if (event) {
153 ProcessEvent(event);
154 } else {
155 cout << "problem getting the event!"<<endl;
156 }
157
158}
159
fd2adb88 160void AliHLTEveCalo::ProcessEvent(AliESDEvent * event) {
161 //see header file for documentation
162
163
164
165 Int_t nClusters = GetClusters(event, fClustersArray);
166 for(int ic = 0; ic < nClusters; ic++) {
167 AliESDCaloCluster * cluster = dynamic_cast<AliESDCaloCluster*>(fClustersArray->At(ic));
168 ProcessESDCluster(cluster);
169 }
170
171}
172
33791895 173
174void AliHLTEveCalo::ProcessClusters(AliHLTHOMERBlockDesc* block) {
175 //See header file for documentation
176
33791895 177 AliHLTCaloClusterHeaderStruct *dh = reinterpret_cast<AliHLTCaloClusterHeaderStruct*> (block->GetData());
178 AliHLTCaloClusterReader * clusterReader = new AliHLTCaloClusterReader();
179 clusterReader->SetMemory(dh);
180
181 AliHLTCaloClusterDataStruct * ds;
182
33791895 183 while( (ds = clusterReader->NextCluster()) ){
db76648f 184 AddClusters(ds->fGlobalPos, ds->fModule, ds->fEnergy);
33791895 185 }
186
187 AliHLTCaloDigitDataStruct *dg = clusterReader->GetDigits();
188 UInt_t nDigits = clusterReader->GetNDigits();;
189 for(UInt_t i = 0; i < nDigits; i++, dg++) {
190 AddDigits(dg->fX, dg->fZ, dg->fModule, dg->fEnergy);
191 }
192}
193
194void AliHLTEveCalo::UpdateElements() {
195 //See header file for documentation
196 if(fCanvas) fCanvas->Update();
3fe4881e 197 if(fInvMassCanvas) fInvMassCanvas->Update();
198
33791895 199
9374a7f9 200 if(fBoxSetDigits) {
201 for(int im = 0; im < fNModules; im++) {
202 fBoxSetDigits[im].ElementChanged();
203 }
204 }
205
206 if(fBoxSetClusters) {
33791895 207 for(int im = 0; im < fNModules; im++) {
9374a7f9 208 fBoxSetClusters[im].ElementChanged();
33791895 209 }
210 }
9374a7f9 211
33791895 212}
213
214void AliHLTEveCalo::ResetElements(){
215 //See header file for documentation
216 fHistoCount = 0;
217
9374a7f9 218 if ( fBoxSetDigits ){
33791895 219 for(int im = 0; im < fNModules; im++){
9374a7f9 220 fBoxSetDigits[im].Reset();
33791895 221 }
222 }
9374a7f9 223
224 if ( fBoxSetClusters ){
225 for(int im = 0; im < fNModules; im++){
226 fBoxSetClusters[im].Reset();
227 }
228 }
229
33791895 230}
e77bc5e0 231
232Int_t AliHLTEveCalo::GetPadNumber(TString name) {
233
234
3d600a8b 235 for(int i = 0; i < GetMaxHistograms(); i++) {
e77bc5e0 236 if (!fPadTitles[i].CompareTo(name)){
237 return i+1;
238 }
239 else if (!fPadTitles[i].CompareTo("")) {
3d600a8b 240 //cout <<"in empty title"<<endl;
e77bc5e0 241 fPadTitles[i] = name;
242 return i+1;
243 }
244 }
245
c0fbdcad 246 cout << "AliHLTEveCalo()->GetPadNUmber():returning one"<<endl;
e77bc5e0 247 return 1;
248
249}
250
3fe4881e 251void AliHLTEveCalo::DrawInvMassHistogram(TH1F * histo) {
252
253 fInvMassCanvas->cd(++fHistoCount);
254
255 histo->SetAxisRange(histo->GetXaxis()->GetBinLowEdge(histo->FindFirstBinAbove(0, 1) - 3), histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
fcbd8645 256 //histo->Fit("gaus", "", "", histo->GetXaxis()->GetBinLowEdge(histo->FindFirstBinAbove(0, 1)), histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1)));
3fe4881e 257
258 histo->Draw();
259
260}
261
9328177e 262void AliHLTEveCalo::AddHistogramsToCanvas(AliHLTHOMERBlockDesc * block, TCanvas * canvas, Int_t &/*cdCount*/) {
e77bc5e0 263 //See header file for documentation
264
265 if ( ! block->GetClassName().CompareTo("TObjArray")) {
266 TIter next((TObjArray*)(block->GetTObject()));
267 TObject *object;
e77bc5e0 268
3d600a8b 269
3fe4881e 270
271 while (( object = (TObject*) next())) {
e77bc5e0 272
3fe4881e 273 TString name = static_cast<TH1*>(object)->GetName();
274 if(name.Contains("InvMass")){
275 DrawInvMassHistogram(static_cast<TH1F*>(object));
e77bc5e0 276
3fe4881e 277 } else {
e77bc5e0 278
3fe4881e 279
280 Int_t iPad = GetPadNumber(name);
281 canvas->cd(iPad);
282
283
284 //Check if histo is 2D histo
285 TH2F* histo2 = dynamic_cast<TH2F*>(object);
286 if(histo2){
e77bc5e0 287
3fe4881e 288 Int_t lb = histo2->FindLastBinAbove(0,1);
289 if(lb > -1) {
290 histo2->SetAxisRange(0, histo2->GetXaxis()->GetBinUpEdge(histo2->FindLastBinAbove(0, 1) + 3), "X");
291 histo2->SetAxisRange(0, histo2->GetYaxis()->GetBinUpEdge(histo2->FindLastBinAbove(0, 2) + 3), "Y");
e77bc5e0 292 }
3fe4881e 293
294 histo2->Draw("COLZ");
295 }
296
297
298 //Must be 1D histo
299 else {
300 TH1F* histo = dynamic_cast<TH1F*>(object);
301 if (histo) {
302
1039df55 303 TString name2 = histo->GetName();
3fe4881e 304
1039df55 305 if(name2.Contains("Energy")) {
3fe4881e 306 histo->SetAxisRange(0, histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
307 }
308
309
310 histo->Draw();
311 } else {
312 cout <<"AliHLTEveCaloBase::AddHistogramsTocCanvas: Histogram neither TH1F nor TH2F"<<endl;
e77bc5e0 313 }
e77bc5e0 314 }
315 }
316 }
3d600a8b 317
318 } else if ( ! block->GetClassName().CompareTo("TH1F")) {
e77bc5e0 319
320 TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
3d600a8b 321 if(histo) {
322
323 Int_t iPad = GetPadNumber(histo->GetName());
324 canvas->cd(iPad);
325 histo->Draw();
326 }
e77bc5e0 327
3d600a8b 328
329 } else if ( ! block->GetClassName().CompareTo("TH2F")) {
330
e77bc5e0 331 TH2F *histo = reinterpret_cast<TH2F*>(block->GetTObject());
3d600a8b 332 if(histo) {
333
334 Int_t iPad = GetPadNumber(histo->GetName());
335 canvas->cd(iPad);
336 histo->Draw();
e77bc5e0 337 }
e77bc5e0 338
3d600a8b 339
340 }
341
e77bc5e0 342 canvas->cd();
343}
344