]>
Commit | Line | Data |
---|---|---|
e5a93224 | 1 | /************************************************************************** |
2012850d | 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 | |
b13bbe81 | 20 | // EMCAL consists of layers of scintillator and lead |
ffa6d63b | 21 | // Places the the Barrel Geometry of The EMCAL at Midrapidity |
d87bd045 | 22 | // between 80 and 180(or 190) degrees of Phi and |
ffa6d63b | 23 | // -0.7 to 0.7 in eta |
24 | // Number of Modules and Layers may be controlled by | |
25 | // the name of the instance defined | |
b13bbe81 | 26 | //*-- Author: Sahal Yacoob (LBL / UCT) |
27 | // and : Yves Schutz (SUBATECH) | |
28 | // and : Jennifer Klay (LBL) | |
1963b290 | 29 | // SHASHLYK : Aleksei Pavlinov (WSU) |
c63c3c5d | 30 | // SuperModules -> module(or tower) -> cell |
2012850d | 31 | |
2012850d | 32 | // --- AliRoot header files --- |
1ceeec56 | 33 | #include <assert.h> |
e52475ed | 34 | #include "Riostream.h" |
35 | ||
ca8f5bd0 | 36 | #include <TMath.h> |
116cbefd | 37 | #include <TVector3.h> |
e52475ed | 38 | #include <TArrayD.h> |
c63c3c5d | 39 | #include <TObjArray.h> |
e52475ed | 40 | #include <TGeoManager.h> |
41 | #include <TGeoNode.h> | |
42 | #include <TGeoMatrix.h> | |
f0377b23 | 43 | #include <TMatrixD.h> |
d434833b | 44 | #include <TObjString.h> |
f0377b23 | 45 | #include <TClonesArray.h> |
173558f2 | 46 | |
ca8f5bd0 | 47 | // -- ALICE Headers. |
d64c959b | 48 | //#include "AliConst.h" |
e5a93224 | 49 | #include "AliLog.h" |
173558f2 | 50 | |
ca8f5bd0 | 51 | // --- EMCAL headers |
52 | #include "AliEMCALGeometry.h" | |
e52475ed | 53 | #include "AliEMCALShishKebabTrd1Module.h" |
e52475ed | 54 | #include "AliEMCALRecPoint.h" |
f0377b23 | 55 | #include "AliEMCALDigit.h" |
d434833b | 56 | #include "AliEMCALHistoUtilities.h" |
57 | #include "AliEMCALAlignData.h" | |
2012850d | 58 | |
925e6570 | 59 | ClassImp(AliEMCALGeometry) |
2012850d | 60 | |
d434833b | 61 | // these initialisations are needed for a singleton |
62 | AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0; | |
63 | Bool_t AliEMCALGeometry::fgInit = kFALSE; | |
64 | AliEMCALAlignData *AliEMCALGeometry::fgAlignData = 0; | |
65 | ||
b13bbe81 | 66 | //______________________________________________________________________ |
67 | AliEMCALGeometry::~AliEMCALGeometry(void){ | |
68 | // dtor | |
2012850d | 69 | } |
395c7ba2 | 70 | //______________________________________________________________________ |
71 | void AliEMCALGeometry::Init(void){ | |
72 | // Initializes the EMCAL parameters | |
fdebddeb | 73 | // naming convention : GUV_WX_N_ gives the composition of a tower |
395c7ba2 | 74 | // WX inform about the composition of the EM calorimeter section: |
fdebddeb | 75 | // thickness in mm of Pb radiator (W) and of scintillator (X), and number of scintillator layers (N) |
76 | // New geometry: EMCAL_55_25 | |
1963b290 | 77 | // 24-aug-04 for shish-kebab |
78 | // SHISH_25 or SHISH_62 | |
c63c3c5d | 79 | // 11-oct-05 - correction for pre final design |
80 | // Feb 06,2006 - decrease the weight of EMCAL | |
fc575e27 | 81 | |
82 | fAdditionalOpts[0] = "nl="; // number of sampling layers | |
83 | fAdditionalOpts[1] = "pbTh="; // cm, Thickness of the Pb | |
84 | fAdditionalOpts[2] = "scTh="; // cm, Thickness of the Sc | |
85 | ||
86 | fNAdditionalOpts = sizeof(fAdditionalOpts) / sizeof(char*); | |
87 | ||
fdebddeb | 88 | fgInit = kFALSE; // Assume failed until proven otherwise. |
fc575e27 | 89 | fGeoName = GetName(); |
90 | fGeoName.ToUpper(); | |
d87bd045 | 91 | fKey110DEG = 0; |
fc575e27 | 92 | if(fGeoName.Contains("110DEG")) fKey110DEG = 1; // for GetAbsCellId |
e52475ed | 93 | fShishKebabTrd1Modules = 0; |
94 | fTrd2AngleY = f2Trd2Dy2 = fEmptySpace = fTubsR = fTubsTurnAngle = 0; | |
1963b290 | 95 | |
96 | fNZ = 114; // granularity along Z (eta) | |
97 | fNPhi = 168; // granularity in phi (azimuth) | |
98 | fArm1PhiMin = 60.0; // degrees, Starting EMCAL Phi position | |
99 | fArm1PhiMax = 180.0; // degrees, Ending EMCAL Phi position | |
100 | fArm1EtaMin = -0.7; // pseudorapidity, Starting EMCAL Eta position | |
101 | fArm1EtaMax = +0.7; // pseudorapidity, Ending EMCAL Eta position | |
102 | fIPDistance = 454.0; // cm, Radial distance to inner surface of EMCAL | |
905263da | 103 | fPhiGapForSM = 0.; // cm, only for final TRD1 geometry |
e52475ed | 104 | for(int i=0; i<12; i++) fMatrixOfSM[i] = 0; |
1963b290 | 105 | |
106 | // geometry | |
fc575e27 | 107 | if(fGeoName.Contains("SHISH")){ // Only shahslyk now |
905263da | 108 | // 7-sep-05; integration issue |
109 | fArm1PhiMin = 80.0; // 60 -> 80 | |
c01485dd | 110 | fArm1PhiMax = 180.0; // 180 -> 190 |
905263da | 111 | |
112 | fNumberOfSuperModules = 10; // 12 = 6 * 2 (6 in phi, 2 in Z); | |
1963b290 | 113 | fSteelFrontThick = 2.54; // 9-sep-04 |
114 | fIPDistance = 460.0; | |
115 | fFrontSteelStrip = fPassiveScintThick = 0.0; // 13-may-05 | |
116 | fLateralSteelStrip = 0.025; // before MAY 2005 | |
117 | fPhiModuleSize = fEtaModuleSize = 11.4; | |
118 | fPhiTileSize = fEtaTileSize = 5.52; // (11.4-5.52*2)/2. = 0.18 cm (wall thickness) | |
119 | fNPhi = 14; | |
120 | fNZ = 30; | |
121 | fAlFrontThick = fGap2Active = 0; | |
122 | fNPHIdiv = fNETAdiv = 2; | |
123 | ||
124 | fNECLayers = 62; | |
125 | fECScintThick = fECPbRadThickness = 0.2; | |
126 | fSampling = 1.; // 30-aug-04 - should be calculated | |
fc575e27 | 127 | if(fGeoName.Contains("TWIST")) { // all about EMCAL module |
1963b290 | 128 | fNZ = 27; // 16-sep-04 |
fc575e27 | 129 | } else if(fGeoName.Contains("TRD")) { |
1963b290 | 130 | fIPDistance = 428.0; // 11-may-05 |
131 | fSteelFrontThick = 0.0; // 3.17 -> 0.0; 28-mar-05 : no stell plate | |
132 | fNPhi = 12; | |
133 | fSampling = 12.327; | |
134 | fPhiModuleSize = fEtaModuleSize = 12.26; | |
135 | fNZ = 26; // 11-oct-04 | |
136 | fTrd1Angle = 1.3; // in degree | |
137 | // 18-nov-04; 1./0.08112=12.327 | |
138 | // http://pdsfweb01.nersc.gov/~pavlinov/ALICE/SHISHKEBAB/RES/linearityAndResolutionForTRD1.html | |
fc575e27 | 139 | if(fGeoName.Contains("TRD1")) { // 30-jan-05 |
1963b290 | 140 | // for final design |
905263da | 141 | fPhiGapForSM = 2.; // cm, only for final TRD1 geometry |
fc575e27 | 142 | if(fGeoName.Contains("MAY05") || fGeoName.Contains("WSUC") || fGeoName.Contains("FINAL")){ |
1963b290 | 143 | fNumberOfSuperModules = 12; // 20-may-05 |
fc575e27 | 144 | if(fGeoName.Contains("WSUC")) fNumberOfSuperModules = 1; // 27-may-05 |
1963b290 | 145 | fNECLayers = 77; // (13-may-05 from V.Petrov) |
146 | fPhiModuleSize = 12.5; // 20-may-05 - rectangular shape | |
147 | fEtaModuleSize = 11.9; | |
148 | fECScintThick = fECPbRadThickness = 0.16;// (13-may-05 from V.Petrov) | |
149 | fFrontSteelStrip = 0.025;// 0.025cm = 0.25mm (13-may-05 from V.Petrov) | |
150 | fLateralSteelStrip = 0.01; // 0.01cm = 0.1mm (13-may-05 from V.Petrov) - was 0.025 | |
151 | fPassiveScintThick = 0.8; // 0.8cm = 8mm (13-may-05 from V.Petrov) | |
152 | fNZ = 24; | |
153 | fTrd1Angle = 1.5; // 1.3 or 1.5 | |
905263da | 154 | |
fc575e27 | 155 | if(fGeoName.Contains("FINAL")) { // 9-sep-05 |
905263da | 156 | fNumberOfSuperModules = 10; |
fc575e27 | 157 | if(fGeoName.Contains("110DEG")) { |
d87bd045 | 158 | fNumberOfSuperModules = 12;// last two modules have size 10 degree in phi (180<phi<190) |
159 | fArm1PhiMax = 200.0; // for XEN1 and turn angle of super modules | |
160 | } | |
905263da | 161 | fPhiModuleSize = 12.26 - fPhiGapForSM / Float_t(fNPhi); // first assumption |
162 | fEtaModuleSize = fPhiModuleSize; | |
fc575e27 | 163 | if(fGeoName.Contains("HUGE")) fNECLayers *= 3; // 28-oct-05 for analysing leakage |
905263da | 164 | } |
1963b290 | 165 | } |
fc575e27 | 166 | } else if(fGeoName.Contains("TRD2")) { // 30-jan-05 |
1963b290 | 167 | fSteelFrontThick = 0.0; // 11-mar-05 |
168 | fIPDistance+= fSteelFrontThick; // 1-feb-05 - compensate absence of steel plate | |
169 | fTrd1Angle = 1.64; // 1.3->1.64 | |
170 | fTrd2AngleY = fTrd1Angle; // symmetric case now | |
171 | fEmptySpace = 0.2; // 2 mm | |
172 | fTubsR = fIPDistance; // 31-jan-05 - as for Fred case | |
173 | ||
174 | fPhiModuleSize = fTubsR*2.*TMath::Tan(fTrd2AngleY*TMath::DegToRad()/2.); | |
175 | fPhiModuleSize -= fEmptySpace/2.; // 11-mar-05 | |
176 | fEtaModuleSize = fPhiModuleSize; // 20-may-05 | |
177 | fTubsTurnAngle = 3.; | |
178 | } | |
179 | fNPHIdiv = fNETAdiv = 2; // 13-oct-04 - division again | |
fc575e27 | 180 | if(fGeoName.Contains("3X3")) { // 23-nov-04 |
1963b290 | 181 | fNPHIdiv = fNETAdiv = 3; |
fc575e27 | 182 | } else if(fGeoName.Contains("4X4")) { |
1963b290 | 183 | fNPHIdiv = fNETAdiv = 4; |
184 | } | |
185 | } | |
186 | fPhiTileSize = fPhiModuleSize/2. - fLateralSteelStrip; // 13-may-05 | |
187 | fEtaTileSize = fEtaModuleSize/2. - fLateralSteelStrip; // 13-may-05 | |
188 | ||
fc575e27 | 189 | if(fGeoName.Contains("25")){ |
1963b290 | 190 | fNECLayers = 25; |
191 | fECScintThick = fECPbRadThickness = 0.5; | |
192 | } | |
fc575e27 | 193 | if(fGeoName.Contains("WSUC")){ // 18-may-05 - about common structure |
1963b290 | 194 | fShellThickness = 30.; // should be change |
195 | fNPhi = fNZ = 4; | |
196 | } | |
c63c3c5d | 197 | |
fc575e27 | 198 | CheckAdditionalOptions(); |
c63c3c5d | 199 | |
1963b290 | 200 | // constant for transition absid <--> indexes |
201 | fNCellsInTower = fNPHIdiv*fNETAdiv; | |
202 | fNCellsInSupMod = fNCellsInTower*fNPhi*fNZ; | |
203 | fNCells = fNCellsInSupMod*fNumberOfSuperModules; | |
fc575e27 | 204 | if(fGeoName.Contains("110DEG")) fNCells -= fNCellsInSupMod; |
1963b290 | 205 | |
206 | fLongModuleSize = fNECLayers*(fECScintThick + fECPbRadThickness); | |
fc575e27 | 207 | if(fGeoName.Contains("MAY05")) fLongModuleSize += (fFrontSteelStrip + fPassiveScintThick); |
1963b290 | 208 | |
209 | // 30-sep-04 | |
fc575e27 | 210 | if(fGeoName.Contains("TRD")) { |
1963b290 | 211 | f2Trd1Dx2 = fEtaModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd1Angle*TMath::DegToRad()/2.); |
fc575e27 | 212 | if(fGeoName.Contains("TRD2")) { // 27-jan-05 |
1963b290 | 213 | f2Trd2Dy2 = fPhiModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd2AngleY*TMath::DegToRad()/2.); |
214 | } | |
215 | } | |
fc575e27 | 216 | } else Fatal("Init", "%s is an undefined geometry!", fGeoName.Data()) ; |
fdebddeb | 217 | |
1963b290 | 218 | fNPhiSuperModule = fNumberOfSuperModules/2; |
219 | if(fNPhiSuperModule<1) fNPhiSuperModule = 1; | |
fdebddeb | 220 | //There is always one more scintillator than radiator layer because of the first block of aluminium |
221 | fShellThickness = fAlFrontThick + fGap2Active + fNECLayers*GetECScintThick()+(fNECLayers-1)*GetECPbRadThick(); | |
fc575e27 | 222 | if(fGeoName.Contains("SHISH")) { |
1963b290 | 223 | fShellThickness = fSteelFrontThick + fLongModuleSize; |
fc575e27 | 224 | if(fGeoName.Contains("TWIST")) { // 13-sep-04 |
1963b290 | 225 | fShellThickness = TMath::Sqrt(fLongModuleSize*fLongModuleSize + fPhiModuleSize*fEtaModuleSize); |
226 | fShellThickness += fSteelFrontThick; | |
fc575e27 | 227 | } else if(fGeoName.Contains("TRD")) { // 1-oct-04 |
1963b290 | 228 | fShellThickness = TMath::Sqrt(fLongModuleSize*fLongModuleSize + f2Trd1Dx2*f2Trd1Dx2); |
229 | fShellThickness += fSteelFrontThick; | |
e52475ed | 230 | // Local coordinates |
231 | fParSM[0] = GetShellThickness()/2.; | |
232 | fParSM[1] = GetPhiModuleSize() * GetNPhi()/2.; | |
233 | fParSM[2] = 350./2.; | |
1963b290 | 234 | } |
235 | } | |
fdebddeb | 236 | |
395c7ba2 | 237 | fZLength = 2.*ZFromEtaR(fIPDistance+fShellThickness,fArm1EtaMax); // Z coverage |
238 | fEnvelop[0] = fIPDistance; // mother volume inner radius | |
239 | fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r. | |
240 | fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume. | |
241 | ||
d434833b | 242 | if(fgAlignData != NULL) { |
243 | // Number of modules is read from Alignment DB if exists | |
244 | fNumberOfSuperModules = fgAlignData->GetNSuperModules(); | |
245 | } | |
246 | ||
395c7ba2 | 247 | fgInit = kTRUE; |
248 | ||
e5a93224 | 249 | if (AliDebugLevel()>=2) { |
fc575e27 | 250 | printf("Init: geometry of EMCAL named %s is as follows:\n", fGeoName.Data()); |
e52475ed | 251 | printf( " ECAL : %d x (%f cm Pb, %f cm Sc) \n", |
252 | GetNECLayers(), GetECPbRadThick(), GetECScintThick() ) ; | |
253 | printf(" fSampling %5.2f \n", fSampling ); | |
fc575e27 | 254 | if(fGeoName.Contains("SHISH")){ |
1963b290 | 255 | printf(" fIPDistance %6.3f cm \n", fIPDistance); |
256 | if(fSteelFrontThick>0.) | |
257 | printf(" fSteelFrontThick %6.3f cm \n", fSteelFrontThick); | |
258 | printf(" fNPhi %i | fNZ %i \n", fNPhi, fNZ); | |
d87bd045 | 259 | printf(" fNCellsInTower %i : fNCellsInSupMod %i : fNCells %i\n",fNCellsInTower, fNCellsInSupMod, fNCells); |
fc575e27 | 260 | if(fGeoName.Contains("MAY05")){ |
1963b290 | 261 | printf(" fFrontSteelStrip %6.4f cm (thickness of front steel strip)\n", |
262 | fFrontSteelStrip); | |
263 | printf(" fLateralSteelStrip %6.4f cm (thickness of lateral steel strip)\n", | |
264 | fLateralSteelStrip); | |
265 | printf(" fPassiveScintThick %6.4f cm (thickness of front passive Sc tile)\n", | |
266 | fPassiveScintThick); | |
267 | } | |
c63c3c5d | 268 | printf(" X:Y module size %6.3f , %6.3f cm \n", fPhiModuleSize, fEtaModuleSize); |
269 | printf(" X:Y tile size %6.3f , %6.3f cm \n", fPhiTileSize, fEtaTileSize); | |
270 | printf(" #of sampling layers %i(fNECLayers) \n", fNECLayers); | |
271 | printf(" fLongModuleSize %6.3f cm \n", fLongModuleSize); | |
1963b290 | 272 | printf(" #supermodule in phi direction %i \n", fNPhiSuperModule ); |
273 | } | |
fc575e27 | 274 | if(fGeoName.Contains("TRD")) { |
1963b290 | 275 | printf(" fTrd1Angle %7.4f\n", fTrd1Angle); |
276 | printf(" f2Trd1Dx2 %7.4f\n", f2Trd1Dx2); | |
fc575e27 | 277 | if(fGeoName.Contains("TRD2")) { |
1963b290 | 278 | printf(" fTrd2AngleY %7.4f\n", fTrd2AngleY); |
279 | printf(" f2Trd2Dy2 %7.4f\n", f2Trd2Dy2); | |
905263da | 280 | printf(" fTubsR %7.2f cm\n", fTubsR); |
1963b290 | 281 | printf(" fTubsTurnAngle %7.4f\n", fTubsTurnAngle); |
905263da | 282 | printf(" fEmptySpace %7.4f cm\n", fEmptySpace); |
fc575e27 | 283 | } else if(fGeoName.Contains("TRD1") && fGeoName.Contains("FINAL")){ |
e52475ed | 284 | printf("SM dimensions(TRD1) : dx %7.2f dy %7.2f dz %7.2f (SMOD, BOX)\n", |
285 | fParSM[0],fParSM[1],fParSM[2]); | |
905263da | 286 | printf(" fPhiGapForSM %7.4f cm \n", fPhiGapForSM); |
fc575e27 | 287 | if(fGeoName.Contains("110DEG"))printf(" Last two modules have size 10 degree in phi (180<phi<190)\n"); |
1963b290 | 288 | } |
289 | } | |
88cb7938 | 290 | printf("Granularity: %d in eta and %d in phi\n", GetNZ(), GetNPhi()) ; |
1963b290 | 291 | printf("Layout: phi = (%7.1f, %7.1f), eta = (%5.2f, %5.2f), IP = %7.2f\n", |
292 | GetArm1PhiMin(), GetArm1PhiMax(),GetArm1EtaMin(), GetArm1EtaMax(), GetIPDistance() ); | |
88cb7938 | 293 | } |
f0377b23 | 294 | //TRU parameters. These parameters values are not the final ones. |
295 | fNTRU = 3 ; | |
296 | fNTRUEta = 3 ; | |
297 | fNTRUPhi = 1 ; | |
2012850d | 298 | } |
173558f2 | 299 | |
c63c3c5d | 300 | //______________________________________________________________________ |
301 | ||
fc575e27 | 302 | void AliEMCALGeometry::CheckAdditionalOptions() |
303 | { | |
304 | // Feb 06,2006 | |
305 | //Additional options that | |
306 | //can be used to select | |
307 | //the specific geometry of | |
308 | //EMCAL to run | |
309 | ||
c63c3c5d | 310 | fArrayOpts = new TObjArray; |
fc575e27 | 311 | Int_t nopt = AliEMCALHistoUtilities::ParseString(fGeoName, *fArrayOpts); |
c63c3c5d | 312 | if(nopt==1) { // no aditional option(s) |
313 | fArrayOpts->Delete(); | |
314 | delete fArrayOpts; | |
315 | fArrayOpts = 0; | |
316 | return; | |
317 | } | |
318 | for(Int_t i=1; i<nopt; i++){ | |
319 | TObjString *o = (TObjString*)fArrayOpts->At(i); | |
320 | ||
321 | TString addOpt = o->String(); | |
322 | Int_t indj=-1; | |
fc575e27 | 323 | for(Int_t j=0; j<fNAdditionalOpts; j++) { |
324 | TString opt = fAdditionalOpts[j]; | |
c63c3c5d | 325 | if(addOpt.Contains(opt,TString::kIgnoreCase)) { |
326 | indj = j; | |
327 | break; | |
328 | } | |
329 | } | |
330 | if(indj<0) { | |
e5a93224 | 331 | AliDebug(2,Form("<E> option |%s| unavailable : ** look to the file AliEMCALGeometry.h **\n", |
332 | addOpt.Data())); | |
c63c3c5d | 333 | assert(0); |
334 | } else { | |
e5a93224 | 335 | AliDebug(2,Form("<I> option |%s| is valid : number %i : |%s|\n", |
336 | addOpt.Data(), indj, fAdditionalOpts[indj])); | |
c63c3c5d | 337 | if (addOpt.Contains("NL=",TString::kIgnoreCase)) {// number of sampling layers |
338 | sscanf(addOpt.Data(),"NL=%i", &fNECLayers); | |
e5a93224 | 339 | AliDebug(2,Form(" fNECLayers %i (new) \n", fNECLayers)); |
c63c3c5d | 340 | } else if(addOpt.Contains("PBTH=",TString::kIgnoreCase)) {//Thickness of the Pb |
341 | sscanf(addOpt.Data(),"PBTH=%f", &fECPbRadThickness); | |
342 | } else if(addOpt.Contains("SCTH=",TString::kIgnoreCase)) {//Thickness of the Sc | |
343 | sscanf(addOpt.Data(),"SCTH=%f", &fECScintThick); | |
344 | } | |
345 | } | |
346 | } | |
347 | } | |
348 | ||
f0377b23 | 349 | //____________________________________________________________________________ |
356fd0a9 | 350 | void AliEMCALGeometry::FillTRU(const TClonesArray * digits, TClonesArray * ampmatrix, TClonesArray * timeRmatrix) { |
f0377b23 | 351 | |
352 | ||
356fd0a9 | 353 | // Orders digits ampitudes list in fNTRU TRUs (384 cells) per supermodule. |
354 | // Each TRU is a TMatrixD, and they are kept in TClonesArrays. The number of | |
355 | // TRU in phi is fNTRUPhi, and the number of TRU in eta is fNTRUEta. | |
356 | // Last 2 modules are half size in Phi, I considered that the number of TRU | |
357 | // is maintained for the last modules but decision not taken. If different, | |
358 | // then this must be changed. | |
359 | ||
f0377b23 | 360 | |
361 | //Check data members | |
362 | ||
363 | if(fNTRUEta*fNTRUPhi != fNTRU) | |
364 | Error("FillTRU"," Wrong number of TRUS per Eta or Phi"); | |
365 | ||
356fd0a9 | 366 | //Initilize and declare variables |
f0377b23 | 367 | //List of TRU matrices initialized to 0. |
356fd0a9 | 368 | Int_t nCellsPhi = fNPhi*2/fNTRUPhi; |
369 | Int_t nCellsPhi2 = fNPhi/fNTRUPhi; //HalfSize modules | |
370 | Int_t nCellsEta = fNZ*2/fNTRUEta; | |
f0377b23 | 371 | Int_t id = -1; |
372 | Float_t amp = -1; | |
356fd0a9 | 373 | Float_t timeR = -1; |
f0377b23 | 374 | Int_t iSupMod = -1; |
375 | Int_t nTower = -1; | |
376 | Int_t nIphi = -1; | |
377 | Int_t nIeta = -1; | |
378 | Int_t iphi = -1; | |
379 | Int_t ieta = -1; | |
356fd0a9 | 380 | |
381 | //List of TRU matrices initialized to 0. | |
382 | for(Int_t k = 0; k < fNTRU*fNumberOfSuperModules; k++){ | |
383 | TMatrixD * amptrus = new TMatrixD(nCellsPhi,nCellsEta) ; | |
384 | TMatrixD * timeRtrus = new TMatrixD(nCellsPhi,nCellsEta) ; | |
385 | for(Int_t i = 0; i < nCellsPhi; i++){ | |
386 | for(Int_t j = 0; j < nCellsEta; j++){ | |
387 | (*amptrus)(i,j) = 0.0; | |
388 | (*timeRtrus)(i,j) = 0.0; | |
389 | } | |
390 | } | |
391 | new((*ampmatrix)[k]) TMatrixD(*amptrus) ; | |
392 | new((*timeRmatrix)[k]) TMatrixD(*timeRtrus) ; | |
393 | } | |
394 | ||
395 | AliEMCALDigit * dig ; | |
f0377b23 | 396 | |
397 | //Digits loop to fill TRU matrices with amplitudes. | |
f0377b23 | 398 | for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){ |
399 | ||
400 | dig = dynamic_cast<AliEMCALDigit *>(digits->At(idig)) ; | |
356fd0a9 | 401 | amp = dig->GetAmp() ; // Energy of the digit (arbitrary units) |
402 | id = dig->GetId() ; // Id label of the cell | |
403 | timeR = dig->GetTimeR() ; // Earliest time of the digit | |
f0377b23 | 404 | |
405 | //Get eta and phi cell position in supermodule | |
406 | Bool_t bCell = GetCellIndex(id, iSupMod, nTower, nIphi, nIeta) ; | |
407 | if(!bCell) | |
408 | Error("FillTRU","Wrong cell id number") ; | |
409 | ||
410 | GetCellPhiEtaIndexInSModule(iSupMod,nTower,nIphi, nIeta,iphi,ieta); | |
411 | ||
412 | //Check to which TRU in the supermodule belongs the cell. | |
413 | //Supermodules are divided in a TRU matrix of dimension | |
414 | //(fNTRUPhi,fNTRUEta). | |
415 | //Each TRU is a cell matrix of dimension (nCellsPhi,nCellsEta) | |
416 | ||
417 | //First calculate the row and column in the supermodule | |
418 | //of the TRU to which the cell belongs. | |
f0377b23 | 419 | Int_t col = (ieta-1)/nCellsEta+1; |
420 | Int_t row = (iphi-1)/nCellsPhi+1; | |
356fd0a9 | 421 | if(iSupMod > 10) |
422 | row = (iphi-1)/nCellsPhi2+1; | |
423 | //Calculate label number of the TRU | |
424 | Int_t itru = (row-1) + (col-1)*fNTRUPhi + (iSupMod-1)*fNTRU ; | |
f0377b23 | 425 | |
426 | //Fill TRU matrix with cell values | |
356fd0a9 | 427 | TMatrixD * amptrus = dynamic_cast<TMatrixD *>(ampmatrix->At(itru)) ; |
428 | TMatrixD * timeRtrus = dynamic_cast<TMatrixD *>(timeRmatrix->At(itru)) ; | |
f0377b23 | 429 | |
356fd0a9 | 430 | //Calculate row and column of the cell inside the TRU with number itru |
431 | Int_t irow = (iphi-1) - (row-1) * nCellsPhi; | |
432 | if(iSupMod > 10) | |
433 | irow = (iphi-1) - (row-1) * nCellsPhi2; | |
f0377b23 | 434 | Int_t icol = (ieta-1) - (col-1) * nCellsEta; |
435 | ||
356fd0a9 | 436 | (*amptrus)(irow,icol) = amp ; |
437 | (*timeRtrus)(irow,icol) = timeR ; | |
f0377b23 | 438 | |
439 | } | |
f0377b23 | 440 | } |
441 | ||
356fd0a9 | 442 | //______________________________________________________________________ |
443 | void AliEMCALGeometry::GetCellPhiEtaIndexInSModuleFromTRUIndex(const Int_t itru, const Int_t iphitru, const Int_t ietatru, Int_t &iphiSM, Int_t &ietaSM) const | |
444 | { | |
445 | ||
446 | // This method transforms the (eta,phi) index of a cells in a | |
447 | // TRU matrix into Super Module (eta,phi) index. | |
448 | ||
449 | // Calculate in which row and column in which the TRU are | |
450 | // ordered in the SM | |
451 | ||
452 | Int_t col = itru/ fNTRUPhi + 1; | |
453 | Int_t row = itru - (col-1)*fNTRUPhi + 1; | |
454 | ||
455 | //Calculate the (eta,phi) index in SM | |
456 | Int_t nCellsPhi = fNPhi*2/fNTRUPhi; | |
457 | Int_t nCellsEta = fNZ*2/fNTRUEta; | |
458 | ||
459 | iphiSM = nCellsPhi*(row-1) + iphitru + 1 ; | |
460 | ietaSM = nCellsEta*(col-1) + ietatru + 1 ; | |
461 | } | |
f0377b23 | 462 | |
b13bbe81 | 463 | //______________________________________________________________________ |
464 | AliEMCALGeometry * AliEMCALGeometry::GetInstance(){ | |
05a92d59 | 465 | // Returns the pointer of the unique instance |
466 | ||
e52475ed | 467 | AliEMCALGeometry * rv = static_cast<AliEMCALGeometry *>( fgGeom ); |
468 | return rv; | |
2012850d | 469 | } |
173558f2 | 470 | |
b13bbe81 | 471 | //______________________________________________________________________ |
472 | AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name, | |
473 | const Text_t* title){ | |
474 | // Returns the pointer of the unique instance | |
475 | ||
476 | AliEMCALGeometry * rv = 0; | |
477 | if ( fgGeom == 0 ) { | |
478 | if ( strcmp(name,"") == 0 ) rv = 0; | |
e5a93224 | 479 | else { |
b13bbe81 | 480 | fgGeom = new AliEMCALGeometry(name, title); |
481 | if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom; | |
482 | else { | |
483 | rv = 0; | |
484 | delete fgGeom; | |
485 | fgGeom = 0; | |
486 | } // end if fgInit | |
487 | } // end if strcmp(name,"") | |
488 | }else{ | |
e5a93224 | 489 | if ( strcmp(fgGeom->GetName(), name) != 0) { |
490 | printf("\ncurrent geometry is %s : ", fgGeom->GetName()); | |
491 | printf(" you cannot call %s ", name); | |
b13bbe81 | 492 | }else{ |
9859bfc0 | 493 | rv = (AliEMCALGeometry *) fgGeom; |
e52475ed | 494 | } // end |
b13bbe81 | 495 | } // end if fgGeom |
496 | return rv; | |
2012850d | 497 | } |
173558f2 | 498 | |
c63c3c5d | 499 | // These methods are obsolete but use in AliEMCALRecPoint - keep it now |
ca8f5bd0 | 500 | //______________________________________________________________________ |
395c7ba2 | 501 | Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi) const { |
502 | // Returns the tower index number from the based on the Z and Phi | |
fdebddeb | 503 | // index numbers. |
395c7ba2 | 504 | // Inputs: |
fdebddeb | 505 | // Int_t ieta // index along z axis [1-fNZ] |
506 | // Int_t iphi // index along phi axis [1-fNPhi] | |
395c7ba2 | 507 | // Outputs: |
508 | // none. | |
509 | // Returned | |
510 | // Int_t index // Tower index number | |
511 | ||
512 | if ( (ieta <= 0 || ieta>GetNEta()) || | |
f1da4a27 | 513 | (iphi <= 0 || iphi>GetNPhi())) { |
514 | Error("TowerIndex", "Unexpected parameters eta = %d phi = %d!", ieta, iphi) ; | |
515 | return -1; | |
516 | } | |
395c7ba2 | 517 | return ( (iphi - 1)*GetNEta() + ieta ); |
ca8f5bd0 | 518 | } |
173558f2 | 519 | |
ca8f5bd0 | 520 | //______________________________________________________________________ |
fdebddeb | 521 | void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi) const { |
395c7ba2 | 522 | // Inputs: |
fdebddeb | 523 | // Int_t index // Tower index number [1-fNZ*fNPhi] |
395c7ba2 | 524 | // Outputs: |
525 | // Int_t ieta // index allong z axis [1-fNZ] | |
526 | // Int_t iphi // index allong phi axis [1-fNPhi] | |
395c7ba2 | 527 | // Returned |
528 | // none. | |
395c7ba2 | 529 | |
fdebddeb | 530 | Int_t nindex = 0; |
395c7ba2 | 531 | |
fdebddeb | 532 | if ( IsInECA(index) ) { // ECAL index |
395c7ba2 | 533 | nindex = index ; |
395c7ba2 | 534 | } |
f1da4a27 | 535 | else { |
536 | Error("TowerIndexes", "Unexpected Id number!") ; | |
537 | ieta = -1; | |
538 | iphi = -1; | |
539 | return; | |
540 | } | |
541 | ||
395c7ba2 | 542 | if (nindex%GetNZ()) |
543 | iphi = nindex / GetNZ() + 1 ; | |
544 | else | |
545 | iphi = nindex / GetNZ() ; | |
546 | ieta = nindex - (iphi - 1) * GetNZ() ; | |
547 | ||
e5a93224 | 548 | AliDebug(2,Form("TowerIndexes: index=%d,%d, ieta=%d, iphi = %d", index, nindex,ieta, iphi)); |
395c7ba2 | 549 | return; |
550 | ||
ca8f5bd0 | 551 | } |
173558f2 | 552 | |
ca8f5bd0 | 553 | //______________________________________________________________________ |
a34b7b9f | 554 | void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const { |
ca8f5bd0 | 555 | // given the tower index number it returns the based on the eta and phi |
556 | // of the tower. | |
557 | // Inputs: | |
fdebddeb | 558 | // Int_t index // Tower index number [1-fNZ*fNPhi] |
ca8f5bd0 | 559 | // Outputs: |
560 | // Float_t eta // eta of center of tower in pseudorapidity | |
561 | // Float_t phi // phi of center of tower in degrees | |
562 | // Returned | |
563 | // none. | |
fdebddeb | 564 | Int_t ieta, iphi; |
395c7ba2 | 565 | Float_t deta, dphi ; |
ca8f5bd0 | 566 | |
fdebddeb | 567 | TowerIndexes(index,ieta,iphi); |
395c7ba2 | 568 | |
e5a93224 | 569 | AliDebug(2,Form("EtaPhiFromIndex: index = %d, ieta = %d, iphi = %d", index, ieta, iphi)); |
395c7ba2 | 570 | |
571 | deta = (GetArm1EtaMax()-GetArm1EtaMin())/(static_cast<Float_t>(GetNEta())); | |
572 | eta = GetArm1EtaMin() + ((static_cast<Float_t>(ieta) - 0.5 ))*deta; | |
573 | ||
574 | dphi = (GetArm1PhiMax() - GetArm1PhiMin())/(static_cast<Float_t>(GetNPhi())); // in degrees. | |
575 | phi = GetArm1PhiMin() + dphi*(static_cast<Float_t>(iphi) - 0.5);//iphi range [1-fNphi]. | |
ca8f5bd0 | 576 | } |
173558f2 | 577 | |
ca8f5bd0 | 578 | //______________________________________________________________________ |
a34b7b9f | 579 | Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const { |
ca8f5bd0 | 580 | // returns the tower index number based on the eta and phi of the tower. |
581 | // Inputs: | |
582 | // Float_t eta // eta of center of tower in pseudorapidity | |
583 | // Float_t phi // phi of center of tower in degrees | |
584 | // Outputs: | |
585 | // none. | |
586 | // Returned | |
587 | // Int_t index // Tower index number [1-fNZ*fNPhi] | |
395c7ba2 | 588 | |
e908f07f | 589 | Int_t ieta,iphi; |
ca8f5bd0 | 590 | |
395c7ba2 | 591 | ieta = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNEta()) * (eta - GetArm1EtaMin()) / (GetArm1EtaMax() - GetArm1EtaMin())) ) ; |
592 | ||
593 | if( ieta <= 0 || ieta > GetNEta() ) { | |
594 | Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ; | |
595 | return -1 ; | |
596 | } | |
597 | ||
598 | iphi = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNPhi()) * (phi - GetArm1PhiMin()) / (GetArm1PhiMax() - GetArm1PhiMin())) ) ; | |
599 | ||
600 | if( iphi <= 0 || iphi > GetNPhi() ) { | |
601 | Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ; | |
602 | return -1 ; | |
603 | } | |
604 | ||
605 | return TowerIndex(ieta,iphi); | |
ca8f5bd0 | 606 | } |
173558f2 | 607 | |
ca8f5bd0 | 608 | //______________________________________________________________________ |
a34b7b9f | 609 | Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const { |
ca8f5bd0 | 610 | // Converts the absolute numbering into the following array/ |
2608a1fc | 611 | // relid[0] = Row number inside EMCAL |
612 | // relid[1] = Column number inside EMCAL | |
ca8f5bd0 | 613 | // Input: |
614 | // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi] | |
615 | // Outputs: | |
2608a1fc | 616 | // Int_t *relid // array of 2. Described above. |
ca8f5bd0 | 617 | Bool_t rv = kTRUE ; |
fdebddeb | 618 | Int_t ieta=0,iphi=0,index=AbsId; |
ca8f5bd0 | 619 | |
fdebddeb | 620 | TowerIndexes(index,ieta,iphi); |
2608a1fc | 621 | relid[0] = ieta; |
622 | relid[1] = iphi; | |
ca8f5bd0 | 623 | |
624 | return rv; | |
625 | } | |
173558f2 | 626 | |
ca8f5bd0 | 627 | //______________________________________________________________________ |
395c7ba2 | 628 | void AliEMCALGeometry::PosInAlice(const Int_t *relid, Float_t &theta, Float_t &phi) const |
629 | { | |
630 | // Converts the relative numbering into the local EMCAL-module (x, z) | |
631 | // coordinates | |
2608a1fc | 632 | Int_t ieta = relid[0]; // offset along x axis |
633 | Int_t iphi = relid[1]; // offset along z axis | |
395c7ba2 | 634 | Int_t index; |
635 | Float_t eta; | |
636 | ||
637 | index = TowerIndex(ieta,iphi); | |
638 | EtaPhiFromIndex(index,eta,phi); | |
fdebddeb | 639 | //theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi(); |
640 | theta = 2.0*TMath::ATan(TMath::Exp(-eta)); | |
395c7ba2 | 641 | |
fdebddeb | 642 | // correct for distance to IP |
643 | Float_t d = GetIP2ECASection() - GetIPDistance() ; | |
395c7ba2 | 644 | |
645 | Float_t correction = 1 + d/GetIPDistance() ; | |
646 | Float_t tantheta = TMath::Tan(theta) * correction ; | |
647 | theta = TMath::ATan(tantheta) * TMath::RadToDeg() ; | |
648 | if (theta < 0 ) | |
649 | theta += 180. ; | |
650 | ||
651 | return; | |
652 | } | |
ca8f5bd0 | 653 | |
395c7ba2 | 654 | //______________________________________________________________________ |
09884213 | 655 | void AliEMCALGeometry::PosInAlice(Int_t absid, Float_t &theta, Float_t &phi) const |
395c7ba2 | 656 | { |
657 | // Converts the relative numbering into the local EMCAL-module (x, z) | |
658 | // coordinates | |
2608a1fc | 659 | Int_t relid[2] ; |
395c7ba2 | 660 | AbsToRelNumbering(absid, relid) ; |
2608a1fc | 661 | Int_t ieta = relid[0]; // offset along x axis |
662 | Int_t iphi = relid[1]; // offset along z axis | |
395c7ba2 | 663 | Int_t index; |
664 | Float_t eta; | |
665 | ||
666 | index = TowerIndex(ieta,iphi); | |
667 | EtaPhiFromIndex(index,eta,phi); | |
668 | theta = 2.0*TMath::ATan(TMath::Exp(-eta)) ; | |
669 | ||
fdebddeb | 670 | // correct for distance to IP |
395c7ba2 | 671 | Float_t d = 0. ; |
fdebddeb | 672 | if (IsInECA(absid)) |
88cb7938 | 673 | d = GetIP2ECASection() - GetIPDistance() ; |
f1da4a27 | 674 | else { |
675 | Error("PosInAlice", "Unexpected id # %d!", absid) ; | |
676 | return; | |
677 | } | |
395c7ba2 | 678 | |
679 | Float_t correction = 1 + d/GetIPDistance() ; | |
680 | Float_t tantheta = TMath::Tan(theta) * correction ; | |
681 | theta = TMath::ATan(tantheta) * TMath::RadToDeg() ; | |
682 | if (theta < 0 ) | |
683 | theta += 180. ; | |
684 | ||
685 | return; | |
ca8f5bd0 | 686 | } |
6119e5db | 687 | |
688 | //______________________________________________________________________ | |
689 | void AliEMCALGeometry::XYZFromIndex(const Int_t *relid,Float_t &x,Float_t &y, Float_t &z) const { | |
690 | // given the tower relative number it returns the X, Y and Z | |
691 | // of the tower. | |
692 | ||
693 | // Outputs: | |
694 | // Float_t x // x of center of tower in cm | |
695 | // Float_t y // y of center of tower in cm | |
696 | // Float_t z // z of centre of tower in cm | |
697 | // Returned | |
698 | // none. | |
699 | ||
fdebddeb | 700 | Float_t eta,theta, phi,cylradius=0. ; |
6119e5db | 701 | |
2608a1fc | 702 | Int_t ieta = relid[0]; // offset along x axis |
703 | Int_t iphi = relid[1]; // offset along z axis. | |
6119e5db | 704 | Int_t index; |
705 | ||
395c7ba2 | 706 | index = TowerIndex(ieta,iphi); |
6119e5db | 707 | EtaPhiFromIndex(index,eta,phi); |
708 | theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi(); | |
6119e5db | 709 | |
fdebddeb | 710 | cylradius = GetIP2ECASection() ; |
a97849a9 | 711 | |
395c7ba2 | 712 | Double_t kDeg2Rad = TMath::DegToRad() ; |
fdebddeb | 713 | x = cylradius * TMath::Cos(phi * kDeg2Rad ) ; |
714 | y = cylradius * TMath::Sin(phi * kDeg2Rad ) ; | |
715 | z = cylradius / TMath::Tan(theta * kDeg2Rad ) ; | |
6119e5db | 716 | |
717 | return; | |
718 | } | |
719 | ||
395c7ba2 | 720 | //______________________________________________________________________ |
09884213 | 721 | void AliEMCALGeometry::XYZFromIndex(Int_t absid, TVector3 &v) const { |
395c7ba2 | 722 | // given the tower relative number it returns the X, Y and Z |
723 | // of the tower. | |
724 | ||
725 | // Outputs: | |
726 | // Float_t x // x of center of tower in cm | |
727 | // Float_t y // y of center of tower in cm | |
728 | // Float_t z // z of centre of tower in cm | |
729 | // Returned | |
730 | // none. | |
731 | ||
fdebddeb | 732 | Float_t theta, phi,cylradius=0. ; |
395c7ba2 | 733 | |
734 | PosInAlice(absid, theta, phi) ; | |
735 | ||
88cb7938 | 736 | if ( IsInECA(absid) ) |
fdebddeb | 737 | cylradius = GetIP2ECASection() ; |
f1da4a27 | 738 | else { |
739 | Error("XYZFromIndex", "Unexpected Tower section") ; | |
740 | return; | |
741 | } | |
395c7ba2 | 742 | |
743 | Double_t kDeg2Rad = TMath::DegToRad() ; | |
fdebddeb | 744 | v.SetX(cylradius * TMath::Cos(phi * kDeg2Rad ) ); |
745 | v.SetY(cylradius * TMath::Sin(phi * kDeg2Rad ) ); | |
746 | v.SetZ(cylradius / TMath::Tan(theta * kDeg2Rad ) ) ; | |
395c7ba2 | 747 | |
748 | return; | |
749 | } | |
ab37d09c | 750 | |
751 | Bool_t AliEMCALGeometry::IsInEMCAL(Double_t x, Double_t y, Double_t z) const { | |
752 | // Checks whether point is inside the EMCal volume | |
753 | // | |
754 | // Code uses cylindrical approximation made of inner radius (for speed) | |
755 | // | |
756 | // Points behind EMCAl, i.e. R > outer radius, but eta, phi in acceptance | |
757 | // are considered to inside | |
758 | ||
759 | Double_t r=sqrt(x*x+y*y); | |
760 | ||
761 | if ( r > fEnvelop[0] ) { | |
762 | Double_t theta; | |
763 | theta = TMath::ATan2(r,z); | |
764 | Double_t eta; | |
765 | if(theta == 0) | |
766 | eta = 9999; | |
767 | else | |
768 | eta = -TMath::Log(TMath::Tan(theta/2.)); | |
769 | if (eta < fArm1EtaMin || eta > fArm1EtaMax) | |
770 | return 0; | |
771 | ||
772 | Double_t phi = TMath::ATan2(y,x) * 180./TMath::Pi(); | |
773 | if (phi > fArm1PhiMin && phi < fArm1PhiMax) | |
774 | return 1; | |
775 | } | |
776 | return 0; | |
777 | } | |
c63c3c5d | 778 | // == |
1963b290 | 779 | |
780 | // | |
781 | // == Shish-kebab cases == | |
782 | // | |
e52475ed | 783 | Int_t AliEMCALGeometry::GetAbsCellId(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta) const |
d87bd045 | 784 | { // 27-aug-04; |
785 | // corr. 21-sep-04; | |
786 | // 13-oct-05; 110 degree case | |
787 | // 1 <= nSupMod <= fNumberOfSuperModules | |
788 | // 1 <= nTower <= fNPHI * fNZ ( fNPHI * fNZ/2 for fKey110DEG=1) | |
789 | // 1 <= nIphi <= fNPHIdiv | |
790 | // 1 <= nIeta <= fNETAdiv | |
791 | // 1 <= absid <= fNCells | |
792 | static Int_t id=0; // have to change from 1 to fNCells | |
793 | if(fKey110DEG == 1 && nSupMod > 10) { // 110 degree case; last two supermodules | |
794 | id = fNCellsInSupMod*10 + (fNCellsInSupMod/2)*(nSupMod-11); | |
795 | } else { | |
796 | id = fNCellsInSupMod*(nSupMod-1); | |
797 | } | |
1963b290 | 798 | id += fNCellsInTower *(nTower-1); |
799 | id += fNPHIdiv *(nIphi-1); | |
800 | id += nIeta; | |
801 | if(id<=0 || id > fNCells) { | |
500aeccc | 802 | // printf(" wrong numerations !!\n"); |
803 | // printf(" id %6i(will be force to -1)\n", id); | |
804 | // printf(" fNCells %6i\n", fNCells); | |
805 | // printf(" nSupMod %6i\n", nSupMod); | |
806 | // printf(" nTower %6i\n", nTower); | |
807 | // printf(" nIphi %6i\n", nIphi); | |
808 | // printf(" nIeta %6i\n", nIeta); | |
d87bd045 | 809 | id = -TMath::Abs(id); |
1963b290 | 810 | } |
811 | return id; | |
812 | } | |
813 | ||
e52475ed | 814 | Bool_t AliEMCALGeometry::CheckAbsCellId(Int_t ind) const |
fc575e27 | 815 | { |
816 | // 17-nov-04 - analog of IsInECA | |
817 | if(fGeoName.Contains("TRD")) { | |
1963b290 | 818 | if(ind<=0 || ind > fNCells) return kFALSE; |
819 | else return kTRUE; | |
820 | } else return IsInECA(ind); | |
821 | } | |
822 | ||
e52475ed | 823 | Bool_t AliEMCALGeometry::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nTower,Int_t &nIphi,Int_t &nIeta) const |
fc575e27 | 824 | { |
825 | // 21-sep-04 | |
d87bd045 | 826 | // 19-oct-05; |
827 | static Int_t tmp=0, sm10=0; | |
1963b290 | 828 | if(absId<=0 || absId>fNCells) { |
500aeccc | 829 | // Info("GetCellIndex"," wrong abs Id %i !! \n", absId); |
1963b290 | 830 | return kFALSE; |
831 | } | |
d87bd045 | 832 | sm10 = fNCellsInSupMod*10; |
833 | if(fKey110DEG == 1 && absId > sm10) { // 110 degree case; last two supermodules | |
834 | nSupMod = (absId-1-sm10) / (fNCellsInSupMod/2) + 11; | |
835 | tmp = (absId-1-sm10) % (fNCellsInSupMod/2); | |
836 | } else { | |
837 | nSupMod = (absId-1) / fNCellsInSupMod + 1; | |
838 | tmp = (absId-1) % fNCellsInSupMod; | |
839 | } | |
1963b290 | 840 | |
841 | nTower = tmp / fNCellsInTower + 1; | |
842 | tmp = tmp % fNCellsInTower; | |
d87bd045 | 843 | nIphi = tmp / fNPHIdiv + 1; |
844 | nIeta = tmp % fNPHIdiv + 1; | |
1963b290 | 845 | |
846 | return kTRUE; | |
847 | } | |
848 | ||
e52475ed | 849 | void AliEMCALGeometry::GetTowerPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, int &iphit, int &ietat) const |
fc575e27 | 850 | { |
851 | // added nSupMod; have to check - 19-oct-05 ! | |
d87bd045 | 852 | static Int_t nphi; |
853 | ||
854 | if(fKey110DEG == 1 && nSupMod>=11) nphi = fNPhi/2; | |
855 | else nphi = fNPhi; | |
856 | ||
857 | ietat = (nTower-1)/nphi + 1; // have to change from 1 to fNZ | |
d87bd045 | 858 | iphit = (nTower-1)%nphi + 1; // have to change from 1 to fNPhi |
859 | } | |
860 | ||
eb0b1051 | 861 | void AliEMCALGeometry::GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta, |
e52475ed | 862 | int &iphi, int &ieta) const |
fc575e27 | 863 | { |
864 | // added nSupMod; Nov 25, 05 | |
c01485dd | 865 | static Int_t iphit, ietat; |
866 | ||
867 | GetTowerPhiEtaIndexInSModule(nSupMod,nTower, iphit, ietat); | |
868 | // have to change from 1 to fNZ*fNETAdiv | |
869 | ieta = (ietat-1)*fNETAdiv + (3-nIeta); // x(module) = -z(SM) | |
870 | // iphi - have to change from 1 to fNPhi*fNPHIdiv | |
871 | iphi = (iphit-1)*fNPHIdiv + nIphi; // y(module) = y(SM) | |
1963b290 | 872 | } |
e52475ed | 873 | |
874 | Int_t AliEMCALGeometry::GetSuperModuleNumber(Int_t absId) const | |
875 | { | |
fc575e27 | 876 | //return the number of the |
877 | //supermodule given the absolute | |
878 | //ALICE numbering | |
879 | ||
e52475ed | 880 | static Int_t nSupMod, nTower, nIphi, nIeta; |
881 | GetCellIndex(absId, nSupMod, nTower, nIphi, nIeta); | |
882 | return nSupMod; | |
883 | } | |
884 | ||
885 | // Methods for AliEMCALRecPoint - Feb 19, 2006 | |
886 | Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr) | |
887 | { | |
fc575e27 | 888 | //Look to see what the relative |
889 | //position inside a given cell is | |
890 | //for a recpoint. | |
891 | ||
e52475ed | 892 | static Int_t nSupMod, nTower, nIphi, nIeta, iphi, ieta; |
893 | if(!CheckAbsCellId(absId)) return kFALSE; | |
894 | ||
895 | GetCellIndex(absId, nSupMod, nTower, nIphi, nIeta); | |
896 | GetCellPhiEtaIndexInSModule(nSupMod,nTower,nIphi,nIeta, iphi, ieta); | |
897 | ||
898 | xr = fXCentersOfCells->At(ieta-1); | |
899 | zr = fEtaCentersOfCells->At(ieta-1); | |
900 | ||
901 | yr = fPhiCentersOfCells->At(iphi-1); | |
902 | ||
903 | // cout<<" absId "<<absId<<" iphi "<<iphi<<"ieta"<<ieta; | |
904 | // cout<< " xr " << xr << " yr " << yr << " zr " << zr <<endl; | |
905 | return kTRUE; | |
906 | } | |
907 | ||
908 | void AliEMCALGeometry::CreateListOfTrd1Modules() | |
909 | { | |
fc575e27 | 910 | //Generate the list of Trd1 modules |
911 | //which will make up the EMCAL | |
912 | //geometry | |
913 | ||
e5a93224 | 914 | AliDebug(2,Form(" AliEMCALGeometry::CreateListOfTrd1Modules() started ")); |
915 | ||
e52475ed | 916 | AliEMCALShishKebabTrd1Module *mod=0, *mTmp=0; // current module |
917 | if(fShishKebabTrd1Modules == 0) { | |
918 | fShishKebabTrd1Modules = new TList; | |
919 | for(int iz=0; iz< GetNZ(); iz++) { | |
920 | if(iz==0) { | |
921 | mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,this); | |
922 | } else { | |
923 | mTmp = new AliEMCALShishKebabTrd1Module(*mod); | |
924 | mod = mTmp; | |
925 | } | |
926 | fShishKebabTrd1Modules->Add(mod); | |
927 | } | |
928 | } else { | |
e5a93224 | 929 | AliDebug(2,Form(" Already exits : ")); |
e52475ed | 930 | } |
e5a93224 | 931 | AliDebug(2,Form(" fShishKebabTrd1Modules has %i modules \n", |
932 | fShishKebabTrd1Modules->GetSize())); | |
e52475ed | 933 | // Feb 20,2006; |
934 | // define grid for cells in eta(z) and x directions in local coordinates system of SM | |
935 | fEtaCentersOfCells = new TArrayD(fNZ *fNETAdiv); | |
936 | fXCentersOfCells = new TArrayD(fNZ *fNETAdiv); | |
e5a93224 | 937 | AliDebug(2,Form(" Cells grid in eta directions : size %i\n", fEtaCentersOfCells->GetSize())); |
e52475ed | 938 | Int_t iphi=0, ieta=0, nTower=0; |
939 | Double_t xr, zr; | |
940 | for(Int_t it=0; it<fNZ; it++) { // array index | |
941 | AliEMCALShishKebabTrd1Module *trd1 = GetShishKebabModule(it); | |
942 | nTower = fNPhi*it + 1; | |
943 | for(Int_t ic=0; ic<fNETAdiv; ic++) { // array index | |
944 | trd1->GetCenterOfCellInLocalCoordinateofSM(ic+1, xr, zr); | |
945 | GetCellPhiEtaIndexInSModule(1, nTower, 1, ic+1, iphi, ieta); // don't depend from phi | |
946 | fXCentersOfCells->AddAt(float(xr) - fParSM[0],ieta-1); | |
947 | fEtaCentersOfCells->AddAt(float(zr) - fParSM[2],ieta-1); | |
948 | } | |
949 | } | |
950 | for(Int_t i=0; i<fEtaCentersOfCells->GetSize(); i++) { | |
e5a93224 | 951 | AliDebug(2,Form(" ind %2.2i : z %8.3f : x %8.3f", i+1, |
952 | fEtaCentersOfCells->At(i),fXCentersOfCells->At(i))); | |
e52475ed | 953 | } |
e5a93224 | 954 | |
e52475ed | 955 | // define grid for cells in phi(y) direction in local coordinates system of SM |
956 | fPhiCentersOfCells = new TArrayD(fNPhi*fNPHIdiv); | |
e5a93224 | 957 | AliDebug(2,Form(" Cells grid in phi directions : size %i\n", fPhiCentersOfCells->GetSize())); |
e52475ed | 958 | Int_t ind=0; |
959 | for(Int_t it=0; it<fNPhi; it++) { // array index | |
960 | Float_t ytLeftCenterModule = -fParSM[1] + fPhiModuleSize*(2*it+1)/2; // module | |
961 | for(Int_t ic=0; ic<fNPHIdiv; ic++) { // array index | |
962 | Float_t ytLeftCenterCell = ytLeftCenterModule + fPhiTileSize *(2*ic-1)/2.; // tower(cell) | |
963 | fPhiCentersOfCells->AddAt(ytLeftCenterCell,ind); | |
e5a93224 | 964 | AliDebug(2,Form(" ind %2.2i : y %8.3f ", ind, fPhiCentersOfCells->At(ind))); |
965 | ind++; | |
e52475ed | 966 | } |
967 | } | |
e52475ed | 968 | } |
969 | ||
970 | void AliEMCALGeometry::GetTransformationForSM() | |
971 | { | |
fc575e27 | 972 | //Uses the geometry manager to |
973 | //load the transformation matrix | |
974 | //for the supermodules | |
975 | ||
e52475ed | 976 | static Bool_t transInit=kFALSE; |
977 | if(transInit) return; | |
978 | ||
979 | int i=0; | |
980 | if(gGeoManager == 0) { | |
981 | Info("CreateTransformationForSM() "," Load geometry : TGeoManager::Import()"); | |
982 | assert(0); | |
983 | } | |
984 | TGeoNode *tn = gGeoManager->GetTopNode(); | |
fc575e27 | 985 | TGeoNode *node=0, *xen1 = 0; |
e52475ed | 986 | for(i=0; i<tn->GetNdaughters(); i++) { |
987 | node = tn->GetDaughter(i); | |
988 | TString ns(node->GetName()); | |
989 | if(ns.Contains(GetNameOfEMCALEnvelope())) { | |
fc575e27 | 990 | xen1 = node; |
e52475ed | 991 | break; |
992 | } | |
993 | } | |
fc575e27 | 994 | if(!xen1) { |
e52475ed | 995 | Info("CreateTransformationForSM() "," geometry has not EMCAL envelope with name %s", |
996 | GetNameOfEMCALEnvelope()); | |
997 | assert(0); | |
998 | } | |
fc575e27 | 999 | printf(" i %i : EMCAL Envelope is %s : #SM %i \n", i, xen1->GetName(), xen1->GetNdaughters()); |
1000 | for(i=0; i<xen1->GetNdaughters(); i++) { | |
1001 | TGeoNodeMatrix *sm = (TGeoNodeMatrix*)xen1->GetDaughter(i); | |
e52475ed | 1002 | fMatrixOfSM[i] = sm->GetMatrix(); |
64942713 | 1003 | //Compiler doesn't like this syntax... |
1004 | // printf(" %i : matrix %x \n", i, fMatrixOfSM[i]); | |
e52475ed | 1005 | } |
1006 | transInit = kTRUE; | |
1007 | } | |
1008 | ||
1009 | void AliEMCALGeometry::GetGlobal(const Double_t *loc, Double_t *glob, int nsm) const | |
1010 | { | |
fc575e27 | 1011 | //Figure out the global numbering |
1012 | //of a given supermodule from the | |
1013 | //local numbering | |
1014 | ||
e52475ed | 1015 | // if(fMatrixOfSM[0] == 0) GetTransformationForSM(); |
1016 | static int ind; | |
1017 | ind = nsm-1; | |
1018 | if(ind>=0 && ind < GetNumberOfSuperModules()) { | |
1019 | fMatrixOfSM[ind]->LocalToMaster(loc, glob); | |
1020 | } | |
1021 | } | |
1022 | ||
21cf2b24 | 1023 | void AliEMCALGeometry::GetGlobal(Int_t /* absId */, TVector3 & /* vglob */) const |
e52475ed | 1024 | { // have to be defined |
1025 | } | |
1026 | ||
1027 | void AliEMCALGeometry::GetGlobal(const TVector3 &vloc, TVector3 &vglob, int nsm) const | |
1028 | { | |
fc575e27 | 1029 | //Figure out the global numbering |
1030 | //of a given supermodule from the | |
1031 | //local numbering given a 3-vector location | |
1032 | ||
e52475ed | 1033 | static Double_t tglob[3], tloc[3]; |
1034 | vloc.GetXYZ(tloc); | |
1035 | GetGlobal(tloc, tglob, nsm); | |
1036 | vglob.SetXYZ(tglob[0], tglob[1], tglob[2]); | |
1037 | } | |
1038 | ||
1039 | void AliEMCALGeometry::GetGlobal(const AliRecPoint *rp, TVector3 &vglob) const | |
1040 | { | |
fc575e27 | 1041 | //Figure out the global numbering |
1042 | //of a given supermodule from the | |
1043 | //local numbering for RecPoints | |
1044 | ||
e52475ed | 1045 | static TVector3 vloc; |
1046 | static Int_t nSupMod, nTower, nIphi, nIeta; | |
1047 | ||
1048 | AliRecPoint *rpTmp = (AliRecPoint*)rp; // const_cast ?? | |
1049 | if(!rpTmp) return; | |
1050 | AliEMCALRecPoint *rpEmc = (AliEMCALRecPoint*)rpTmp; | |
1051 | ||
1052 | GetCellIndex(rpEmc->GetAbsId(0), nSupMod, nTower, nIphi, nIeta); | |
1053 | rpTmp->GetLocalPosition(vloc); | |
1054 | GetGlobal(vloc, vglob, nSupMod); | |
1055 | } | |
1056 | ||
fc575e27 | 1057 | AliEMCALShishKebabTrd1Module* AliEMCALGeometry::GetShishKebabModule(Int_t neta=0) |
1058 | { | |
1059 | //This method was too long to be | |
1060 | //included in the header file - the | |
1061 | //rule checker complained about it's | |
1062 | //length, so we move it here. It returns the | |
1063 | //shishkebabmodule at a given eta index point. | |
1064 | ||
1065 | static AliEMCALShishKebabTrd1Module* trd1=0; | |
1066 | if(fShishKebabTrd1Modules && neta>=0 && neta<fShishKebabTrd1Modules->GetSize()) { | |
1067 | trd1 = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(neta); | |
1068 | } else trd1 = 0; | |
1069 | return trd1; | |
1070 | } |