]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALv1.cxx
Rotation Angle is +60 deg.
[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>
47#include <strstream.h>
48#include <iostream.h>
49#include <math.h>
50// --- AliRoot header files ---
51
52#include "AliEMCALv1.h"
53#include "AliEMCALHit.h"
54#include "AliEMCALGeometry.h"
55#include "AliConst.h"
56#include "AliRun.h"
57#include "AliMC.h"
58
59ClassImp(AliEMCALv1)
60
61
62//______________________________________________________________________
63AliEMCALv1::AliEMCALv1():AliEMCALv0(){
64 // ctor
dfce7eb2 65 fLightYieldMean = 0 ;
66 fIntrinsicAPDEfficiency = fLightFactor = fLightYieldAttenuation = fAPDFactor = fAPDGain = fRecalibrationFactor = fAPDFactor = 0. ;
b13bbe81 67}
1f4d29d2 68
b13bbe81 69//______________________________________________________________________
70AliEMCALv1::AliEMCALv1(const char *name, const char *title):
71 AliEMCALv0(name,title){
72 // Standard Creator.
73
74 fHits= new TClonesArray("AliEMCALHit",1000);
75 gAlice->AddHitList(fHits);
76
77 fNhits = 0;
fceb09ed 78 fIshunt = 2; // All hits are associated with particles entering the calorimeter
dfce7eb2 79
80 //Photoelectron statistics:
81 // The light yield is a poissonian distribution of the number of
82 // photons created in a plastic layer, calculated using following formula
83 // NumberOfPhotons = EnergyLost * LightYieldMean* APDEfficiency *
84 // exp (-LightYieldAttenuation * DistanceToPINdiodeFromTheHit)
85 // LightYieldMean is parameter calculated to be over 100000 photons per GeV (a guess)
86 // APDEfficiency is 0.02655
87 // fLightYieldAttenuation is 0.0045 a guess
88 // TO BE FIXED
89 //***** Need a method in geometry to retrieve the fiber length corresponding to each layer
90 //***** See the step manager for the light attenuation calculation
91 // The number of electrons created in the APD is
92 // NumberOfElectrons = APDGain * LightYield
93 // The APD Gain is 300
94
95 fLightYieldMean = 10000000.; // This is a guess
96 fIntrinsicAPDEfficiency = 0.02655 ;
97 fLightFactor = fLightYieldMean * fIntrinsicAPDEfficiency ;
98 fLightYieldAttenuation = 0.0045 ; // an other guess
99 fAPDGain = 300. ;
100 fRecalibrationFactor = 13.418/ fLightYieldMean ;
101 fAPDFactor = (fRecalibrationFactor/100.) * fAPDGain ;
102
b13bbe81 103}
1f4d29d2 104
b13bbe81 105//______________________________________________________________________
106AliEMCALv1::~AliEMCALv1(){
107 // dtor
108
109 if ( fHits) {
110 fHits->Delete();
111 delete fHits;
112 fHits = 0;
113 }
114}
115//______________________________________________________________________
61e0abb5 116void AliEMCALv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t iparent, Float_t ienergy,
117 Int_t id, Float_t * hits,Float_t * p){
b13bbe81 118 // Add a hit to the hit list.
ffa6d63b 119 // An EMCAL hit is the sum of all hits in a single segment
120 // originating from the same enterring particle
b13bbe81 121 Int_t hitCounter;
122
123 AliEMCALHit *newHit;
124 AliEMCALHit *curHit;
125 Bool_t deja = kFALSE;
126
61e0abb5 127 newHit = new AliEMCALHit(shunt, primary, tracknumber, iparent, ienergy, id, hits, p);
b13bbe81 128 for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) {
129 curHit = (AliEMCALHit*) (*fHits)[hitCounter];
61e0abb5 130 // We add hits with the same tracknumber, while GEANT treats
b13bbe81 131 // primaries succesively
132 if(curHit->GetPrimary() != primary) break;
133 if( *curHit == *newHit ) {
134 *curHit = *curHit + *newHit;
135 deja = kTRUE;
136 } // end if
137 } // end for hitCounter
138
139 if ( !deja ) {
140 new((*fHits)[fNhits]) AliEMCALHit(*newHit);
141 fNhits++;
142 } // end if
143
144 delete newHit;
145}
146//______________________________________________________________________
147void AliEMCALv1::StepManager(void){
1f4d29d2 148 // Accumulates hits as long as the track stays in a single
149 // crystal or PPSD gas Cell
150
151 Int_t id[2]; // (layer, phi, Eta) indices
152 Int_t absid;
153 // position wrt MRS and energy deposited
154 Float_t xyzte[5]={0.,0.,0.,0.,0.};// position wrt MRS, time and energy deposited
155 Float_t pmom[4]={0.,0.,0.,0.};
156 TLorentzVector pos; // Lorentz vector of the track current position.
157 TLorentzVector mom; // Lorentz vector of the track current momentum.
158 Int_t tracknumber = gAlice->CurrentTrack();
159 Int_t primary = 0;
160 static Int_t iparent = 0;
161 static Float_t ienergy = 0;
162 Int_t copy = 0;
1f4d29d2 163
164 if(gMC->IsTrackEntering() && (strcmp(gMC->CurrentVolName(),"XALU") == 0)){ // This Particle in enterring the Calorimeter
165 gMC->TrackPosition(pos) ;
166 xyzte[0] = pos[0] ;
167 xyzte[1] = pos[1] ;
168 xyzte[2] = pos[2] ;
169 if ( (xyzte[0]*xyzte[0] + xyzte[1]*xyzte[1])
170 < (fGeom->GetEnvelop(0)+fGeom->GetGap2Active()+1.5 )*(fGeom->GetEnvelop(0)+fGeom->GetGap2Active()+1.5 ) ) {
171 iparent = tracknumber;
172 gMC->TrackMomentum(mom);
173 ienergy = mom[3];
174 TParticle * part = 0 ;
175 Int_t parent = iparent ;
176 while ( parent != -1 ) { // <------------- flags this particle to be kept and
177 //all the ancestors of this particle
178 part = gAlice->Particle(parent) ;
179 part->SetBit(kKeepBit);
180 parent = part->GetFirstMother() ;
fceb09ed 181 }
1f4d29d2 182 }
183 }
184 if(gMC->CurrentVolID(copy) == gMC->VolId("XPHI") ) { // We are in a Scintillator Layer
185
dfce7eb2 186 Float_t depositedEnergy ;
61e0abb5 187
dfce7eb2 188 if( (depositedEnergy = gMC->Edep()) > 0.){// Track is inside a scintillator and deposits some energy
189
190 gMC->TrackPosition(pos);
191 xyzte[0] = pos[0];
192 xyzte[1] = pos[1];
193 xyzte[2] = pos[2];
194 xyzte[3] = gMC->TrackTime() ;
195
196 gMC->TrackMomentum(mom);
197 pmom[0] = mom[0];
198 pmom[1] = mom[1];
199 pmom[2] = mom[2];
200 pmom[3] = mom[3];
201
202 gMC->CurrentVolOffID(1, id[0]); // get the POLY copy number;
203 gMC->CurrentVolID(id[1]); // get the phi number inside the layer
1f4d29d2 204 absid = (id[0]-1)*(fGeom->GetNPhi()) + id[1];
dfce7eb2 205
206 //Calculates the light yield, the number of photons produced in the
207 //plastic layer
208 // Here we need to know the fiber lebgth to calculate the attenuation
209
210 Float_t lengthOfFiber = 0. ;// should be retrieved from the geometry
211
212 Float_t lightYield = gRandom->Poisson(fLightFactor * depositedEnergy *
213 exp(-fLightYieldAttenuation * lengthOfFiber)) ;
214 xyzte[4] = fAPDFactor * lightYield ;
215
216 primary = gAlice->GetPrimary(tracknumber);
1f4d29d2 217 AddHit(fIshunt, primary,tracknumber, iparent, ienergy, absid, xyzte, pmom);
b13bbe81 218 } // there is deposited energy
1f4d29d2 219 }
b13bbe81 220}