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 /* History of cvs commits:
21 * Revision 1.30 2006/09/13 07:31:01 kharlov
22 * Effective C++ corrections (T.Pocheptsov)
24 * Revision 1.29 2005/05/28 14:19:05 schutz
25 * Compilation warnings fixed by T.P.
29 //_________________________________________________________________________
30 // Implementation of the PHOS manager class for fast simulations
31 // Tracks particles until the reach a grossly designed PHOS module
32 // Modify the particles property (momentum, energy, type) according to
33 // the PHOS response function. The result is called a virtual reconstructed
36 //*-- Author: Yves Schutz (SUBATECH)
38 // --- ROOT system ---
41 #include <TGeometry.h>
43 #include <TParticle.h>
44 #include "TClonesArray.h"
45 #include <TVirtualMC.h>
47 // --- Standard library ---
49 // --- AliRoot header files ---
50 #include "AliPHOSFastRecParticle.h"
51 #include "AliPHOSGeometry.h"
52 #include "AliPHOSLoader.h"
53 #include "AliPHOSvFast.h"
56 ClassImp(AliPHOSvFast)
58 AliPHOSvFast::AliPHOSvFast() :
74 // default ctor : initialize data member
77 //____________________________________________________________________________
78 AliPHOSvFast::AliPHOSvFast(const char *name, const char *title):
83 fFastRecParticles(new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100)),
86 fResPara1(0.030), // GeV
89 fPosParaA0(2.87), // mm
97 SetBigBox(0, GetGeometry()->GetOuterBoxSize(0) ) ;
98 SetBigBox(1, GetGeometry()->GetOuterBoxSize(3) + GetGeometry()->GetCPVBoxSize(1) ) ;
99 SetBigBox(2, GetGeometry()->GetOuterBoxSize(2) );
102 //____________________________________________________________________________
103 AliPHOSvFast::~AliPHOSvFast()
107 fFastRecParticles->Delete() ;
108 delete fFastRecParticles ;
109 fFastRecParticles = 0 ;
113 //____________________________________________________________________________
114 void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp)
116 // Add a virtually reconstructed particle to the list
118 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
122 //____________________________________________________________________________
123 void AliPHOSvFast::BuildGeometry()
125 // Build the PHOS geometry for the ROOT display
129 PHOS FAST in ALICE displayed by root
134 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSvFastAllViews.gif">
136 <H4> Front View </H4>
139 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSvFastFrontView.gif">
144 const Int_t kColorPHOS = kRed ;
146 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
148 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
152 // position PHOS into ALICE
154 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
156 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * GetGeometry()->GetIPtoCrystalSurface() ) ) ;
158 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
160 char * nodename = new char[20] ;
161 char * rotname = new char[20] ;
163 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
164 Float_t angle = pphi * 2 * ( i - GetGeometry()->GetNModules() / 2.0 - 0.5 ) ;
165 sprintf(rotname, "%s%d", "rot", number++) ;
166 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
168 sprintf(nodename,"%s%d", "Module", i) ;
169 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
170 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
171 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
172 bigboxnode->SetLineColor(kColorPHOS) ;
173 fNodes->Add(bigboxnode) ;
179 //____________________________________________________________________________
180 void AliPHOSvFast::CreateGeometry()
182 // Create the geometry for GEANT
184 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
186 if ( phostmp == NULL ) {
188 fprintf(stderr, "PHOS detector not found!\n") ;
193 // Get pointer to the array containing media indeces
194 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
197 bigbox[0] = GetBigBox(0) / 2.0 ;
198 bigbox[1] = GetBigBox(1) / 2.0 ;
199 bigbox[2] = GetBigBox(2) / 2.0 ;
201 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
203 // --- Position PHOS mdules in ALICE setup ---
206 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
208 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
210 Float_t angle = GetGeometry()->GetPHOSAngle(i) ;
211 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
213 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
215 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
216 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
217 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
224 //____________________________________________________________________________
225 void AliPHOSvFast::Init(void)
227 // Prints out an information message
232 for(i=0;i<35;i++) printf("*");
233 printf(" FAST PHOS_INIT ");
234 for(i=0;i<35;i++) printf("*");
237 // Here the PHOS initialisation code (if any!)
239 for(i=0;i<80;i++) printf("*");
244 //___________________________________________________________________________
245 Float_t AliPHOSvFast::GetBigBox(Int_t index) const
247 // Get the X, Y or Z dimension of the box describing a PHOS module
264 //___________________________________________________________________________
266 void AliPHOSvFast::MakeBranch(Option_t* opt)
268 // Create new branch in the current reconstructed Root Tree
269 AliDetector::MakeBranch(opt);
270 const char *cd = strstr(opt,"R");
272 if (fFastRecParticles && fLoader->TreeR() && cd) {
273 MakeBranchInTree(fLoader->TreeR(), GetName(), &fFastRecParticles, fBufferSize, 0);
276 //____________________________________________________________________________
278 Double_t AliPHOSvFast::MakeEnergy(Double_t energy)
280 // Smears the energy according to the energy dependent energy resolution.
281 // A gaussian distribution is assumed
283 Double_t sigma = SigmaE(energy) ;
284 return fRan.Gaus(energy, sigma) ;
286 //____________________________________________________________________________
288 TVector3 AliPHOSvFast::MakePosition(Double_t energy, TVector3 pos, Double_t theta, Double_t phi)
290 // Smears the impact position according to the energy dependent position resolution
291 // A gaussian position distribution is assumed
294 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
295 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
296 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
297 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
298 Double_t y = pos.Y() ;
307 //____________________________________________________________________________
308 void AliPHOSvFast::MakeRecParticle(Int_t modid, TVector3 pos, AliPHOSFastRecParticle & rp)
310 // Modify the primary particle properties according
311 // 1. the response function of PHOS
312 // 2. the performance of the EMC+PPSD setup
314 Int_t type = MakeType( rp ) ;
318 // get the detected energy
320 TLorentzVector momentum ;
321 rp.Momentum(momentum) ;
322 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
323 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
324 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
325 + TMath::Power( rp.GetMass(), 2) ) ;
327 // get the angle of incidence
329 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
330 Double_t incidencephi = ( 270 + GetGeometry()->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
332 // get the detected direction
334 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
335 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
337 // Set the modified 4-momentum of the reconstructed particle
339 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
343 //____________________________________________________________________________
344 Int_t AliPHOSvFast::MakeType(AliPHOSFastRecParticle & rp )
346 // Generate a particle type using the performance of the EMC+PPSD setup
348 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
349 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
352 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
355 test = rp.GetPdgCode() ;
357 Fatal("MakeType", "SHOULD NOT BE USED until values of probabilities are properly set ") ;
358 // NB: ALL VALUES SHOULD BE CHECKED !!!!
361 case 22: // it's a photon // NB: ALL VALUES SHOLD BE CHECKED !!!!
364 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
366 rv = AliPHOSFastRecParticle::kNEUTRALEMFAST ;
369 case 2112: // it's a neutron
372 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
374 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
377 case -2112: // it's a anti-neutron
380 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
382 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
385 case 11: // it's a electron
388 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
390 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
393 case -11: // it's a positon
396 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
398 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
401 case -1: // it's a charged
404 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
406 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
415 //___________________________________________________________________________
416 void AliPHOSvFast::ResetPoints()
418 // This overloads the method in AliDetector
420 ResetFastRecParticles() ;
423 //___________________________________________________________________________
424 void AliPHOSvFast::ResetFastRecParticles()
426 // Resets the list of virtual reconstructed particles
428 if (fFastRecParticles)
429 fFastRecParticles->Clear() ;
433 //___________________________________________________________________________
434 void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
436 // Set the size of the Box describing a PHOS module
452 //____________________________________________________________________________
453 Double_t AliPHOSvFast::SigmaE(Double_t energy)
455 // Calculates the energy dependent energy resolution
459 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
460 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
461 + TMath::Power(fResPara3, 2) ) ;
466 //____________________________________________________________________________
467 Double_t AliPHOSvFast::SigmaP(Double_t energy, Double_t incidence)
469 // Calculates the energy dependent position resolution
471 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
472 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
474 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
477 //____________________________________________________________________________
478 void AliPHOSvFast::StepManager(void)
480 // Only verifies if the particle reaches PHOS and stops the tracking
483 gMC->TrackPosition(lv) ;
484 TVector3 pos = lv.Vect() ;
486 gMC->CurrentVolID(modid);
488 Float_t energy = gMC->Etot() ; //Total energy of current track
490 //Calculating mass of current particle
491 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
492 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
493 Float_t mass = partPDG->Mass() ;
496 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
497 TLorentzVector pTrack(pos, energy) ;
499 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
501 AliPHOSFastRecParticle rp(*part) ;
503 // Adds the response of PHOS to the particle
504 MakeRecParticle(modid, pos, rp) ;
506 // add the `track' particle to the FastRecParticles list
512 // stop the track as soon PHOS is reached