]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/EVE/AliHLTEveCalo.cxx
Merge branch 'devel'
[u/mrichter/AliRoot.git] / HLT / EVE / AliHLTEveCalo.cxx
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"
35
36 ClassImp(AliHLTEveCalo);
37
38 AliHLTEveCalo::AliHLTEveCalo(Int_t nm, TString name) : 
39   AliHLTEveBase(), 
40   fBoxSet(NULL),
41   fElementList(NULL),
42   fNModules(nm),
43   fName(name)
44 {
45   // Constructor.
46 }
47
48 AliHLTEveCalo::~AliHLTEveCalo()
49 {
50   //Destructor
51   if(fBoxSet)
52     delete fBoxSet;
53   fBoxSet = NULL;
54
55   if(fElementList)
56     delete fElementList;
57   fElementList = NULL;
58 }
59
60
61 void AliHLTEveCalo::ProcessBlock(AliHLTHOMERBlockDesc * block) {
62   //See header file for documentation
63
64   if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) { 
65     ProcessHistogram(block);
66    
67   } else {
68
69     if( !fElementList ) {
70       fElementList = CreateElementList();
71       fEventManager->GetEveManager()->AddElement(fElementList);
72     }
73     
74     if ( block->GetDataType().CompareTo("CALOCLUS") == 0 ){
75       //cout <<"Skipping calo clusters"<<endl;
76       ProcessClusters( block );
77     }
78     else if ( block->GetDataType().CompareTo("DIGITTYP") == 0 )
79       ProcessDigits( block);
80     
81     else if ( block->GetDataType().CompareTo("CHANNELT") == 0 ) 
82       ProcessClusters( block );
83   }
84 }
85
86 void AliHLTEveCalo::ProcessHistogram(AliHLTHOMERBlockDesc * block ) {
87   //See header file for documentation
88   
89   if(!fCanvas) {
90     fCanvas = CreateCanvas(Form("%s QA", fName.Data()), Form("%s QA", fName.Data()));
91     fCanvas->Divide(3, 2);
92   }
93
94   AddHistogramsToCanvas(block, fCanvas, fHistoCount);
95
96
97 }
98
99
100 void AliHLTEveCalo::ProcessDigits(AliHLTHOMERBlockDesc* block) {
101   //See header file for documentation
102   
103   AliHLTCaloDigitDataStruct *ds = reinterpret_cast<AliHLTCaloDigitDataStruct*> (block->GetData());
104   UInt_t nDigits = block->GetSize()/sizeof(AliHLTCaloDigitDataStruct);
105     
106
107   for(UInt_t i = 0; i < nDigits; i++, ds++) {
108
109     Float_t x = (ds->fX - 32)* 2.2;
110       Float_t z = (ds->fZ - 28) * 2.2;
111
112       cout << "MODULE DIGITTYP  :" << ds->fModule;
113
114     fBoxSet[4-ds->fModule].AddBox(x, 0, z, 2.2, ds->fEnergy*200, 2.2);
115     fBoxSet[4-ds->fModule].DigitValue(static_cast<Int_t>(ds->fEnergy*10));
116   }
117
118 }
119
120
121 void AliHLTEveCalo::ProcessClusters(AliHLTHOMERBlockDesc* block) {
122   //See header file for documentation
123
124
125   AliHLTCaloClusterHeaderStruct *dh = reinterpret_cast<AliHLTCaloClusterHeaderStruct*> (block->GetData());
126   AliHLTCaloClusterReader * clusterReader = new AliHLTCaloClusterReader();
127   clusterReader->SetMemory(dh);  
128
129   AliHLTCaloClusterDataStruct * ds;
130
131
132   
133   while( (ds = clusterReader->NextCluster()) ){
134     //    AddClusters(ds->fGlobalPos, ds->fModule, ds->fEnergy);
135   }
136
137   AliHLTCaloDigitDataStruct *dg = clusterReader->GetDigits();
138   UInt_t nDigits = clusterReader->GetNDigits();;
139   for(UInt_t i = 0; i < nDigits; i++, dg++) {
140     AddDigits(dg->fX, dg->fZ, dg->fModule, dg->fEnergy);
141   }
142 }
143
144 void AliHLTEveCalo::UpdateElements() {
145   //See header file for documentation
146   if(fCanvas) fCanvas->Update();
147
148   if(fBoxSet) {
149     for(int im = 0; im < fNModules; im++) {
150       fBoxSet[im].ElementChanged();
151     }
152   }
153 }
154
155 void AliHLTEveCalo::ResetElements(){
156   //See header file for documentation
157   fHistoCount = 0;
158   
159   if ( fBoxSet ){
160     for(int im = 0; im < fNModules; im++){
161       cout<<"Resetting"<<endl;
162       fBoxSet[im].Reset();   
163     }
164   }
165 }