1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
5 * Primary Authors: Svein Lindal <slindal@fys.uio.no > *
6 * for The ALICE HLT Project. *
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 **************************************************************************/
17 /// @file AliHLTEveCalo.cxx
18 /// @author Svein Lindal <slindal@fys.uio.no>
19 /// @brief Calorimeter base class for the HLT EVE display
21 #include "TCollection.h"
22 #include "TObjArray.h"
23 #include "AliHLTEveCalo.h"
24 #include "AliHLTHOMERBlockDesc.h"
26 #include "AliHLTEveBase.h"
27 #include "TEveBoxSet.h"
28 #include "AliPHOSGeometry.h"
30 #include "AliEveHLTEventManager.h"
31 #include "TEveManager.h"
32 #include "AliHLTCaloDigitDataStruct.h"
33 #include "AliHLTCaloClusterDataStruct.h"
34 #include "AliHLTCaloClusterReader.h"
35 #include "TEveTrans.h"
39 #include "TRefArray.h"
40 #include "AliESDEvent.h"
41 #include "AliESDCaloCluster.h"
43 ClassImp(AliHLTEveCalo);
45 AliHLTEveCalo::AliHLTEveCalo(Int_t nm, TString name) :
48 fBoxSetClusters(NULL),
59 fPadTitles = new TString[GetMaxHistograms()];
61 for(int i = 0; i < GetMaxHistograms(); i++) {
65 fClustersArray = new TRefArray();
69 AliHLTEveCalo::~AliHLTEveCalo()
77 delete fBoxSetClusters;
78 fBoxSetClusters = NULL;
88 void AliHLTEveCalo::ProcessBlock(AliHLTHOMERBlockDesc * block) {
89 //See header file for documentation
91 if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) {
92 ProcessHistogram(block);
97 if ( block->GetDataType().CompareTo("CALOCLUS") == 0 ){
98 //cout <<"Skipping calo clusters"<<endl;
99 ProcessClusters( block );
100 } else if ( block->GetDataType().CompareTo("DIGITTYP") == 0 ) {
101 //ProcessDigits( block);
103 } else if ( block->GetDataType().CompareTo("CHANNELT") == 0 ) {
104 //ProcessClusters( block );
105 } else if (!block->GetDataType().CompareTo("ALIESDV0")) {
106 ProcessEsdBlock(block);
111 void AliHLTEveCalo::ProcessHistogram(AliHLTHOMERBlockDesc * block ) {
112 //See header file for documentation
115 fCanvas = CreateCanvas(Form("%s QA", fName.Data()), Form("%s QA", fName.Data()));
116 fCanvas->Divide(3, 3);
119 if(!fInvMassCanvas) {
120 fInvMassCanvas = CreateCanvas(Form("%s IM", fName.Data()), Form("%s IM", fName.Data()));
121 fInvMassCanvas->Divide(3, 2);
125 AddHistogramsToCanvas(block, fCanvas, fHistoCount);
131 // void AliHLTEveCalo::ProcessDigits(AliHLTHOMERBlockDesc* block) {
132 // //See header file for documentation
134 // AliHLTCaloDigitDataStruct *ds = reinterpret_cast<AliHLTCaloDigitDataStruct*> (block->GetData());
135 // UInt_t nDigits = block->GetSize()/sizeof(AliHLTCaloDigitDataStruct);
138 // for(UInt_t i = 0; i < nDigits; i++, ds++) {
140 // Float_t x = (ds->fX - 32)* 2.2;
141 // Float_t z = (ds->fZ - 28) * 2.2;
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));
150 void AliHLTEveCalo::ProcessEsdBlock(AliHLTHOMERBlockDesc * block) {
151 AliESDEvent * event = dynamic_cast<AliESDEvent*>(block->GetTObject());
155 cout << "problem getting the event!"<<endl;
160 void AliHLTEveCalo::ProcessEvent(AliESDEvent * event) {
161 //see header file for documentation
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);
174 void AliHLTEveCalo::ProcessClusters(AliHLTHOMERBlockDesc* block) {
175 //See header file for documentation
177 AliHLTCaloClusterHeaderStruct *dh = reinterpret_cast<AliHLTCaloClusterHeaderStruct*> (block->GetData());
178 AliHLTCaloClusterReader * clusterReader = new AliHLTCaloClusterReader();
179 clusterReader->SetMemory(dh);
181 AliHLTCaloClusterDataStruct * ds;
183 while( (ds = clusterReader->NextCluster()) ){
184 AddClusters(ds->fGlobalPos, ds->fModule, ds->fEnergy);
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);
194 void AliHLTEveCalo::UpdateElements() {
195 //See header file for documentation
196 if(fCanvas) fCanvas->Update();
197 if(fInvMassCanvas) fInvMassCanvas->Update();
201 for(int im = 0; im < fNModules; im++) {
202 fBoxSetDigits[im].ElementChanged();
206 if(fBoxSetClusters) {
207 for(int im = 0; im < fNModules; im++) {
208 fBoxSetClusters[im].ElementChanged();
214 void AliHLTEveCalo::ResetElements(){
215 //See header file for documentation
218 if ( fBoxSetDigits ){
219 for(int im = 0; im < fNModules; im++){
220 fBoxSetDigits[im].Reset();
224 if ( fBoxSetClusters ){
225 for(int im = 0; im < fNModules; im++){
226 fBoxSetClusters[im].Reset();
232 Int_t AliHLTEveCalo::GetPadNumber(TString name) {
235 //cout << "GetPadNumber name " << name << endl;
237 for(int i = 0; i < GetMaxHistograms(); i++) {
238 if (!fPadTitles[i].CompareTo(name)){
241 else if (!fPadTitles[i].CompareTo("")) {
242 //cout <<"in empty title"<<endl;
243 fPadTitles[i] = name;
248 if(fPadTitles[GetMaxHistograms()].CompareTo("")) {
249 cout << "AliHLTEveCalo::GetPadNumber: We have more histograms than we have room for"<< endl;
255 void AliHLTEveCalo::DrawInvMassHistogram(TH1F * histo) {
257 fInvMassCanvas->cd(++fHistoCount);
259 histo->SetAxisRange(histo->GetXaxis()->GetBinLowEdge(histo->FindFirstBinAbove(0, 1) - 3), histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
260 histo->Fit("gaus", "", "", histo->GetXaxis()->GetBinLowEdge(histo->FindFirstBinAbove(0, 1)), histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1)));
266 void AliHLTEveCalo::AddHistogramsToCanvas(AliHLTHOMERBlockDesc * block, TCanvas * canvas, Int_t &/*cdCount*/) {
267 //See header file for documentation
269 if ( ! block->GetClassName().CompareTo("TObjArray")) {
270 TIter next((TObjArray*)(block->GetTObject()));
275 while (( object = (TObject*) next())) {
277 TString name = static_cast<TH1*>(object)->GetName();
278 if(name.Contains("InvMass")){
279 DrawInvMassHistogram(static_cast<TH1F*>(object));
284 Int_t iPad = GetPadNumber(name);
288 //Check if histo is 2D histo
289 TH2F* histo2 = dynamic_cast<TH2F*>(object);
292 Int_t lb = histo2->FindLastBinAbove(0,1);
294 histo2->SetAxisRange(0, histo2->GetXaxis()->GetBinUpEdge(histo2->FindLastBinAbove(0, 1) + 3), "X");
295 histo2->SetAxisRange(0, histo2->GetYaxis()->GetBinUpEdge(histo2->FindLastBinAbove(0, 2) + 3), "Y");
298 histo2->Draw("COLZ");
304 TH1F* histo = dynamic_cast<TH1F*>(object);
307 TString name2 = histo->GetName();
309 if(name2.Contains("Energy")) {
310 histo->SetAxisRange(0, histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
316 cout <<"AliHLTEveCaloBase::AddHistogramsTocCanvas: Histogram neither TH1F nor TH2F"<<endl;
322 } else if ( ! block->GetClassName().CompareTo("TH1F")) {
324 TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
327 Int_t iPad = GetPadNumber(histo->GetName());
333 } else if ( ! block->GetClassName().CompareTo("TH2F")) {
335 TH2F *histo = reinterpret_cast<TH2F*>(block->GetTObject());
338 Int_t iPad = GetPadNumber(histo->GetName());