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 *
6 * Author: federico ronchetti 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 #include "AliHLTEMCALGeometry.h"
18 #include "AliHLTEMCALConstants.h"
19 #include "AliCDBEntry.h"
20 #include "AliCDBManager.h"
21 #include "AliCDBPath.h"
24 ClassImp(AliHLTEMCALGeometry);
25 TGeoManager *gGeoManager = 0;
27 AliHLTEMCALGeometry::AliHLTEMCALGeometry() :
28 AliHLTCaloGeometry ("EMCAL"),
32 //fGeo = new AliEMCALGeoUtils("EMCAL_COMPLETE","EMCAL");
33 //fGeo = new AliEMCALGeometry("EMCAL_COMPLETE","EMCAL");
34 //fGeo = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
35 //TGeoManager::Import("/home/fedro/work/AliRoot/test/QA/geometry.root");
40 Int_t AliHLTEMCALGeometry::InitialiseGeometry()
43 return GetGeometryFromCDB();
47 AliHLTEMCALGeometry::~AliHLTEMCALGeometry()
53 AliHLTEMCALGeometry::GetGlobalCoordinates(AliHLTCaloRecPointDataStruct &recPoint, AliHLTCaloGlobalCoordinate &globalCoord)
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
65 // parameters for shower depth calculation
66 Float_t X0 = fCaloConstants->GetRADLENGTH();
67 Float_t Ecr = fCaloConstants->GetCRITICENERGY();
68 Float_t Cj = fCaloConstants->GetCJ();
71 Float_t teta0 = fCaloConstants->GetCELLANGLE(); //tapering angle (deg)
72 Float_t teta1; //working angle
73 Float_t L = fCaloConstants->GetCELLHEIGHT();
76 Float_t E = recPoint.fAmp * 1000;
78 Double_t glob[3] ={0,0,0};
79 Double_t loc[3] = {0,0,0};
81 if (recPoint.fZ >= 47.51 || recPoint.fZ< -0.51) {
82 //Logging(kHLTLogError, "HLT", "EMCAL", "AliHLTEMCALGeometry::GetGlobalCoordinates: invalid Z: %f from recpoint ", recPoint.fZ);
86 if (recPoint.fX >= 23.51 || recPoint.fX< -0.51) {
87 //Logging(kHLTLogError, "HLT", "EMCAL", "AliHLTEMCALGeometry::GetGlobalCoordinates: invalid X: % from recpoint ", recPoint.fX);
92 switch ( recPoint.fParticle )
95 Cj = - fCaloConstants->GetCJ(); // photon
96 d = X0 * TMath::Log( E / Ecr + Cj);
100 Cj = + fCaloConstants->GetCJ(); // electron
101 d = X0 * TMath::Log( E / Ecr + Cj);
110 Cj = - fCaloConstants->GetCJ(); // defaulting to photon
111 d = X0 * TMath::Log( E / Ecr + Cj);
114 istrip = int ((recPoint.fZ + 0.5 ) / 2);
117 teta1 = TMath::DegToRad() * istrip * teta0;
119 // calculation of module corner along z
120 // as a function of strip
122 for (Int_t is=0; is<= istrip; is++) {
124 teta1 = TMath::DegToRad() * is * teta0;
126 z_is = z_is + 2*dz*(TMath::Sin(teta1)*TMath::Tan(teta1) + TMath::Cos(teta1));
130 z0 = dz * (recPoint.fZ - 2*istrip + 0.5);
131 zb = (2*dz-z0-d*TMath::Tan(teta1))*TMath::Cos(teta1);
133 z = z_is - zb*TMath::Cos(teta1);
135 // cout << "----> istrip: " << istrip << endl;
136 // cout << "----> z0: "<< z0 << endl;
137 // cout << "----> zb: "<< zb << endl;
138 // cout << "----> corner z: "<< z_is << endl;
139 // cout << "----> teta1: "<< TMath::RadToDeg()*teta1 << endl;
141 y = d/TMath::Cos(teta1) + zb*TMath::Sin(teta1);
143 x = (recPoint.fX + 0.5)*dx;
145 // cout << "x: " << x << " y: "<< y << " z " << z << endl;
147 // check coordinate origin
154 Logging(kHLTLogError, "HLT", "EMCAL", "AliHLTEMCALGeometry::GetGlobalCoordinates: no geometry initialised");
158 //cout << "recpoint Particle " << recPoint.fParticle << endl;
159 // cout << "recpoint Module " << recPoint.fModule << endl;
161 fGeo->GetGlobal(loc, glob, recPoint.fModule);
164 // cout << "recpoint Amp " << recPoint.fAmp << endl;
166 ConvertRecPointCoordinates(loc[0], loc[1], loc[2]);
168 //cout << "after conversion ";
169 //cout << "x: " << loc[0] << " y: "<< loc[1] << " z " << loc[2] << endl;
171 fGeo->GetGlobal(&loc[0], &glob[0], recPoint.fModule);
173 //cout << "global cooordinates after call:";
174 //cout << "x: " << glob[0] << " y: "<< glob[1] << " z " << glob[2] << endl;
176 globalCoord.fX = glob[0];
177 globalCoord.fY = glob[1];
178 globalCoord.fZ = glob[2];
182 AliHLTEMCALGeometry::GetCellAbsId(UInt_t module, Double_t x, Double_t z, Int_t& AbsId)
187 Logging(kHLTLogError, "HLT", "EMCAL", "AliHLTEMCALGeometry::GetCellAbsId: no geometry initialised");
191 AbsId = fGeo->GetAbsCellIdFromCellIndexes(module, (Int_t) x, (Int_t) z);
197 void AliHLTEMCALGeometry::ConvertRecPointCoordinates(Double_t &x, Double_t &y, Double_t &z) const
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;
206 // from our local frame to GEANT local frame
215 AliHLTEMCALGeometry::GetGeometryFromCDB()
218 // AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
220 AliCDBPath path("GRP","Geometry","Data");
223 // HLTInfo("configure from entry %s", path.GetPath());
224 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
233 gGeoManager = (TGeoManager*) pEntry->GetObject();
237 fGeo = new AliEMCALGeoUtils("EMCAL_COMPLETE","EMCAL");
243 //HLTError("can not fetch object \"%s\" from OCDB", path);
244 Logging(kHLTLogError, "HLT", "EMCAL", "can not fetch object from OCDB");