]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALGeometry.cxx
remove static from variables which are initialized
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGeometry.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$*/
17
18 //_________________________________________________________________________
19 // Geometry class  for EMCAL : singleton  
20 // EMCAL consists of layers of scintillator and lead
21 // with scintillator fiber arranged as "shish-kebab" skewers 
22 // Places the the Barrel Geometry of The EMCAL at Midrapidity
23 // between 80 and 180(or 190) degrees of Phi and
24 // -0.7 to 0.7 in eta 
25 //
26 //     EMCAL geometry tree:
27 //     EMCAL -> superModule -> module -> tower(cell)
28 //     Indexes
29 //     absId -> nSupMod     -> nModule -> (nIphi,nIeta)
30 //
31 //   Name choices: 
32 //   EMCAL_PDC06 (geometry used for PDC06 simulations, kept for backward compatibility)
33 //      = equivalent to SHISH_77_TRD1_2X2_FINAL_110DEG in old notation
34 //   EMCAL_COMPLETE (geometry for expected complete detector)
35 //      = equivalent to SHISH_77_TRD1_2X2_FINAL_110DEG scTh=0.176 pbTh=0.144
36 //          in old notation
37 //   EMCAL_WSUC (Wayne State test stand)
38 //      = no definite equivalent in old notation, was only used by
39 //          Aleksei, but kept for testing purposes
40 //
41 //   etc.
42 //
43 //
44 //
45 //*-- Author: Sahal Yacoob (LBL / UCT)
46 //     and  : Yves Schutz (SUBATECH)
47 //     and  : Jennifer Klay (LBL)
48 //     and  : Aleksei Pavlinov (WSU) 
49 //
50
51 //--- Root header files ---
52 #include <TVector2.h>
53 #include <TVector3.h>
54 //-- ALICE Headers.
55 #include "AliLog.h"
56
57 // // --- EMCAL headers
58 #include "AliEMCALGeometry.h"
59 #include "AliEMCALShishKebabTrd1Module.h"
60 //#include "AliEMCALRecPoint.h"
61 //#include "AliEMCALHistoUtilities.h"
62
63 ClassImp(AliEMCALGeometry)
64
65 // these initialisations are needed for a singleton
66 AliEMCALGeometry  *AliEMCALGeometry::fgGeom      = 0;
67 const Char_t*      AliEMCALGeometry::fgkDefaultGeometryName = "EMCAL_COMPLETE";
68 //
69 // Usage: 
70 //        You can create the AliEMCALGeometry object independently from anything.
71 //        You have to use just the correct name of geometry. If name is empty string the
72 //        default name of geometry will be used.
73 //         
74 //  AliEMCALGeometry* g = AliEMCALGeometry::GetInstance(name,title); // first time
75 //  ..
76 //  g = AliEMCALGeometry::GetInstance();                             // after first time
77 //
78 //  MC:   If you work with MC data you have to get geometry the next way: 
79 //  ==                                      =============================
80 //  AliRunLoader    *rl   = AliRunLoader::Instance();
81 //  AliEMCALGeometry *geom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
82 //  TGeoManager::Import("geometry.root");
83
84 AliEMCALGeometry::AliEMCALGeometry() 
85   : AliEMCALGeoUtils()
86
87   // default ctor only for internal usage (singleton)
88   // must be kept public for root persistency purposes, 
89   // but should never be called by the outside world    
90
91   AliDebug(2, "AliEMCALGeometry : default ctor ");
92 }
93 //______________________________________________________________________
94 AliEMCALGeometry::AliEMCALGeometry(const Text_t* name, const Text_t* title) 
95   : AliEMCALGeoUtils(name, title)
96 {
97   // ctor only for internal usage (singleton)
98   AliDebug(2, Form("AliEMCALGeometry(%s,%s) ", name,title));
99
100 }
101 //______________________________________________________________________
102 AliEMCALGeometry::AliEMCALGeometry(const AliEMCALGeometry& geom)
103   : AliEMCALGeoUtils(geom)
104 {
105   //copy ctor
106 }
107
108 //______________________________________________________________________
109 AliEMCALGeometry::~AliEMCALGeometry(void){
110     // dtor
111 }
112
113
114 //______________________________________________________________________
115 AliEMCALGeometry *  AliEMCALGeometry::GetInstance(){ 
116   // Returns the pointer of the unique instance
117   
118   AliEMCALGeometry * rv = static_cast<AliEMCALGeometry *>( fgGeom );
119   return rv; 
120 }
121
122 //______________________________________________________________________
123 AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
124                                                 const Text_t* title){
125     // Returns the pointer of the unique instance
126
127     AliEMCALGeometry * rv = 0; 
128     if ( fgGeom == 0 ) {
129       if ( strcmp(name,"") == 0 ) { // get default geometry
130          fgGeom = new AliEMCALGeometry(fgkDefaultGeometryName, title);
131       } else {
132          fgGeom = new AliEMCALGeometry(name, title);
133       }  // end if strcmp(name,"")
134       if ( AliEMCALEMCGeometry::fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
135       else {
136          rv = 0; 
137          delete fgGeom; 
138          fgGeom = 0; 
139       } // end if fgInit
140     }else{
141         if ( strcmp(fgGeom->GetName(), name) != 0) {
142           printf("\ncurrent geometry is %s : ", fgGeom->GetName());
143           printf(" you cannot call %s ",name);  
144         }else{
145           rv = (AliEMCALGeometry *) fgGeom; 
146         } // end 
147     }  // end if fgGeom
148     return rv; 
149 }
150
151 //________________________________________________________________________________________________
152 Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t distEff, Double_t &xr, Double_t &yr, Double_t &zr) const
153 {
154   // Jul 30, 2007 - taking into account position of shower max
155   // Look to see what the relative
156   // position inside a given cell is
157   // for a recpoint.
158   // In:
159   // absId   - cell is as in Geant,     0<= absId   < fNCells;
160   // e       - cluster energy
161   // OUT:
162   // xr,yr,zr - x,y,z coordinates of cell with absId inside SM 
163
164   // Shift index taking into account the difference between standard SM 
165   // and SM of half size in phi direction
166   const  Int_t kphiIndexShift = fCentersOfCellsPhiDir.GetSize()/4; // Nov 22, 2006; was 6 for cas 2X2
167   static Int_t nSupMod=0, nModule=-1, nIphi=-1, nIeta=-1, iphi=-1, ieta=-1;
168   static Int_t iphim=-1, ietam=-1;
169   static AliEMCALShishKebabTrd1Module *mod = 0;
170   static TVector2 v;
171   if(!CheckAbsCellId(absId)) return kFALSE;
172   
173   GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
174   GetModulePhiEtaIndexInSModule(nSupMod, nModule, iphim, ietam);
175   GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta); 
176   
177   //Get eta position. Careful with ALICE conventions (increase index decrease eta)      
178   if(nSupMod%2 == 0) {             
179     ietam = (fCentersOfCellsEtaDir.GetSize()/2-1)-ietam;// 47-ietam, revert the ordering on A side in order to keep convention.
180     if(nIeta == 0) nIeta = 1;
181     else           nIeta = 0;
182   }
183   mod = GetShishKebabModule(ietam);
184   mod ->GetPositionAtCenterCellLine(nIeta, distEff, v); 
185   xr = v.Y() - fParSM[0];
186   zr = v.X() - fParSM[2];
187   
188   //Get phi position. Careful with ALICE conventions (increase index increase phi)
189   Int_t iphi2 = iphi;
190   if(nSupMod<10) { 
191     if(nSupMod%2 != 0) 
192       iphi2 = (fCentersOfCellsPhiDir.GetSize()-1)-iphi;// 23-iphi, revert the ordering on C side in order to keep convention.
193     yr = fCentersOfCellsPhiDir.At(iphi2);
194     
195   } else {
196     if(nSupMod%2 != 0) 
197       iphi2 = (fCentersOfCellsPhiDir.GetSize()/2-1)-iphi;// 11-iphi, revert the ordering on C side in order to keep convention.
198     yr = fCentersOfCellsPhiDir.At(iphi2 + kphiIndexShift);
199   }
200   
201   AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr));
202   
203   return kTRUE;
204 }
205
206 //Not in use, comment for the moment
207 //________________________________________________________________________________________________
208 //Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Int_t maxAbsId, Double_t distEff, Double_t &xr, Double_t &yr, Double_t &zr) const
209 //{
210 //  // Jul 31, 2007 - taking into account position of shower max and apply coor2.
211 //  // Look to see what the relative
212 //  // position inside a given cell is
213 //  // for a recpoint.
214 //  // In:
215 //  // absId     - cell is as in Geant,     0<= absId   < fNCells;
216 //  // maxAbsId  - abs id of cell with highest energy
217 //  // e         - cluster energy
218 //  // OUT:
219 //  // xr,yr,zr - x,y,z coordinates of cell with absId inside SM 
220 //  
221 //  // Shift index taking into account the difference between standard SM 
222 //  // and SM of half size in phi direction
223 //  const  Int_t kphiIndexShift = fCentersOfCellsPhiDir.GetSize()/4; // Nov 22, 2006; was 6 for cas 2X2
224 //  static Int_t nSupMod, nModule, nIphi, nIeta, iphi, ieta;
225 //  static Int_t iphim, ietam;
226 //  static AliEMCALShishKebabTrd1Module *mod = 0;
227 //  static TVector2 v;
228 //
229 //  static Int_t nSupModM, nModuleM, nIphiM, nIetaM, iphiM, ietaM;
230 //  static Int_t iphimM, ietamM, maxAbsIdCopy=-1;
231 //  static AliEMCALShishKebabTrd1Module *modM = 0;
232 //  static Double_t distCorr;
233 //
234 //  if(!CheckAbsCellId(absId)) return kFALSE;
235 //  
236 //  GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
237 //  GetModulePhiEtaIndexInSModule(nSupMod, nModule, iphim, ietam);
238 //  GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta); 
239 //  
240 //  //Get eta position. Careful with ALICE conventions (increase index decrease eta)    
241 //  if(nSupMod%2 == 0) {             
242 //    ietam = (fCentersOfCellsEtaDir.GetSize()/2-1)-ietam;// 23-ietam, revert the ordering on A side in order to keep convention.
243 //    if(nIeta == 0) nIeta = 1;
244 //    else                 nIeta = 0;
245 //  }
246 //  
247 //  mod = GetShishKebabModule(ietam);
248 //  
249 //  if(absId != maxAbsId) {
250 //    distCorr = 0.;
251 //    if(maxAbsIdCopy != maxAbsId) {
252 //      GetCellIndex(maxAbsId, nSupModM, nModuleM, nIphiM, nIetaM);
253 //      GetModulePhiEtaIndexInSModule(nSupModM, nModuleM, iphimM, ietamM);
254 //      GetCellPhiEtaIndexInSModule(nSupModM,nModuleM,nIphiM,nIetaM, iphiM, ietaM); 
255 //      //Careful with ALICE conventions (increase index decrease eta)  
256 //      if(nSupModM%2 == 0) {             
257 //      ietamM = (fCentersOfCellsEtaDir.GetSize()/2-1)-ietamM;// 47-ietam, revert the ordering on A side in order to keep convention.
258 //      }
259 //      
260 //      modM = GetShishKebabModule(ietamM); // do I need this ?
261 //      maxAbsIdCopy = maxAbsId;
262 //    }
263 //    
264 //    if(ietamM !=0) {
265 //      distCorr = fEMCGeometry->GetEtaModuleSize()*(ietam-ietamM)/TMath::Tan(modM->GetTheta()); // Stay here
266 //      //printf(" distCorr %f | dist %f | ietam %i -> etamM %i\n", distCorr, dist, ietam, ietamM);  
267 //    }
268 //    // distEff += distCorr;
269 //  }
270 //  // Bad resolution in this case, strong bias vs phi
271 //  // distEff = 0.0; 
272 //  mod->GetPositionAtCenterCellLine(nIeta, distEff, v); // Stay here
273 //  xr = v.Y() - fParSM[0];
274 //  zr = v.X() - fParSM[2];
275 //  
276 //  //Get phi position. Careful with ALICE conventions (increase index increase phi)
277 //  Int_t iphi2 = iphi;
278 //  if(nSupMod<10) { 
279 //    if(nSupMod%2 != 0) 
280 //      iphi2 = (fCentersOfCellsPhiDir.GetSize()-1)-iphi;// 23-iphi, revert the ordering on C side in order to keep convention.
281 //    yr = fCentersOfCellsPhiDir.At(iphi2);
282 //    
283 //  } else {
284 //    if(nSupMod%2 != 0) 
285 //      iphi2 = (fCentersOfCellsPhiDir.GetSize()/2-1)-iphi;// 11-iphi, revert the ordering on C side in order to keep convention.
286 //    yr = fCentersOfCellsPhiDir.At(iphi2 + kphiIndexShift);
287 //  }
288 //  AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr));
289 //  
290 //  return kTRUE;
291 //}
292 //
293
294 //
295 // == Shish-kebab cases ==
296 //
297
298 //
299 ////_________________________________________________________________________________
300 //void AliEMCALGeometry::GetGlobalEMCAL(const AliEMCALRecPoint *rp, TVector3 &vglob) const
301 //{
302 //  // Figure out the global numbering
303 //  // of a given supermodule from the
304 //  // local numbering for RecPoints
305 //
306 //  static TVector3 vloc;
307 //  static Int_t nSupMod, nModule, nIphi, nIeta;
308 //
309 //  const AliEMCALRecPoint *rpTmp = rp;
310 //  const AliEMCALRecPoint *rpEmc = rpTmp;
311 //
312 //  GetCellIndex(rpEmc->GetAbsId(0), nSupMod, nModule, nIphi, nIeta);
313 //  rpTmp->GetLocalPosition(vloc);
314 //  GetGlobal(vloc, vglob, nSupMod);
315 //}
316