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 ---
30 #include <TGeometry.h>
32 #include <TParticle.h>
33 #include "TClonesArray.h"
34 #include <TVirtualMC.h>
36 // --- Standard library ---
38 // --- AliRoot header files ---
39 #include "AliPHOSFastRecParticle.h"
40 #include "AliPHOSGeometry.h"
41 #include "AliPHOSLoader.h"
42 #include "AliPHOSvFast.h"
45 ClassImp(AliPHOSvFast)
47 //____________________________________________________________________________
48 AliPHOSvFast::AliPHOSvFast() : AliPHOS()
50 // default ctor : initialize data member
54 fFastRecParticles = 0 ;
68 //____________________________________________________________________________
69 AliPHOSvFast::AliPHOSvFast(const char *name, const char *title):
77 SetBigBox(0, GetGeometry()->GetOuterBoxSize(0) ) ;
78 SetBigBox(1, GetGeometry()->GetOuterBoxSize(3) + GetGeometry()->GetCPVBoxSize(1) ) ;
79 SetBigBox(2, GetGeometry()->GetOuterBoxSize(2) );
82 fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
84 fResPara1 = 0.030 ; // GeV
88 fPosParaA0 = 2.87 ; // mm
89 fPosParaA1 = -0.0975 ;
92 fPosParaB2 = 0.00619 ;
95 //____________________________________________________________________________
96 AliPHOSvFast::~AliPHOSvFast()
100 fFastRecParticles->Delete() ;
101 delete fFastRecParticles ;
102 fFastRecParticles = 0 ;
106 //____________________________________________________________________________
107 void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp)
109 // Add a virtually reconstructed particle to the list
111 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
115 //____________________________________________________________________________
116 void AliPHOSvFast::BuildGeometry()
118 // Build the PHOS geometry for the ROOT display
122 PHOS FAST in ALICE displayed by root
127 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSvFastAllViews.gif">
129 <H4> Front View </H4>
132 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSvFastFrontView.gif">
137 const Int_t kColorPHOS = kRed ;
139 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
141 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
145 // position PHOS into ALICE
147 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
149 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * GetGeometry()->GetIPtoCrystalSurface() ) ) ;
151 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
153 char * nodename = new char[20] ;
154 char * rotname = new char[20] ;
156 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
157 Float_t angle = pphi * 2 * ( i - GetGeometry()->GetNModules() / 2.0 - 0.5 ) ;
158 sprintf(rotname, "%s%d", "rot", number++) ;
159 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
161 sprintf(nodename,"%s%d", "Module", i) ;
162 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
163 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
164 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
165 bigboxnode->SetLineColor(kColorPHOS) ;
166 fNodes->Add(bigboxnode) ;
172 //____________________________________________________________________________
173 void AliPHOSvFast::CreateGeometry()
175 // Create the geometry for GEANT
177 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
179 if ( phostmp == NULL ) {
181 fprintf(stderr, "PHOS detector not found!\n") ;
186 // Get pointer to the array containing media indeces
187 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
190 bigbox[0] = GetBigBox(0) / 2.0 ;
191 bigbox[1] = GetBigBox(1) / 2.0 ;
192 bigbox[2] = GetBigBox(2) / 2.0 ;
194 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
196 // --- Position PHOS mdules in ALICE setup ---
199 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
201 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
203 Float_t angle = GetGeometry()->GetPHOSAngle(i) ;
204 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
206 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
208 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
209 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
210 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
217 //____________________________________________________________________________
218 void AliPHOSvFast::Init(void)
220 // Prints out an information message
225 for(i=0;i<35;i++) printf("*");
226 printf(" FAST PHOS_INIT ");
227 for(i=0;i<35;i++) printf("*");
230 // Here the PHOS initialisation code (if any!)
232 for(i=0;i<80;i++) printf("*");
237 //___________________________________________________________________________
238 Float_t AliPHOSvFast::GetBigBox(Int_t index) const
240 // Get the X, Y or Z dimension of the box describing a PHOS module
257 //___________________________________________________________________________
259 void AliPHOSvFast::MakeBranch(Option_t* opt)
261 // Create new branch in the current reconstructed Root Tree
262 AliDetector::MakeBranch(opt);
263 const char *cd = strstr(opt,"R");
265 if (fFastRecParticles && fLoader->TreeR() && cd) {
266 MakeBranchInTree(fLoader->TreeR(), GetName(), &fFastRecParticles, fBufferSize, 0);
269 //____________________________________________________________________________
271 Double_t AliPHOSvFast::MakeEnergy(const Double_t energy)
273 // Smears the energy according to the energy dependent energy resolution.
274 // A gaussian distribution is assumed
276 Double_t sigma = SigmaE(energy) ;
277 return fRan.Gaus(energy, sigma) ;
279 //____________________________________________________________________________
281 TVector3 AliPHOSvFast::MakePosition(const Double_t energy, const TVector3 pos, const Double_t theta, const Double_t phi)
283 // Smears the impact position according to the energy dependent position resolution
284 // A gaussian position distribution is assumed
287 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
288 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
289 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
290 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
291 Double_t y = pos.Y() ;
300 //____________________________________________________________________________
301 void AliPHOSvFast::MakeRecParticle(const Int_t modid, const TVector3 pos, AliPHOSFastRecParticle & rp)
303 // Modify the primary particle properties according
304 // 1. the response function of PHOS
305 // 2. the performance of the EMC+PPSD setup
307 Int_t type = MakeType( rp ) ;
311 // get the detected energy
313 TLorentzVector momentum ;
314 rp.Momentum(momentum) ;
315 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
316 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
317 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
318 + TMath::Power( rp.GetMass(), 2) ) ;
320 // get the angle of incidence
322 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
323 Double_t incidencephi = ( 270 + GetGeometry()->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
325 // get the detected direction
327 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
328 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
330 // Set the modified 4-momentum of the reconstructed particle
332 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
336 //____________________________________________________________________________
337 Int_t AliPHOSvFast::MakeType(AliPHOSFastRecParticle & rp )
339 // Generate a particle type using the performance of the EMC+PPSD setup
341 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
342 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
345 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
348 test = rp.GetPdgCode() ;
350 Info("MakeType", "SHOULD NOT BE USED until values of probabilities are properly set ") ;
351 assert(1==0) ; // NB: ALL VALUES SHOULD BE CHECKED !!!!
354 case 22: // it's a photon // NB: ALL VALUES SHOLD BE CHECKED !!!!
357 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
359 rv = AliPHOSFastRecParticle::kNEUTRALEMFAST ;
362 case 2112: // it's a neutron
365 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
367 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
370 case -2112: // it's a anti-neutron
373 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
375 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
378 case 11: // it's a electron
381 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
383 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
386 case -11: // it's a positon
389 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
391 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
394 case -1: // it's a charged
397 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
399 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
408 //___________________________________________________________________________
409 void AliPHOSvFast::ResetPoints()
411 // This overloads the method in AliDetector
413 ResetFastRecParticles() ;
416 //___________________________________________________________________________
417 void AliPHOSvFast::ResetFastRecParticles()
419 // Resets the list of virtual reconstructed particles
421 if (fFastRecParticles)
422 fFastRecParticles->Clear() ;
426 //___________________________________________________________________________
427 void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
429 // Set the size of the Box describing a PHOS module
445 //____________________________________________________________________________
446 Double_t AliPHOSvFast::SigmaE(Double_t energy)
448 // Calculates the energy dependent energy resolution
452 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
453 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
454 + TMath::Power(fResPara3, 2) ) ;
459 //____________________________________________________________________________
460 Double_t AliPHOSvFast::SigmaP(Double_t energy, Double_t incidence)
462 // Calculates the energy dependent position resolution
464 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
465 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
467 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
470 //____________________________________________________________________________
471 void AliPHOSvFast::StepManager(void)
473 // Only verifies if the particle reaches PHOS and stops the tracking
476 gMC->TrackPosition(lv) ;
477 TVector3 pos = lv.Vect() ;
479 gMC->CurrentVolID(modid);
481 Float_t energy = gMC->Etot() ; //Total energy of current track
483 //Calculating mass of current particle
484 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
485 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
486 Float_t mass = partPDG->Mass() ;
489 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
490 TLorentzVector pTrack(pos, energy) ;
492 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
494 AliPHOSFastRecParticle rp(*part) ;
496 // Adds the response of PHOS to the particle
497 MakeRecParticle(modid, pos, rp) ;
499 // add the `track' particle to the FastRecParticles list
505 // stop the track as soon PHOS is reached