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 **************************************************************************/
16 //_________________________________________________________________________
17 // Manager class for PHOS version for fast simulations
18 //*-- Author : Y. Schutz SUBATECH
19 //////////////////////////////////////////////////////////////////////////////
21 // --- ROOT system ---
25 #include "TParticle.h"
27 // --- Standard library ---
32 // --- AliRoot header files ---
34 #include "AliPHOSvFast.h"
38 ClassImp(AliPHOSvFast)
40 //____________________________________________________________________________
41 AliPHOSvFast::AliPHOSvFast()
43 fFastRecParticles = 0 ;
47 //____________________________________________________________________________
48 AliPHOSvFast::AliPHOSvFast(const char *name, const char *title):
51 // gets an instance of the geometry parameters class
53 fGeom = AliPHOSGeometry::GetInstance(title, "") ;
55 if (fGeom->IsInitialized() )
56 cout << "AliPHOSvFast : PHOS geometry intialized for " << fGeom->GetName() << endl ;
58 cout << "AliPHOSvFast : PHOS geometry initialization failed !" << endl ;
60 SetBigBox(0, fGeom->GetOuterBoxSize(0) ) ;
61 SetBigBox(1, fGeom->GetOuterBoxSize(1) + fGeom->GetPPSDBoxSize(1) ) ;
62 SetBigBox(2, fGeom->GetOuterBoxSize(0) );
65 fFastRecParticles = new FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
67 fResPara1 = 0.030 ; // GeV
71 fPosParaA0 = 2.87 ; // mm
72 fPosParaA1 = -0.0975 ;
75 fPosParaB2 = 0.00619 ;
78 //____________________________________________________________________________
79 AliPHOSvFast::~AliPHOSvFast()
82 fFastRecParticles->Delete() ;
83 delete fFastRecParticles ;
84 fFastRecParticles = 0 ;
88 //____________________________________________________________________________
89 void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp)
91 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
95 //____________________________________________________________________________
96 void AliPHOSvFast::BuildGeometry()
99 // Build the PHOS geometry for the ROOT display
101 const Int_t kColorPHOS = kRed ;
103 Double_t const kRADDEG = 180.0 / kPI ;
105 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
109 // position PHOS into ALICE
111 Float_t r = fGeom->GetIPtoOuterCoverDistance() + GetBigBox(1) / 2.0 ;
113 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * fGeom->GetIPtoOuterCoverDistance() ) ) ;
115 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
117 char * nodename = new char[20] ;
118 char * rotname = new char[20] ;
120 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
121 Float_t angle = pphi * 2 * ( i - fGeom->GetNModules() / 2.0 - 0.5 ) ;
122 sprintf(rotname, "%s%d", "rot", number++) ;
123 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
125 sprintf(nodename,"%s%d", "Module", i) ;
126 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
127 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
128 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
129 bigboxnode->SetLineColor(kColorPHOS) ;
130 fNodes->Add(bigboxnode) ;
136 //____________________________________________________________________________
137 void AliPHOSvFast::CreateGeometry()
140 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
142 if ( phostmp == NULL ) {
144 fprintf(stderr, "PHOS detector not found!\n") ;
149 // Get pointer to the array containing media indeces
150 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
153 bigbox[0] = GetBigBox(0) / 2.0 ;
154 bigbox[1] = GetBigBox(1) / 2.0 ;
155 bigbox[2] = GetBigBox(2) / 2.0 ;
157 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
159 // --- Position PHOS mdules in ALICE setup ---
162 Double_t const kRADDEG = 180.0 / kPI ;
164 for( Int_t i = 1; i <= fGeom->GetNModules(); i++ ) {
166 Float_t angle = fGeom->GetPHOSAngle(i) ;
167 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
169 Float_t r = fGeom->GetIPtoOuterCoverDistance() + GetBigBox(1) / 2.0 ;
171 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
172 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
173 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
180 //____________________________________________________________________________
181 void AliPHOSvFast::Init(void)
187 for(i=0;i<35;i++) printf("*");
188 printf(" FAST PHOS_INIT ");
189 for(i=0;i<35;i++) printf("*");
192 // Here the PHOS initialisation code (if any!)
194 for(i=0;i<80;i++) printf("*");
199 //___________________________________________________________________________
200 Float_t AliPHOSvFast::GetBigBox(Int_t index)
218 //___________________________________________________________________________
219 void AliPHOSvFast::MakeBranch(Option_t* opt)
222 // Create a new branch in the current Root Tree
224 AliDetector::MakeBranch(opt) ;
227 sprintf(branchname,"%s",GetName());
228 char *cd = strstr(opt,"R");
230 if (fFastRecParticles && gAlice->TreeR() && cd) {
231 gAlice->TreeR()->Branch(branchname, &fFastRecParticles, fBufferSize);
235 //____________________________________________________________________________
236 Double_t AliPHOSvFast::MakeEnergy(const Double_t energy)
238 Double_t sigma = SigmaE(energy) ;
239 return fRan.Gaus(energy, sigma) ;
242 //____________________________________________________________________________
243 TVector3 AliPHOSvFast::MakePosition(const Double_t energy, const TVector3 pos, const Double_t theta, const Double_t phi)
246 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
247 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
248 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
249 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
250 Double_t y = pos.Y() ;
259 //____________________________________________________________________________
260 void AliPHOSvFast::MakeRecParticle(const Int_t modid, const TVector3 pos, AliPHOSFastRecParticle & rp)
262 // get the detected type of particle
264 Int_t type = MakeType( rp ) ;
268 // get the detected energy
270 TLorentzVector momentum ;
271 rp.Momentum(momentum) ;
272 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
273 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
274 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
275 + TMath::Power( rp.GetMass(), 2) ) ;
277 // get the angle of incidence
279 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
280 Double_t incidencephi = ( 270 + fGeom->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
282 // get the detected direction
284 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
285 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
287 // Set the modified 4-momentum of the reconstructed particle
289 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
293 //____________________________________________________________________________
294 Int_t AliPHOSvFast::MakeType(AliPHOSFastRecParticle & rp )
296 Int_t rv = kUNDEFINED ;
297 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
300 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
303 test = rp.GetPdgCode() ;
307 case 22: // it's a photon
309 if ( ran <= 0.5 ) // 50 %
316 rv = kNEUTRALHADRON ;
320 case 2112: // it's a neutron
323 rv = kNEUTRALHADRON ;
328 case -2112: // it's a anti-neutron
331 rv = kNEUTRALHADRON ;
336 case 11: // it's a electron
341 rv = kCHARGEDHADRON ;
344 case -11: // it's a positon
349 rv = kCHARGEDHADRON ;
352 case -1: // it's a charged
355 rv = kCHARGEDHADRON ;
366 //___________________________________________________________________________
367 void AliPHOSvFast::ResetPoints()
369 ResetFastRecParticles() ;
372 //___________________________________________________________________________
373 void AliPHOSvFast::ResetFastRecParticles()
375 if (fFastRecParticles)
376 fFastRecParticles->Clear() ;
380 //___________________________________________________________________________
381 void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
398 //____________________________________________________________________________
399 Double_t AliPHOSvFast::SigmaE(Double_t energy)
403 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
404 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
405 + TMath::Power(fResPara3, 2) ) ;
410 //____________________________________________________________________________
411 Double_t AliPHOSvFast::SigmaP(Double_t energy, Int_t incidence)
414 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
415 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
417 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
420 //____________________________________________________________________________
421 void AliPHOSvFast::StepManager(void)
424 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
426 gMC->TrackPosition(lv) ;
427 TVector3 pos = lv.Vect() ;
429 gMC->CurrentVolID(modid);
431 // Makes a reconstructed particle from the primary particle
433 TClonesArray * particlelist = gAlice->Particles() ;
434 TParticle * part = (TParticle *)particlelist->At(primary) ;
436 AliPHOSFastRecParticle rp(*part) ;
438 // Adds the response of PHOS to the particle
440 MakeRecParticle(modid, pos, rp) ;
442 // add the primary particle to the FastRecParticles list
446 // stop the track as soon PHOS is reached