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