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 "AliPHOSvFast.h"
43 ClassImp(AliPHOSvFast)
45 //____________________________________________________________________________
46 AliPHOSvFast::AliPHOSvFast()
50 fFastRecParticles = 0 ;
54 //____________________________________________________________________________
55 AliPHOSvFast::AliPHOSvFast(const char *name, const char *title):
60 // gets an instance of the geometry parameters class
62 fGeom = AliPHOSGeometry::GetInstance(title, "") ;
64 if (fGeom->IsInitialized() )
65 cout << "AliPHOSvFast : PHOS geometry intialized for " << fGeom->GetName() << endl ;
67 cout << "AliPHOSvFast : PHOS geometry initialization failed !" << endl ;
69 SetBigBox(0, fGeom->GetOuterBoxSize(0) ) ;
70 SetBigBox(1, fGeom->GetOuterBoxSize(1) + fGeom->GetPPSDBoxSize(1) ) ;
71 SetBigBox(2, fGeom->GetOuterBoxSize(0) );
74 fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
76 fResPara1 = 0.030 ; // GeV
80 fPosParaA0 = 2.87 ; // mm
81 fPosParaA1 = -0.0975 ;
84 fPosParaB2 = 0.00619 ;
87 //____________________________________________________________________________
88 AliPHOSvFast::~AliPHOSvFast()
92 fFastRecParticles->Delete() ;
93 delete fFastRecParticles ;
94 fFastRecParticles = 0 ;
98 //____________________________________________________________________________
99 void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp)
101 // Add a virtually reconstructed particle to the list
103 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
107 //____________________________________________________________________________
108 void AliPHOSvFast::BuildGeometry()
110 // Build the PHOS geometry for the ROOT display
114 PHOS FAST in ALICE displayed by root
119 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSvFastAllViews.gif">
121 <H4> Front View </H4>
124 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSvFastFrontView.gif">
129 const Int_t kColorPHOS = kRed ;
131 Double_t const kRADDEG = 180.0 / kPI ;
133 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
137 // position PHOS into ALICE
139 Float_t r = fGeom->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
141 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * fGeom->GetIPtoCrystalSurface() ) ) ;
143 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
145 char * nodename = new char[20] ;
146 char * rotname = new char[20] ;
148 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
149 Float_t angle = pphi * 2 * ( i - fGeom->GetNModules() / 2.0 - 0.5 ) ;
150 sprintf(rotname, "%s%d", "rot", number++) ;
151 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
153 sprintf(nodename,"%s%d", "Module", i) ;
154 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
155 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
156 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
157 bigboxnode->SetLineColor(kColorPHOS) ;
158 fNodes->Add(bigboxnode) ;
164 //____________________________________________________________________________
165 void AliPHOSvFast::CreateGeometry()
167 // Create the geometry for GEANT
169 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
171 if ( phostmp == NULL ) {
173 fprintf(stderr, "PHOS detector not found!\n") ;
178 // Get pointer to the array containing media indeces
179 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
182 bigbox[0] = GetBigBox(0) / 2.0 ;
183 bigbox[1] = GetBigBox(1) / 2.0 ;
184 bigbox[2] = GetBigBox(2) / 2.0 ;
186 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
188 // --- Position PHOS mdules in ALICE setup ---
191 Double_t const kRADDEG = 180.0 / kPI ;
193 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
195 Float_t angle = fGeom->GetPHOSAngle(i) ;
196 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
198 Float_t r = fGeom->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
200 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
201 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
202 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
209 //____________________________________________________________________________
210 void AliPHOSvFast::Init(void)
212 // Prints out an information message
217 for(i=0;i<35;i++) printf("*");
218 printf(" FAST PHOS_INIT ");
219 for(i=0;i<35;i++) printf("*");
222 // Here the PHOS initialisation code (if any!)
224 for(i=0;i<80;i++) printf("*");
229 //___________________________________________________________________________
230 Float_t AliPHOSvFast::GetBigBox(Int_t index)
232 // Get the X, Y or Z dimension of the box describing a PHOS module
250 //___________________________________________________________________________
251 void AliPHOSvFast::MakeBranch(Option_t* opt)
253 // Create new branch in the current reconstructed Root Tree
255 AliDetector::MakeBranch(opt) ;
258 sprintf(branchname,"%s",GetName());
259 char *cd = strstr(opt,"R");
261 if (fFastRecParticles && gAlice->TreeR() && cd) {
262 gAlice->TreeR()->Branch(branchname, &fFastRecParticles, fBufferSize);
266 //____________________________________________________________________________
267 Double_t AliPHOSvFast::MakeEnergy(const Double_t energy)
269 // Smears the energy according to the energy dependent energy resolution.
270 // A gaussian distribution is assumed
272 Double_t sigma = SigmaE(energy) ;
273 return fRan.Gaus(energy, sigma) ;
276 //____________________________________________________________________________
277 TVector3 AliPHOSvFast::MakePosition(const Double_t energy, const TVector3 pos, const Double_t theta, const Double_t phi)
279 // Smears the impact position according to the energy dependent position resolution
280 // A gaussian position distribution is assumed
283 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
284 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
285 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
286 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
287 Double_t y = pos.Y() ;
296 //____________________________________________________________________________
297 void AliPHOSvFast::MakeRecParticle(const Int_t modid, const TVector3 pos, AliPHOSFastRecParticle & rp)
299 // Modify the primary particle properties according
300 // 1. the response function of PHOS
301 // 2. the performance of the EMC+PPSD setup
303 Int_t type = MakeType( rp ) ;
307 // get the detected energy
309 TLorentzVector momentum ;
310 rp.Momentum(momentum) ;
311 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
312 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
313 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
314 + TMath::Power( rp.GetMass(), 2) ) ;
316 // get the angle of incidence
318 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
319 Double_t incidencephi = ( 270 + fGeom->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
321 // get the detected direction
323 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
324 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
326 // Set the modified 4-momentum of the reconstructed particle
328 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
332 //____________________________________________________________________________
333 Int_t AliPHOSvFast::MakeType(AliPHOSFastRecParticle & rp )
335 // Generate a particle type using the performance of the EMC+PPSD setup
337 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
338 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
341 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
344 test = rp.GetPdgCode() ;
348 case 22: // it's a photon
350 if ( ran <= 0.5 ) // 50 %
351 rv = AliPHOSFastRecParticle::kGAMMA ;
355 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
357 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
361 case 2112: // it's a neutron
364 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
366 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
369 case -2112: // it's a anti-neutron
372 rv = AliPHOSFastRecParticle::kNEUTRALHA ;
374 rv = AliPHOSFastRecParticle::kNEUTRALEM ;
377 case 11: // it's a electron
380 rv = AliPHOSFastRecParticle::kELECTRON ;
382 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
385 case -11: // it's a positon
388 rv = AliPHOSFastRecParticle::kELECTRON ;
390 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
393 case -1: // it's a charged
396 rv = AliPHOSFastRecParticle::kCHARGEDHA ;
398 rv = AliPHOSFastRecParticle::kGAMMA ;
407 //___________________________________________________________________________
408 void AliPHOSvFast::ResetPoints()
410 // This overloads the method in AliDetector
412 ResetFastRecParticles() ;
415 //___________________________________________________________________________
416 void AliPHOSvFast::ResetFastRecParticles()
418 // Resets the list of virtual reconstructed particles
420 if (fFastRecParticles)
421 fFastRecParticles->Clear() ;
425 //___________________________________________________________________________
426 void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
428 // Set the size of the Box describing a PHOS module
444 //____________________________________________________________________________
445 Double_t AliPHOSvFast::SigmaE(Double_t energy)
447 // Calculates the energy dependent energy resolution
451 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
452 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
453 + TMath::Power(fResPara3, 2) ) ;
458 //____________________________________________________________________________
459 Double_t AliPHOSvFast::SigmaP(Double_t energy, Int_t incidence)
461 // Calculates the energy dependent position resolution
463 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
464 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
466 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
469 //____________________________________________________________________________
470 void AliPHOSvFast::StepManager(void)
472 // Only verifies if the particle reaches PHOS and stops the tracking
474 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
476 gMC->TrackPosition(lv) ;
477 TVector3 pos = lv.Vect() ;
479 gMC->CurrentVolID(modid);
481 // Makes a reconstructed particle from the primary particle
483 TClonesArray * particlelist = gAlice->Particles() ;
484 TParticle * part = (TParticle *)particlelist->At(primary) ;
486 AliPHOSFastRecParticle rp(*part) ;
487 rp.SetPrimary(primary) ;
489 // Adds the response of PHOS to the particle
491 MakeRecParticle(modid, pos, rp) ;
493 // add the primary particle to the FastRecParticles list
497 // stop the track as soon PHOS is reached