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"
35 // --- Standard library ---
39 // --- AliRoot header files ---
41 #include "AliPHOSv4.h"
48 //____________________________________________________________________________
49 AliPHOSv4::AliPHOSv4(const char *name, const char *title):
54 // gets an instance of the geometry parameters class
55 if (strcmp(GetTitle(),"") != 0 )
56 fGeom = AliPHOSGeometry::GetInstance(GetTitle(), "") ;
59 SetBigBox(0, fGeom->GetOuterBoxSize(0) ) ;
60 SetBigBox(1, fGeom->GetOuterBoxSize(1) + fGeom->GetCPVBoxSize(1) ) ;
61 SetBigBox(2, fGeom->GetOuterBoxSize(0) );
64 fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
66 fResPara1 = 0.030 ; // GeV
70 fPosParaA0 = 2.87 ; // mm
71 fPosParaA1 = -0.0975 ;
74 fPosParaB2 = 0.00619 ;
77 //____________________________________________________________________________
78 AliPHOSv4::~AliPHOSv4()
82 fFastRecParticles->Delete() ;
83 delete fFastRecParticles ;
84 fFastRecParticles = 0 ;
88 //____________________________________________________________________________
89 void AliPHOSv4::AddRecParticle(const AliPHOSFastRecParticle & rp)
91 // Add a virtually reconstructed particle to the list
93 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
97 //____________________________________________________________________________
98 void AliPHOSv4::BuildGeometry()
100 // Build the PHOS geometry for the ROOT display
104 PHOS FAST in ALICE displayed by root
109 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSv4AllViews.gif">
111 <H4> Front View </H4>
114 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSv4FrontView.gif">
119 const Int_t kColorPHOS = kRed ;
121 Double_t const kRADDEG = 180.0 / kPI ;
123 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
127 // position PHOS into ALICE
129 Float_t r = fGeom->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
131 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * fGeom->GetIPtoCrystalSurface() ) ) ;
133 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
135 char * nodename = new char[20] ;
136 char * rotname = new char[20] ;
138 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
139 Float_t angle = pphi * 2 * ( i - fGeom->GetNModules() / 2.0 - 0.5 ) ;
140 sprintf(rotname, "%s%d", "rot", number++) ;
141 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
143 sprintf(nodename,"%s%d", "Module", i) ;
144 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
145 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
146 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
147 bigboxnode->SetLineColor(kColorPHOS) ;
148 fNodes->Add(bigboxnode) ;
154 //____________________________________________________________________________
155 void AliPHOSv4::CreateGeometry()
157 // Create the geometry for GEANT
159 AliPHOSv4 *phostmp = (AliPHOSv4*)gAlice->GetModule("PHOS") ;
161 if ( phostmp == NULL ) {
163 fprintf(stderr, "PHOS detector not found!\n") ;
168 // Get pointer to the array containing media indeces
169 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
172 bigbox[0] = GetBigBox(0) / 2.0 ;
173 bigbox[1] = GetBigBox(1) / 2.0 ;
174 bigbox[2] = GetBigBox(2) / 2.0 ;
176 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
178 // --- Position PHOS mdules in ALICE setup ---
181 Double_t const kRADDEG = 180.0 / kPI ;
183 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
185 Float_t angle = fGeom->GetPHOSAngle(i) ;
186 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
188 Float_t r = fGeom->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
190 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
191 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
192 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
199 //____________________________________________________________________________
200 void AliPHOSv4::Init(void)
202 // Prints out an information message
207 for(i=0;i<35;i++) printf("*");
208 printf(" FAST PHOS_INIT ");
209 for(i=0;i<35;i++) printf("*");
212 // Here the PHOS initialisation code (if any!)
214 for(i=0;i<80;i++) printf("*");
219 //___________________________________________________________________________
220 Float_t AliPHOSv4::GetBigBox(Int_t index)
222 // Get the X, Y or Z dimension of the box describing a PHOS module
240 //___________________________________________________________________________
241 void AliPHOSv4::MakeBranch(Option_t* opt)
243 // Create new branch in the current reconstructed Root Tree
245 AliDetector::MakeBranch(opt) ;
248 sprintf(branchname,"%s",GetName());
249 char *cd = strstr(opt,"R");
251 if (fFastRecParticles && gAlice->TreeR() && cd) {
252 gAlice->TreeR()->Branch(branchname, &fFastRecParticles, fBufferSize);
256 //____________________________________________________________________________
257 Double_t AliPHOSv4::MakeEnergy(const Double_t energy)
259 // Smears the energy according to the energy dependent energy resolution.
260 // A gaussian distribution is assumed
262 Double_t sigma = SigmaE(energy) ;
263 return fRan.Gaus(energy, sigma) ;
266 //____________________________________________________________________________
267 TVector3 AliPHOSv4::MakePosition(const Double_t energy, const TVector3 pos, const Double_t theta, const Double_t phi)
269 // Smears the impact position according to the energy dependent position resolution
270 // A gaussian position distribution is assumed
273 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
274 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
275 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
276 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
277 Double_t y = pos.Y() ;
286 //____________________________________________________________________________
287 void AliPHOSv4::MakeRecParticle(const Int_t modid, const TVector3 pos, AliPHOSFastRecParticle & rp)
289 // Modify the primary particle properties according
290 // 1. the response function of PHOS
291 // 2. the performance of the EMC+PPSD setup
293 Int_t type = MakeType( rp ) ;
297 // get the detected energy
299 TLorentzVector momentum ;
300 rp.Momentum(momentum) ;
301 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
302 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
303 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
304 + TMath::Power( rp.GetMass(), 2) ) ;
306 // get the angle of incidence
308 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
309 Double_t incidencephi = ( 270 + fGeom->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
311 // get the detected direction
313 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
314 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
316 // Set the modified 4-momentum of the reconstructed particle
318 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
322 //____________________________________________________________________________
323 Int_t AliPHOSv4::MakeType(AliPHOSFastRecParticle & rp )
325 // Generate a particle type using the performance of the EMC+PPSD setup
327 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
328 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
331 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
334 test = rp.GetPdgCode() ;
338 case 22: // it's a photon
340 if ( ran <= 0.5 ) // 50 %
341 rv = AliPHOSFastRecParticle::kGAMMA ;
345 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
347 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
351 case 2112: // it's a neutron
354 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
356 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
359 case -2112: // it's a anti-neutron
362 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
364 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
367 case 11: // it's a electron
370 rv = AliPHOSFastRecParticle::kELECTRON ;
372 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
375 case -11: // it's a positon
378 rv = AliPHOSFastRecParticle::kELECTRON ;
380 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
383 case -1: // it's a charged
386 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
388 rv = AliPHOSFastRecParticle::kGAMMA ;
397 //___________________________________________________________________________
398 void AliPHOSv4::ResetPoints()
400 // This overloads the method in AliDetector
402 ResetFastRecParticles() ;
405 //___________________________________________________________________________
406 void AliPHOSv4::ResetFastRecParticles()
408 // Resets the list of virtual reconstructed particles
410 if (fFastRecParticles)
411 fFastRecParticles->Clear() ;
415 //___________________________________________________________________________
416 void AliPHOSv4::SetBigBox(Int_t index, Float_t value)
418 // Set the size of the Box describing a PHOS module
434 //____________________________________________________________________________
435 Double_t AliPHOSv4::SigmaE(Double_t energy)
437 // Calculates the energy dependent energy resolution
441 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
442 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
443 + TMath::Power(fResPara3, 2) ) ;
448 //____________________________________________________________________________
449 Double_t AliPHOSv4::SigmaP(Double_t energy, Int_t incidence)
451 // Calculates the energy dependent position resolution
453 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
454 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
456 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
459 //____________________________________________________________________________
460 void AliPHOSv4::StepManager(void)
462 // Only verifies if the particle reaches PHOS and stops the tracking
464 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
467 gMC->TrackPosition(lv) ;
468 TVector3 pos = lv.Vect() ;
470 gMC->CurrentVolID(modid);
472 Float_t Energy = gMC->Etot() ; //Total energy of current track
474 //Calculating mass of current particle
475 TDatabasePDG * PDG = TDatabasePDG::Instance() ;
476 TParticlePDG * partPDG = PDG->GetParticle(gMC->TrackPid()) ;
477 Float_t mass = partPDG->Mass() ;
480 pos.SetMag(TMath::Sqrt(Energy*Energy-mass*mass)) ;
481 TLorentzVector pTrack(pos,Energy) ;
483 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
485 AliPHOSFastRecParticle rp(*part) ;
486 rp.SetPrimary(primary) ;
488 // Adds the response of PHOS to the particle
489 MakeRecParticle(modid, pos, rp) ;
491 // add the `track' particle to the FastRecParticles list
497 // stop the track as soon PHOS is reached