new function EtaPhiFromIndex
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGeometry.h
CommitLineData
2012850d 1#ifndef ALIEMCALGEOMETRY_H
2#define ALIEMCALGEOMETRY_H
1963b290 3/* Copyright(c) 1998-2004, ALICE Experiment at CERN, All rights reserved. *
2012850d 4 * See cxx source for full Copyright notice */
5
6/* $Id$ */
7
8//_________________________________________________________________________
9// Geometry class for EMCAL : singleton
b13bbe81 10// EMCAL consists of a layers of scintillator, and lead.
2012850d 11//
b13bbe81 12//*-- Author: Sahal Yacoob (LBL / UCT)
13//*-- and : Yves Schutz (Subatech)
c63c3c5d 14//*-- and : Aleksei Pavlinov (WSU) - shashlyk staff
f0377b23 15//*-- and : Gustavo Conesa: Add TRU mapping. TRU parameters still not fixed.
2012850d 16
17// --- ROOT system ---
d64c959b 18class TString ;
c63c3c5d 19class TObjArray;
e52475ed 20class TVector3;
21class TGeoMatrix;
cad18b88 22class TParticle ;
e52475ed 23class AliEMCALShishKebabTrd1Module;
24class AliEMCALRecPoint;
f0377b23 25class TClonesArray ;
2012850d 26
2012850d 27// --- AliRoot header files ---
2012850d 28#include "AliGeometry.h"
d434833b 29#include "AliEMCALAlignData.h"
dc7da436 30#include "TArrayD.h"
2012850d 31
2012850d 32class AliEMCALGeometry : public AliGeometry {
a97849a9 33public:
39200c71 34 AliEMCALGeometry(const AliEMCALGeometry& geom):AliGeometry(geom) {
a97849a9 35 // cpy ctor requested by Coding Convention but not yet needed
d64c959b 36 Fatal("Cpy ctor", "Not implemented");
a97849a9 37 };
d434833b 38 virtual ~AliEMCALGeometry(void);
39
a97849a9 40 static AliEMCALGeometry * GetInstance(const Text_t* name,
41 const Text_t* title="") ;
42 static AliEMCALGeometry * GetInstance() ;
9c0a4862 43 AliEMCALGeometry & operator = (const AliEMCALGeometry & /*rvalue*/) const {
a97849a9 44 // assignement operator requested by coding convention but not needed
fdebddeb 45 Fatal("operator =", "not implemented");
d434833b 46 return *(GetInstance());
a97849a9 47 };
356fd0a9 48
49 void FillTRU(const TClonesArray * digits, TClonesArray * amptru, TClonesArray * timeRtru) ; //Fills Trigger Unit matrices with digit amplitudes and time
03ecfe88 50 void GetCellPhiEtaIndexInSModuleFromTRUIndex(Int_t itru, Int_t iphitru, Int_t ietatru, Int_t &ietaSM, Int_t &iphiSM) const ; // Tranforms Eta-Phi Cell index in TRU into Eta-Phi index in Super Module
356fd0a9 51
e52475ed 52 // Have to call GetTransformationForSM() before calculation global charachteristics
53 void GetGlobal(const Double_t *loc, Double_t *glob, int nsm) const;
54 void GetGlobal(const TVector3 &vloc, TVector3 &vglob, int nsm) const;
21cf2b24 55 void GetGlobal(Int_t absId, TVector3 &vglob) const;
e52475ed 56 // for a given tower index it returns eta and phi of center of that tower.
664bfd66 57 void EtaPhiFromIndex(Int_t absId,Float_t &eta,Float_t &phi) const;
e52475ed 58
59 // virtual void GetGlobal(const AliEMCALRecPoint *rp, TVector3 &vglob) const;
60
61 virtual void GetGlobal(const AliRecPoint *rp, TVector3 &vglob) const;
62 // Bool_t AreInSameTower(Int_t id1, Int_t id2) const ;
f0377b23 63
e8d02863 64 virtual void GetGlobal(const AliRecPoint *, TVector3 &, TMatrixF &) const {}
e52475ed 65
9e5d2067 66 virtual Bool_t Impact(const TParticle *) const {return kTRUE;}
ab37d09c 67
68 Bool_t IsInEMCAL(Double_t x, Double_t y, Double_t z) const;
a97849a9 69 // General
70 Bool_t IsInitialized(void) const { return fgInit ; }
c63c3c5d 71 // Return EMCAL geometrical parameters
a97849a9 72 // geometry
e52475ed 73 Char_t* GetNameOfEMCALEnvelope() const {return "XEN1";}
09884213 74 Float_t GetAlFrontThickness() const { return fAlFrontThick;}
75 Float_t GetArm1PhiMin() const { return fArm1PhiMin ; }
76 Float_t GetArm1PhiMax() const { return fArm1PhiMax ; }
77 Float_t GetArm1EtaMin() const { return fArm1EtaMin;}
78 Float_t GetArm1EtaMax() const { return fArm1EtaMax;}
79 Float_t GetIPDistance() const { return fIPDistance;}
80 Float_t GetIP2ECASection() const { return ( GetIPDistance() + GetAlFrontThickness() + GetGap2Active() ) ; }
81 Float_t GetEnvelop(Int_t index) const { return fEnvelop[index] ; }
82 Float_t GetShellThickness() const { return fShellThickness ; }
83 Float_t GetZLength() const { return fZLength ; }
c63c3c5d 84 Float_t GetGap2Active() const {return fGap2Active ;}
09884213 85 Float_t GetDeltaEta() const {return (fArm1EtaMax-fArm1EtaMin)/
a97849a9 86 ((Float_t)fNZ);}
09884213 87 Float_t GetDeltaPhi() const {return (fArm1PhiMax-fArm1PhiMin)/
a97849a9 88 ((Float_t)fNPhi);}
09884213 89 Int_t GetNECLayers() const {return fNECLayers ;}
90 Int_t GetNZ() const {return fNZ ;}
91 Int_t GetNEta() const {return fNZ ;}
92 Int_t GetNPhi() const {return fNPhi ;}
93 Int_t GetNTowers() const {return fNPhi * fNZ ;}
94 Float_t GetECPbRadThick()const {return fECPbRadThickness;}
95 Float_t GetECScintThick() const {return fECScintThick;}
96 Float_t GetSampling() const {return fSampling ; }
dc7da436 97 // Bool_t IsInECA(Int_t index) const { if ( (index > 0 && (index <= GetNZ() * GetNPhi()))) return kTRUE; else return kFALSE ;}
1963b290 98
e52475ed 99 Int_t GetNumberOfSuperModules() const {return fNumberOfSuperModules;}
100 Float_t GetfPhiGapForSuperModules() const {return fPhiGapForSM;}
1963b290 101 Float_t GetPhiModuleSize() const {return fPhiModuleSize;}
102 Float_t GetEtaModuleSize() const {return fEtaModuleSize;}
103 Float_t GetFrontSteelStrip() const {return fFrontSteelStrip;}
104 Float_t GetLateralSteelStrip() const {return fLateralSteelStrip;}
105 Float_t GetPassiveScintThick() const {return fPassiveScintThick;}
106 Float_t GetPhiTileSize() const {return fPhiTileSize;}
107 Float_t GetEtaTileSize() const {return fEtaTileSize;}
108 Int_t GetNPhiSuperModule() const {return fNPhiSuperModule;}
109 Int_t GetNPHIdiv() const {return fNPHIdiv ;}
110 Int_t GetNETAdiv() const {return fNETAdiv ;}
111 Int_t GetNCells() const {return fNCells;}
f0377b23 112
113 Int_t GetNTRU() const {return fNTRU ; }
114 Int_t GetNTRUEta() const {return fNTRUEta ; }
115 Int_t GetNTRUPhi() const {return fNTRUPhi ; }
116
1963b290 117 Float_t GetSteelFrontThickness() const { return fSteelFrontThick;}
118 Float_t GetLongModuleSize() const {return fLongModuleSize;}
119
120 Float_t GetTrd1Angle() const {return fTrd1Angle;}
121 Float_t Get2Trd1Dx2() const {return f2Trd1Dx2;}
122 Float_t GetTrd2AngleY()const {return fTrd2AngleY;}
123 Float_t Get2Trd2Dy2() const {return f2Trd2Dy2;}
124 Float_t GetTubsR() const {return fTubsR;}
125 Float_t GetTubsTurnAngle() const {return fTubsTurnAngle;}
e52475ed 126
127 // TRD1 staff
128 void CreateListOfTrd1Modules();
129 TList *GetShishKebabTrd1Modules() const {return fShishKebabTrd1Modules;}
fc575e27 130 AliEMCALShishKebabTrd1Module *GetShishKebabModule(Int_t neta);
131
e52475ed 132 void GetTransformationForSM();
133 Float_t *GetSuperModulesPars() {return fParSM;}
134 TGeoMatrix *GetTransformationForSM(int i) {
135 if(i>=0 && GetNumberOfSuperModules()) return fMatrixOfSM[i];
136 else return 0;}
dc7da436 137 // abs id <-> indexes; Shish-kebab case, only TRD1 now.
138 // EMCAL -> Super Module -> module -> tower(or cell) - logic tree of EMCAL
139 // May 31, 2006; ALICE numbering scheme:
140 // see ALICE-INT-2003-038: ALICE Coordinate System and Software Numbering Convention
141 // All indexes are stared from zero now.
e52475ed 142 Int_t GetAbsCellId(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta) const;
dc7da436 143 Bool_t CheckAbsCellId(Int_t absId) const;
e52475ed 144 Bool_t GetCellIndex(Int_t absId, Int_t &nSupMod, Int_t &nTower, Int_t &nIphi, Int_t &nIeta) const;
dc7da436 145 // Local coordinate of Super Module
146 void GetModulePhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, Int_t &iphim, Int_t &ietam) const;
eb0b1051 147 void GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta,
e52475ed 148 Int_t &iphi, Int_t &ieta) const ;
149 Int_t GetSuperModuleNumber(Int_t absId) const;
150 // Methods for AliEMCALRecPoint - Frb 19, 2006
151 Bool_t RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr);
1963b290 152 // ---
e52475ed 153 Float_t AngleFromEta(Float_t eta) const { // returns theta in radians for a given pseudorapidity
a97849a9 154 return 2.0*TMath::ATan(TMath::Exp(-eta));
155 }
e52475ed 156 Float_t ZFromEtaR(Float_t r,Float_t eta) const { // returns z in for a given
a97849a9 157 // pseudorapidity and r=sqrt(x*x+y*y).
158 return r/TMath::Tan(AngleFromEta(eta));
159 }
fdebddeb 160 void SetNZ(Int_t nz) { fNZ= nz ; printf("SetNZ: Number of modules in Z set to %d", fNZ) ; }
161 void SetNPhi(Int_t nphi) { fNPhi= nphi ; printf("SetNPhi: Number of modules in Phi set to %d", fNPhi) ; }
f0377b23 162
163 void SetNTRU(Int_t ntru) {fNTRU = ntru; printf("SetNTRU: Number of TRUs per SuperModule set to %d", fNTRU) ; }
164 void SetNTRUEta(Int_t ntru) {fNTRUEta = ntru; ; printf("SetNTRU: Number of TRUs per SuperModule in Etaset to %d", fNTRUEta) ;}
165 void SetNTRUPhi(Int_t ntru) {fNTRUPhi = ntru; ; printf("SetNTRU: Number of TRUs per SuperModule in Phi set to %d", fNTRUPhi) ;}
166
fdebddeb 167 void SetSampling(Float_t samp) { fSampling = samp; printf("SetSampling: Sampling factor set to %f", fSampling) ; }
395c7ba2 168
4c431bcc 169 Int_t GetNCellsInSupMod() const {return fNCellsInSupMod;}
170 Int_t GetNCellsInTower() const {return fNCellsInTower; }
171
dc7da436 172 AliEMCALGeometry(); // default ctor only for internal usage (singleton)
d434833b 173
a97849a9 174protected:
dc7da436 175 AliEMCALGeometry(const Text_t* name, const Text_t* title);// ctor only for internal usage (singleton)
d434833b 176
177 AliEMCALGeometry(const Text_t* name, const Text_t* title, AliEMCALAlignData* alignData) :
178 AliGeometry(name, title) {// Align data in action
179 fgAlignData = alignData;
180 Init();
e52475ed 181 CreateListOfTrd1Modules();
eb0b1051 182 };
d434833b 183
fdebddeb 184 void Init(void); // initializes the parameters of EMCAL
fc575e27 185 void CheckAdditionalOptions(); //
a97849a9 186
187private:
fdebddeb 188 static AliEMCALGeometry * fgGeom; // pointer to the unique instance of the singleton
189 static Bool_t fgInit; // Tells if geometry has been succesfully set up.
fc575e27 190 static AliEMCALAlignData *fgAlignData;// Alignment data, to be replaced by AliAlignData soon
191
192 TString fGeoName; //geometry name
d434833b 193
c63c3c5d 194 TObjArray *fArrayOpts; //! array of geometry options
195
196 Float_t fAlFrontThick; // Thickness of the front Al face of the support box
fdebddeb 197 Float_t fECPbRadThickness; // cm, Thickness of the Pb radiators
198 Float_t fECScintThick; // cm, Thickness of the scintillators
199 Int_t fNECLayers; // number of scintillator layers
395c7ba2 200
fdebddeb 201 Float_t fArm1PhiMin; // Minimum angular position of EMCAL in Phi (degrees)
202 Float_t fArm1PhiMax; // Maximum angular position of EMCAL in Phi (degrees)
203 Float_t fArm1EtaMin; // Minimum pseudorapidity position of EMCAL in Eta
204 Float_t fArm1EtaMax; // Maximum pseudorapidity position of EMCAL in Eta
a97849a9 205
fdebddeb 206 // Geometry Parameters
207 Float_t fEnvelop[3]; // the GEANT TUB for the detector
208 Float_t fIPDistance; // Radial Distance of the inner surface of the EMCAL
209 Float_t fShellThickness; // Total thickness in (x,y) direction
210 Float_t fZLength; // Total length in z direction
211 Float_t fGap2Active; // Gap between the envelop and the active material
212 Int_t fNZ; // Number of Towers in the Z direction
1963b290 213 Int_t fNPhi; // Number of Towers in the PHI direction
fdebddeb 214 Float_t fSampling; // Sampling factor
1963b290 215
216 // Shish-kebab option - 23-aug-04 by PAI; COMPACT, TWIST, TRD1 and TRD2
217 Int_t fNumberOfSuperModules; // default is 12 = 6 * 2
218 Float_t fSteelFrontThick; // Thickness of the front stell face of the support box - 9-sep-04
219 Float_t fFrontSteelStrip; // 13-may-05
220 Float_t fLateralSteelStrip; // 13-may-05
221 Float_t fPassiveScintThick; // 13-may-05
222 Float_t fPhiModuleSize; // Phi -> X
223 Float_t fEtaModuleSize; // Eta -> Y
fc575e27 224 Float_t fPhiTileSize; // Size of phi tile
225 Float_t fEtaTileSize; // Size of eta tile
226 Float_t fLongModuleSize; // Size of long module
1963b290 227 Int_t fNPhiSuperModule; // 6 - number supermodule in phi direction
d87bd045 228 Int_t fNPHIdiv; // number phi divizion of module
229 Int_t fNETAdiv; // number eta divizion of module
1963b290 230 //
231 Int_t fNCells; // number of cells in calo
232 Int_t fNCellsInSupMod; // number cell in super module
c63c3c5d 233 Int_t fNCellsInTower; // number cell in tower(or module)
f0377b23 234 //TRU parameters
235 Int_t fNTRU ; //! Number of TRUs per module
236 Int_t fNTRUEta ; //! Number of cell rows per Z in one TRU
237 Int_t fNTRUPhi ; //! Number of cell rows per Phi in one TRU
1963b290 238 // TRD1 options - 30-sep-04
239 Float_t fTrd1Angle; // angle in x-z plane (in degree)
240 Float_t f2Trd1Dx2; // 2*dx2 for TRD1
905263da 241 Float_t fPhiGapForSM; // Gap betweeen supermodules in phi direction
d87bd045 242 Int_t fKey110DEG; // for calculation abs cell id; 19-oct-05
1963b290 243 // TRD2 options - 27-jan-07
244 Float_t fTrd2AngleY; // angle in y-z plane (in degree)
245 Float_t f2Trd2Dy2; // 2*dy2 for TRD2
246 Float_t fEmptySpace; // 2mm om fred drawing
d87bd045 247 // Super module as TUBS
1963b290 248 Float_t fTubsR; // radius of tubs
249 Float_t fTubsTurnAngle; // turn angle of tubs in degree
e52475ed 250 // Local Coordinates of SM
dc7da436 251 TArrayD fEtaCentersOfCells; // size fNEta*fNETAdiv (for TRD1 only) (eta or z in SM)
252 TArrayD fXCentersOfCells; // size fNEta*fNETAdiv (for TRD1 only) ( x in SM)
253 TArrayD fPhiCentersOfCells; // size fNPhi*fNPHIdiv (for TRD1 only) (phi or y in SM)
e52475ed 254 // Move from AliEMCALv0 - Feb 19, 2006
255 TList *fShishKebabTrd1Modules; //! list of modules
256 // Local coordinates of SM for TRD1
257 Float_t fParSM[3]; // SM sizes as in GEANT (TRD1)
258 TGeoMatrix* fMatrixOfSM[12]; //![fNumberOfSuperModules]; get from gGeoManager;
1963b290 259
b44d5aa4 260 char *fAdditionalOpts[4]; //! some additional options for the geometry type and name
fc575e27 261 int fNAdditionalOpts; //! size of additional options parameter
262
d434833b 263 ClassDef(AliEMCALGeometry, 10) // EMCAL geometry class
c63c3c5d 264 };
2012850d 265
266#endif // AliEMCALGEOMETRY_H