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