]>
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 | //____________________________________________________________________________ |
345 | TClonesArray * AliEMCALGeometry::FillTRU(const TClonesArray * digits) { | |
346 | ||
347 | ||
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. For the | |
351 | //moment the TRU of the 2 smaller supermodules are considered to be equal | |
352 | //to the rest. | |
353 | ||
354 | //Check data members | |
355 | ||
356 | if(fNTRUEta*fNTRUPhi != fNTRU) | |
357 | Error("FillTRU"," Wrong number of TRUS per Eta or Phi"); | |
358 | ||
359 | //Initilize variables | |
360 | //List of TRU matrices initialized to 0. | |
361 | Int_t nCellsPhi = fNPhi*2/fNTRUPhi; | |
362 | Int_t nCellsEta = fNZ*2/fNTRUEta; | |
363 | TClonesArray * matrix = new TClonesArray("TMatrixD",1000); | |
364 | ||
365 | for(Int_t k = 0; k < fNTRU*fNumberOfSuperModules; k++){ | |
366 | TMatrixD * trus = new TMatrixD(nCellsPhi,nCellsEta) ; | |
367 | for(Int_t i = 0; i < nCellsPhi; i++) | |
368 | for(Int_t j = 0; j < nCellsEta; j++) | |
369 | (*trus)(i,j) = 0.0; | |
370 | ||
371 | new((*matrix)[k]) TMatrixD(*trus) ; | |
372 | } | |
373 | ||
374 | AliEMCALDigit * dig ; | |
375 | ||
376 | //Declare variables | |
377 | Int_t id = -1; | |
378 | Float_t amp = -1; | |
379 | Int_t iSupMod = -1; | |
380 | Int_t nTower = -1; | |
381 | Int_t nIphi = -1; | |
382 | Int_t nIeta = -1; | |
383 | Int_t iphi = -1; | |
384 | Int_t ieta = -1; | |
385 | ||
386 | //Digits loop to fill TRU matrices with amplitudes. | |
387 | ||
388 | for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){ | |
389 | ||
390 | dig = dynamic_cast<AliEMCALDigit *>(digits->At(idig)) ; | |
391 | amp = dig->GetAmp() ; //Energy of the digit (arbitrary units) | |
392 | id = dig->GetId() ; //Id label of the cell | |
393 | //cout<<"idig "<<idig<<" Amp "<<amp<<" Id "<<id<<endl; | |
394 | ||
395 | //Get eta and phi cell position in supermodule | |
396 | Bool_t bCell = GetCellIndex(id, iSupMod, nTower, nIphi, nIeta) ; | |
397 | if(!bCell) | |
398 | Error("FillTRU","Wrong cell id number") ; | |
399 | ||
400 | GetCellPhiEtaIndexInSModule(iSupMod,nTower,nIphi, nIeta,iphi,ieta); | |
401 | ||
402 | //Check to which TRU in the supermodule belongs the cell. | |
403 | //Supermodules are divided in a TRU matrix of dimension | |
404 | //(fNTRUPhi,fNTRUEta). | |
405 | //Each TRU is a cell matrix of dimension (nCellsPhi,nCellsEta) | |
406 | ||
407 | //First calculate the row and column in the supermodule | |
408 | //of the TRU to which the cell belongs. | |
409 | ||
410 | Int_t col = (ieta-1)/nCellsEta+1; | |
411 | Int_t row = (iphi-1)/nCellsPhi+1; | |
412 | Int_t itru = col*row + (iSupMod-1)*fNTRU - 1; //Label number of the TRU | |
413 | // Info("FillTRU","SM %d, cell: phi %d, eta %d",iSupMod,iphi,ieta); | |
414 | // Info("FillTRU","SM TRU: SMrow %d, SMcol %d, SMtru %d,",row,col,itru); | |
415 | ||
416 | ||
417 | //Fill TRU matrix with cell values | |
418 | ||
419 | TMatrixD * trus = dynamic_cast<TMatrixD *>(matrix->At(itru)) ; | |
420 | ||
421 | //Calculate row and column of the cell inside the TRU with number itru | |
422 | ||
423 | Int_t irow = (iphi-1) - (row-1) * nCellsPhi; | |
424 | Int_t icol = (ieta-1) - (col-1) * nCellsEta; | |
425 | ||
426 | (*trus)(irow,icol) = amp ; | |
427 | ||
428 | ||
429 | // Info("FillTRU","TRU: row %d, col %d",irow,icol); | |
430 | ||
431 | } | |
432 | return matrix; | |
433 | } | |
434 | ||
435 | ||
b13bbe81 | 436 | //______________________________________________________________________ |
437 | AliEMCALGeometry * AliEMCALGeometry::GetInstance(){ | |
05a92d59 | 438 | // Returns the pointer of the unique instance |
439 | ||
e52475ed | 440 | AliEMCALGeometry * rv = static_cast<AliEMCALGeometry *>( fgGeom ); |
441 | return rv; | |
2012850d | 442 | } |
173558f2 | 443 | |
b13bbe81 | 444 | //______________________________________________________________________ |
445 | AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name, | |
446 | const Text_t* title){ | |
447 | // Returns the pointer of the unique instance | |
448 | ||
449 | AliEMCALGeometry * rv = 0; | |
450 | if ( fgGeom == 0 ) { | |
451 | if ( strcmp(name,"") == 0 ) rv = 0; | |
452 | else { | |
453 | fgGeom = new AliEMCALGeometry(name, title); | |
454 | if ( fgInit ) rv = (AliEMCALGeometry * ) fgGeom; | |
455 | else { | |
456 | rv = 0; | |
457 | delete fgGeom; | |
458 | fgGeom = 0; | |
459 | } // end if fgInit | |
460 | } // end if strcmp(name,"") | |
461 | }else{ | |
462 | if ( strcmp(fgGeom->GetName(), name) != 0 ) { | |
fdebddeb | 463 | printf("\ncurrent geometry is ") ; |
464 | printf(fgGeom->GetName()); | |
465 | printf("\n you cannot call "); | |
466 | printf(name); | |
b13bbe81 | 467 | }else{ |
9859bfc0 | 468 | rv = (AliEMCALGeometry *) fgGeom; |
e52475ed | 469 | } // end |
b13bbe81 | 470 | } // end if fgGeom |
471 | return rv; | |
2012850d | 472 | } |
173558f2 | 473 | |
c63c3c5d | 474 | // These methods are obsolete but use in AliEMCALRecPoint - keep it now |
ca8f5bd0 | 475 | //______________________________________________________________________ |
395c7ba2 | 476 | Int_t AliEMCALGeometry::TowerIndex(Int_t ieta,Int_t iphi) const { |
477 | // Returns the tower index number from the based on the Z and Phi | |
fdebddeb | 478 | // index numbers. |
395c7ba2 | 479 | // Inputs: |
fdebddeb | 480 | // Int_t ieta // index along z axis [1-fNZ] |
481 | // Int_t iphi // index along phi axis [1-fNPhi] | |
395c7ba2 | 482 | // Outputs: |
483 | // none. | |
484 | // Returned | |
485 | // Int_t index // Tower index number | |
486 | ||
487 | if ( (ieta <= 0 || ieta>GetNEta()) || | |
f1da4a27 | 488 | (iphi <= 0 || iphi>GetNPhi())) { |
489 | Error("TowerIndex", "Unexpected parameters eta = %d phi = %d!", ieta, iphi) ; | |
490 | return -1; | |
491 | } | |
395c7ba2 | 492 | return ( (iphi - 1)*GetNEta() + ieta ); |
ca8f5bd0 | 493 | } |
173558f2 | 494 | |
ca8f5bd0 | 495 | //______________________________________________________________________ |
fdebddeb | 496 | void AliEMCALGeometry::TowerIndexes(Int_t index,Int_t &ieta,Int_t &iphi) const { |
395c7ba2 | 497 | // Inputs: |
fdebddeb | 498 | // Int_t index // Tower index number [1-fNZ*fNPhi] |
395c7ba2 | 499 | // Outputs: |
500 | // Int_t ieta // index allong z axis [1-fNZ] | |
501 | // Int_t iphi // index allong phi axis [1-fNPhi] | |
395c7ba2 | 502 | // Returned |
503 | // none. | |
395c7ba2 | 504 | |
fdebddeb | 505 | Int_t nindex = 0; |
395c7ba2 | 506 | |
fdebddeb | 507 | if ( IsInECA(index) ) { // ECAL index |
395c7ba2 | 508 | nindex = index ; |
395c7ba2 | 509 | } |
f1da4a27 | 510 | else { |
511 | Error("TowerIndexes", "Unexpected Id number!") ; | |
512 | ieta = -1; | |
513 | iphi = -1; | |
514 | return; | |
515 | } | |
516 | ||
395c7ba2 | 517 | if (nindex%GetNZ()) |
518 | iphi = nindex / GetNZ() + 1 ; | |
519 | else | |
520 | iphi = nindex / GetNZ() ; | |
521 | ieta = nindex - (iphi - 1) * GetNZ() ; | |
522 | ||
523 | if (gDebug==2) | |
fdebddeb | 524 | printf("TowerIndexes: index=%d,%d, ieta=%d, iphi = %d", index, nindex,ieta, iphi) ; |
395c7ba2 | 525 | return; |
526 | ||
ca8f5bd0 | 527 | } |
173558f2 | 528 | |
ca8f5bd0 | 529 | //______________________________________________________________________ |
a34b7b9f | 530 | void AliEMCALGeometry::EtaPhiFromIndex(Int_t index,Float_t &eta,Float_t &phi) const { |
ca8f5bd0 | 531 | // given the tower index number it returns the based on the eta and phi |
532 | // of the tower. | |
533 | // Inputs: | |
fdebddeb | 534 | // Int_t index // Tower index number [1-fNZ*fNPhi] |
ca8f5bd0 | 535 | // Outputs: |
536 | // Float_t eta // eta of center of tower in pseudorapidity | |
537 | // Float_t phi // phi of center of tower in degrees | |
538 | // Returned | |
539 | // none. | |
fdebddeb | 540 | Int_t ieta, iphi; |
395c7ba2 | 541 | Float_t deta, dphi ; |
ca8f5bd0 | 542 | |
fdebddeb | 543 | TowerIndexes(index,ieta,iphi); |
395c7ba2 | 544 | |
545 | if (gDebug == 2) | |
fdebddeb | 546 | printf("EtaPhiFromIndex: index = %d, ieta = %d, iphi = %d", index, ieta, iphi) ; |
395c7ba2 | 547 | |
548 | deta = (GetArm1EtaMax()-GetArm1EtaMin())/(static_cast<Float_t>(GetNEta())); | |
549 | eta = GetArm1EtaMin() + ((static_cast<Float_t>(ieta) - 0.5 ))*deta; | |
550 | ||
551 | dphi = (GetArm1PhiMax() - GetArm1PhiMin())/(static_cast<Float_t>(GetNPhi())); // in degrees. | |
552 | phi = GetArm1PhiMin() + dphi*(static_cast<Float_t>(iphi) - 0.5);//iphi range [1-fNphi]. | |
ca8f5bd0 | 553 | } |
173558f2 | 554 | |
ca8f5bd0 | 555 | //______________________________________________________________________ |
a34b7b9f | 556 | Int_t AliEMCALGeometry::TowerIndexFromEtaPhi(Float_t eta,Float_t phi) const { |
ca8f5bd0 | 557 | // returns the tower index number based on the eta and phi of the tower. |
558 | // Inputs: | |
559 | // Float_t eta // eta of center of tower in pseudorapidity | |
560 | // Float_t phi // phi of center of tower in degrees | |
561 | // Outputs: | |
562 | // none. | |
563 | // Returned | |
564 | // Int_t index // Tower index number [1-fNZ*fNPhi] | |
395c7ba2 | 565 | |
e908f07f | 566 | Int_t ieta,iphi; |
ca8f5bd0 | 567 | |
395c7ba2 | 568 | ieta = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNEta()) * (eta - GetArm1EtaMin()) / (GetArm1EtaMax() - GetArm1EtaMin())) ) ; |
569 | ||
570 | if( ieta <= 0 || ieta > GetNEta() ) { | |
571 | Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ; | |
572 | return -1 ; | |
573 | } | |
574 | ||
575 | iphi = static_cast<Int_t> ( 1 + (static_cast<Float_t>(GetNPhi()) * (phi - GetArm1PhiMin()) / (GetArm1PhiMax() - GetArm1PhiMin())) ) ; | |
576 | ||
577 | if( iphi <= 0 || iphi > GetNPhi() ) { | |
578 | Error("TowerIndexFromEtaPhi", "Unexpected (eta, phi) = (%f, %f) value, outside of EMCAL!", eta, phi) ; | |
579 | return -1 ; | |
580 | } | |
581 | ||
582 | return TowerIndex(ieta,iphi); | |
ca8f5bd0 | 583 | } |
173558f2 | 584 | |
ca8f5bd0 | 585 | //______________________________________________________________________ |
a34b7b9f | 586 | Bool_t AliEMCALGeometry::AbsToRelNumbering(Int_t AbsId, Int_t *relid) const { |
ca8f5bd0 | 587 | // Converts the absolute numbering into the following array/ |
2608a1fc | 588 | // relid[0] = Row number inside EMCAL |
589 | // relid[1] = Column number inside EMCAL | |
ca8f5bd0 | 590 | // Input: |
591 | // Int_t AbsId // Tower index number [1-2*fNZ*fNPhi] | |
592 | // Outputs: | |
2608a1fc | 593 | // Int_t *relid // array of 2. Described above. |
ca8f5bd0 | 594 | Bool_t rv = kTRUE ; |
fdebddeb | 595 | Int_t ieta=0,iphi=0,index=AbsId; |
ca8f5bd0 | 596 | |
fdebddeb | 597 | TowerIndexes(index,ieta,iphi); |
2608a1fc | 598 | relid[0] = ieta; |
599 | relid[1] = iphi; | |
ca8f5bd0 | 600 | |
601 | return rv; | |
602 | } | |
173558f2 | 603 | |
ca8f5bd0 | 604 | //______________________________________________________________________ |
395c7ba2 | 605 | void AliEMCALGeometry::PosInAlice(const Int_t *relid, Float_t &theta, Float_t &phi) const |
606 | { | |
607 | // Converts the relative numbering into the local EMCAL-module (x, z) | |
608 | // coordinates | |
2608a1fc | 609 | Int_t ieta = relid[0]; // offset along x axis |
610 | Int_t iphi = relid[1]; // offset along z axis | |
395c7ba2 | 611 | Int_t index; |
612 | Float_t eta; | |
613 | ||
614 | index = TowerIndex(ieta,iphi); | |
615 | EtaPhiFromIndex(index,eta,phi); | |
fdebddeb | 616 | //theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi(); |
617 | theta = 2.0*TMath::ATan(TMath::Exp(-eta)); | |
395c7ba2 | 618 | |
fdebddeb | 619 | // correct for distance to IP |
620 | Float_t d = GetIP2ECASection() - GetIPDistance() ; | |
395c7ba2 | 621 | |
622 | Float_t correction = 1 + d/GetIPDistance() ; | |
623 | Float_t tantheta = TMath::Tan(theta) * correction ; | |
624 | theta = TMath::ATan(tantheta) * TMath::RadToDeg() ; | |
625 | if (theta < 0 ) | |
626 | theta += 180. ; | |
627 | ||
628 | return; | |
629 | } | |
ca8f5bd0 | 630 | |
395c7ba2 | 631 | //______________________________________________________________________ |
09884213 | 632 | void AliEMCALGeometry::PosInAlice(Int_t absid, Float_t &theta, Float_t &phi) const |
395c7ba2 | 633 | { |
634 | // Converts the relative numbering into the local EMCAL-module (x, z) | |
635 | // coordinates | |
2608a1fc | 636 | Int_t relid[2] ; |
395c7ba2 | 637 | AbsToRelNumbering(absid, relid) ; |
2608a1fc | 638 | Int_t ieta = relid[0]; // offset along x axis |
639 | Int_t iphi = relid[1]; // offset along z axis | |
395c7ba2 | 640 | Int_t index; |
641 | Float_t eta; | |
642 | ||
643 | index = TowerIndex(ieta,iphi); | |
644 | EtaPhiFromIndex(index,eta,phi); | |
645 | theta = 2.0*TMath::ATan(TMath::Exp(-eta)) ; | |
646 | ||
fdebddeb | 647 | // correct for distance to IP |
395c7ba2 | 648 | Float_t d = 0. ; |
fdebddeb | 649 | if (IsInECA(absid)) |
88cb7938 | 650 | d = GetIP2ECASection() - GetIPDistance() ; |
f1da4a27 | 651 | else { |
652 | Error("PosInAlice", "Unexpected id # %d!", absid) ; | |
653 | return; | |
654 | } | |
395c7ba2 | 655 | |
656 | Float_t correction = 1 + d/GetIPDistance() ; | |
657 | Float_t tantheta = TMath::Tan(theta) * correction ; | |
658 | theta = TMath::ATan(tantheta) * TMath::RadToDeg() ; | |
659 | if (theta < 0 ) | |
660 | theta += 180. ; | |
661 | ||
662 | return; | |
ca8f5bd0 | 663 | } |
6119e5db | 664 | |
665 | //______________________________________________________________________ | |
666 | void AliEMCALGeometry::XYZFromIndex(const Int_t *relid,Float_t &x,Float_t &y, Float_t &z) const { | |
667 | // given the tower relative number it returns the X, Y and Z | |
668 | // of the tower. | |
669 | ||
670 | // Outputs: | |
671 | // Float_t x // x of center of tower in cm | |
672 | // Float_t y // y of center of tower in cm | |
673 | // Float_t z // z of centre of tower in cm | |
674 | // Returned | |
675 | // none. | |
676 | ||
fdebddeb | 677 | Float_t eta,theta, phi,cylradius=0. ; |
6119e5db | 678 | |
2608a1fc | 679 | Int_t ieta = relid[0]; // offset along x axis |
680 | Int_t iphi = relid[1]; // offset along z axis. | |
6119e5db | 681 | Int_t index; |
682 | ||
395c7ba2 | 683 | index = TowerIndex(ieta,iphi); |
6119e5db | 684 | EtaPhiFromIndex(index,eta,phi); |
685 | theta = 180.*(2.0*TMath::ATan(TMath::Exp(-eta)))/TMath::Pi(); | |
6119e5db | 686 | |
fdebddeb | 687 | cylradius = GetIP2ECASection() ; |
a97849a9 | 688 | |
395c7ba2 | 689 | Double_t kDeg2Rad = TMath::DegToRad() ; |
fdebddeb | 690 | x = cylradius * TMath::Cos(phi * kDeg2Rad ) ; |
691 | y = cylradius * TMath::Sin(phi * kDeg2Rad ) ; | |
692 | z = cylradius / TMath::Tan(theta * kDeg2Rad ) ; | |
6119e5db | 693 | |
694 | return; | |
695 | } | |
696 | ||
395c7ba2 | 697 | //______________________________________________________________________ |
09884213 | 698 | void AliEMCALGeometry::XYZFromIndex(Int_t absid, TVector3 &v) const { |
395c7ba2 | 699 | // given the tower relative number it returns the X, Y and Z |
700 | // of the tower. | |
701 | ||
702 | // Outputs: | |
703 | // Float_t x // x of center of tower in cm | |
704 | // Float_t y // y of center of tower in cm | |
705 | // Float_t z // z of centre of tower in cm | |
706 | // Returned | |
707 | // none. | |
708 | ||
fdebddeb | 709 | Float_t theta, phi,cylradius=0. ; |
395c7ba2 | 710 | |
711 | PosInAlice(absid, theta, phi) ; | |
712 | ||
88cb7938 | 713 | if ( IsInECA(absid) ) |
fdebddeb | 714 | cylradius = GetIP2ECASection() ; |
f1da4a27 | 715 | else { |
716 | Error("XYZFromIndex", "Unexpected Tower section") ; | |
717 | return; | |
718 | } | |
395c7ba2 | 719 | |
720 | Double_t kDeg2Rad = TMath::DegToRad() ; | |
fdebddeb | 721 | v.SetX(cylradius * TMath::Cos(phi * kDeg2Rad ) ); |
722 | v.SetY(cylradius * TMath::Sin(phi * kDeg2Rad ) ); | |
723 | v.SetZ(cylradius / TMath::Tan(theta * kDeg2Rad ) ) ; | |
395c7ba2 | 724 | |
725 | return; | |
726 | } | |
ab37d09c | 727 | |
728 | Bool_t AliEMCALGeometry::IsInEMCAL(Double_t x, Double_t y, Double_t z) const { | |
729 | // Checks whether point is inside the EMCal volume | |
730 | // | |
731 | // Code uses cylindrical approximation made of inner radius (for speed) | |
732 | // | |
733 | // Points behind EMCAl, i.e. R > outer radius, but eta, phi in acceptance | |
734 | // are considered to inside | |
735 | ||
736 | Double_t r=sqrt(x*x+y*y); | |
737 | ||
738 | if ( r > fEnvelop[0] ) { | |
739 | Double_t theta; | |
740 | theta = TMath::ATan2(r,z); | |
741 | Double_t eta; | |
742 | if(theta == 0) | |
743 | eta = 9999; | |
744 | else | |
745 | eta = -TMath::Log(TMath::Tan(theta/2.)); | |
746 | if (eta < fArm1EtaMin || eta > fArm1EtaMax) | |
747 | return 0; | |
748 | ||
749 | Double_t phi = TMath::ATan2(y,x) * 180./TMath::Pi(); | |
750 | if (phi > fArm1PhiMin && phi < fArm1PhiMax) | |
751 | return 1; | |
752 | } | |
753 | return 0; | |
754 | } | |
c63c3c5d | 755 | // == |
1963b290 | 756 | |
757 | // | |
758 | // == Shish-kebab cases == | |
759 | // | |
e52475ed | 760 | Int_t AliEMCALGeometry::GetAbsCellId(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta) const |
d87bd045 | 761 | { // 27-aug-04; |
762 | // corr. 21-sep-04; | |
763 | // 13-oct-05; 110 degree case | |
764 | // 1 <= nSupMod <= fNumberOfSuperModules | |
765 | // 1 <= nTower <= fNPHI * fNZ ( fNPHI * fNZ/2 for fKey110DEG=1) | |
766 | // 1 <= nIphi <= fNPHIdiv | |
767 | // 1 <= nIeta <= fNETAdiv | |
768 | // 1 <= absid <= fNCells | |
769 | static Int_t id=0; // have to change from 1 to fNCells | |
770 | if(fKey110DEG == 1 && nSupMod > 10) { // 110 degree case; last two supermodules | |
771 | id = fNCellsInSupMod*10 + (fNCellsInSupMod/2)*(nSupMod-11); | |
772 | } else { | |
773 | id = fNCellsInSupMod*(nSupMod-1); | |
774 | } | |
1963b290 | 775 | id += fNCellsInTower *(nTower-1); |
776 | id += fNPHIdiv *(nIphi-1); | |
777 | id += nIeta; | |
778 | if(id<=0 || id > fNCells) { | |
500aeccc | 779 | // printf(" wrong numerations !!\n"); |
780 | // printf(" id %6i(will be force to -1)\n", id); | |
781 | // printf(" fNCells %6i\n", fNCells); | |
782 | // printf(" nSupMod %6i\n", nSupMod); | |
783 | // printf(" nTower %6i\n", nTower); | |
784 | // printf(" nIphi %6i\n", nIphi); | |
785 | // printf(" nIeta %6i\n", nIeta); | |
d87bd045 | 786 | id = -TMath::Abs(id); |
1963b290 | 787 | } |
788 | return id; | |
789 | } | |
790 | ||
e52475ed | 791 | Bool_t AliEMCALGeometry::CheckAbsCellId(Int_t ind) const |
1963b290 | 792 | { // 17-niv-04 - analog of IsInECA |
793 | if(name.Contains("TRD")) { | |
794 | if(ind<=0 || ind > fNCells) return kFALSE; | |
795 | else return kTRUE; | |
796 | } else return IsInECA(ind); | |
797 | } | |
798 | ||
e52475ed | 799 | Bool_t AliEMCALGeometry::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nTower,Int_t &nIphi,Int_t &nIeta) const |
1963b290 | 800 | { // 21-sep-04 |
d87bd045 | 801 | // 19-oct-05; |
802 | static Int_t tmp=0, sm10=0; | |
1963b290 | 803 | if(absId<=0 || absId>fNCells) { |
500aeccc | 804 | // Info("GetCellIndex"," wrong abs Id %i !! \n", absId); |
1963b290 | 805 | return kFALSE; |
806 | } | |
d87bd045 | 807 | sm10 = fNCellsInSupMod*10; |
808 | if(fKey110DEG == 1 && absId > sm10) { // 110 degree case; last two supermodules | |
809 | nSupMod = (absId-1-sm10) / (fNCellsInSupMod/2) + 11; | |
810 | tmp = (absId-1-sm10) % (fNCellsInSupMod/2); | |
811 | } else { | |
812 | nSupMod = (absId-1) / fNCellsInSupMod + 1; | |
813 | tmp = (absId-1) % fNCellsInSupMod; | |
814 | } | |
1963b290 | 815 | |
816 | nTower = tmp / fNCellsInTower + 1; | |
817 | tmp = tmp % fNCellsInTower; | |
d87bd045 | 818 | nIphi = tmp / fNPHIdiv + 1; |
819 | nIeta = tmp % fNPHIdiv + 1; | |
1963b290 | 820 | |
821 | return kTRUE; | |
822 | } | |
823 | ||
e52475ed | 824 | void AliEMCALGeometry::GetTowerPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, int &iphit, int &ietat) const |
d87bd045 | 825 | { // added nSupMod; have to check - 19-oct-05 ! |
826 | static Int_t nphi; | |
827 | ||
828 | if(fKey110DEG == 1 && nSupMod>=11) nphi = fNPhi/2; | |
829 | else nphi = fNPhi; | |
830 | ||
831 | ietat = (nTower-1)/nphi + 1; // have to change from 1 to fNZ | |
d87bd045 | 832 | iphit = (nTower-1)%nphi + 1; // have to change from 1 to fNPhi |
833 | } | |
834 | ||
eb0b1051 | 835 | void AliEMCALGeometry::GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta, |
e52475ed | 836 | int &iphi, int &ieta) const |
c01485dd | 837 | { // added nSupMod; Nov 25, 05 |
838 | static Int_t iphit, ietat; | |
839 | ||
840 | GetTowerPhiEtaIndexInSModule(nSupMod,nTower, iphit, ietat); | |
841 | // have to change from 1 to fNZ*fNETAdiv | |
842 | ieta = (ietat-1)*fNETAdiv + (3-nIeta); // x(module) = -z(SM) | |
843 | // iphi - have to change from 1 to fNPhi*fNPHIdiv | |
844 | iphi = (iphit-1)*fNPHIdiv + nIphi; // y(module) = y(SM) | |
1963b290 | 845 | } |
e52475ed | 846 | |
847 | Int_t AliEMCALGeometry::GetSuperModuleNumber(Int_t absId) const | |
848 | { | |
849 | static Int_t nSupMod, nTower, nIphi, nIeta; | |
850 | GetCellIndex(absId, nSupMod, nTower, nIphi, nIeta); | |
851 | return nSupMod; | |
852 | } | |
853 | ||
854 | // Methods for AliEMCALRecPoint - Feb 19, 2006 | |
855 | Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr) | |
856 | { | |
857 | static Int_t nSupMod, nTower, nIphi, nIeta, iphi, ieta; | |
858 | if(!CheckAbsCellId(absId)) return kFALSE; | |
859 | ||
860 | GetCellIndex(absId, nSupMod, nTower, nIphi, nIeta); | |
861 | GetCellPhiEtaIndexInSModule(nSupMod,nTower,nIphi,nIeta, iphi, ieta); | |
862 | ||
863 | xr = fXCentersOfCells->At(ieta-1); | |
864 | zr = fEtaCentersOfCells->At(ieta-1); | |
865 | ||
866 | yr = fPhiCentersOfCells->At(iphi-1); | |
867 | ||
868 | // cout<<" absId "<<absId<<" iphi "<<iphi<<"ieta"<<ieta; | |
869 | // cout<< " xr " << xr << " yr " << yr << " zr " << zr <<endl; | |
870 | return kTRUE; | |
871 | } | |
872 | ||
873 | void AliEMCALGeometry::CreateListOfTrd1Modules() | |
874 | { | |
875 | cout<< endl<< " AliEMCALGeometry::CreateListOfTrd1Modules() started " << endl; | |
876 | AliEMCALShishKebabTrd1Module *mod=0, *mTmp=0; // current module | |
877 | if(fShishKebabTrd1Modules == 0) { | |
878 | fShishKebabTrd1Modules = new TList; | |
879 | for(int iz=0; iz< GetNZ(); iz++) { | |
880 | if(iz==0) { | |
881 | mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,this); | |
882 | } else { | |
883 | mTmp = new AliEMCALShishKebabTrd1Module(*mod); | |
884 | mod = mTmp; | |
885 | } | |
886 | fShishKebabTrd1Modules->Add(mod); | |
887 | } | |
888 | } else { | |
889 | cout<<" Already exits : "; | |
890 | } | |
891 | cout<<" fShishKebabTrd1Modules "<< fShishKebabTrd1Modules << " has " | |
892 | << fShishKebabTrd1Modules->GetSize() << " modules" <<endl << endl; | |
893 | // Feb 20,2006; | |
894 | // define grid for cells in eta(z) and x directions in local coordinates system of SM | |
895 | fEtaCentersOfCells = new TArrayD(fNZ *fNETAdiv); | |
896 | fXCentersOfCells = new TArrayD(fNZ *fNETAdiv); | |
897 | printf(" Cells grid in eta directions : size %i\n", fEtaCentersOfCells->GetSize()); | |
898 | Int_t iphi=0, ieta=0, nTower=0; | |
899 | Double_t xr, zr; | |
900 | for(Int_t it=0; it<fNZ; it++) { // array index | |
901 | AliEMCALShishKebabTrd1Module *trd1 = GetShishKebabModule(it); | |
902 | nTower = fNPhi*it + 1; | |
903 | for(Int_t ic=0; ic<fNETAdiv; ic++) { // array index | |
904 | trd1->GetCenterOfCellInLocalCoordinateofSM(ic+1, xr, zr); | |
905 | GetCellPhiEtaIndexInSModule(1, nTower, 1, ic+1, iphi, ieta); // don't depend from phi | |
906 | fXCentersOfCells->AddAt(float(xr) - fParSM[0],ieta-1); | |
907 | fEtaCentersOfCells->AddAt(float(zr) - fParSM[2],ieta-1); | |
908 | } | |
909 | } | |
910 | for(Int_t i=0; i<fEtaCentersOfCells->GetSize(); i++) { | |
911 | printf(" ind %2.2i : z %8.3f : x %8.3f", i+1, fEtaCentersOfCells->At(i),fXCentersOfCells->At(i)); | |
912 | if(i%2 != 0) printf("\n"); | |
913 | } | |
914 | printf("\n"); | |
915 | // define grid for cells in phi(y) direction in local coordinates system of SM | |
916 | fPhiCentersOfCells = new TArrayD(fNPhi*fNPHIdiv); | |
917 | printf(" Cells grid in phi directions : size %i\n", fPhiCentersOfCells->GetSize()); | |
918 | Int_t ind=0; | |
919 | for(Int_t it=0; it<fNPhi; it++) { // array index | |
920 | Float_t ytLeftCenterModule = -fParSM[1] + fPhiModuleSize*(2*it+1)/2; // module | |
921 | for(Int_t ic=0; ic<fNPHIdiv; ic++) { // array index | |
922 | Float_t ytLeftCenterCell = ytLeftCenterModule + fPhiTileSize *(2*ic-1)/2.; // tower(cell) | |
923 | fPhiCentersOfCells->AddAt(ytLeftCenterCell,ind); | |
924 | printf(" ind %2.2i : y %8.3f ", ind, fPhiCentersOfCells->At(ind++)); | |
925 | if(ic == fNPHIdiv-1) printf("\n"); | |
926 | } | |
927 | } | |
928 | printf("\n"); | |
929 | } | |
930 | ||
931 | void AliEMCALGeometry::GetTransformationForSM() | |
932 | { | |
933 | static Bool_t transInit=kFALSE; | |
934 | if(transInit) return; | |
935 | ||
936 | int i=0; | |
937 | if(gGeoManager == 0) { | |
938 | Info("CreateTransformationForSM() "," Load geometry : TGeoManager::Import()"); | |
939 | assert(0); | |
940 | } | |
941 | TGeoNode *tn = gGeoManager->GetTopNode(); | |
942 | TGeoNode *node=0, *XEN1 = 0; | |
943 | for(i=0; i<tn->GetNdaughters(); i++) { | |
944 | node = tn->GetDaughter(i); | |
945 | TString ns(node->GetName()); | |
946 | if(ns.Contains(GetNameOfEMCALEnvelope())) { | |
947 | XEN1 = node; | |
948 | break; | |
949 | } | |
950 | } | |
951 | if(!XEN1) { | |
952 | Info("CreateTransformationForSM() "," geometry has not EMCAL envelope with name %s", | |
953 | GetNameOfEMCALEnvelope()); | |
954 | assert(0); | |
955 | } | |
956 | printf(" i %i : EMCAL Envelope is %s : #SM %i \n", i, XEN1->GetName(), XEN1->GetNdaughters()); | |
957 | for(i=0; i<XEN1->GetNdaughters(); i++) { | |
958 | TGeoNodeMatrix *sm = (TGeoNodeMatrix*)XEN1->GetDaughter(i); | |
959 | fMatrixOfSM[i] = sm->GetMatrix(); | |
64942713 | 960 | //Compiler doesn't like this syntax... |
961 | // printf(" %i : matrix %x \n", i, fMatrixOfSM[i]); | |
e52475ed | 962 | } |
963 | transInit = kTRUE; | |
964 | } | |
965 | ||
966 | void AliEMCALGeometry::GetGlobal(const Double_t *loc, Double_t *glob, int nsm) const | |
967 | { | |
968 | // if(fMatrixOfSM[0] == 0) GetTransformationForSM(); | |
969 | static int ind; | |
970 | ind = nsm-1; | |
971 | if(ind>=0 && ind < GetNumberOfSuperModules()) { | |
972 | fMatrixOfSM[ind]->LocalToMaster(loc, glob); | |
973 | } | |
974 | } | |
975 | ||
21cf2b24 | 976 | void AliEMCALGeometry::GetGlobal(Int_t /* absId */, TVector3 & /* vglob */) const |
e52475ed | 977 | { // have to be defined |
978 | } | |
979 | ||
980 | void AliEMCALGeometry::GetGlobal(const TVector3 &vloc, TVector3 &vglob, int nsm) const | |
981 | { | |
982 | static Double_t tglob[3], tloc[3]; | |
983 | vloc.GetXYZ(tloc); | |
984 | GetGlobal(tloc, tglob, nsm); | |
985 | vglob.SetXYZ(tglob[0], tglob[1], tglob[2]); | |
986 | } | |
987 | ||
988 | void AliEMCALGeometry::GetGlobal(const AliRecPoint *rp, TVector3 &vglob) const | |
989 | { | |
990 | static TVector3 vloc; | |
991 | static Int_t nSupMod, nTower, nIphi, nIeta; | |
992 | ||
993 | AliRecPoint *rpTmp = (AliRecPoint*)rp; // const_cast ?? | |
994 | if(!rpTmp) return; | |
995 | AliEMCALRecPoint *rpEmc = (AliEMCALRecPoint*)rpTmp; | |
996 | ||
997 | GetCellIndex(rpEmc->GetAbsId(0), nSupMod, nTower, nIphi, nIeta); | |
998 | rpTmp->GetLocalPosition(vloc); | |
999 | GetGlobal(vloc, vglob, nSupMod); | |
1000 | } | |
1001 |