]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/EVE/AliHLTEveCalo.cxx
Update the mult corr histograms
[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
3fe4881e 57 SetMaxHistograms(6);
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 //cout << "GetPadNumber name " << name << endl;
e77bc5e0 236
3d600a8b 237 for(int i = 0; i < GetMaxHistograms(); i++) {
e77bc5e0 238 if (!fPadTitles[i].CompareTo(name)){
239 return i+1;
240 }
241 else if (!fPadTitles[i].CompareTo("")) {
3d600a8b 242 //cout <<"in empty title"<<endl;
e77bc5e0 243 fPadTitles[i] = name;
244 return i+1;
245 }
246 }
247
3d600a8b 248 if(fPadTitles[GetMaxHistograms()].CompareTo("")) {
249 cout << "AliHLTEveCalo::GetPadNumber: We have more histograms than we have room for"<< endl;
250 }
5beb4fc1 251 cout << "returning one"<<endl;
e77bc5e0 252 return 1;
253
254}
255
3fe4881e 256void AliHLTEveCalo::DrawInvMassHistogram(TH1F * histo) {
257
258 fInvMassCanvas->cd(++fHistoCount);
259
260 histo->SetAxisRange(histo->GetXaxis()->GetBinLowEdge(histo->FindFirstBinAbove(0, 1) - 3), histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
261 histo->Fit("gaus", "", "", histo->GetXaxis()->GetBinLowEdge(histo->FindFirstBinAbove(0, 1)), histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1)));
262
263 histo->Draw();
264
265}
266
9328177e 267void AliHLTEveCalo::AddHistogramsToCanvas(AliHLTHOMERBlockDesc * block, TCanvas * canvas, Int_t &/*cdCount*/) {
e77bc5e0 268 //See header file for documentation
269
270 if ( ! block->GetClassName().CompareTo("TObjArray")) {
271 TIter next((TObjArray*)(block->GetTObject()));
272 TObject *object;
e77bc5e0 273
3d600a8b 274
3fe4881e 275
276 while (( object = (TObject*) next())) {
e77bc5e0 277
3fe4881e 278 TString name = static_cast<TH1*>(object)->GetName();
279 if(name.Contains("InvMass")){
280 DrawInvMassHistogram(static_cast<TH1F*>(object));
e77bc5e0 281
3fe4881e 282 } else {
e77bc5e0 283
3fe4881e 284
285 Int_t iPad = GetPadNumber(name);
286 canvas->cd(iPad);
287
288
289 //Check if histo is 2D histo
290 TH2F* histo2 = dynamic_cast<TH2F*>(object);
291 if(histo2){
e77bc5e0 292
3fe4881e 293 Int_t lb = histo2->FindLastBinAbove(0,1);
294 if(lb > -1) {
295 histo2->SetAxisRange(0, histo2->GetXaxis()->GetBinUpEdge(histo2->FindLastBinAbove(0, 1) + 3), "X");
296 histo2->SetAxisRange(0, histo2->GetYaxis()->GetBinUpEdge(histo2->FindLastBinAbove(0, 2) + 3), "Y");
e77bc5e0 297 }
3fe4881e 298
299 histo2->Draw("COLZ");
300 }
301
302
303 //Must be 1D histo
304 else {
305 TH1F* histo = dynamic_cast<TH1F*>(object);
306 if (histo) {
307
1039df55 308 TString name2 = histo->GetName();
3fe4881e 309
1039df55 310 if(name2.Contains("Energy")) {
3fe4881e 311 histo->SetAxisRange(0, histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
312 }
313
314
315 histo->Draw();
316 } else {
317 cout <<"AliHLTEveCaloBase::AddHistogramsTocCanvas: Histogram neither TH1F nor TH2F"<<endl;
e77bc5e0 318 }
e77bc5e0 319 }
320 }
321 }
3d600a8b 322
323 } else if ( ! block->GetClassName().CompareTo("TH1F")) {
e77bc5e0 324
325 TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
3d600a8b 326 if(histo) {
327
328 Int_t iPad = GetPadNumber(histo->GetName());
329 canvas->cd(iPad);
330 histo->Draw();
331 }
e77bc5e0 332
3d600a8b 333
334 } else if ( ! block->GetClassName().CompareTo("TH2F")) {
335
e77bc5e0 336 TH2F *histo = reinterpret_cast<TH2F*>(block->GetTObject());
3d600a8b 337 if(histo) {
338
339 Int_t iPad = GetPadNumber(histo->GetName());
340 canvas->cd(iPad);
341 histo->Draw();
e77bc5e0 342 }
e77bc5e0 343
3d600a8b 344
345 }
346
e77bc5e0 347 canvas->cd();
348}
349