]>
Commit | Line | Data |
---|---|---|
e5a93224 | 1 | /************************************************************************** |
2012850d | 2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$*/ | |
17 | ||
18 | //_________________________________________________________________________ | |
e8c0d6bb | 19 | // Geometry class for EMCAL : singleton |
b13bbe81 | 20 | // EMCAL consists of layers of scintillator and lead |
d297ef6e | 21 | // with scintillator fiber arranged as "shish-kebab" skewers |
ffa6d63b | 22 | // Places the the Barrel Geometry of The EMCAL at Midrapidity |
d87bd045 | 23 | // between 80 and 180(or 190) degrees of Phi and |
ffa6d63b | 24 | // -0.7 to 0.7 in eta |
d297ef6e | 25 | // |
1d46d1f6 | 26 | // EMCAL geometry tree: |
2bb3725c | 27 | // EMCAL -> superModule -> module -> tower(cell) |
1d46d1f6 | 28 | // Indexes |
2bb3725c | 29 | // absId -> nSupMod -> nModule -> (nIphi,nIeta) |
1d46d1f6 | 30 | // |
d297ef6e | 31 | // Name choices: |
32 | // EMCAL_PDC06 (geometry used for PDC06 simulations, kept for backward compatibility) | |
33 | // = equivalent to SHISH_77_TRD1_2X2_FINAL_110DEG in old notation | |
34 | // EMCAL_COMPLETE (geometry for expected complete detector) | |
35 | // = equivalent to SHISH_77_TRD1_2X2_FINAL_110DEG scTh=0.176 pbTh=0.144 | |
36 | // in old notation | |
171d2441 | 37 | // EMCAL_FIRSTYEARV1 - geometry for December 2009 to December 2010 run period; |
3d841a9f | 38 | // fixed bug for positions of modules inside SM |
39 | // (first module has tilt 0.75 degree); | |
40 | // the sizes updated with last information from production | |
41 | // drawing (end of October 2010). | |
171d2441 | 42 | // |
a520bcd0 | 43 | // EMCAL_COMPLETEV1: Same fixes as FIRSTYEAR and 10 SM instead of 10 + 2 one_third SM, for 2011 runs |
d7f5c01a | 44 | // |
45 | // EMCAL_COMPLETE12SMV1: contains 12 SM for runs from year 2012 and on | |
3d841a9f | 46 | // |
8cc543cb | 47 | // EMCAL_COMPLETE12SMV1_DCAL: contains 12 SM and 6 DCAL SM |
48 | // | |
49 | // EMCAL_COMPLETE12SMV1_DCAL_8SM: contains 12 SM and 8 DCAL SM including the DCAL extention (2 SM) | |
50 | // | |
51 | // EMCAL_COMPLETE12SMV1_DCAL_DEV: contains 12 SM shifted and 10 DCAL SM | |
52 | // | |
d297ef6e | 53 | // EMCAL_WSUC (Wayne State test stand) |
54 | // = no definite equivalent in old notation, was only used by | |
55 | // Aleksei, but kept for testing purposes | |
56 | // | |
57 | // etc. | |
e8c0d6bb | 58 | |
d297ef6e | 59 | // |
e8c0d6bb | 60 | // Usage: |
61 | // You can create the AliEMCALGeometry object independently from anything. | |
62 | // You have to use just the correct name of geometry. If name is empty string the | |
63 | // default name of geometry will be used. | |
64 | // | |
65 | // AliEMCALGeometry* g = AliEMCALGeometry::GetInstance(name,title); // first time | |
66 | // .. | |
67 | // g = AliEMCALGeometry::GetInstance(); // after first time | |
d297ef6e | 68 | // |
e8c0d6bb | 69 | // MC: If you work with MC data you have to get geometry the next way: |
70 | // == ============================= | |
71 | // AliRunLoader *rl = AliRunLoader::Instance(); | |
72 | // AliEMCALGeometry *geom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry(); | |
73 | // TGeoManager::Import("geometry.root"); | |
d297ef6e | 74 | // |
b13bbe81 | 75 | //*-- Author: Sahal Yacoob (LBL / UCT) |
76 | // and : Yves Schutz (SUBATECH) | |
77 | // and : Jennifer Klay (LBL) | |
3d841a9f | 78 | // and : Alexei Pavlinov (WSU) |
1d46d1f6 | 79 | // |
e8c0d6bb | 80 | // Implementation for analysis usage, before AliEMCALGeometry now (06/2011) merged again |
81 | // in AliEMCALGeometry | |
82 | // | |
83 | // -- Author: Magali Estienne (magali.estienne@subatech.in2p3.fr) | |
8cc543cb | 84 | // and : Adapted for DCAL, M.L. Wang CCNU & Subatech Oct-18-2012 |
e8c0d6bb | 85 | // |
89557f6d | 86 | // |
87 | // Usage: | |
88 | // You can create the AliEMCALGeometry object independently from anything. | |
89 | // You have to use just the correct name of geometry. If name is empty string the | |
90 | // default name of geometry will be used. | |
91 | // | |
d7f5c01a | 92 | // AliEMCALGeometry* geom = new AliEMCALGeometry("EMCAL_COMPLETE12SMV1","EMCAL"); |
e8c0d6bb | 93 | // TGeoManager::Import("geometry.root"); |
89557f6d | 94 | // |
76855a3c | 95 | // MC: If you work with MC data you have to get geometry the next way: |
96 | // == ============================= | |
e8c0d6bb | 97 | // !!!!!!!!! This part has to be modified |
98 | // AliRunLoader *rl = AliRunLoader::GetRunLoader(); | |
99 | // AliEMCALEMCGeometry *geom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry(); | |
d297ef6e | 100 | // TGeoManager::Import("geometry.root"); |
dc7da436 | 101 | |
937d0661 | 102 | |
e8c0d6bb | 103 | // --- ROOT system --- |
104 | ||
105 | #include <TParticle.h> | |
106 | #include <TGeoManager.h> | |
107 | #include <TGeoMatrix.h> | |
108 | #include <TGeoBBox.h> | |
109 | #include <TList.h> | |
110 | #include <TBrowser.h> | |
111 | ||
112 | // --- Standard library --- | |
113 | //#include <Riostream.h> | |
114 | ||
115 | // --- AliRoot header files --- | |
a520bcd0 | 116 | #include "AliLog.h" |
e8c0d6bb | 117 | #include "AliEMCALGeometry.h" |
118 | #include "AliEMCALShishKebabTrd1Module.h" | |
787342d6 | 119 | #include "AliEMCALTriggerMappingV1.h" |
120 | #include "AliEMCALTriggerMappingV2.h" | |
e8c0d6bb | 121 | |
122 | ClassImp(AliEMCALGeometry) | |
123 | ||
124 | // these initialisations are needed for a singleton | |
125 | AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0; | |
d7f5c01a | 126 | const Char_t* AliEMCALGeometry::fgkDefaultGeometryName = "EMCAL_COMPLETE12SMV1"; |
e8c0d6bb | 127 | |
128 | //____________________________________________________________________________ | |
129 | AliEMCALGeometry::AliEMCALGeometry(): | |
787342d6 | 130 | fEMCGeometry(0x0),fTriggerMapping(0x0),fGeoName(0),fEMCSMSystem(0x0), |
8cc543cb | 131 | fKey110DEG(0),fnSupModInDCAL(0),fNCellsInSupMod(0),fNETAdiv(0),fNPHIdiv(0), |
e8c0d6bb | 132 | fNCellsInModule(0),fPhiBoundariesOfSM(0x0),fPhiCentersOfSM(0x0), |
8cc543cb | 133 | fPhiCentersOfSMSec(0x0),fPhiCentersOfCells(0x0),fCentersOfCellsEtaDir(0x0), |
e8c0d6bb | 134 | fCentersOfCellsPhiDir(0x0),fEtaCentersOfCells(0x0), |
135 | fNCells(0),fNPhi(0),fCentersOfCellsXDir(0x0),fArm1EtaMin(0), | |
136 | fArm1EtaMax(0),fArm1PhiMin(0),fArm1PhiMax(0),fEtaMaxOfTRD1(0), | |
8cc543cb | 137 | fDCALPhiMin(0),fDCALPhiMax(0),fEMCALPhiMax(0),fDCALStandardPhiMax(0), |
138 | fDCALInnerExtandedEta(0),fShishKebabTrd1Modules(0),fPhiModuleSize(0.), | |
e8c0d6bb | 139 | fEtaModuleSize(0.),fPhiTileSize(0.),fEtaTileSize(0.),fNZ(0), |
140 | fIPDistance(0.),fLongModuleSize(0.),fShellThickness(0.), | |
141 | fZLength(0.),fSampling(0.),fUseExternalMatrices(kFALSE) | |
9cff4509 | 142 | { |
e8c0d6bb | 143 | // default ctor |
144 | // must be kept public for root persistency purposes, but should never be called by the outside world | |
145 | fEnvelop[0] = 0.; | |
146 | fEnvelop[1] = 0.; | |
147 | fEnvelop[2] = 0.; | |
148 | fParSM[0] = 0.; | |
149 | fParSM[1] = 0.; | |
150 | fParSM[2] = 0.; | |
d7cff4de | 151 | for (Int_t i=0;i<AliEMCALGeoParams::fgkEMCALModules;i++) |
152 | fkSModuleMatrix[i]=0 ; | |
e8c0d6bb | 153 | } |
154 | ||
155 | //____________________________________________________________________________ | |
156 | AliEMCALGeometry::AliEMCALGeometry(const AliEMCALGeometry & geo) | |
157 | : TNamed(geo), | |
787342d6 | 158 | fEMCGeometry(geo.fEMCGeometry),fTriggerMapping(geo.fTriggerMapping),fGeoName(geo.fGeoName),fEMCSMSystem(geo.fEMCSMSystem), |
8cc543cb | 159 | fKey110DEG(geo.fKey110DEG),fnSupModInDCAL(geo.fnSupModInDCAL),fNCellsInSupMod(geo.fNCellsInSupMod),fNETAdiv(geo.fNETAdiv),fNPHIdiv(geo.fNPHIdiv), |
e8c0d6bb | 160 | fNCellsInModule(geo.fNCellsInModule),fPhiBoundariesOfSM(geo.fPhiBoundariesOfSM),fPhiCentersOfSM(geo.fPhiCentersOfSM), |
8cc543cb | 161 | fPhiCentersOfSMSec(geo.fPhiCentersOfSMSec),fPhiCentersOfCells(geo.fPhiCentersOfCells),fCentersOfCellsEtaDir(geo.fCentersOfCellsEtaDir), |
e8c0d6bb | 162 | fCentersOfCellsPhiDir(geo.fCentersOfCellsPhiDir),fEtaCentersOfCells(geo.fEtaCentersOfCells), |
163 | fNCells(geo.fNCells),fNPhi(geo.fNPhi),fCentersOfCellsXDir(geo.fCentersOfCellsXDir),fArm1EtaMin(geo.fArm1EtaMin), | |
164 | fArm1EtaMax(geo.fArm1EtaMax),fArm1PhiMin(geo.fArm1PhiMin),fArm1PhiMax(geo.fArm1PhiMax),fEtaMaxOfTRD1(geo.fEtaMaxOfTRD1), | |
8cc543cb | 165 | fDCALPhiMin(geo.fDCALPhiMin),fDCALPhiMax(geo.fDCALPhiMax),fEMCALPhiMax(geo.fEMCALPhiMax),fDCALStandardPhiMax(geo.fDCALStandardPhiMax), |
166 | fDCALInnerExtandedEta(geo.fDCALInnerExtandedEta),fShishKebabTrd1Modules(geo.fShishKebabTrd1Modules),fPhiModuleSize(geo.fPhiModuleSize), | |
e8c0d6bb | 167 | fEtaModuleSize(geo.fEtaModuleSize),fPhiTileSize(geo.fPhiTileSize),fEtaTileSize(geo.fEtaTileSize),fNZ(geo.fNZ), |
168 | fIPDistance(geo.fIPDistance),fLongModuleSize(geo.fLongModuleSize),fShellThickness(geo.fShellThickness), | |
169 | fZLength(geo.fZLength),fSampling(geo.fSampling),fUseExternalMatrices(geo.fUseExternalMatrices) | |
9cff4509 | 170 | { |
bccc4a4f | 171 | // Copy constarctor |
e8c0d6bb | 172 | fEnvelop[0] = geo.fEnvelop[0]; |
173 | fEnvelop[1] = geo.fEnvelop[1]; | |
174 | fEnvelop[2] = geo.fEnvelop[2]; | |
175 | fParSM[0] = geo.fParSM[0]; | |
176 | fParSM[1] = geo.fParSM[1]; | |
177 | fParSM[2] = geo.fParSM[2]; | |
d7cff4de | 178 | for (Int_t i=0;i<AliEMCALGeoParams::fgkEMCALModules;i++) |
179 | fkSModuleMatrix[i]=0 ; | |
0a4cb131 | 180 | } |
181 | ||
e8c0d6bb | 182 | //____________________________________________________________________________ |
126215a5 | 183 | AliEMCALGeometry::AliEMCALGeometry(const Text_t* name, const Text_t* title, |
184 | const Text_t* mcname, const Text_t* mctitle) | |
e8c0d6bb | 185 | : TNamed(name, title), |
787342d6 | 186 | fEMCGeometry(0x0),fTriggerMapping(0x0),fGeoName(0),fEMCSMSystem(0x0), |
8cc543cb | 187 | fKey110DEG(0),fnSupModInDCAL(0),fNCellsInSupMod(0),fNETAdiv(0),fNPHIdiv(0), |
e8c0d6bb | 188 | fNCellsInModule(0),fPhiBoundariesOfSM(0x0),fPhiCentersOfSM(0x0), |
8cc543cb | 189 | fPhiCentersOfSMSec(0x0),fPhiCentersOfCells(0x0),fCentersOfCellsEtaDir(0x0), |
e8c0d6bb | 190 | fCentersOfCellsPhiDir(0x0),fEtaCentersOfCells(0x0), |
191 | fNCells(0),fNPhi(0),fCentersOfCellsXDir(0x0),fArm1EtaMin(0), | |
192 | fArm1EtaMax(0),fArm1PhiMin(0),fArm1PhiMax(0),fEtaMaxOfTRD1(0), | |
8cc543cb | 193 | fDCALPhiMin(0),fDCALPhiMax(0),fEMCALPhiMax(0),fDCALStandardPhiMax(0), |
194 | fDCALInnerExtandedEta(0),fShishKebabTrd1Modules(0),fPhiModuleSize(0.), | |
e8c0d6bb | 195 | fEtaModuleSize(0.),fPhiTileSize(0.),fEtaTileSize(0.),fNZ(0), |
196 | fIPDistance(0.),fLongModuleSize(0.),fShellThickness(0.), | |
197 | fZLength(0.),fSampling(0.), fUseExternalMatrices(kFALSE) | |
198 | { | |
e8c0d6bb | 199 | // ctor only for normal usage |
126215a5 | 200 | |
201 | fEMCGeometry = new AliEMCALEMCGeometry(name,title,mcname,mctitle); | |
e8c0d6bb | 202 | fGeoName = fEMCGeometry->GetGeoName(); |
8cc543cb | 203 | fEMCSMSystem = fEMCGeometry->GetEMCSystem(); |
e8c0d6bb | 204 | fKey110DEG = fEMCGeometry->GetKey110DEG(); |
8cc543cb | 205 | fnSupModInDCAL = fEMCGeometry->GetnSupModInDCAL(); |
e8c0d6bb | 206 | fNCellsInSupMod = fEMCGeometry->GetNCellsInSupMod(); |
207 | fNETAdiv = fEMCGeometry->GetNETAdiv(); | |
208 | fNPHIdiv = fEMCGeometry->GetNPHIdiv(); | |
209 | fNCellsInModule = fNPHIdiv*fNETAdiv; | |
210 | static int i=0; | |
211 | Int_t nSMod = fEMCGeometry->GetNumberOfSuperModules(); | |
212 | fPhiBoundariesOfSM.Set(nSMod); | |
213 | fPhiCentersOfSM.Set(nSMod/2); | |
8cc543cb | 214 | fPhiCentersOfSMSec.Set(nSMod/2); |
e8c0d6bb | 215 | for(Int_t sm=0; sm<nSMod; sm++) { |
216 | i = sm/2; | |
217 | fEMCGeometry->GetPhiBoundariesOfSM(sm,fPhiBoundariesOfSM[2*i],fPhiBoundariesOfSM[2*i+1]); | |
218 | } | |
219 | ||
220 | Double_t phiMin = 0.; | |
221 | Double_t phiMax = 0.; | |
222 | for(Int_t sm=0; sm<nSMod; sm++) { | |
223 | fEMCGeometry->GetPhiBoundariesOfSM(sm,phiMin,phiMax); | |
224 | i=sm/2; | |
225 | fPhiCentersOfSM[i] = fEMCGeometry->GetPhiCenterOfSM(sm); | |
8cc543cb | 226 | fPhiCentersOfSMSec[i] = fEMCGeometry->GetPhiCenterOfSMSec(sm); |
e8c0d6bb | 227 | } |
228 | fNCells = fEMCGeometry->GetNCells(); | |
229 | fNPhi = fEMCGeometry->GetNPhi(); | |
230 | fEnvelop[0] = fEMCGeometry->GetEnvelop(0); | |
231 | fEnvelop[1] = fEMCGeometry->GetEnvelop(1); | |
232 | fEnvelop[2] = fEMCGeometry->GetEnvelop(2); | |
233 | fParSM[0] = fEMCGeometry->GetSuperModulesPar(0); | |
234 | fParSM[1] = fEMCGeometry->GetSuperModulesPar(1); | |
235 | fParSM[2] = fEMCGeometry->GetSuperModulesPar(2); | |
236 | fArm1EtaMin = fEMCGeometry->GetArm1EtaMin(); | |
237 | fArm1EtaMax = fEMCGeometry->GetArm1EtaMax(); | |
238 | fArm1PhiMin = fEMCGeometry->GetArm1PhiMin(); | |
239 | fArm1PhiMax = fEMCGeometry->GetArm1PhiMax(); | |
8cc543cb | 240 | fDCALPhiMin = fEMCGeometry->GetDCALPhiMin(); |
241 | fDCALPhiMax = fEMCGeometry->GetDCALPhiMax(); | |
242 | fEMCALPhiMax = fEMCGeometry->GetEMCALPhiMax(); | |
243 | fDCALStandardPhiMax = fEMCGeometry->GetDCALStandardPhiMax(); | |
244 | fDCALInnerExtandedEta = fEMCGeometry->GetDCALInnerExtandedEta(); | |
e8c0d6bb | 245 | fShellThickness = fEMCGeometry->GetShellThickness(); |
246 | fZLength = fEMCGeometry->GetZLength(); | |
247 | fSampling = fEMCGeometry->GetSampling(); | |
248 | fEtaModuleSize = fEMCGeometry->GetEtaModuleSize(); | |
249 | fPhiModuleSize = fEMCGeometry->GetPhiModuleSize(); | |
250 | fEtaTileSize = fEMCGeometry->GetEtaTileSize(); | |
251 | fPhiTileSize = fEMCGeometry->GetPhiTileSize(); | |
252 | fNZ = fEMCGeometry->GetNZ(); | |
253 | fIPDistance = fEMCGeometry->GetIPDistance(); | |
254 | fLongModuleSize = fEMCGeometry->GetLongModuleSize(); | |
255 | ||
256 | CreateListOfTrd1Modules(); | |
257 | ||
d7cff4de | 258 | for(Int_t smod=0; smod < AliEMCALGeoParams::fgkEMCALModules; smod++) |
259 | fkSModuleMatrix[smod]=0 ; | |
e8c0d6bb | 260 | |
261 | if (AliDebugLevel()>=2) { | |
262 | fEMCGeometry->Print(); | |
263 | PrintGeometryGeoUtils(); | |
264 | } | |
787342d6 | 265 | |
266 | if ((fEMCGeometry->GetGeoName()).Contains("DCAL")) { | |
267 | fTriggerMapping = new AliEMCALTriggerMappingV2(46, this); | |
268 | } else { | |
269 | fTriggerMapping = new AliEMCALTriggerMappingV1(32, this); | |
270 | } | |
2012850d | 271 | } |
d297ef6e | 272 | |
e8c0d6bb | 273 | //____________________________________________________________________________ |
e9edf555 | 274 | AliEMCALGeometry & AliEMCALGeometry::operator = (const AliEMCALGeometry & /*rvalue*/) |
275 | { | |
e8c0d6bb | 276 | //assing operator |
277 | Fatal("assignment operator", "not implemented") ; | |
278 | return *this ; | |
279 | } | |
280 | ||
281 | //____________________________________________________________________________ | |
282 | AliEMCALGeometry::~AliEMCALGeometry(void) | |
283 | { | |
284 | // dtor | |
7272e45f | 285 | if (this==fgGeom) |
286 | { | |
d7cff4de | 287 | AliError("Do not call delete on me"); |
288 | return; | |
289 | } | |
7272e45f | 290 | |
291 | if (fEMCGeometry) | |
292 | { | |
293 | for(Int_t smod = 0 ; smod < fEMCGeometry->GetNumberOfSuperModules(); smod++) | |
294 | { | |
e8c0d6bb | 295 | if(fkSModuleMatrix[smod]) |
296 | delete fkSModuleMatrix[smod] ; | |
7272e45f | 297 | |
298 | fkSModuleMatrix[smod]=0 ; | |
e8c0d6bb | 299 | } |
7272e45f | 300 | |
bccc4a4f | 301 | delete fEMCGeometry; // fEMCGeometry = 0 ; |
e8c0d6bb | 302 | } |
787342d6 | 303 | |
304 | if (fTriggerMapping) delete fTriggerMapping; | |
e8c0d6bb | 305 | } |
f0377b23 | 306 | |
b13bbe81 | 307 | //______________________________________________________________________ |
e9edf555 | 308 | AliEMCALGeometry * AliEMCALGeometry::GetInstance() |
309 | { | |
05a92d59 | 310 | // Returns the pointer of the unique instance |
311 | ||
e52475ed | 312 | AliEMCALGeometry * rv = static_cast<AliEMCALGeometry *>( fgGeom ); |
313 | return rv; | |
2012850d | 314 | } |
173558f2 | 315 | |
b13bbe81 | 316 | //______________________________________________________________________ |
126215a5 | 317 | AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name, const Text_t* title, |
e9edf555 | 318 | const Text_t* mcname, const Text_t* mctitle ) |
319 | { | |
e8c0d6bb | 320 | // Returns the pointer of the unique instance |
126215a5 | 321 | |
e8c0d6bb | 322 | AliEMCALGeometry * rv = 0; |
323 | if ( fgGeom == 0 ) { | |
324 | if ( strcmp(name,"") == 0 ) { // get default geometry | |
126215a5 | 325 | fgGeom = new AliEMCALGeometry(fgkDefaultGeometryName, title,mcname,mctitle); |
e8c0d6bb | 326 | } else { |
126215a5 | 327 | fgGeom = new AliEMCALGeometry(name, title,mcname,mctitle); |
e8c0d6bb | 328 | } // end if strcmp(name,"") |
329 | if ( AliEMCALEMCGeometry::fgInit ) rv = (AliEMCALGeometry * ) fgGeom; | |
330 | else { | |
331 | rv = 0; | |
332 | delete fgGeom; | |
333 | fgGeom = 0; | |
334 | } // end if fgInit | |
335 | }else{ | |
336 | if ( strcmp(fgGeom->GetName(), name) != 0) { | |
337 | printf("\ncurrent geometry is %s : ", fgGeom->GetName()); | |
338 | printf(" you cannot call %s ",name); | |
b13bbe81 | 339 | }else{ |
e8c0d6bb | 340 | rv = (AliEMCALGeometry *) fgGeom; |
341 | } // end | |
342 | } // end if fgGeom | |
343 | return rv; | |
344 | } | |
345 | ||
346 | //________________________________________________________________________________________________ | |
347 | void AliEMCALGeometry::Browse(TBrowser* b) | |
348 | { | |
349 | //Browse the modules | |
350 | if(fShishKebabTrd1Modules) b->Add(fShishKebabTrd1Modules); | |
351 | } | |
352 | ||
353 | //________________________________________________________________________________________________ | |
354 | Bool_t AliEMCALGeometry::IsFolder() const | |
355 | { | |
356 | //Check if fShishKebabTrd1Modules is in folder | |
357 | if(fShishKebabTrd1Modules) return kTRUE; | |
358 | else return kFALSE; | |
359 | } | |
360 | ||
361 | //________________________________________________________________________________________________ | |
362 | void AliEMCALGeometry::GetGlobal(const Double_t *loc, Double_t *glob, int ind) const | |
363 | { | |
364 | // Figure out the global numbering | |
365 | // of a given supermodule from the | |
366 | // local numbering and the transformation | |
367 | // matrix stored by the geometry manager (allows for misaligned | |
368 | // geometry) | |
369 | ||
e9edf555 | 370 | const TGeoHMatrix* m = GetMatrixForSuperModule(ind); |
371 | if(m) { | |
372 | m->LocalToMaster(loc, glob); | |
373 | } else { | |
374 | AliFatal("Geo matrixes are not loaded \n") ; | |
375 | } | |
e8c0d6bb | 376 | } |
377 | ||
378 | //________________________________________________________________________________________________ | |
379 | void AliEMCALGeometry::GetGlobal(const TVector3 &vloc, TVector3 &vglob, int ind) const | |
380 | { | |
381 | //Figure out the global numbering | |
382 | //of a given supermodule from the | |
383 | //local numbering given a 3-vector location | |
384 | ||
385 | static Double_t tglob[3], tloc[3]; | |
386 | vloc.GetXYZ(tloc); | |
387 | GetGlobal(tloc, tglob, ind); | |
388 | vglob.SetXYZ(tglob[0], tglob[1], tglob[2]); | |
389 | } | |
390 | ||
391 | //________________________________________________________________________________________________ | |
392 | void AliEMCALGeometry::GetGlobal(Int_t absId , double glob[3]) const | |
393 | { | |
394 | // Alice numbering scheme - Jun 03, 2006 | |
395 | static Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1; | |
396 | static double loc[3]; | |
397 | ||
398 | glob[0]=glob[1]=glob[2]=0.0; // bad case | |
399 | if(RelPosCellInSModule(absId, loc)) { | |
400 | GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta); | |
e9edf555 | 401 | const TGeoHMatrix* m = GetMatrixForSuperModule(nSupMod); |
402 | if(m) { | |
e8c0d6bb | 403 | m->LocalToMaster(loc, glob); |
404 | } else { | |
405 | AliFatal("Geo matrixes are not loaded \n") ; | |
406 | } | |
407 | } | |
408 | } | |
409 | ||
410 | //___________________________________________________________________ | |
411 | void AliEMCALGeometry::GetGlobal(Int_t absId , TVector3 &vglob) const | |
412 | { | |
413 | // Alice numbering scheme - Jun 03, 2006 | |
414 | static Double_t glob[3]; | |
415 | ||
416 | GetGlobal(absId, glob); | |
417 | vglob.SetXYZ(glob[0], glob[1], glob[2]); | |
e8c0d6bb | 418 | } |
419 | ||
e8c0d6bb | 420 | //______________________________________________________________________ |
421 | void AliEMCALGeometry::PrintCellIndexes(Int_t absId, int pri, const char *tit) const | |
422 | { | |
423 | // Service methods | |
424 | Int_t nSupMod, nModule, nIphi, nIeta; | |
425 | Int_t iphi, ieta; | |
426 | TVector3 vg; | |
427 | ||
428 | GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta); | |
429 | printf(" %s | absId : %i -> nSupMod %i nModule %i nIphi %i nIeta %i \n", tit, absId, nSupMod, nModule, nIphi, nIeta); | |
430 | if(pri>0) { | |
431 | GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta); | |
432 | printf(" local SM index : iphi %i : ieta %i \n", iphi,ieta); | |
433 | GetGlobal(absId, vg); | |
434 | printf(" vglob : mag %7.2f : perp %7.2f : z %7.2f : eta %6.4f : phi %6.4f(%6.2f) \n", | |
435 | vg.Mag(), vg.Perp(), vg.Z(), vg.Eta(), vg.Phi(), vg.Phi()*TMath::RadToDeg()); | |
436 | } | |
437 | } | |
438 | ||
439 | void AliEMCALGeometry::PrintLocalTrd1(Int_t pri) const | |
440 | { | |
441 | // For comparing with numbers from drawing | |
442 | for(Int_t i=0; i<GetShishKebabTrd1Modules()->GetSize(); i++){ | |
443 | printf(" %s | ", GetShishKebabModule(i)->GetName()); | |
444 | if(i==0 && pri<1) GetShishKebabModule(i)->PrintShish(1); | |
445 | else GetShishKebabModule(i)->PrintShish(pri); | |
446 | } | |
447 | } | |
448 | ||
449 | //________________________________________________________________________________________________ | |
450 | void AliEMCALGeometry::EtaPhiFromIndex(Int_t absId,Double_t &eta,Double_t &phi) const | |
451 | { | |
452 | // Nov 16, 2006- float to double | |
453 | // version for TRD1 only | |
454 | static TVector3 vglob; | |
455 | GetGlobal(absId, vglob); | |
456 | eta = vglob.Eta(); | |
457 | phi = vglob.Phi(); | |
458 | } | |
459 | ||
460 | //________________________________________________________________________________________________ | |
461 | void AliEMCALGeometry::EtaPhiFromIndex(Int_t absId,Float_t &eta,Float_t &phi) const | |
462 | { | |
463 | // Nov 16,2006 - should be discard in future | |
464 | static TVector3 vglob; | |
465 | GetGlobal(absId, vglob); | |
466 | eta = float(vglob.Eta()); | |
467 | phi = float(vglob.Phi()); | |
468 | } | |
469 | ||
470 | // | |
471 | // == Shish-kebab cases == | |
472 | // | |
473 | //________________________________________________________________________________________________ | |
474 | Int_t AliEMCALGeometry::GetAbsCellId(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta) const | |
475 | { | |
476 | // 27-aug-04; | |
477 | // corr. 21-sep-04; | |
478 | // 13-oct-05; 110 degree case | |
479 | // May 31, 2006; ALICE numbering scheme: | |
480 | // 0 <= nSupMod < fNumberOfSuperModules | |
481 | // 0 <= nModule < fNPHI * fNZ ( fNPHI * fNZ/2 for fKey110DEG=1) | |
482 | // 0 <= nIphi < fNPHIdiv | |
483 | // 0 <= nIeta < fNETAdiv | |
484 | // 0 <= absid < fNCells | |
8cc543cb | 485 | Int_t id=0; // have to change from 0 to fNCells-1 |
486 | for( int i = 0 ; i < nSupMod; i++) { | |
487 | if( GetSMType(i) == kEMCAL_Standard) id += fNCellsInSupMod; | |
488 | else if( GetSMType(i) == kEMCAL_Half) id += fNCellsInSupMod/2; | |
489 | else if( GetSMType(i) == kEMCAL_3rd) id += fNCellsInSupMod/3; | |
490 | else if( GetSMType(i) == kDCAL_Standard) id += 2*fNCellsInSupMod/3; | |
491 | else if( GetSMType(i) == kDCAL_Ext) id += fNCellsInSupMod/3; | |
492 | else { | |
493 | AliError(Form("Uknown SuperModule Type !!")); | |
494 | } | |
e8c0d6bb | 495 | } |
8cc543cb | 496 | |
e8c0d6bb | 497 | id += fNCellsInModule *nModule; |
498 | id += fNPHIdiv *nIphi; | |
499 | id += nIeta; | |
8cc543cb | 500 | if( !CheckAbsCellId(id) ) { |
e8c0d6bb | 501 | id = -TMath::Abs(id); // if negative something wrong |
502 | } | |
503 | return id; | |
504 | } | |
505 | ||
506 | //________________________________________________________________________________________________ | |
507 | void AliEMCALGeometry::GetModuleIndexesFromCellIndexesInSModule(Int_t nSupMod, Int_t iphi, Int_t ieta, | |
508 | Int_t &iphim, Int_t &ietam, Int_t &nModule) const | |
509 | { | |
510 | // Transition from cell indexes (ieta,iphi) to module indexes (ietam,iphim, nModule) | |
511 | static Int_t nphi=-1; | |
512 | nphi = GetNumberOfModuleInPhiDirection(nSupMod); | |
513 | ||
514 | ietam = ieta/fNETAdiv; | |
515 | iphim = iphi/fNPHIdiv; | |
516 | nModule = ietam * nphi + iphim; | |
517 | } | |
518 | ||
519 | //________________________________________________________________________________________________ | |
520 | Int_t AliEMCALGeometry::GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, Int_t ieta) const | |
521 | { | |
522 | // Transition from super module number(nSupMod) and cell indexes (ieta,iphi) to absId | |
84cb7b3f | 523 | |
524 | // Check if the indeces correspond to existing SM or tower indeces | |
525 | if(iphi < 0 || iphi >= AliEMCALGeoParams::fgkEMCALRows || | |
526 | ieta < 0 || ieta >= AliEMCALGeoParams::fgkEMCALCols || | |
527 | nSupMod < 0 || nSupMod >= GetNumberOfSuperModules() ) | |
528 | { | |
529 | AliDebug(1,Form("Wrong cell indexes : SM %d, column (eta) %d, row (phi) %d", nSupMod,ieta,iphi)); | |
530 | return -1 ; | |
531 | } | |
532 | ||
e8c0d6bb | 533 | static Int_t ietam=-1, iphim=-1, nModule=-1; |
534 | static Int_t nIeta=-1, nIphi=-1; // cell indexes in module | |
535 | ||
536 | GetModuleIndexesFromCellIndexesInSModule(nSupMod, iphi, ieta, ietam, iphim, nModule); | |
537 | ||
538 | nIeta = ieta%fNETAdiv; | |
539 | nIeta = fNETAdiv - 1 - nIeta; | |
540 | nIphi = iphi%fNPHIdiv; | |
84cb7b3f | 541 | |
e8c0d6bb | 542 | return GetAbsCellId(nSupMod, nModule, nIphi, nIeta); |
543 | } | |
544 | ||
545 | //________________________________________________________________________________________________ | |
546 | Bool_t AliEMCALGeometry::SuperModuleNumberFromEtaPhi(Double_t eta, Double_t phi, Int_t &nSupMod) const | |
547 | { | |
548 | // Return false if phi belongs a phi cracks between SM | |
549 | ||
550 | static Int_t i=0; | |
551 | ||
552 | if(TMath::Abs(eta) > fEtaMaxOfTRD1) return kFALSE; | |
553 | ||
554 | phi = TVector2::Phi_0_2pi(phi); // move phi to (0,2pi) boundaries | |
8cc543cb | 555 | Int_t nphism = fEMCGeometry->GetNumberOfSuperModules()/2; |
556 | for(i=0; i<nphism; i++) { | |
e8c0d6bb | 557 | if(phi>=fPhiBoundariesOfSM[2*i] && phi<=fPhiBoundariesOfSM[2*i+1]) { |
558 | nSupMod = 2*i; | |
559 | if(eta < 0.0) nSupMod++; | |
8cc543cb | 560 | if( GetSMType(nSupMod) == kDCAL_Standard) {// Gap between DCAL |
561 | if(TMath::Abs(eta) < GetNEta()/3*(GetEMCGeometry()->GetTrd1Angle())*TMath::DegToRad()) return kFALSE; | |
562 | } | |
e8c0d6bb | 563 | AliDebug(1,Form("eta %f phi %f(%5.2f) : nSupMod %i : #bound %i", eta,phi,phi*TMath::RadToDeg(), nSupMod,i)); |
564 | return kTRUE; | |
565 | } | |
566 | } | |
567 | return kFALSE; | |
568 | } | |
569 | ||
570 | ||
571 | //________________________________________________________________________________________________ | |
572 | Bool_t AliEMCALGeometry::GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi, Int_t &absId) const | |
573 | { | |
8cc543cb | 574 | |
e8c0d6bb | 575 | // Nov 17,2006 |
576 | // stay here - phi problem as usual | |
8cc543cb | 577 | static Int_t nSupMod=-1, i=0, ieta=-1, iphi=-1, etaShift=0, neta=-1, nphi=-1; |
e8c0d6bb | 578 | static Double_t absEta=0.0, d=0.0, dmin=0.0, phiLoc=0; |
579 | absId = nSupMod = - 1; | |
580 | if(SuperModuleNumberFromEtaPhi(eta, phi, nSupMod)) { | |
581 | // phi index first | |
582 | phi = TVector2::Phi_0_2pi(phi); | |
a1ec550c | 583 | phiLoc = phi - fPhiCentersOfSMSec[nSupMod/2]; |
e8c0d6bb | 584 | nphi = fPhiCentersOfCells.GetSize(); |
8cc543cb | 585 | if ( GetSMType(nSupMod) == kEMCAL_Half ) nphi /= 2; |
586 | else if( GetSMType(nSupMod) == kEMCAL_3rd ) nphi /= 3; | |
587 | else if( GetSMType(nSupMod) == kDCAL_Ext ) nphi /= 3; | |
588 | ||
e8c0d6bb | 589 | dmin = TMath::Abs(fPhiCentersOfCells[0]-phiLoc); |
590 | iphi = 0; | |
591 | for(i=1; i<nphi; i++) { | |
592 | d = TMath::Abs(fPhiCentersOfCells[i] - phiLoc); | |
593 | if(d < dmin) { | |
594 | dmin = d; | |
595 | iphi = i; | |
596 | } | |
e9edf555 | 597 | //printf(" i %i : d %f : dmin %f : fPhiCentersOfCells[i] %f \n", i, d, dmin, fPhiCentersOfCells[i]); |
e8c0d6bb | 598 | } |
599 | // odd SM are turned with respect of even SM - reverse indexes | |
600 | AliDebug(2,Form(" iphi %i : dmin %f (phi %f, phiLoc %f ) ", iphi, dmin, phi, phiLoc)); | |
8cc543cb | 601 | |
e8c0d6bb | 602 | // eta index |
603 | absEta = TMath::Abs(eta); | |
8cc543cb | 604 | neta = fCentersOfCellsEtaDir.GetSize(); |
605 | etaShift = iphi*neta; | |
e8c0d6bb | 606 | ieta = 0; |
8cc543cb | 607 | if( GetSMType(nSupMod) == kDCAL_Standard) ieta += 16; //jump 16 cells for DCSM |
608 | dmin = TMath::Abs(fEtaCentersOfCells[etaShift + ieta]-absEta); | |
609 | for(i= ieta+1 ; i<neta; i++) { | |
e8c0d6bb | 610 | d = TMath::Abs(fEtaCentersOfCells[i+etaShift] - absEta); |
611 | if(d < dmin) { | |
612 | dmin = d; | |
613 | ieta = i; | |
614 | } | |
615 | } | |
8cc543cb | 616 | if( GetSMType(nSupMod) == kDCAL_Standard) ieta -= 16; //jump 16 cells for DCSM |
617 | ||
e8c0d6bb | 618 | AliDebug(2,Form(" ieta %i : dmin %f (eta=%f) : nSupMod %i ", ieta, dmin, eta, nSupMod)); |
a520bcd0 | 619 | |
620 | //patch for mapping following alice convention | |
8cc543cb | 621 | if(nSupMod%2 == 0) {// 47 + 16 -ieta for DCSM, 47 - ieta for others, revert the ordering on A side in order to keep convention. |
622 | ieta = (neta -1)-ieta; | |
623 | if( GetSMType(nSupMod) == kDCAL_Standard) ieta -= 16; //recover cells for DCSM | |
624 | } | |
e8c0d6bb | 625 | |
8cc543cb | 626 | absId = GetAbsCellIdFromCellIndexes(nSupMod, iphi, ieta); |
e8c0d6bb | 627 | return kTRUE; |
628 | } | |
629 | return kFALSE; | |
630 | } | |
631 | ||
632 | //________________________________________________________________________________________________ | |
633 | Bool_t AliEMCALGeometry::CheckAbsCellId(Int_t absId) const | |
634 | { | |
635 | // May 31, 2006; only trd1 now | |
636 | if(absId<0 || absId >= fNCells) return kFALSE; | |
637 | else return kTRUE; | |
638 | } | |
639 | ||
640 | //________________________________________________________________________________________________ | |
641 | Bool_t AliEMCALGeometry::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nModule,Int_t &nIphi,Int_t &nIeta) const | |
642 | { | |
643 | // 21-sep-04; 19-oct-05; | |
644 | // May 31, 2006; ALICE numbering scheme: | |
645 | // | |
646 | // In: | |
647 | // absId - cell is as in Geant, 0<= absId < fNCells; | |
648 | // Out: | |
649 | // nSupMod - super module(SM) number, 0<= nSupMod < fNumberOfSuperModules; | |
650 | // nModule - module number in SM, 0<= nModule < fNCellsInSupMod/fNCellsInSupMod or(/2) for tow last SM (10th and 11th); | |
651 | // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv; | |
652 | // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv; | |
653 | // | |
e8c0d6bb | 654 | if(!CheckAbsCellId(absId)) return kFALSE; |
655 | ||
8cc543cb | 656 | static Int_t tmp = absId; |
657 | Int_t test = absId; | |
658 | ||
659 | for(nSupMod = -1; test >= 0; ) { | |
660 | nSupMod++; | |
661 | tmp = test; | |
662 | if( GetSMType(nSupMod) == kEMCAL_Standard) test -= fNCellsInSupMod; | |
663 | else if( GetSMType(nSupMod) == kEMCAL_Half) test -= fNCellsInSupMod/2; | |
664 | else if( GetSMType(nSupMod) == kEMCAL_3rd) test -= fNCellsInSupMod/3; | |
665 | else if( GetSMType(nSupMod) == kDCAL_Standard) test -= 2*fNCellsInSupMod/3; | |
666 | else if( GetSMType(nSupMod) == kDCAL_Ext) test -= fNCellsInSupMod/3; | |
667 | else { | |
668 | AliError(Form("Uknown SuperModule Type !!")); | |
669 | return kFALSE; | |
670 | } | |
e8c0d6bb | 671 | } |
8cc543cb | 672 | nModule = tmp / fNCellsInModule; |
e8c0d6bb | 673 | tmp = tmp % fNCellsInModule; |
674 | nIphi = tmp / fNPHIdiv; | |
675 | nIeta = tmp % fNPHIdiv; | |
676 | ||
677 | return kTRUE; | |
678 | } | |
679 | ||
680 | //________________________________________________________________________________________________ | |
681 | Int_t AliEMCALGeometry::GetSuperModuleNumber(Int_t absId) const | |
682 | { | |
683 | // Return the number of the supermodule given the absolute | |
684 | // ALICE numbering id | |
685 | ||
686 | static Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1; | |
687 | GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta); | |
688 | return nSupMod; | |
689 | } | |
690 | ||
691 | //________________________________________________________________________________________________ | |
692 | void AliEMCALGeometry::GetModulePhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, int &iphim, int &ietam) const | |
693 | { | |
694 | // added nSupMod; - 19-oct-05 ! | |
695 | // Alice numbering scheme - Jun 01,2006 | |
696 | // ietam, iphi - indexes of module in two dimensional grid of SM | |
697 | // ietam - have to change from 0 to fNZ-1 | |
698 | // iphim - have to change from 0 to nphi-1 (fNPhi-1 or fNPhi/2-1) | |
699 | static Int_t nphi=-1; | |
8cc543cb | 700 | if( GetSMType(nSupMod) == kEMCAL_Half ) nphi = fNPhi/2; // halfSM |
701 | else if( GetSMType(nSupMod) == kEMCAL_3rd ) nphi = fNPhi/3; // 1/3 SM | |
702 | else if( GetSMType(nSupMod) == kDCAL_Ext ) nphi = fNPhi/3; // 1/3 SM | |
703 | else nphi = fNPhi; // full SM | |
704 | ||
e8c0d6bb | 705 | ietam = nModule/nphi; |
706 | iphim = nModule%nphi; | |
707 | } | |
708 | ||
709 | //________________________________________________________________________________________________ | |
710 | void AliEMCALGeometry::GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta, | |
711 | int &iphi, int &ieta) const | |
712 | { | |
713 | // | |
714 | // Added nSupMod; Nov 25, 05 | |
715 | // Alice numbering scheme - Jun 01,2006 | |
716 | // IN: | |
717 | // nSupMod - super module(SM) number, 0<= nSupMod < fNumberOfSuperModules; | |
718 | // nModule - module number in SM, 0<= nModule < fNCellsInSupMod/fNCellsInSupMod or(/2) for tow last SM (10th and 11th); | |
719 | // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv; | |
720 | // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv; | |
721 | // | |
e9edf555 | 722 | // OUT: |
e8c0d6bb | 723 | // ieta, iphi - indexes of cell(tower) in two dimensional grid of SM |
724 | // ieta - have to change from 0 to (fNZ*fNETAdiv-1) | |
725 | // iphi - have to change from 0 to (fNPhi*fNPHIdiv-1 or fNPhi*fNPHIdiv/2-1) | |
726 | // | |
727 | static Int_t iphim=-1, ietam=-1; | |
728 | ||
729 | GetModulePhiEtaIndexInSModule(nSupMod,nModule, iphim, ietam); | |
730 | // ieta = ietam*fNETAdiv + (1-nIeta); // x(module) = -z(SM) | |
731 | ieta = ietam*fNETAdiv + (fNETAdiv - 1 - nIeta); // x(module) = -z(SM) | |
732 | iphi = iphim*fNPHIdiv + nIphi; // y(module) = y(SM) | |
733 | ||
734 | if(iphi<0 || ieta<0) | |
735 | AliDebug(1,Form(" nSupMod %i nModule %i nIphi %i nIeta %i => ieta %i iphi %i\n", | |
736 | nSupMod, nModule, nIphi, nIeta, ieta, iphi)); | |
737 | } | |
738 | ||
e8c0d6bb | 739 | // Methods for AliEMCALRecPoint - Feb 19, 2006 |
740 | //________________________________________________________________________________________________ | |
741 | Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr) const | |
742 | { | |
743 | // Look to see what the relative | |
744 | // position inside a given cell is | |
745 | // for a recpoint. | |
746 | // Alice numbering scheme - Jun 08, 2006 | |
747 | // In: | |
748 | // absId - cell is as in Geant, 0<= absId < fNCells; | |
749 | // OUT: | |
750 | // xr,yr,zr - x,y,z coordinates of cell with absId inside SM | |
751 | ||
752 | // Shift index taking into account the difference between standard SM | |
a520bcd0 | 753 | // and SM of half (or one third) size in phi direction |
754 | ||
8cc543cb | 755 | const Int_t kNphiIndex = fCentersOfCellsPhiDir.GetSize(); |
756 | Double_t zshift = 0.5*GetDCALInnerEdge(); | |
a520bcd0 | 757 | |
e8c0d6bb | 758 | static Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1, iphi=-1, ieta=-1; |
759 | if(!CheckAbsCellId(absId)) return kFALSE; | |
760 | ||
761 | GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta); | |
762 | GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta); | |
763 | ||
764 | //Get eta position. Careful with ALICE conventions (increase index decrease eta) | |
765 | Int_t ieta2 = ieta; | |
8cc543cb | 766 | if(nSupMod%2 == 0) { |
767 | ieta2 = (fCentersOfCellsEtaDir.GetSize()-1)-ieta;// 47-ieta, revert the ordering on A side in order to keep convention. | |
768 | } | |
769 | if( GetSMType(nSupMod) == kDCAL_Standard && nSupMod%2 ) ieta2 += 16; // DCAL revert the ordering on C side ... | |
e8c0d6bb | 770 | zr = fCentersOfCellsEtaDir.At(ieta2); |
8cc543cb | 771 | if( GetSMType(nSupMod) == kDCAL_Standard ) zr -= zshift; // DCAL shift (SMALLER SM) |
e8c0d6bb | 772 | xr = fCentersOfCellsXDir.At(ieta2); |
773 | ||
774 | //Get phi position. Careful with ALICE conventions (increase index increase phi) | |
775 | Int_t iphi2 = iphi; | |
8cc543cb | 776 | if( GetSMType(nSupMod) == kDCAL_Ext ) { |
777 | if(nSupMod%2 != 0) iphi2 = (kNphiIndex/3 -1)-iphi; // 7-iphi [1/3SM], revert the ordering on C side in order to keep convention. | |
778 | yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/3); | |
779 | } else if( GetSMType(nSupMod) == kEMCAL_Half ){ | |
780 | if(nSupMod%2 != 0) iphi2 = (kNphiIndex/2 -1)-iphi; //11-iphi [1/2SM], revert the ordering on C side in order to keep convention. | |
781 | yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/4); | |
782 | } else if( GetSMType(nSupMod) == kEMCAL_3rd ){ | |
783 | if(nSupMod%2 != 0) iphi2 = (kNphiIndex/3 -1)-iphi; // 7-iphi [1/3SM], revert the ordering on C side in order to keep convention. | |
784 | yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/3); | |
e8c0d6bb | 785 | } else { |
8cc543cb | 786 | if(nSupMod%2 != 0) iphi2 = (kNphiIndex -1)-iphi;// 23-iphi, revert the ordering on C side in order to keep conventi |
787 | yr = fCentersOfCellsPhiDir.At(iphi2); | |
788 | } | |
e8c0d6bb | 789 | AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr)); |
790 | ||
791 | return kTRUE; | |
792 | } | |
793 | ||
794 | //________________________________________________________________________________________________ | |
795 | Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t loc[3]) const | |
796 | { | |
797 | // Look to see what the relative | |
798 | // position inside a given cell is | |
799 | // for a recpoint. // Alice numbering scheme - Jun 03, 2006 | |
800 | loc[0] = loc[1] = loc[2]=0.0; | |
801 | if(RelPosCellInSModule(absId, loc[0],loc[1],loc[2])) { | |
802 | return kTRUE; | |
803 | } | |
804 | return kFALSE; | |
805 | } | |
806 | ||
807 | //________________________________________________________________________________________________ | |
808 | Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, TVector3 &vloc) const | |
809 | { | |
810 | // Look to see what the relative | |
811 | // position inside a given cell is | |
812 | // for a recpoint. | |
813 | // Alice numbering scheme - Jun 03, 2006 | |
814 | static Double_t loc[3]; | |
815 | if(RelPosCellInSModule(absId,loc)) { | |
816 | vloc.SetXYZ(loc[0], loc[1], loc[2]); | |
817 | return kTRUE; | |
818 | } else { | |
819 | vloc.SetXYZ(0,0,0); | |
820 | return kFALSE; | |
821 | } | |
2012850d | 822 | } |
173558f2 | 823 | |
d297ef6e | 824 | //________________________________________________________________________________________________ |
1ae500a2 | 825 | Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t distEff, Double_t &xr, Double_t &yr, Double_t &zr) const |
826 | { | |
827 | // Jul 30, 2007 - taking into account position of shower max | |
828 | // Look to see what the relative | |
829 | // position inside a given cell is | |
830 | // for a recpoint. | |
831 | // In: | |
832 | // absId - cell is as in Geant, 0<= absId < fNCells; | |
833 | // e - cluster energy | |
834 | // OUT: | |
835 | // xr,yr,zr - x,y,z coordinates of cell with absId inside SM | |
e8c0d6bb | 836 | |
1ae500a2 | 837 | // Shift index taking into account the difference between standard SM |
a520bcd0 | 838 | // and SM of half (or one third) size in phi direction |
8cc543cb | 839 | |
840 | const Int_t kNphiIndex = fCentersOfCellsPhiDir.GetSize(); | |
841 | Double_t zshift = 0.5*GetDCALInnerEdge(); | |
842 | Int_t kDCalshift = 8;//wangml DCal cut first 8 modules(16 cells) | |
a520bcd0 | 843 | |
53e430a3 | 844 | static Int_t nSupMod=0, nModule=-1, nIphi=-1, nIeta=-1, iphi=-1, ieta=-1; |
845 | static Int_t iphim=-1, ietam=-1; | |
1ae500a2 | 846 | static AliEMCALShishKebabTrd1Module *mod = 0; |
847 | static TVector2 v; | |
848 | if(!CheckAbsCellId(absId)) return kFALSE; | |
c694fff1 | 849 | |
1ae500a2 | 850 | GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta); |
851 | GetModulePhiEtaIndexInSModule(nSupMod, nModule, iphim, ietam); | |
852 | GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta); | |
c694fff1 | 853 | |
854 | //Get eta position. Careful with ALICE conventions (increase index decrease eta) | |
855 | if(nSupMod%2 == 0) { | |
8cc543cb | 856 | ietam = (fCentersOfCellsEtaDir.GetSize()/2-1)-ietam;// 24-ietam, revert the ordering on A side in order to keep convention. |
c694fff1 | 857 | if(nIeta == 0) nIeta = 1; |
858 | else nIeta = 0; | |
859 | } | |
8cc543cb | 860 | if( GetSMType(nSupMod) == kDCAL_Standard && nSupMod%2) ietam += kDCalshift; // DCAL revert the ordering on C side .... |
1ae500a2 | 861 | mod = GetShishKebabModule(ietam); |
c694fff1 | 862 | mod ->GetPositionAtCenterCellLine(nIeta, distEff, v); |
1ae500a2 | 863 | xr = v.Y() - fParSM[0]; |
864 | zr = v.X() - fParSM[2]; | |
8cc543cb | 865 | if( GetSMType(nSupMod) == kDCAL_Standard ) zr -= zshift; // DCAL shift (SMALLER SM) |
866 | ||
c694fff1 | 867 | //Get phi position. Careful with ALICE conventions (increase index increase phi) |
868 | Int_t iphi2 = iphi; | |
8cc543cb | 869 | if( GetSMType(nSupMod) == kDCAL_Ext ) { |
870 | if(nSupMod%2 != 0) iphi2 = (kNphiIndex/3 -1)-iphi; // 7-iphi [1/3SM], revert the ordering on C side in order to keep convention. | |
871 | yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/3); | |
872 | } else if( GetSMType(nSupMod) == kEMCAL_Half ){ | |
873 | if(nSupMod%2 != 0) iphi2 = (kNphiIndex/2 -1)-iphi; //11-iphi [1/2SM], revert the ordering on C side in order to keep convention. | |
874 | yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/2); | |
875 | } else if( GetSMType(nSupMod) == kEMCAL_3rd ){ | |
876 | if(nSupMod%2 != 0) iphi2 = (kNphiIndex/3 -1)-iphi; // 7-iphi [1/3SM], revert the ordering on C side in order to keep convention. | |
877 | yr = fCentersOfCellsPhiDir.At(iphi2 + kNphiIndex/3); | |
878 | } else { | |
879 | if(nSupMod%2 != 0) iphi2 = (kNphiIndex -1)-iphi;// 23-iphi, revert the ordering on C side in order to keep convention. | |
880 | yr = fCentersOfCellsPhiDir.At(iphi2); | |
881 | } | |
c694fff1 | 882 | |
1ae500a2 | 883 | AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr)); |
c694fff1 | 884 | |
1ae500a2 | 885 | return kTRUE; |
886 | } | |
887 | ||
e8c0d6bb | 888 | //________________________________________________________________________________________________ |
889 | void AliEMCALGeometry::CreateListOfTrd1Modules() | |
890 | { | |
891 | // Generate the list of Trd1 modules | |
892 | // which will make up the EMCAL | |
893 | // geometry | |
894 | // key: look to the AliEMCALShishKebabTrd1Module:: | |
14e75ea7 | 895 | |
e8c0d6bb | 896 | AliDebug(2,Form(" AliEMCALGeometry::CreateListOfTrd1Modules() started ")); |
e52475ed | 897 | |
e8c0d6bb | 898 | AliEMCALShishKebabTrd1Module *mod=0, *mTmp=0; // current module |
899 | if(fShishKebabTrd1Modules == 0) { | |
900 | fShishKebabTrd1Modules = new TList; | |
901 | fShishKebabTrd1Modules->SetName("ListOfTRD1"); | |
902 | for(int iz=0; iz< fEMCGeometry->GetNZ(); iz++) { | |
903 | if(iz==0) { | |
904 | // mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,this); | |
905 | mod = new AliEMCALShishKebabTrd1Module(TMath::Pi()/2.,fEMCGeometry); | |
906 | } else { | |
907 | mTmp = new AliEMCALShishKebabTrd1Module(*mod); | |
908 | mod = mTmp; | |
909 | } | |
910 | fShishKebabTrd1Modules->Add(mod); | |
911 | } | |
912 | } else { | |
913 | AliDebug(2,Form(" Already exits : ")); | |
914 | } | |
915 | mod = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(fShishKebabTrd1Modules->GetSize()-1); | |
916 | fEtaMaxOfTRD1 = mod->GetMaxEtaOfModule(0); | |
917 | ||
918 | AliDebug(2,Form(" fShishKebabTrd1Modules has %i modules : max eta %5.4f \n", | |
919 | fShishKebabTrd1Modules->GetSize(),fEtaMaxOfTRD1)); | |
920 | // Feb 20,2006; | |
921 | // Jun 01, 2006 - ALICE numbering scheme | |
922 | // define grid for cells in eta(z) and x directions in local coordinates system of SM | |
923 | // Works just for 2x2 case only -- ?? start here | |
924 | // | |
925 | // | |
926 | // Define grid for cells in phi(y) direction in local coordinates system of SM | |
927 | // as for 2X2 as for 3X3 - Nov 8,2006 | |
928 | // | |
929 | AliDebug(2,Form(" Cells grid in phi directions : size %i\n", fCentersOfCellsPhiDir.GetSize())); | |
930 | Int_t ind=0; // this is phi index | |
931 | Int_t ieta=0, nModule=0, iphiTemp; | |
932 | Double_t xr=0., zr=0., theta=0., phi=0., eta=0., r=0., x=0.,y=0.; | |
933 | TVector3 vglob; | |
934 | Double_t ytCenterModule=0.0, ytCenterCell=0.0; | |
935 | ||
936 | fCentersOfCellsPhiDir.Set(fNPhi*fNPHIdiv); | |
937 | fPhiCentersOfCells.Set(fNPhi*fNPHIdiv); | |
938 | ||
939 | Double_t r0 = fIPDistance + fLongModuleSize/2.; | |
940 | for(Int_t it=0; it<fNPhi; it++) { // cycle on modules | |
941 | ytCenterModule = -fParSM[1] + fPhiModuleSize*(2*it+1)/2; // center of module | |
942 | for(Int_t ic=0; ic<fNPHIdiv; ic++) { // cycle on cells in module | |
943 | if(fNPHIdiv==2) { | |
944 | ytCenterCell = ytCenterModule + fPhiTileSize *(2*ic-1)/2.; | |
945 | } else if(fNPHIdiv==3){ | |
946 | ytCenterCell = ytCenterModule + fPhiTileSize *(ic-1); | |
947 | } else if(fNPHIdiv==1){ | |
948 | ytCenterCell = ytCenterModule; | |
949 | } | |
950 | fCentersOfCellsPhiDir.AddAt(ytCenterCell,ind); | |
951 | // Define grid on phi direction | |
952 | // Grid is not the same for different eta bin; | |
953 | // Effect is small but is still here | |
954 | phi = TMath::ATan2(ytCenterCell, r0); | |
955 | fPhiCentersOfCells.AddAt(phi, ind); | |
956 | ||
957 | AliDebug(2,Form(" ind %2.2i : y %8.3f ", ind, fCentersOfCellsPhiDir.At(ind))); | |
958 | ind++; | |
959 | } | |
960 | } | |
961 | ||
962 | fCentersOfCellsEtaDir.Set(fNZ *fNETAdiv); | |
963 | fCentersOfCellsXDir.Set(fNZ *fNETAdiv); | |
964 | fEtaCentersOfCells.Set(fNZ *fNETAdiv * fNPhi*fNPHIdiv); | |
965 | AliDebug(2,Form(" Cells grid in eta directions : size %i\n", fCentersOfCellsEtaDir.GetSize())); | |
966 | for(Int_t it=0; it<fNZ; it++) { | |
967 | AliEMCALShishKebabTrd1Module *trd1 = GetShishKebabModule(it); | |
968 | nModule = fNPhi*it; | |
969 | for(Int_t ic=0; ic<fNETAdiv; ic++) { | |
970 | if(fNPHIdiv==2) { | |
971 | trd1->GetCenterOfCellInLocalCoordinateofSM(ic, xr, zr); // case of 2X2 | |
972 | GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta); | |
973 | } if(fNPHIdiv==3) { | |
974 | trd1->GetCenterOfCellInLocalCoordinateofSM3X3(ic, xr, zr); // case of 3X3 | |
975 | GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta); | |
976 | } if(fNPHIdiv==1) { | |
977 | trd1->GetCenterOfCellInLocalCoordinateofSM1X1(xr, zr); // case of 1X1 | |
978 | GetCellPhiEtaIndexInSModule(0, nModule, 0, ic, iphiTemp, ieta); | |
979 | } | |
980 | fCentersOfCellsXDir.AddAt(float(xr) - fParSM[0],ieta); | |
981 | fCentersOfCellsEtaDir.AddAt(float(zr) - fParSM[2],ieta); | |
982 | // Define grid on eta direction for each bin in phi | |
983 | for(int iphi=0; iphi<fCentersOfCellsPhiDir.GetSize(); iphi++) { | |
984 | x = xr + trd1->GetRadius(); | |
985 | y = fCentersOfCellsPhiDir[iphi]; | |
986 | r = TMath::Sqrt(x*x + y*y + zr*zr); | |
987 | theta = TMath::ACos(zr/r); | |
988 | eta = AliEMCALShishKebabTrd1Module::ThetaToEta(theta); | |
989 | // ind = ieta*fCentersOfCellsPhiDir.GetSize() + iphi; | |
990 | ind = iphi*fCentersOfCellsEtaDir.GetSize() + ieta; | |
991 | fEtaCentersOfCells.AddAt(eta, ind); | |
992 | } | |
993 | //printf(" ieta %i : xr + trd1->GetRadius() %f : zr %f : eta %f \n", ieta, xr + trd1->GetRadius(), zr, eta); | |
994 | } | |
995 | } | |
996 | for(Int_t i=0; i<fCentersOfCellsEtaDir.GetSize(); i++) { | |
997 | AliDebug(2,Form(" ind %2.2i : z %8.3f : x %8.3f", i+1, | |
998 | fCentersOfCellsEtaDir.At(i),fCentersOfCellsXDir.At(i))); | |
999 | } | |
1000 | ||
1001 | } | |
1002 | ||
e8c0d6bb | 1003 | //________________________________________________________________________________________________ |
1004 | AliEMCALShishKebabTrd1Module* AliEMCALGeometry::GetShishKebabModule(Int_t neta) const | |
1005 | { | |
1006 | //This method was too long to be | |
1007 | //included in the header file - the | |
1008 | //rule checker complained about it's | |
1009 | //length, so we move it here. It returns the | |
1010 | //shishkebabmodule at a given eta index point. | |
1011 | ||
1012 | static AliEMCALShishKebabTrd1Module* trd1=0; | |
1013 | if(fShishKebabTrd1Modules && neta>=0 && neta<fShishKebabTrd1Modules->GetSize()) { | |
1014 | trd1 = (AliEMCALShishKebabTrd1Module*)fShishKebabTrd1Modules->At(neta); | |
1015 | } else trd1 = 0; | |
1016 | return trd1; | |
1017 | } | |
1018 | ||
1019 | //___________________________________________________________________ | |
1020 | void AliEMCALGeometry::PrintGeometryGeoUtils() | |
1021 | { | |
1022 | //Print information from geometry | |
1023 | fEMCGeometry->PrintGeometry(); | |
1024 | ||
1025 | printf(" fShishKebabTrd1Modules has %i modules : max eta %5.4f \n", | |
1026 | fShishKebabTrd1Modules->GetSize(),fEtaMaxOfTRD1); | |
1027 | ||
1028 | printf("\n Cells grid in eta directions : size %i\n", fCentersOfCellsEtaDir.GetSize()); | |
1029 | for(Int_t i=0; i<fCentersOfCellsEtaDir.GetSize(); i++) { | |
1030 | printf(" ind %2.2i : z %8.3f : x %8.3f \n", i, | |
1031 | fCentersOfCellsEtaDir.At(i),fCentersOfCellsXDir.At(i)); | |
1032 | int ind=0; // Nov 21,2006 | |
1033 | for(Int_t iphi=0; iphi<fCentersOfCellsPhiDir.GetSize(); iphi++) { | |
1034 | ind = iphi*fCentersOfCellsEtaDir.GetSize() + i; | |
1035 | printf("%6.4f ", fEtaCentersOfCells[ind]); | |
1036 | if((iphi+1)%12 == 0) printf("\n"); | |
1037 | } | |
1038 | printf("\n"); | |
1039 | ||
1040 | } | |
1041 | ||
1042 | printf("\n Cells grid in phi directions : size %i\n", fCentersOfCellsPhiDir.GetSize()); | |
1043 | for(Int_t i=0; i<fCentersOfCellsPhiDir.GetSize(); i++) { | |
1044 | double phi=fPhiCentersOfCells.At(i); | |
1045 | printf(" ind %2.2i : y %8.3f : phi %7.5f(%6.2f) \n", i, fCentersOfCellsPhiDir.At(i), | |
1046 | phi, phi*TMath::RadToDeg()); | |
1047 | } | |
e8c0d6bb | 1048 | } |
1049 | ||
1050 | //____________________________________________________________________________ | |
1051 | Bool_t AliEMCALGeometry::Impact(const TParticle * particle) const | |
1052 | { | |
1053 | // Tells if a particle enters EMCAL | |
1054 | Bool_t in=kFALSE; | |
1055 | Int_t absID=0; | |
1056 | TVector3 vtx(particle->Vx(),particle->Vy(),particle->Vz()); | |
1057 | TVector3 vimpact(0,0,0); | |
1058 | ImpactOnEmcal(vtx,particle->Theta(),particle->Phi(),absID,vimpact); | |
1059 | if(absID>=0) | |
1060 | in=kTRUE; | |
1061 | return in; | |
1062 | } | |
1063 | //____________________________________________________________________________ | |
1064 | void AliEMCALGeometry::ImpactOnEmcal(TVector3 vtx, Double_t theta, Double_t phi, | |
1065 | Int_t & absId, TVector3 & vimpact) const | |
1066 | { | |
1067 | // calculates the impact coordinates on EMCAL (centre of a tower/not on EMCAL surface) | |
1068 | // of a neutral particle | |
1069 | // emitted in the vertex vtx[3] with direction theta and phi in the ALICE global coordinate system | |
1070 | ||
1071 | TVector3 p(TMath::Sin(theta)*TMath::Cos(phi),TMath::Sin(theta)*TMath::Sin(phi),TMath::Cos(theta)) ; | |
1072 | ||
1073 | vimpact.SetXYZ(0,0,0); | |
1074 | absId=-1; | |
1075 | if(phi==0 || theta==0) return; | |
1076 | ||
1077 | TVector3 direction; | |
1078 | Double_t factor = (fIPDistance-vtx[1])/p[1]; | |
1079 | direction = vtx + factor*p; | |
1080 | ||
1081 | //from particle direction -> tower hitted | |
1082 | GetAbsCellIdFromEtaPhi(direction.Eta(),direction.Phi(),absId); | |
1083 | ||
1084 | //tower absID hitted -> tower/module plane (evaluated at the center of the tower) | |
1085 | Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1; | |
1086 | Double_t loc[3],loc2[3],loc3[3]; | |
1087 | Double_t glob[3]={},glob2[3]={},glob3[3]={}; | |
1088 | ||
1089 | if(!RelPosCellInSModule(absId,loc)) return; | |
1090 | ||
1091 | //loc is cell center of tower | |
1092 | GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta); | |
1093 | ||
1094 | //look at 2 neighbours-s cell using nIphi={0,1} and nIeta={0,1} | |
1095 | Int_t nIphi2=-1,nIeta2=-1,absId2=-1,absId3=-1; | |
1096 | if(nIeta==0) nIeta2=1; | |
1097 | else nIeta2=0; | |
1098 | absId2=GetAbsCellId(nSupMod,nModule,nIphi,nIeta2); | |
1099 | if(nIphi==0) nIphi2=1; | |
1100 | else nIphi2=0; | |
1101 | absId3=GetAbsCellId(nSupMod,nModule,nIphi2,nIeta); | |
1102 | ||
1103 | //2nd point on emcal cell plane | |
1104 | if(!RelPosCellInSModule(absId2,loc2)) return; | |
1105 | ||
1106 | //3rd point on emcal cell plane | |
1107 | if(!RelPosCellInSModule(absId3,loc3)) return; | |
1108 | ||
1109 | // Get Matrix | |
1110 | const TGeoHMatrix* m = GetMatrixForSuperModule(nSupMod); | |
1111 | if(m) { | |
1112 | m->LocalToMaster(loc, glob); | |
1113 | m->LocalToMaster(loc2, glob2); | |
1114 | m->LocalToMaster(loc3, glob3); | |
1115 | } else { | |
1116 | AliFatal("Geo matrixes are not loaded \n") ; | |
1117 | } | |
1118 | ||
1119 | //Equation of Plane from glob,glob2,glob3 (Ax+By+Cz+D=0) | |
1120 | Double_t a = glob[1]*(glob2[2]-glob3[2]) + glob2[1]*(glob3[2]-glob[2]) + glob3[1]*(glob[2]-glob2[2]); | |
1121 | Double_t b = glob[2]*(glob2[0]-glob3[0]) + glob2[2]*(glob3[0]-glob[0]) + glob3[2]*(glob[0]-glob2[0]); | |
1122 | Double_t c = glob[0]*(glob2[1]-glob3[1]) + glob2[0]*(glob3[1]-glob[1]) + glob3[0]*(glob[1]-glob2[1]); | |
1123 | 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]); | |
1124 | d=-d; | |
1125 | ||
1126 | //shift equation of plane from tower/module center to surface along vector (A,B,C) normal to tower/module plane | |
1127 | Double_t dist = fLongModuleSize/2.; | |
1128 | Double_t norm = TMath::Sqrt(a*a+b*b+c*c); | |
1129 | Double_t glob4[3]={}; | |
1130 | TVector3 dir(a,b,c); | |
1131 | TVector3 point(glob[0],glob[1],glob[2]); | |
1132 | if(point.Dot(dir)<0) dist*=-1; | |
1133 | glob4[0]=glob[0]-dist*a/norm; | |
1134 | glob4[1]=glob[1]-dist*b/norm; | |
1135 | glob4[2]=glob[2]-dist*c/norm; | |
1136 | d = glob4[0]*a + glob4[1]*b + glob4[2]*c ; | |
1137 | d = -d; | |
1138 | ||
1139 | //Line determination (2 points for equation of line : vtx and direction) | |
1140 | //impact between line (particle) and plane (module/tower plane) | |
1141 | Double_t den = a*(vtx(0)-direction(0)) + b*(vtx(1)-direction(1)) + c*(vtx(2)-direction(2)); | |
1142 | if(den==0){ | |
1143 | printf("ImpactOnEmcal() No solution :\n"); | |
1144 | return; | |
1145 | } | |
1146 | ||
1147 | Double_t length = a*vtx(0)+b*vtx(1)+c*vtx(2)+d; | |
1148 | length /=den; | |
1149 | ||
1150 | vimpact.SetXYZ(vtx(0)+length*(direction(0)-vtx(0)),vtx(1)+length*(direction(1)-vtx(1)),vtx(2)+length*(direction(2)-vtx(2))); | |
1151 | ||
1152 | //shift vimpact from tower/module surface to center along vector (A,B,C) normal to tower/module plane | |
1153 | vimpact.SetXYZ(vimpact(0)+dist*a/norm,vimpact(1)+dist*b/norm,vimpact(2)+dist*c/norm); | |
1154 | ||
1155 | return; | |
1156 | } | |
1157 | ||
1158 | //_____________________________________________________________________________ | |
e9edf555 | 1159 | Bool_t AliEMCALGeometry::IsInEMCAL(Double_t x, Double_t y, Double_t z) const |
1160 | { | |
8cc543cb | 1161 | // Checks whether point is inside the EMCal volume |
1162 | if( IsInEMCALOrDCAL(x,y,z) == 1 ) return kTRUE; | |
1163 | else return kFALSE; | |
1164 | } | |
1165 | ||
1166 | //_____________________________________________________________________________ | |
1167 | Bool_t AliEMCALGeometry::IsInDCAL(Double_t x, Double_t y, Double_t z) const | |
1168 | { | |
1169 | // Checks whether point is inside the DCal volume | |
1170 | if( IsInEMCALOrDCAL(x,y,z) == 2 ) return kTRUE; | |
1171 | else return kFALSE; | |
1172 | } | |
1173 | ||
1174 | //_____________________________________________________________________________ | |
1175 | Int_t AliEMCALGeometry::IsInEMCALOrDCAL(Double_t x, Double_t y, Double_t z) const | |
1176 | { | |
1177 | // Checks whether point is inside the EMCal volume (included DCal), used in AliEMCALv*.cxx | |
e8c0d6bb | 1178 | // |
1179 | // Code uses cylindrical approximation made of inner radius (for speed) | |
1180 | // | |
8cc543cb | 1181 | // Points behind EMCAl/DCal, i.e. R > outer radius, but eta, phi in acceptance |
e8c0d6bb | 1182 | // are considered to inside |
1183 | ||
1184 | Double_t r=sqrt(x*x+y*y); | |
1185 | ||
8cc543cb | 1186 | if ( r <= fEnvelop[0] ) return 0; |
1187 | else { | |
1188 | Double_t theta = TMath::ATan2(r,z); | |
1189 | Double_t eta; | |
1190 | if(theta == 0) eta = 9999; | |
1191 | else eta = -TMath::Log(TMath::Tan(theta/2.)); | |
1192 | if (eta < fArm1EtaMin || eta > fArm1EtaMax) return 0; | |
1193 | ||
1194 | Double_t phi = TMath::ATan2(y,x) * 180./TMath::Pi(); | |
1195 | if (phi < 0) phi += 360; // phi should go from 0 to 360 in this case | |
1196 | ||
1197 | if ( phi >= fArm1PhiMin && phi <= fEMCALPhiMax ) return 1; | |
1198 | else if ( phi >= fDCALPhiMin && phi <= fDCALStandardPhiMax && TMath::Abs(eta) > fDCALInnerExtandedEta ) return 2; | |
1199 | else if ( phi > fDCALStandardPhiMax && phi <= fDCALPhiMax ) return 2; | |
1200 | else return 0; | |
1201 | } | |
e8c0d6bb | 1202 | } |
1203 | ||
e8c0d6bb | 1204 | //____________________________________________________________________________ |
e9edf555 | 1205 | const TGeoHMatrix * AliEMCALGeometry::GetMatrixForSuperModule(Int_t smod) const |
1206 | { | |
1207 | //Provides shift-rotation matrix for EMCAL | |
e8c0d6bb | 1208 | |
e9edf555 | 1209 | if(smod < 0 || smod > fEMCGeometry->GetNumberOfSuperModules()) |
1210 | AliFatal(Form("Wrong supermodule index -> %d",smod)); | |
e8c0d6bb | 1211 | |
e9edf555 | 1212 | //If GeoManager exists, take matrixes from it |
e8c0d6bb | 1213 | |
e9edf555 | 1214 | // |
1215 | // if(fKey110DEG && ind>=10) { | |
1216 | // } | |
1217 | // | |
1218 | // if(!gGeoManager->cd(volpath.Data())) | |
1219 | // AliFatal(Form("AliEMCALGeometry::GeoManager cannot find path %s!",volpath.Data())); | |
1220 | // | |
1221 | // TGeoHMatrix* m = gGeoManager->GetCurrentMatrix(); | |
e8c0d6bb | 1222 | |
1223 | //Use matrices set externally | |
e9edf555 | 1224 | if(!gGeoManager || (gGeoManager && fUseExternalMatrices)){ |
e8c0d6bb | 1225 | if(fkSModuleMatrix[smod]){ |
1226 | return fkSModuleMatrix[smod] ; | |
1227 | } | |
1228 | else{ | |
1229 | AliInfo("Stop:"); | |
1230 | printf("\t Can not find EMCAL misalignment matrixes\n") ; | |
1231 | printf("\t Either import TGeoManager from geometry.root or \n"); | |
1232 | printf("\t read stored matrixes from AliESD Header: \n") ; | |
1233 | printf("\t AliEMCALGeometry::SetMisalMatrixes(header->GetEMCALMisalMatrix()) \n") ; | |
b8bec44f | 1234 | AliFatal("") ; |
e8c0d6bb | 1235 | } |
1236 | }//external matrices | |
1237 | ||
e9edf555 | 1238 | if(gGeoManager){ |
e8c0d6bb | 1239 | const Int_t buffersize = 255; |
e9edf555 | 1240 | char path[buffersize] ; |
8cc543cb | 1241 | TString SMName; |
1242 | Int_t tmpType = -1; | |
1243 | Int_t SMOrder = 0; | |
1244 | //Get the order for SM | |
1245 | for( Int_t i = 0; i < smod+1; i++){ | |
1246 | if(GetSMType(i) == tmpType) { | |
1247 | SMOrder++; | |
1248 | } else { | |
1249 | tmpType = GetSMType(i); | |
1250 | SMOrder = 1; | |
1251 | } | |
1252 | } | |
1253 | ||
1254 | if(GetSMType(smod) == kEMCAL_Standard ) SMName = "SMOD"; | |
1255 | else if(GetSMType(smod) == kEMCAL_Half ) SMName = "SM10"; | |
1256 | else if(GetSMType(smod) == kEMCAL_3rd ) SMName = "SM3rd"; | |
1257 | else if( GetSMType(smod) == kDCAL_Standard ) SMName = "DCSM"; | |
1258 | else if( GetSMType(smod) == kDCAL_Ext ) SMName = "DCEXT"; | |
1259 | else AliError("Unkown SM Type!!"); | |
1260 | snprintf(path,buffersize,"/ALIC_1/XEN1_1/%s_%d", SMName.Data(), SMOrder) ; | |
1261 | ||
e9edf555 | 1262 | if (!gGeoManager->cd(path)){ |
1263 | AliFatal(Form("Geo manager can not find path %s!\n",path)); | |
1264 | } | |
1265 | return gGeoManager->GetCurrentMatrix(); | |
1266 | } | |
e9edf555 | 1267 | return 0 ; |
e8c0d6bb | 1268 | } |
1269 | ||
e8c0d6bb | 1270 | //__________________________________________________________________________________________________________________ |
1271 | void AliEMCALGeometry::RecalculateTowerPosition(Float_t drow, Float_t dcol, const Int_t sm, const Float_t depth, | |
1272 | const Float_t misaligTransShifts[15], const Float_t misaligRotShifts[15], Float_t global[3]) const | |
e9edf555 | 1273 | { |
1274 | //Transform clusters cell position into global with alternative method, taking into account the depth calculation. | |
e8c0d6bb | 1275 | //Input are: the tower indeces, |
1276 | // supermodule, | |
1277 | // particle type (photon 0, electron 1, hadron 2 ) | |
1278 | // misalignment shifts to global position in case of need. | |
1279 | // Federico.Ronchetti@cern.ch | |
e8c0d6bb | 1280 | |
1281 | // To use in a print later | |
1282 | Float_t droworg = drow; | |
1283 | Float_t dcolorg = dcol; | |
1284 | ||
1285 | if(gGeoManager){ | |
1286 | //Recover some stuff | |
1287 | ||
1288 | const Int_t nSMod = fEMCGeometry->GetNumberOfSuperModules(); | |
1289 | ||
1290 | gGeoManager->cd("ALIC_1/XEN1_1"); | |
1291 | TGeoNode *geoXEn1 = gGeoManager->GetCurrentNode(); | |
1292 | TGeoNodeMatrix *geoSM[nSMod]; | |
1293 | TGeoVolume *geoSMVol[nSMod]; | |
1294 | TGeoShape *geoSMShape[nSMod]; | |
1295 | TGeoBBox *geoBox[nSMod]; | |
1296 | TGeoMatrix *geoSMMatrix[nSMod]; | |
1297 | ||
1298 | for(int iSM = 0; iSM < nSMod; iSM++) { | |
1299 | geoSM[iSM] = dynamic_cast<TGeoNodeMatrix *>(geoXEn1->GetDaughter(iSM)); | |
1300 | geoSMVol[iSM] = geoSM[iSM]->GetVolume(); | |
1301 | geoSMShape[iSM] = geoSMVol[iSM]->GetShape(); | |
1302 | geoBox[iSM] = dynamic_cast<TGeoBBox *>(geoSMShape[iSM]); | |
1303 | geoSMMatrix[iSM] = geoSM[iSM]->GetMatrix(); | |
1304 | } | |
1305 | ||
1306 | if(sm % 2 == 0) { | |
1307 | dcol = 47. - dcol; | |
1308 | drow = 23. - drow; | |
1309 | } | |
1310 | ||
1311 | Int_t istrip = 0; | |
1312 | Float_t z0 = 0; | |
1313 | Float_t zb = 0; | |
bccc4a4f | 1314 | Float_t zIs = 0; |
e8c0d6bb | 1315 | |
1316 | Float_t x,y,z; // return variables in terry's RF | |
1317 | ||
1318 | //*********************************************************** | |
1319 | //Do not like this: too many hardcoded values, is it not already stored somewhere else? | |
1320 | // : need more comments in the code | |
1321 | //*********************************************************** | |
1322 | ||
1323 | Float_t dz = 6.0; // base cell width in eta | |
1324 | Float_t dx = 6.004; // base cell width in phi | |
1325 | ||
1326 | ||
1327 | //Float_t L = 26.04; // active tower length for hadron (lead+scint+paper) | |
1328 | // we use the geant numbers 13.87*2=27.74 | |
1329 | Float_t teta1 = 0.; | |
1330 | ||
1331 | //Do some basic checks | |
1332 | if (dcol >= 47.5 || dcol<-0.5) { | |
1333 | AliError(Form("Bad tower coordinate dcol=%f, where dcol >= 47.5 || dcol<-0.5; org: %f", dcol, dcolorg)); | |
1334 | return; | |
1335 | } | |
1336 | if (drow >= 23.5 || drow<-0.5) { | |
1337 | AliError(Form("Bad tower coordinate drow=%f, where drow >= 23.5 || drow<-0.5; org: %f", drow, droworg)); | |
1338 | return; | |
1339 | } | |
1340 | if (sm >= nSMod || sm < 0) { | |
1341 | AliError(Form("Bad SM number sm=%d, where sm >= %d || sm < 0", nSMod, sm)); | |
1342 | return; | |
1343 | } | |
1344 | ||
1345 | istrip = int ((dcol+0.5)/2); | |
1346 | ||
1347 | // tapering angle | |
1348 | teta1 = TMath::DegToRad() * istrip * 1.5; | |
1349 | ||
1350 | // calculation of module corner along z | |
1351 | // as a function of strip | |
1352 | ||
1353 | for (int is=0; is<= istrip; is++) { | |
1354 | ||
1355 | teta1 = TMath::DegToRad() * (is*1.5 + 0.75); | |
1356 | if(is==0) | |
bccc4a4f | 1357 | zIs = zIs + 2*dz*TMath::Cos(teta1); |
e8c0d6bb | 1358 | else |
bccc4a4f | 1359 | zIs = zIs + 2*dz*TMath::Cos(teta1) + 2*dz*TMath::Sin(teta1)*TMath::Tan(teta1-0.75*TMath::DegToRad()); |
e8c0d6bb | 1360 | |
1361 | } | |
1362 | ||
1363 | z0 = dz*(dcol-2*istrip+0.5); | |
1364 | zb = (2*dz-z0-depth*TMath::Tan(teta1)); | |
1365 | ||
bccc4a4f | 1366 | z = zIs - zb*TMath::Cos(teta1); |
e8c0d6bb | 1367 | y = depth/TMath::Cos(teta1) + zb*TMath::Sin(teta1); |
1368 | ||
1369 | x = (drow + 0.5)*dx; | |
1370 | ||
1371 | // moving the origin from terry's RF | |
1372 | // to the GEANT one | |
1373 | ||
1374 | double xx = y - geoBox[sm]->GetDX(); | |
1375 | double yy = -x + geoBox[sm]->GetDY(); | |
1376 | double zz = z - geoBox[sm]->GetDZ(); | |
1377 | const double localIn[3] = {xx, yy, zz}; | |
1378 | double dglobal[3]; | |
1379 | //geoSMMatrix[sm]->Print(); | |
1380 | //printf("TFF Local (row = %d, col = %d, x = %3.2f, y = %3.2f, z = %3.2f)\n", iroworg, icolorg, localIn[0], localIn[1], localIn[2]); | |
1381 | geoSMMatrix[sm]->LocalToMaster(localIn, dglobal); | |
1382 | //printf("TFF Global (row = %2.0f, col = %2.0f, x = %3.2f, y = %3.2f, z = %3.2f)\n", drow, dcol, dglobal[0], dglobal[1], dglobal[2]); | |
1383 | ||
1384 | //apply global shifts | |
1385 | if(sm == 2 || sm == 3) {//sector 1 | |
1386 | global[0] = dglobal[0] + misaligTransShifts[3] + misaligRotShifts[3]*TMath::Sin(TMath::DegToRad()*20) ; | |
1387 | global[1] = dglobal[1] + misaligTransShifts[4] + misaligRotShifts[4]*TMath::Cos(TMath::DegToRad()*20) ; | |
1388 | global[2] = dglobal[2] + misaligTransShifts[5]; | |
1389 | } | |
1390 | else if(sm == 0 || sm == 1){//sector 0 | |
1391 | global[0] = dglobal[0] + misaligTransShifts[0]; | |
1392 | global[1] = dglobal[1] + misaligTransShifts[1]; | |
1393 | global[2] = dglobal[2] + misaligTransShifts[2]; | |
1394 | } | |
1395 | else { | |
1396 | AliInfo("Careful, correction not implemented yet!"); | |
1397 | global[0] = dglobal[0] ; | |
1398 | global[1] = dglobal[1] ; | |
1399 | global[2] = dglobal[2] ; | |
1400 | } | |
e8c0d6bb | 1401 | } |
1402 | else{ | |
1403 | AliFatal("Geometry boxes information, check that geometry.root is loaded\n"); | |
1404 | } | |
e8c0d6bb | 1405 | } |
bccc4a4f | 1406 | |
8cc543cb | 1407 | //__________________________________________________________________________________________________________________ |
bccc4a4f | 1408 | void AliEMCALGeometry::SetMisalMatrix(const TGeoHMatrix * m, Int_t smod) |
1409 | { | |
e9edf555 | 1410 | // Method to set shift-rotational matrixes from ESDHeader |
1411 | // Move from header due to coding violations : Dec 2,2011 by PAI | |
bccc4a4f | 1412 | fUseExternalMatrices = kTRUE; |
1413 | ||
1414 | if (smod >= 0 && smod < fEMCGeometry->GetNumberOfSuperModules()){ | |
1415 | if(!fkSModuleMatrix[smod]) fkSModuleMatrix[smod] = new TGeoHMatrix(*m) ; //Set only if not set yet | |
1416 | } else AliFatal(Form("Wrong supermodule index -> %d",smod)); | |
1417 | } | |
8cc543cb | 1418 | |
1419 | //__________________________________________________________________________________________________________________ | |
1420 | Bool_t AliEMCALGeometry::IsDCALSM(Int_t iSupMod) const | |
1421 | { | |
1422 | if( fEMCSMSystem[iSupMod] == kDCAL_Standard || fEMCSMSystem[iSupMod] == kDCAL_Ext ) return kTRUE; | |
1423 | return kFALSE; | |
1424 | } | |
1425 | ||
1426 | //__________________________________________________________________________________________________________________ | |
1427 | Bool_t AliEMCALGeometry::IsDCALExtSM(Int_t iSupMod) const | |
1428 | { | |
1429 | if( fEMCSMSystem[iSupMod] == kDCAL_Ext ) return kTRUE; | |
1430 | return kFALSE; | |
1431 | } |