1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
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.
28 // 15/02/2002 .... Yves Schutz
29 // 1. fSamplingFraction and fLayerToPreshowerRatio have been removed
30 // 2. Timing signal is collected and added to hit
32 // --- ROOT system ---
33 #include <TClonesArray.h>
34 #include <TParticle.h>
35 #include <TVirtualMC.h>
37 // --- Standard library ---
39 // --- AliRoot header files ---
40 #include "AliEMCALv1.h"
41 #include "AliEMCALHit.h"
42 #include "AliEMCALGeometry.h"
50 //______________________________________________________________________
51 AliEMCALv1::AliEMCALv1()
61 //______________________________________________________________________
62 AliEMCALv1::AliEMCALv1(const char *name, const char *title)
63 : AliEMCALv0(name,title),
71 fHits= new TClonesArray("AliEMCALHit",1000);
72 // gAlice->GetMCApp()->AddHitList(fHits); // 20-dec-04 - advice of Andreas
75 fIshunt = 2; // All hits are associated with particles entering the calorimeter
78 //______________________________________________________________________
79 AliEMCALv1::~AliEMCALv1(){
89 //______________________________________________________________________
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){
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
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)
108 if( *curHit == *newHit ) {
109 *curHit = *curHit + *newHit;
112 } // end for hitCounter
115 new((*fHits)[fNhits]) AliEMCALHit(*newHit);
121 //______________________________________________________________________
122 void AliEMCALv1::StepManager(void){
123 // Accumulates hits as long as the track stays in a tower
125 Int_t id[2]; // (phi, Eta) indices
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.
131 Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber();
132 static Float_t ienergy = 0;
135 AliEMCALGeometry * geom = GetGeometry() ;
140 static Int_t idXPHI = gMC->VolId("XPHI");
141 if(gMC->CurrentVolID(copy) == idXPHI ) { // We are in a Scintillator Layer
142 Float_t depositedEnergy ;
144 if( ((depositedEnergy = gMC->Edep()) > 0.) && (gMC->TrackTime() < fTimeCut)){// Track is inside a scintillator and deposits some energy
146 fCurPrimary=gAlice->GetMCApp()->GetPrimary(tracknumber);
148 if (fCurParent==-1 || tracknumber != fCurTrack) {
150 //Int_t parent=tracknumber;
152 if (fCurParent != -1) {
153 while (parent != fCurParent && parent != -1) {
154 //TParticle *part=gAlice->GetMCApp()->Particle(parent);
155 part=gAlice->GetMCApp()->Particle(parent);
156 parent=part->GetFirstMother();
159 if (fCurParent==-1 || parent==-1) {
160 //Int_t parent=tracknumber;
161 //TParticle *part=gAlice->GetMCApp()->Particle(parent);
163 part=gAlice->GetMCApp()->Particle(parent);
164 while (parent != -1 && geom->IsInEMCAL(part->Vx(),part->Vy(),part->Vz())) {
165 parent=part->GetFirstMother();
167 part=gAlice->GetMCApp()->Particle(parent);
171 Error("StepManager","Cannot find parent");
173 //TParticle *part=gAlice->GetMCApp()->Particle(fCurParent);
174 part=gAlice->GetMCApp()->Particle(fCurParent);
175 ienergy = part->Energy();
177 while (parent != -1) {
178 part=gAlice->GetMCApp()->Particle(parent);
179 part->SetBit(kKeepBit);
180 parent=part->GetFirstMother();
183 fCurTrack=tracknumber;
185 gMC->TrackPosition(pos);
189 xyzte[3] = gMC->TrackTime() ;
191 gMC->TrackMomentum(mom);
197 gMC->CurrentVolOffID(1, id[0]); // get the POLY copy number;
198 gMC->CurrentVolID(id[1]); // get the phi number inside the layer
200 Int_t tower = (id[0]-1) % geom->GetNZ() + 1 + (id[1] - 1) * geom->GetNZ() ;
201 Int_t layer = static_cast<Int_t>((id[0]-1)/(geom->GetNZ())) + 1 ;
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) ;
207 Float_t lightYield = depositedEnergy ;
208 // Apply Birk's law (copied from G3BIRK)
210 if (gMC->TrackCharge()!=0) { // Check
211 Float_t birkC1Mod = 0;
212 if (fBirkC0==1){ // Apply correction for higher charge states
213 if (TMath::Abs(gMC->TrackCharge())>=2)
214 birkC1Mod=fBirkC1*7.2/12.6;
219 if (gMC->TrackStep()>0)
220 dedxcm=1000.*gMC->Edep()/gMC->TrackStep();
223 lightYield=lightYield/(1.+birkC1Mod*dedxcm+fBirkC2*dedxcm*dedxcm);
226 // use sampling fraction to get original energy --HG
227 xyzte[4] = lightYield * geom->GetSampling();
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]) ;
232 AddHit(fIshunt, fCurPrimary,tracknumber, fCurParent, ienergy, absid, xyzte, pmom);
233 } // there is deposited energy
237 //___________________________________________________________
238 void AliEMCALv1::RemapTrackHitIDs(Int_t *map) {
239 // remap track index numbers for primary and parent indices
240 // (Called by AliStack::PurifyKine)
243 TIter hitIter(Hits());
245 while (AliEMCALHit *hit=dynamic_cast<AliEMCALHit*>(hitIter()) ) {
246 if (map[hit->GetIparent()]==-99)
247 cout << "Remapping, found -99 for parent id " << hit->GetIparent() << ", " << map[hit->GetIparent()] << ", iHit " << iHit << endl;
248 hit->SetIparent(map[hit->GetIparent()]);
249 if (map[hit->GetPrimary()]==-99)
250 cout << "Remapping, found -99 for primary id " << hit->GetPrimary() << ", " << map[hit->GetPrimary()] << ", iHit " << iHit << endl;
251 hit->SetPrimary(map[hit->GetPrimary()]);
256 //___________________________________________________________
257 void AliEMCALv1::FinishPrimary() {