]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSv3.cxx
Cosmetics
[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//
50abc6f8 27//*-- Author: Odd Harald Odland & Gines Martinez (SUBATECH)
5f20d3fb 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"
97cee223 44#include "AliPHOSCPVDigit.h"
5f20d3fb 45#include "AliRun.h"
46#include "AliConst.h"
94de3818 47#include "AliMC.h"
97cee223 48#include "AliPHOSGeometry.h"
5f20d3fb 49
50ClassImp(AliPHOSv3)
51
735e58f1 52//____________________________________________________________________________
53 AliPHOSv3::AliPHOSv3(void) : AliPHOSv1()
54{
55 // default ctor: initialize daa members
56
57 fLightYieldMean = 0. ;
58 fIntrinsicPINEfficiency = 0. ;
59 fLightYieldAttenuation = 0. ;
60 fRecalibrationFactor = 0. ;
3dab1cef 61 fElectronsPerGeV = 0. ;
62 fAPDGain = 0. ;
735e58f1 63
64}
65
5f20d3fb 66//____________________________________________________________________________
e04976bd 67 AliPHOSv3::AliPHOSv3(const char *name, const char *title):
68AliPHOSv1(name,title)
5f20d3fb 69{
70 // ctor
71
3dab1cef 72 // The light yield is a poissonian distribution of the number of
73 // photons created in the PbWo4 crystal, calculated using following formula
74 // NumberOfPhotons = EnergyLost * LightYieldMean* APDEfficiency *
75 // exp (-LightYieldAttenuation * DistanceToPINdiodeFromTheHit);
76 // LightYieldMean is parameter calculated to be over 47000 photons per GeV
77 // APDEfficiency is 0.02655
5f20d3fb 78 // k_0 is 0.0045 from Valery Antonenko
3dab1cef 79 // The number of electrons created in the APD is
80 // NumberOfElectrons = APDGain * LightYield
81 // The APD Gain is 300
82
83 fLightYieldMean = 47000;
84 fIntrinsicPINEfficiency = 0.02655 ; //APD= 0.1875/0.1271 * 0.018 (PIN)
85 fLightYieldAttenuation = 0.0045 ;
86 fRecalibrationFactor = 13.418/ fLightYieldMean ;
87 fElectronsPerGeV = 2.77e+8 ;
88 fAPDGain= 300. ;
5f20d3fb 89}
90
97cee223 91// //____________________________________________________________________________
92// AliPHOSv3::AliPHOSv3(AliPHOSReconstructioner * Reconstructioner, const char *name, const char *title):
93// AliPHOSv1(Reconstructioner,name,title)
94// {
95// // ctor
96
97// // Number of electrons created in the PIN due to light collected in the PbWo4 crystal is calculated using
98// // following formula
99// // NumberOfElectrons = EnergyLost * LightYield * PINEfficiency *
100// // exp (-LightYieldAttenuation * DistanceToPINdiodeFromTheHit) *
101// // RecalibrationFactor ;
102// // LightYield is obtained as a Poissonian distribution with a mean at 700000 photons per GeV fromValery Antonenko
50abc6f8 103// // PINEfficiency is 0.1875
97cee223 104// // k_0 is 0.0045 from Valery Antonenko
105
106// fLightYieldMean = 700000.;
107// fIntrinsicPINEfficiency = 0.1875 ;
108// fLightYieldAttenuation = 0.0045 ;
109// fRecalibrationFactor = 6.2 / fLightYieldMean ;
50abc6f8 110// fRecalibrationFactor = 5.67 /fLightYieldMean ;//25.04.2001 OHO
97cee223 111// fElectronsPerGeV = 2.77e+8 ;
112// }
5f20d3fb 113//____________________________________________________________________________
037cc66d 114
5f20d3fb 115void AliPHOSv3::StepManager(void)
116{
117 // Accumulates hits as long as the track stays in a single crystal or PPSD gas Cell
037cc66d 118
119// if (gMC->IsTrackEntering())
120// cout << "Track enters the volume " << gMC->CurrentVolName() << endl;
121// if (gMC->IsTrackExiting())
122// cout << "Track leaves the volume " << gMC->CurrentVolName() << endl;
5f20d3fb 123
5c617c31 124 Int_t relid[4] ; // (box, layer, row, column) indices
125 Int_t absid ; // absolute cell ID number
037cc66d 126 Float_t xyze[4]={0,0,0,0} ; // position wrt MRS and energy deposited
3dab1cef 127
128 TLorentzVector pos ; // Lorentz vector of the track current position
037cc66d 129 Int_t copy ;
3dab1cef 130 Float_t fLightYield ; // Light Yield per GeV
131
5f20d3fb 132 Int_t tracknumber = gAlice->CurrentTrack() ;
037cc66d 133 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
fa7cce36 134 TString name = GetGeometry()->GetName() ;
50abc6f8 135 Float_t lostenergy ;
136 Float_t global[3] ;
137 Float_t local[3] ;
037cc66d 138
139
140 if ( name == "GPS2" || name == "MIXT" ) { // ======> CPV is a GPS' PPSD
5f20d3fb 141
dc999bc0 142 if( gMC->CurrentVolID(copy) == gMC->VolId("PPCE") ) // We are inside a gas cell
5f20d3fb 143 {
144 gMC->TrackPosition(pos) ;
145 xyze[0] = pos[0] ;
146 xyze[1] = pos[1] ;
147 xyze[2] = pos[2] ;
037cc66d 148 xyze[3] = gMC->Edep() ;
5f20d3fb 149
b37750a6 150 if ( xyze[3] != 0) { // there is deposited energy
5f20d3fb 151 gMC->CurrentVolOffID(5, relid[0]) ; // get the PHOS Module number
037cc66d 152 if ( name == "MIXT" && strcmp(gMC->CurrentVolOffName(5),"PHO1") == 0 ){
fa7cce36 153 relid[0] += GetGeometry()->GetNModules() - GetGeometry()->GetNPPSDModules();
037cc66d 154 }
5f20d3fb 155 gMC->CurrentVolOffID(3, relid[1]) ; // get the Micromegas Module number
fa7cce36 156 // 1-> GetGeometry()->GetNumberOfModulesPhi() * GetGeometry()->GetNumberOfModulesZ() upper
157 // > GetGeometry()->GetNumberOfModulesPhi() * GetGeometry()->GetNumberOfModulesZ() lower
5f20d3fb 158 gMC->CurrentVolOffID(1, relid[2]) ; // get the row number of the cell
159 gMC->CurrentVolID(relid[3]) ; // get the column number
160
161 // get the absolute Id number
162
fa7cce36 163 GetGeometry()->RelToAbsNumbering(relid, absid) ;
037cc66d 164
165 // add current hit to the hit list
b37750a6 166 AddHit(fIshunt, primary, tracknumber, absid, xyze);
5f20d3fb 167
5f20d3fb 168
169 } // there is deposited energy
037cc66d 170 } // We are inside the gas of the CPV
171 } // GPS2 configuration
172
173 if ( name == "IHEP" || name == "MIXT" ) { // ======> CPV is a IHEP's one
174
175 // Yuri Kharlov, 28 September 2000
176
97cee223 177 if( gMC->CurrentVolID(copy) == gMC->VolId("PCPQ") &&
b37750a6 178 gMC->IsTrackEntering() &&
037cc66d 179 gMC->TrackCharge() != 0) {
b37750a6 180
181 gMC -> TrackPosition(pos);
182 Float_t xyzm[3], xyzd[3] ;
183 Int_t i;
184 for (i=0; i<3; i++) xyzm[i] = pos[i];
185 gMC -> Gmtod (xyzm, xyzd, 1); // transform coordinate from master to daughter system
186
187 Float_t xyd[3]={0,0,0} ; //local posiiton of the entering
188 xyd[0] = xyzd[0];
189 xyd[1] =-xyzd[1];
190 xyd[2] =-xyzd[2];
191
192
193 // Current momentum of the hit's track in the local ref. system
194 TLorentzVector pmom ; //momentum of the particle initiated hit
195 gMC -> TrackMomentum(pmom);
196 Float_t pm[3], pd[3];
197 for (i=0; i<3; i++) pm[i] = pmom[i];
198 gMC -> Gmtod (pm, pd, 2); // transform 3-momentum from master to daughter system
199 pmom[0] = pd[0];
200 pmom[1] =-pd[1];
201 pmom[2] =-pd[2];
037cc66d 202
203 // Digitize the current CPV hit:
204
205 // 1. find pad response and
206
207 Int_t moduleNumber;
208 gMC->CurrentVolOffID(3,moduleNumber);
209 moduleNumber--;
210
211
212 TClonesArray *cpvDigits = new TClonesArray("AliPHOSCPVDigit",0); // array of digits for current hit
213 CPVDigitize(pmom,xyd,moduleNumber,cpvDigits);
214
215 Float_t xmean = 0;
216 Float_t zmean = 0;
217 Float_t qsum = 0;
218 Int_t idigit,ndigits;
219
220 // 2. go through the current digit list and sum digits in pads
221
222 ndigits = cpvDigits->GetEntriesFast();
223 for (idigit=0; idigit<ndigits-1; idigit++) {
29b077b5 224 AliPHOSCPVDigit *cpvDigit1 = dynamic_cast<AliPHOSCPVDigit*>(cpvDigits->UncheckedAt(idigit));
037cc66d 225 Float_t x1 = cpvDigit1->GetXpad() ;
226 Float_t z1 = cpvDigit1->GetYpad() ;
227 for (Int_t jdigit=idigit+1; jdigit<ndigits; jdigit++) {
29b077b5 228 AliPHOSCPVDigit *cpvDigit2 = dynamic_cast<AliPHOSCPVDigit*>(cpvDigits->UncheckedAt(jdigit));
037cc66d 229 Float_t x2 = cpvDigit2->GetXpad() ;
230 Float_t z2 = cpvDigit2->GetYpad() ;
231 if (x1==x2 && z1==z2) {
232 Float_t qsum = cpvDigit1->GetQpad() + cpvDigit2->GetQpad() ;
233 cpvDigit2->SetQpad(qsum) ;
234 cpvDigits->RemoveAt(idigit) ;
235 }
236 }
237 }
238 cpvDigits->Compress() ;
239
240 // 3. add digits to temporary hit list fTmpHits
241
242 ndigits = cpvDigits->GetEntriesFast();
243 for (idigit=0; idigit<ndigits; idigit++) {
29b077b5 244 AliPHOSCPVDigit *cpvDigit = dynamic_cast<AliPHOSCPVDigit*>(cpvDigits->UncheckedAt(idigit));
037cc66d 245 relid[0] = moduleNumber + 1 ; // CPV (or PHOS) module number
246 relid[1] =-1 ; // means CPV
247 relid[2] = cpvDigit->GetXpad() ; // column number of a pad
248 relid[3] = cpvDigit->GetYpad() ; // row number of a pad
249
250 // get the absolute Id number
fa7cce36 251 GetGeometry()->RelToAbsNumbering(relid, absid) ;
037cc66d 252
253 // add current digit to the temporary hit list
254 xyze[0] = 0. ;
255 xyze[1] = 0. ;
256 xyze[2] = 0. ;
257 xyze[3] = cpvDigit->GetQpad() ; // amplitude in a pad
258 primary = -1; // No need in primary for CPV
b37750a6 259 AddHit(fIshunt, primary, tracknumber, absid, xyze);
037cc66d 260
261 if (cpvDigit->GetQpad() > 0.02) {
262 xmean += cpvDigit->GetQpad() * (cpvDigit->GetXpad() + 0.5);
263 zmean += cpvDigit->GetQpad() * (cpvDigit->GetYpad() + 0.5);
264 qsum += cpvDigit->GetQpad();
265 }
266 }
267 delete cpvDigits;
268 }
269 } // end of IHEP configuration
5f20d3fb 270
5f20d3fb 271
50abc6f8 272if(gMC->CurrentVolID(copy)==gMC->VolId("PXTL")){// We are inside a PBWO4 crystal
037cc66d 273 gMC->TrackPosition(pos) ;
274 xyze[0] = pos[0] ;
275 xyze[1] = pos[1] ;
276 xyze[2] = pos[2] ;
50abc6f8 277 global[0] = pos[0] ;
278 global[1] = pos[1] ;
279 global[2] = pos[2] ;
280 lostenergy = gMC->Edep();
037cc66d 281 xyze[3] = gMC->Edep() ;
5f20d3fb 282
037cc66d 283
50abc6f8 284 if ( (xyze[3] != 0) ){//Track is inside the crystal and deposits some energy
5f20d3fb 285
037cc66d 286 gMC->CurrentVolOffID(10, relid[0]) ; // get the PHOS module number ;
5f20d3fb 287
037cc66d 288 if ( name == "MIXT" && strcmp(gMC->CurrentVolOffName(10),"PHO1") == 0 )
fa7cce36 289 relid[0] += GetGeometry()->GetNModules() - GetGeometry()->GetNPPSDModules();
037cc66d 290
291 relid[1] = 0 ; // means PBW04
50abc6f8 292 gMC->CurrentVolOffID(4, relid[2]) ; // get the row number inside the module
293 gMC->CurrentVolOffID(3, relid[3]) ; // get the cell number inside the module
037cc66d 294
5f20d3fb 295 // get the absolute Id number
50abc6f8 296
3dab1cef 297 GetGeometry()->RelToAbsNumbering(relid, absid) ;
037cc66d 298
3dab1cef 299 gMC->Gmtod(global, local, 1) ;
50abc6f8 300
3dab1cef 301 //Calculates the light yield, the number of photns produced in the
302 //crystal
303 fLightYield = gRandom->Poisson(
304 fLightYieldMean * lostenergy *
305 fIntrinsicPINEfficiency *
306 exp(-fLightYieldAttenuation *
307 (local[1]+GetGeometry()->GetCrystalSize(1)/2.0 ))
308 ) ;
309 //Calculates de energy deposited in the crystal
310 xyze[3] = (fRecalibrationFactor/100.) * fAPDGain * fLightYield ;
311
68140e39 312
3dab1cef 313 // cout<<"xyze[3]: "<<xyze[3]<< endl;
68140e39 314 //cout<<"lostenergy: "<<lostenergy<<endl;
50abc6f8 315
50abc6f8 316
3dab1cef 317
50abc6f8 318
037cc66d 319 // add current hit to the hit list
3dab1cef 320
50abc6f8 321
3dab1cef 322 if (xyze[3] != 0.) AddHit(fIshunt, primary,tracknumber, absid, xyze);
323
5f20d3fb 324
037cc66d 325 } // there is deposited energy
326 } // we are inside a PHOS Xtal
327
3dab1cef 328// if(gMC->CurrentVolID(copy) == gMC->VolId("PPIN"))//We are inside the PIN diode
329// {
330// cout<<" Inside PIN "<<endl;
331// gMC->TrackPosition(pos) ;
332// global[0] = pos[0] ;
333// global[1] = pos[1] ;
334// global[2] = pos[2] ;
335// xyze[0] = pos[0] ;
336// xyze[1] = pos[1] ;
337// xyze[2] = pos[2] ;
338// lostenergy = gMC->Edep() ;
339// xyze[3] = gMC->Edep() ;
037cc66d 340
3dab1cef 341// if ( xyze[3] != 0 ) {
342// gMC->CurrentVolOffID(11, relid[0]) ; // get the PHOS module number ;
343// relid[1] = 0 ; // means PW04 and PIN
344// gMC->CurrentVolOffID(5, relid[2]) ; // get the row number inside the module
345// gMC->CurrentVolOffID(4, relid[3]) ; // get the cell number inside the module
037cc66d 346
3dab1cef 347// // get the absolute Id number
037cc66d 348
3dab1cef 349// Int_t absid ;
350// GetGeometry()->RelToAbsNumbering(relid,absid) ;
351// gMC->Gmtod(global, local, 1) ;
50abc6f8 352
3dab1cef 353// // calculating number of electrons in the PIN diode asociated to this hit
50abc6f8 354
3dab1cef 355// //nElectrons = lostenergy * fElectronsPerGeV ;
356// // xyze[3] = nElectrons * fRecalibrationFactor ;
357// apdgain = gRandom->Poisson(300.) ;
358// // apdgain = 300.;
359// //if(local[1]<-0.0045) xyze[3] = apdgain * nElectrons * fRecalibrationFactor/10000.;
68140e39 360
3dab1cef 361// if(local[1]<-0.0045) xyze[3] = apdgain * lostenergy * fElectronsPerGeV* (fRecalibrationFactor/100.);
68140e39 362
3dab1cef 363// //if((local[1]>-0.0045)&&(gMC->TrackPid()==-11)) xyze[3] = apdgain * nElectrons * fRecalibrationFactor/10000.;
68140e39 364
3dab1cef 365// if((local[1]>-0.0045)&&(gMC->TrackPid()==-11)) xyze[3] = apdgain * lostenergy * fElectronsPerGeV * (fRecalibrationFactor/100.);
68140e39 366
3dab1cef 367// //if(local[1]>-0.0045) xyze[3] = nElectrons * fRecalibrationFactor/10000.;
68140e39 368
3dab1cef 369// if(local[1]>-0.0045) xyze[3] = lostenergy * fElectronsPerGeV * (fRecalibrationFactor/100.);
037cc66d 370
3dab1cef 371// // add current hit to the hit list
50abc6f8 372
3dab1cef 373// AddHit(fIshunt, primary, tracknumber, absid, xyze);
50abc6f8 374
3dab1cef 375// //printf("PIN volume is %d, %d, %d, %d \n",relid[0],relid[1],relid[2],relid[3]);
376// printf("Lost energy in the PIN is %f \n",lostenergy) ;
377// } // there is deposited energy
378// } // we are inside a PHOS XtalPHOS PIN diode
5f20d3fb 379}