]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/EMCAL/AliHLTEMCALGeometry.cxx
Refactoring: Using common CALO constants
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALGeometry.cxx
CommitLineData
5308534b 1/**************************************************************************
2 * This file is property of and copyright by the Experimental Nuclear *
3 * Physics Group, Dep. of Physics *
4 * University of Oslo, Norway, 2007 *
5 * *
6 * Author: federico ronchetti 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 **************************************************************************/
22406a6a 16
5308534b 17#include "AliHLTEMCALGeometry.h"
22406a6a 18#include "AliHLTEMCALConstants.h"
cdf43bb0 19#include "AliCDBEntry.h"
20#include "AliCDBManager.h"
21#include "AliCDBPath.h"
5308534b 22
5308534b 23
24ClassImp(AliHLTEMCALGeometry);
22406a6a 25TGeoManager *gGeoManager = 0;
5308534b 26
22406a6a 27AliHLTEMCALGeometry::AliHLTEMCALGeometry() :
28 AliHLTCaloGeometry ("EMCAL"),
08a69753 29 fGeo(0)
5308534b 30{
cdf43bb0 31
32 //fGeo = new AliEMCALGeoUtils("EMCAL_COMPLETE","EMCAL");
5308534b 33 //fGeo = new AliEMCALGeometry("EMCAL_COMPLETE","EMCAL");
34 //fGeo = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
22406a6a 35 //TGeoManager::Import("/home/fedro/work/AliRoot/test/QA/geometry.root");
cdf43bb0 36
37 GetGeometryFromCDB();
5308534b 38}
39
7b3a0a0e 40Int_t AliHLTEMCALGeometry::InitialiseGeometry()
41{
42
43 return GetGeometryFromCDB();
44}
45
5308534b 46
47AliHLTEMCALGeometry::~AliHLTEMCALGeometry()
48{
49
50}
51
52void
5d3cb748 53AliHLTEMCALGeometry::GetGlobalCoordinates(AliHLTCaloRecPointDataStruct &recPoint, AliHLTCaloGlobalCoordinate &globalCoord)
5308534b 54{
08a69753 55 // Working variables
85e654fb 56 Int_t istrip = 0;
57 Float_t z0 = 0;
58 Float_t zb = 0;
59 Float_t z_is = 0;
60 Float_t d = 0;
61 Float_t x,y,z; // return variables in terry's RF
62 Float_t dz = fCaloConstants->GetMINCELLSTEPETA(); // base cell width in eta
63 Float_t dx = fCaloConstants->GetCELLSTEPPHI(); // base cell width in phi
64
65 // parameters for shower depth calculation
66 Float_t X0 = fCaloConstants->GetRADLENGTH();
67 Float_t Ecr = fCaloConstants->GetCRITICENERGY();
08a69753 68 Float_t Cj = fCaloConstants->GetCJ();
69
70 // tapering angles
85e654fb 71 Float_t teta0 = fCaloConstants->GetCELLANGLE(); //tapering angle (deg)
72 Float_t teta1; //working angle
73 Float_t L = fCaloConstants->GetCELLHEIGHT();
08a69753 74
85e654fb 75 // converting to MEV
76 Float_t E = recPoint.fAmp * 1000;
08a69753 77
85e654fb 78 Double_t glob[3] ={0,0,0};
79 Double_t loc[3] = {0,0,0};
80
81 if (recPoint.fZ >= 47.51 || recPoint.fZ< -0.51) {
08a69753 82 //Logging(kHLTLogError, "HLT", "EMCAL", "AliHLTEMCALGeometry::GetGlobalCoordinates: invalid Z: %f from recpoint ", recPoint.fZ);
85e654fb 83 return;
84 }
85
86 if (recPoint.fX >= 23.51 || recPoint.fX< -0.51) {
08a69753 87 //Logging(kHLTLogError, "HLT", "EMCAL", "AliHLTEMCALGeometry::GetGlobalCoordinates: invalid X: % from recpoint ", recPoint.fX);
85e654fb 88 return;
89 }
90
91
92 switch ( recPoint.fParticle )
93 {
94 case 0:
95 Cj = - fCaloConstants->GetCJ(); // photon
96 d = X0 * TMath::Log( E / Ecr + Cj);
97 break;
98
99 case 1:
100 Cj = + fCaloConstants->GetCJ(); // electron
101 d = X0 * TMath::Log( E / Ecr + Cj);
102 break;
103
104 case 2:
105 // hadron
106 d = 0.5 * L;
107 break;
108
109 default:
110 Cj = - fCaloConstants->GetCJ(); // defaulting to photon
111 d = X0 * TMath::Log( E / Ecr + Cj);
112 }
113
114 istrip = int ((recPoint.fZ + 0.5 ) / 2);
115
116 // module angle
117 teta1 = TMath::DegToRad() * istrip * teta0;
5308534b 118
85e654fb 119 // calculation of module corner along z
120 // as a function of strip
22406a6a 121
85e654fb 122 for (Int_t is=0; is<= istrip; is++) {
22406a6a 123
85e654fb 124 teta1 = TMath::DegToRad() * is * teta0;
22406a6a 125
85e654fb 126 z_is = z_is + 2*dz*(TMath::Sin(teta1)*TMath::Tan(teta1) + TMath::Cos(teta1));
22406a6a 127
85e654fb 128 }
22406a6a 129
85e654fb 130 z0 = dz * (recPoint.fZ - 2*istrip + 0.5);
131 zb = (2*dz-z0-d*TMath::Tan(teta1))*TMath::Cos(teta1);
5308534b 132
85e654fb 133 z = z_is - zb*TMath::Cos(teta1);
5308534b 134
85e654fb 135 // cout << "----> istrip: " << istrip << endl;
136 // cout << "----> z0: "<< z0 << endl;
137 // cout << "----> zb: "<< zb << endl;
138 // cout << "----> corner z: "<< z_is << endl;
85e654fb 139 // cout << "----> teta1: "<< TMath::RadToDeg()*teta1 << endl;
22406a6a 140
85e654fb 141 y = d/TMath::Cos(teta1) + zb*TMath::Sin(teta1);
22406a6a 142
85e654fb 143 x = (recPoint.fX + 0.5)*dx;
22406a6a 144
85e654fb 145 // cout << "x: " << x << " y: "<< y << " z " << z << endl;
22406a6a 146
85e654fb 147 // check coordinate origin
148 loc[0] = x;
149 loc[1] = y;
150 loc[2] = z;
22406a6a 151
85e654fb 152 if(!fGeo)
153 {
22406a6a 154 Logging(kHLTLogError, "HLT", "EMCAL", "AliHLTEMCALGeometry::GetGlobalCoordinates: no geometry initialised");
155 return;
85e654fb 156 }
22406a6a 157
08a69753 158 //cout << "recpoint Particle " << recPoint.fParticle << endl;
159 // cout << "recpoint Module " << recPoint.fModule << endl;
160
161 fGeo->GetGlobal(loc, glob, recPoint.fModule);
162
163
164 // cout << "recpoint Amp " << recPoint.fAmp << endl;
165
166 ConvertRecPointCoordinates(loc[0], loc[1], loc[2]);
22406a6a 167
08a69753 168 //cout << "after conversion ";
169 //cout << "x: " << loc[0] << " y: "<< loc[1] << " z " << loc[2] << endl;
22406a6a 170
08a69753 171 fGeo->GetGlobal(&loc[0], &glob[0], recPoint.fModule);
172
173 //cout << "global cooordinates after call:";
174 //cout << "x: " << glob[0] << " y: "<< glob[1] << " z " << glob[2] << endl;
175
176 globalCoord.fX = glob[0];
177 globalCoord.fY = glob[1];
178 globalCoord.fZ = glob[2];
5308534b 179}
180
181void
b64e6e99 182AliHLTEMCALGeometry::GetCellAbsId(UInt_t module, UInt_t x, UInt_t z, Int_t& AbsId)
5308534b 183{
22406a6a 184
85e654fb 185 if(!fGeo)
186 {
187 Logging(kHLTLogError, "HLT", "EMCAL", "AliHLTEMCALGeometry::GetCellAbsId: no geometry initialised");
188 return;
22406a6a 189
85e654fb 190 }
08a69753 191 AbsId = fGeo->GetAbsCellIdFromCellIndexes(module, (Int_t) x, (Int_t) z);
192
193
5308534b 194
195}
196
22406a6a 197void AliHLTEMCALGeometry::ConvertRecPointCoordinates(Double_t &x, Double_t &y, Double_t &z) const
198{
5308534b 199
08a69753 200 //FIXME
201 // this should be read from GEANT box dimensions
202 Double_t DX = 13.869008;
203 Double_t DY = 72.559998;
204 Double_t DZ = 175.00000;
205
206 // from our local frame to GEANT local frame
207 x = y - DX; //FIXME
208 y = -x + DY; //FIXME
209 z = z - DZ; //FIXME
22406a6a 210
211}
212
213
214int
215AliHLTEMCALGeometry::GetGeometryFromCDB()
216{
22406a6a 217
85e654fb 218 // AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
22406a6a 219
220 AliCDBPath path("GRP","Geometry","Data");
221 if(path.GetPath())
222 {
223 // HLTInfo("configure from entry %s", path.GetPath());
224 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
225 if (pEntry)
226 {
08a69753 227 if(!fGeo)
22406a6a 228 {
08a69753 229 delete fGeo;
230 fGeo = 0;
22406a6a 231 }
232
233 gGeoManager = (TGeoManager*) pEntry->GetObject();
22406a6a 234
235 if(gGeoManager)
236 {
237 fGeo = new AliEMCALGeoUtils("EMCAL_COMPLETE","EMCAL");
22406a6a 238 }
239
240 }
241 else
242 {
08a69753 243 //HLTError("can not fetch object \"%s\" from OCDB", path);
244 Logging(kHLTLogError, "HLT", "EMCAL", "can not fetch object from OCDB");
245
22406a6a 246 }
247 }
248 return 0;
249}