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