]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/CALO/AliHLTEMCALGeometry.cxx
Updated branch aliroot-master, development and master to
[u/mrichter/AliRoot.git] / HLT / CALO / AliHLTEMCALGeometry.cxx
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  **************************************************************************/
16
17 #include "AliHLTEMCALGeometry.h"
18 #include "AliHLTEMCALConstants.h"
19 #include "AliCDBEntry.h"
20 #include "AliCDBManager.h"
21 #include "AliCDBPath.h"
22
23
24 ClassImp(AliHLTEMCALGeometry);
25 TGeoManager *gGeoManager = 0;
26
27 AliHLTEMCALGeometry::AliHLTEMCALGeometry() :
28         AliHLTCaloGeometry ("EMCAL"),
29         fGeo(0),fReco(0)
30 {
31   GetGeometryFromCDB();
32 }
33
34 Int_t AliHLTEMCALGeometry::InitialiseGeometry()
35 {
36    
37    return GetGeometryFromCDB();
38 }
39
40
41 AliHLTEMCALGeometry::~AliHLTEMCALGeometry()
42 {
43
44 }
45   
46 void 
47 AliHLTEMCALGeometry::GetGlobalCoordinates(AliHLTCaloRecPointDataStruct &recPoint, AliHLTCaloGlobalCoordinate &globalCoord, Int_t iParticle)
48 {
49
50   Float_t fDepth = 0;
51   // remove misalignments for 2010
52   //Float_t *fRot = fReco->GetMisalRotShiftArray();
53   //Float_t *fTrans = fReco->GetMisalTransShiftArray();
54   
55   Float_t fRot[15];
56   Float_t fTrans[15];
57
58   Float_t glob[] = {0.,0.,0.};
59
60   // Zeroing out misaligments 
61   for (Int_t i = 0; i<14; i++) { fRot[i] = 0; fTrans[i] = 0; }
62   
63   //assume only photon for the moment
64   
65   if (recPoint.fX>=-0.5 && recPoint.fZ>=-0.5) // -0.5 is the extreme border of 0,0 cell
66     
67     {
68       if (iParticle == 1)  // electron case
69         fDepth = fReco->GetDepth(recPoint.fAmp, AliEMCALRecoUtils::kElectron, recPoint.fModule);
70       else if (iParticle == 2) // hadron case 
71         fDepth = fReco->GetDepth(recPoint.fAmp, AliEMCALRecoUtils::kHadron, recPoint.fModule);
72       else // anything else is photon
73         fDepth = fReco->GetDepth(recPoint.fAmp, AliEMCALRecoUtils::kPhoton, recPoint.fModule);
74     }
75   
76   else {
77     HLTDebug("W-AliHLTEMCALGeometry: got cluster with negative flags in coordinates.");
78     return; // we don't want to give out strange coordinates to event display
79   }
80   
81   fGeo->RecalculateTowerPosition(recPoint.fX, recPoint.fZ,recPoint.fModule, fDepth, fTrans, fRot, glob);
82   
83   globalCoord.fX = glob[0];
84   globalCoord.fY = glob[1];
85   globalCoord.fZ = glob[2];
86   
87
88 }
89
90 void 
91 AliHLTEMCALGeometry::GetCellAbsId(UInt_t module, UInt_t x, UInt_t z, Int_t& AbsId)
92 {
93
94   if(!fGeo)
95     {
96       Logging(kHLTLogError, "HLT", "EMCAL", "AliHLTEMCALGeometry::GetCellAbsId: no geometry initialised");
97       return;
98
99     }
100         AbsId = fGeo->GetAbsCellIdFromCellIndexes(module, (Int_t) x, (Int_t) z);
101
102
103         
104 }
105
106
107 int
108 AliHLTEMCALGeometry::GetGeometryFromCDB()
109 {
110   // local path to OCDB
111   // AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
112
113   AliCDBPath path("GRP","Geometry","Data");
114   if(path.GetPath())
115     {
116       //      HLTInfo("configure from entry %s", path.GetPath());
117       AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
118       if (pEntry)
119         {
120           if(!fGeo)
121             {
122               delete fGeo;
123               fGeo = 0;
124             }
125           if(!gGeoManager)
126           {
127             gGeoManager = (TGeoManager*) pEntry->GetObject();
128           }
129
130           if(gGeoManager)
131             {
132               HLTDebug("Getting geometry from CDB");
133               fGeo = AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1");
134               //fGeo = new AliEMCALGeoUtils("EMCAL_COMPLETE","EMCAL");
135               fReco = new AliEMCALRecoUtils;
136               
137               // Old misalignments for 2010
138               // We don't use them now
139               /*
140               fReco->SetMisalTransShift(0,1.08); 
141               fReco->SetMisalTransShift(1,8.35); 
142               fReco->SetMisalTransShift(2,1.12); //sector 0
143               fReco->SetMisalRotShift(3,-8.05); 
144               fReco->SetMisalRotShift(4,8.05); 
145               fReco->SetMisalTransShift(3,-0.42); 
146               fReco->SetMisalTransShift(5,1.55);//sector 1
147               */
148             }
149
150         }
151       else
152         {
153           //HLTError("can not fetch object \"%s\" from OCDB", path);
154           Logging(kHLTLogError, "HLT", "EMCAL", "can not fetch object from OCDB");
155
156         }
157     }
158   return 0;
159 }
160
161 void AliHLTEMCALGeometry::GetLocalCoordinatesFromAbsId(Int_t absId, Int_t& module, Int_t& x, Int_t& z)
162 {
163   Int_t mod; // not super module
164   Int_t tmpx;
165   Int_t tmpz;
166   
167   fGeo->GetCellIndex(absId, module, mod, tmpx, tmpz);
168   fGeo->GetCellPhiEtaIndexInSModule(module,mod,tmpx,tmpz, x, z);
169   
170   HLTDebug("ID: %d, smodule: %d, mod: %d, x: %d, z: %d", absId, module, mod, x, z);
171 }