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::Copy(AliPHOSvFast & fast)
109 TObject::Copy(fast) ;
110 AliPHOS::Copy(fast) ;
111 fast.fBigBoxX = fBigBoxX ;
112 fast.fBigBoxY = fBigBoxY ;
113 fast.fBigBoxZ = fBigBoxZ ;
114 fast.fNRecParticles = fNRecParticles ;
116 fast.fResPara1 = fResPara1 ;
117 fast.fResPara2 = fResPara2 ;
118 fast.fResPara3 = fResPara3 ;
119 fast.fPosParaA0 = fPosParaA0 ;
120 fast.fPosParaA1 = fPosParaA1 ;
121 fast.fPosParaB0 = fPosParaB0 ;
122 fast.fPosParaB1 = fPosParaB1 ;
123 fast.fFastRecParticles = new TClonesArray(fFastRecParticles->GetClass()->GetName(), 100) ;
125 for (index = 0 ; index < fFastRecParticles->GetEntries(); index++)
126 (fast.fFastRecParticles)->AddAt(fFastRecParticles->At(index), index) ;
129 //____________________________________________________________________________
130 void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp)
132 // Add a virtually reconstructed particle to the list
134 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
138 //____________________________________________________________________________
139 void AliPHOSvFast::BuildGeometry()
141 // Build the PHOS geometry for the ROOT display
145 PHOS FAST in ALICE displayed by root
150 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSvFastAllViews.gif">
152 <H4> Front View </H4>
155 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSvFastFrontView.gif">
160 const Int_t kColorPHOS = kRed ;
162 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
164 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
168 // position PHOS into ALICE
170 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
172 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * GetGeometry()->GetIPtoCrystalSurface() ) ) ;
174 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
176 char * nodename = new char[20] ;
177 char * rotname = new char[20] ;
179 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
180 Float_t angle = pphi * 2 * ( i - GetGeometry()->GetNModules() / 2.0 - 0.5 ) ;
181 sprintf(rotname, "%s%d", "rot", number++) ;
182 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
184 sprintf(nodename,"%s%d", "Module", i) ;
185 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
186 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
187 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
188 bigboxnode->SetLineColor(kColorPHOS) ;
189 fNodes->Add(bigboxnode) ;
195 //____________________________________________________________________________
196 void AliPHOSvFast::CreateGeometry()
198 // Create the geometry for GEANT
200 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
202 if ( phostmp == NULL ) {
204 fprintf(stderr, "PHOS detector not found!\n") ;
209 // Get pointer to the array containing media indeces
210 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
213 bigbox[0] = GetBigBox(0) / 2.0 ;
214 bigbox[1] = GetBigBox(1) / 2.0 ;
215 bigbox[2] = GetBigBox(2) / 2.0 ;
217 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
219 // --- Position PHOS mdules in ALICE setup ---
222 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
224 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
226 Float_t angle = GetGeometry()->GetPHOSAngle(i) ;
227 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
229 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
231 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
232 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
233 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
240 //____________________________________________________________________________
241 void AliPHOSvFast::Init(void)
243 // Prints out an information message
248 for(i=0;i<35;i++) printf("*");
249 printf(" FAST PHOS_INIT ");
250 for(i=0;i<35;i++) printf("*");
253 // Here the PHOS initialisation code (if any!)
255 for(i=0;i<80;i++) printf("*");
260 //___________________________________________________________________________
261 Float_t AliPHOSvFast::GetBigBox(Int_t index) const
263 // Get the X, Y or Z dimension of the box describing a PHOS module
280 //___________________________________________________________________________
282 void AliPHOSvFast::MakeBranch(Option_t* opt)
284 // Create new branch in the current reconstructed Root Tree
285 AliDetector::MakeBranch(opt);
286 const char *cd = strstr(opt,"R");
288 if (fFastRecParticles && fLoader->TreeR() && cd) {
289 MakeBranchInTree(fLoader->TreeR(), GetName(), &fFastRecParticles, fBufferSize, 0);
292 //____________________________________________________________________________
294 Double_t AliPHOSvFast::MakeEnergy(Double_t energy)
296 // Smears the energy according to the energy dependent energy resolution.
297 // A gaussian distribution is assumed
299 Double_t sigma = SigmaE(energy) ;
300 return fRan.Gaus(energy, sigma) ;
302 //____________________________________________________________________________
304 TVector3 AliPHOSvFast::MakePosition(Double_t energy, TVector3 pos, Double_t theta, Double_t phi)
306 // Smears the impact position according to the energy dependent position resolution
307 // A gaussian position distribution is assumed
310 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
311 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
312 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
313 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
314 Double_t y = pos.Y() ;
323 //____________________________________________________________________________
324 void AliPHOSvFast::MakeRecParticle(Int_t modid, TVector3 pos, AliPHOSFastRecParticle & rp)
326 // Modify the primary particle properties according
327 // 1. the response function of PHOS
328 // 2. the performance of the EMC+PPSD setup
330 Int_t type = MakeType( rp ) ;
334 // get the detected energy
336 TLorentzVector momentum ;
337 rp.Momentum(momentum) ;
338 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
339 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
340 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
341 + TMath::Power( rp.GetMass(), 2) ) ;
343 // get the angle of incidence
345 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
346 Double_t incidencephi = ( 270 + GetGeometry()->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
348 // get the detected direction
350 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
351 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
353 // Set the modified 4-momentum of the reconstructed particle
355 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
359 //____________________________________________________________________________
360 Int_t AliPHOSvFast::MakeType(AliPHOSFastRecParticle & rp )
362 // Generate a particle type using the performance of the EMC+PPSD setup
364 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
365 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
368 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
371 test = rp.GetPdgCode() ;
373 Fatal("MakeType", "SHOULD NOT BE USED until values of probabilities are properly set ") ;
374 // NB: ALL VALUES SHOULD BE CHECKED !!!!
377 case 22: // it's a photon // NB: ALL VALUES SHOLD BE CHECKED !!!!
380 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
382 rv = AliPHOSFastRecParticle::kNEUTRALEMFAST ;
385 case 2112: // it's a neutron
388 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
390 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
393 case -2112: // it's a anti-neutron
396 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
398 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
401 case 11: // it's a electron
404 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
406 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
409 case -11: // it's a positon
412 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
414 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
417 case -1: // it's a charged
420 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
422 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
431 //___________________________________________________________________________
432 void AliPHOSvFast::ResetPoints()
434 // This overloads the method in AliDetector
436 ResetFastRecParticles() ;
439 //___________________________________________________________________________
440 void AliPHOSvFast::ResetFastRecParticles()
442 // Resets the list of virtual reconstructed particles
444 if (fFastRecParticles)
445 fFastRecParticles->Clear() ;
449 //___________________________________________________________________________
450 void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
452 // Set the size of the Box describing a PHOS module
468 //____________________________________________________________________________
469 Double_t AliPHOSvFast::SigmaE(Double_t energy)
471 // Calculates the energy dependent energy resolution
475 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
476 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
477 + TMath::Power(fResPara3, 2) ) ;
482 //____________________________________________________________________________
483 Double_t AliPHOSvFast::SigmaP(Double_t energy, Double_t incidence)
485 // Calculates the energy dependent position resolution
487 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
488 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
490 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
493 //____________________________________________________________________________
494 void AliPHOSvFast::StepManager(void)
496 // Only verifies if the particle reaches PHOS and stops the tracking
499 gMC->TrackPosition(lv) ;
500 TVector3 pos = lv.Vect() ;
502 gMC->CurrentVolID(modid);
504 Float_t energy = gMC->Etot() ; //Total energy of current track
506 //Calculating mass of current particle
507 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
508 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
509 Float_t mass = partPDG->Mass() ;
512 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
513 TLorentzVector pTrack(pos, energy) ;
515 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
517 AliPHOSFastRecParticle rp(*part) ;
519 // Adds the response of PHOS to the particle
520 MakeRecParticle(modid, pos, rp) ;
522 // add the `track' particle to the FastRecParticles list
528 // stop the track as soon PHOS is reached