2D Centrality files
[u/mrichter/AliRoot.git] / JETAN / AliJetDummyGeo.cxx
CommitLineData
5ad5f558 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 **************************************************************************/
ee7de0dd 15
16//
17// Temporarily added to define part of the EMCal geometry
18// necessary for the jet finder
3e147bc8 19//
20// M. Estienne
6b22f7f4 21// Magali.Estienne@cern.ch
ee7de0dd 22//
23
3e147bc8 24#include <Riostream.h>
ee7de0dd 25#include <assert.h>
3e147bc8 26#include <TList.h>
ee7de0dd 27
28// --- Root header files ---
29#include <TVector3.h>
30#include <TGeoManager.h>
31#include <TGeoMatrix.h>
32#include <TGeoNode.h>
33
34// --- AliRoot header files ---
3e147bc8 35#include "AliLog.h"
5ad5f558 36#include "AliJetDummyGeo.h"
3e147bc8 37#include "AliJetDummyShishKebabTrd1Module.h"
5ad5f558 38
39ClassImp(AliJetDummyGeo)
ee7de0dd 40
41AliJetDummyGeo::AliJetDummyGeo():
3e147bc8 42 fArm1EtaMin(-0.7),
43 fArm1EtaMax(+0.7),
44 fArm1PhiMin(80.0),
45 fArm1PhiMax(200.0),
46 fNumberOfSuperModules(12),
47 fSteelFrontThick(0.0),
48 fLateralSteelStrip(0.01),
49 fIPDistance(428.0),
50 fPhiGapForSM(2.),
51 fNPhi(12),
52 fNZ(24),
53 fPhiModuleSize(12.26 - fPhiGapForSM / Float_t(fNPhi)),
54 fEtaModuleSize(fPhiModuleSize),
55 fNPHIdiv(2),
56 fNETAdiv(2),
57 fPhiTileSize(fPhiModuleSize/Double_t(fNPHIdiv) - fLateralSteelStrip),
58 fEtaTileSize(fEtaModuleSize/Double_t(fNETAdiv) - fLateralSteelStrip),
59 fNECLayers(77),
60 fECScintThick(0.16),
61 fECPbRadThickness(0.16),
62 fSampling(12.327),
63 fTrd1Angle(1.5),
64 fNCellsInModule(fNPHIdiv*fNETAdiv),
65 fNCellsInSupMod(fNCellsInModule*fNPhi*fNZ),
66 fNCells(fNCellsInSupMod*fNumberOfSuperModules-fNCellsInSupMod),
67 fLongModuleSize(fNECLayers*(fECScintThick + fECPbRadThickness)),
68 f2Trd1Dx2(fEtaModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd1Angle*TMath::DegToRad()/2.)),
69 fShellThickness(TMath::Sqrt(fLongModuleSize*fLongModuleSize + f2Trd1Dx2*f2Trd1Dx2)+fSteelFrontThick),
70 fZLength(2.*ZFromEtaR(fIPDistance+fShellThickness,fArm1EtaMax)),
71 fEtaMaxOfTRD1(0.),
72 fPhiBoundariesOfSM(0),
73 fPhiCentersOfSM(0),
74 fCentersOfCellsEtaDir(0),
75 fCentersOfCellsXDir(0),
76 fCentersOfCellsPhiDir(0),
77 fEtaCentersOfCells(0),
78 fPhiCentersOfCells(0),
79 fShishKebabTrd1Modules(0),
80 fDebug(0)
ee7de0dd 81{
82 // Constructor
3e147bc8 83
ee7de0dd 84 // Local coordinates
85 fParSM[0] = GetShellThickness()/2.;
86 fParSM[1] = GetPhiModuleSize() * GetNPhi()/2.;
87 fParSM[2] = 350./2.;
88
ee7de0dd 89 fEnvelop[0] = fIPDistance; // mother volume inner radius
90 fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r.
91 fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume.
92
93 // SM phi boundaries - (0,1),(2,3) .. (10,11) - has the same boundaries; Nov 7, 2006
94 fPhiBoundariesOfSM.Set(fNumberOfSuperModules);
95 fPhiCentersOfSM.Set(fNumberOfSuperModules/2);
96 fPhiBoundariesOfSM[0] = TMath::PiOver2() - TMath::ATan2(fParSM[1] , fIPDistance); // 1th and 2th modules)
97 fPhiBoundariesOfSM[1] = TMath::PiOver2() + TMath::ATan2(fParSM[1] , fIPDistance);
98 fPhiCentersOfSM[0] = TMath::PiOver2();
3e147bc8 99 for(Int_t i=1; i<=4; i++) { // from 2th ro 9th
ee7de0dd 100 fPhiBoundariesOfSM[2*i] = fPhiBoundariesOfSM[0] + 20.*TMath::DegToRad()*i;
101 fPhiBoundariesOfSM[2*i+1] = fPhiBoundariesOfSM[1] + 20.*TMath::DegToRad()*i;
102 fPhiCentersOfSM[i] = fPhiCentersOfSM[0] + 20.*TMath::DegToRad()*i;
103 }
104 fPhiBoundariesOfSM[11] = 190.*TMath::DegToRad();
105 fPhiBoundariesOfSM[10] = fPhiBoundariesOfSM[11] - TMath::ATan2((fParSM[1]) , fIPDistance);
106 fPhiCentersOfSM[5] = (fPhiBoundariesOfSM[10]+fPhiBoundariesOfSM[11])/2.;
107
3e147bc8 108 Int_t nphism = GetNumberOfSuperModules()/2;
109 Double_t dphi = (GetArm1PhiMax() - GetArm1PhiMin())/nphism;
110 Double_t rpos = (GetEnvelop(0) + GetEnvelop(1))/2.;
111 Double_t phi, phiRad, xpos, ypos, zpos;
112 for(Int_t i=0; i<nphism; i++){
ee7de0dd 113 phi = GetArm1PhiMin() + dphi*(2*i+1)/2.; // phi= 90, 110, 130, 150, 170, 190
114 phiRad = phi*TMath::Pi()/180.;
115 xpos = rpos * TMath::Cos(phiRad);
116 ypos = rpos * TMath::Sin(phiRad);
117 zpos = fParSM[2];
118 if(i==5) {
119 xpos += (fParSM[1]/2. * TMath::Sin(phiRad));
120 ypos -= (fParSM[1]/2. * TMath::Cos(phiRad));
121 }
122 // pozitive z
3e147bc8 123 Int_t ind = 2*i;
ee7de0dd 124 TGeoRotation *geoRot0 = new TGeoRotation("geoRot0", 90.0, phi, 90.0, 90.0+phi, 0.0, 0.0);
125 fMatrixOfSM[ind] = new TGeoCombiTrans(Form("EmcalSM%2.2i",ind),
126 xpos,ypos, zpos, geoRot0);
127 // negaive z
128 ind++;
3e147bc8 129 Double_t phiy = 90. + phi + 180.;
ee7de0dd 130 if(phiy>=360.) phiy -= 360.;
131 TGeoRotation *geoRot1 = new TGeoRotation("geoRot1", 90.0, phi, 90.0, phiy, 180.0, 0.0);
132 fMatrixOfSM[ind] = new TGeoCombiTrans(Form("EmcalSM%2.2i",ind),
133 xpos,ypos,-zpos, geoRot1);
134 } // for
135
3e147bc8 136 CreateListOfTrd1Modules();
137
138 if(fDebug > 0){
139 for(Int_t i=0; i<6; i++){
140 cout << "fMatrixOfSM[" << i << "]: " << fMatrixOfSM[i] << endl;
141 }
142 cout << "fArm1EtaMin: " << fArm1EtaMin << endl;
143 cout << "fArm1EtaMax: " << fArm1EtaMax << endl;
144 cout << "fArm1PhiMin: " << fArm1PhiMin << endl;
145 cout << "fArm1PhiMax: " << fArm1PhiMax << endl;
146 cout << "fNumberOfSuperModules: " << fNumberOfSuperModules << endl;
147 cout << "fSteelFrontThick: " << fSteelFrontThick << endl;
148 cout << "fIPDistance: " << fIPDistance << endl;
149 cout << "fZLength: " << fZLength << endl;
150 cout << "fPhiGapForSM: " << fPhiGapForSM << endl;
151 cout << "fNPhi: " << fNPhi << endl;
152 cout << "fNZ: " << fNZ << endl;
153 cout << "fPhiModuleSize: " << fPhiModuleSize << endl;
154 cout << "fEtaModuleSize: " << fEtaModuleSize << endl;
155 cout << "fNPHIdiv: " << fNPHIdiv << endl;
156 cout << "fNETAdiv: " << fNETAdiv << endl;
157 cout << "fNECLayers: " << fNECLayers << endl;
158 cout << "fECScintThick: " << fECScintThick << endl;
159 cout << "fECPbRadThickness: " << fECPbRadThickness << endl;
160 cout << "fSampling: " << fSampling << endl;
161 cout << "fTrd1Angle: " << fTrd1Angle << endl;
162 cout << "fNCellsInModule: " << fNCellsInModule << endl;
163 cout << "fNCellsInSupMod: " << fNCellsInSupMod << endl;
164 cout << "fNCells: " << fNCells << endl;
165 cout << "fLongModuleSize: " << fLongModuleSize << endl;
166 cout << "f2Trd1Dx2: " << f2Trd1Dx2 << endl;
167 cout << "fShellThickness: " << fShellThickness << endl;
168 cout << "fEtaMaxOfTRD1: " << fEtaMaxOfTRD1 << endl;
169 }
ee7de0dd 170}
171
172AliJetDummyGeo::AliJetDummyGeo(const AliJetDummyGeo& geom):
8162bd23 173 TObject(geom),
3e147bc8 174 fArm1EtaMin(geom.fArm1EtaMin),
175 fArm1EtaMax(geom.fArm1EtaMax),
176 fArm1PhiMin(geom.fArm1PhiMin),
177 fArm1PhiMax(geom.fArm1PhiMax),
178 fNumberOfSuperModules(geom.fNumberOfSuperModules),
179 fSteelFrontThick(geom.fSteelFrontThick),
180 fLateralSteelStrip(geom.fLateralSteelStrip),
181 fIPDistance(geom.fIPDistance),
182 fPhiGapForSM(geom.fPhiGapForSM),
183 fNPhi(geom.fNPhi),
184 fNZ(geom.fNZ),
185 fPhiModuleSize(geom.fPhiModuleSize),
186 fEtaModuleSize(geom.fEtaModuleSize),
187 fNPHIdiv(geom.fNPHIdiv),
188 fNETAdiv(geom.fNETAdiv),
189 fPhiTileSize(geom.fPhiTileSize),
190 fEtaTileSize(geom.fEtaTileSize),
191 fNECLayers(geom.fNECLayers),
192 fECScintThick(geom.fECScintThick),
193 fECPbRadThickness(geom.fECPbRadThickness),
194 fSampling(geom.fSampling),
195 fTrd1Angle(geom.fTrd1Angle),
196 fNCellsInModule(geom.fNCellsInModule),
197 fNCellsInSupMod(geom.fNCellsInSupMod),
198 fNCells(geom.fNCells),
199 fLongModuleSize(geom.fLongModuleSize),
200 f2Trd1Dx2(geom.f2Trd1Dx2),
201 fShellThickness(geom.fShellThickness),
202 fZLength(geom.fZLength),
203 fEtaMaxOfTRD1(geom.fEtaMaxOfTRD1),
204 fPhiBoundariesOfSM(geom.fPhiBoundariesOfSM),
205 fPhiCentersOfSM(geom.fPhiCentersOfSM),
206 fCentersOfCellsEtaDir(geom.fCentersOfCellsEtaDir),
207 fCentersOfCellsXDir(geom.fCentersOfCellsXDir),
208 fCentersOfCellsPhiDir(geom.fCentersOfCellsPhiDir),
209 fEtaCentersOfCells(geom.fEtaCentersOfCells),
210 fPhiCentersOfCells(geom.fPhiCentersOfCells),
211 fShishKebabTrd1Modules(geom.fShishKebabTrd1Modules),
212 fDebug(geom.fDebug)
ee7de0dd 213{
214 // Constructor
215 // Local coordinates
216 fParSM[0] = GetShellThickness()/2.;
217 fParSM[1] = GetPhiModuleSize() * GetNPhi()/2.;
218 fParSM[2] = 350./2.;
219
3e147bc8 220 fEnvelop[0] = fIPDistance; // mother volume inner radius
221 fEnvelop[1] = fIPDistance + fShellThickness; // mother volume outer r.
222 fEnvelop[2] = 1.00001*fZLength; // add some padding for mother volume.
223
ee7de0dd 224 // SM phi boundaries - (0,1),(2,3) .. (10,11) - has the same boundaries; Nov 7, 2006
225 fPhiBoundariesOfSM.Set(fNumberOfSuperModules);
226 fPhiCentersOfSM.Set(fNumberOfSuperModules/2);
227 fPhiBoundariesOfSM[0] = TMath::PiOver2() - TMath::ATan2(fParSM[1] , fIPDistance); // 1th and 2th modules)
228 fPhiBoundariesOfSM[1] = TMath::PiOver2() + TMath::ATan2(fParSM[1] , fIPDistance);
229 fPhiCentersOfSM[0] = TMath::PiOver2();
3e147bc8 230 for(Int_t i=1; i<=4; i++) { // from 2th ro 9th
ee7de0dd 231 fPhiBoundariesOfSM[2*i] = fPhiBoundariesOfSM[0] + 20.*TMath::DegToRad()*i;
232 fPhiBoundariesOfSM[2*i+1] = fPhiBoundariesOfSM[1] + 20.*TMath::DegToRad()*i;
233 fPhiCentersOfSM[i] = fPhiCentersOfSM[0] + 20.*TMath::DegToRad()*i;
234 }
235 fPhiBoundariesOfSM[11] = 190.*TMath::DegToRad();
236 fPhiBoundariesOfSM[10] = fPhiBoundariesOfSM[11] - TMath::ATan2((fParSM[1]) , fIPDistance);
237 fPhiCentersOfSM[5] = (fPhiBoundariesOfSM[10]+fPhiBoundariesOfSM[11])/2.;
238
3e147bc8 239 Int_t nphism = GetNumberOfSuperModules()/2;
240 Double_t dphi = (GetArm1PhiMax() - GetArm1PhiMin())/nphism;
241 Double_t rpos = (GetEnvelop(0) + GetEnvelop(1))/2.;
242 Double_t phi, phiRad, xpos, ypos, zpos;
243 for(Int_t i=0; i<nphism; i++){
ee7de0dd 244 phi = GetArm1PhiMin() + dphi*(2*i+1)/2.; // phi= 90, 110, 130, 150, 170, 190
245 phiRad = phi*TMath::Pi()/180.;
246 xpos = rpos * TMath::Cos(phiRad);
247 ypos = rpos * TMath::Sin(phiRad);
248 zpos = fParSM[2];
249 if(i==5) {
250 xpos += (fParSM[1]/2. * TMath::Sin(phiRad));
251 ypos -= (fParSM[1]/2. * TMath::Cos(phiRad));
252 }
253 // pozitive z
3e147bc8 254 Int_t ind = 2*i;
ee7de0dd 255 TGeoRotation *geoRot0 = new TGeoRotation("geoRot0", 90.0, phi, 90.0, 90.0+phi, 0.0, 0.0);
256 fMatrixOfSM[ind] = new TGeoCombiTrans(Form("EmcalSM%2.2i",ind),
257 xpos,ypos, zpos, geoRot0);
258 // negaive z
259 ind++;
3e147bc8 260 Double_t phiy = 90. + phi + 180.;
ee7de0dd 261 if(phiy>=360.) phiy -= 360.;
262 TGeoRotation *geoRot1 = new TGeoRotation("geoRot1", 90.0, phi, 90.0, phiy, 180.0, 0.0);
263 fMatrixOfSM[ind] = new TGeoCombiTrans(Form("EmcalSM%2.2i",ind),
264 xpos,ypos,-zpos, geoRot1);
265
266 delete geoRot0;
267 delete geoRot1;
268
269 } // for
270
3e147bc8 271 CreateListOfTrd1Modules();
272
ee7de0dd 273}
274
3e147bc8 275//------------------------------------------------------------------------------------
ee7de0dd 276AliJetDummyGeo::~AliJetDummyGeo()
277{
278 // Destructor
6b22f7f4 279 // delete [] fMatrixOfSM;
ee7de0dd 280}
281
282//------------------------------------------------------------------------------------
283void AliJetDummyGeo::EtaPhiFromIndex(Int_t absId, Float_t& eta, Float_t& phi)
284{
285 // Nov 16, 2006- float to double
286 // version for TRD1 only
287 static TVector3 vglob;
288 GetGlobal(absId, vglob);
289 eta = vglob.Eta();
290 phi = vglob.Phi();
291
292}
293
294//------------------------------------------------------------------------------------
3e147bc8 295void AliJetDummyGeo::GetGlobal(const Double_t *loc, Double_t *glob, Int_t ind) const
ee7de0dd 296{
297 // Figure out the global numbering of a given supermodule from the
298 // local numbering
299 // Alice numbering - Jun 03,2006
300 // if(fMatrixOfSM[0] == 0) GetTransformationForSM();
301
302 if(ind>=0 && ind < GetNumberOfSuperModules()) {
303 fMatrixOfSM[ind]->LocalToMaster(loc, glob);
304 }
305}
306
307//------------------------------------------------------------------------------------
3e147bc8 308void AliJetDummyGeo::GetGlobal(Int_t absId , Double_t glob[3]) const
ee7de0dd 309{
310 // Alice numbering scheme - Jun 03, 2006
311 static Int_t nSupMod, nModule, nIphi, nIeta;
3e147bc8 312 static Double_t loc[3];
ee7de0dd 313
314 glob[0]=glob[1]=glob[2]=0.0; // bad case
315 if(RelPosCellInSModule(absId, loc)) {
316 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
317 fMatrixOfSM[nSupMod]->LocalToMaster(loc, glob);
318 }
319}
320
321//------------------------------------------------------------------------------------
322void AliJetDummyGeo::GetGlobal(Int_t absId , TVector3 &vglob) const
323{
324 // Alice numbering scheme - Jun 03, 2006
325 static Double_t glob[3];
326
327 GetGlobal(absId, glob);
328 vglob.SetXYZ(glob[0], glob[1], glob[2]);
329
330}
331
332//------------------------------------------------------------------------------------
333Bool_t AliJetDummyGeo::RelPosCellInSModule(Int_t absId, Double_t loc[3]) const
334{
335 // Alice numbering scheme - Jun 03, 2006
336 loc[0] = loc[1] = loc[2]=0.0;
337 if(RelPosCellInSModule(absId, loc[0],loc[1],loc[2])) {
338 return kTRUE;
339 }
340 return kFALSE;
341}
342
343//------------------------------------------------------------------------------------
344Bool_t AliJetDummyGeo::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr) const
345{
346 // Look to see what the relative position inside a given cell is
347 // for a recpoint.
348 // Alice numbering scheme - Jun 08, 2006
349 // In:
350 // absId - cell is as in Geant, 0<= absId < fNCells;
351 // OUT:
352 // xr,yr,zr - x,y,z coordinates of cell with absId inside SM
353
354 // Shift index taking into account the difference between standard SM
355 // and SM of half size in phi direction
3e147bc8 356 const Int_t phiIndexShift = fCentersOfCellsPhiDir.GetSize()/4; // Nov 22, 2006; was 6 for cas 2X2
ee7de0dd 357 static Int_t nSupMod, nModule, nIphi, nIeta, iphi, ieta;
358 if(!CheckAbsCellId(absId)) return kFALSE;
359
360 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
361 GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta);
362
363 xr = fCentersOfCellsXDir.At(ieta);
364 zr = fCentersOfCellsEtaDir.At(ieta);
365
366 if(nSupMod<10) {
367 yr = fCentersOfCellsPhiDir.At(iphi);
368 } else {
3e147bc8 369 yr = fCentersOfCellsPhiDir.At(iphi + phiIndexShift);
ee7de0dd 370 }
371
372 return kTRUE;
373}
374
375//------------------------------------------------------------------------------------
376Bool_t AliJetDummyGeo::CheckAbsCellId(Int_t absId) const
377{
378 // May 31, 2006; only trd1 now
379 if(absId<0 || absId >= fNCells) return kFALSE;
380 else return kTRUE;
381}
382
383//------------------------------------------------------------------------------------
384Bool_t AliJetDummyGeo::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nModule,Int_t &nIphi,Int_t &nIeta) const
385{
386 // 21-sep-04; 19-oct-05;
387 // May 31, 2006; ALICE numbering scheme:
388 //
389 // In:
390 // absId - cell is as in Geant, 0<= absId < fNCells;
391 // Out:
392 // nSupMod - super module(SM) number, 0<= nSupMod < fNumberOfSuperModules;
393 // nModule - module number in SM, 0<= nModule < fNCellsInSupMod/fNCellsInSupMod or(/2) for tow last SM (10th and 11th);
394 // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv;
395 // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv;
396 //
397 static Int_t tmp=0, sm10=0;
398 if(!CheckAbsCellId(absId)) return kFALSE;
399
400 sm10 = fNCellsInSupMod*10;
401 if(absId >= sm10) { // 110 degree case; last two supermodules
402 nSupMod = (absId-sm10) / (fNCellsInSupMod/2) + 10;
403 tmp = (absId-sm10) % (fNCellsInSupMod/2);
404 } else {
405 nSupMod = absId / fNCellsInSupMod;
406 tmp = absId % fNCellsInSupMod;
407 }
408
409 nModule = tmp / fNCellsInModule;
410 tmp = tmp % fNCellsInModule;
411 nIphi = tmp / fNPHIdiv;
412 nIeta = tmp % fNPHIdiv;
413
414 return kTRUE;
415}
416
417//------------------------------------------------------------------------------------
3e147bc8 418void AliJetDummyGeo::GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta, Int_t &iphi, Int_t &ieta) const
ee7de0dd 419{
420 //
421 // Added nSupMod; Nov 25, 05
422 // Alice numbering scheme - Jun 01,2006
423 // IN:
424 // nSupMod - super module(SM) number, 0<= nSupMod < fNumberOfSuperModules;
425 // nModule - module number in SM, 0<= nModule < fNCellsInSupMod/fNCellsInSupMod or(/2) for tow last SM (10th and 11th);
426 // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv;
427 // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv;
428 //
429 // OUT:
430 // ieta, iphi - indexes of cell(tower) in two dimensional grid of SM
431 // ieta - have to change from 0 to (fNZ*fNETAdiv-1)
432 // iphi - have to change from 0 to (fNPhi*fNPHIdiv-1 or fNPhi*fNPHIdiv/2-1)
433 //
434 static Int_t iphim, ietam;
435
436 GetModulePhiEtaIndexInSModule(nSupMod,nModule, iphim, ietam);
437 // ieta = ietam*fNETAdiv + (1-nIeta); // x(module) = -z(SM)
438 ieta = ietam*fNETAdiv + (fNETAdiv - 1 - nIeta); // x(module) = -z(SM)
439 iphi = iphim*fNPHIdiv + nIphi; // y(module) = y(SM)
440
441}
442
443
444//------------------------------------------------------------------------------------
3e147bc8 445void AliJetDummyGeo::GetModulePhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t &iphim, Int_t &ietam) const
ee7de0dd 446{
447 // added nSupMod; - 19-oct-05 !
448 // Alice numbering scheme - Jun 01,2006
449 // ietam, iphi - indexes of module in two dimensional grid of SM
450 // ietam - have to change from 0 to fNZ-1
451 // iphim - have to change from 0 to nphi-1 (fNPhi-1 or fNPhi/2-1)
452 static Int_t nphi;
453
454 if(nSupMod>=10) nphi = fNPhi/2;
455 else nphi = fNPhi;
456
457 ietam = nModule/nphi;
458 iphim = nModule%nphi;
459}
460
461//------------------------------------------------------------------------------------
462Bool_t AliJetDummyGeo::GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi, Int_t &absId) const
463{
464 // Nov 17,2006
465 // stay here - phi problem as usual
466 static Int_t nSupMod, i, ieta, iphi, etaShift, nphi;
467 static Double_t absEta=0.0, d=0.0, dmin=0.0, phiLoc;
468 absId = nSupMod = - 1;
469 if(SuperModuleNumberFromEtaPhi(eta, phi, nSupMod)) {
470 // phi index first
471 phi = TVector2::Phi_0_2pi(phi);
472 phiLoc = phi - fPhiCentersOfSM[nSupMod/2];
473 nphi = fPhiCentersOfCells.GetSize();
474 if(nSupMod>=10) {
475 phiLoc = phi - 190.*TMath::DegToRad();
476 nphi /= 2;
477 }
478
479 dmin = TMath::Abs(fPhiCentersOfCells[0]-phiLoc);
480 iphi = 0;
481 for(i=1; i<nphi; i++) {
482 d = TMath::Abs(fPhiCentersOfCells[i] - phiLoc);
483 if(d < dmin) {
484 dmin = d;
485 iphi = i;
486 }
487 }
488 // odd SM are turned with respect of even SM - reverse indexes
489
490 // eta index
491 absEta = TMath::Abs(eta);
492 etaShift = iphi*fCentersOfCellsEtaDir.GetSize();
493 dmin = TMath::Abs(fEtaCentersOfCells[etaShift]-absEta);
494 ieta = 0;
495 for(i=1; i<fCentersOfCellsEtaDir.GetSize(); i++) {
496 d = TMath::Abs(fEtaCentersOfCells[i+etaShift] - absEta);
497 if(d < dmin) {
498 dmin = d;
499 ieta = i;
500 }
501 }
502
503 if(eta<0) iphi = (nphi-1) - iphi;
504 absId = GetAbsCellIdFromCellIndexes(nSupMod, iphi, ieta);
505
506 return kTRUE;
507 }
508 return kFALSE;
509}
510
511//------------------------------------------------------------------------------------
512Bool_t AliJetDummyGeo::SuperModuleNumberFromEtaPhi(Double_t eta, Double_t phi, Int_t &nSupMod) const
513{
514 // Return false if phi belongs a phi cracks between SM
515
516 static Int_t i;
517
518 if(TMath::Abs(eta) > fEtaMaxOfTRD1) return kFALSE;
519
520 phi = TVector2::Phi_0_2pi(phi); // move phi to (0,2pi) boundaries
521 for(i=0; i<6; i++) {
522 if(phi>=fPhiBoundariesOfSM[2*i] && phi<=fPhiBoundariesOfSM[2*i+1]) {
523 nSupMod = 2*i;
524 if(eta < 0.0) nSupMod++;
525 return kTRUE;
526 }
527 }
528 return kFALSE;
529}
530
531//------------------------------------------------------------------------------------
532Int_t AliJetDummyGeo::GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, Int_t ieta) const
533{
534 // Transition from super module number(nSupMod) and cell indexes (ieta,iphi) to absId
535 static Int_t ietam, iphim, nModule;
536 static Int_t nIeta, nIphi; // cell indexes in module
537
538 GetModuleIndexesFromCellIndexesInSModule(nSupMod, iphi, ieta, ietam, iphim, nModule);
539
540 nIeta = ieta%fNETAdiv;
541 nIeta = fNETAdiv - 1 - nIeta;
542 nIphi = iphi%fNPHIdiv;
543
544 return GetAbsCellId(nSupMod, nModule, nIphi, nIeta);
545}
546
547//------------------------------------------------------------------------------------
548void AliJetDummyGeo::GetModuleIndexesFromCellIndexesInSModule(Int_t nSupMod, Int_t iphi, Int_t ieta,
549 Int_t &iphim, Int_t &ietam, Int_t &nModule) const
550{
551 // Transition from cell indexes (ieta,iphi) to module indexes (ietam,iphim, nModule)
552 static Int_t nphi;
553 nphi = GetNumberOfModuleInPhiDirection(nSupMod);
554
555 ietam = ieta/fNETAdiv;
556 iphim = iphi/fNPHIdiv;
557 nModule = ietam * nphi + iphim;
558}
559
560//------------------------------------------------------------------------------------
561Int_t AliJetDummyGeo::GetAbsCellId(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta) const
562{
563 // 27-aug-04;
564 // corr. 21-sep-04;
565 // 13-oct-05; 110 degree case
566 // May 31, 2006; ALICE numbering scheme:
567 // 0 <= nSupMod < fNumberOfSuperModules
568 // 0 <= nModule < fNPHI * fNZ ( fNPHI * fNZ/2 for fKey110DEG=1)
569 // 0 <= nIphi < fNPHIdiv
570 // 0 <= nIeta < fNETAdiv
571 // 0 <= absid < fNCells
572 static Int_t id=0; // have to change from 0 to fNCells-1
573 if(nSupMod >= 10) { // 110 degree case; last two supermodules
574 id = fNCellsInSupMod*10 + (fNCellsInSupMod/2)*(nSupMod-10);
575 } else {
576 id = fNCellsInSupMod*nSupMod;
577 }
578 id += fNCellsInModule *nModule;
579 id += fNPHIdiv *nIphi;
580 id += nIeta;
581 if(id<0 || id >= fNCells) {
582 id = -TMath::Abs(id); // if negative something wrong
583 }
584 return id;
585}
586
587//------------------------------------------------------------------------------------
588Bool_t AliJetDummyGeo::GetPhiBoundariesOfSMGap(Int_t nPhiSec, Double_t &phiMin, Double_t &phiMax) const
589{
590 // 0<= nPhiSec <=4; phi in rad
591 // 0; gap boundaries between 0th&2th | 1th&3th SM
592 // 1; gap boundaries between 2th&4th | 3th&5th SM
593 // 2; gap boundaries between 4th&6th | 5th&7th SM
594 // 3; gap boundaries between 6th&8th | 7th&9th SM
595 // 4; gap boundaries between 8th&10th | 9th&11th SM
596 if(nPhiSec<0 || nPhiSec >4) return kFALSE;
597 phiMin = fPhiBoundariesOfSM[2*nPhiSec+1];
598 phiMax = fPhiBoundariesOfSM[2*nPhiSec+2];
599 return kTRUE;
600}
601
602//------------------------------------------------------------------------------------
3e147bc8 603void AliJetDummyGeo::CreateListOfTrd1Modules()
604{
605 // Generate the list of Trd1 modules
606 // which will make up the EMCAL
607 // geometry
6b22f7f4 608 printf("CreateListOfTrd1Modules() \n");
609
3e147bc8 610 AliJetDummyShishKebabTrd1Module *mod=0, *mTmp=0; // current module
611 if(fShishKebabTrd1Modules == 0) {
612 fShishKebabTrd1Modules = new TList;
613 fShishKebabTrd1Modules->SetName("ListOfTRD1");
614 for(Int_t iz=0; iz< GetNZ(); iz++) {
615 if(iz==0) {
616 mod = new AliJetDummyShishKebabTrd1Module(TMath::Pi()/2.,this);
617 } else {
618 mTmp = new AliJetDummyShishKebabTrd1Module(*mod);
619 mod = mTmp;
620 }
621 fShishKebabTrd1Modules->Add(mod);
622 }
623 } else {
624 printf(" Already exits : ");
625 }
626 mod = (AliJetDummyShishKebabTrd1Module*)fShishKebabTrd1Modules->At(fShishKebabTrd1Modules->GetSize()-1);
627 fEtaMaxOfTRD1 = mod->GetMaxEtaOfModule(0);
628
629 // printf(" fShishKebabTrd1Modules has %i modules : max eta %5.4f \n",
630 // fShishKebabTrd1Modules->GetSize(),fEtaMaxOfTRD1);
631
632 // Feb 20,2006;
633 // Jun 01, 2006 - ALICE numbering scheme
634 // define grid for cells in eta(z) and x directions in local coordinates system of SM
635 // Works just for 2x2 case only -- ?? start here
636 //
637 //
638 // Define grid for cells in phi(y) direction in local coordinates system of SM
639 // as for 2X2 as for 3X3 - Nov 8,2006
640 //
641
642 // printf(" Cells grid in phi directions : size %i\n", fCentersOfCellsPhiDir.GetSize());
643
644 Int_t ind=0; // this is phi index
645 Int_t ieta=0, nModule=0, iphiTemp;
646 Double_t xr, zr, theta, phi, eta, r, x,y;
cb4aa3df 647 xr = 0.;
648 zr = 0.;
649
3e147bc8 650 TVector3 vglob;
651 Double_t ytCenterModule=0.0, ytCenterCell=0.0;
652
653 fCentersOfCellsPhiDir.Set(fNPhi*fNPHIdiv);
654 fPhiCentersOfCells.Set(fNPhi*fNPHIdiv);
655
656 Double_t R0 = GetIPDistance() + GetLongModuleSize()/2.;
657 for(Int_t it=0; it<fNPhi; it++) { // cycle on modules
658 ytCenterModule = -fParSM[1] + fPhiModuleSize*(2*it+1)/2; // center of module
659 for(Int_t ic=0; ic<fNPHIdiv; ic++) { // cycle on cells in module
660 if(fNPHIdiv==2) {
661 ytCenterCell = ytCenterModule + fPhiTileSize *(2*ic-1)/2.;
662 } else if(fNPHIdiv==3){
663 ytCenterCell = ytCenterModule + fPhiTileSize *(ic-1);
664 } else if(fNPHIdiv==1){
665 ytCenterCell = ytCenterModule;
666 }
667 fCentersOfCellsPhiDir.AddAt(ytCenterCell,ind);
668 // Define grid on phi direction
669 // Grid is not the same for different eta bin;
670 // Effect is small but is still here
671 phi = TMath::ATan2(ytCenterCell, R0);
672 fPhiCentersOfCells.AddAt(phi, ind);
673
674 // printf(" ind %2.2i : y %8.3f ", ind, fCentersOfCellsPhiDir.At(ind));
675 ind++;
676 }
677 }
678
679 fCentersOfCellsEtaDir.Set(fNZ *fNETAdiv);
680 fCentersOfCellsXDir.Set(fNZ *fNETAdiv);
681 fEtaCentersOfCells.Set(fNZ *fNETAdiv * fNPhi*fNPHIdiv);
682 if(fDebug>1) AliInfo(Form(" Cells grid in eta directions : size %i\n", fCentersOfCellsEtaDir.GetSize()));
683 for(Int_t it=0; it<fNZ; it++) {
684 AliJetDummyShishKebabTrd1Module *trd1 = GetShishKebabModule(it);
685 nModule = fNPhi*it;
686 for(Int_t ic=0; ic<fNETAdiv; ic++) {
687 if(fNPHIdiv==2) {
688 trd1->GetCenterOfCellInLocalCoordinateofSM(ic, xr, zr); // case of 2X2
689 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
690 } if(fNPHIdiv==3) {
03b05b15 691 trd1->GetCenterOfCellInLocalCoordinateofSM3X3(ic, xr, zr); // case of 3X3
3e147bc8 692 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
693 } if(fNPHIdiv==1) {
03b05b15 694 trd1->GetCenterOfCellInLocalCoordinateofSM1X1(xr, zr); // case of 1X1
3e147bc8 695 GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta);
696 }
697 fCentersOfCellsXDir.AddAt(Float_t(xr) - fParSM[0],ieta);
698 fCentersOfCellsEtaDir.AddAt(Float_t(zr) - fParSM[2],ieta);
699 // Define grid on eta direction for each bin in phi
700 for(Int_t iphi=0; iphi<fCentersOfCellsPhiDir.GetSize(); iphi++) {
701 x = xr + trd1->GetRadius();
702 y = fCentersOfCellsPhiDir[iphi];
703 r = TMath::Sqrt(x*x + y*y + zr*zr);
704 theta = TMath::ACos(zr/r);
705 eta = AliJetDummyShishKebabTrd1Module::ThetaToEta(theta);
706 // ind = ieta*fCentersOfCellsPhiDir.GetSize() + iphi;
707 ind = iphi*fCentersOfCellsEtaDir.GetSize() + ieta;
708 fEtaCentersOfCells.AddAt(eta, ind);
709 }
710 //printf(" ieta %i : xr + trd1->GetRadius() %f : zr %f : eta %f \n", ieta, xr + trd1->GetRadius(), zr, eta);
711 }
712 }
713
714 if(fDebug>1){
715 for(Int_t i=0; i<fCentersOfCellsEtaDir.GetSize(); i++) {
716 AliInfo(Form(" ind %2.2i : z %8.3f : x %8.3f", i+1,
717 fCentersOfCellsEtaDir.At(i),fCentersOfCellsXDir.At(i)));
718 }
719 }
720}
721
722//------------------------------------------------------------------------------------
723AliJetDummyShishKebabTrd1Module* AliJetDummyGeo::GetShishKebabModule(Int_t neta)
724{
725 // This method was too long to be included in the header file - the
726 // rule checker complained about it's length, so we move it here. It
727 // returns the shishkebabmodule at a given eta index point.
728
729 static AliJetDummyShishKebabTrd1Module* trd1=0;
730 if(fShishKebabTrd1Modules && neta>=0 && neta<fShishKebabTrd1Modules->GetSize()) {
731 trd1 = (AliJetDummyShishKebabTrd1Module*)fShishKebabTrd1Modules->At(neta);
732 } else trd1 = 0;
733 return trd1;
734}
735
736//------------------------------------------------------------------------------------
ee7de0dd 737void AliJetDummyGeo::GetTransformationForSM()
738{
739 // Uses the geometry manager to load the transformation matrix
740 // for the supermodules
741 // Unused after 19 Jan, 2007 - keep for compatibility;
742
743 return;
744 static Bool_t transInit=kFALSE;
745 if(transInit) return;
746
3e147bc8 747 Int_t i=0;
ee7de0dd 748 if(gGeoManager == 0) {
749 Info("CreateTransformationForSM() "," Load geometry : TGeoManager::Import()");
750 assert(0);
751 }
752
753 TGeoNode *tn = gGeoManager->GetTopNode();
754 TGeoNode *node=0, *xen1 = 0;
755 for(i=0; i<tn->GetNdaughters(); i++) {
756 node = tn->GetDaughter(i);
757 TString ns(node->GetName());
758 if(ns.Contains(GetNameOfEMCALEnvelope())) {
759 xen1 = node;
760 break;
761 }
762 }
763
764 if(!xen1) {
765 Info("CreateTransformationForSM() "," geometry has not EMCAL envelope with name %s",
766 GetNameOfEMCALEnvelope());
767 assert(0);
768 }
3e147bc8 769 AliInfo(Form(" i %i : EMCAL Envelope is %s : #SM %i \n", i, xen1->GetName(), xen1->GetNdaughters()));
ee7de0dd 770 for(i=0; i<xen1->GetNdaughters(); i++) {
771 TGeoNodeMatrix *sm = (TGeoNodeMatrix*)xen1->GetDaughter(i);
772 fMatrixOfSM[i] = sm->GetMatrix();
773 }
3e147bc8 774 AliInfo(Form("transInit %d: ", transInit));
ee7de0dd 775 transInit = kTRUE;
776}
777