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 "AliPHOSv4.h"
42 #include "AliPHOSGetter.h"
49 //____________________________________________________________________________
50 AliPHOSv4::AliPHOSv4() : AliPHOS()
52 // default ctor : initialize data member
56 fFastRecParticles = 0 ;
70 //____________________________________________________________________________
71 AliPHOSv4::AliPHOSv4(const char *name, const char *title):
77 // create the geometry parameters object
78 // and post it to a folder (Post retrieves the correct geometry)
79 AliPHOSGetter::GetInstance(gDirectory->GetName(), 0)->PostGeometry() ;
81 SetBigBox(0, GetGeometry()->GetOuterBoxSize(0) ) ;
82 SetBigBox(1, GetGeometry()->GetOuterBoxSize(1) + GetGeometry()->GetCPVBoxSize(1) ) ;
83 SetBigBox(2, GetGeometry()->GetOuterBoxSize(0) );
86 fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
88 fResPara1 = 0.030 ; // GeV
92 fPosParaA0 = 2.87 ; // mm
93 fPosParaA1 = -0.0975 ;
96 fPosParaB2 = 0.00619 ;
99 //____________________________________________________________________________
100 AliPHOSv4::~AliPHOSv4()
104 fFastRecParticles->Delete() ;
105 delete fFastRecParticles ;
106 fFastRecParticles = 0 ;
110 //____________________________________________________________________________
111 void AliPHOSv4::AddRecParticle(const AliPHOSFastRecParticle & rp)
113 // Add a virtually reconstructed particle to the list
115 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
119 //____________________________________________________________________________
120 void AliPHOSv4::BuildGeometry()
122 // Build the PHOS geometry for the ROOT display
126 PHOS FAST in ALICE displayed by root
131 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSv4AllViews.gif">
133 <H4> Front View </H4>
136 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSv4FrontView.gif">
141 const Int_t kColorPHOS = kRed ;
143 Double_t const kRADDEG = 180.0 / kPI ;
145 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
149 // position PHOS into ALICE
151 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
153 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * GetGeometry()->GetIPtoCrystalSurface() ) ) ;
155 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
157 char * nodename = new char[20] ;
158 char * rotname = new char[20] ;
160 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
161 Float_t angle = pphi * 2 * ( i - GetGeometry()->GetNModules() / 2.0 - 0.5 ) ;
162 sprintf(rotname, "%s%d", "rot", number++) ;
163 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
165 sprintf(nodename,"%s%d", "Module", i) ;
166 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
167 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
168 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
169 bigboxnode->SetLineColor(kColorPHOS) ;
170 fNodes->Add(bigboxnode) ;
176 //____________________________________________________________________________
177 void AliPHOSv4::CreateGeometry()
179 // Create the geometry for GEANT
181 AliPHOSv4 *phostmp = dynamic_cast<AliPHOSv4*>(gAlice->GetModule("PHOS")) ;
183 if ( phostmp == NULL ) {
185 fprintf(stderr, "PHOS detector not found!\n") ;
190 // Get pointer to the array containing media indeces
191 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
194 bigbox[0] = GetBigBox(0) / 2.0 ;
195 bigbox[1] = GetBigBox(1) / 2.0 ;
196 bigbox[2] = GetBigBox(2) / 2.0 ;
198 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
200 // --- Position PHOS mdules in ALICE setup ---
203 Double_t const kRADDEG = 180.0 / kPI ;
205 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
207 Float_t angle = GetGeometry()->GetPHOSAngle(i) ;
208 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
210 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
212 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
213 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
214 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
221 //____________________________________________________________________________
222 void AliPHOSv4::Init(void)
224 // Prints out an information message
229 for(i=0;i<35;i++) printf("*");
230 printf(" FAST PHOS_INIT ");
231 for(i=0;i<35;i++) printf("*");
234 // Here the PHOS initialisation code (if any!)
236 for(i=0;i<80;i++) printf("*");
241 //___________________________________________________________________________
242 Float_t AliPHOSv4::GetBigBox(Int_t index) const
244 // Get the X, Y or Z dimension of the box describing a PHOS module
262 //___________________________________________________________________________
263 void AliPHOSv4::MakeBranch(Option_t* opt, const char *file)
265 // Create new branch in the current reconstructed Root Tree
267 AliDetector::MakeBranch(opt,file) ;
270 sprintf(branchname,"%s",GetName());
271 const char *cd = strstr(opt,"R");
273 if (fFastRecParticles && gAlice->TreeR() && cd) {
274 MakeBranchInTree(gAlice->TreeR(),
275 branchname, &fFastRecParticles, fBufferSize, file);
279 //____________________________________________________________________________
280 Double_t AliPHOSv4::MakeEnergy(const Double_t energy)
282 // Smears the energy according to the energy dependent energy resolution.
283 // A gaussian distribution is assumed
285 Double_t sigma = SigmaE(energy) ;
286 return fRan.Gaus(energy, sigma) ;
289 //____________________________________________________________________________
290 TVector3 AliPHOSv4::MakePosition(const Double_t energy, const TVector3 pos, const Double_t theta, const Double_t phi)
292 // Smears the impact position according to the energy dependent position resolution
293 // A gaussian position distribution is assumed
296 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
297 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
298 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
299 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
300 Double_t y = pos.Y() ;
309 //____________________________________________________________________________
310 void AliPHOSv4::MakeRecParticle(const Int_t modid, const TVector3 pos, AliPHOSFastRecParticle & rp)
312 // Modify the primary particle properties according
313 // 1. the response function of PHOS
314 // 2. the performance of the EMC+PPSD setup
316 Int_t type = MakeType( rp ) ;
320 // get the detected energy
322 TLorentzVector momentum ;
323 rp.Momentum(momentum) ;
324 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
325 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
326 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
327 + TMath::Power( rp.GetMass(), 2) ) ;
329 // get the angle of incidence
331 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
332 Double_t incidencephi = ( 270 + GetGeometry()->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
334 // get the detected direction
336 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
337 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
339 // Set the modified 4-momentum of the reconstructed particle
341 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
345 //____________________________________________________________________________
346 Int_t AliPHOSv4::MakeType(AliPHOSFastRecParticle & rp )
348 // Generate a particle type using the performance of the EMC+PPSD setup
350 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
351 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
354 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
357 test = rp.GetPdgCode() ;
361 case 22: // it's a photon
363 if ( ran <= 0.5 ) // 50 %
364 rv = AliPHOSFastRecParticle::kGAMMA ;
368 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
370 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
374 case 2112: // it's a neutron
377 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
379 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
382 case -2112: // it's a anti-neutron
385 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
387 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
390 case 11: // it's a electron
393 rv = AliPHOSFastRecParticle::kELECTRON ;
395 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
398 case -11: // it's a positon
401 rv = AliPHOSFastRecParticle::kELECTRON ;
403 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
406 case -1: // it's a charged
409 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
411 rv = AliPHOSFastRecParticle::kGAMMA ;
420 //___________________________________________________________________________
421 void AliPHOSv4::ResetPoints()
423 // This overloads the method in AliDetector
425 ResetFastRecParticles() ;
428 //___________________________________________________________________________
429 void AliPHOSv4::ResetFastRecParticles()
431 // Resets the list of virtual reconstructed particles
433 if (fFastRecParticles)
434 fFastRecParticles->Clear() ;
438 //___________________________________________________________________________
439 void AliPHOSv4::SetBigBox(Int_t index, Float_t value)
441 // Set the size of the Box describing a PHOS module
457 //____________________________________________________________________________
458 Double_t AliPHOSv4::SigmaE(Double_t energy)
460 // Calculates the energy dependent energy resolution
464 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
465 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
466 + TMath::Power(fResPara3, 2) ) ;
471 //____________________________________________________________________________
472 Double_t AliPHOSv4::SigmaP(Double_t energy, Double_t incidence)
474 // Calculates the energy dependent position resolution
476 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
477 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
479 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
482 //____________________________________________________________________________
483 void AliPHOSv4::StepManager(void)
485 // Only verifies if the particle reaches PHOS and stops the tracking
487 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
490 gMC->TrackPosition(lv) ;
491 TVector3 pos = lv.Vect() ;
493 gMC->CurrentVolID(modid);
495 Float_t energy = gMC->Etot() ; //Total energy of current track
497 //Calculating mass of current particle
498 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
499 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
500 Float_t mass = partPDG->Mass() ;
503 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
504 TLorentzVector pTrack(pos, energy) ;
506 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
508 AliPHOSFastRecParticle rp(*part) ;
509 rp.SetPrimary(primary) ;
511 // Adds the response of PHOS to the particle
512 MakeRecParticle(modid, pos, rp) ;
514 // add the `track' particle to the FastRecParticles list
520 // stop the track as soon PHOS is reached