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