]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSvFast.cxx
Updated DAs to comply with root known problems
[u/mrichter/AliRoot.git] / PHOS / AliPHOSvFast.cxx
CommitLineData
88cb7938 1 /**************************************************************************
3decf5cb 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
b2a60966 16/* $Id$ */
17
702ab87e 18/* History of cvs commits:
19 *
20 * $Log$
e939a978 21 * Revision 1.30 2006/09/13 07:31:01 kharlov
22 * Effective C++ corrections (T.Pocheptsov)
23 *
43fbaae1 24 * Revision 1.29 2005/05/28 14:19:05 schutz
25 * Compilation warnings fixed by T.P.
26 *
702ab87e 27 */
28
3decf5cb 29//_________________________________________________________________________
b2a60966 30// Implementation of the PHOS manager class for fast simulations
31// Tracks particles until the reach a grossly designed PHOS module
32// Modify the particles property (momentum, energy, type) according to
33// the PHOS response function. The result is called a virtual reconstructed
34// particle.
35//
36//*-- Author: Yves Schutz (SUBATECH)
3decf5cb 37
38// --- ROOT system ---
3a4295ee 39
88cb7938 40#include <TGeometry.h>
88cb7938 41#include <TParticle.h>
e957fea8 42#include "TClonesArray.h"
88cb7938 43#include <TVirtualMC.h>
3decf5cb 44
45// --- Standard library ---
46
3decf5cb 47// --- AliRoot header files ---
3a4295ee 48#include "AliPHOSFastRecParticle.h"
88cb7938 49#include "AliPHOSGeometry.h"
50#include "AliPHOSLoader.h"
3decf5cb 51#include "AliPHOSvFast.h"
3decf5cb 52#include "AliRun.h"
3decf5cb 53
54ClassImp(AliPHOSvFast)
55
43fbaae1 56AliPHOSvFast::AliPHOSvFast() :
57 fBigBoxX(0.),
58 fBigBoxY(0.),
59 fBigBoxZ(0.),
60 fFastRecParticles(0),
61 fNRecParticles(0),
62 fRan(0),
63 fResPara1(0.),
64 fResPara2(0.),
65 fResPara3(0.),
66 fPosParaA0(0.),
67 fPosParaA1(0.),
68 fPosParaB0(0.),
69 fPosParaB1(0.),
70 fPosParaB2(0.)
3decf5cb 71{
3a4295ee 72 // default ctor : initialize data member
3decf5cb 73}
74
75//____________________________________________________________________________
76AliPHOSvFast::AliPHOSvFast(const char *name, const char *title):
43fbaae1 77 AliPHOS(name,title),
78 fBigBoxX(0.),
79 fBigBoxY(0.),
80 fBigBoxZ(0.),
81 fFastRecParticles(new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100)),
82 fNRecParticles(0),
83 fRan(0),
84 fResPara1(0.030), // GeV
85 fResPara2(0.00003),
86 fResPara3(0.00001),
87 fPosParaA0(2.87), // mm
88 fPosParaA1(-0.0975),
89 fPosParaB0(0.257),
90 fPosParaB1(0.137),
91 fPosParaB2(0.00619)
3decf5cb 92{
b2a60966 93 // ctor
88cb7938 94 // create the Loader
7a9d98f9 95 SetBigBox(0, GetGeometry()->GetOuterBoxSize(0) ) ;
96 SetBigBox(1, GetGeometry()->GetOuterBoxSize(3) + GetGeometry()->GetCPVBoxSize(1) ) ;
97 SetBigBox(2, GetGeometry()->GetOuterBoxSize(2) );
3decf5cb 98}
99
100//____________________________________________________________________________
101AliPHOSvFast::~AliPHOSvFast()
102{
b2a60966 103 // dtor
3decf5cb 104
a73f33f0 105 fFastRecParticles->Delete() ;
106 delete fFastRecParticles ;
107 fFastRecParticles = 0 ;
3decf5cb 108
109}
110
111//____________________________________________________________________________
a73f33f0 112void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp)
113{
b2a60966 114 // Add a virtually reconstructed particle to the list
115
f96d3dc7 116 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
117 fNRecParticles++ ;
3decf5cb 118}
119
3decf5cb 120//____________________________________________________________________________
121void AliPHOSvFast::CreateGeometry()
122{
b2a60966 123 // Create the geometry for GEANT
124
3decf5cb 125 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
b2a60966 126
3decf5cb 127 if ( phostmp == NULL ) {
128
129 fprintf(stderr, "PHOS detector not found!\n") ;
130 return ;
131
132 }
133
134 // Get pointer to the array containing media indeces
135 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
136
137 Float_t bigbox[3] ;
138 bigbox[0] = GetBigBox(0) / 2.0 ;
139 bigbox[1] = GetBigBox(1) / 2.0 ;
140 bigbox[2] = GetBigBox(2) / 2.0 ;
141
142 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
143
144 // --- Position PHOS mdules in ALICE setup ---
145
146 Int_t idrotm[99] ;
a8c47ab6 147 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
3decf5cb 148
fa7cce36 149 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
3decf5cb 150
fa7cce36 151 Float_t angle = GetGeometry()->GetPHOSAngle(i) ;
3decf5cb 152 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
153
fa7cce36 154 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
3decf5cb 155
156 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
157 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
3decf5cb 158 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
159
160 } // for GetNModules
161
162}
163
164
165//____________________________________________________________________________
166void AliPHOSvFast::Init(void)
167{
b2a60966 168 // Prints out an information message
169
3decf5cb 170 Int_t i;
171
172 printf("\n");
173 for(i=0;i<35;i++) printf("*");
174 printf(" FAST PHOS_INIT ");
175 for(i=0;i<35;i++) printf("*");
176 printf("\n");
177
178 // Here the PHOS initialisation code (if any!)
179
180 for(i=0;i<80;i++) printf("*");
181 printf("\n");
182
183}
184
185//___________________________________________________________________________
3a4295ee 186Float_t AliPHOSvFast::GetBigBox(Int_t index) const
3decf5cb 187{
b2a60966 188 // Get the X, Y or Z dimension of the box describing a PHOS module
189
3decf5cb 190 Float_t rv = 0 ;
191
192 switch (index) {
193 case 0:
194 rv = fBigBoxX ;
195 break ;
196 case 1:
197 rv = fBigBoxY ;
198 break ;
199 case 2:
200 rv = fBigBoxZ ;
201 break ;
202 }
203 return rv ;
204}
3decf5cb 205//___________________________________________________________________________
88cb7938 206
207void AliPHOSvFast::MakeBranch(Option_t* opt)
3decf5cb 208{
b2a60966 209 // Create new branch in the current reconstructed Root Tree
88cb7938 210 AliDetector::MakeBranch(opt);
3a4295ee 211 const char *cd = strstr(opt,"R");
3decf5cb 212
88cb7938 213 if (fFastRecParticles && fLoader->TreeR() && cd) {
214 MakeBranchInTree(fLoader->TreeR(), GetName(), &fFastRecParticles, fBufferSize, 0);
3decf5cb 215 }
216}
a73f33f0 217//____________________________________________________________________________
88cb7938 218
fc7e2f43 219Double_t AliPHOSvFast::MakeEnergy(Double_t energy)
a73f33f0 220{
b2a60966 221 // Smears the energy according to the energy dependent energy resolution.
222 // A gaussian distribution is assumed
223
b1aa729d 224 Double_t sigma = SigmaE(energy) ;
225 return fRan.Gaus(energy, sigma) ;
a73f33f0 226}
a73f33f0 227//____________________________________________________________________________
88cb7938 228
fc7e2f43 229TVector3 AliPHOSvFast::MakePosition(Double_t energy, TVector3 pos, Double_t theta, Double_t phi)
a73f33f0 230{
b2a60966 231 // Smears the impact position according to the energy dependent position resolution
232 // A gaussian position distribution is assumed
233
b1aa729d 234 TVector3 newpos ;
235 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
236 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
237 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
238 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
239 Double_t y = pos.Y() ;
240
241 newpos.SetX(x) ;
242 newpos.SetY(y) ;
243 newpos.SetZ(z) ;
244
245 return newpos ;
246}
a73f33f0 247
b1aa729d 248//____________________________________________________________________________
fc7e2f43 249void AliPHOSvFast::MakeRecParticle(Int_t modid, TVector3 pos, AliPHOSFastRecParticle & rp)
b1aa729d 250{
b2a60966 251 // Modify the primary particle properties according
252 // 1. the response function of PHOS
253 // 2. the performance of the EMC+PPSD setup
254
b1aa729d 255 Int_t type = MakeType( rp ) ;
a73f33f0 256 rp.SetType(type) ;
257
258
259 // get the detected energy
260
261 TLorentzVector momentum ;
262 rp.Momentum(momentum) ;
263 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
264 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
b1aa729d 265 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
266 + TMath::Power( rp.GetMass(), 2) ) ;
267
268 // get the angle of incidence
269
270 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
fa7cce36 271 Double_t incidencephi = ( 270 + GetGeometry()->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
b1aa729d 272
273 // get the detected direction
274
275 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
276 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
277
278 // Set the modified 4-momentum of the reconstructed particle
279
280 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
281
a73f33f0 282 }
283
284//____________________________________________________________________________
b1aa729d 285Int_t AliPHOSvFast::MakeType(AliPHOSFastRecParticle & rp )
a73f33f0 286{
b2a60966 287 // Generate a particle type using the performance of the EMC+PPSD setup
288
9ec91567 289 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
b1aa729d 290 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
291 Int_t test ;
292 Float_t ran ;
f96d3dc7 293 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
b1aa729d 294 test = - 1 ;
295 else
296 test = rp.GetPdgCode() ;
297
a4765fe4 298 Fatal("MakeType", "SHOULD NOT BE USED until values of probabilities are properly set ") ;
299 // NB: ALL VALUES SHOULD BE CHECKED !!!!
b1aa729d 300 switch (test) {
301
3a4295ee 302 case 22: // it's a photon // NB: ALL VALUES SHOLD BE CHECKED !!!!
b1aa729d 303 ran = fRan.Rndm() ;
3a4295ee 304 if( ran <= 0.9498 )
305 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
306 else
307 rv = AliPHOSFastRecParticle::kNEUTRALEMFAST ;
b1aa729d 308 break ;
309
310 case 2112: // it's a neutron
311 ran = fRan.Rndm() ;
312 if ( ran <= 0.9998 )
3a4295ee 313 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
b1aa729d 314 else
3a4295ee 315 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
b1aa729d 316 break ;
3a4295ee 317
b1aa729d 318 case -2112: // it's a anti-neutron
319 ran = fRan.Rndm() ;
320 if ( ran <= 0.9984 )
3a4295ee 321 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
b1aa729d 322 else
3a4295ee 323 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
b1aa729d 324 break ;
325
326 case 11: // it's a electron
327 ran = fRan.Rndm() ;
328 if ( ran <= 0.9996 )
3a4295ee 329 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
b1aa729d 330 else
3a4295ee 331 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
b1aa729d 332 break;
333
f96d3dc7 334 case -11: // it's a positon
b1aa729d 335 ran = fRan.Rndm() ;
336 if ( ran <= 0.9996 )
3a4295ee 337 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
b1aa729d 338 else
3a4295ee 339 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
b1aa729d 340 break;
341
342 case -1: // it's a charged
343 ran = fRan.Rndm() ;
344 if ( ran <= 0.9996 )
3a4295ee 345 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
b1aa729d 346 else
3a4295ee 347 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
b1aa729d 348
349 break ;
350 }
351
352
a73f33f0 353 return rv ;
354}
355
f96d3dc7 356//___________________________________________________________________________
357void AliPHOSvFast::ResetPoints()
358{
b2a60966 359 // This overloads the method in AliDetector
360
f96d3dc7 361 ResetFastRecParticles() ;
362}
363
364//___________________________________________________________________________
365void AliPHOSvFast::ResetFastRecParticles()
366{
b2a60966 367 // Resets the list of virtual reconstructed particles
368
f96d3dc7 369 if (fFastRecParticles)
370 fFastRecParticles->Clear() ;
371 fNRecParticles = 0 ;
372}
373
3decf5cb 374//___________________________________________________________________________
375void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
376{
b2a60966 377 // Set the size of the Box describing a PHOS module
378
3decf5cb 379 switch (index) {
380 case 0:
381 fBigBoxX = value ;
382 break ;
383 case 1:
384 fBigBoxY = value ;
385 break ;
386 case 2:
387 fBigBoxZ = value ;
388 break ;
389 }
390
391}
392
a73f33f0 393//____________________________________________________________________________
394Double_t AliPHOSvFast::SigmaE(Double_t energy)
395{
b2a60966 396 // Calculates the energy dependent energy resolution
397
a73f33f0 398 Double_t rv = -1 ;
399
400 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
401 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
402 + TMath::Power(fResPara3, 2) ) ;
403
404 return rv * energy ;
405}
406
b1aa729d 407//____________________________________________________________________________
7a9d98f9 408Double_t AliPHOSvFast::SigmaP(Double_t energy, Double_t incidence)
b1aa729d 409{
b2a60966 410 // Calculates the energy dependent position resolution
411
b1aa729d 412 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
413 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
414
415 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
416}
417
3decf5cb 418//____________________________________________________________________________
419void AliPHOSvFast::StepManager(void)
420{
b2a60966 421 // Only verifies if the particle reaches PHOS and stops the tracking
3a4295ee 422
a73f33f0 423 TLorentzVector lv ;
424 gMC->TrackPosition(lv) ;
b1aa729d 425 TVector3 pos = lv.Vect() ;
426 Int_t modid ;
427 gMC->CurrentVolID(modid);
a73f33f0 428
3a4295ee 429 Float_t energy = gMC->Etot() ; //Total energy of current track
3decf5cb 430
3a4295ee 431 //Calculating mass of current particle
432 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
433 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
434 Float_t mass = partPDG->Mass() ;
a73f33f0 435
3a4295ee 436 if(energy > mass){
437 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
438 TLorentzVector pTrack(pos, energy) ;
a73f33f0 439
3a4295ee 440 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
441
442 AliPHOSFastRecParticle rp(*part) ;
b1aa729d 443
3a4295ee 444 // Adds the response of PHOS to the particle
445 MakeRecParticle(modid, pos, rp) ;
446
447 // add the `track' particle to the FastRecParticles list
b1aa729d 448
3a4295ee 449 AddRecParticle(rp) ;
a73f33f0 450
3a4295ee 451 part->Delete() ;
452 }
a73f33f0 453 // stop the track as soon PHOS is reached
b1aa729d 454
3decf5cb 455 gMC->StopTrack() ;
456
457}
458