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 ---
40 // --- AliRoot header files ---
41 #include "AliPHOSFastRecParticle.h"
42 #include "AliPHOSGeometry.h"
43 #include "AliPHOSv4.h"
50 //____________________________________________________________________________
51 AliPHOSv4::AliPHOSv4() : AliPHOS()
53 // default ctor : initialize data member
57 fFastRecParticles = 0 ;
71 //____________________________________________________________________________
72 AliPHOSv4::AliPHOSv4(const char *name, const char *title):
77 // gets an instance of the geometry parameters class
78 if (strcmp(GetTitle(),"") != 0 )
79 fGeom = AliPHOSGeometry::GetInstance(GetTitle(), "") ;
82 SetBigBox(0, GetGeometry()->GetOuterBoxSize(0) ) ;
83 SetBigBox(1, GetGeometry()->GetOuterBoxSize(1) + GetGeometry()->GetCPVBoxSize(1) ) ;
84 SetBigBox(2, GetGeometry()->GetOuterBoxSize(0) );
87 fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
89 fResPara1 = 0.030 ; // GeV
93 fPosParaA0 = 2.87 ; // mm
94 fPosParaA1 = -0.0975 ;
97 fPosParaB2 = 0.00619 ;
100 //____________________________________________________________________________
101 AliPHOSv4::~AliPHOSv4()
105 fFastRecParticles->Delete() ;
106 delete fFastRecParticles ;
107 fFastRecParticles = 0 ;
111 //____________________________________________________________________________
112 void AliPHOSv4::AddRecParticle(const AliPHOSFastRecParticle & rp)
114 // Add a virtually reconstructed particle to the list
116 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
120 //____________________________________________________________________________
121 void AliPHOSv4::BuildGeometry()
123 // Build the PHOS geometry for the ROOT display
127 PHOS FAST in ALICE displayed by root
132 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSv4AllViews.gif">
134 <H4> Front View </H4>
137 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSv4FrontView.gif">
142 const Int_t kColorPHOS = kRed ;
144 Double_t const kRADDEG = 180.0 / kPI ;
146 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
150 // position PHOS into ALICE
152 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
154 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * GetGeometry()->GetIPtoCrystalSurface() ) ) ;
156 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
158 char * nodename = new char[20] ;
159 char * rotname = new char[20] ;
161 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
162 Float_t angle = pphi * 2 * ( i - GetGeometry()->GetNModules() / 2.0 - 0.5 ) ;
163 sprintf(rotname, "%s%d", "rot", number++) ;
164 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
166 sprintf(nodename,"%s%d", "Module", i) ;
167 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
168 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
169 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
170 bigboxnode->SetLineColor(kColorPHOS) ;
171 fNodes->Add(bigboxnode) ;
177 //____________________________________________________________________________
178 void AliPHOSv4::CreateGeometry()
180 // Create the geometry for GEANT
182 AliPHOSv4 *phostmp = (AliPHOSv4*)gAlice->GetModule("PHOS") ;
184 if ( phostmp == NULL ) {
186 fprintf(stderr, "PHOS detector not found!\n") ;
191 // Get pointer to the array containing media indeces
192 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
195 bigbox[0] = GetBigBox(0) / 2.0 ;
196 bigbox[1] = GetBigBox(1) / 2.0 ;
197 bigbox[2] = GetBigBox(2) / 2.0 ;
199 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
201 // --- Position PHOS mdules in ALICE setup ---
204 Double_t const kRADDEG = 180.0 / kPI ;
206 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
208 Float_t angle = GetGeometry()->GetPHOSAngle(i) ;
209 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
211 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
213 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
214 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
215 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
222 //____________________________________________________________________________
223 void AliPHOSv4::Init(void)
225 // Prints out an information message
230 for(i=0;i<35;i++) printf("*");
231 printf(" FAST PHOS_INIT ");
232 for(i=0;i<35;i++) printf("*");
235 // Here the PHOS initialisation code (if any!)
237 for(i=0;i<80;i++) printf("*");
242 //___________________________________________________________________________
243 Float_t AliPHOSv4::GetBigBox(Int_t index) const
245 // Get the X, Y or Z dimension of the box describing a PHOS module
263 //___________________________________________________________________________
264 void AliPHOSv4::MakeBranch(Option_t* opt, const char *file)
266 // Create new branch in the current reconstructed Root Tree
268 AliDetector::MakeBranch(opt,file) ;
271 sprintf(branchname,"%s",GetName());
272 const char *cd = strstr(opt,"R");
274 if (fFastRecParticles && gAlice->TreeR() && cd) {
275 MakeBranchInTree(gAlice->TreeR(),
276 branchname, &fFastRecParticles, fBufferSize, file);
280 //____________________________________________________________________________
281 Double_t AliPHOSv4::MakeEnergy(const Double_t energy)
283 // Smears the energy according to the energy dependent energy resolution.
284 // A gaussian distribution is assumed
286 Double_t sigma = SigmaE(energy) ;
287 return fRan.Gaus(energy, sigma) ;
290 //____________________________________________________________________________
291 TVector3 AliPHOSv4::MakePosition(const Double_t energy, const TVector3 pos, const Double_t theta, const Double_t phi)
293 // Smears the impact position according to the energy dependent position resolution
294 // A gaussian position distribution is assumed
297 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
298 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
299 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
300 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
301 Double_t y = pos.Y() ;
310 //____________________________________________________________________________
311 void AliPHOSv4::MakeRecParticle(const Int_t modid, const TVector3 pos, AliPHOSFastRecParticle & rp)
313 // Modify the primary particle properties according
314 // 1. the response function of PHOS
315 // 2. the performance of the EMC+PPSD setup
317 Int_t type = MakeType( rp ) ;
321 // get the detected energy
323 TLorentzVector momentum ;
324 rp.Momentum(momentum) ;
325 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
326 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
327 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
328 + TMath::Power( rp.GetMass(), 2) ) ;
330 // get the angle of incidence
332 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
333 Double_t incidencephi = ( 270 + GetGeometry()->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
335 // get the detected direction
337 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
338 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
340 // Set the modified 4-momentum of the reconstructed particle
342 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
346 //____________________________________________________________________________
347 Int_t AliPHOSv4::MakeType(AliPHOSFastRecParticle & rp )
349 // Generate a particle type using the performance of the EMC+PPSD setup
351 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
352 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
355 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
358 test = rp.GetPdgCode() ;
362 case 22: // it's a photon
364 if ( ran <= 0.5 ) // 50 %
365 rv = AliPHOSFastRecParticle::kGAMMA ;
369 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
371 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
375 case 2112: // it's a neutron
378 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
380 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
383 case -2112: // it's a anti-neutron
386 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
388 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
391 case 11: // it's a electron
394 rv = AliPHOSFastRecParticle::kELECTRON ;
396 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
399 case -11: // it's a positon
402 rv = AliPHOSFastRecParticle::kELECTRON ;
404 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
407 case -1: // it's a charged
410 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
412 rv = AliPHOSFastRecParticle::kGAMMA ;
421 //___________________________________________________________________________
422 void AliPHOSv4::ResetPoints()
424 // This overloads the method in AliDetector
426 ResetFastRecParticles() ;
429 //___________________________________________________________________________
430 void AliPHOSv4::ResetFastRecParticles()
432 // Resets the list of virtual reconstructed particles
434 if (fFastRecParticles)
435 fFastRecParticles->Clear() ;
439 //___________________________________________________________________________
440 void AliPHOSv4::SetBigBox(Int_t index, Float_t value)
442 // Set the size of the Box describing a PHOS module
458 //____________________________________________________________________________
459 Double_t AliPHOSv4::SigmaE(Double_t energy)
461 // Calculates the energy dependent energy resolution
465 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
466 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
467 + TMath::Power(fResPara3, 2) ) ;
472 //____________________________________________________________________________
473 Double_t AliPHOSv4::SigmaP(Double_t energy, Int_t incidence)
475 // Calculates the energy dependent position resolution
477 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
478 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
480 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
483 //____________________________________________________________________________
484 void AliPHOSv4::StepManager(void)
486 // Only verifies if the particle reaches PHOS and stops the tracking
488 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
491 gMC->TrackPosition(lv) ;
492 TVector3 pos = lv.Vect() ;
494 gMC->CurrentVolID(modid);
496 Float_t energy = gMC->Etot() ; //Total energy of current track
498 //Calculating mass of current particle
499 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
500 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
501 Float_t mass = partPDG->Mass() ;
504 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
505 TLorentzVector pTrack(pos, energy) ;
507 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
509 AliPHOSFastRecParticle rp(*part) ;
510 rp.SetPrimary(primary) ;
512 // Adds the response of PHOS to the particle
513 MakeRecParticle(modid, pos, rp) ;
515 // add the `track' particle to the FastRecParticles list
521 // stop the track as soon PHOS is reached