]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - EMCAL/AliEMCALv1.cxx
Updates in RAA error calculation (Zaida)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALv1.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18//_________________________________________________________________________
19//*-- Implementation version v1 of EMCAL Manager class
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//*--
23//*-- Author: Sahal Yacoob (LBL /UCT)
24//*-- : Jennifer Klay (LBL)
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
28// 15/02/2002 .... Yves Schutz
29// 1. fSamplingFraction and fLayerToPreshowerRatio have been removed
30// 2. Timing signal is collected and added to hit
31
32// --- ROOT system ---
33#include <TClonesArray.h>
34#include <TParticle.h>
35#include <TVirtualMC.h>
36
37// --- Standard library ---
38
39// --- AliRoot header files ---
40#include "AliEMCALv1.h"
41#include "AliEMCALHit.h"
42#include "AliEMCALGeometry.h"
43#include "AliRun.h"
44#include "AliMC.h"
45#include "AliStack.h"
46
47ClassImp(AliEMCALv1)
48
49
50//______________________________________________________________________
51AliEMCALv1::AliEMCALv1()
52 : AliEMCALv0(),
53 fCurPrimary(-1),
54 fCurParent(-1),
55 fCurTrack(-1),
56 fTimeCut(30e-09)
57{
58 // default ctor
59}
60
61//______________________________________________________________________
62AliEMCALv1::AliEMCALv1(const char *name, const char *title,
63 const Bool_t checkGeoAndRun)
64 : AliEMCALv0(name,title,checkGeoAndRun),
65 fCurPrimary(-1),
66 fCurParent(-1),
67 fCurTrack(-1),
68 fTimeCut(30e-09)
69{
70 // Standard Creator.
71
72 fHits= new TClonesArray("AliEMCALHit",1000);
73 // gAlice->GetMCApp()->AddHitList(fHits); // 20-dec-04 - advice of Andreas
74
75 fNhits = 0;
76 fIshunt = 2; // All hits are associated with particles entering the calorimeter
77}
78
79//______________________________________________________________________
80AliEMCALv1::~AliEMCALv1(){
81 // dtor
82
83 if ( fHits ) {
84 fHits->Clear();
85 delete fHits;
86 fHits = 0;
87 }
88}
89
90//______________________________________________________________________
91void AliEMCALv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t iparent, Float_t ienergy,
92 Int_t id, Float_t * hits,Float_t * p){
93 // Add a hit to the hit list.
94 // An EMCAL hit is the sum of all hits in a tower section
95 // originating from the same entering particle
96 Int_t hitCounter=0;
97
98 AliEMCALHit *newHit=0;
99 AliEMCALHit *curHit=0;
100 Bool_t deja = kFALSE;
101
102 newHit = new AliEMCALHit(shunt, primary, tracknumber, iparent, ienergy, id, hits, p);
103 for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) {
104 curHit = (AliEMCALHit*) (*fHits)[hitCounter];
105 // We add hits with the same tracknumber, while GEANT treats
106 // primaries succesively
107 if(curHit->GetPrimary() != primary)
108 break;
109 if( *curHit == *newHit ) {
110 *curHit = *curHit + *newHit;
111 deja = kTRUE;
112 } // end if
113 } // end for hitCounter
114
115 if ( !deja ) {
116 new((*fHits)[fNhits]) AliEMCALHit(*newHit);
117 fNhits++;
118 } // end if
119
120 delete newHit;
121}
122//______________________________________________________________________
123void AliEMCALv1::StepManager(void){
124 // Accumulates hits as long as the track stays in a tower
125
126 Int_t id[2]={0,0}; // (phi, Eta) indices
127 // position wrt MRS and energy deposited
128 Float_t xyzte[5]={0.,0.,0.,0.,0.};// position wrt MRS, time and energy deposited
129 Float_t pmom[4]={0.,0.,0.,0.};
130 TLorentzVector pos; // Lorentz vector of the track current position.
131 TLorentzVector mom; // Lorentz vector of the track current momentum.
132 Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber();
133 static Float_t ienergy = 0;
134 Int_t copy = 0;
135
136 AliEMCALGeometry * geom = GetGeometry() ;
137
138 TParticle *part=0;
139 Int_t parent=-1;
140
141 static Int_t idXPHI = gMC->VolId("XPHI");
142 if(gMC->CurrentVolID(copy) == idXPHI ) { // We are in a Scintillator Layer
143 Float_t depositedEnergy ;
144
145 if( ((depositedEnergy = gMC->Edep()) > 0.) && (gMC->TrackTime() < fTimeCut)){// Track is inside a scintillator and deposits some energy
146 if (fCurPrimary==-1)
147 fCurPrimary=gAlice->GetMCApp()->GetPrimary(tracknumber);
148
149 if (fCurParent==-1 || tracknumber != fCurTrack) {
150 // Check parentage
151 //Int_t parent=tracknumber;
152 parent=tracknumber;
153 if (fCurParent != -1) {
154 while (parent != fCurParent && parent != -1) {
155 //TParticle *part=gAlice->GetMCApp()->Particle(parent);
156 part=gAlice->GetMCApp()->Particle(parent);
157 parent=part->GetFirstMother();
158 }
159 }
160 if (fCurParent==-1 || parent==-1) {
161 //Int_t parent=tracknumber;
162 //TParticle *part=gAlice->GetMCApp()->Particle(parent);
163 parent=tracknumber;
164 part=gAlice->GetMCApp()->Particle(parent);
165 while (parent != -1 && geom->IsInEMCAL(part->Vx(),part->Vy(),part->Vz())) {
166 parent=part->GetFirstMother();
167 if (parent!=-1)
168 part=gAlice->GetMCApp()->Particle(parent);
169 }
170 fCurParent=parent;
171 if (fCurParent==-1)
172 Error("StepManager","Cannot find parent");
173 else {
174 //TParticle *part=gAlice->GetMCApp()->Particle(fCurParent);
175 part=gAlice->GetMCApp()->Particle(fCurParent);
176 ienergy = part->Energy();
177 }
178 while (parent != -1) {
179 part=gAlice->GetMCApp()->Particle(parent);
180 part->SetBit(kKeepBit);
181 parent=part->GetFirstMother();
182 }
183 }
184 fCurTrack=tracknumber;
185 }
186 gMC->TrackPosition(pos);
187 xyzte[0] = pos[0];
188 xyzte[1] = pos[1];
189 xyzte[2] = pos[2];
190 xyzte[3] = gMC->TrackTime() ;
191
192 gMC->TrackMomentum(mom);
193 pmom[0] = mom[0];
194 pmom[1] = mom[1];
195 pmom[2] = mom[2];
196 pmom[3] = mom[3];
197
198 gMC->CurrentVolOffID(1, id[0]); // get the POLY copy number;
199 gMC->CurrentVolID(id[1]); // get the phi number inside the layer
200
201 Int_t tower = (id[0]-1) % geom->GetNZ() + 1 + (id[1] - 1) * geom->GetNZ() ;
202 Int_t layer = static_cast<Int_t>((id[0]-1)/(geom->GetNZ())) + 1 ;
203 Int_t absid = tower;
204 Int_t nlayers = geom->GetNECLayers();
205 if ((layer > nlayers)||(layer<1))
206 Fatal("StepManager", "Wrong calculation of layer number: layer = %d > %d\n", layer, nlayers) ;
207
208 Float_t lightYield = depositedEnergy ;
209 // Apply Birk's law (copied from G3BIRK)
210
211 if (gMC->TrackCharge()!=0) { // Check
212 Float_t birkC1Mod = 0;
213 if (fBirkC0==1){ // Apply correction for higher charge states
214 if (TMath::Abs(gMC->TrackCharge())>=2)
215 birkC1Mod=fBirkC1*7.2/12.6;
216 else
217 birkC1Mod=fBirkC1;
218 }
219 Float_t dedxcm=0.;
220 if (gMC->TrackStep()>0)
221 dedxcm=1000.*gMC->Edep()/gMC->TrackStep();
222 else
223 dedxcm=0;
224 lightYield=lightYield/(1.+birkC1Mod*dedxcm+fBirkC2*dedxcm*dedxcm);
225 }
226
227 // use sampling fraction to get original energy --HG
228 xyzte[4] = lightYield * geom->GetSampling();
229
230 if (gDebug == 2)
231 printf("StepManager: id0 = %d, id1 = %d, absid = %d tower = %d layer = %d energy = %f\n", id[0], id[1], absid, tower, layer, xyzte[4]) ;
232
233 AddHit(fIshunt, fCurPrimary,tracknumber, fCurParent, ienergy, absid, xyzte, pmom);
234 } // there is deposited energy
235 }
236}
237
238//___________________________________________________________
239void AliEMCALv1::RemapTrackHitIDs(Int_t *map) {
240 // remap track index numbers for primary and parent indices
241 // (Called by AliStack::PurifyKine)
242 if (Hits()==0)
243 return;
244 TIter hitIter(Hits());
245 Int_t iHit=0;
246 while (AliEMCALHit *hit=dynamic_cast<AliEMCALHit*>(hitIter()) ) {
247 if (map[hit->GetIparent()]==-99)
248 cout << "Remapping, found -99 for parent id " << hit->GetIparent() << ", " << map[hit->GetIparent()] << ", iHit " << iHit << endl;
249 hit->SetIparent(map[hit->GetIparent()]);
250 if (map[hit->GetPrimary()]==-99)
251 cout << "Remapping, found -99 for primary id " << hit->GetPrimary() << ", " << map[hit->GetPrimary()] << ", iHit " << iHit << endl;
252 hit->SetPrimary(map[hit->GetPrimary()]);
253 iHit++;
254 }
255}
256
257//___________________________________________________________
258void AliEMCALv1::FinishPrimary() {
259 // finish primary
260 fCurPrimary=-1;
261 fCurParent=-1;
262 fCurTrack=-1;
263}