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(const char *name, const char *title):
56 // gets an instance of the geometry parameters class
57 if (strcmp(GetTitle(),"") != 0 )
58 fGeom = AliPHOSGeometry::GetInstance(GetTitle(), "") ;
61 SetBigBox(0, fGeom->GetOuterBoxSize(0) ) ;
62 SetBigBox(1, fGeom->GetOuterBoxSize(1) + fGeom->GetCPVBoxSize(1) ) ;
63 SetBigBox(2, fGeom->GetOuterBoxSize(0) );
66 fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
68 fResPara1 = 0.030 ; // GeV
72 fPosParaA0 = 2.87 ; // mm
73 fPosParaA1 = -0.0975 ;
76 fPosParaB2 = 0.00619 ;
79 //____________________________________________________________________________
80 AliPHOSv4::~AliPHOSv4()
84 fFastRecParticles->Delete() ;
85 delete fFastRecParticles ;
86 fFastRecParticles = 0 ;
90 //____________________________________________________________________________
91 void AliPHOSv4::AddRecParticle(const AliPHOSFastRecParticle & rp)
93 // Add a virtually reconstructed particle to the list
95 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
99 //____________________________________________________________________________
100 void AliPHOSv4::BuildGeometry()
102 // Build the PHOS geometry for the ROOT display
106 PHOS FAST in ALICE displayed by root
111 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSv4AllViews.gif">
113 <H4> Front View </H4>
116 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSv4FrontView.gif">
121 const Int_t kColorPHOS = kRed ;
123 Double_t const kRADDEG = 180.0 / kPI ;
125 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
129 // position PHOS into ALICE
131 Float_t r = fGeom->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
133 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * fGeom->GetIPtoCrystalSurface() ) ) ;
135 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
137 char * nodename = new char[20] ;
138 char * rotname = new char[20] ;
140 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
141 Float_t angle = pphi * 2 * ( i - fGeom->GetNModules() / 2.0 - 0.5 ) ;
142 sprintf(rotname, "%s%d", "rot", number++) ;
143 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
145 sprintf(nodename,"%s%d", "Module", i) ;
146 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
147 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
148 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
149 bigboxnode->SetLineColor(kColorPHOS) ;
150 fNodes->Add(bigboxnode) ;
156 //____________________________________________________________________________
157 void AliPHOSv4::CreateGeometry()
159 // Create the geometry for GEANT
161 AliPHOSv4 *phostmp = (AliPHOSv4*)gAlice->GetModule("PHOS") ;
163 if ( phostmp == NULL ) {
165 fprintf(stderr, "PHOS detector not found!\n") ;
170 // Get pointer to the array containing media indeces
171 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
174 bigbox[0] = GetBigBox(0) / 2.0 ;
175 bigbox[1] = GetBigBox(1) / 2.0 ;
176 bigbox[2] = GetBigBox(2) / 2.0 ;
178 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
180 // --- Position PHOS mdules in ALICE setup ---
183 Double_t const kRADDEG = 180.0 / kPI ;
185 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
187 Float_t angle = fGeom->GetPHOSAngle(i) ;
188 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
190 Float_t r = fGeom->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
192 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
193 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
194 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
201 //____________________________________________________________________________
202 void AliPHOSv4::Init(void)
204 // Prints out an information message
209 for(i=0;i<35;i++) printf("*");
210 printf(" FAST PHOS_INIT ");
211 for(i=0;i<35;i++) printf("*");
214 // Here the PHOS initialisation code (if any!)
216 for(i=0;i<80;i++) printf("*");
221 //___________________________________________________________________________
222 Float_t AliPHOSv4::GetBigBox(Int_t index)
224 // Get the X, Y or Z dimension of the box describing a PHOS module
242 //___________________________________________________________________________
243 void AliPHOSv4::MakeBranch(Option_t* opt, char *file)
245 // Create new branch in the current reconstructed Root Tree
247 AliDetector::MakeBranch(opt,file) ;
250 sprintf(branchname,"%s",GetName());
251 const char *cd = strstr(opt,"R");
253 if (fFastRecParticles && gAlice->TreeR() && cd) {
254 gAlice->MakeBranchInTree(gAlice->TreeR(),
255 branchname, &fFastRecParticles, fBufferSize, file) ;
259 //____________________________________________________________________________
260 Double_t AliPHOSv4::MakeEnergy(const Double_t energy)
262 // Smears the energy according to the energy dependent energy resolution.
263 // A gaussian distribution is assumed
265 Double_t sigma = SigmaE(energy) ;
266 return fRan.Gaus(energy, sigma) ;
269 //____________________________________________________________________________
270 TVector3 AliPHOSv4::MakePosition(const Double_t energy, const TVector3 pos, const Double_t theta, const Double_t phi)
272 // Smears the impact position according to the energy dependent position resolution
273 // A gaussian position distribution is assumed
276 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
277 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
278 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
279 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
280 Double_t y = pos.Y() ;
289 //____________________________________________________________________________
290 void AliPHOSv4::MakeRecParticle(const Int_t modid, const TVector3 pos, AliPHOSFastRecParticle & rp)
292 // Modify the primary particle properties according
293 // 1. the response function of PHOS
294 // 2. the performance of the EMC+PPSD setup
296 Int_t type = MakeType( rp ) ;
300 // get the detected energy
302 TLorentzVector momentum ;
303 rp.Momentum(momentum) ;
304 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
305 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
306 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
307 + TMath::Power( rp.GetMass(), 2) ) ;
309 // get the angle of incidence
311 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
312 Double_t incidencephi = ( 270 + fGeom->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
314 // get the detected direction
316 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
317 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
319 // Set the modified 4-momentum of the reconstructed particle
321 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
325 //____________________________________________________________________________
326 Int_t AliPHOSv4::MakeType(AliPHOSFastRecParticle & rp )
328 // Generate a particle type using the performance of the EMC+PPSD setup
330 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
331 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
334 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
337 test = rp.GetPdgCode() ;
341 case 22: // it's a photon
343 if ( ran <= 0.5 ) // 50 %
344 rv = AliPHOSFastRecParticle::kGAMMA ;
348 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
350 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
354 case 2112: // it's a neutron
357 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
359 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
362 case -2112: // it's a anti-neutron
365 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
367 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
370 case 11: // it's a electron
373 rv = AliPHOSFastRecParticle::kELECTRON ;
375 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
378 case -11: // it's a positon
381 rv = AliPHOSFastRecParticle::kELECTRON ;
383 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
386 case -1: // it's a charged
389 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
391 rv = AliPHOSFastRecParticle::kGAMMA ;
400 //___________________________________________________________________________
401 void AliPHOSv4::ResetPoints()
403 // This overloads the method in AliDetector
405 ResetFastRecParticles() ;
408 //___________________________________________________________________________
409 void AliPHOSv4::ResetFastRecParticles()
411 // Resets the list of virtual reconstructed particles
413 if (fFastRecParticles)
414 fFastRecParticles->Clear() ;
418 //___________________________________________________________________________
419 void AliPHOSv4::SetBigBox(Int_t index, Float_t value)
421 // Set the size of the Box describing a PHOS module
437 //____________________________________________________________________________
438 Double_t AliPHOSv4::SigmaE(Double_t energy)
440 // Calculates the energy dependent energy resolution
444 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
445 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
446 + TMath::Power(fResPara3, 2) ) ;
451 //____________________________________________________________________________
452 Double_t AliPHOSv4::SigmaP(Double_t energy, Int_t incidence)
454 // Calculates the energy dependent position resolution
456 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
457 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
459 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
462 //____________________________________________________________________________
463 void AliPHOSv4::StepManager(void)
465 // Only verifies if the particle reaches PHOS and stops the tracking
467 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
470 gMC->TrackPosition(lv) ;
471 TVector3 pos = lv.Vect() ;
473 gMC->CurrentVolID(modid);
475 Float_t energy = gMC->Etot() ; //Total energy of current track
477 //Calculating mass of current particle
478 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
479 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
480 Float_t mass = partPDG->Mass() ;
483 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
484 TLorentzVector pTrack(pos, energy) ;
486 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
488 AliPHOSFastRecParticle rp(*part) ;
489 rp.SetPrimary(primary) ;
491 // Adds the response of PHOS to the particle
492 MakeRecParticle(modid, pos, rp) ;
494 // add the `track' particle to the FastRecParticles list
500 // stop the track as soon PHOS is reached