b13bbe81 |
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 | //_________________________________________________________________________ |
fdebddeb |
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 | //*-- |
b13bbe81 |
23 | //*-- Author: Sahal Yacoob (LBL /UCT) |
24 | //*-- : Jennifer Klay (LBL) |
fceb09ed |
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 | |
1f4d29d2 |
28 | // 15/02/2002 .... Yves Schutz |
29 | // 1. fSamplingFraction and fLayerToPreshowerRatio have been removed |
30 | // 2. Timing signal is collected and added to hit |
b13bbe81 |
31 | |
32 | // --- ROOT system --- |
fceb09ed |
33 | #include "TParticle.h" |
5d12ce38 |
34 | #include "TVirtualMC.h" |
b13bbe81 |
35 | |
36 | // --- Standard library --- |
37 | |
b13bbe81 |
38 | // --- AliRoot header files --- |
b13bbe81 |
39 | #include "AliEMCALv1.h" |
40 | #include "AliEMCALHit.h" |
41 | #include "AliEMCALGeometry.h" |
b13bbe81 |
42 | #include "AliRun.h" |
5d12ce38 |
43 | #include "AliMC.h" |
b13bbe81 |
44 | |
45 | ClassImp(AliEMCALv1) |
46 | |
47 | |
48 | //______________________________________________________________________ |
ab37d09c |
49 | AliEMCALv1::AliEMCALv1():AliEMCALv0(), fCurPrimary(-1), fCurParent(-1), fCurTrack(-1){ |
b13bbe81 |
50 | // ctor |
7b6cc0b5 |
51 | |
b13bbe81 |
52 | } |
1f4d29d2 |
53 | |
b13bbe81 |
54 | //______________________________________________________________________ |
55 | AliEMCALv1::AliEMCALv1(const char *name, const char *title): |
ab37d09c |
56 | AliEMCALv0(name,title), fCurPrimary(-1), fCurParent(-1), fCurTrack(-1) { |
b13bbe81 |
57 | // Standard Creator. |
58 | |
59 | fHits= new TClonesArray("AliEMCALHit",1000); |
5d12ce38 |
60 | gAlice->GetMCApp()->AddHitList(fHits); |
b13bbe81 |
61 | |
62 | fNhits = 0; |
fceb09ed |
63 | fIshunt = 2; // All hits are associated with particles entering the calorimeter |
9b358506 |
64 | fTimeCut = 30e-09; |
b13bbe81 |
65 | } |
1f4d29d2 |
66 | |
b13bbe81 |
67 | //______________________________________________________________________ |
68 | AliEMCALv1::~AliEMCALv1(){ |
69 | // dtor |
70 | |
71 | if ( fHits) { |
72 | fHits->Delete(); |
73 | delete fHits; |
74 | fHits = 0; |
75 | } |
76 | } |
ab37d09c |
77 | |
b13bbe81 |
78 | //______________________________________________________________________ |
61e0abb5 |
79 | void AliEMCALv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t iparent, Float_t ienergy, |
80 | Int_t id, Float_t * hits,Float_t * p){ |
b13bbe81 |
81 | // Add a hit to the hit list. |
fdebddeb |
82 | // An EMCAL hit is the sum of all hits in a tower section |
7b6cc0b5 |
83 | // originating from the same entering particle |
b13bbe81 |
84 | Int_t hitCounter; |
85 | |
86 | AliEMCALHit *newHit; |
87 | AliEMCALHit *curHit; |
88 | Bool_t deja = kFALSE; |
89 | |
61e0abb5 |
90 | newHit = new AliEMCALHit(shunt, primary, tracknumber, iparent, ienergy, id, hits, p); |
fdebddeb |
91 | for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) { |
b13bbe81 |
92 | curHit = (AliEMCALHit*) (*fHits)[hitCounter]; |
61e0abb5 |
93 | // We add hits with the same tracknumber, while GEANT treats |
b13bbe81 |
94 | // primaries succesively |
7b6cc0b5 |
95 | if(curHit->GetPrimary() != primary) |
96 | break; |
b13bbe81 |
97 | if( *curHit == *newHit ) { |
98 | *curHit = *curHit + *newHit; |
99 | deja = kTRUE; |
fdebddeb |
100 | } // end if |
b13bbe81 |
101 | } // end for hitCounter |
fdebddeb |
102 | |
b13bbe81 |
103 | if ( !deja ) { |
104 | new((*fHits)[fNhits]) AliEMCALHit(*newHit); |
105 | fNhits++; |
106 | } // end if |
107 | |
108 | delete newHit; |
109 | } |
110 | //______________________________________________________________________ |
111 | void AliEMCALv1::StepManager(void){ |
8ddf73e5 |
112 | // Accumulates hits as long as the track stays in a tower |
1f4d29d2 |
113 | |
fdebddeb |
114 | Int_t id[2]; // (phi, Eta) indices |
1f4d29d2 |
115 | // position wrt MRS and energy deposited |
116 | Float_t xyzte[5]={0.,0.,0.,0.,0.};// position wrt MRS, time and energy deposited |
117 | Float_t pmom[4]={0.,0.,0.,0.}; |
118 | TLorentzVector pos; // Lorentz vector of the track current position. |
119 | TLorentzVector mom; // Lorentz vector of the track current momentum. |
5d12ce38 |
120 | Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber(); |
1f4d29d2 |
121 | static Float_t ienergy = 0; |
122 | Int_t copy = 0; |
1f4d29d2 |
123 | |
05a92d59 |
124 | AliEMCALGeometry * geom = GetGeometry() ; |
125 | |
1f4d29d2 |
126 | if(gMC->CurrentVolID(copy) == gMC->VolId("XPHI") ) { // We are in a Scintillator Layer |
dfce7eb2 |
127 | Float_t depositedEnergy ; |
61e0abb5 |
128 | |
9b358506 |
129 | if( ((depositedEnergy = gMC->Edep()) > 0.) && (gMC->TrackTime() < fTimeCut)){// Track is inside a scintillator and deposits some energy |
ab37d09c |
130 | if (fCurPrimary==-1) |
131 | fCurPrimary=gAlice->GetMCApp()->GetPrimary(tracknumber); |
132 | |
133 | if (fCurParent==-1 || tracknumber != fCurTrack) { |
134 | // Check parentage |
135 | Int_t parent=tracknumber; |
136 | if (fCurParent != -1) { |
137 | while (parent != fCurParent && parent != -1) { |
138 | TParticle *part=gAlice->GetMCApp()->Particle(parent); |
139 | parent=part->GetFirstMother(); |
140 | } |
141 | } |
142 | if (fCurParent==-1 || parent==-1) { |
143 | Int_t parent=tracknumber; |
144 | TParticle *part=gAlice->GetMCApp()->Particle(parent); |
145 | while (parent != -1 && geom->IsInEMCAL(part->Vx(),part->Vy(),part->Vz())) { |
146 | parent=part->GetFirstMother(); |
147 | if (parent!=-1) |
148 | part=gAlice->GetMCApp()->Particle(parent); |
149 | } |
150 | fCurParent=parent; |
151 | if (fCurParent==-1) |
152 | Error("StepManager","Cannot find parent"); |
153 | else { |
154 | TParticle *part=gAlice->GetMCApp()->Particle(fCurParent); |
155 | ienergy = part->Energy(); |
156 | } |
157 | while (parent != -1) { |
158 | part=gAlice->GetMCApp()->Particle(parent); |
159 | part->SetBit(kKeepBit); |
160 | parent=part->GetFirstMother(); |
161 | } |
162 | } |
163 | fCurTrack=tracknumber; |
164 | } |
dfce7eb2 |
165 | gMC->TrackPosition(pos); |
166 | xyzte[0] = pos[0]; |
167 | xyzte[1] = pos[1]; |
168 | xyzte[2] = pos[2]; |
169 | xyzte[3] = gMC->TrackTime() ; |
170 | |
171 | gMC->TrackMomentum(mom); |
172 | pmom[0] = mom[0]; |
173 | pmom[1] = mom[1]; |
174 | pmom[2] = mom[2]; |
175 | pmom[3] = mom[3]; |
176 | |
177 | gMC->CurrentVolOffID(1, id[0]); // get the POLY copy number; |
178 | gMC->CurrentVolID(id[1]); // get the phi number inside the layer |
dfce7eb2 |
179 | |
de56e4f9 |
180 | Int_t tower = (id[0]-1) % geom->GetNZ() + 1 + (id[1] - 1) * geom->GetNZ() ; |
7b6cc0b5 |
181 | Int_t layer = static_cast<Int_t>((id[0]-1)/(geom->GetNZ())) + 1 ; |
fdebddeb |
182 | Int_t absid = tower; |
183 | Int_t nlayers = geom->GetNECLayers(); |
184 | if ((layer > nlayers)||(layer<1)) |
185 | Fatal("StepManager", "Wrong calculation of layer number: layer = %d > %d\n", layer, nlayers) ; |
186 | |
7b6cc0b5 |
187 | Float_t lightYield = depositedEnergy ; |
ab37d09c |
188 | // Apply Birk's law (copied from G3BIRK) |
189 | |
190 | if (gMC->TrackCharge()!=0) { // Check |
191 | Float_t BirkC1_mod = 0; |
192 | if (fBirkC0==1){ // Apply correction for higher charge states |
41289e86 |
193 | if (TMath::Abs(gMC->TrackCharge())>=2) |
ab37d09c |
194 | BirkC1_mod=fBirkC1*7.2/12.6; |
195 | else |
196 | BirkC1_mod=fBirkC1; |
197 | } |
198 | Float_t dedxcm; |
199 | if (gMC->TrackStep()>0) |
200 | dedxcm=1000.*gMC->Edep()/gMC->TrackStep(); |
201 | else |
202 | dedxcm=0; |
203 | lightYield=lightYield/(1.+BirkC1_mod*dedxcm+fBirkC2*dedxcm*dedxcm); |
204 | } |
7b6cc0b5 |
205 | |
ab37d09c |
206 | // use sampling fraction to get original energy --HG |
207 | xyzte[4] = lightYield * geom->GetSampling(); |
208 | |
7b6cc0b5 |
209 | if (gDebug == 2) |
fdebddeb |
210 | printf("StepManager: id0 = %d, id1 = %d, absid = %d tower = %d layer = %d energy = %f\n", id[0], id[1], absid, tower, layer, xyzte[4]) ; |
7b6cc0b5 |
211 | |
ab37d09c |
212 | AddHit(fIshunt, fCurPrimary,tracknumber, fCurParent, ienergy, absid, xyzte, pmom); |
b13bbe81 |
213 | } // there is deposited energy |
1f4d29d2 |
214 | } |
b13bbe81 |
215 | } |
ab37d09c |
216 | |
217 | void AliEMCALv1::RemapTrackHitIDs(Int_t *map) { |
218 | // remap track index numbers for primary and parent indices |
219 | // (Called by AliStack::PurifyKine) |
220 | if (Hits()==0) |
221 | return; |
222 | TIter hit_it(Hits()); |
223 | Int_t i_hit=0; |
224 | while (AliEMCALHit *hit=dynamic_cast<AliEMCALHit*>(hit_it()) ) { |
225 | if (map[hit->GetIparent()]==-99) |
226 | cout << "Remapping, found -99 for parent id " << hit->GetIparent() << ", " << map[hit->GetIparent()] << ", i_hit " << i_hit << endl; |
227 | hit->SetIparent(map[hit->GetIparent()]); |
228 | if (map[hit->GetPrimary()]==-99) |
229 | cout << "Remapping, found -99 for primary id " << hit->GetPrimary() << ", " << map[hit->GetPrimary()] << ", i_hit " << i_hit << endl; |
230 | hit->SetPrimary(map[hit->GetPrimary()]); |
231 | i_hit++; |
232 | } |
233 | } |
234 | |
235 | void AliEMCALv1::FinishPrimary() { |
236 | fCurPrimary=-1; |
237 | fCurParent=-1; |
238 | fCurTrack=-1; |
239 | } |