]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALv2.cxx
Split dEdxUtils into dEdxBaseUtils, dEdxCalibUtils, dEdxReconUtils and one CalibHistA...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALv2.cxx
CommitLineData
1963b290 1/**************************************************************************
2 * Copyright(c) 1998-2004, 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//_________________________________________________________________________
d87bd045 19//*-- Implementation version v2 of EMCAL Manager class; SHASHLYK version
1963b290 20//*-- An object of this class does not produce digits
21//*-- It is the one to use if you do want to produce outputs in TREEH
22//*--
3d841a9f 23//*-- Author : Alexei Pavlinov (WSU)
d87bd045 24
1963b290 25// This Class not stores information on all particles prior to EMCAL entry - in order to facilitate analysis.
26// This is done by setting fIShunt =2, and flagging all parents of particles entering the EMCAL.
27
7dd95fbf 28#include <cassert>
1963b290 29// --- ROOT system ---
cde6a23d 30#include <TBrowser.h>
7ca4655f 31#include <TClonesArray.h>
cde6a23d 32#include <TH2.h>
7ca4655f 33#include <TParticle.h>
a1e17193 34#include <TROOT.h>
7ca4655f 35#include <TVirtualMC.h>
1963b290 36
37// --- Standard library ---
38
39// --- AliRoot header files ---
40#include "AliEMCALv2.h"
41#include "AliEMCALHit.h"
42#include "AliEMCALGeometry.h"
43#include "AliRun.h"
44#include "AliHeader.h"
45#include "AliMC.h"
5bf6eb16 46#include "AliStack.h"
6c62c273 47#include "AliTrackReference.h"
dc7da436 48// for TRD1 case only; May 31,2006
1963b290 49
50ClassImp(AliEMCALv2)
51
1963b290 52//______________________________________________________________________
18a21c7c 53AliEMCALv2::AliEMCALv2()
ab6a174f 54 : AliEMCALv1()
18a21c7c 55{
1963b290 56 // ctor
1963b290 57}
58
59//______________________________________________________________________
28135539 60AliEMCALv2::AliEMCALv2(const char *name, const char *title,
61 const Bool_t checkGeoAndRun)
62 : AliEMCALv1(name,title,checkGeoAndRun)
18a21c7c 63{
1963b290 64 // Standard Creator.
65
96d5ea0d 66 //fHits= new TClonesArray("AliEMCALHit",1000); //Already done in ctor of v1
1963b290 67 gAlice->GetMCApp()->AddHitList(fHits);
68
69 fNhits = 0;
70 fIshunt = 2; // All hits are associated with particles entering the calorimeter
71 fTimeCut = 30e-09;
28135539 72
73 printf("Geo %s, check %d \n", title, checkGeoAndRun );
1963b290 74 fGeometry = GetGeometry();
1963b290 75}
76
77//______________________________________________________________________
78AliEMCALv2::~AliEMCALv2(){
79 // dtor
80
96d5ea0d 81 //Already done in dtor of v1
82// if ( fHits ) {
83// fHits->Clear();
84// delete fHits;
85// fHits = 0;
86// }
1963b290 87}
88
89//______________________________________________________________________
90void AliEMCALv2::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t iparent, Float_t ienergy,
91 Int_t id, Float_t * hits,Float_t * p){
92 // Add a hit to the hit list.
93 // An EMCAL hit is the sum of all hits in a tower section
94 // originating from the same entering particle
80b68f94 95 static Int_t hitCounter;
96 static AliEMCALHit *newHit, *curHit;
97 static Bool_t deja ;
98
99 deja = kFALSE;
1963b290 100
101 newHit = new AliEMCALHit(shunt, primary, tracknumber, iparent, ienergy, id, hits, p);
102 for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) {
103 curHit = (AliEMCALHit*) (*fHits)[hitCounter];
104 // We add hits with the same tracknumber, while GEANT treats
105 // primaries succesively
106 if(curHit->GetPrimary() != primary)
107 break;
108 if( *curHit == *newHit ) {
109 *curHit = *curHit + *newHit;
110 deja = kTRUE;
111 // break; // 30-aug-04 by PAI
112 } // end if
113 } // end for hitCounter
114
115 if ( !deja ) {
116 new((*fHits)[fNhits]) AliEMCALHit(*newHit);
117 fNhits++;
118 }
119 // printf(" fNhits %i \n", fNhits);
120 delete newHit;
121}
d297ef6e 122
1963b290 123//______________________________________________________________________
124void AliEMCALv2::StepManager(void){
125 // Accumulates hits as long as the track stays in a tower
126
127 // position wrt MRS and energy deposited
128 static Float_t xyzte[5]={0.,0.,0.,0.,0.};// position wrt MRS, time and energy deposited
129 static Float_t pmom[4]={0.,0.,0.,0.};
d25f2c54 130 static TLorentzVector pos; // Lorentz vector of the track current position.
131 static TLorentzVector mom; // Lorentz vector of the track current momentum.
132 static Float_t ienergy = 0; // part->Energy();
53e430a3 133 static TString curVolName="";
134 static int supModuleNumber=-1, moduleNumber=-1, yNumber=-1, xNumber=-1, absid=-1;
d297ef6e 135 static int keyGeom=1; //real TRD1 geometry
a6e0ebfe 136 static const char *vn = "SCMX"; // Apr 13, 2006 - only TRD1 case now
1963b290 137 static int nSMOP[7]={1,3,5,7,9,11}; // 30-mar-05
138 static int nSMON[7]={2,4,6,8,10,12};
139 static Float_t depositedEnergy=0.0;
140
141 if(keyGeom == 0) {
142 keyGeom = 2;
143 if(gMC->VolId("PBMO")==0 || gMC->VolId("WSUC")==1) {
144 vn = "SCMX"; // old TRD2(TRD1) or WSUC
145 keyGeom = 1;
146 }
147 printf("AliEMCALv2::StepManager(): keyGeom %i : Sensetive volume %s \n",
148 keyGeom, vn);
149 if(gMC->VolId("WSUC")==1) printf(" WSUC - cosmic ray stand geometry \n");
150 }
151 Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber();
53e430a3 152 Int_t parent=0;
153 TParticle* part=0;
1963b290 154
155 curVolName = gMC->CurrentVolName();
1d46d1f6 156 if(curVolName.Contains(vn) || curVolName.Contains("SCX")) { // We are in a scintillator layer; SCX for 3X3
1963b290 157
158 if( ((depositedEnergy = gMC->Edep()) > 0.) && (gMC->TrackTime() < fTimeCut)){// Track is inside a scintillator and deposits some energy
159 // Info("StepManager "," entry %i DE %f",++ientry, depositedEnergy); // for testing
160 if (fCurPrimary==-1)
161 fCurPrimary=gAlice->GetMCApp()->GetPrimary(tracknumber);
162
163 if (fCurParent==-1 || tracknumber != fCurTrack) {
164 // Check parentage
e63c78ba 165 parent=tracknumber;
6c62c273 166
1963b290 167 if (fCurParent != -1) {
168 while (parent != fCurParent && parent != -1) {
e63c78ba 169 //TParticle *part=gAlice->GetMCApp()->Particle(parent);
170 part=gAlice->GetMCApp()->Particle(parent);
1963b290 171 parent=part->GetFirstMother();
172 }
173 }
174 if (fCurParent==-1 || parent==-1) {
e63c78ba 175 //Int_t parent=tracknumber;
176 //TParticle *part=gAlice->GetMCApp()->Particle(parent);
177 parent=tracknumber;
178 part=gAlice->GetMCApp()->Particle(parent);
1963b290 179 while (parent != -1 && fGeometry->IsInEMCAL(part->Vx(),part->Vy(),part->Vz())) {
180 parent=part->GetFirstMother();
181 if (parent!=-1)
182 part=gAlice->GetMCApp()->Particle(parent);
183 }
184 fCurParent=parent;
185 if (fCurParent==-1)
186 Error("StepManager","Cannot find parent");
187 else {
e63c78ba 188 //TParticle *part=gAlice->GetMCApp()->Particle(fCurParent);
189 part=gAlice->GetMCApp()->Particle(fCurParent);
1963b290 190 ienergy = part->Energy();
6c62c273 191
192 //Add reference to parent in TR tree.
193 AddTrackReference(tracknumber, AliTrackReference::kEMCAL);
194
1963b290 195 }
196 while (parent != -1) {
197 part=gAlice->GetMCApp()->Particle(parent);
198 part->SetBit(kKeepBit);
199 parent=part->GetFirstMother();
200 }
201 }
202 fCurTrack=tracknumber;
203 }
204 gMC->TrackPosition(pos);
205 xyzte[0] = pos[0];
206 xyzte[1] = pos[1];
207 xyzte[2] = pos[2];
208 xyzte[3] = gMC->TrackTime() ;
209
210 gMC->TrackMomentum(mom);
211 pmom[0] = mom[0];
212 pmom[1] = mom[1];
213 pmom[2] = mom[2];
214 pmom[3] = mom[3];
215
216 // if(ientry%200 > 0) return; // testing
217 supModuleNumber = moduleNumber = yNumber = xNumber = absid = 0;
d25f2c54 218 if(keyGeom >= 1) { // TRD1 case now
1963b290 219 gMC->CurrentVolOffID(4, supModuleNumber);
220 gMC->CurrentVolOffID(3, moduleNumber);
221 gMC->CurrentVolOffID(1, yNumber);
222 gMC->CurrentVolOffID(0, xNumber); // really x number now
d87bd045 223 if(strcmp(gMC->CurrentVolOffName(4),"SM10")==0) supModuleNumber += 10; // 13-oct-05
a520bcd0 224 if(strcmp(gMC->CurrentVolOffName(4),"SM3rd")==0) supModuleNumber += 10; // 1-feb-12
1d46d1f6 225 // Nov 10,2006
d25f2c54 226 if(strcmp(gMC->CurrentVolOffName(0),vn) != 0) { // 3X3 case
227 if (strcmp(gMC->CurrentVolOffName(0),"SCX1")==0) xNumber=1;
228 else if(strcmp(gMC->CurrentVolOffName(0),"SCX2")==0) xNumber=2;
229 else if(strcmp(gMC->CurrentVolOffName(0),"SCX3")==0) xNumber=3;
6c62c273 230 else Fatal("StepManager()", "Wrong name of sensitive volume in 3X3 case : %s ", gMC->CurrentVolOffName(0));
1d46d1f6 231 }
1963b290 232 } else {
233 gMC->CurrentVolOffID(5, supModuleNumber);
234 gMC->CurrentVolOffID(4, moduleNumber);
235 gMC->CurrentVolOffID(1, yNumber);
d87bd045 236 gMC->CurrentVolOffID(0, xNumber);
237 if (strcmp(gMC->CurrentVolOffName(5),"SMOP")==0) supModuleNumber = nSMOP[supModuleNumber-1];
1963b290 238 else if(strcmp(gMC->CurrentVolOffName(5),"SMON")==0) supModuleNumber = nSMON[supModuleNumber-1];
239 else assert(0); // something wrong
240 }
c694fff1 241
242 // Due to problem with index ordering conventions the calcultation of absid is no more like this:
243 //absid = fGeometry->GetAbsCellId(smNumber, moduleNumber-1, yNumber-1, xNumber-1);
244
245 //Swap A side in Phi and C side in Eta due to wrong indexing.
246 Int_t iphi = -1;
247 Int_t ieta = -1;
248 Int_t smNumber = supModuleNumber-1;
249 Int_t smType = 1;
250 fGeometry->GetCellPhiEtaIndexInSModule(smNumber,moduleNumber-1,yNumber-1,xNumber-1, iphi, ieta);
251 if (smNumber%2 == 0) {
252 ieta = ((fGeometry->GetCentersOfCellsEtaDir()).GetSize()-1)-ieta;// 47-ieta, revert the ordering on A side in order to keep convention.
253 }
254 else {
a520bcd0 255 if(smNumber >= 10 && strcmp(gMC->CurrentVolOffName(4),"SM10")==0) smType = 2 ; //half supermodule. previous design/idea
256 if(smNumber >= 10 && strcmp(gMC->CurrentVolOffName(4),"SM3rd")==0) smType = 3 ; //one third (installed in 2012) supermodule
c694fff1 257 iphi= ((fGeometry->GetCentersOfCellsPhiDir()).GetSize()/smType-1)-iphi;//23-iphi, revert the ordering on C side in order to keep convention.
258 }
259
260 //Once we know the indexes, calculate the absolute ID
261 absid = fGeometry->GetAbsCellIdFromCellIndexes(smNumber, iphi, ieta);
262
1d46d1f6 263 if (absid < 0) {
264 printf(" supModuleNumber %i : moduleNumber %i : yNumber %i : xNumber %i \n",
c694fff1 265 supModuleNumber, moduleNumber, yNumber, xNumber);
1d46d1f6 266 Fatal("StepManager()", "Wrong id : %i ", absid) ;
267 }
1963b290 268
269 Float_t lightYield = depositedEnergy ;
270 // Apply Birk's law (copied from G3BIRK)
271
272 if (gMC->TrackCharge()!=0) { // Check
cde6a23d 273 Float_t birkC1Mod = 0;
1963b290 274 if (fBirkC0==1){ // Apply correction for higher charge states
cde6a23d 275 if (TMath::Abs(gMC->TrackCharge())>=2) birkC1Mod = fBirkC1*7.2/12.6;
276 else birkC1Mod = fBirkC1;
1963b290 277 }
278
53e430a3 279 Float_t dedxcm=0.;
1963b290 280 if (gMC->TrackStep()>0) dedxcm=1000.*gMC->Edep()/gMC->TrackStep();
281 else dedxcm=0;
cde6a23d 282 lightYield=lightYield/(1.+birkC1Mod*dedxcm+fBirkC2*dedxcm*dedxcm);
1963b290 283 }
284
285 // use sampling fraction to get original energy --HG
286 // xyzte[4] = lightYield * fGeometry->GetSampling();
287 xyzte[4] = lightYield; // 15-dec-04
288
289 if (gDebug == -2)
290 printf("#sm %2i #m %3i #x %1i #z %1i -> absid %i : xyzte[4] = %f\n",
291 supModuleNumber,moduleNumber,yNumber,xNumber,absid, xyzte[4]);
292
293 AddHit(fIshunt, fCurPrimary,tracknumber, fCurParent, ienergy, absid, xyzte, pmom);
294 } // there is deposited energy
295 }
296}