]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/EVE/AliHLTEveCalo.cxx
Bug fix for like-sign
[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
21#include "AliHLTEveCalo.h"
22#include "AliHLTHOMERBlockDesc.h"
23#include "TCanvas.h"
24#include "AliHLTEveBase.h"
25#include "TEveBoxSet.h"
26#include "AliPHOSGeometry.h"
27#include "TVector3.h"
28#include "AliEveHOMERManager.h"
29#include "TEveManager.h"
30#include "AliHLTCaloDigitDataStruct.h"
31#include "AliHLTCaloClusterDataStruct.h"
32#include "AliHLTCaloClusterReader.h"
33#include "TEveTrans.h"
34#include "TString.h"
e77bc5e0 35#include "TH2F.h"
36#include "TH1F.h"
37
38
33791895 39
40ClassImp(AliHLTEveCalo);
41
42AliHLTEveCalo::AliHLTEveCalo(Int_t nm, TString name) :
43 AliHLTEveBase(),
44 fBoxSet(NULL),
45 fElementList(NULL),
46 fNModules(nm),
3d600a8b 47 fName(name),
48 fPadTitles(NULL)
33791895 49{
50 // Constructor.
3d600a8b 51
52 SetMaxHistograms(9);
53
54 fPadTitles = new TString[GetMaxHistograms()];
55
56 for(int i = 0; i < GetMaxHistograms(); i++) {
e77bc5e0 57 fPadTitles[i] = "";
58 }
59
60
33791895 61}
62
63AliHLTEveCalo::~AliHLTEveCalo()
64{
65 //Destructor
66 if(fBoxSet)
67 delete fBoxSet;
68 fBoxSet = NULL;
69
70 if(fElementList)
71 delete fElementList;
72 fElementList = NULL;
73}
74
75
76void AliHLTEveCalo::ProcessBlock(AliHLTHOMERBlockDesc * block) {
77 //See header file for documentation
78
79 if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) {
80 ProcessHistogram(block);
81
82 } else {
83
84 if( !fElementList ) {
85 fElementList = CreateElementList();
86 fEventManager->GetEveManager()->AddElement(fElementList);
87 }
88
89 if ( block->GetDataType().CompareTo("CALOCLUS") == 0 ){
90 //cout <<"Skipping calo clusters"<<endl;
91 ProcessClusters( block );
92 }
db76648f 93 else if ( block->GetDataType().CompareTo("DIGITTYP") == 0 ) {
94 //ProcessDigits( block);
95 //
96 }
33791895 97 else if ( block->GetDataType().CompareTo("CHANNELT") == 0 )
98 ProcessClusters( block );
99 }
100}
101
102void AliHLTEveCalo::ProcessHistogram(AliHLTHOMERBlockDesc * block ) {
103 //See header file for documentation
104
105 if(!fCanvas) {
106 fCanvas = CreateCanvas(Form("%s QA", fName.Data()), Form("%s QA", fName.Data()));
6a6e8a01 107 fCanvas->Divide(3, 3);
33791895 108 }
109
110 AddHistogramsToCanvas(block, fCanvas, fHistoCount);
111
112
113}
114
115
116void AliHLTEveCalo::ProcessDigits(AliHLTHOMERBlockDesc* block) {
117 //See header file for documentation
118
119 AliHLTCaloDigitDataStruct *ds = reinterpret_cast<AliHLTCaloDigitDataStruct*> (block->GetData());
120 UInt_t nDigits = block->GetSize()/sizeof(AliHLTCaloDigitDataStruct);
121
122
123 for(UInt_t i = 0; i < nDigits; i++, ds++) {
124
125 Float_t x = (ds->fX - 32)* 2.2;
126 Float_t z = (ds->fZ - 28) * 2.2;
127
33791895 128
129 fBoxSet[4-ds->fModule].AddBox(x, 0, z, 2.2, ds->fEnergy*200, 2.2);
130 fBoxSet[4-ds->fModule].DigitValue(static_cast<Int_t>(ds->fEnergy*10));
131 }
132
133}
134
135
136void AliHLTEveCalo::ProcessClusters(AliHLTHOMERBlockDesc* block) {
137 //See header file for documentation
138
139
140 AliHLTCaloClusterHeaderStruct *dh = reinterpret_cast<AliHLTCaloClusterHeaderStruct*> (block->GetData());
141 AliHLTCaloClusterReader * clusterReader = new AliHLTCaloClusterReader();
142 clusterReader->SetMemory(dh);
143
144 AliHLTCaloClusterDataStruct * ds;
145
33791895 146 while( (ds = clusterReader->NextCluster()) ){
db76648f 147 AddClusters(ds->fGlobalPos, ds->fModule, ds->fEnergy);
33791895 148 }
149
150 AliHLTCaloDigitDataStruct *dg = clusterReader->GetDigits();
151 UInt_t nDigits = clusterReader->GetNDigits();;
152 for(UInt_t i = 0; i < nDigits; i++, dg++) {
153 AddDigits(dg->fX, dg->fZ, dg->fModule, dg->fEnergy);
154 }
155}
156
157void AliHLTEveCalo::UpdateElements() {
158 //See header file for documentation
159 if(fCanvas) fCanvas->Update();
160
161 if(fBoxSet) {
162 for(int im = 0; im < fNModules; im++) {
163 fBoxSet[im].ElementChanged();
164 }
165 }
166}
167
168void AliHLTEveCalo::ResetElements(){
169 //See header file for documentation
170 fHistoCount = 0;
171
172 if ( fBoxSet ){
173 for(int im = 0; im < fNModules; im++){
174 cout<<"Resetting"<<endl;
175 fBoxSet[im].Reset();
176 }
177 }
178}
e77bc5e0 179
180Int_t AliHLTEveCalo::GetPadNumber(TString name) {
181
182
3d600a8b 183 //cout << "GetPadNumber name " << name << endl;
e77bc5e0 184
3d600a8b 185 for(int i = 0; i < GetMaxHistograms(); i++) {
e77bc5e0 186 if (!fPadTitles[i].CompareTo(name)){
187 return i+1;
188 }
189 else if (!fPadTitles[i].CompareTo("")) {
3d600a8b 190 //cout <<"in empty title"<<endl;
e77bc5e0 191 fPadTitles[i] = name;
192 return i+1;
193 }
194 }
195
3d600a8b 196 if(fPadTitles[GetMaxHistograms()].CompareTo("")) {
197 cout << "AliHLTEveCalo::GetPadNumber: We have more histograms than we have room for"<< endl;
198 }
e77bc5e0 199 return 1;
200
201}
202
203void AliHLTEveCalo::AddHistogramsToCanvas(AliHLTHOMERBlockDesc * block, TCanvas * canvas, Int_t &cdCount ) {
204 //See header file for documentation
205
3d600a8b 206
e77bc5e0 207 if ( ! block->GetClassName().CompareTo("TObjArray")) {
208 TIter next((TObjArray*)(block->GetTObject()));
209 TObject *object;
210
211 while (( object = (TObject*) next())) {
212
213 Int_t iPad = GetPadNumber((static_cast<TH1*>(object))->GetName());
214 canvas->cd(iPad);
215
3d600a8b 216
217
e77bc5e0 218 //Check if histo is 2D histo
219 TH2F* histo = dynamic_cast<TH2F*>(object);
220 if(histo){
e77bc5e0 221
3d600a8b 222 Int_t lb = histo->FindLastBinAbove(0,1);
223 if(lb > -1) {
224 histo->SetAxisRange(0, histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
225 histo->SetAxisRange(0, histo->GetYaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 2) + 3), "Y");
226 }
e77bc5e0 227
e77bc5e0 228 histo->Draw("COLZ");
229 }
230
231
232 //Must be 1D histo
233 else {
234 TH1F* histo = dynamic_cast<TH1F*>(object);
235 if (histo) {
236
237 TString name = histo->GetName();
e77bc5e0 238
239 if(name.Contains("Energy")) {
240 histo->SetAxisRange(0, histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
241 }
242
243 else if(name.Contains("InvMass")) {
244 histo->SetAxisRange(histo->GetXaxis()->GetBinLowEdge(histo->FindLastBinAbove(0, 1) - 3), histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
245 }
246
247 histo->Draw();
248 } else {
249 cout <<"AliHLTEveCaloBase::AddHistogramsTocCanvas: Histogram neither TH1F nor TH2F"<<endl;
250 }
251 }
252 }
3d600a8b 253
254
255 } else if ( ! block->GetClassName().CompareTo("TH1F")) {
e77bc5e0 256
257 TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
3d600a8b 258 if(histo) {
259
260 Int_t iPad = GetPadNumber(histo->GetName());
261 canvas->cd(iPad);
262 histo->Draw();
263 }
e77bc5e0 264
3d600a8b 265
266 } else if ( ! block->GetClassName().CompareTo("TH2F")) {
267
e77bc5e0 268 TH2F *histo = reinterpret_cast<TH2F*>(block->GetTObject());
3d600a8b 269 if(histo) {
270
271 Int_t iPad = GetPadNumber(histo->GetName());
272 canvas->cd(iPad);
273 histo->Draw();
e77bc5e0 274 }
e77bc5e0 275
3d600a8b 276
277 }
278
e77bc5e0 279 canvas->cd();
280}
281