Anti-Splitting Cut implemented
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALv1.cxx
CommitLineData
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 ---
fceb09ed 34#include "TParticle.h"
5d12ce38 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"
b13bbe81 45
46ClassImp(AliEMCALv1)
47
48
49//______________________________________________________________________
50AliEMCALv1::AliEMCALv1():AliEMCALv0(){
51 // ctor
7b6cc0b5 52
b13bbe81 53}
1f4d29d2 54
b13bbe81 55//______________________________________________________________________
56AliEMCALv1::AliEMCALv1(const char *name, const char *title):
57 AliEMCALv0(name,title){
58 // Standard Creator.
59
60 fHits= new TClonesArray("AliEMCALHit",1000);
5d12ce38 61 gAlice->GetMCApp()->AddHitList(fHits);
b13bbe81 62
63 fNhits = 0;
fceb09ed 64 fIshunt = 2; // All hits are associated with particles entering the calorimeter
b13bbe81 65}
1f4d29d2 66
b13bbe81 67//______________________________________________________________________
68AliEMCALv1::~AliEMCALv1(){
69 // dtor
70
71 if ( fHits) {
72 fHits->Delete();
73 delete fHits;
74 fHits = 0;
75 }
76}
77//______________________________________________________________________
61e0abb5 78void AliEMCALv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t iparent, Float_t ienergy,
79 Int_t id, Float_t * hits,Float_t * p){
b13bbe81 80 // Add a hit to the hit list.
7b6cc0b5 81 // An EMCAL hit is the sum of all hits in a tower section (PRE, ECAL, HCAL)
82 // originating from the same entering particle
b13bbe81 83 Int_t hitCounter;
84
85 AliEMCALHit *newHit;
86 AliEMCALHit *curHit;
87 Bool_t deja = kFALSE;
88
61e0abb5 89 newHit = new AliEMCALHit(shunt, primary, tracknumber, iparent, ienergy, id, hits, p);
b13bbe81 90 for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) {
91 curHit = (AliEMCALHit*) (*fHits)[hitCounter];
61e0abb5 92 // We add hits with the same tracknumber, while GEANT treats
b13bbe81 93 // primaries succesively
7b6cc0b5 94 if(curHit->GetPrimary() != primary)
95 break;
b13bbe81 96 if( *curHit == *newHit ) {
97 *curHit = *curHit + *newHit;
98 deja = kTRUE;
99 } // end if
100 } // end for hitCounter
101
102 if ( !deja ) {
103 new((*fHits)[fNhits]) AliEMCALHit(*newHit);
104 fNhits++;
105 } // end if
106
107 delete newHit;
108}
109//______________________________________________________________________
110void AliEMCALv1::StepManager(void){
8ddf73e5 111 // Accumulates hits as long as the track stays in a tower
1f4d29d2 112
113 Int_t id[2]; // (layer, phi, Eta) indices
1f4d29d2 114 // position wrt MRS and energy deposited
115 Float_t xyzte[5]={0.,0.,0.,0.,0.};// position wrt MRS, time and energy deposited
116 Float_t pmom[4]={0.,0.,0.,0.};
117 TLorentzVector pos; // Lorentz vector of the track current position.
118 TLorentzVector mom; // Lorentz vector of the track current momentum.
5d12ce38 119 Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber();
1f4d29d2 120 Int_t primary = 0;
121 static Int_t iparent = 0;
122 static Float_t ienergy = 0;
123 Int_t copy = 0;
1f4d29d2 124
05a92d59 125 AliEMCALGeometry * geom = GetGeometry() ;
126
1f4d29d2 127 if(gMC->IsTrackEntering() && (strcmp(gMC->CurrentVolName(),"XALU") == 0)){ // This Particle in enterring the Calorimeter
128 gMC->TrackPosition(pos) ;
129 xyzte[0] = pos[0] ;
130 xyzte[1] = pos[1] ;
131 xyzte[2] = pos[2] ;
132 if ( (xyzte[0]*xyzte[0] + xyzte[1]*xyzte[1])
05a92d59 133 < (geom->GetEnvelop(0)+geom->GetGap2Active()+1.5 )*(geom->GetEnvelop(0)+geom->GetGap2Active()+1.5 ) ) {
1f4d29d2 134 iparent = tracknumber;
135 gMC->TrackMomentum(mom);
136 ienergy = mom[3];
137 TParticle * part = 0 ;
138 Int_t parent = iparent ;
139 while ( parent != -1 ) { // <------------- flags this particle to be kept and
140 //all the ancestors of this particle
5d12ce38 141 part = gAlice->GetMCApp()->Particle(parent) ;
1f4d29d2 142 part->SetBit(kKeepBit);
143 parent = part->GetFirstMother() ;
fceb09ed 144 }
1f4d29d2 145 }
146 }
147 if(gMC->CurrentVolID(copy) == gMC->VolId("XPHI") ) { // We are in a Scintillator Layer
148
dfce7eb2 149 Float_t depositedEnergy ;
61e0abb5 150
dfce7eb2 151 if( (depositedEnergy = gMC->Edep()) > 0.){// Track is inside a scintillator and deposits some energy
7b6cc0b5 152
dfce7eb2 153 gMC->TrackPosition(pos);
154 xyzte[0] = pos[0];
155 xyzte[1] = pos[1];
156 xyzte[2] = pos[2];
157 xyzte[3] = gMC->TrackTime() ;
158
159 gMC->TrackMomentum(mom);
160 pmom[0] = mom[0];
161 pmom[1] = mom[1];
162 pmom[2] = mom[2];
163 pmom[3] = mom[3];
164
165 gMC->CurrentVolOffID(1, id[0]); // get the POLY copy number;
166 gMC->CurrentVolID(id[1]); // get the phi number inside the layer
dfce7eb2 167
de56e4f9 168 Int_t tower = (id[0]-1) % geom->GetNZ() + 1 + (id[1] - 1) * geom->GetNZ() ;
7b6cc0b5 169 Int_t layer = static_cast<Int_t>((id[0]-1)/(geom->GetNZ())) + 1 ;
170 Int_t absid = tower ;
171 if (layer <= geom->GetNPRLayers() )
172 absid += geom->GetNZ() * geom->GetNPhi() ;
8ddf73e5 173 else if (layer > geom->GetNECLayers() + geom->GetNPRLayers() )
7b6cc0b5 174 absid += 2 * geom->GetNZ() * geom->GetNPhi() ;
175 else {
176 Int_t nlayers = geom->GetNPRLayers()+ geom->GetNECLayers()+ geom->GetNHCLayers() ;
177 if (layer > nlayers)
178 Fatal("StepManager", "Wrong calculation of layer number: layer = %d > %d\n", layer, nlayers) ;
179 }
180
181 Float_t lightYield = depositedEnergy ;
182 ;
183 xyzte[4] = lightYield ;
dfce7eb2 184
5d12ce38 185 primary = gAlice->GetMCApp()->GetPrimary(tracknumber);
7b6cc0b5 186
187 if (gDebug == 2)
188 Info("StepManager", "id0 = %d, id1 = %d, absid = %d tower = %d layer = %d energy = %f\n", id[0], id[1], absid, tower, layer, xyzte[4]) ;
189
1f4d29d2 190 AddHit(fIshunt, primary,tracknumber, iparent, ienergy, absid, xyzte, pmom);
b13bbe81 191 } // there is deposited energy
1f4d29d2 192 }
b13bbe81 193}