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