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
54 SetBigBox(0, fGeom->GetOuterBoxSize(0) ) ;
55 SetBigBox(1, fGeom->GetOuterBoxSize(1) + fGeom->GetPPSDBoxSize(1) ) ;
56 SetBigBox(2, fGeom->GetOuterBoxSize(0) );
59 fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
61 fResPara1 = 0.030 ; // GeV
65 fPosParaA0 = 2.87 ; // mm
66 fPosParaA1 = -0.0975 ;
69 fPosParaB2 = 0.00619 ;
72 //____________________________________________________________________________
73 AliPHOSv4::~AliPHOSv4()
77 fFastRecParticles->Delete() ;
78 delete fFastRecParticles ;
79 fFastRecParticles = 0 ;
83 //____________________________________________________________________________
84 void AliPHOSv4::AddRecParticle(const AliPHOSFastRecParticle & rp)
86 // Add a virtually reconstructed particle to the list
88 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
92 //____________________________________________________________________________
93 void AliPHOSv4::BuildGeometry()
95 // Build the PHOS geometry for the ROOT display
99 PHOS FAST in ALICE displayed by root
104 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSv4AllViews.gif">
106 <H4> Front View </H4>
109 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSv4FrontView.gif">
114 const Int_t kColorPHOS = kRed ;
116 Double_t const kRADDEG = 180.0 / kPI ;
118 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
122 // position PHOS into ALICE
124 Float_t r = fGeom->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
126 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * fGeom->GetIPtoCrystalSurface() ) ) ;
128 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
130 char * nodename = new char[20] ;
131 char * rotname = new char[20] ;
133 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
134 Float_t angle = pphi * 2 * ( i - fGeom->GetNModules() / 2.0 - 0.5 ) ;
135 sprintf(rotname, "%s%d", "rot", number++) ;
136 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
138 sprintf(nodename,"%s%d", "Module", i) ;
139 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
140 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
141 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
142 bigboxnode->SetLineColor(kColorPHOS) ;
143 fNodes->Add(bigboxnode) ;
149 //____________________________________________________________________________
150 void AliPHOSv4::CreateGeometry()
152 // Create the geometry for GEANT
154 AliPHOSv4 *phostmp = (AliPHOSv4*)gAlice->GetModule("PHOS") ;
156 if ( phostmp == NULL ) {
158 fprintf(stderr, "PHOS detector not found!\n") ;
163 // Get pointer to the array containing media indeces
164 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
167 bigbox[0] = GetBigBox(0) / 2.0 ;
168 bigbox[1] = GetBigBox(1) / 2.0 ;
169 bigbox[2] = GetBigBox(2) / 2.0 ;
171 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
173 // --- Position PHOS mdules in ALICE setup ---
176 Double_t const kRADDEG = 180.0 / kPI ;
178 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
180 Float_t angle = fGeom->GetPHOSAngle(i) ;
181 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
183 Float_t r = fGeom->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
185 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
186 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
187 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
194 //____________________________________________________________________________
195 void AliPHOSv4::Init(void)
197 // Prints out an information message
202 for(i=0;i<35;i++) printf("*");
203 printf(" FAST PHOS_INIT ");
204 for(i=0;i<35;i++) printf("*");
207 // Here the PHOS initialisation code (if any!)
209 for(i=0;i<80;i++) printf("*");
214 //___________________________________________________________________________
215 Float_t AliPHOSv4::GetBigBox(Int_t index)
217 // Get the X, Y or Z dimension of the box describing a PHOS module
235 //___________________________________________________________________________
236 void AliPHOSv4::MakeBranch(Option_t* opt)
238 // Create new branch in the current reconstructed Root Tree
240 AliDetector::MakeBranch(opt) ;
243 sprintf(branchname,"%s",GetName());
244 char *cd = strstr(opt,"R");
246 if (fFastRecParticles && gAlice->TreeR() && cd) {
247 gAlice->TreeR()->Branch(branchname, &fFastRecParticles, fBufferSize);
251 //____________________________________________________________________________
252 Double_t AliPHOSv4::MakeEnergy(const Double_t energy)
254 // Smears the energy according to the energy dependent energy resolution.
255 // A gaussian distribution is assumed
257 Double_t sigma = SigmaE(energy) ;
258 return fRan.Gaus(energy, sigma) ;
261 //____________________________________________________________________________
262 TVector3 AliPHOSv4::MakePosition(const Double_t energy, const TVector3 pos, const Double_t theta, const Double_t phi)
264 // Smears the impact position according to the energy dependent position resolution
265 // A gaussian position distribution is assumed
268 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
269 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
270 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
271 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
272 Double_t y = pos.Y() ;
281 //____________________________________________________________________________
282 void AliPHOSv4::MakeRecParticle(const Int_t modid, const TVector3 pos, AliPHOSFastRecParticle & rp)
284 // Modify the primary particle properties according
285 // 1. the response function of PHOS
286 // 2. the performance of the EMC+PPSD setup
288 Int_t type = MakeType( rp ) ;
292 // get the detected energy
294 TLorentzVector momentum ;
295 rp.Momentum(momentum) ;
296 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
297 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
298 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
299 + TMath::Power( rp.GetMass(), 2) ) ;
301 // get the angle of incidence
303 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
304 Double_t incidencephi = ( 270 + fGeom->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
306 // get the detected direction
308 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
309 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
311 // Set the modified 4-momentum of the reconstructed particle
313 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
317 //____________________________________________________________________________
318 Int_t AliPHOSv4::MakeType(AliPHOSFastRecParticle & rp )
320 // Generate a particle type using the performance of the EMC+PPSD setup
322 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
323 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
326 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
329 test = rp.GetPdgCode() ;
333 case 22: // it's a photon
335 if ( ran <= 0.5 ) // 50 %
336 rv = AliPHOSFastRecParticle::kGAMMA ;
340 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
342 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
346 case 2112: // it's a neutron
349 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
351 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
354 case -2112: // it's a anti-neutron
357 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
359 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
362 case 11: // it's a electron
365 rv = AliPHOSFastRecParticle::kELECTRON ;
367 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
370 case -11: // it's a positon
373 rv = AliPHOSFastRecParticle::kELECTRON ;
375 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
378 case -1: // it's a charged
381 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
383 rv = AliPHOSFastRecParticle::kGAMMA ;
392 //___________________________________________________________________________
393 void AliPHOSv4::ResetPoints()
395 // This overloads the method in AliDetector
397 ResetFastRecParticles() ;
400 //___________________________________________________________________________
401 void AliPHOSv4::ResetFastRecParticles()
403 // Resets the list of virtual reconstructed particles
405 if (fFastRecParticles)
406 fFastRecParticles->Clear() ;
410 //___________________________________________________________________________
411 void AliPHOSv4::SetBigBox(Int_t index, Float_t value)
413 // Set the size of the Box describing a PHOS module
429 //____________________________________________________________________________
430 Double_t AliPHOSv4::SigmaE(Double_t energy)
432 // Calculates the energy dependent energy resolution
436 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
437 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
438 + TMath::Power(fResPara3, 2) ) ;
443 //____________________________________________________________________________
444 Double_t AliPHOSv4::SigmaP(Double_t energy, Int_t incidence)
446 // Calculates the energy dependent position resolution
448 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
449 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
451 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
454 //____________________________________________________________________________
455 void AliPHOSv4::StepManager(void)
457 // Only verifies if the particle reaches PHOS and stops the tracking
459 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
461 gMC->TrackPosition(lv) ;
462 TVector3 pos = lv.Vect() ;
464 gMC->CurrentVolID(modid);
466 // Makes a reconstructed particle from the primary particle
468 TClonesArray * particlelist = gAlice->Particles() ;
469 TParticle * part = (TParticle *)particlelist->At(primary) ;
471 AliPHOSFastRecParticle rp(*part) ;
472 rp.SetPrimary(primary) ;
474 // Adds the response of PHOS to the particle
476 MakeRecParticle(modid, pos, rp) ;
478 // add the primary particle to the FastRecParticles list
482 // stop the track as soon PHOS is reached