]>
Commit | Line | Data |
---|---|---|
0c5b726e | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id: AliEMCALGeoUtils.cxx 25590 2008-05-06 07:09:11Z prsnko $ */ | |
17 | ||
18 | //_________________________________________________________________________ | |
19 | // Geometry class for EMCAL : singleton | |
20 | // | |
21 | // -- Author: Magali Estienne (magali.estienne@subatech.in2p3.fr) | |
22 | ||
23 | // | |
24 | // Usage: | |
25 | // You can create the AliEMCALGeoUtils object independently from anything. | |
26 | // You have to use just the correct name of geometry. If name is empty string the | |
27 | // default name of geometry will be used. | |
28 | // | |
29 | // AliEMCALGeoUtils* geom = new AliEMCALGeoUtils("EMCAL_COMPLETE","EMCAL"); | |
30 | // TGeoManager::Import("geometry.root"); | |
31 | // | |
32 | // MC: If you work with MC data you have to get geometry the next way: | |
33 | // == ============================= | |
34 | // !!!!!!!!! This part has to be modified | |
35 | // AliRunLoader *rl = AliRunLoader::GetRunLoader(); | |
36 | // AliEMCALEMCGeometry *geom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry(); | |
37 | // TGeoManager::Import("geometry.root"); | |
38 | ||
39 | ||
40 | // --- ROOT system --- | |
41 | ||
42 | #include <TParticle.h> | |
43 | #include <TGeoManager.h> | |
44 | #include <TGeoMatrix.h> | |
45 | #include <TList.h> | |
46 | #include <TBrowser.h> | |
47 | ||
48 | // --- Standard library --- | |
49 | //#include <Riostream.h> | |
50 | ||
51 | // --- AliRoot header files --- | |
52 | #include "AliEMCALGeoUtils.h" | |
53 | #include "AliEMCALShishKebabTrd1Module.h" | |
54 | ||
55 | ClassImp(AliEMCALGeoUtils) | |
56 | ||
57 | //____________________________________________________________________________ | |
58 | AliEMCALGeoUtils::AliEMCALGeoUtils(): | |
59 | fEMCGeometry(0x0),fGeoName(0), | |
60 | fKey110DEG(0),fNCellsInSupMod(0),fNETAdiv(0),fNPHIdiv(0), | |
61 | fNCellsInModule(0),fPhiBoundariesOfSM(0x0),fPhiCentersOfSM(0x0), | |
62 | fPhiCentersOfCells(0x0),fCentersOfCellsEtaDir(0x0), | |
63 | fCentersOfCellsPhiDir(0x0),fEtaCentersOfCells(0x0), | |
64 | fNCells(0),fNPhi(0),fCentersOfCellsXDir(0x0),fArm1EtaMin(0), | |
65 | fArm1EtaMax(0),fArm1PhiMin(0),fArm1PhiMax(0),fEtaMaxOfTRD1(0), | |
66 | fShishKebabTrd1Modules(0),fParSM(0x0),fPhiModuleSize(0.), | |
67 | fEtaModuleSize(0.),fPhiTileSize(0.),fEtaTileSize(0.),fNZ(0), | |
68 | fIPDistance(0.),fLongModuleSize(0.),fShellThickness(0.), | |
69 | fZLength(0.),fSampling(0.) | |
70 | { | |
71 | // default ctor | |
72 | // must be kept public for root persistency purposes, but should never be called by the outside world | |
73 | fEnvelop[0] = 0.; | |
74 | fEnvelop[1] = 0.; | |
75 | fEnvelop[2] = 0.; | |
76 | ||
77 | } | |
78 | ||
79 | //____________________________________________________________________________ | |
80 | AliEMCALGeoUtils::AliEMCALGeoUtils(const AliEMCALGeoUtils & geo) | |
81 | : TNamed(geo), | |
82 | fEMCGeometry(geo.fEMCGeometry),fGeoName(geo.fGeoName), | |
83 | fKey110DEG(geo.fKey110DEG),fNCellsInSupMod(geo.fNCellsInSupMod),fNETAdiv(geo.fNETAdiv),fNPHIdiv(geo.fNPHIdiv), | |
84 | fNCellsInModule(geo.fNCellsInModule),fPhiBoundariesOfSM(geo.fPhiBoundariesOfSM),fPhiCentersOfSM(geo.fPhiCentersOfSM), | |
85 | fPhiCentersOfCells(geo.fPhiCentersOfCells),fCentersOfCellsEtaDir(geo.fCentersOfCellsEtaDir), | |
86 | fCentersOfCellsPhiDir(geo.fCentersOfCellsPhiDir),fEtaCentersOfCells(geo.fEtaCentersOfCells), | |
87 | fNCells(geo.fNCells),fNPhi(geo.fNPhi),fCentersOfCellsXDir(geo.fCentersOfCellsXDir),fArm1EtaMin(geo.fArm1EtaMin), | |
88 | fArm1EtaMax(geo.fArm1EtaMax),fArm1PhiMin(geo.fArm1PhiMin),fArm1PhiMax(geo.fArm1PhiMax),fEtaMaxOfTRD1(geo.fEtaMaxOfTRD1), | |
89 | fShishKebabTrd1Modules(geo.fShishKebabTrd1Modules),fParSM(geo.fParSM),fPhiModuleSize(geo.fPhiModuleSize), | |
90 | fEtaModuleSize(geo.fEtaModuleSize),fPhiTileSize(geo.fPhiTileSize),fEtaTileSize(geo.fEtaTileSize),fNZ(geo.fNZ), | |
91 | fIPDistance(geo.fIPDistance),fLongModuleSize(geo.fLongModuleSize),fShellThickness(geo.fShellThickness), | |
92 | fZLength(geo.fZLength),fSampling(geo.fSampling) | |
93 | { | |
94 | fEnvelop[0] = geo.fEnvelop[0]; | |
95 | fEnvelop[1] = geo.fEnvelop[1]; | |
96 | fEnvelop[2] = geo.fEnvelop[2]; | |
97 | } | |
98 | ||
99 | //____________________________________________________________________________ | |
100 | AliEMCALGeoUtils::AliEMCALGeoUtils(const Text_t* name, const Text_t* title) | |
101 | : TNamed(name, title), | |
102 | fEMCGeometry(0x0),fGeoName(0), | |
103 | fKey110DEG(0),fNCellsInSupMod(0),fNETAdiv(0),fNPHIdiv(0), | |
104 | fNCellsInModule(0),fPhiBoundariesOfSM(0x0),fPhiCentersOfSM(0x0), | |
105 | fPhiCentersOfCells(0x0),fCentersOfCellsEtaDir(0x0), | |
106 | fCentersOfCellsPhiDir(0x0),fEtaCentersOfCells(0x0), | |
107 | fNCells(0),fNPhi(0),fCentersOfCellsXDir(0x0),fArm1EtaMin(0), | |
108 | fArm1EtaMax(0),fArm1PhiMin(0),fArm1PhiMax(0),fEtaMaxOfTRD1(0), | |
109 | fShishKebabTrd1Modules(0),fParSM(0x0),fPhiModuleSize(0.), | |
110 | fEtaModuleSize(0.),fPhiTileSize(0.),fEtaTileSize(0.),fNZ(0), | |
111 | fIPDistance(0.),fLongModuleSize(0.),fShellThickness(0.), | |
112 | fZLength(0.),fSampling(0.) | |
113 | { | |
114 | ||
115 | // ctor only for normal usage | |
116 | ||
117 | fEMCGeometry = new AliEMCALEMCGeometry(name,title); | |
118 | ||
119 | fGeoName = fEMCGeometry->GetGeoName(); | |
120 | fKey110DEG = fEMCGeometry->GetKey110DEG(); | |
121 | fNCellsInSupMod = fEMCGeometry->GetNCellsInSupMod(); | |
122 | fNETAdiv = fEMCGeometry->GetNETAdiv(); | |
123 | fNPHIdiv = fEMCGeometry->GetNPHIdiv(); | |
124 | fNCellsInModule = fNPHIdiv*fNETAdiv; | |
125 | static int i; | |
126 | Int_t nSMod = fEMCGeometry->GetNumberOfSuperModules(); | |
127 | fPhiBoundariesOfSM.Set(nSMod); | |
128 | fPhiCentersOfSM.Set(nSMod/2); | |
129 | for(Int_t sm=0; sm<nSMod; sm++) { | |
130 | i = sm/2; | |
131 | fEMCGeometry->GetPhiBoundariesOfSM(sm,fPhiBoundariesOfSM[2*i],fPhiBoundariesOfSM[2*i+1]); | |
132 | } | |
133 | ||
134 | Double_t phiMin = 0.; | |
135 | Double_t phiMax = 0.; | |
136 | for(Int_t sm=0; sm<nSMod; sm++) { | |
137 | fEMCGeometry->GetPhiBoundariesOfSM(sm,phiMin,phiMax); | |
138 | i=sm/2; | |
139 | fPhiCentersOfSM[i] = fEMCGeometry->GetPhiCenterOfSM(sm); | |
140 | } | |
141 | fNCells = fEMCGeometry->GetNCells(); | |
142 | fNPhi = fEMCGeometry->GetNPhi(); | |
143 | fEnvelop[0] = fEMCGeometry->GetEnvelop(0); | |
144 | fEnvelop[1] = fEMCGeometry->GetEnvelop(1); | |
145 | fEnvelop[2] = fEMCGeometry->GetEnvelop(2); | |
146 | fArm1EtaMin = fEMCGeometry->GetArm1EtaMin(); | |
147 | fArm1EtaMax = fEMCGeometry->GetArm1EtaMax(); | |
148 | fArm1PhiMin = fEMCGeometry->GetArm1PhiMin(); | |
149 | fArm1PhiMax = fEMCGeometry->GetArm1PhiMax(); | |
150 | fShellThickness = fEMCGeometry->GetShellThickness(); | |
151 | fZLength = fEMCGeometry->GetZLength(); | |
152 | fSampling = fEMCGeometry->GetSampling(); | |
153 | fParSM = fEMCGeometry->GetSuperModulesPars(); | |
154 | fEtaModuleSize = fEMCGeometry->GetEtaModuleSize(); | |
155 | fPhiModuleSize = fEMCGeometry->GetPhiModuleSize(); | |
156 | fEtaTileSize = fEMCGeometry->GetEtaTileSize(); | |
157 | fPhiTileSize = fEMCGeometry->GetPhiTileSize(); | |
158 | fNZ = fEMCGeometry->GetNZ(); | |
159 | fIPDistance = fEMCGeometry->GetIPDistance(); | |
160 | fLongModuleSize = fEMCGeometry->GetLongModuleSize(); | |
161 | ||
162 | CreateListOfTrd1Modules(); | |
163 | ||
164 | for(Int_t smod=0; smod < fEMCGeometry->GetNumberOfSuperModules(); smod++) | |
165 | fkSModuleMatrix[smod]=0 ; | |
166 | ||
167 | if (AliDebugLevel()>=2) { | |
168 | fEMCGeometry->Print(); | |
169 | PrintGeometry(); | |
170 | } | |
171 | ||
172 | } | |
173 | ||
174 | //____________________________________________________________________________ | |
175 | AliEMCALGeoUtils & AliEMCALGeoUtils::operator = (const AliEMCALGeoUtils & /*rvalue*/) { | |
176 | ||
177 | Fatal("assignment operator", "not implemented") ; | |
178 | return *this ; | |
179 | } | |
180 | ||
181 | //____________________________________________________________________________ | |
182 | AliEMCALGeoUtils::~AliEMCALGeoUtils(void) | |
183 | { | |
184 | // dtor | |
185 | if(fEMCGeometry){ | |
186 | delete fEMCGeometry; fEMCGeometry = 0 ; | |
187 | } | |
188 | } | |
189 | ||
190 | ||
191 | //________________________________________________________________________________________________ | |
192 | void AliEMCALGeoUtils::Browse(TBrowser* b) | |
193 | { | |
194 | //Browse the modules | |
195 | if(fShishKebabTrd1Modules) b->Add(fShishKebabTrd1Modules); | |
196 | } | |
197 | ||
198 | //________________________________________________________________________________________________ | |
199 | Bool_t AliEMCALGeoUtils::IsFolder() const | |
200 | { | |
201 | //Check if fShishKebabTrd1Modules is in folder | |
202 | if(fShishKebabTrd1Modules) return kTRUE; | |
203 | else return kFALSE; | |
204 | } | |
205 | ||
206 | //________________________________________________________________________________________________ | |
207 | void AliEMCALGeoUtils::GetGlobal(const Double_t *loc, Double_t *glob, int ind) const | |
208 | { | |
209 | // Figure out the global numbering | |
210 | // of a given supermodule from the | |
211 | // local numbering and the transformation | |
212 | // matrix stored by the geometry manager (allows for misaligned | |
213 | // geometry) | |
214 | ||
215 | // if(ind>=0 && ind < fEMCGeometry->GetNumberOfSuperModules()) { | |
216 | // TString volpath = "ALIC_1/XEN1_1/SMOD_"; | |
217 | // volpath += ind+1; | |
218 | // | |
219 | // if(fKey110DEG && ind>=10) { | |
220 | // volpath = "ALIC_1/XEN1_1/SM10_"; | |
221 | // volpath += ind-10+1; | |
222 | // } | |
223 | // | |
224 | // if(!gGeoManager->cd(volpath.Data())) | |
225 | // AliFatal(Form("AliEMCALGeometry::GeoManager cannot find path %s!",volpath.Data())); | |
226 | // | |
227 | // TGeoHMatrix* m = gGeoManager->GetCurrentMatrix(); | |
228 | ||
229 | const TGeoHMatrix* m = GetMatrixForSuperModule(ind); | |
230 | if(m) { | |
231 | m->LocalToMaster(loc, glob); | |
232 | } else { | |
233 | AliFatal("Geo matrixes are not loaded \n") ; | |
234 | } | |
235 | // } | |
236 | } | |
237 | ||
238 | //________________________________________________________________________________________________ | |
239 | void AliEMCALGeoUtils::GetGlobal(const TVector3 &vloc, TVector3 &vglob, int ind) const | |
240 | { | |
241 | //Figure out the global numbering | |
242 | //of a given supermodule from the | |
243 | //local numbering given a 3-vector location | |
244 | ||
245 | static Double_t tglob[3], tloc[3]; | |
246 | vloc.GetXYZ(tloc); | |
247 | GetGlobal(tloc, tglob, ind); | |
248 | vglob.SetXYZ(tglob[0], tglob[1], tglob[2]); | |
249 | } | |
250 | ||
251 | //________________________________________________________________________________________________ | |
252 | void AliEMCALGeoUtils::GetGlobal(Int_t absId , double glob[3]) const | |
253 | { | |
254 | // Alice numbering scheme - Jun 03, 2006 | |
255 | static Int_t nSupMod, nModule, nIphi, nIeta; | |
256 | static double loc[3]; | |
257 | ||
258 | if (!gGeoManager || !gGeoManager->IsClosed()) { | |
259 | AliError("Can't get the global coordinates! gGeoManager doesn't exist or it is still open!"); | |
260 | return; | |
261 | } | |
262 | ||
263 | glob[0]=glob[1]=glob[2]=0.0; // bad case | |
264 | if(RelPosCellInSModule(absId, loc)) { | |
265 | GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta); | |
266 | ||
267 | // TString volpath = "ALIC_1/XEN1_1/SMOD_"; | |
268 | // volpath += (nSupMod+1); | |
269 | // | |
270 | // if(fKey110DEG && nSupMod>=10) { | |
271 | // volpath = "ALIC_1/XEN1_1/SM10_"; | |
272 | // volpath += (nSupMod-10+1); | |
273 | // } | |
274 | // if(!gGeoManager->cd(volpath.Data())) | |
275 | // AliFatal(Form("GeoManager cannot find path %s!",volpath.Data())); | |
276 | // | |
277 | // TGeoHMatrix* m = gGeoManager->GetCurrentMatrix(); | |
278 | const TGeoHMatrix* m = GetMatrixForSuperModule(nSupMod); | |
279 | if(m) { | |
280 | m->LocalToMaster(loc, glob); | |
281 | } else { | |
282 | AliFatal("Geo matrixes are not loaded \n") ; | |
283 | } | |
284 | } | |
285 | } | |
286 | ||
287 | //___________________________________________________________________ | |
288 | void AliEMCALGeoUtils::GetGlobal(Int_t absId , TVector3 &vglob) const | |
289 | { | |
290 | // Alice numbering scheme - Jun 03, 2006 | |
291 | static Double_t glob[3]; | |
292 | ||
293 | GetGlobal(absId, glob); | |
294 | vglob.SetXYZ(glob[0], glob[1], glob[2]); | |
295 | ||
296 | } | |
297 | ||
298 | ||
299 | //______________________________________________________________________ | |
300 | void AliEMCALGeoUtils::PrintCellIndexes(Int_t absId, int pri, const char *tit) const | |
301 | { | |
302 | // Service methods | |
303 | Int_t nSupMod, nModule, nIphi, nIeta; | |
304 | Int_t iphi, ieta; | |
305 | TVector3 vg; | |
306 | ||
307 | GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta); | |
308 | printf(" %s | absId : %i -> nSupMod %i nModule %i nIphi %i nIeta %i \n", tit, absId, nSupMod, nModule, nIphi, nIeta); | |
309 | if(pri>0) { | |
310 | GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta); | |
311 | printf(" local SM index : iphi %i : ieta %i \n", iphi,ieta); | |
312 | GetGlobal(absId, vg); | |
313 | printf(" vglob : mag %7.2f : perp %7.2f : z %7.2f : eta %6.4f : phi %6.4f(%6.2f) \n", | |
314 | vg.Mag(), vg.Perp(), vg.Z(), vg.Eta(), vg.Phi(), vg.Phi()*TMath::RadToDeg()); | |
315 | } | |
316 | } | |
317 | ||
318 | //________________________________________________________________________________________________ | |
319 | void AliEMCALGeoUtils::EtaPhiFromIndex(Int_t absId,Double_t &eta,Double_t &phi) const | |
320 | { | |
321 | // Nov 16, 2006- float to double | |
322 | // version for TRD1 only | |
323 | static TVector3 vglob; | |
324 | GetGlobal(absId, vglob); | |
325 | eta = vglob.Eta(); | |
326 | phi = vglob.Phi(); | |
327 | } | |
328 | ||
329 | //________________________________________________________________________________________________ | |
330 | void AliEMCALGeoUtils::EtaPhiFromIndex(Int_t absId,Float_t &eta,Float_t &phi) const | |
331 | { | |
332 | // Nov 16,2006 - should be discard in future | |
333 | static TVector3 vglob; | |
334 | GetGlobal(absId, vglob); | |
335 | eta = float(vglob.Eta()); | |
336 | phi = float(vglob.Phi()); | |
337 | } | |
338 | ||
339 | // | |
340 | // == Shish-kebab cases == | |
341 | // | |
342 | //________________________________________________________________________________________________ | |
343 | Int_t AliEMCALGeoUtils::GetAbsCellId(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta) const | |
344 | { | |
345 | // 27-aug-04; | |
346 | // corr. 21-sep-04; | |
347 | // 13-oct-05; 110 degree case | |
348 | // May 31, 2006; ALICE numbering scheme: | |
349 | // 0 <= nSupMod < fNumberOfSuperModules | |
350 | // 0 <= nModule < fNPHI * fNZ ( fNPHI * fNZ/2 for fKey110DEG=1) | |
351 | // 0 <= nIphi < fNPHIdiv | |
352 | // 0 <= nIeta < fNETAdiv | |
353 | // 0 <= absid < fNCells | |
354 | static Int_t id=0; // have to change from 0 to fNCells-1 | |
355 | if(fKey110DEG == 1 && nSupMod >= 10) { // 110 degree case; last two supermodules | |
356 | id = fNCellsInSupMod*10 + (fNCellsInSupMod/2)*(nSupMod-10); | |
357 | } else { | |
358 | id = fNCellsInSupMod*nSupMod; | |
359 | } | |
360 | id += fNCellsInModule *nModule; | |
361 | id += fNPHIdiv *nIphi; | |
362 | id += nIeta; | |
363 | if(id<0 || id >= fNCells) { | |
364 | // printf(" wrong numerations !!\n"); | |
365 | // printf(" id %6i(will be force to -1)\n", id); | |
366 | // printf(" fNCells %6i\n", fNCells); | |
367 | // printf(" nSupMod %6i\n", nSupMod); | |
368 | // printf(" nModule %6i\n", nModule); | |
369 | // printf(" nIphi %6i\n", nIphi); | |
370 | // printf(" nIeta %6i\n", nIeta); | |
371 | id = -TMath::Abs(id); // if negative something wrong | |
372 | } | |
373 | return id; | |
374 | } | |
375 | ||
376 | //________________________________________________________________________________________________ | |
377 | void AliEMCALGeoUtils::GetModuleIndexesFromCellIndexesInSModule(Int_t nSupMod, Int_t iphi, Int_t ieta, | |
378 | Int_t &iphim, Int_t &ietam, Int_t &nModule) const | |
379 | { | |
380 | // Transition from cell indexes (ieta,iphi) to module indexes (ietam,iphim, nModule) | |
381 | static Int_t nphi; | |
382 | nphi = GetNumberOfModuleInPhiDirection(nSupMod); | |
383 | ||
384 | ietam = ieta/fNETAdiv; | |
385 | iphim = iphi/fNPHIdiv; | |
386 | nModule = ietam * nphi + iphim; | |
387 | } | |
388 | ||
389 | //________________________________________________________________________________________________ | |
390 | Int_t AliEMCALGeoUtils::GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, Int_t ieta) const | |
391 | { | |
392 | // Transition from super module number(nSupMod) and cell indexes (ieta,iphi) to absId | |
393 | static Int_t ietam, iphim, nModule; | |
394 | static Int_t nIeta, nIphi; // cell indexes in module | |
395 | ||
396 | GetModuleIndexesFromCellIndexesInSModule(nSupMod, iphi, ieta, ietam, iphim, nModule); | |
397 | ||
398 | nIeta = ieta%fNETAdiv; | |
399 | nIeta = fNETAdiv - 1 - nIeta; | |
400 | nIphi = iphi%fNPHIdiv; | |
401 | ||
402 | return GetAbsCellId(nSupMod, nModule, nIphi, nIeta); | |
403 | } | |
404 | ||
405 | //________________________________________________________________________________________________ | |
406 | Bool_t AliEMCALGeoUtils::SuperModuleNumberFromEtaPhi(Double_t eta, Double_t phi, Int_t &nSupMod) const | |
407 | { | |
408 | // Return false if phi belongs a phi cracks between SM | |
409 | ||
410 | static Int_t i; | |
411 | ||
412 | if(TMath::Abs(eta) > fEtaMaxOfTRD1) return kFALSE; | |
413 | ||
414 | phi = TVector2::Phi_0_2pi(phi); // move phi to (0,2pi) boundaries | |
415 | for(i=0; i<6; i++) { | |
416 | if(phi>=fPhiBoundariesOfSM[2*i] && phi<=fPhiBoundariesOfSM[2*i+1]) { | |
417 | nSupMod = 2*i; | |
418 | if(eta < 0.0) nSupMod++; | |
419 | AliDebug(1,Form("eta %f phi %f(%5.2f) : nSupMod %i : #bound %i", eta,phi,phi*TMath::RadToDeg(), nSupMod,i)); | |
420 | return kTRUE; | |
421 | } | |
422 | } | |
423 | return kFALSE; | |
424 | } | |
425 | ||
426 | ||
427 | //________________________________________________________________________________________________ | |
428 | Bool_t AliEMCALGeoUtils::GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi, Int_t &absId) const | |
429 | { | |
430 | // Nov 17,2006 | |
431 | // stay here - phi problem as usual | |
432 | static Int_t nSupMod, i, ieta, iphi, etaShift, nphi; | |
433 | static Double_t absEta=0.0, d=0.0, dmin=0.0, phiLoc; | |
434 | absId = nSupMod = - 1; | |
435 | if(SuperModuleNumberFromEtaPhi(eta, phi, nSupMod)) { | |
436 | // phi index first | |
437 | phi = TVector2::Phi_0_2pi(phi); | |
438 | phiLoc = phi - fPhiCentersOfSM[nSupMod/2]; | |
439 | nphi = fPhiCentersOfCells.GetSize(); | |
440 | if(nSupMod>=10) { | |
441 | phiLoc = phi - 190.*TMath::DegToRad(); | |
442 | nphi /= 2; | |
443 | } | |
444 | ||
445 | dmin = TMath::Abs(fPhiCentersOfCells[0]-phiLoc); | |
446 | iphi = 0; | |
447 | for(i=1; i<nphi; i++) { | |
448 | d = TMath::Abs(fPhiCentersOfCells[i] - phiLoc); | |
449 | if(d < dmin) { | |
450 | dmin = d; | |
451 | iphi = i; | |
452 | } | |
453 | // printf(" i %i : d %f : dmin %f : fPhiCentersOfCells[i] %f \n", i, d, dmin, fPhiCentersOfCells[i]); | |
454 | } | |
455 | // odd SM are turned with respect of even SM - reverse indexes | |
456 | AliDebug(2,Form(" iphi %i : dmin %f (phi %f, phiLoc %f ) ", iphi, dmin, phi, phiLoc)); | |
457 | // eta index | |
458 | absEta = TMath::Abs(eta); | |
459 | etaShift = iphi*fCentersOfCellsEtaDir.GetSize(); | |
460 | dmin = TMath::Abs(fEtaCentersOfCells[etaShift]-absEta); | |
461 | ieta = 0; | |
462 | for(i=1; i<fCentersOfCellsEtaDir.GetSize(); i++) { | |
463 | d = TMath::Abs(fEtaCentersOfCells[i+etaShift] - absEta); | |
464 | if(d < dmin) { | |
465 | dmin = d; | |
466 | ieta = i; | |
467 | } | |
468 | } | |
469 | AliDebug(2,Form(" ieta %i : dmin %f (eta=%f) : nSupMod %i ", ieta, dmin, eta, nSupMod)); | |
470 | ||
471 | if(eta<0) iphi = (nphi-1) - iphi; | |
472 | absId = GetAbsCellIdFromCellIndexes(nSupMod, iphi, ieta); | |
473 | ||
474 | return kTRUE; | |
475 | } | |
476 | return kFALSE; | |
477 | } | |
478 | ||
479 | //________________________________________________________________________________________________ | |
480 | Bool_t AliEMCALGeoUtils::CheckAbsCellId(Int_t absId) const | |
481 | { | |
482 | // May 31, 2006; only trd1 now | |
483 | if(absId<0 || absId >= fNCells) return kFALSE; | |
484 | else return kTRUE; | |
485 | } | |
486 | ||
487 | //________________________________________________________________________________________________ | |
488 | Bool_t AliEMCALGeoUtils::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nModule,Int_t &nIphi,Int_t &nIeta) const | |
489 | { | |
490 | // 21-sep-04; 19-oct-05; | |
491 | // May 31, 2006; ALICE numbering scheme: | |
492 | // | |
493 | // In: | |
494 | // absId - cell is as in Geant, 0<= absId < fNCells; | |
495 | // Out: | |
496 | // nSupMod - super module(SM) number, 0<= nSupMod < fNumberOfSuperModules; | |
497 | // nModule - module number in SM, 0<= nModule < fNCellsInSupMod/fNCellsInSupMod or(/2) for tow last SM (10th and 11th); | |
498 | // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv; | |
499 | // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv; | |
500 | // | |
501 | static Int_t tmp=0, sm10=0; | |
502 | if(!CheckAbsCellId(absId)) return kFALSE; | |
503 | ||
504 | sm10 = fNCellsInSupMod*10; | |
505 | if(fKey110DEG == 1 && absId >= sm10) { // 110 degree case; last two supermodules | |
506 | nSupMod = (absId-sm10) / (fNCellsInSupMod/2) + 10; | |
507 | tmp = (absId-sm10) % (fNCellsInSupMod/2); | |
508 | } else { | |
509 | nSupMod = absId / fNCellsInSupMod; | |
510 | tmp = absId % fNCellsInSupMod; | |
511 | } | |
512 | ||
513 | nModule = tmp / fNCellsInModule; | |
514 | tmp = tmp % fNCellsInModule; | |
515 | nIphi = tmp / fNPHIdiv; | |
516 | nIeta = tmp % fNPHIdiv; | |
517 | ||
518 | return kTRUE; | |
519 | } | |
520 | ||
521 | //________________________________________________________________________________________________ | |
522 | Int_t AliEMCALGeoUtils::GetSuperModuleNumber(Int_t absId) const | |
523 | { | |
524 | // Return the number of the supermodule given the absolute | |
525 | // ALICE numbering id | |
526 | ||
527 | static Int_t nSupMod, nModule, nIphi, nIeta; | |
528 | GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta); | |
529 | return nSupMod; | |
530 | } | |
531 | ||
532 | //________________________________________________________________________________________________ | |
533 | void AliEMCALGeoUtils::GetModulePhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, int &iphim, int &ietam) const | |
534 | { | |
535 | // added nSupMod; - 19-oct-05 ! | |
536 | // Alice numbering scheme - Jun 01,2006 | |
537 | // ietam, iphi - indexes of module in two dimensional grid of SM | |
538 | // ietam - have to change from 0 to fNZ-1 | |
539 | // iphim - have to change from 0 to nphi-1 (fNPhi-1 or fNPhi/2-1) | |
540 | static Int_t nphi; | |
541 | ||
542 | if(fKey110DEG == 1 && nSupMod>=10) nphi = fNPhi/2; | |
543 | else nphi = fNPhi; | |
544 | ||
545 | ietam = nModule/nphi; | |
546 | iphim = nModule%nphi; | |
547 | } | |
548 | ||
549 | //________________________________________________________________________________________________ | |
550 | void AliEMCALGeoUtils::GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta, | |
551 | int &iphi, int &ieta) const | |
552 | { | |
553 | // | |
554 | // Added nSupMod; Nov 25, 05 | |
555 | // Alice numbering scheme - Jun 01,2006 | |
556 | // IN: | |
557 | // nSupMod - super module(SM) number, 0<= nSupMod < fNumberOfSuperModules; | |
558 | // nModule - module number in SM, 0<= nModule < fNCellsInSupMod/fNCellsInSupMod or(/2) for tow last SM (10th and 11th); | |
559 | // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv; | |
560 | // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv; | |
561 | // | |
562 | // OUT: | |
563 | // ieta, iphi - indexes of cell(tower) in two dimensional grid of SM | |
564 | // ieta - have to change from 0 to (fNZ*fNETAdiv-1) | |
565 | // iphi - have to change from 0 to (fNPhi*fNPHIdiv-1 or fNPhi*fNPHIdiv/2-1) | |
566 | // | |
567 | static Int_t iphim, ietam; | |
568 | ||
569 | GetModulePhiEtaIndexInSModule(nSupMod,nModule, iphim, ietam); | |
570 | // ieta = ietam*fNETAdiv + (1-nIeta); // x(module) = -z(SM) | |
571 | ieta = ietam*fNETAdiv + (fNETAdiv - 1 - nIeta); // x(module) = -z(SM) | |
572 | iphi = iphim*fNPHIdiv + nIphi; // y(module) = y(SM) | |
573 | ||
574 | if(iphi<0 || ieta<0) | |
575 | AliDebug(1,Form(" nSupMod %i nModule %i nIphi %i nIeta %i => ieta %i iphi %i\n", | |
576 | nSupMod, nModule, nIphi, nIeta, ieta, iphi)); | |
577 | } | |
578 | ||
579 | ||
580 | // Methods for AliEMCALRecPoint - Feb 19, 2006 | |
581 | //________________________________________________________________________________________________ | |
582 | Bool_t AliEMCALGeoUtils::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr) const | |
583 | { | |
584 | // Look to see what the relative | |
585 | // position inside a given cell is | |
586 | // for a recpoint. | |
587 | // Alice numbering scheme - Jun 08, 2006 | |
588 | // In: | |
589 | // absId - cell is as in Geant, 0<= absId < fNCells; | |
590 | // OUT: | |
591 | // xr,yr,zr - x,y,z coordinates of cell with absId inside SM | |
592 | ||
593 | // Shift index taking into account the difference between standard SM | |
594 | // and SM of half size in phi direction | |
595 | const Int_t kphiIndexShift = fCentersOfCellsPhiDir.GetSize()/4; // Nov 22, 2006; was 6 for cas 2X2 | |
596 | static Int_t nSupMod, nModule, nIphi, nIeta, iphi, ieta; | |
597 | if(!CheckAbsCellId(absId)) return kFALSE; | |
598 | ||
599 | GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta); | |
600 | GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta); | |
601 | ||
602 | xr = fCentersOfCellsXDir.At(ieta); | |
dd91d8ac | 603 | zr = fCentersOfCellsEtaDir.At(ieta); |
604 | ||
605 | Int_t iphi2 = iphi; | |
606 | ||
607 | if(nSupMod<10) { | |
608 | if(nSupMod%2 != 0) | |
609 | iphi2 = (fCentersOfCellsPhiDir.GetSize()-1)-iphi;// 23-iphi, revert the ordering on C side in order to keep convention. | |
610 | yr = fCentersOfCellsPhiDir.At(iphi2); | |
611 | ||
0c5b726e | 612 | } else { |
dd91d8ac | 613 | if(nSupMod%2 != 0) |
614 | iphi2 = (fCentersOfCellsPhiDir.GetSize()/2-1)-iphi;// 11-iphi, revert the ordering on C side in order to keep convention. | |
615 | yr = fCentersOfCellsPhiDir.At(iphi2 + kphiIndexShift); | |
0c5b726e | 616 | } |
617 | AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr)); | |
618 | ||
619 | return kTRUE; | |
620 | } | |
621 | ||
622 | //________________________________________________________________________________________________ | |
623 | Bool_t AliEMCALGeoUtils::RelPosCellInSModule(Int_t absId, Double_t loc[3]) const | |
624 | { | |
625 | // Look to see what the relative | |
626 | // position inside a given cell is | |
627 | // for a recpoint. // Alice numbering scheme - Jun 03, 2006 | |
628 | loc[0] = loc[1] = loc[2]=0.0; | |
629 | if(RelPosCellInSModule(absId, loc[0],loc[1],loc[2])) { | |
630 | return kTRUE; | |
631 | } | |
632 | return kFALSE; | |
633 | } | |
634 | ||
635 | //________________________________________________________________________________________________ | |
636 | Bool_t AliEMCALGeoUtils::RelPosCellInSModule(Int_t absId, TVector3 &vloc) const | |
637 | { | |
638 | // Look to see what the relative | |
639 | // position inside a given cell is | |
640 | // for a recpoint. | |
641 | // Alice numbering scheme - Jun 03, 2006 | |
642 | static Double_t loc[3]; | |
643 | if(RelPosCellInSModule(absId,loc)) { | |
644 | vloc.SetXYZ(loc[0], loc[1], loc[2]); | |
645 | return kTRUE; | |
646 | } else { | |
647 | vloc.SetXYZ(0,0,0); | |
648 | return kFALSE; | |
649 | } | |
650 | } | |
651 | ||
652 | //________________________________________________________________________________________________ | |
653 | void AliEMCALGeoUtils::CreateListOfTrd1Modules() | |
654 | { | |
655 | // Generate the list of Trd1 modules | |
656 | // which will make up the EMCAL | |
657 | // geometry | |
658 | ||
659 | AliDebug(2,Form(" AliEMCALGeometry::CreateListOfTrd1Modules() started ")); | |
660 | ||
661 | AliEMCALShishKebabTrd1Module *mod=0, *mTmp=0; // current module | |
662 | if(fShishKebabTrd1Modules == 0) { | |
663 | fShishKebabTrd1Modules = new TList; | |
664 | fShishKebabTrd1Modules->SetName("ListOfTRD1"); | |
665 | for(int iz=0; iz< fEMCGeometry->GetNZ(); iz++) { | |
666 | if(iz==0) { | |
667 | // mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,this); | |
668 | mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,fEMCGeometry); | |
669 | } else { | |
670 | mTmp = new AliEMCALShishKebabTrd1Module(*mod); | |
671 | mod = mTmp; | |
672 | } | |
673 | fShishKebabTrd1Modules->Add(mod); | |
674 | } | |
675 | } else { | |
676 | AliDebug(2,Form(" Already exits : ")); | |
677 | } | |
678 | mod = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(fShishKebabTrd1Modules->GetSize()-1); | |
679 | fEtaMaxOfTRD1 = mod->GetMaxEtaOfModule(0); | |
680 | ||
681 | AliDebug(2,Form(" fShishKebabTrd1Modules has %i modules : max eta %5.4f \n", | |
682 | fShishKebabTrd1Modules->GetSize(),fEtaMaxOfTRD1)); | |
683 | // Feb 20,2006; | |
684 | // Jun 01, 2006 - ALICE numbering scheme | |
685 | // define grid for cells in eta(z) and x directions in local coordinates system of SM | |
686 | // Works just for 2x2 case only -- ?? start here | |
687 | // | |
688 | // | |
689 | // Define grid for cells in phi(y) direction in local coordinates system of SM | |
690 | // as for 2X2 as for 3X3 - Nov 8,2006 | |
691 | // | |
692 | AliDebug(2,Form(" Cells grid in phi directions : size %i\n", fCentersOfCellsPhiDir.GetSize())); | |
693 | Int_t ind=0; // this is phi index | |
694 | Int_t ieta=0, nModule=0, iphiTemp; | |
695 | Double_t xr=0., zr=0., theta=0., phi=0., eta=0., r=0., x=0.,y=0.; | |
696 | TVector3 vglob; | |
697 | Double_t ytCenterModule=0.0, ytCenterCell=0.0; | |
698 | ||
699 | fCentersOfCellsPhiDir.Set(fNPhi*fNPHIdiv); | |
700 | fPhiCentersOfCells.Set(fNPhi*fNPHIdiv); | |
701 | ||
702 | Double_t r0 = fIPDistance + fLongModuleSize/2.; | |
703 | for(Int_t it=0; it<fNPhi; it++) { // cycle on modules | |
704 | ytCenterModule = -fParSM[1] + fPhiModuleSize*(2*it+1)/2; // center of module | |
705 | for(Int_t ic=0; ic<fNPHIdiv; ic++) { // cycle on cells in module | |
706 | if(fNPHIdiv==2) { | |
707 | ytCenterCell = ytCenterModule + fPhiTileSize *(2*ic-1)/2.; | |
708 | } else if(fNPHIdiv==3){ | |
709 | ytCenterCell = ytCenterModule + fPhiTileSize *(ic-1); | |
710 | } else if(fNPHIdiv==1){ | |
711 | ytCenterCell = ytCenterModule; | |
712 | } | |
713 | fCentersOfCellsPhiDir.AddAt(ytCenterCell,ind); | |
714 | // Define grid on phi direction | |
715 | // Grid is not the same for different eta bin; | |
716 | // Effect is small but is still here | |
717 | phi = TMath::ATan2(ytCenterCell, r0); | |
718 | fPhiCentersOfCells.AddAt(phi, ind); | |
719 | ||
720 | AliDebug(2,Form(" ind %2.2i : y %8.3f ", ind, fCentersOfCellsPhiDir.At(ind))); | |
721 | ind++; | |
722 | } | |
723 | } | |
724 | ||
725 | fCentersOfCellsEtaDir.Set(fNZ *fNETAdiv); | |
726 | fCentersOfCellsXDir.Set(fNZ *fNETAdiv); | |
727 | fEtaCentersOfCells.Set(fNZ *fNETAdiv * fNPhi*fNPHIdiv); | |
728 | AliDebug(2,Form(" Cells grid in eta directions : size %i\n", fCentersOfCellsEtaDir.GetSize())); | |
729 | for(Int_t it=0; it<fNZ; it++) { | |
730 | AliEMCALShishKebabTrd1Module *trd1 = GetShishKebabModule(it); | |
731 | nModule = fNPhi*it; | |
732 | for(Int_t ic=0; ic<fNETAdiv; ic++) { | |
733 | if(fNPHIdiv==2) { | |
734 | trd1->GetCenterOfCellInLocalCoordinateofSM(ic, xr, zr); // case of 2X2 | |
735 | GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta); | |
736 | } if(fNPHIdiv==3) { | |
737 | trd1->GetCenterOfCellInLocalCoordinateofSM3X3(ic, xr, zr); // case of 3X3 | |
738 | GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta); | |
739 | } if(fNPHIdiv==1) { | |
740 | trd1->GetCenterOfCellInLocalCoordinateofSM1X1(xr, zr); // case of 1X1 | |
741 | GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta); | |
742 | } | |
743 | fCentersOfCellsXDir.AddAt(float(xr) - fParSM[0],ieta); | |
744 | fCentersOfCellsEtaDir.AddAt(float(zr) - fParSM[2],ieta); | |
745 | // Define grid on eta direction for each bin in phi | |
746 | for(int iphi=0; iphi<fCentersOfCellsPhiDir.GetSize(); iphi++) { | |
747 | x = xr + trd1->GetRadius(); | |
748 | y = fCentersOfCellsPhiDir[iphi]; | |
749 | r = TMath::Sqrt(x*x + y*y + zr*zr); | |
750 | theta = TMath::ACos(zr/r); | |
751 | eta = AliEMCALShishKebabTrd1Module::ThetaToEta(theta); | |
752 | // ind = ieta*fCentersOfCellsPhiDir.GetSize() + iphi; | |
753 | ind = iphi*fCentersOfCellsEtaDir.GetSize() + ieta; | |
754 | fEtaCentersOfCells.AddAt(eta, ind); | |
755 | } | |
756 | //printf(" ieta %i : xr + trd1->GetRadius() %f : zr %f : eta %f \n", ieta, xr + trd1->GetRadius(), zr, eta); | |
757 | } | |
758 | } | |
759 | for(Int_t i=0; i<fCentersOfCellsEtaDir.GetSize(); i++) { | |
760 | AliDebug(2,Form(" ind %2.2i : z %8.3f : x %8.3f", i+1, | |
761 | fCentersOfCellsEtaDir.At(i),fCentersOfCellsXDir.At(i))); | |
762 | } | |
763 | ||
764 | } | |
765 | ||
766 | ||
767 | //________________________________________________________________________________________________ | |
768 | AliEMCALShishKebabTrd1Module* AliEMCALGeoUtils::GetShishKebabModule(Int_t neta) const | |
769 | { | |
770 | //This method was too long to be | |
771 | //included in the header file - the | |
772 | //rule checker complained about it's | |
773 | //length, so we move it here. It returns the | |
774 | //shishkebabmodule at a given eta index point. | |
775 | ||
776 | static AliEMCALShishKebabTrd1Module* trd1=0; | |
777 | if(fShishKebabTrd1Modules && neta>=0 && neta<fShishKebabTrd1Modules->GetSize()) { | |
778 | trd1 = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(neta); | |
779 | } else trd1 = 0; | |
780 | return trd1; | |
781 | } | |
782 | ||
783 | //___________________________________________________________________ | |
784 | void AliEMCALGeoUtils::PrintGeometry() | |
785 | { | |
786 | //Print information from geometry | |
787 | fEMCGeometry->PrintGeometry(); | |
788 | ||
789 | printf(" fShishKebabTrd1Modules has %i modules : max eta %5.4f \n", | |
790 | fShishKebabTrd1Modules->GetSize(),fEtaMaxOfTRD1); | |
791 | ||
792 | printf("\n Cells grid in eta directions : size %i\n", fCentersOfCellsEtaDir.GetSize()); | |
793 | for(Int_t i=0; i<fCentersOfCellsEtaDir.GetSize(); i++) { | |
794 | printf(" ind %2.2i : z %8.3f : x %8.3f \n", i, | |
795 | fCentersOfCellsEtaDir.At(i),fCentersOfCellsXDir.At(i)); | |
796 | int ind=0; // Nov 21,2006 | |
797 | for(Int_t iphi=0; iphi<fCentersOfCellsPhiDir.GetSize(); iphi++) { | |
798 | ind = iphi*fCentersOfCellsEtaDir.GetSize() + i; | |
799 | printf("%6.4f ", fEtaCentersOfCells[ind]); | |
800 | if((iphi+1)%12 == 0) printf("\n"); | |
801 | } | |
802 | printf("\n"); | |
803 | ||
804 | } | |
805 | ||
806 | printf("\n Cells grid in phi directions : size %i\n", fCentersOfCellsPhiDir.GetSize()); | |
807 | for(Int_t i=0; i<fCentersOfCellsPhiDir.GetSize(); i++) { | |
808 | double phi=fPhiCentersOfCells.At(i); | |
809 | printf(" ind %2.2i : y %8.3f : phi %7.5f(%6.2f) \n", i, fCentersOfCellsPhiDir.At(i), | |
810 | phi, phi*TMath::RadToDeg()); | |
811 | } | |
812 | ||
813 | } | |
814 | ||
815 | //____________________________________________________________________________ | |
816 | Bool_t AliEMCALGeoUtils::Impact(const TParticle * particle) const | |
817 | { | |
818 | // Tells if a particle enters EMCAL | |
819 | Bool_t in=kFALSE; | |
820 | Int_t absID=0; | |
821 | TVector3 vtx(particle->Vx(),particle->Vy(),particle->Vz()); | |
822 | TVector3 vimpact(0,0,0); | |
823 | ImpactOnEmcal(vtx,particle->Theta(),particle->Phi(),absID,vimpact); | |
824 | if(absID!=0) | |
825 | in=kTRUE; | |
826 | return in; | |
827 | } | |
828 | //____________________________________________________________________________ | |
829 | void AliEMCALGeoUtils::ImpactOnEmcal(TVector3 vtx, Double_t theta, Double_t phi, | |
830 | Int_t & absId, TVector3 & vimpact) const | |
831 | { | |
832 | // calculates the impact coordinates on EMCAL (centre of a tower/not on EMCAL surface) | |
833 | // of a neutral particle | |
834 | // emitted in the vertex vtx[3] with direction theta and phi in the ALICE global coordinate system | |
835 | ||
836 | TVector3 p(TMath::Sin(theta)*TMath::Cos(phi),TMath::Sin(theta)*TMath::Sin(phi),TMath::Cos(theta)) ; | |
837 | ||
838 | vimpact.SetXYZ(0,0,0); | |
839 | absId=-1; | |
840 | if(phi==0 || theta==0) return; | |
841 | ||
842 | TVector3 direction; | |
843 | Double_t factor = (fIPDistance-vtx[1])/p[1]; | |
844 | direction = vtx + factor*p; | |
845 | ||
846 | if (!gGeoManager){ | |
847 | AliFatal("Geo manager not initialized\n"); | |
848 | } | |
849 | //from particle direction -> tower hitted | |
850 | GetAbsCellIdFromEtaPhi(direction.Eta(),direction.Phi(),absId); | |
851 | ||
852 | //tower absID hitted -> tower/module plane (evaluated at the center of the tower) | |
853 | Int_t nSupMod, nModule, nIphi, nIeta; | |
854 | Double_t loc[3],loc2[3],loc3[3]; | |
855 | Double_t glob[3]={},glob2[3]={},glob3[3]={}; | |
856 | ||
857 | if(!RelPosCellInSModule(absId,loc)) return; | |
858 | ||
859 | //loc is cell center of tower | |
860 | GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta); | |
861 | ||
862 | //look at 2 neighbours-s cell using nIphi={0,1} and nIeta={0,1} | |
863 | Int_t nIphi2,nIeta2,absId2,absId3; | |
864 | if(nIeta==0) nIeta2=1; | |
865 | else nIeta2=0; | |
866 | absId2=GetAbsCellId(nSupMod,nModule,nIphi,nIeta2); | |
867 | if(nIphi==0) nIphi2=1; | |
868 | else nIphi2=0; | |
869 | absId3=GetAbsCellId(nSupMod,nModule,nIphi2,nIeta); | |
870 | ||
871 | //2nd point on emcal cell plane | |
872 | if(!RelPosCellInSModule(absId2,loc2)) return; | |
873 | ||
874 | //3rd point on emcal cell plane | |
875 | if(!RelPosCellInSModule(absId3,loc3)) return; | |
876 | ||
877 | // TString volpath = "ALIC_1/XEN1_1/SMOD_"; | |
878 | // volpath += (nSupMod+1); | |
879 | // | |
880 | // if(fKey110DEG && nSupMod>=10) { | |
881 | // volpath = "ALIC_1/XEN1_1/SM10_"; | |
882 | // volpath += (nSupMod-10+1); | |
883 | // } | |
884 | // if(!gGeoManager->cd(volpath.Data())){ | |
885 | // AliFatal(Form("GeoManager cannot find path %s!",volpath.Data())) | |
886 | // return; | |
887 | // } | |
888 | // TGeoHMatrix* m = gGeoManager->GetCurrentMatrix(); | |
889 | const TGeoHMatrix* m = GetMatrixForSuperModule(nSupMod); | |
890 | if(m) { | |
891 | m->LocalToMaster(loc, glob); | |
892 | m->LocalToMaster(loc2, glob2); | |
893 | m->LocalToMaster(loc3, glob3); | |
894 | } else { | |
895 | AliFatal("Geo matrixes are not loaded \n") ; | |
896 | } | |
897 | ||
898 | //Equation of Plane from glob,glob2,glob3 (Ax+By+Cz+D=0) | |
899 | Double_t a = glob[1]*(glob2[2]-glob3[2]) + glob2[1]*(glob3[2]-glob[2]) + glob3[1]*(glob[2]-glob2[2]); | |
900 | Double_t b = glob[2]*(glob2[0]-glob3[0]) + glob2[2]*(glob3[0]-glob[0]) + glob3[2]*(glob[0]-glob2[0]); | |
901 | Double_t c = glob[0]*(glob2[1]-glob3[1]) + glob2[0]*(glob3[1]-glob[1]) + glob3[0]*(glob[1]-glob2[1]); | |
902 | Double_t d = glob[0]*(glob2[1]*glob3[2]-glob3[1]*glob2[2]) + glob2[0]*(glob3[1]*glob[2]-glob[1]*glob3[2]) + glob3[0]*(glob[1]*glob2[2]-glob2[1]*glob[2]); | |
903 | d=-d; | |
904 | ||
905 | //shift equation of plane from tower/module center to surface along vector (A,B,C) normal to tower/module plane | |
906 | Double_t dist = fLongModuleSize/2.; | |
907 | Double_t norm = TMath::Sqrt(a*a+b*b+c*c); | |
908 | Double_t glob4[3]={}; | |
909 | TVector3 dir(a,b,c); | |
910 | TVector3 point(glob[0],glob[1],glob[2]); | |
911 | if(point.Dot(dir)<0) dist*=-1; | |
912 | glob4[0]=glob[0]-dist*a/norm; | |
913 | glob4[1]=glob[1]-dist*b/norm; | |
914 | glob4[2]=glob[2]-dist*c/norm; | |
915 | d = glob4[0]*a + glob4[1]*b + glob4[2]*c ; | |
916 | d = -d; | |
917 | ||
918 | //Line determination (2 points for equation of line : vtx and direction) | |
919 | //impact between line (particle) and plane (module/tower plane) | |
920 | Double_t den = a*(vtx(0)-direction(0)) + b*(vtx(1)-direction(1)) + c*(vtx(2)-direction(2)); | |
921 | if(den==0){ | |
922 | printf("ImpactOnEmcal() No solution :\n"); | |
923 | return; | |
924 | } | |
925 | ||
926 | Double_t length = a*vtx(0)+b*vtx(1)+c*vtx(2)+d; | |
927 | length /=den; | |
928 | ||
929 | vimpact.SetXYZ(vtx(0)+length*(direction(0)-vtx(0)),vtx(1)+length*(direction(1)-vtx(1)),vtx(2)+length*(direction(2)-vtx(2))); | |
930 | ||
931 | //shift vimpact from tower/module surface to center along vector (A,B,C) normal to tower/module plane | |
932 | vimpact.SetXYZ(vimpact(0)+dist*a/norm,vimpact(1)+dist*b/norm,vimpact(2)+dist*c/norm); | |
933 | ||
934 | return; | |
935 | } | |
936 | ||
937 | //_____________________________________________________________________________ | |
938 | Bool_t AliEMCALGeoUtils::IsInEMCAL(Double_t x, Double_t y, Double_t z) const { | |
939 | // Checks whether point is inside the EMCal volume, used in AliEMCALv*.cxx | |
940 | // | |
941 | // Code uses cylindrical approximation made of inner radius (for speed) | |
942 | // | |
943 | // Points behind EMCAl, i.e. R > outer radius, but eta, phi in acceptance | |
944 | // are considered to inside | |
945 | ||
946 | Double_t r=sqrt(x*x+y*y); | |
947 | ||
948 | if ( r > fEnvelop[0] ) { | |
949 | Double_t theta; | |
950 | theta = TMath::ATan2(r,z); | |
951 | Double_t eta; | |
952 | if(theta == 0) | |
953 | eta = 9999; | |
954 | else | |
955 | eta = -TMath::Log(TMath::Tan(theta/2.)); | |
956 | if (eta < fArm1EtaMin || eta > fArm1EtaMax) | |
957 | return 0; | |
958 | ||
959 | Double_t phi = TMath::ATan2(y,x) * 180./TMath::Pi(); | |
960 | if (phi < 0) phi += 360; // phi should go from 0 to 360 in this case | |
961 | if (phi > fArm1PhiMin && phi < fArm1PhiMax) | |
962 | return 1; | |
963 | } | |
964 | return 0; | |
965 | } | |
966 | ||
967 | //________________________________________________________________________________________________ | |
968 | Int_t AliEMCALGeoUtils::GetAbsTRUNumberFromNumberInSm(const Int_t row, const Int_t col, const Int_t sm) const | |
969 | { // Nov 6, 2007 | |
970 | // Get TRU absolute number from column, row and Super Module number | |
971 | Int_t itru = row + col*fEMCGeometry->GetNModulesInTRUPhi() + sm*fEMCGeometry->GetNTRU(); | |
972 | // printf(" GetAbsTRUNumberFromNumberInSm : row %2i col %2i sm %2i -> itru %2i\n", row, col, sm, itru); | |
973 | return itru; | |
974 | } | |
975 | ||
976 | ||
977 | //____________________________________________________________________________ | |
978 | const TGeoHMatrix * AliEMCALGeoUtils::GetMatrixForSuperModule(Int_t smod) const { | |
979 | //Provides shift-rotation matrix for EMCAL | |
980 | ||
981 | if(smod < 0 || smod > fEMCGeometry->GetNumberOfSuperModules()) | |
982 | AliFatal(Form("Wrong supermodule index -> %d",smod)); | |
983 | ||
984 | //If GeoManager exists, take matrixes from it | |
985 | ||
986 | // | |
987 | // if(fKey110DEG && ind>=10) { | |
988 | // } | |
989 | // | |
990 | // if(!gGeoManager->cd(volpath.Data())) | |
991 | // AliFatal(Form("AliEMCALGeometry::GeoManager cannot find path %s!",volpath.Data())); | |
992 | // | |
993 | // TGeoHMatrix* m = gGeoManager->GetCurrentMatrix(); | |
994 | ||
995 | if(gGeoManager){ | |
996 | char path[255] ; | |
997 | sprintf(path,"/ALIC_1/XEN1_1/SMOD_%d",smod+1) ; | |
998 | //TString volpath = "ALIC_1/XEN1_1/SMOD_"; | |
999 | //volpath += smod+1; | |
1000 | ||
1001 | if(fKey110DEG && smod >= 10){ | |
1002 | sprintf(path,"/ALIC_1/XEN1_1/SM10_%d",smod-10+1) ; | |
1003 | //volpath = "ALIC_1/XEN1_1/SM10_"; | |
1004 | //volpath += smod-10+1; | |
1005 | } | |
1006 | if (!gGeoManager->cd(path)){ | |
1007 | AliFatal(Form("Geo manager can not find path %s!\n",path)); | |
1008 | } | |
1009 | return gGeoManager->GetCurrentMatrix(); | |
1010 | } | |
1011 | ||
1012 | if(fkSModuleMatrix[smod]){ | |
1013 | return fkSModuleMatrix[smod] ; | |
1014 | } | |
1015 | else{ | |
1016 | printf("Can not find EMCAL misalignment matrixes\n") ; | |
1017 | printf("Either import TGeoManager from geometry.root or \n"); | |
1018 | printf("read stored matrixes from AliESD Header: \n") ; | |
1019 | printf("AliEMCALGeoUtils::SetMisalMatrixes(header->GetEMCALMisalMatrix()) \n") ; | |
1020 | abort() ; | |
1021 | } | |
1022 | return 0 ; | |
1023 | } | |
1024 | ||
1025 | //______________________________________________________________________ | |
1026 | void AliEMCALGeoUtils::GetModulePhiEtaIndexInSModuleFromTRUIndex(Int_t itru, Int_t iphitru, Int_t ietatru, Int_t &iphiSM, Int_t &ietaSM) const | |
1027 | { | |
1028 | ||
1029 | // This method transforms the (eta,phi) index of module in a | |
1030 | // TRU matrix into Super Module (eta,phi) index. | |
1031 | ||
1032 | // Calculate in which row and column where the TRU are | |
1033 | // ordered in the SM | |
1034 | ||
1035 | Int_t col = itru/fEMCGeometry->GetNTRUPhi() ; // indexes of TRU in SM | |
1036 | Int_t row = itru - col*fEMCGeometry->GetNTRUPhi(); | |
1037 | ||
1038 | iphiSM = fEMCGeometry->GetNModulesInTRUPhi()*row + iphitru ; | |
1039 | ietaSM = fEMCGeometry->GetNModulesInTRUEta()*col + ietatru ; | |
1040 | //printf(" GetModulePhiEtaIndexInSModuleFromTRUIndex : itru %2i iphitru %2i ietatru %2i iphiSM %2i ietaSM %2i \n", | |
1041 | // itru, iphitru, ietatru, iphiSM, ietaSM); | |
1042 | } |