1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 /* History of cvs commits:
21 * Revision 1.30 2006/09/13 07:31:01 kharlov
22 * Effective C++ corrections (T.Pocheptsov)
24 * Revision 1.29 2005/05/28 14:19:05 schutz
25 * Compilation warnings fixed by T.P.
29 //_________________________________________________________________________
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
36 //*-- Author: Yves Schutz (SUBATECH)
38 // --- ROOT system ---
40 #include <TGeometry.h>
41 #include <TParticle.h>
42 #include <TDatabasePDG.h>
43 #include "TClonesArray.h"
44 #include <TVirtualMC.h>
46 // --- Standard library ---
48 // --- AliRoot header files ---
49 #include "AliPHOSFastRecParticle.h"
50 #include "AliPHOSGeometry.h"
51 #include "AliPHOSLoader.h"
52 #include "AliPHOSvFast.h"
55 ClassImp(AliPHOSvFast)
57 AliPHOSvFast::AliPHOSvFast() :
73 // default ctor : initialize data member
76 //____________________________________________________________________________
77 AliPHOSvFast::AliPHOSvFast(const char *name, const char *title):
82 fFastRecParticles(new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100)),
85 fResPara1(0.030), // GeV
88 fPosParaA0(2.87), // mm
96 SetBigBox(0, GetGeometry()->GetOuterBoxSize(0) ) ;
97 SetBigBox(1, GetGeometry()->GetOuterBoxSize(3) + GetGeometry()->GetCPVBoxSize(1) ) ;
98 SetBigBox(2, GetGeometry()->GetOuterBoxSize(2) );
101 //____________________________________________________________________________
102 AliPHOSvFast::~AliPHOSvFast()
106 fFastRecParticles->Delete() ;
107 delete fFastRecParticles ;
108 fFastRecParticles = 0 ;
112 //____________________________________________________________________________
113 void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp)
115 // Add a virtually reconstructed particle to the list
117 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
121 //____________________________________________________________________________
122 void AliPHOSvFast::CreateGeometry()
124 // Create the geometry for GEANT
126 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
128 if ( phostmp == NULL ) {
130 fprintf(stderr, "PHOS detector not found!\n") ;
135 // Get pointer to the array containing media indeces
136 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
139 bigbox[0] = GetBigBox(0) / 2.0 ;
140 bigbox[1] = GetBigBox(1) / 2.0 ;
141 bigbox[2] = GetBigBox(2) / 2.0 ;
143 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
145 // --- Position PHOS mdules in ALICE setup ---
148 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
150 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
152 Float_t angle = GetGeometry()->GetPHOSAngle(i) ;
153 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
155 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
157 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
158 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
159 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
166 //____________________________________________________________________________
167 void AliPHOSvFast::Init(void)
169 // Prints out an information message
174 for(i=0;i<35;i++) printf("*");
175 printf(" FAST PHOS_INIT ");
176 for(i=0;i<35;i++) printf("*");
179 // Here the PHOS initialisation code (if any!)
181 for(i=0;i<80;i++) printf("*");
186 //___________________________________________________________________________
187 Float_t AliPHOSvFast::GetBigBox(Int_t index) const
189 // Get the X, Y or Z dimension of the box describing a PHOS module
206 //___________________________________________________________________________
208 void AliPHOSvFast::MakeBranch(Option_t* opt)
210 // Create new branch in the current reconstructed Root Tree
211 AliDetector::MakeBranch(opt);
212 const char *cd = strstr(opt,"R");
214 if (fFastRecParticles && fLoader->TreeR() && cd) {
215 MakeBranchInTree(fLoader->TreeR(), GetName(), &fFastRecParticles, fBufferSize, 0);
218 //____________________________________________________________________________
220 Double_t AliPHOSvFast::MakeEnergy(Double_t energy)
222 // Smears the energy according to the energy dependent energy resolution.
223 // A gaussian distribution is assumed
225 Double_t sigma = SigmaE(energy) ;
226 return fRan.Gaus(energy, sigma) ;
228 //____________________________________________________________________________
230 TVector3 AliPHOSvFast::MakePosition(Double_t energy, TVector3 pos, Double_t theta, Double_t phi)
232 // Smears the impact position according to the energy dependent position resolution
233 // A gaussian position distribution is assumed
236 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
237 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
238 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
239 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
240 Double_t y = pos.Y() ;
249 //____________________________________________________________________________
250 void AliPHOSvFast::MakeRecParticle(Int_t modid, TVector3 pos, AliPHOSFastRecParticle & rp)
252 // Modify the primary particle properties according
253 // 1. the response function of PHOS
254 // 2. the performance of the EMC+PPSD setup
256 Int_t type = MakeType( rp ) ;
260 // get the detected energy
262 TLorentzVector momentum ;
263 rp.Momentum(momentum) ;
264 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
265 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
266 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
267 + TMath::Power( rp.GetMass(), 2) ) ;
269 // get the angle of incidence
271 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
272 Double_t incidencephi = ( 270 + GetGeometry()->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
274 // get the detected direction
276 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
277 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
279 // Set the modified 4-momentum of the reconstructed particle
281 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
285 //____________________________________________________________________________
286 Int_t AliPHOSvFast::MakeType(AliPHOSFastRecParticle & rp )
288 // Generate a particle type using the performance of the EMC+PPSD setup
290 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
291 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
294 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
297 test = rp.GetPdgCode() ;
299 Fatal("MakeType", "SHOULD NOT BE USED until values of probabilities are properly set ") ;
300 // NB: ALL VALUES SHOULD BE CHECKED !!!!
303 case 22: // it's a photon // NB: ALL VALUES SHOLD BE CHECKED !!!!
306 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
308 rv = AliPHOSFastRecParticle::kNEUTRALEMFAST ;
311 case 2112: // it's a neutron
314 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
316 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
319 case -2112: // it's a anti-neutron
322 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
324 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
327 case 11: // it's a electron
330 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
332 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
335 case -11: // it's a positon
338 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
340 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
343 case -1: // it's a charged
346 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
348 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
357 //___________________________________________________________________________
358 void AliPHOSvFast::ResetPoints()
360 // This overloads the method in AliDetector
362 ResetFastRecParticles() ;
365 //___________________________________________________________________________
366 void AliPHOSvFast::ResetFastRecParticles()
368 // Resets the list of virtual reconstructed particles
370 if (fFastRecParticles)
371 fFastRecParticles->Clear() ;
375 //___________________________________________________________________________
376 void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
378 // Set the size of the Box describing a PHOS module
394 //____________________________________________________________________________
395 Double_t AliPHOSvFast::SigmaE(Double_t energy)
397 // Calculates the energy dependent energy resolution
401 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
402 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
403 + TMath::Power(fResPara3, 2) ) ;
408 //____________________________________________________________________________
409 Double_t AliPHOSvFast::SigmaP(Double_t energy, Double_t incidence)
411 // Calculates the energy dependent position resolution
413 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
414 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
416 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
419 //____________________________________________________________________________
420 void AliPHOSvFast::StepManager(void)
422 // Only verifies if the particle reaches PHOS and stops the tracking
425 gMC->TrackPosition(lv) ;
426 TVector3 pos = lv.Vect() ;
428 gMC->CurrentVolID(modid);
430 Float_t energy = gMC->Etot() ; //Total energy of current track
432 //Calculating mass of current particle
433 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
434 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
435 Float_t mass = partPDG->Mass() ;
438 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
439 TLorentzVector pTrack(pos, energy) ;
441 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
443 AliPHOSFastRecParticle rp(*part) ;
445 // Adds the response of PHOS to the particle
446 MakeRecParticle(modid, pos, rp) ;
448 // add the `track' particle to the FastRecParticles list
454 // stop the track as soon PHOS is reached