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 // --- Standard library ---
37 // --- AliRoot header files ---
39 #include "AliPHOSv4.h"
45 //____________________________________________________________________________
46 AliPHOSv4::AliPHOSv4(const char *name, const char *title):
51 // gets an instance of the geometry parameters class
52 if (strcmp(GetTitle(),"") != 0 )
53 fGeom = AliPHOSGeometry::GetInstance(GetTitle(), "") ;
56 SetBigBox(0, fGeom->GetOuterBoxSize(0) ) ;
57 SetBigBox(1, fGeom->GetOuterBoxSize(1) + fGeom->GetPPSDBoxSize(1) ) ;
58 SetBigBox(2, fGeom->GetOuterBoxSize(0) );
61 fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
63 fResPara1 = 0.030 ; // GeV
67 fPosParaA0 = 2.87 ; // mm
68 fPosParaA1 = -0.0975 ;
71 fPosParaB2 = 0.00619 ;
74 //____________________________________________________________________________
75 AliPHOSv4::~AliPHOSv4()
79 fFastRecParticles->Delete() ;
80 delete fFastRecParticles ;
81 fFastRecParticles = 0 ;
85 //____________________________________________________________________________
86 void AliPHOSv4::AddRecParticle(const AliPHOSFastRecParticle & rp)
88 // Add a virtually reconstructed particle to the list
90 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
94 //____________________________________________________________________________
95 void AliPHOSv4::BuildGeometry()
97 // Build the PHOS geometry for the ROOT display
101 PHOS FAST in ALICE displayed by root
106 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSv4AllViews.gif">
108 <H4> Front View </H4>
111 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSv4FrontView.gif">
116 const Int_t kColorPHOS = kRed ;
118 Double_t const kRADDEG = 180.0 / kPI ;
120 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
124 // position PHOS into ALICE
126 Float_t r = fGeom->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
128 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * fGeom->GetIPtoCrystalSurface() ) ) ;
130 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
132 char * nodename = new char[20] ;
133 char * rotname = new char[20] ;
135 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
136 Float_t angle = pphi * 2 * ( i - fGeom->GetNModules() / 2.0 - 0.5 ) ;
137 sprintf(rotname, "%s%d", "rot", number++) ;
138 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
140 sprintf(nodename,"%s%d", "Module", i) ;
141 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
142 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
143 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
144 bigboxnode->SetLineColor(kColorPHOS) ;
145 fNodes->Add(bigboxnode) ;
151 //____________________________________________________________________________
152 void AliPHOSv4::CreateGeometry()
154 // Create the geometry for GEANT
156 AliPHOSv4 *phostmp = (AliPHOSv4*)gAlice->GetModule("PHOS") ;
158 if ( phostmp == NULL ) {
160 fprintf(stderr, "PHOS detector not found!\n") ;
165 // Get pointer to the array containing media indeces
166 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
169 bigbox[0] = GetBigBox(0) / 2.0 ;
170 bigbox[1] = GetBigBox(1) / 2.0 ;
171 bigbox[2] = GetBigBox(2) / 2.0 ;
173 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
175 // --- Position PHOS mdules in ALICE setup ---
178 Double_t const kRADDEG = 180.0 / kPI ;
180 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
182 Float_t angle = fGeom->GetPHOSAngle(i) ;
183 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
185 Float_t r = fGeom->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
187 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
188 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
189 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
196 //____________________________________________________________________________
197 void AliPHOSv4::Init(void)
199 // Prints out an information message
204 for(i=0;i<35;i++) printf("*");
205 printf(" FAST PHOS_INIT ");
206 for(i=0;i<35;i++) printf("*");
209 // Here the PHOS initialisation code (if any!)
211 for(i=0;i<80;i++) printf("*");
216 //___________________________________________________________________________
217 Float_t AliPHOSv4::GetBigBox(Int_t index)
219 // Get the X, Y or Z dimension of the box describing a PHOS module
237 //___________________________________________________________________________
238 void AliPHOSv4::MakeBranch(Option_t* opt)
240 // Create new branch in the current reconstructed Root Tree
242 AliDetector::MakeBranch(opt) ;
245 sprintf(branchname,"%s",GetName());
246 char *cd = strstr(opt,"R");
248 if (fFastRecParticles && gAlice->TreeR() && cd) {
249 gAlice->TreeR()->Branch(branchname, &fFastRecParticles, fBufferSize);
253 //____________________________________________________________________________
254 Double_t AliPHOSv4::MakeEnergy(const Double_t energy)
256 // Smears the energy according to the energy dependent energy resolution.
257 // A gaussian distribution is assumed
259 Double_t sigma = SigmaE(energy) ;
260 return fRan.Gaus(energy, sigma) ;
263 //____________________________________________________________________________
264 TVector3 AliPHOSv4::MakePosition(const Double_t energy, const TVector3 pos, const Double_t theta, const Double_t phi)
266 // Smears the impact position according to the energy dependent position resolution
267 // A gaussian position distribution is assumed
270 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
271 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
272 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
273 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
274 Double_t y = pos.Y() ;
283 //____________________________________________________________________________
284 void AliPHOSv4::MakeRecParticle(const Int_t modid, const TVector3 pos, AliPHOSFastRecParticle & rp)
286 // Modify the primary particle properties according
287 // 1. the response function of PHOS
288 // 2. the performance of the EMC+PPSD setup
290 Int_t type = MakeType( rp ) ;
294 // get the detected energy
296 TLorentzVector momentum ;
297 rp.Momentum(momentum) ;
298 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
299 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
300 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
301 + TMath::Power( rp.GetMass(), 2) ) ;
303 // get the angle of incidence
305 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
306 Double_t incidencephi = ( 270 + fGeom->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
308 // get the detected direction
310 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
311 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
313 // Set the modified 4-momentum of the reconstructed particle
315 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
319 //____________________________________________________________________________
320 Int_t AliPHOSv4::MakeType(AliPHOSFastRecParticle & rp )
322 // Generate a particle type using the performance of the EMC+PPSD setup
324 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
325 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
328 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
331 test = rp.GetPdgCode() ;
335 case 22: // it's a photon
337 if ( ran <= 0.5 ) // 50 %
338 rv = AliPHOSFastRecParticle::kGAMMA ;
342 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
344 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
348 case 2112: // it's a neutron
351 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
353 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
356 case -2112: // it's a anti-neutron
359 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
361 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
364 case 11: // it's a electron
367 rv = AliPHOSFastRecParticle::kELECTRON ;
369 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
372 case -11: // it's a positon
375 rv = AliPHOSFastRecParticle::kELECTRON ;
377 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
380 case -1: // it's a charged
383 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
385 rv = AliPHOSFastRecParticle::kGAMMA ;
394 //___________________________________________________________________________
395 void AliPHOSv4::ResetPoints()
397 // This overloads the method in AliDetector
399 ResetFastRecParticles() ;
402 //___________________________________________________________________________
403 void AliPHOSv4::ResetFastRecParticles()
405 // Resets the list of virtual reconstructed particles
407 if (fFastRecParticles)
408 fFastRecParticles->Clear() ;
412 //___________________________________________________________________________
413 void AliPHOSv4::SetBigBox(Int_t index, Float_t value)
415 // Set the size of the Box describing a PHOS module
431 //____________________________________________________________________________
432 Double_t AliPHOSv4::SigmaE(Double_t energy)
434 // Calculates the energy dependent energy resolution
438 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
439 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
440 + TMath::Power(fResPara3, 2) ) ;
445 //____________________________________________________________________________
446 Double_t AliPHOSv4::SigmaP(Double_t energy, Int_t incidence)
448 // Calculates the energy dependent position resolution
450 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
451 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
453 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
456 //____________________________________________________________________________
457 void AliPHOSv4::StepManager(void)
459 // Only verifies if the particle reaches PHOS and stops the tracking
461 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
464 gMC->TrackPosition(lv) ;
465 TVector3 pos = lv.Vect() ;
467 gMC->CurrentVolID(modid);
469 Float_t Energy = gMC->Etot() ; //Total energy of current track
471 //Calculating mass of current particle
472 TDatabasePDG * PDG = TDatabasePDG::Instance() ;
473 TParticlePDG * partPDG = PDG->GetParticle(gMC->TrackPid()) ;
474 Float_t mass = partPDG->Mass() ;
477 pos.SetMag(TMath::Sqrt(Energy*Energy-mass*mass)) ;
478 TLorentzVector pTrack(pos,Energy) ;
480 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
482 AliPHOSFastRecParticle rp(*part) ;
483 rp.SetPrimary(primary) ;
485 // Adds the response of PHOS to the particle
486 MakeRecParticle(modid, pos, rp) ;
488 // add the `track' particle to the FastRecParticles list
494 // stop the track as soon PHOS is reached