]>
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 | //_________________________________________________________________________ | |
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 | ||
fceb09ed | 26 | // This Class not stores information on all particles prior to EMCAL entry - in order to facilitate analysis. |
27 | // This is done by setting fIShunt =2, and flagging all parents of particles entering the EMCAL. | |
28 | ||
1f4d29d2 | 29 | // 15/02/2002 .... Yves Schutz |
30 | // 1. fSamplingFraction and fLayerToPreshowerRatio have been removed | |
31 | // 2. Timing signal is collected and added to hit | |
b13bbe81 | 32 | |
33 | // --- ROOT system --- | |
34 | #include "TPGON.h" | |
35 | #include "TTUBS.h" | |
36 | #include "TNode.h" | |
37 | #include "TRandom.h" | |
38 | #include "TTree.h" | |
39 | #include "TGeometry.h" | |
fceb09ed | 40 | #include "TParticle.h" |
5d12ce38 | 41 | #include "TVirtualMC.h" |
b13bbe81 | 42 | |
43 | // --- Standard library --- | |
44 | ||
45 | #include <stdio.h> | |
46 | #include <string.h> | |
47 | #include <stdlib.h> | |
70479d0e | 48 | #include <Rstrstream.h> |
70479d0e | 49 | #include <Riostream.h> |
b13bbe81 | 50 | #include <math.h> |
173558f2 | 51 | |
b13bbe81 | 52 | // --- AliRoot header files --- |
53 | ||
54 | #include "AliEMCALv1.h" | |
55 | #include "AliEMCALHit.h" | |
56 | #include "AliEMCALGeometry.h" | |
57 | #include "AliConst.h" | |
58 | #include "AliRun.h" | |
5d12ce38 | 59 | #include "AliMC.h" |
b13bbe81 | 60 | |
61 | ClassImp(AliEMCALv1) | |
62 | ||
63 | ||
64 | //______________________________________________________________________ | |
65 | AliEMCALv1::AliEMCALv1():AliEMCALv0(){ | |
66 | // ctor | |
7b6cc0b5 | 67 | |
b13bbe81 | 68 | } |
1f4d29d2 | 69 | |
b13bbe81 | 70 | //______________________________________________________________________ |
71 | AliEMCALv1::AliEMCALv1(const char *name, const char *title): | |
72 | AliEMCALv0(name,title){ | |
73 | // Standard Creator. | |
74 | ||
75 | fHits= new TClonesArray("AliEMCALHit",1000); | |
5d12ce38 | 76 | gAlice->GetMCApp()->AddHitList(fHits); |
b13bbe81 | 77 | |
78 | fNhits = 0; | |
fceb09ed | 79 | fIshunt = 2; // All hits are associated with particles entering the calorimeter |
b13bbe81 | 80 | } |
1f4d29d2 | 81 | |
b13bbe81 | 82 | //______________________________________________________________________ |
83 | AliEMCALv1::~AliEMCALv1(){ | |
84 | // dtor | |
85 | ||
86 | if ( fHits) { | |
87 | fHits->Delete(); | |
88 | delete fHits; | |
89 | fHits = 0; | |
90 | } | |
91 | } | |
92 | //______________________________________________________________________ | |
61e0abb5 | 93 | void AliEMCALv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t iparent, Float_t ienergy, |
94 | Int_t id, Float_t * hits,Float_t * p){ | |
b13bbe81 | 95 | // Add a hit to the hit list. |
7b6cc0b5 | 96 | // An EMCAL hit is the sum of all hits in a tower section (PRE, ECAL, HCAL) |
97 | // originating from the same entering particle | |
b13bbe81 | 98 | Int_t hitCounter; |
99 | ||
100 | AliEMCALHit *newHit; | |
101 | AliEMCALHit *curHit; | |
102 | Bool_t deja = kFALSE; | |
103 | ||
61e0abb5 | 104 | newHit = new AliEMCALHit(shunt, primary, tracknumber, iparent, ienergy, id, hits, p); |
b13bbe81 | 105 | for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) { |
106 | curHit = (AliEMCALHit*) (*fHits)[hitCounter]; | |
61e0abb5 | 107 | // We add hits with the same tracknumber, while GEANT treats |
b13bbe81 | 108 | // primaries succesively |
7b6cc0b5 | 109 | if(curHit->GetPrimary() != primary) |
110 | break; | |
b13bbe81 | 111 | if( *curHit == *newHit ) { |
112 | *curHit = *curHit + *newHit; | |
113 | deja = kTRUE; | |
114 | } // end if | |
115 | } // end for hitCounter | |
116 | ||
117 | if ( !deja ) { | |
118 | new((*fHits)[fNhits]) AliEMCALHit(*newHit); | |
119 | fNhits++; | |
120 | } // end if | |
121 | ||
122 | delete newHit; | |
123 | } | |
124 | //______________________________________________________________________ | |
125 | void AliEMCALv1::StepManager(void){ | |
1f4d29d2 | 126 | // Accumulates hits as long as the track stays in a single |
127 | // crystal or PPSD gas Cell | |
128 | ||
129 | Int_t id[2]; // (layer, phi, Eta) indices | |
1f4d29d2 | 130 | // position wrt MRS and energy deposited |
131 | Float_t xyzte[5]={0.,0.,0.,0.,0.};// position wrt MRS, time and energy deposited | |
132 | Float_t pmom[4]={0.,0.,0.,0.}; | |
133 | TLorentzVector pos; // Lorentz vector of the track current position. | |
134 | TLorentzVector mom; // Lorentz vector of the track current momentum. | |
5d12ce38 | 135 | Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber(); |
1f4d29d2 | 136 | Int_t primary = 0; |
137 | static Int_t iparent = 0; | |
138 | static Float_t ienergy = 0; | |
139 | Int_t copy = 0; | |
1f4d29d2 | 140 | |
05a92d59 | 141 | AliEMCALGeometry * geom = GetGeometry() ; |
142 | ||
1f4d29d2 | 143 | if(gMC->IsTrackEntering() && (strcmp(gMC->CurrentVolName(),"XALU") == 0)){ // This Particle in enterring the Calorimeter |
144 | gMC->TrackPosition(pos) ; | |
145 | xyzte[0] = pos[0] ; | |
146 | xyzte[1] = pos[1] ; | |
147 | xyzte[2] = pos[2] ; | |
148 | if ( (xyzte[0]*xyzte[0] + xyzte[1]*xyzte[1]) | |
05a92d59 | 149 | < (geom->GetEnvelop(0)+geom->GetGap2Active()+1.5 )*(geom->GetEnvelop(0)+geom->GetGap2Active()+1.5 ) ) { |
1f4d29d2 | 150 | iparent = tracknumber; |
151 | gMC->TrackMomentum(mom); | |
152 | ienergy = mom[3]; | |
153 | TParticle * part = 0 ; | |
154 | Int_t parent = iparent ; | |
155 | while ( parent != -1 ) { // <------------- flags this particle to be kept and | |
156 | //all the ancestors of this particle | |
5d12ce38 | 157 | part = gAlice->GetMCApp()->Particle(parent) ; |
1f4d29d2 | 158 | part->SetBit(kKeepBit); |
159 | parent = part->GetFirstMother() ; | |
fceb09ed | 160 | } |
1f4d29d2 | 161 | } |
162 | } | |
163 | if(gMC->CurrentVolID(copy) == gMC->VolId("XPHI") ) { // We are in a Scintillator Layer | |
164 | ||
dfce7eb2 | 165 | Float_t depositedEnergy ; |
61e0abb5 | 166 | |
dfce7eb2 | 167 | if( (depositedEnergy = gMC->Edep()) > 0.){// Track is inside a scintillator and deposits some energy |
7b6cc0b5 | 168 | |
dfce7eb2 | 169 | gMC->TrackPosition(pos); |
170 | xyzte[0] = pos[0]; | |
171 | xyzte[1] = pos[1]; | |
172 | xyzte[2] = pos[2]; | |
173 | xyzte[3] = gMC->TrackTime() ; | |
174 | ||
175 | gMC->TrackMomentum(mom); | |
176 | pmom[0] = mom[0]; | |
177 | pmom[1] = mom[1]; | |
178 | pmom[2] = mom[2]; | |
179 | pmom[3] = mom[3]; | |
180 | ||
181 | gMC->CurrentVolOffID(1, id[0]); // get the POLY copy number; | |
182 | gMC->CurrentVolID(id[1]); // get the phi number inside the layer | |
dfce7eb2 | 183 | |
de56e4f9 | 184 | Int_t tower = (id[0]-1) % geom->GetNZ() + 1 + (id[1] - 1) * geom->GetNZ() ; |
7b6cc0b5 | 185 | Int_t layer = static_cast<Int_t>((id[0]-1)/(geom->GetNZ())) + 1 ; |
186 | Int_t absid = tower ; | |
187 | if (layer <= geom->GetNPRLayers() ) | |
188 | absid += geom->GetNZ() * geom->GetNPhi() ; | |
189 | else if (layer > geom->GetNECLayers() ) | |
190 | absid += 2 * geom->GetNZ() * geom->GetNPhi() ; | |
191 | else { | |
192 | Int_t nlayers = geom->GetNPRLayers()+ geom->GetNECLayers()+ geom->GetNHCLayers() ; | |
193 | if (layer > nlayers) | |
194 | Fatal("StepManager", "Wrong calculation of layer number: layer = %d > %d\n", layer, nlayers) ; | |
195 | } | |
196 | ||
197 | Float_t lightYield = depositedEnergy ; | |
198 | ; | |
199 | xyzte[4] = lightYield ; | |
dfce7eb2 | 200 | |
5d12ce38 | 201 | primary = gAlice->GetMCApp()->GetPrimary(tracknumber); |
7b6cc0b5 | 202 | |
203 | if (gDebug == 2) | |
204 | Info("StepManager", "id0 = %d, id1 = %d, absid = %d tower = %d layer = %d energy = %f\n", id[0], id[1], absid, tower, layer, xyzte[4]) ; | |
205 | ||
1f4d29d2 | 206 | AddHit(fIshunt, primary,tracknumber, iparent, ienergy, absid, xyzte, pmom); |
b13bbe81 | 207 | } // there is deposited energy |
1f4d29d2 | 208 | } |
b13bbe81 | 209 | } |