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 <TGeometry.h>
33 #include <TParticle.h>
35 #include <TVirtualMC.h>
37 // --- Standard library ---
39 // --- AliRoot header files ---
41 #include "AliPHOSFastRecParticle.h"
42 #include "AliPHOSGeometry.h"
43 #include "AliPHOSLoader.h"
44 #include "AliPHOSvFast.h"
47 ClassImp(AliPHOSvFast)
49 //____________________________________________________________________________
50 AliPHOSvFast::AliPHOSvFast() : AliPHOS()
52 // default ctor : initialize data member
56 fFastRecParticles = 0 ;
70 //____________________________________________________________________________
71 AliPHOSvFast::AliPHOSvFast(const char *name, const char *title):
79 SetBigBox(0, GetGeometry()->GetOuterBoxSize(0) ) ;
80 SetBigBox(1, GetGeometry()->GetOuterBoxSize(3) + GetGeometry()->GetCPVBoxSize(1) ) ;
81 SetBigBox(2, GetGeometry()->GetOuterBoxSize(2) );
84 fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
86 fResPara1 = 0.030 ; // GeV
90 fPosParaA0 = 2.87 ; // mm
91 fPosParaA1 = -0.0975 ;
94 fPosParaB2 = 0.00619 ;
97 //____________________________________________________________________________
98 AliPHOSvFast::~AliPHOSvFast()
102 fFastRecParticles->Delete() ;
103 delete fFastRecParticles ;
104 fFastRecParticles = 0 ;
108 //____________________________________________________________________________
109 void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp)
111 // Add a virtually reconstructed particle to the list
113 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
117 //____________________________________________________________________________
118 void AliPHOSvFast::BuildGeometry()
120 // Build the PHOS geometry for the ROOT display
124 PHOS FAST in ALICE displayed by root
129 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSvFastAllViews.gif">
131 <H4> Front View </H4>
134 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSvFastFrontView.gif">
139 const Int_t kColorPHOS = kRed ;
141 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
143 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
147 // position PHOS into ALICE
149 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
151 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * GetGeometry()->GetIPtoCrystalSurface() ) ) ;
153 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
155 char * nodename = new char[20] ;
156 char * rotname = new char[20] ;
158 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
159 Float_t angle = pphi * 2 * ( i - GetGeometry()->GetNModules() / 2.0 - 0.5 ) ;
160 sprintf(rotname, "%s%d", "rot", number++) ;
161 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
163 sprintf(nodename,"%s%d", "Module", i) ;
164 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
165 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
166 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
167 bigboxnode->SetLineColor(kColorPHOS) ;
168 fNodes->Add(bigboxnode) ;
174 //____________________________________________________________________________
175 void AliPHOSvFast::CreateGeometry()
177 // Create the geometry for GEANT
179 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
181 if ( phostmp == NULL ) {
183 fprintf(stderr, "PHOS detector not found!\n") ;
188 // Get pointer to the array containing media indeces
189 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
192 bigbox[0] = GetBigBox(0) / 2.0 ;
193 bigbox[1] = GetBigBox(1) / 2.0 ;
194 bigbox[2] = GetBigBox(2) / 2.0 ;
196 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
198 // --- Position PHOS mdules in ALICE setup ---
201 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
203 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
205 Float_t angle = GetGeometry()->GetPHOSAngle(i) ;
206 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
208 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
210 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
211 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
212 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
219 //____________________________________________________________________________
220 void AliPHOSvFast::Init(void)
222 // Prints out an information message
227 for(i=0;i<35;i++) printf("*");
228 printf(" FAST PHOS_INIT ");
229 for(i=0;i<35;i++) printf("*");
232 // Here the PHOS initialisation code (if any!)
234 for(i=0;i<80;i++) printf("*");
239 //___________________________________________________________________________
240 Float_t AliPHOSvFast::GetBigBox(Int_t index) const
242 // Get the X, Y or Z dimension of the box describing a PHOS module
259 //___________________________________________________________________________
261 void AliPHOSvFast::MakeBranch(Option_t* opt)
263 // Create new branch in the current reconstructed Root Tree
264 AliDetector::MakeBranch(opt);
265 const char *cd = strstr(opt,"R");
267 if (fFastRecParticles && fLoader->TreeR() && cd) {
268 MakeBranchInTree(fLoader->TreeR(), GetName(), &fFastRecParticles, fBufferSize, 0);
271 //____________________________________________________________________________
273 Double_t AliPHOSvFast::MakeEnergy(const Double_t energy)
275 // Smears the energy according to the energy dependent energy resolution.
276 // A gaussian distribution is assumed
278 Double_t sigma = SigmaE(energy) ;
279 return fRan.Gaus(energy, sigma) ;
281 //____________________________________________________________________________
283 TVector3 AliPHOSvFast::MakePosition(const Double_t energy, const TVector3 pos, const Double_t theta, const Double_t phi)
285 // Smears the impact position according to the energy dependent position resolution
286 // A gaussian position distribution is assumed
289 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
290 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
291 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
292 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
293 Double_t y = pos.Y() ;
302 //____________________________________________________________________________
303 void AliPHOSvFast::MakeRecParticle(const Int_t modid, const TVector3 pos, AliPHOSFastRecParticle & rp)
305 // Modify the primary particle properties according
306 // 1. the response function of PHOS
307 // 2. the performance of the EMC+PPSD setup
309 Int_t type = MakeType( rp ) ;
313 // get the detected energy
315 TLorentzVector momentum ;
316 rp.Momentum(momentum) ;
317 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
318 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
319 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
320 + TMath::Power( rp.GetMass(), 2) ) ;
322 // get the angle of incidence
324 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
325 Double_t incidencephi = ( 270 + GetGeometry()->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
327 // get the detected direction
329 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
330 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
332 // Set the modified 4-momentum of the reconstructed particle
334 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
338 //____________________________________________________________________________
339 Int_t AliPHOSvFast::MakeType(AliPHOSFastRecParticle & rp )
341 // Generate a particle type using the performance of the EMC+PPSD setup
343 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
344 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
347 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
350 test = rp.GetPdgCode() ;
352 Info("MakeType", "SHOULD NOT BE USED until values of probabilities are properly set ") ;
353 assert(1==0) ; // NB: ALL VALUES SHOULD BE CHECKED !!!!
356 case 22: // it's a photon // NB: ALL VALUES SHOLD BE CHECKED !!!!
359 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
361 rv = AliPHOSFastRecParticle::kNEUTRALEMFAST ;
364 case 2112: // it's a neutron
367 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
369 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
372 case -2112: // it's a anti-neutron
375 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
377 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
380 case 11: // it's a electron
383 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
385 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
388 case -11: // it's a positon
391 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
393 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
396 case -1: // it's a charged
399 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
401 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
410 //___________________________________________________________________________
411 void AliPHOSvFast::ResetPoints()
413 // This overloads the method in AliDetector
415 ResetFastRecParticles() ;
418 //___________________________________________________________________________
419 void AliPHOSvFast::ResetFastRecParticles()
421 // Resets the list of virtual reconstructed particles
423 if (fFastRecParticles)
424 fFastRecParticles->Clear() ;
428 //___________________________________________________________________________
429 void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
431 // Set the size of the Box describing a PHOS module
447 //____________________________________________________________________________
448 Double_t AliPHOSvFast::SigmaE(Double_t energy)
450 // Calculates the energy dependent energy resolution
454 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
455 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
456 + TMath::Power(fResPara3, 2) ) ;
461 //____________________________________________________________________________
462 Double_t AliPHOSvFast::SigmaP(Double_t energy, Double_t incidence)
464 // Calculates the energy dependent position resolution
466 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
467 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
469 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
472 //____________________________________________________________________________
473 void AliPHOSvFast::StepManager(void)
475 // Only verifies if the particle reaches PHOS and stops the tracking
478 gMC->TrackPosition(lv) ;
479 TVector3 pos = lv.Vect() ;
481 gMC->CurrentVolID(modid);
483 Float_t energy = gMC->Etot() ; //Total energy of current track
485 //Calculating mass of current particle
486 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
487 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
488 Float_t mass = partPDG->Mass() ;
491 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
492 TLorentzVector pTrack(pos, energy) ;
494 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
496 AliPHOSFastRecParticle rp(*part) ;
498 // Adds the response of PHOS to the particle
499 MakeRecParticle(modid, pos, rp) ;
501 // add the `track' particle to the FastRecParticles list
507 // stop the track as soon PHOS is reached