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"
33 #include "TGeometry.h"
36 // --- Standard library ---
38 // --- AliRoot header files ---
39 #include "AliPHOSFastRecParticle.h"
40 #include "AliPHOSGeometry.h"
41 #include "AliPHOSvFast.h"
42 #include "AliPHOSGetter.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):
78 AliPHOSGetter::GetInstance(gDirectory->GetName(), 0) ;
80 SetBigBox(0, GetGeometry()->GetOuterBoxSize(0) ) ;
81 SetBigBox(1, GetGeometry()->GetOuterBoxSize(3) + GetGeometry()->GetCPVBoxSize(1) ) ;
82 SetBigBox(2, GetGeometry()->GetOuterBoxSize(2) );
85 fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
87 fResPara1 = 0.030 ; // GeV
91 fPosParaA0 = 2.87 ; // mm
92 fPosParaA1 = -0.0975 ;
95 fPosParaB2 = 0.00619 ;
98 //____________________________________________________________________________
99 AliPHOSvFast::~AliPHOSvFast()
103 fFastRecParticles->Delete() ;
104 delete fFastRecParticles ;
105 fFastRecParticles = 0 ;
109 //____________________________________________________________________________
110 void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp)
112 // Add a virtually reconstructed particle to the list
114 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
118 //____________________________________________________________________________
119 void AliPHOSvFast::BuildGeometry()
121 // Build the PHOS geometry for the ROOT display
125 PHOS FAST in ALICE displayed by root
130 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSvFastAllViews.gif">
132 <H4> Front View </H4>
135 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSvFastFrontView.gif">
140 const Int_t kColorPHOS = kRed ;
142 Double_t const kRADDEG = 180.0 / kPI ;
144 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
148 // position PHOS into ALICE
150 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
152 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * GetGeometry()->GetIPtoCrystalSurface() ) ) ;
154 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
156 char * nodename = new char[20] ;
157 char * rotname = new char[20] ;
159 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
160 Float_t angle = pphi * 2 * ( i - GetGeometry()->GetNModules() / 2.0 - 0.5 ) ;
161 sprintf(rotname, "%s%d", "rot", number++) ;
162 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
164 sprintf(nodename,"%s%d", "Module", i) ;
165 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
166 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
167 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
168 bigboxnode->SetLineColor(kColorPHOS) ;
169 fNodes->Add(bigboxnode) ;
175 //____________________________________________________________________________
176 void AliPHOSvFast::CreateGeometry()
178 // Create the geometry for GEANT
180 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
182 if ( phostmp == NULL ) {
184 fprintf(stderr, "PHOS detector not found!\n") ;
189 // Get pointer to the array containing media indeces
190 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
193 bigbox[0] = GetBigBox(0) / 2.0 ;
194 bigbox[1] = GetBigBox(1) / 2.0 ;
195 bigbox[2] = GetBigBox(2) / 2.0 ;
197 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
199 // --- Position PHOS mdules in ALICE setup ---
202 Double_t const kRADDEG = 180.0 / kPI ;
204 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
206 Float_t angle = GetGeometry()->GetPHOSAngle(i) ;
207 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
209 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
211 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
212 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
213 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
220 //____________________________________________________________________________
221 void AliPHOSvFast::Init(void)
223 // Prints out an information message
228 for(i=0;i<35;i++) printf("*");
229 printf(" FAST PHOS_INIT ");
230 for(i=0;i<35;i++) printf("*");
233 // Here the PHOS initialisation code (if any!)
235 for(i=0;i<80;i++) printf("*");
240 //___________________________________________________________________________
241 Float_t AliPHOSvFast::GetBigBox(Int_t index) const
243 // Get the X, Y or Z dimension of the box describing a PHOS module
261 //___________________________________________________________________________
262 void AliPHOSvFast::MakeBranch(Option_t* opt, const char *file)
264 // Create new branch in the current reconstructed Root Tree
266 AliDetector::MakeBranch(opt,file) ;
269 sprintf(branchname,"%s",GetName());
270 const char *cd = strstr(opt,"R");
272 if (fFastRecParticles && gAlice->TreeR() && cd) {
273 MakeBranchInTree(gAlice->TreeR(),
274 branchname, &fFastRecParticles, fBufferSize, file);
278 //____________________________________________________________________________
279 Double_t AliPHOSvFast::MakeEnergy(const Double_t energy)
281 // Smears the energy according to the energy dependent energy resolution.
282 // A gaussian distribution is assumed
284 Double_t sigma = SigmaE(energy) ;
285 return fRan.Gaus(energy, sigma) ;
288 //____________________________________________________________________________
289 TVector3 AliPHOSvFast::MakePosition(const Double_t energy, const TVector3 pos, const Double_t theta, const Double_t phi)
291 // Smears the impact position according to the energy dependent position resolution
292 // A gaussian position distribution is assumed
295 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
296 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
297 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
298 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
299 Double_t y = pos.Y() ;
308 //____________________________________________________________________________
309 void AliPHOSvFast::MakeRecParticle(const Int_t modid, const TVector3 pos, AliPHOSFastRecParticle & rp)
311 // Modify the primary particle properties according
312 // 1. the response function of PHOS
313 // 2. the performance of the EMC+PPSD setup
315 Int_t type = MakeType( rp ) ;
319 // get the detected energy
321 TLorentzVector momentum ;
322 rp.Momentum(momentum) ;
323 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
324 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
325 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
326 + TMath::Power( rp.GetMass(), 2) ) ;
328 // get the angle of incidence
330 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
331 Double_t incidencephi = ( 270 + GetGeometry()->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
333 // get the detected direction
335 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
336 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
338 // Set the modified 4-momentum of the reconstructed particle
340 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
344 //____________________________________________________________________________
345 Int_t AliPHOSvFast::MakeType(AliPHOSFastRecParticle & rp )
347 // Generate a particle type using the performance of the EMC+PPSD setup
349 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
350 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
353 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
356 test = rp.GetPdgCode() ;
358 cout << " SHOULD NOT BE USED until values of probabilities are properly set " << endl ;
359 assert(1==0) ; // NB: ALL VALUES SHOLD BE CHECKED !!!!
362 case 22: // it's a photon // NB: ALL VALUES SHOLD BE CHECKED !!!!
365 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
367 rv = AliPHOSFastRecParticle::kNEUTRALEMFAST ;
370 case 2112: // it's a neutron
373 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
375 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
378 case -2112: // it's a anti-neutron
381 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
383 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
386 case 11: // it's a electron
389 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
391 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
394 case -11: // it's a positon
397 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
399 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
402 case -1: // it's a charged
405 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
407 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
416 //___________________________________________________________________________
417 void AliPHOSvFast::ResetPoints()
419 // This overloads the method in AliDetector
421 ResetFastRecParticles() ;
424 //___________________________________________________________________________
425 void AliPHOSvFast::ResetFastRecParticles()
427 // Resets the list of virtual reconstructed particles
429 if (fFastRecParticles)
430 fFastRecParticles->Clear() ;
434 //___________________________________________________________________________
435 void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
437 // Set the size of the Box describing a PHOS module
453 //____________________________________________________________________________
454 Double_t AliPHOSvFast::SigmaE(Double_t energy)
456 // Calculates the energy dependent energy resolution
460 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
461 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
462 + TMath::Power(fResPara3, 2) ) ;
467 //____________________________________________________________________________
468 Double_t AliPHOSvFast::SigmaP(Double_t energy, Double_t incidence)
470 // Calculates the energy dependent position resolution
472 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
473 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
475 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
478 //____________________________________________________________________________
479 void AliPHOSvFast::StepManager(void)
481 // Only verifies if the particle reaches PHOS and stops the tracking
484 gMC->TrackPosition(lv) ;
485 TVector3 pos = lv.Vect() ;
487 gMC->CurrentVolID(modid);
489 Float_t energy = gMC->Etot() ; //Total energy of current track
491 //Calculating mass of current particle
492 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
493 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
494 Float_t mass = partPDG->Mass() ;
497 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
498 TLorentzVector pTrack(pos, energy) ;
500 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
502 AliPHOSFastRecParticle rp(*part) ;
504 // Adds the response of PHOS to the particle
505 MakeRecParticle(modid, pos, rp) ;
507 // add the `track' particle to the FastRecParticles list
513 // stop the track as soon PHOS is reached