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 "TClonesArray.h"
43 #include <TVirtualMC.h>
45 // --- Standard library ---
47 // --- AliRoot header files ---
48 #include "AliPHOSFastRecParticle.h"
49 #include "AliPHOSGeometry.h"
50 #include "AliPHOSLoader.h"
51 #include "AliPHOSvFast.h"
54 ClassImp(AliPHOSvFast)
56 AliPHOSvFast::AliPHOSvFast() :
72 // default ctor : initialize data member
75 //____________________________________________________________________________
76 AliPHOSvFast::AliPHOSvFast(const char *name, const char *title):
81 fFastRecParticles(new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100)),
84 fResPara1(0.030), // GeV
87 fPosParaA0(2.87), // mm
95 SetBigBox(0, GetGeometry()->GetOuterBoxSize(0) ) ;
96 SetBigBox(1, GetGeometry()->GetOuterBoxSize(3) + GetGeometry()->GetCPVBoxSize(1) ) ;
97 SetBigBox(2, GetGeometry()->GetOuterBoxSize(2) );
100 //____________________________________________________________________________
101 AliPHOSvFast::~AliPHOSvFast()
105 fFastRecParticles->Delete() ;
106 delete fFastRecParticles ;
107 fFastRecParticles = 0 ;
111 //____________________________________________________________________________
112 void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp)
114 // Add a virtually reconstructed particle to the list
116 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
120 //____________________________________________________________________________
121 void AliPHOSvFast::CreateGeometry()
123 // Create the geometry for GEANT
125 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
127 if ( phostmp == NULL ) {
129 fprintf(stderr, "PHOS detector not found!\n") ;
134 // Get pointer to the array containing media indeces
135 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
138 bigbox[0] = GetBigBox(0) / 2.0 ;
139 bigbox[1] = GetBigBox(1) / 2.0 ;
140 bigbox[2] = GetBigBox(2) / 2.0 ;
142 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
144 // --- Position PHOS mdules in ALICE setup ---
147 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
149 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
151 Float_t angle = GetGeometry()->GetPHOSAngle(i) ;
152 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
154 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
156 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
157 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
158 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
165 //____________________________________________________________________________
166 void AliPHOSvFast::Init(void)
168 // Prints out an information message
173 for(i=0;i<35;i++) printf("*");
174 printf(" FAST PHOS_INIT ");
175 for(i=0;i<35;i++) printf("*");
178 // Here the PHOS initialisation code (if any!)
180 for(i=0;i<80;i++) printf("*");
185 //___________________________________________________________________________
186 Float_t AliPHOSvFast::GetBigBox(Int_t index) const
188 // Get the X, Y or Z dimension of the box describing a PHOS module
205 //___________________________________________________________________________
207 void AliPHOSvFast::MakeBranch(Option_t* opt)
209 // Create new branch in the current reconstructed Root Tree
210 AliDetector::MakeBranch(opt);
211 const char *cd = strstr(opt,"R");
213 if (fFastRecParticles && fLoader->TreeR() && cd) {
214 MakeBranchInTree(fLoader->TreeR(), GetName(), &fFastRecParticles, fBufferSize, 0);
217 //____________________________________________________________________________
219 Double_t AliPHOSvFast::MakeEnergy(Double_t energy)
221 // Smears the energy according to the energy dependent energy resolution.
222 // A gaussian distribution is assumed
224 Double_t sigma = SigmaE(energy) ;
225 return fRan.Gaus(energy, sigma) ;
227 //____________________________________________________________________________
229 TVector3 AliPHOSvFast::MakePosition(Double_t energy, TVector3 pos, Double_t theta, Double_t phi)
231 // Smears the impact position according to the energy dependent position resolution
232 // A gaussian position distribution is assumed
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() ;
248 //____________________________________________________________________________
249 void AliPHOSvFast::MakeRecParticle(Int_t modid, TVector3 pos, AliPHOSFastRecParticle & rp)
251 // Modify the primary particle properties according
252 // 1. the response function of PHOS
253 // 2. the performance of the EMC+PPSD setup
255 Int_t type = MakeType( rp ) ;
259 // get the detected energy
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 ) ;
265 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
266 + TMath::Power( rp.GetMass(), 2) ) ;
268 // get the angle of incidence
270 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
271 Double_t incidencephi = ( 270 + GetGeometry()->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
273 // get the detected direction
275 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
276 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
278 // Set the modified 4-momentum of the reconstructed particle
280 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
284 //____________________________________________________________________________
285 Int_t AliPHOSvFast::MakeType(AliPHOSFastRecParticle & rp )
287 // Generate a particle type using the performance of the EMC+PPSD setup
289 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
290 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
293 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
296 test = rp.GetPdgCode() ;
298 Fatal("MakeType", "SHOULD NOT BE USED until values of probabilities are properly set ") ;
299 // NB: ALL VALUES SHOULD BE CHECKED !!!!
302 case 22: // it's a photon // NB: ALL VALUES SHOLD BE CHECKED !!!!
305 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
307 rv = AliPHOSFastRecParticle::kNEUTRALEMFAST ;
310 case 2112: // it's a neutron
313 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
315 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
318 case -2112: // it's a anti-neutron
321 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
323 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
326 case 11: // it's a electron
329 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
331 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
334 case -11: // it's a positon
337 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
339 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
342 case -1: // it's a charged
345 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
347 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
356 //___________________________________________________________________________
357 void AliPHOSvFast::ResetPoints()
359 // This overloads the method in AliDetector
361 ResetFastRecParticles() ;
364 //___________________________________________________________________________
365 void AliPHOSvFast::ResetFastRecParticles()
367 // Resets the list of virtual reconstructed particles
369 if (fFastRecParticles)
370 fFastRecParticles->Clear() ;
374 //___________________________________________________________________________
375 void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
377 // Set the size of the Box describing a PHOS module
393 //____________________________________________________________________________
394 Double_t AliPHOSvFast::SigmaE(Double_t energy)
396 // Calculates the energy dependent energy resolution
400 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
401 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
402 + TMath::Power(fResPara3, 2) ) ;
407 //____________________________________________________________________________
408 Double_t AliPHOSvFast::SigmaP(Double_t energy, Double_t incidence)
410 // Calculates the energy dependent position resolution
412 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
413 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
415 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
418 //____________________________________________________________________________
419 void AliPHOSvFast::StepManager(void)
421 // Only verifies if the particle reaches PHOS and stops the tracking
424 gMC->TrackPosition(lv) ;
425 TVector3 pos = lv.Vect() ;
427 gMC->CurrentVolID(modid);
429 Float_t energy = gMC->Etot() ; //Total energy of current track
431 //Calculating mass of current particle
432 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
433 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
434 Float_t mass = partPDG->Mass() ;
437 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
438 TLorentzVector pTrack(pos, energy) ;
440 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
442 AliPHOSFastRecParticle rp(*part) ;
444 // Adds the response of PHOS to the particle
445 MakeRecParticle(modid, pos, rp) ;
447 // add the `track' particle to the FastRecParticles list
453 // stop the track as soon PHOS is reached