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:
23 //_________________________________________________________________________
24 // Implementation of the PHOS manager class for fast simulations
25 // Tracks particles until the reach a grossly designed PHOS module
26 // Modify the particles property (momentum, energy, type) according to
27 // the PHOS response function. The result is called a virtual reconstructed
30 //*-- Author: Yves Schutz (SUBATECH)
32 // --- ROOT system ---
35 #include <TGeometry.h>
37 #include <TParticle.h>
38 #include "TClonesArray.h"
39 #include <TVirtualMC.h>
41 // --- Standard library ---
43 // --- AliRoot header files ---
44 #include "AliPHOSFastRecParticle.h"
45 #include "AliPHOSGeometry.h"
46 #include "AliPHOSLoader.h"
47 #include "AliPHOSvFast.h"
50 ClassImp(AliPHOSvFast)
52 //____________________________________________________________________________
53 AliPHOSvFast::AliPHOSvFast() : AliPHOS()
55 // default ctor : initialize data member
59 fFastRecParticles = 0 ;
73 //____________________________________________________________________________
74 AliPHOSvFast::AliPHOSvFast(const char *name, const char *title):
82 SetBigBox(0, GetGeometry()->GetOuterBoxSize(0) ) ;
83 SetBigBox(1, GetGeometry()->GetOuterBoxSize(3) + GetGeometry()->GetCPVBoxSize(1) ) ;
84 SetBigBox(2, GetGeometry()->GetOuterBoxSize(2) );
87 fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
89 fResPara1 = 0.030 ; // GeV
93 fPosParaA0 = 2.87 ; // mm
94 fPosParaA1 = -0.0975 ;
97 fPosParaB2 = 0.00619 ;
100 //____________________________________________________________________________
101 AliPHOSvFast::~AliPHOSvFast()
105 fFastRecParticles->Delete() ;
106 delete fFastRecParticles ;
107 fFastRecParticles = 0 ;
111 //____________________________________________________________________________
112 void AliPHOSvFast::Copy(TObject & base)const
114 TObject::Copy(base) ;
115 AliPHOS::Copy(base) ;
116 AliPHOSvFast &fast = static_cast<AliPHOSvFast &>(base);
117 fast.fBigBoxX = fBigBoxX ;
118 fast.fBigBoxY = fBigBoxY ;
119 fast.fBigBoxZ = fBigBoxZ ;
120 fast.fNRecParticles = fNRecParticles ;
122 fast.fResPara1 = fResPara1 ;
123 fast.fResPara2 = fResPara2 ;
124 fast.fResPara3 = fResPara3 ;
125 fast.fPosParaA0 = fPosParaA0 ;
126 fast.fPosParaA1 = fPosParaA1 ;
127 fast.fPosParaB0 = fPosParaB0 ;
128 fast.fPosParaB1 = fPosParaB1 ;
129 fast.fFastRecParticles = new TClonesArray(fFastRecParticles->GetClass()->GetName(), 100) ;
131 for (index = 0 ; index < fFastRecParticles->GetEntries(); index++)
132 (fast.fFastRecParticles)->AddAt(fFastRecParticles->At(index), index) ;
135 //____________________________________________________________________________
136 void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp)
138 // Add a virtually reconstructed particle to the list
140 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
144 //____________________________________________________________________________
145 void AliPHOSvFast::BuildGeometry()
147 // Build the PHOS geometry for the ROOT display
151 PHOS FAST in ALICE displayed by root
156 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSvFastAllViews.gif">
158 <H4> Front View </H4>
161 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSvFastFrontView.gif">
166 const Int_t kColorPHOS = kRed ;
168 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
170 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
174 // position PHOS into ALICE
176 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
178 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * GetGeometry()->GetIPtoCrystalSurface() ) ) ;
180 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
182 char * nodename = new char[20] ;
183 char * rotname = new char[20] ;
185 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
186 Float_t angle = pphi * 2 * ( i - GetGeometry()->GetNModules() / 2.0 - 0.5 ) ;
187 sprintf(rotname, "%s%d", "rot", number++) ;
188 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
190 sprintf(nodename,"%s%d", "Module", i) ;
191 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
192 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
193 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
194 bigboxnode->SetLineColor(kColorPHOS) ;
195 fNodes->Add(bigboxnode) ;
201 //____________________________________________________________________________
202 void AliPHOSvFast::CreateGeometry()
204 // Create the geometry for GEANT
206 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
208 if ( phostmp == NULL ) {
210 fprintf(stderr, "PHOS detector not found!\n") ;
215 // Get pointer to the array containing media indeces
216 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
219 bigbox[0] = GetBigBox(0) / 2.0 ;
220 bigbox[1] = GetBigBox(1) / 2.0 ;
221 bigbox[2] = GetBigBox(2) / 2.0 ;
223 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
225 // --- Position PHOS mdules in ALICE setup ---
228 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
230 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
232 Float_t angle = GetGeometry()->GetPHOSAngle(i) ;
233 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
235 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
237 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
238 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
239 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
246 //____________________________________________________________________________
247 void AliPHOSvFast::Init(void)
249 // Prints out an information message
254 for(i=0;i<35;i++) printf("*");
255 printf(" FAST PHOS_INIT ");
256 for(i=0;i<35;i++) printf("*");
259 // Here the PHOS initialisation code (if any!)
261 for(i=0;i<80;i++) printf("*");
266 //___________________________________________________________________________
267 Float_t AliPHOSvFast::GetBigBox(Int_t index) const
269 // Get the X, Y or Z dimension of the box describing a PHOS module
286 //___________________________________________________________________________
288 void AliPHOSvFast::MakeBranch(Option_t* opt)
290 // Create new branch in the current reconstructed Root Tree
291 AliDetector::MakeBranch(opt);
292 const char *cd = strstr(opt,"R");
294 if (fFastRecParticles && fLoader->TreeR() && cd) {
295 MakeBranchInTree(fLoader->TreeR(), GetName(), &fFastRecParticles, fBufferSize, 0);
298 //____________________________________________________________________________
300 Double_t AliPHOSvFast::MakeEnergy(Double_t energy)
302 // Smears the energy according to the energy dependent energy resolution.
303 // A gaussian distribution is assumed
305 Double_t sigma = SigmaE(energy) ;
306 return fRan.Gaus(energy, sigma) ;
308 //____________________________________________________________________________
310 TVector3 AliPHOSvFast::MakePosition(Double_t energy, TVector3 pos, Double_t theta, Double_t phi)
312 // Smears the impact position according to the energy dependent position resolution
313 // A gaussian position distribution is assumed
316 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
317 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
318 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
319 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
320 Double_t y = pos.Y() ;
329 //____________________________________________________________________________
330 void AliPHOSvFast::MakeRecParticle(Int_t modid, TVector3 pos, AliPHOSFastRecParticle & rp)
332 // Modify the primary particle properties according
333 // 1. the response function of PHOS
334 // 2. the performance of the EMC+PPSD setup
336 Int_t type = MakeType( rp ) ;
340 // get the detected energy
342 TLorentzVector momentum ;
343 rp.Momentum(momentum) ;
344 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
345 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
346 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
347 + TMath::Power( rp.GetMass(), 2) ) ;
349 // get the angle of incidence
351 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
352 Double_t incidencephi = ( 270 + GetGeometry()->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
354 // get the detected direction
356 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
357 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
359 // Set the modified 4-momentum of the reconstructed particle
361 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
365 //____________________________________________________________________________
366 Int_t AliPHOSvFast::MakeType(AliPHOSFastRecParticle & rp )
368 // Generate a particle type using the performance of the EMC+PPSD setup
370 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
371 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
374 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
377 test = rp.GetPdgCode() ;
379 Fatal("MakeType", "SHOULD NOT BE USED until values of probabilities are properly set ") ;
380 // NB: ALL VALUES SHOULD BE CHECKED !!!!
383 case 22: // it's a photon // NB: ALL VALUES SHOLD BE CHECKED !!!!
386 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
388 rv = AliPHOSFastRecParticle::kNEUTRALEMFAST ;
391 case 2112: // it's a neutron
394 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
396 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
399 case -2112: // it's a anti-neutron
402 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
404 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
407 case 11: // it's a electron
410 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
412 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
415 case -11: // it's a positon
418 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
420 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
423 case -1: // it's a charged
426 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
428 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
437 //___________________________________________________________________________
438 void AliPHOSvFast::ResetPoints()
440 // This overloads the method in AliDetector
442 ResetFastRecParticles() ;
445 //___________________________________________________________________________
446 void AliPHOSvFast::ResetFastRecParticles()
448 // Resets the list of virtual reconstructed particles
450 if (fFastRecParticles)
451 fFastRecParticles->Clear() ;
455 //___________________________________________________________________________
456 void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
458 // Set the size of the Box describing a PHOS module
474 //____________________________________________________________________________
475 Double_t AliPHOSvFast::SigmaE(Double_t energy)
477 // Calculates the energy dependent energy resolution
481 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
482 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
483 + TMath::Power(fResPara3, 2) ) ;
488 //____________________________________________________________________________
489 Double_t AliPHOSvFast::SigmaP(Double_t energy, Double_t incidence)
491 // Calculates the energy dependent position resolution
493 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
494 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
496 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
499 //____________________________________________________________________________
500 void AliPHOSvFast::StepManager(void)
502 // Only verifies if the particle reaches PHOS and stops the tracking
505 gMC->TrackPosition(lv) ;
506 TVector3 pos = lv.Vect() ;
508 gMC->CurrentVolID(modid);
510 Float_t energy = gMC->Etot() ; //Total energy of current track
512 //Calculating mass of current particle
513 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
514 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
515 Float_t mass = partPDG->Mass() ;
518 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
519 TLorentzVector pTrack(pos, energy) ;
521 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
523 AliPHOSFastRecParticle rp(*part) ;
525 // Adds the response of PHOS to the particle
526 MakeRecParticle(modid, pos, rp) ;
528 // add the `track' particle to the FastRecParticles list
534 // stop the track as soon PHOS is reached