These are the interface classes to Geant 3 to read the geometry information
[u/mrichter/AliRoot.git] / PHOS / AliPHOSv3.cxx
CommitLineData
5f20d3fb 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 v0 of PHOS Manager class
20// Layout EMC + PPSD has name GPS2
21// The main goal of this version of AliPHOS is to calculte the
22// induced charged in the PIN diode, taking into account light
23// tracking in the PbWO4 crystal, induced signal in the
24// PIN due to MIPS particle and electronic noise.
25// This is done in the StepManager
26//
27//*-- Author: Odd Harald Oddland & Gines Martinez (SUBATECH)
28
29
30// --- ROOT system ---
31#include "TRandom.h"
32
33// --- Standard library ---
34
35#include <stdio.h>
36#include <string.h>
37#include <stdlib.h>
38#include <strstream.h>
39
40// --- AliRoot header files ---
41
42#include "AliPHOSv3.h"
43#include "AliPHOSHit.h"
44#include "AliPHOSDigit.h"
45#include "AliRun.h"
46#include "AliConst.h"
94de3818 47#include "AliMC.h"
5f20d3fb 48
49ClassImp(AliPHOSv3)
50
51//____________________________________________________________________________
e04976bd 52 AliPHOSv3::AliPHOSv3(const char *name, const char *title):
53AliPHOSv1(name,title)
5f20d3fb 54{
55 // ctor
56
57 // Number of electrons created in the PIN due to light collected in the PbWo4 crystal is calculated using
58 // following formula
59 // NumberOfElectrons = EnergyLost * LightYield * PINEfficiency *
60 // exp (-LightYieldAttenuation * DistanceToPINdiodeFromTheHit) *
61 // RecalibrationFactor ;
62 // LightYield is obtained as a Poissonian distribution with a mean at 700000 photons per GeV fromValery Antonenko
63 // PINEfficiency is 0.1875 from Odd Harald Odland work
64 // k_0 is 0.0045 from Valery Antonenko
65
e04976bd 66
5f20d3fb 67 fLightYieldMean = 700000. ;
68 fIntrinsicPINEfficiency = 0.1875 ;
69 fLightYieldAttenuation = 0.0045 ;
70 fRecalibrationFactor = 6.2 / fLightYieldMean ;
71 fElectronsPerGeV = 2.77e+8 ;
72}
73
74//____________________________________________________________________________
75AliPHOSv3::AliPHOSv3(AliPHOSReconstructioner * Reconstructioner, const char *name, const char *title):
76 AliPHOSv1(Reconstructioner,name,title)
77{
78 // ctor
79
80 // Number of electrons created in the PIN due to light collected in the PbWo4 crystal is calculated using
81 // following formula
82 // NumberOfElectrons = EnergyLost * LightYield * PINEfficiency *
83 // exp (-LightYieldAttenuation * DistanceToPINdiodeFromTheHit) *
84 // RecalibrationFactor ;
85 // LightYield is obtained as a Poissonian distribution with a mean at 700000 photons per GeV fromValery Antonenko
86 // PINEfficiency is 0.1875 from Odd Harald Odland work
87 // k_0 is 0.0045 from Valery Antonenko
88
89 fLightYieldMean = 700000.;
90 fIntrinsicPINEfficiency = 0.1875 ;
91 fLightYieldAttenuation = 0.0045 ;
92 fRecalibrationFactor = 6.2 / fLightYieldMean ;
93 fElectronsPerGeV = 2.77e+8 ;
94}
95
96//____________________________________________________________________________
97void AliPHOSv3::StepManager(void)
98{
99 // Accumulates hits as long as the track stays in a single crystal or PPSD gas Cell
100 // Adds the energy deposited in the PIN diode
101
102 Int_t relid[4] ; // (box, layer, row, column) indices
103 Float_t xyze[4] ; // position wrt MRS and energy deposited
104 TLorentzVector pos ;
105 Int_t copy;
106 Float_t lightyield ; // Light Yield per GeV
107 Float_t nElectrons ; // Number of electrons in the PIN diode
108 TString name = fGeom->GetName() ;
109 Float_t global[3] ;
110 Float_t local[3] ;
111 Float_t lostenergy ;
112
113 Int_t tracknumber = gAlice->CurrentTrack() ;
114 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
7eb9d12d 115 Int_t trackpid = gMC->TrackPid() ;
5f20d3fb 116
117 if ( name == "GPS2" ) { // the CPV is a PPSD
118 if( gMC->CurrentVolID(copy) == gMC->VolId("GCEL") ) // We are inside a gas cell
119 {
120 gMC->TrackPosition(pos) ;
121 xyze[0] = pos[0] ;
122 xyze[1] = pos[1] ;
123 xyze[2] = pos[2] ;
124 xyze[3] = gMC->Edep() ;
125
126
127 if ( xyze[3] != 0 ) { // there is deposited energy
128 gMC->CurrentVolOffID(5, relid[0]) ; // get the PHOS Module number
129 gMC->CurrentVolOffID(3, relid[1]) ; // get the Micromegas Module number
130 // 1-> Geom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() upper
131 // > fGeom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() lower
132 gMC->CurrentVolOffID(1, relid[2]) ; // get the row number of the cell
133 gMC->CurrentVolID(relid[3]) ; // get the column number
134
135 // get the absolute Id number
136
137 Int_t absid ;
138 fGeom->RelToAbsNumbering(relid,absid) ;
139
140
7eb9d12d 141 AddHit(fIshunt, primary, tracknumber, absid, xyze, trackpid);
5f20d3fb 142
143 } // there is deposited energy
144 } // We are inside the gas of the CPV
145 } // GPS2 configuration
146
147 if(gMC->CurrentVolID(copy) == gMC->VolId("PXTL") )// We are inside a PBWO crystal
148 {
149 gMC->TrackPosition(pos) ;
150 xyze[0] = pos[0] ;
151 xyze[1] = pos[1] ;
152 xyze[2] = pos[2] ;
153 lostenergy = gMC->Edep() ;
154 xyze[3] = gMC->Edep() ;
155
156 global[0] = pos[0] ;
157 global[1] = pos[1] ;
158 global[2] = pos[2] ;
159
160 if ( xyze[3] != 0 ) {
161 gMC->CurrentVolOffID(10, relid[0]) ; // get the PHOS module number ;
162 relid[1] = 0 ; // means PW04
163 gMC->CurrentVolOffID(4, relid[2]) ; // get the row number inside the module
164 gMC->CurrentVolOffID(3, relid[3]) ; // get the cell number inside the module
165
166 // get the absolute Id number
167
168 Int_t absid ;
169 fGeom->RelToAbsNumbering(relid,absid) ;
170 gMC->Gmtod(global, local, 1) ;
171
172 // calculating number of electrons in the PIN diode asociated to this hit
173 lightyield = gRandom->Poisson(fLightYieldMean) ;
174 nElectrons = lostenergy * lightyield * fIntrinsicPINEfficiency *
175 exp(-fLightYieldAttenuation * (local[1]+fGeom->GetCrystalSize(1)/2.0 ) ) ;
176
177 xyze[3] = nElectrons * fRecalibrationFactor ;
178 // add current hit to the hit list
7eb9d12d 179 AddHit(fIshunt, primary, tracknumber, absid, xyze, trackpid);
5f20d3fb 180
181 } // there is deposited energy
182 } // we are inside a PHOS Xtal
183
184 if(gMC->CurrentVolID(copy) == gMC->VolId("PPIN") ) // We are inside de PIN diode
185 {
186 gMC->TrackPosition(pos) ;
187 xyze[0] = pos[0] ;
188 xyze[1] = pos[1] ;
189 xyze[2] = pos[2] ;
190 lostenergy = gMC->Edep() ;
191 xyze[3] = gMC->Edep() ;
192
193 if ( xyze[3] != 0 ) {
194 gMC->CurrentVolOffID(11, relid[0]) ; // get the PHOS module number ;
195 relid[1] = 0 ; // means PW04 and PIN
196 gMC->CurrentVolOffID(5, relid[2]) ; // get the row number inside the module
197 gMC->CurrentVolOffID(4, relid[3]) ; // get the cell number inside the module
198
199 // get the absolute Id number
200
201 Int_t absid ;
202 fGeom->RelToAbsNumbering(relid,absid) ;
203
204 // calculating number of electrons in the PIN diode asociated to this hit
205 nElectrons = lostenergy * fElectronsPerGeV ;
206 xyze[3] = nElectrons * fRecalibrationFactor ;
207
208 // add current hit to the hit list
7eb9d12d 209 AddHit(fIshunt, primary, tracknumber, absid, xyze, trackpid);
5f20d3fb 210 //printf("PIN volume is %d, %d, %d, %d \n",relid[0],relid[1],relid[2],relid[3]);
211 //printf("Lost energy in the PIN is %f \n",lostenergy) ;
212 } // there is deposited energy
213 } // we are inside a PHOS XtalPHOS PIN diode
214}