]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALv1.cxx
Removing AliMCProcess and AliMC
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALv1.cxx
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
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
29 // 15/02/2002 .... Yves Schutz
30 //  1. fSamplingFraction and fLayerToPreshowerRatio have been removed
31 //  2. Timing signal is collected and added to hit
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"
40 #include "TParticle.h"
41
42 // --- Standard library ---
43
44 #include <stdio.h>
45 #include <string.h>
46 #include <stdlib.h>
47 #include <Rstrstream.h>
48 #include <Riostream.h>
49 #include <math.h>
50
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"
58
59 ClassImp(AliEMCALv1)
60
61
62 //______________________________________________________________________
63 AliEMCALv1::AliEMCALv1():AliEMCALv0(){
64   // ctor
65     fLightYieldMean = 0 ; 
66     fIntrinsicAPDEfficiency = fLightFactor = fLightYieldAttenuation =   fAPDFactor = fAPDGain = fRecalibrationFactor = fAPDFactor = 0. ; 
67 }
68
69 //______________________________________________________________________
70 AliEMCALv1::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;
78     fIshunt     =  2; // All hits are associated with particles entering the calorimeter
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
103 }
104
105 //______________________________________________________________________
106 AliEMCALv1::~AliEMCALv1(){
107     // dtor
108
109     if ( fHits) {
110         fHits->Delete();
111         delete fHits;
112         fHits = 0;
113     }
114 }
115 //______________________________________________________________________
116 void 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){
118     // Add a hit to the hit list.
119     // An EMCAL hit is the sum of all hits in a single segment 
120     //   originating from the same enterring particle 
121     Int_t hitCounter;
122     
123     AliEMCALHit *newHit;
124     AliEMCALHit *curHit;
125     Bool_t deja = kFALSE;
126
127     newHit = new AliEMCALHit(shunt, primary, tracknumber, iparent, ienergy, id, hits, p);
128     for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) {
129         curHit = (AliEMCALHit*) (*fHits)[hitCounter];
130         // We add hits with the same tracknumber, while GEANT treats
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 //______________________________________________________________________
147 void AliEMCALv1::StepManager(void){
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;
163   
164   AliEMCALGeometry * geom = GetGeometry() ; 
165
166   if(gMC->IsTrackEntering() && (strcmp(gMC->CurrentVolName(),"XALU") == 0)){ // This Particle in enterring the Calorimeter
167     gMC->TrackPosition(pos) ;
168     xyzte[0] = pos[0] ;
169     xyzte[1] = pos[1] ;
170     xyzte[2] = pos[2] ;
171     if ( (xyzte[0]*xyzte[0] + xyzte[1]*xyzte[1])  
172          <  (geom->GetEnvelop(0)+geom->GetGap2Active()+1.5 )*(geom->GetEnvelop(0)+geom->GetGap2Active()+1.5 ) ) {
173       iparent = tracknumber;
174       gMC->TrackMomentum(mom);
175       ienergy = mom[3]; 
176       TParticle * part = 0 ;
177       Int_t parent = iparent ;
178       while ( parent != -1 ) { // <------------- flags this particle to be kept and
179         //all the ancestors of this particle
180         part = gAlice->Particle(parent) ;
181         part->SetBit(kKeepBit);
182         parent = part->GetFirstMother() ;
183       }
184     }
185   }
186   if(gMC->CurrentVolID(copy) == gMC->VolId("XPHI") ) { // We are in a Scintillator Layer 
187     
188     Float_t depositedEnergy ; 
189     
190     if( (depositedEnergy = gMC->Edep()) > 0.){// Track is inside a scintillator and deposits some energy
191       
192       gMC->TrackPosition(pos);
193       xyzte[0] = pos[0];
194       xyzte[1] = pos[1];
195       xyzte[2] = pos[2];
196       xyzte[3] = gMC->TrackTime() ;       
197       
198       gMC->TrackMomentum(mom);
199       pmom[0] = mom[0];
200       pmom[1] = mom[1];
201       pmom[2] = mom[2];
202       pmom[3] = mom[3];
203       
204       gMC->CurrentVolOffID(1, id[0]); // get the POLY copy number;
205       gMC->CurrentVolID(id[1]); // get the phi number inside the layer
206       absid = (id[0]-1)*(geom->GetNPhi()) + id[1];
207       
208       //Calculates the light yield, the number of photons produced in the
209       //plastic layer 
210       // Here we need to know the fiber lebgth to calculate the attenuation
211      
212       Float_t lengthOfFiber = 0. ;// should be retrieved from the geometry
213
214       Float_t lightYield = gRandom->Poisson(fLightFactor * depositedEnergy *
215                                             exp(-fLightYieldAttenuation * lengthOfFiber)) ;
216       xyzte[4] = fAPDFactor * lightYield  ;
217    
218       primary = gAlice->GetPrimary(tracknumber);
219       AddHit(fIshunt, primary,tracknumber, iparent, ienergy, absid, xyzte, pmom);
220     } // there is deposited energy
221   }
222 }