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 //_________________________________________________________________________
19 // Implementation of the PHOS manager class for fast simulations
20 // Tracks particles until the reach a grossly designed PHOS module
21 // Modify the particles property (momentum, energy, type) according to
22 // the PHOS response function. The result is called a virtual reconstructed
25 //*-- Author: Yves Schutz (SUBATECH)
27 // --- ROOT system ---
31 #include "TParticle.h"
32 #include "TGeometry.h"
34 // --- Standard library ---
36 // --- AliRoot header files ---
37 #include "AliPHOSFastRecParticle.h"
38 #include "AliPHOSvFast.h"
39 #include "AliPHOSGetter.h"
42 ClassImp(AliPHOSvFast)
44 //____________________________________________________________________________
45 AliPHOSvFast::AliPHOSvFast() : AliPHOS()
47 // default ctor : initialize data member
51 fFastRecParticles = 0 ;
65 //____________________________________________________________________________
66 AliPHOSvFast::AliPHOSvFast(const char *name, const char *title):
73 AliPHOSGetter::GetInstance(gDirectory->GetName(), 0) ;
75 SetBigBox(0, GetGeometry()->GetOuterBoxSize(0) ) ;
76 SetBigBox(1, GetGeometry()->GetOuterBoxSize(3) + GetGeometry()->GetCPVBoxSize(1) ) ;
77 SetBigBox(2, GetGeometry()->GetOuterBoxSize(2) );
80 fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
82 fResPara1 = 0.030 ; // GeV
86 fPosParaA0 = 2.87 ; // mm
87 fPosParaA1 = -0.0975 ;
90 fPosParaB2 = 0.00619 ;
93 //____________________________________________________________________________
94 AliPHOSvFast::AliPHOSvFast(const AliPHOSvFast & pv):
95 AliPHOS(pv.GetName(), pv.GetTitle())
101 AliPHOSGetter::GetInstance(gDirectory->GetName(), 0) ;
103 SetBigBox(0, pv.fBigBoxX) ;
104 SetBigBox(1, pv.fBigBoxY) ;
105 SetBigBox(2, pv.fBigBoxZ) ;
107 fNRecParticles = pv.fNRecParticles;
108 fFastRecParticles = new TClonesArray( *(pv.fFastRecParticles) ) ;
110 fResPara1 = pv.fResPara1 ;
111 fResPara2 = pv.fResPara2 ;
112 fResPara3 = pv.fResPara3 ;
114 fPosParaA0 = pv.fPosParaA0 ;
115 fPosParaA1 = pv.fPosParaA1 ;
116 fPosParaB0 = pv.fPosParaB0 ;
117 fPosParaB1 = pv.fPosParaB1 ;
118 fPosParaB2 = pv.fPosParaB2 ;
121 //____________________________________________________________________________
122 AliPHOSvFast::~AliPHOSvFast()
126 fFastRecParticles->Delete() ;
127 delete fFastRecParticles ;
128 fFastRecParticles = 0 ;
132 //____________________________________________________________________________
133 void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp)
135 // Add a virtually reconstructed particle to the list
137 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
141 //____________________________________________________________________________
142 void AliPHOSvFast::BuildGeometry()
144 // Build the PHOS geometry for the ROOT display
148 PHOS FAST in ALICE displayed by root
153 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSvFastAllViews.gif">
155 <H4> Front View </H4>
158 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSvFastFrontView.gif">
163 const Int_t kColorPHOS = kRed ;
165 Double_t const kRADDEG = 180.0 / kPI ;
167 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
171 // position PHOS into ALICE
173 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
175 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * GetGeometry()->GetIPtoCrystalSurface() ) ) ;
177 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
179 char * nodename = new char[20] ;
180 char * rotname = new char[20] ;
182 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
183 Float_t angle = pphi * 2 * ( i - GetGeometry()->GetNModules() / 2.0 - 0.5 ) ;
184 sprintf(rotname, "%s%d", "rot", number++) ;
185 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
187 sprintf(nodename,"%s%d", "Module", i) ;
188 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
189 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
190 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
191 bigboxnode->SetLineColor(kColorPHOS) ;
192 fNodes->Add(bigboxnode) ;
198 //____________________________________________________________________________
199 void AliPHOSvFast::CreateGeometry()
201 // Create the geometry for GEANT
203 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
205 if ( phostmp == NULL ) {
207 fprintf(stderr, "PHOS detector not found!\n") ;
212 // Get pointer to the array containing media indeces
213 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
216 bigbox[0] = GetBigBox(0) / 2.0 ;
217 bigbox[1] = GetBigBox(1) / 2.0 ;
218 bigbox[2] = GetBigBox(2) / 2.0 ;
220 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
222 // --- Position PHOS mdules in ALICE setup ---
225 Double_t const kRADDEG = 180.0 / kPI ;
227 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
229 Float_t angle = GetGeometry()->GetPHOSAngle(i) ;
230 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
232 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
234 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
235 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
236 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
243 //____________________________________________________________________________
244 void AliPHOSvFast::Init(void)
246 // Prints out an information message
251 for(i=0;i<35;i++) printf("*");
252 printf(" FAST PHOS_INIT ");
253 for(i=0;i<35;i++) printf("*");
256 // Here the PHOS initialisation code (if any!)
258 for(i=0;i<80;i++) printf("*");
263 //___________________________________________________________________________
264 Float_t AliPHOSvFast::GetBigBox(Int_t index) const
266 // Get the X, Y or Z dimension of the box describing a PHOS module
284 //___________________________________________________________________________
285 void AliPHOSvFast::MakeBranch(Option_t* opt, const char *file)
287 // Create new branch in the current reconstructed Root Tree
289 AliDetector::MakeBranch(opt,file) ;
292 sprintf(branchname,"%s",GetName());
293 const char *cd = strstr(opt,"R");
295 if (fFastRecParticles && gAlice->TreeR() && cd) {
296 MakeBranchInTree(gAlice->TreeR(),
297 branchname, &fFastRecParticles, fBufferSize, file);
301 //____________________________________________________________________________
302 Double_t AliPHOSvFast::MakeEnergy(const Double_t energy)
304 // Smears the energy according to the energy dependent energy resolution.
305 // A gaussian distribution is assumed
307 Double_t sigma = SigmaE(energy) ;
308 return fRan.Gaus(energy, sigma) ;
311 //____________________________________________________________________________
312 TVector3 AliPHOSvFast::MakePosition(const Double_t energy, const TVector3 pos, const Double_t theta, const Double_t phi)
314 // Smears the impact position according to the energy dependent position resolution
315 // A gaussian position distribution is assumed
318 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
319 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
320 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
321 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
322 Double_t y = pos.Y() ;
331 //____________________________________________________________________________
332 void AliPHOSvFast::MakeRecParticle(const Int_t modid, const TVector3 pos, AliPHOSFastRecParticle & rp)
334 // Modify the primary particle properties according
335 // 1. the response function of PHOS
336 // 2. the performance of the EMC+PPSD setup
338 Int_t type = MakeType( rp ) ;
342 // get the detected energy
344 TLorentzVector momentum ;
345 rp.Momentum(momentum) ;
346 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
347 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
348 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
349 + TMath::Power( rp.GetMass(), 2) ) ;
351 // get the angle of incidence
353 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
354 Double_t incidencephi = ( 270 + GetGeometry()->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
356 // get the detected direction
358 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
359 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
361 // Set the modified 4-momentum of the reconstructed particle
363 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
367 //____________________________________________________________________________
368 Int_t AliPHOSvFast::MakeType(AliPHOSFastRecParticle & rp )
370 // Generate a particle type using the performance of the EMC+PPSD setup
372 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
373 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
376 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
379 test = rp.GetPdgCode() ;
381 Fatal("MakeType", "SHOULD NOT BE USED until values of probabilities are properly set ") ;
385 case 22: // it's a photon // NB: ALL VALUES SHOLD BE CHECKED !!!!
388 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
390 rv = AliPHOSFastRecParticle::kNEUTRALEMFAST ;
393 case 2112: // it's a neutron
396 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
398 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
401 case -2112: // it's a anti-neutron
404 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
406 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
409 case 11: // it's a electron
412 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
414 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
417 case -11: // it's a positon
420 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
422 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
425 case -1: // it's a charged
428 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
430 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
439 //___________________________________________________________________________
440 void AliPHOSvFast::ResetPoints()
442 // This overloads the method in AliDetector
444 ResetFastRecParticles() ;
447 //___________________________________________________________________________
448 void AliPHOSvFast::ResetFastRecParticles()
450 // Resets the list of virtual reconstructed particles
452 if (fFastRecParticles)
453 fFastRecParticles->Clear() ;
457 //___________________________________________________________________________
458 void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
460 // Set the size of the Box describing a PHOS module
476 //____________________________________________________________________________
477 Double_t AliPHOSvFast::SigmaE(Double_t energy)
479 // Calculates the energy dependent energy resolution
483 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
484 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
485 + TMath::Power(fResPara3, 2) ) ;
490 //____________________________________________________________________________
491 Double_t AliPHOSvFast::SigmaP(Double_t energy, Double_t incidence)
493 // Calculates the energy dependent position resolution
495 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
496 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
498 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
501 //____________________________________________________________________________
502 void AliPHOSvFast::StepManager(void)
504 // Only verifies if the particle reaches PHOS and stops the tracking
507 gMC->TrackPosition(lv) ;
508 TVector3 pos = lv.Vect() ;
510 gMC->CurrentVolID(modid);
512 Float_t energy = gMC->Etot() ; //Total energy of current track
514 //Calculating mass of current particle
515 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
516 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
517 Float_t mass = partPDG->Mass() ;
520 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
521 TLorentzVector pTrack(pos, energy) ;
523 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
525 AliPHOSFastRecParticle rp(*part) ;
527 // Adds the response of PHOS to the particle
528 MakeRecParticle(modid, pos, rp) ;
530 // add the `track' particle to the FastRecParticles list
536 // stop the track as soon PHOS is reached