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 "AliHLTEveCalo.h"
22 #include "AliHLTHOMERBlockDesc.h"
24 #include "AliHLTEveBase.h"
25 #include "TEveBoxSet.h"
26 #include "AliPHOSGeometry.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"
40 ClassImp(AliHLTEveCalo);
42 AliHLTEveCalo::AliHLTEveCalo(Int_t nm, TString name) :
50 for(int i = 0; i < 9; i++) {
57 AliHLTEveCalo::~AliHLTEveCalo()
70 void AliHLTEveCalo::ProcessBlock(AliHLTHOMERBlockDesc * block) {
71 //See header file for documentation
73 if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) {
75 cout <<"calo histo!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<< endl;
76 ProcessHistogram(block);
81 fElementList = CreateElementList();
82 fEventManager->GetEveManager()->AddElement(fElementList);
85 if ( block->GetDataType().CompareTo("CALOCLUS") == 0 ){
86 //cout <<"Skipping calo clusters"<<endl;
87 ProcessClusters( block );
89 else if ( block->GetDataType().CompareTo("DIGITTYP") == 0 ) {
90 //ProcessDigits( block);
93 else if ( block->GetDataType().CompareTo("CHANNELT") == 0 )
94 ProcessClusters( block );
98 void AliHLTEveCalo::ProcessHistogram(AliHLTHOMERBlockDesc * block ) {
99 //See header file for documentation
102 fCanvas = CreateCanvas(Form("%s QA", fName.Data()), Form("%s QA", fName.Data()));
103 fCanvas->Divide(3, 3);
106 AddHistogramsToCanvas(block, fCanvas, fHistoCount);
112 void AliHLTEveCalo::ProcessDigits(AliHLTHOMERBlockDesc* block) {
113 //See header file for documentation
115 AliHLTCaloDigitDataStruct *ds = reinterpret_cast<AliHLTCaloDigitDataStruct*> (block->GetData());
116 UInt_t nDigits = block->GetSize()/sizeof(AliHLTCaloDigitDataStruct);
119 for(UInt_t i = 0; i < nDigits; i++, ds++) {
121 Float_t x = (ds->fX - 32)* 2.2;
122 Float_t z = (ds->fZ - 28) * 2.2;
124 cout << "MODULE DIGITTYP :" << ds->fModule;
126 fBoxSet[4-ds->fModule].AddBox(x, 0, z, 2.2, ds->fEnergy*200, 2.2);
127 fBoxSet[4-ds->fModule].DigitValue(static_cast<Int_t>(ds->fEnergy*10));
133 void AliHLTEveCalo::ProcessClusters(AliHLTHOMERBlockDesc* block) {
134 //See header file for documentation
137 AliHLTCaloClusterHeaderStruct *dh = reinterpret_cast<AliHLTCaloClusterHeaderStruct*> (block->GetData());
138 AliHLTCaloClusterReader * clusterReader = new AliHLTCaloClusterReader();
139 clusterReader->SetMemory(dh);
141 AliHLTCaloClusterDataStruct * ds;
143 while( (ds = clusterReader->NextCluster()) ){
144 AddClusters(ds->fGlobalPos, ds->fModule, ds->fEnergy);
147 AliHLTCaloDigitDataStruct *dg = clusterReader->GetDigits();
148 UInt_t nDigits = clusterReader->GetNDigits();;
149 for(UInt_t i = 0; i < nDigits; i++, dg++) {
150 AddDigits(dg->fX, dg->fZ, dg->fModule, dg->fEnergy);
154 void AliHLTEveCalo::UpdateElements() {
155 //See header file for documentation
156 if(fCanvas) fCanvas->Update();
159 for(int im = 0; im < fNModules; im++) {
160 fBoxSet[im].ElementChanged();
165 void AliHLTEveCalo::ResetElements(){
166 //See header file for documentation
170 for(int im = 0; im < fNModules; im++){
171 cout<<"Resetting"<<endl;
177 Int_t AliHLTEveCalo::GetPadNumber(TString name) {
180 cout << "GetPadNumber name " << name << endl;
182 for(int i = 0; i < 9; i++) {
183 if (!fPadTitles[i].CompareTo(name)){
186 else if (!fPadTitles[i].CompareTo("")) {
187 cout <<"in empty title"<<endl;
188 fPadTitles[i] = name;
193 cout << "BALLE returning default 1"<< endl;
199 void AliHLTEveCalo::AddHistogramsToCanvas(AliHLTHOMERBlockDesc * block, TCanvas * canvas, Int_t &cdCount ) {
200 //See header file for documentation
202 if ( ! block->GetClassName().CompareTo("TObjArray")) {
203 TIter next((TObjArray*)(block->GetTObject()));
206 while (( object = (TObject*) next())) {
208 Int_t iPad = GetPadNumber((static_cast<TH1*>(object))->GetName());
211 //Check if histo is 2D histo
212 TH2F* histo = dynamic_cast<TH2F*>(object);
215 TString name = histo->GetName();
216 if(name.Contains("ClusterEnergy")) {
217 cout << "BALLE CE"<< endl;
219 Int_t lb = histo->FindLastBinAbove(0,1);
220 Int_t fb = histo->FindFirstBinAbove(0,1);
223 histo->SetAxisRange(0, histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
224 histo->SetAxisRange(0, histo->GetYaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 2) + 3), "Y");
228 else if (name.Contains("MatchDistance")) {
229 cout << "BALLE MD"<< endl;
230 Float_t min = histo->GetXaxis()->GetBinLowEdge( histo->FindFirstBinAbove(0, 1) -3 );
231 Float_t max = histo->GetXaxis()->GetBinUpEdge( histo->FindLastBinAbove(0, 1) + 3);
232 min = TMath::Abs(min);
235 histo->SetAxisRange(-max, max, "X");
237 min = histo->GetYaxis()->GetBinLowEdge( histo->FindFirstBinAbove(0, 2) -3 );
238 max = histo->GetYaxis()->GetBinUpEdge( histo->FindLastBinAbove(0, 2) + 3 );
239 min = TMath::Abs(min);
242 histo->SetAxisRange(-max, max, "Y");
251 TH1F* histo = dynamic_cast<TH1F*>(object);
254 TString name = histo->GetName();
256 //canvas->cd(++cdCount);
258 if(name.Contains("Energy")) {
259 histo->SetAxisRange(0, histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
262 else if(name.Contains("InvMass")) {
263 histo->SetAxisRange(histo->GetXaxis()->GetBinLowEdge(histo->FindLastBinAbove(0, 1) - 3), histo->GetXaxis()->GetBinUpEdge(histo->FindLastBinAbove(0, 1) + 3), "X");
268 cout <<"AliHLTEveCaloBase::AddHistogramsTocCanvas: Histogram neither TH1F nor TH2F"<<endl;
274 else if ( ! block->GetClassName().CompareTo("TH1F")) {
276 TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
283 else if ( ! block->GetClassName().CompareTo("TH2F")) {
284 TH2F *histo = reinterpret_cast<TH2F*>(block->GetTObject());