]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALGeometry.cxx
Coverity corrections.
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGeometry.cxx
CommitLineData
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//_________________________________________________________________________
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//
43// EMCAL_COMPLETEV1: Same fixes as FIRSTYEAR and 10 SM instead of 10+2 half SM
3d841a9f 44//
d297ef6e 45// EMCAL_WSUC (Wayne State test stand)
46// = no definite equivalent in old notation, was only used by
47// Aleksei, but kept for testing purposes
48//
49// etc.
50//
51//
52//
b13bbe81 53//*-- Author: Sahal Yacoob (LBL / UCT)
54// and : Yves Schutz (SUBATECH)
55// and : Jennifer Klay (LBL)
3d841a9f 56// and : Alexei Pavlinov (WSU)
1d46d1f6 57//
090026bf 58
0c5b726e 59//--- Root header files ---
1ae500a2 60#include <TVector2.h>
090026bf 61#include <TVector3.h>
0c5b726e 62//-- ALICE Headers.
e5a93224 63#include "AliLog.h"
173558f2 64
0c5b726e 65// // --- EMCAL headers
ca8f5bd0 66#include "AliEMCALGeometry.h"
e52475ed 67#include "AliEMCALShishKebabTrd1Module.h"
2ebdefe6 68//#include "AliEMCALRecPoint.h"
0c5b726e 69//#include "AliEMCALHistoUtilities.h"
2012850d 70
925e6570 71ClassImp(AliEMCALGeometry)
2012850d 72
d434833b 73// these initialisations are needed for a singleton
74AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0;
171d2441 75const Char_t* AliEMCALGeometry::fgkDefaultGeometryName = "EMCAL_COMPLETEV1";
89557f6d 76//
77// Usage:
78// You can create the AliEMCALGeometry object independently from anything.
79// You have to use just the correct name of geometry. If name is empty string the
80// default name of geometry will be used.
81//
82// AliEMCALGeometry* g = AliEMCALGeometry::GetInstance(name,title); // first time
83// ..
84// g = AliEMCALGeometry::GetInstance(); // after first time
85//
76855a3c 86// MC: If you work with MC data you have to get geometry the next way:
87// == =============================
33c3c91a 88// AliRunLoader *rl = AliRunLoader::Instance();
d297ef6e 89// AliEMCALGeometry *geom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
90// TGeoManager::Import("geometry.root");
dc7da436 91
9cff4509 92AliEMCALGeometry::AliEMCALGeometry()
0c5b726e 93 : AliEMCALGeoUtils()
dc7da436 94{
95 // default ctor only for internal usage (singleton)
937d0661 96 // must be kept public for root persistency purposes,
97 // but should never be called by the outside world
98
dc7da436 99 AliDebug(2, "AliEMCALGeometry : default ctor ");
100}
101//______________________________________________________________________
9cff4509 102AliEMCALGeometry::AliEMCALGeometry(const Text_t* name, const Text_t* title)
0c5b726e 103 : AliEMCALGeoUtils(name, title)
9cff4509 104{
105 // ctor only for internal usage (singleton)
dc7da436 106 AliDebug(2, Form("AliEMCALGeometry(%s,%s) ", name,title));
1d46d1f6 107
dc7da436 108}
0a4cb131 109//______________________________________________________________________
9cff4509 110AliEMCALGeometry::AliEMCALGeometry(const AliEMCALGeometry& geom)
0c5b726e 111 : AliEMCALGeoUtils(geom)
9cff4509 112{
0a4cb131 113 //copy ctor
0a4cb131 114}
115
b13bbe81 116//______________________________________________________________________
117AliEMCALGeometry::~AliEMCALGeometry(void){
118 // dtor
2012850d 119}
d297ef6e 120
f0377b23 121
b13bbe81 122//______________________________________________________________________
123AliEMCALGeometry * AliEMCALGeometry::GetInstance(){
05a92d59 124 // Returns the pointer of the unique instance
125
e52475ed 126 AliEMCALGeometry * rv = static_cast<AliEMCALGeometry *>( fgGeom );
127 return rv;
2012850d 128}
173558f2 129
b13bbe81 130//______________________________________________________________________
131AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name,
132 const Text_t* title){
133 // Returns the pointer of the unique instance
134
135 AliEMCALGeometry * rv = 0;
136 if ( fgGeom == 0 ) {
89557f6d 137 if ( strcmp(name,"") == 0 ) { // get default geometry
0c5b726e 138 fgGeom = new AliEMCALGeometry(fgkDefaultGeometryName, title);
89557f6d 139 } else {
140 fgGeom = new AliEMCALGeometry(name, title);
141 } // end if strcmp(name,"")
0c5b726e 142 if ( AliEMCALEMCGeometry::fgInit ) rv = (AliEMCALGeometry * ) fgGeom;
89557f6d 143 else {
144 rv = 0;
145 delete fgGeom;
146 fgGeom = 0;
147 } // end if fgInit
b13bbe81 148 }else{
e5a93224 149 if ( strcmp(fgGeom->GetName(), name) != 0) {
87926378 150 printf("\ncurrent geometry is %s : ", fgGeom->GetName());
151 printf(" you cannot call %s ",name);
b13bbe81 152 }else{
9859bfc0 153 rv = (AliEMCALGeometry *) fgGeom;
e52475ed 154 } // end
b13bbe81 155 } // end if fgGeom
156 return rv;
2012850d 157}
173558f2 158
d297ef6e 159//________________________________________________________________________________________________
1ae500a2 160Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t distEff, Double_t &xr, Double_t &yr, Double_t &zr) const
161{
162 // Jul 30, 2007 - taking into account position of shower max
163 // Look to see what the relative
164 // position inside a given cell is
165 // for a recpoint.
166 // In:
167 // absId - cell is as in Geant, 0<= absId < fNCells;
168 // e - cluster energy
169 // OUT:
170 // xr,yr,zr - x,y,z coordinates of cell with absId inside SM
171
172 // Shift index taking into account the difference between standard SM
173 // and SM of half size in phi direction
37890aaf 174 const Int_t kphiIndexShift = fCentersOfCellsPhiDir.GetSize()/4; // Nov 22, 2006; was 6 for cas 2X2
53e430a3 175 static Int_t nSupMod=0, nModule=-1, nIphi=-1, nIeta=-1, iphi=-1, ieta=-1;
176 static Int_t iphim=-1, ietam=-1;
1ae500a2 177 static AliEMCALShishKebabTrd1Module *mod = 0;
178 static TVector2 v;
179 if(!CheckAbsCellId(absId)) return kFALSE;
c694fff1 180
1ae500a2 181 GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
182 GetModulePhiEtaIndexInSModule(nSupMod, nModule, iphim, ietam);
183 GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta);
c694fff1 184
185 //Get eta position. Careful with ALICE conventions (increase index decrease eta)
186 if(nSupMod%2 == 0) {
187 ietam = (fCentersOfCellsEtaDir.GetSize()/2-1)-ietam;// 47-ietam, revert the ordering on A side in order to keep convention.
188 if(nIeta == 0) nIeta = 1;
189 else nIeta = 0;
190 }
1ae500a2 191 mod = GetShishKebabModule(ietam);
c694fff1 192 mod ->GetPositionAtCenterCellLine(nIeta, distEff, v);
1ae500a2 193 xr = v.Y() - fParSM[0];
194 zr = v.X() - fParSM[2];
c694fff1 195
196 //Get phi position. Careful with ALICE conventions (increase index increase phi)
197 Int_t iphi2 = iphi;
198 if(nSupMod<10) {
199 if(nSupMod%2 != 0)
200 iphi2 = (fCentersOfCellsPhiDir.GetSize()-1)-iphi;// 23-iphi, revert the ordering on C side in order to keep convention.
201 yr = fCentersOfCellsPhiDir.At(iphi2);
202
1ae500a2 203 } else {
c694fff1 204 if(nSupMod%2 != 0)
205 iphi2 = (fCentersOfCellsPhiDir.GetSize()/2-1)-iphi;// 11-iphi, revert the ordering on C side in order to keep convention.
206 yr = fCentersOfCellsPhiDir.At(iphi2 + kphiIndexShift);
1ae500a2 207 }
c694fff1 208
1ae500a2 209 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 210
1ae500a2 211 return kTRUE;
212}
213
7cfcebd3 214//Not in use, comment for the moment
d297ef6e 215//________________________________________________________________________________________________
7cfcebd3 216//Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Int_t maxAbsId, Double_t distEff, Double_t &xr, Double_t &yr, Double_t &zr) const
217//{
218// // Jul 31, 2007 - taking into account position of shower max and apply coor2.
219// // Look to see what the relative
220// // position inside a given cell is
221// // for a recpoint.
222// // In:
223// // absId - cell is as in Geant, 0<= absId < fNCells;
224// // maxAbsId - abs id of cell with highest energy
225// // e - cluster energy
226// // OUT:
227// // xr,yr,zr - x,y,z coordinates of cell with absId inside SM
228//
229// // Shift index taking into account the difference between standard SM
230// // and SM of half size in phi direction
231// const Int_t kphiIndexShift = fCentersOfCellsPhiDir.GetSize()/4; // Nov 22, 2006; was 6 for cas 2X2
232// static Int_t nSupMod, nModule, nIphi, nIeta, iphi, ieta;
233// static Int_t iphim, ietam;
234// static AliEMCALShishKebabTrd1Module *mod = 0;
235// static TVector2 v;
236//
237// static Int_t nSupModM, nModuleM, nIphiM, nIetaM, iphiM, ietaM;
238// static Int_t iphimM, ietamM, maxAbsIdCopy=-1;
239// static AliEMCALShishKebabTrd1Module *modM = 0;
240// static Double_t distCorr;
241//
242// if(!CheckAbsCellId(absId)) return kFALSE;
243//
244// GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
245// GetModulePhiEtaIndexInSModule(nSupMod, nModule, iphim, ietam);
246// GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi, ieta);
247//
248// //Get eta position. Careful with ALICE conventions (increase index decrease eta)
249// if(nSupMod%2 == 0) {
250// ietam = (fCentersOfCellsEtaDir.GetSize()/2-1)-ietam;// 23-ietam, revert the ordering on A side in order to keep convention.
251// if(nIeta == 0) nIeta = 1;
252// else nIeta = 0;
253// }
254//
255// mod = GetShishKebabModule(ietam);
256//
257// if(absId != maxAbsId) {
258// distCorr = 0.;
259// if(maxAbsIdCopy != maxAbsId) {
260// GetCellIndex(maxAbsId, nSupModM, nModuleM, nIphiM, nIetaM);
261// GetModulePhiEtaIndexInSModule(nSupModM, nModuleM, iphimM, ietamM);
262// GetCellPhiEtaIndexInSModule(nSupModM,nModuleM,nIphiM,nIetaM, iphiM, ietaM);
263// //Careful with ALICE conventions (increase index decrease eta)
264// if(nSupModM%2 == 0) {
265// ietamM = (fCentersOfCellsEtaDir.GetSize()/2-1)-ietamM;// 47-ietam, revert the ordering on A side in order to keep convention.
266// }
267//
268// modM = GetShishKebabModule(ietamM); // do I need this ?
269// maxAbsIdCopy = maxAbsId;
270// }
271//
272// if(ietamM !=0) {
273// distCorr = fEMCGeometry->GetEtaModuleSize()*(ietam-ietamM)/TMath::Tan(modM->GetTheta()); // Stay here
274// //printf(" distCorr %f | dist %f | ietam %i -> etamM %i\n", distCorr, dist, ietam, ietamM);
275// }
276// // distEff += distCorr;
277// }
278// // Bad resolution in this case, strong bias vs phi
279// // distEff = 0.0;
280// mod->GetPositionAtCenterCellLine(nIeta, distEff, v); // Stay here
281// xr = v.Y() - fParSM[0];
282// zr = v.X() - fParSM[2];
283//
284// //Get phi position. Careful with ALICE conventions (increase index increase phi)
285// Int_t iphi2 = iphi;
286// if(nSupMod<10) {
287// if(nSupMod%2 != 0)
288// iphi2 = (fCentersOfCellsPhiDir.GetSize()-1)-iphi;// 23-iphi, revert the ordering on C side in order to keep convention.
289// yr = fCentersOfCellsPhiDir.At(iphi2);
290//
291// } else {
292// if(nSupMod%2 != 0)
293// iphi2 = (fCentersOfCellsPhiDir.GetSize()/2-1)-iphi;// 11-iphi, revert the ordering on C side in order to keep convention.
294// yr = fCentersOfCellsPhiDir.At(iphi2 + kphiIndexShift);
295// }
296// AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr));
297//
298// return kTRUE;
299//}
300//
1d46d1f6 301
0c5b726e 302//
303// == Shish-kebab cases ==
304//
14e75ea7 305
7cfcebd3 306//
307////_________________________________________________________________________________
308//void AliEMCALGeometry::GetGlobalEMCAL(const AliEMCALRecPoint *rp, TVector3 &vglob) const
309//{
310// // Figure out the global numbering
311// // of a given supermodule from the
312// // local numbering for RecPoints
313//
314// static TVector3 vloc;
315// static Int_t nSupMod, nModule, nIphi, nIeta;
316//
317// const AliEMCALRecPoint *rpTmp = rp;
318// const AliEMCALRecPoint *rpEmc = rpTmp;
319//
320// GetCellIndex(rpEmc->GetAbsId(0), nSupMod, nModule, nIphi, nIeta);
321// rpTmp->GetLocalPosition(vloc);
322// GetGlobal(vloc, vglob, nSupMod);
323//}
e52475ed 324