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.29 2005/05/28 14:19:05 schutz
22 * Compilation warnings fixed by T.P.
26 //_________________________________________________________________________
27 // Implementation of the PHOS manager class for fast simulations
28 // Tracks particles until the reach a grossly designed PHOS module
29 // Modify the particles property (momentum, energy, type) according to
30 // the PHOS response function. The result is called a virtual reconstructed
33 //*-- Author: Yves Schutz (SUBATECH)
35 // --- ROOT system ---
38 #include <TGeometry.h>
40 #include <TParticle.h>
41 #include "TClonesArray.h"
42 #include <TVirtualMC.h>
44 // --- Standard library ---
46 // --- AliRoot header files ---
47 #include "AliPHOSFastRecParticle.h"
48 #include "AliPHOSGeometry.h"
49 #include "AliPHOSLoader.h"
50 #include "AliPHOSvFast.h"
53 ClassImp(AliPHOSvFast)
55 AliPHOSvFast::AliPHOSvFast() :
71 // default ctor : initialize data member
74 //____________________________________________________________________________
75 AliPHOSvFast::AliPHOSvFast(const char *name, const char *title):
80 fFastRecParticles(new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100)),
83 fResPara1(0.030), // GeV
86 fPosParaA0(2.87), // mm
94 SetBigBox(0, GetGeometry()->GetOuterBoxSize(0) ) ;
95 SetBigBox(1, GetGeometry()->GetOuterBoxSize(3) + GetGeometry()->GetCPVBoxSize(1) ) ;
96 SetBigBox(2, GetGeometry()->GetOuterBoxSize(2) );
99 //____________________________________________________________________________
100 AliPHOSvFast::AliPHOSvFast(AliPHOSvFast & fast) :
105 fFastRecParticles(0),
122 //____________________________________________________________________________
123 AliPHOSvFast::~AliPHOSvFast()
127 fFastRecParticles->Delete() ;
128 delete fFastRecParticles ;
129 fFastRecParticles = 0 ;
133 //____________________________________________________________________________
134 void AliPHOSvFast::Copy(TObject & base)const
136 TObject::Copy(base) ;
137 AliPHOS::Copy(base) ;
138 AliPHOSvFast &fast = static_cast<AliPHOSvFast &>(base);
139 fast.fBigBoxX = fBigBoxX ;
140 fast.fBigBoxY = fBigBoxY ;
141 fast.fBigBoxZ = fBigBoxZ ;
142 fast.fNRecParticles = fNRecParticles ;
144 fast.fResPara1 = fResPara1 ;
145 fast.fResPara2 = fResPara2 ;
146 fast.fResPara3 = fResPara3 ;
147 fast.fPosParaA0 = fPosParaA0 ;
148 fast.fPosParaA1 = fPosParaA1 ;
149 fast.fPosParaB0 = fPosParaB0 ;
150 fast.fPosParaB1 = fPosParaB1 ;
151 fast.fFastRecParticles = new TClonesArray(fFastRecParticles->GetClass()->GetName(), 100) ;
153 for (index = 0 ; index < fFastRecParticles->GetEntries(); index++)
154 (fast.fFastRecParticles)->AddAt(fFastRecParticles->At(index), index) ;
157 //____________________________________________________________________________
158 void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp)
160 // Add a virtually reconstructed particle to the list
162 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
166 //____________________________________________________________________________
167 void AliPHOSvFast::BuildGeometry()
169 // Build the PHOS geometry for the ROOT display
173 PHOS FAST in ALICE displayed by root
178 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSvFastAllViews.gif">
180 <H4> Front View </H4>
183 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSvFastFrontView.gif">
188 const Int_t kColorPHOS = kRed ;
190 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
192 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
196 // position PHOS into ALICE
198 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
200 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * GetGeometry()->GetIPtoCrystalSurface() ) ) ;
202 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
204 char * nodename = new char[20] ;
205 char * rotname = new char[20] ;
207 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
208 Float_t angle = pphi * 2 * ( i - GetGeometry()->GetNModules() / 2.0 - 0.5 ) ;
209 sprintf(rotname, "%s%d", "rot", number++) ;
210 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
212 sprintf(nodename,"%s%d", "Module", i) ;
213 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
214 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
215 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
216 bigboxnode->SetLineColor(kColorPHOS) ;
217 fNodes->Add(bigboxnode) ;
223 //____________________________________________________________________________
224 void AliPHOSvFast::CreateGeometry()
226 // Create the geometry for GEANT
228 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
230 if ( phostmp == NULL ) {
232 fprintf(stderr, "PHOS detector not found!\n") ;
237 // Get pointer to the array containing media indeces
238 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
241 bigbox[0] = GetBigBox(0) / 2.0 ;
242 bigbox[1] = GetBigBox(1) / 2.0 ;
243 bigbox[2] = GetBigBox(2) / 2.0 ;
245 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
247 // --- Position PHOS mdules in ALICE setup ---
250 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
252 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
254 Float_t angle = GetGeometry()->GetPHOSAngle(i) ;
255 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
257 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
259 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
260 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
261 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
268 //____________________________________________________________________________
269 void AliPHOSvFast::Init(void)
271 // Prints out an information message
276 for(i=0;i<35;i++) printf("*");
277 printf(" FAST PHOS_INIT ");
278 for(i=0;i<35;i++) printf("*");
281 // Here the PHOS initialisation code (if any!)
283 for(i=0;i<80;i++) printf("*");
288 //___________________________________________________________________________
289 Float_t AliPHOSvFast::GetBigBox(Int_t index) const
291 // Get the X, Y or Z dimension of the box describing a PHOS module
308 //___________________________________________________________________________
310 void AliPHOSvFast::MakeBranch(Option_t* opt)
312 // Create new branch in the current reconstructed Root Tree
313 AliDetector::MakeBranch(opt);
314 const char *cd = strstr(opt,"R");
316 if (fFastRecParticles && fLoader->TreeR() && cd) {
317 MakeBranchInTree(fLoader->TreeR(), GetName(), &fFastRecParticles, fBufferSize, 0);
320 //____________________________________________________________________________
322 Double_t AliPHOSvFast::MakeEnergy(Double_t energy)
324 // Smears the energy according to the energy dependent energy resolution.
325 // A gaussian distribution is assumed
327 Double_t sigma = SigmaE(energy) ;
328 return fRan.Gaus(energy, sigma) ;
330 //____________________________________________________________________________
332 TVector3 AliPHOSvFast::MakePosition(Double_t energy, TVector3 pos, Double_t theta, Double_t phi)
334 // Smears the impact position according to the energy dependent position resolution
335 // A gaussian position distribution is assumed
338 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
339 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
340 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
341 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
342 Double_t y = pos.Y() ;
351 //____________________________________________________________________________
352 void AliPHOSvFast::MakeRecParticle(Int_t modid, TVector3 pos, AliPHOSFastRecParticle & rp)
354 // Modify the primary particle properties according
355 // 1. the response function of PHOS
356 // 2. the performance of the EMC+PPSD setup
358 Int_t type = MakeType( rp ) ;
362 // get the detected energy
364 TLorentzVector momentum ;
365 rp.Momentum(momentum) ;
366 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
367 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
368 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
369 + TMath::Power( rp.GetMass(), 2) ) ;
371 // get the angle of incidence
373 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
374 Double_t incidencephi = ( 270 + GetGeometry()->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
376 // get the detected direction
378 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
379 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
381 // Set the modified 4-momentum of the reconstructed particle
383 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
387 //____________________________________________________________________________
388 Int_t AliPHOSvFast::MakeType(AliPHOSFastRecParticle & rp )
390 // Generate a particle type using the performance of the EMC+PPSD setup
392 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
393 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
396 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
399 test = rp.GetPdgCode() ;
401 Fatal("MakeType", "SHOULD NOT BE USED until values of probabilities are properly set ") ;
402 // NB: ALL VALUES SHOULD BE CHECKED !!!!
405 case 22: // it's a photon // NB: ALL VALUES SHOLD BE CHECKED !!!!
408 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
410 rv = AliPHOSFastRecParticle::kNEUTRALEMFAST ;
413 case 2112: // it's a neutron
416 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
418 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
421 case -2112: // it's a anti-neutron
424 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
426 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
429 case 11: // it's a electron
432 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
434 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
437 case -11: // it's a positon
440 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
442 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
445 case -1: // it's a charged
448 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
450 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
459 //___________________________________________________________________________
460 void AliPHOSvFast::ResetPoints()
462 // This overloads the method in AliDetector
464 ResetFastRecParticles() ;
467 //___________________________________________________________________________
468 void AliPHOSvFast::ResetFastRecParticles()
470 // Resets the list of virtual reconstructed particles
472 if (fFastRecParticles)
473 fFastRecParticles->Clear() ;
477 //___________________________________________________________________________
478 void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
480 // Set the size of the Box describing a PHOS module
496 //____________________________________________________________________________
497 Double_t AliPHOSvFast::SigmaE(Double_t energy)
499 // Calculates the energy dependent energy resolution
503 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
504 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
505 + TMath::Power(fResPara3, 2) ) ;
510 //____________________________________________________________________________
511 Double_t AliPHOSvFast::SigmaP(Double_t energy, Double_t incidence)
513 // Calculates the energy dependent position resolution
515 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
516 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
518 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
521 //____________________________________________________________________________
522 void AliPHOSvFast::StepManager(void)
524 // Only verifies if the particle reaches PHOS and stops the tracking
527 gMC->TrackPosition(lv) ;
528 TVector3 pos = lv.Vect() ;
530 gMC->CurrentVolID(modid);
532 Float_t energy = gMC->Etot() ; //Total energy of current track
534 //Calculating mass of current particle
535 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
536 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
537 Float_t mass = partPDG->Mass() ;
540 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
541 TLorentzVector pTrack(pos, energy) ;
543 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
545 AliPHOSFastRecParticle rp(*part) ;
547 // Adds the response of PHOS to the particle
548 MakeRecParticle(modid, pos, rp) ;
550 // add the `track' particle to the FastRecParticles list
556 // stop the track as soon PHOS is reached