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 ---
42 #include "AliPHOSv4.h"
49 //____________________________________________________________________________
50 AliPHOSv4::AliPHOSv4(const char *name, const char *title):
55 // gets an instance of the geometry parameters class
56 if (strcmp(GetTitle(),"") != 0 )
57 fGeom = AliPHOSGeometry::GetInstance(GetTitle(), "") ;
60 SetBigBox(0, fGeom->GetOuterBoxSize(0) ) ;
61 SetBigBox(1, fGeom->GetOuterBoxSize(1) + fGeom->GetCPVBoxSize(1) ) ;
62 SetBigBox(2, fGeom->GetOuterBoxSize(0) );
65 fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
67 fResPara1 = 0.030 ; // GeV
71 fPosParaA0 = 2.87 ; // mm
72 fPosParaA1 = -0.0975 ;
75 fPosParaB2 = 0.00619 ;
78 //____________________________________________________________________________
79 AliPHOSv4::~AliPHOSv4()
83 fFastRecParticles->Delete() ;
84 delete fFastRecParticles ;
85 fFastRecParticles = 0 ;
89 //____________________________________________________________________________
90 void AliPHOSv4::AddRecParticle(const AliPHOSFastRecParticle & rp)
92 // Add a virtually reconstructed particle to the list
94 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
98 //____________________________________________________________________________
99 void AliPHOSv4::BuildGeometry()
101 // Build the PHOS geometry for the ROOT display
105 PHOS FAST in ALICE displayed by root
110 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSv4AllViews.gif">
112 <H4> Front View </H4>
115 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSv4FrontView.gif">
120 const Int_t kColorPHOS = kRed ;
122 Double_t const kRADDEG = 180.0 / kPI ;
124 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
128 // position PHOS into ALICE
130 Float_t r = fGeom->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
132 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * fGeom->GetIPtoCrystalSurface() ) ) ;
134 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
136 char * nodename = new char[20] ;
137 char * rotname = new char[20] ;
139 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
140 Float_t angle = pphi * 2 * ( i - fGeom->GetNModules() / 2.0 - 0.5 ) ;
141 sprintf(rotname, "%s%d", "rot", number++) ;
142 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
144 sprintf(nodename,"%s%d", "Module", i) ;
145 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
146 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
147 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
148 bigboxnode->SetLineColor(kColorPHOS) ;
149 fNodes->Add(bigboxnode) ;
155 //____________________________________________________________________________
156 void AliPHOSv4::CreateGeometry()
158 // Create the geometry for GEANT
160 AliPHOSv4 *phostmp = (AliPHOSv4*)gAlice->GetModule("PHOS") ;
162 if ( phostmp == NULL ) {
164 fprintf(stderr, "PHOS detector not found!\n") ;
169 // Get pointer to the array containing media indeces
170 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
173 bigbox[0] = GetBigBox(0) / 2.0 ;
174 bigbox[1] = GetBigBox(1) / 2.0 ;
175 bigbox[2] = GetBigBox(2) / 2.0 ;
177 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
179 // --- Position PHOS mdules in ALICE setup ---
182 Double_t const kRADDEG = 180.0 / kPI ;
184 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
186 Float_t angle = fGeom->GetPHOSAngle(i) ;
187 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
189 Float_t r = fGeom->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
191 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
192 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
193 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
200 //____________________________________________________________________________
201 void AliPHOSv4::Init(void)
203 // Prints out an information message
208 for(i=0;i<35;i++) printf("*");
209 printf(" FAST PHOS_INIT ");
210 for(i=0;i<35;i++) printf("*");
213 // Here the PHOS initialisation code (if any!)
215 for(i=0;i<80;i++) printf("*");
220 //___________________________________________________________________________
221 Float_t AliPHOSv4::GetBigBox(Int_t index)
223 // Get the X, Y or Z dimension of the box describing a PHOS module
241 //___________________________________________________________________________
242 void AliPHOSv4::MakeBranch(Option_t* opt, char *file)
244 // Create new branch in the current reconstructed Root Tree
246 AliDetector::MakeBranch(opt,file) ;
249 sprintf(branchname,"%s",GetName());
250 char *cd = strstr(opt,"R");
252 if (fFastRecParticles && gAlice->TreeR() && cd) {
253 gAlice->MakeBranchInTree(gAlice->TreeR(),
254 branchname, &fFastRecParticles, fBufferSize, file) ;
258 //____________________________________________________________________________
259 Double_t AliPHOSv4::MakeEnergy(const Double_t energy)
261 // Smears the energy according to the energy dependent energy resolution.
262 // A gaussian distribution is assumed
264 Double_t sigma = SigmaE(energy) ;
265 return fRan.Gaus(energy, sigma) ;
268 //____________________________________________________________________________
269 TVector3 AliPHOSv4::MakePosition(const Double_t energy, const TVector3 pos, const Double_t theta, const Double_t phi)
271 // Smears the impact position according to the energy dependent position resolution
272 // A gaussian position distribution is assumed
275 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
276 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
277 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
278 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
279 Double_t y = pos.Y() ;
288 //____________________________________________________________________________
289 void AliPHOSv4::MakeRecParticle(const Int_t modid, const TVector3 pos, AliPHOSFastRecParticle & rp)
291 // Modify the primary particle properties according
292 // 1. the response function of PHOS
293 // 2. the performance of the EMC+PPSD setup
295 Int_t type = MakeType( rp ) ;
299 // get the detected energy
301 TLorentzVector momentum ;
302 rp.Momentum(momentum) ;
303 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
304 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
305 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
306 + TMath::Power( rp.GetMass(), 2) ) ;
308 // get the angle of incidence
310 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
311 Double_t incidencephi = ( 270 + fGeom->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
313 // get the detected direction
315 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
316 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
318 // Set the modified 4-momentum of the reconstructed particle
320 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
324 //____________________________________________________________________________
325 Int_t AliPHOSv4::MakeType(AliPHOSFastRecParticle & rp )
327 // Generate a particle type using the performance of the EMC+PPSD setup
329 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
330 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
333 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
336 test = rp.GetPdgCode() ;
340 case 22: // it's a photon
342 if ( ran <= 0.5 ) // 50 %
343 rv = AliPHOSFastRecParticle::kGAMMA ;
347 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
349 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
353 case 2112: // it's a neutron
356 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
358 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
361 case -2112: // it's a anti-neutron
364 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
366 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
369 case 11: // it's a electron
372 rv = AliPHOSFastRecParticle::kELECTRON ;
374 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
377 case -11: // it's a positon
380 rv = AliPHOSFastRecParticle::kELECTRON ;
382 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
385 case -1: // it's a charged
388 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
390 rv = AliPHOSFastRecParticle::kGAMMA ;
399 //___________________________________________________________________________
400 void AliPHOSv4::ResetPoints()
402 // This overloads the method in AliDetector
404 ResetFastRecParticles() ;
407 //___________________________________________________________________________
408 void AliPHOSv4::ResetFastRecParticles()
410 // Resets the list of virtual reconstructed particles
412 if (fFastRecParticles)
413 fFastRecParticles->Clear() ;
417 //___________________________________________________________________________
418 void AliPHOSv4::SetBigBox(Int_t index, Float_t value)
420 // Set the size of the Box describing a PHOS module
436 //____________________________________________________________________________
437 Double_t AliPHOSv4::SigmaE(Double_t energy)
439 // Calculates the energy dependent energy resolution
443 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
444 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
445 + TMath::Power(fResPara3, 2) ) ;
450 //____________________________________________________________________________
451 Double_t AliPHOSv4::SigmaP(Double_t energy, Int_t incidence)
453 // Calculates the energy dependent position resolution
455 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
456 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
458 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
461 //____________________________________________________________________________
462 void AliPHOSv4::StepManager(void)
464 // Only verifies if the particle reaches PHOS and stops the tracking
466 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
469 gMC->TrackPosition(lv) ;
470 TVector3 pos = lv.Vect() ;
472 gMC->CurrentVolID(modid);
474 Float_t energy = gMC->Etot() ; //Total energy of current track
476 //Calculating mass of current particle
477 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
478 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
479 Float_t mass = partPDG->Mass() ;
482 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
483 TLorentzVector pTrack(pos, energy) ;
485 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
487 AliPHOSFastRecParticle rp(*part) ;
488 rp.SetPrimary(primary) ;
490 // Adds the response of PHOS to the particle
491 MakeRecParticle(modid, pos, rp) ;
493 // add the `track' particle to the FastRecParticles list
499 // stop the track as soon PHOS is reached