]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSvFast.cxx
AliMiniHeader moved to separate file
[u/mrichter/AliRoot.git] / PHOS / AliPHOSvFast.cxx
CommitLineData
88cb7938 1 /**************************************************************************
3decf5cb 2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
b2a60966 16/* $Id$ */
17
3decf5cb 18//_________________________________________________________________________
b2a60966 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
23// particle.
24//
25//*-- Author: Yves Schutz (SUBATECH)
3decf5cb 26
27// --- ROOT system ---
3a4295ee 28
88cb7938 29#include <TBRIK.h>
88cb7938 30#include <TGeometry.h>
31#include <TNode.h>
32#include <TParticle.h>
e957fea8 33#include "TClonesArray.h"
88cb7938 34#include <TVirtualMC.h>
3decf5cb 35
36// --- Standard library ---
37
3decf5cb 38// --- AliRoot header files ---
3a4295ee 39#include "AliPHOSFastRecParticle.h"
88cb7938 40#include "AliPHOSGeometry.h"
41#include "AliPHOSLoader.h"
3decf5cb 42#include "AliPHOSvFast.h"
3decf5cb 43#include "AliRun.h"
3decf5cb 44
45ClassImp(AliPHOSvFast)
46
47//____________________________________________________________________________
3a4295ee 48AliPHOSvFast::AliPHOSvFast() : AliPHOS()
3decf5cb 49{
3a4295ee 50 // default ctor : initialize data member
51 fBigBoxX = 0. ;
52 fBigBoxY = 0. ;
53 fBigBoxZ = 0. ;
54 fFastRecParticles = 0 ;
55 fNRecParticles = 0 ;
56 fRan = 0 ;
57 fResPara1 = 0. ;
58 fResPara2 = 0. ;
59 fResPara3 = 0. ;
60 fPosParaA0 = 0. ;
61 fPosParaA1 = 0. ;
62 fPosParaB0 = 0. ;
63 fPosParaB1 = 0. ;
64 fPosParaB2 = 0. ;
b2a60966 65
3decf5cb 66}
67
68//____________________________________________________________________________
69AliPHOSvFast::AliPHOSvFast(const char *name, const char *title):
70 AliPHOS(name,title)
71{
b2a60966 72 // ctor
73
3decf5cb 74
88cb7938 75 // create the Loader
7a9d98f9 76
77 SetBigBox(0, GetGeometry()->GetOuterBoxSize(0) ) ;
78 SetBigBox(1, GetGeometry()->GetOuterBoxSize(3) + GetGeometry()->GetCPVBoxSize(1) ) ;
79 SetBigBox(2, GetGeometry()->GetOuterBoxSize(2) );
80
81 fNRecParticles = 0 ;
82 fFastRecParticles = new AliPHOSFastRecParticle::FastRecParticlesList("AliPHOSFastRecParticle", 100) ;
83
84 fResPara1 = 0.030 ; // GeV
85 fResPara2 = 0.00003 ;
86 fResPara3 = 0.00001 ;
87
88 fPosParaA0 = 2.87 ; // mm
89 fPosParaA1 = -0.0975 ;
90 fPosParaB0 = 0.257 ;
91 fPosParaB1 = 0.137 ;
92 fPosParaB2 = 0.00619 ;
3decf5cb 93}
94
95//____________________________________________________________________________
96AliPHOSvFast::~AliPHOSvFast()
97{
b2a60966 98 // dtor
3decf5cb 99
a73f33f0 100 fFastRecParticles->Delete() ;
101 delete fFastRecParticles ;
102 fFastRecParticles = 0 ;
3decf5cb 103
104}
105
106//____________________________________________________________________________
a73f33f0 107void AliPHOSvFast::AddRecParticle(const AliPHOSFastRecParticle & rp)
108{
b2a60966 109 // Add a virtually reconstructed particle to the list
110
f96d3dc7 111 new( (*fFastRecParticles)[fNRecParticles] ) AliPHOSFastRecParticle(rp) ;
112 fNRecParticles++ ;
3decf5cb 113}
114
115//____________________________________________________________________________
116void AliPHOSvFast::BuildGeometry()
117{
3decf5cb 118 // Build the PHOS geometry for the ROOT display
b2a60966 119 //BEGIN_HTML
120 /*
121 <H2>
122 PHOS FAST in ALICE displayed by root
123 </H2>
124 <H4> All Views </H4>
125 <P>
126 <CENTER>
127 <IMG Align=BOTTOM ALT="Fast All Views" SRC="../images/AliPHOSvFastAllViews.gif">
128 </CENTER></P>
129 <H4> Front View </H4>
130 <P>
131 <CENTER>
132 <IMG Align=BOTTOM ALT="Fast Front View" SRC="../images/AliPHOSvFastFrontView.gif">
133 </CENTER></P>
134 */
135 //END_HTML
136
3decf5cb 137 const Int_t kColorPHOS = kRed ;
138
a8c47ab6 139 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
3decf5cb 140
141 new TBRIK( "BigBox", "PHOS box", "void", GetBigBox(0)/2,
142 GetBigBox(1)/2,
143 GetBigBox(2)/2 );
144
145 // position PHOS into ALICE
146
fa7cce36 147 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
3decf5cb 148 Int_t number = 988 ;
fa7cce36 149 Float_t pphi = TMath::ATan( GetBigBox(0) / ( 2.0 * GetGeometry()->GetIPtoCrystalSurface() ) ) ;
3decf5cb 150 pphi *= kRADDEG ;
151 TNode * top = gAlice->GetGeometry()->GetNode("alice") ;
152
153 char * nodename = new char[20] ;
154 char * rotname = new char[20] ;
155
fa7cce36 156 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
157 Float_t angle = pphi * 2 * ( i - GetGeometry()->GetNModules() / 2.0 - 0.5 ) ;
3decf5cb 158 sprintf(rotname, "%s%d", "rot", number++) ;
159 new TRotMatrix(rotname, rotname, 90, angle, 90, 90 + angle, 0, 0);
160 top->cd();
161 sprintf(nodename,"%s%d", "Module", i) ;
162 Float_t x = r * TMath::Sin( angle / kRADDEG ) ;
163 Float_t y = -r * TMath::Cos( angle / kRADDEG ) ;
164 TNode * bigboxnode = new TNode(nodename, nodename, "BigBox", x, y, 0, rotname ) ;
165 bigboxnode->SetLineColor(kColorPHOS) ;
166 fNodes->Add(bigboxnode) ;
167 }
168 delete[] nodename ;
169 delete[] rotname ;
170}
171
172//____________________________________________________________________________
173void AliPHOSvFast::CreateGeometry()
174{
b2a60966 175 // Create the geometry for GEANT
176
3decf5cb 177 AliPHOSvFast *phostmp = (AliPHOSvFast*)gAlice->GetModule("PHOS") ;
b2a60966 178
3decf5cb 179 if ( phostmp == NULL ) {
180
181 fprintf(stderr, "PHOS detector not found!\n") ;
182 return ;
183
184 }
185
186 // Get pointer to the array containing media indeces
187 Int_t *idtmed = fIdtmed->GetArray() - 699 ;
188
189 Float_t bigbox[3] ;
190 bigbox[0] = GetBigBox(0) / 2.0 ;
191 bigbox[1] = GetBigBox(1) / 2.0 ;
192 bigbox[2] = GetBigBox(2) / 2.0 ;
193
194 gMC->Gsvolu("PHOS", "BOX ", idtmed[798], bigbox, 3) ;
195
196 // --- Position PHOS mdules in ALICE setup ---
197
198 Int_t idrotm[99] ;
a8c47ab6 199 Double_t const kRADDEG = 180.0 / TMath::Pi() ;
3decf5cb 200
fa7cce36 201 for( Int_t i = 1; i <= GetGeometry()->GetNModules(); i++ ) {
3decf5cb 202
fa7cce36 203 Float_t angle = GetGeometry()->GetPHOSAngle(i) ;
3decf5cb 204 AliMatrix(idrotm[i-1], 90.0, angle, 90.0, 90.0+angle, 0.0, 0.0) ;
205
fa7cce36 206 Float_t r = GetGeometry()->GetIPtoCrystalSurface() + GetBigBox(1) / 2.0 ;
3decf5cb 207
208 Float_t xP1 = r * TMath::Sin( angle / kRADDEG ) ;
209 Float_t yP1 = -r * TMath::Cos( angle / kRADDEG ) ;
3decf5cb 210 gMC->Gspos("PHOS", i, "ALIC", xP1, yP1, 0.0, idrotm[i-1], "ONLY") ;
211
212 } // for GetNModules
213
214}
215
216
217//____________________________________________________________________________
218void AliPHOSvFast::Init(void)
219{
b2a60966 220 // Prints out an information message
221
3decf5cb 222 Int_t i;
223
224 printf("\n");
225 for(i=0;i<35;i++) printf("*");
226 printf(" FAST PHOS_INIT ");
227 for(i=0;i<35;i++) printf("*");
228 printf("\n");
229
230 // Here the PHOS initialisation code (if any!)
231
232 for(i=0;i<80;i++) printf("*");
233 printf("\n");
234
235}
236
237//___________________________________________________________________________
3a4295ee 238Float_t AliPHOSvFast::GetBigBox(Int_t index) const
3decf5cb 239{
b2a60966 240 // Get the X, Y or Z dimension of the box describing a PHOS module
241
3decf5cb 242 Float_t rv = 0 ;
243
244 switch (index) {
245 case 0:
246 rv = fBigBoxX ;
247 break ;
248 case 1:
249 rv = fBigBoxY ;
250 break ;
251 case 2:
252 rv = fBigBoxZ ;
253 break ;
254 }
255 return rv ;
256}
3decf5cb 257//___________________________________________________________________________
88cb7938 258
259void AliPHOSvFast::MakeBranch(Option_t* opt)
3decf5cb 260{
b2a60966 261 // Create new branch in the current reconstructed Root Tree
88cb7938 262 AliDetector::MakeBranch(opt);
3a4295ee 263 const char *cd = strstr(opt,"R");
3decf5cb 264
88cb7938 265 if (fFastRecParticles && fLoader->TreeR() && cd) {
266 MakeBranchInTree(fLoader->TreeR(), GetName(), &fFastRecParticles, fBufferSize, 0);
3decf5cb 267 }
268}
a73f33f0 269//____________________________________________________________________________
88cb7938 270
a73f33f0 271Double_t AliPHOSvFast::MakeEnergy(const Double_t energy)
272{
b2a60966 273 // Smears the energy according to the energy dependent energy resolution.
274 // A gaussian distribution is assumed
275
b1aa729d 276 Double_t sigma = SigmaE(energy) ;
277 return fRan.Gaus(energy, sigma) ;
a73f33f0 278}
a73f33f0 279//____________________________________________________________________________
88cb7938 280
b1aa729d 281TVector3 AliPHOSvFast::MakePosition(const Double_t energy, const TVector3 pos, const Double_t theta, const Double_t phi)
a73f33f0 282{
b2a60966 283 // Smears the impact position according to the energy dependent position resolution
284 // A gaussian position distribution is assumed
285
b1aa729d 286 TVector3 newpos ;
287 Double_t sigma = SigmaP( energy, theta*180./TMath::Pi() ) ;
288 Double_t x = fRan.Gaus( pos.X(), sigma ) ;
289 sigma = SigmaP( energy, phi*180./TMath::Pi() ) ;
290 Double_t z = fRan.Gaus( pos.Z(), sigma ) ;
291 Double_t y = pos.Y() ;
292
293 newpos.SetX(x) ;
294 newpos.SetY(y) ;
295 newpos.SetZ(z) ;
296
297 return newpos ;
298}
a73f33f0 299
b1aa729d 300//____________________________________________________________________________
301void AliPHOSvFast::MakeRecParticle(const Int_t modid, const TVector3 pos, AliPHOSFastRecParticle & rp)
302{
b2a60966 303 // Modify the primary particle properties according
304 // 1. the response function of PHOS
305 // 2. the performance of the EMC+PPSD setup
306
b1aa729d 307 Int_t type = MakeType( rp ) ;
a73f33f0 308 rp.SetType(type) ;
309
310
311 // get the detected energy
312
313 TLorentzVector momentum ;
314 rp.Momentum(momentum) ;
315 Double_t kineticenergy = TMath::Sqrt( TMath::Power(momentum.E(), 2) - TMath::Power(rp.GetMass(), 2) ) ;
316 Double_t modifiedkineticenergy = MakeEnergy(kineticenergy ) ;
b1aa729d 317 Double_t modifiedenergy = TMath::Sqrt( TMath::Power(modifiedkineticenergy, 2)
318 + TMath::Power( rp.GetMass(), 2) ) ;
319
320 // get the angle of incidence
321
322 Double_t incidencetheta = 90. * TMath::Pi() /180 - rp.Theta() ;
fa7cce36 323 Double_t incidencephi = ( 270 + GetGeometry()->GetPHOSAngle(modid) ) * TMath::Pi() / 180. - rp.Phi() ;
b1aa729d 324
325 // get the detected direction
326
327 TVector3 modifiedposition = MakePosition(kineticenergy, pos, incidencetheta, incidencephi) ;
328 modifiedposition *= modifiedkineticenergy / modifiedposition.Mag() ;
329
330 // Set the modified 4-momentum of the reconstructed particle
331
332 rp.SetMomentum(modifiedposition.X(), modifiedposition.Y(), modifiedposition.Z(), modifiedenergy) ;
333
a73f33f0 334 }
335
336//____________________________________________________________________________
b1aa729d 337Int_t AliPHOSvFast::MakeType(AliPHOSFastRecParticle & rp )
a73f33f0 338{
b2a60966 339 // Generate a particle type using the performance of the EMC+PPSD setup
340
9ec91567 341 Int_t rv = AliPHOSFastRecParticle::kUNDEFINED ;
b1aa729d 342 Int_t charge = (Int_t)rp.GetPDG()->Charge() ;
343 Int_t test ;
344 Float_t ran ;
f96d3dc7 345 if ( charge != 0 && ( TMath::Abs(rp.GetPdgCode()) != 11 ) )
b1aa729d 346 test = - 1 ;
347 else
348 test = rp.GetPdgCode() ;
349
88cb7938 350 Info("MakeType", "SHOULD NOT BE USED until values of probabilities are properly set ") ;
351 assert(1==0) ; // NB: ALL VALUES SHOULD BE CHECKED !!!!
b1aa729d 352 switch (test) {
353
3a4295ee 354 case 22: // it's a photon // NB: ALL VALUES SHOLD BE CHECKED !!!!
b1aa729d 355 ran = fRan.Rndm() ;
3a4295ee 356 if( ran <= 0.9498 )
357 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
358 else
359 rv = AliPHOSFastRecParticle::kNEUTRALEMFAST ;
b1aa729d 360 break ;
361
362 case 2112: // it's a neutron
363 ran = fRan.Rndm() ;
364 if ( ran <= 0.9998 )
3a4295ee 365 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
b1aa729d 366 else
3a4295ee 367 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
b1aa729d 368 break ;
3a4295ee 369
b1aa729d 370 case -2112: // it's a anti-neutron
371 ran = fRan.Rndm() ;
372 if ( ran <= 0.9984 )
3a4295ee 373 rv = AliPHOSFastRecParticle::kNEUTRALHASLOW ;
b1aa729d 374 else
3a4295ee 375 rv = AliPHOSFastRecParticle::kNEUTRALEMSLOW ;
b1aa729d 376 break ;
377
378 case 11: // it's a electron
379 ran = fRan.Rndm() ;
380 if ( ran <= 0.9996 )
3a4295ee 381 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
b1aa729d 382 else
3a4295ee 383 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
b1aa729d 384 break;
385
f96d3dc7 386 case -11: // it's a positon
b1aa729d 387 ran = fRan.Rndm() ;
388 if ( ran <= 0.9996 )
3a4295ee 389 rv = AliPHOSFastRecParticle::kCHARGEDEMFAST ;
b1aa729d 390 else
3a4295ee 391 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
b1aa729d 392 break;
393
394 case -1: // it's a charged
395 ran = fRan.Rndm() ;
396 if ( ran <= 0.9996 )
3a4295ee 397 rv = AliPHOSFastRecParticle::kCHARGEDHAFAST ;
b1aa729d 398 else
3a4295ee 399 rv = AliPHOSFastRecParticle::kNEUTRALHAFAST ;
b1aa729d 400
401 break ;
402 }
403
404
a73f33f0 405 return rv ;
406}
407
f96d3dc7 408//___________________________________________________________________________
409void AliPHOSvFast::ResetPoints()
410{
b2a60966 411 // This overloads the method in AliDetector
412
f96d3dc7 413 ResetFastRecParticles() ;
414}
415
416//___________________________________________________________________________
417void AliPHOSvFast::ResetFastRecParticles()
418{
b2a60966 419 // Resets the list of virtual reconstructed particles
420
f96d3dc7 421 if (fFastRecParticles)
422 fFastRecParticles->Clear() ;
423 fNRecParticles = 0 ;
424}
425
3decf5cb 426//___________________________________________________________________________
427void AliPHOSvFast::SetBigBox(Int_t index, Float_t value)
428{
b2a60966 429 // Set the size of the Box describing a PHOS module
430
3decf5cb 431 switch (index) {
432 case 0:
433 fBigBoxX = value ;
434 break ;
435 case 1:
436 fBigBoxY = value ;
437 break ;
438 case 2:
439 fBigBoxZ = value ;
440 break ;
441 }
442
443}
444
a73f33f0 445//____________________________________________________________________________
446Double_t AliPHOSvFast::SigmaE(Double_t energy)
447{
b2a60966 448 // Calculates the energy dependent energy resolution
449
a73f33f0 450 Double_t rv = -1 ;
451
452 rv = TMath::Sqrt( TMath::Power(fResPara1/energy, 2)
453 + TMath::Power(fResPara2/TMath::Sqrt(energy), 2)
454 + TMath::Power(fResPara3, 2) ) ;
455
456 return rv * energy ;
457}
458
b1aa729d 459//____________________________________________________________________________
7a9d98f9 460Double_t AliPHOSvFast::SigmaP(Double_t energy, Double_t incidence)
b1aa729d 461{
b2a60966 462 // Calculates the energy dependent position resolution
463
b1aa729d 464 Double_t paraA = fPosParaA0 + fPosParaA1 * incidence ;
465 Double_t paraB = fPosParaB0 + fPosParaB1 * incidence + fPosParaB2 * incidence * incidence ;
466
467 return ( paraA / TMath::Sqrt(energy) + paraB ) * 0.1 ; // in cm
468}
469
3decf5cb 470//____________________________________________________________________________
471void AliPHOSvFast::StepManager(void)
472{
b2a60966 473 // Only verifies if the particle reaches PHOS and stops the tracking
3a4295ee 474
a73f33f0 475 TLorentzVector lv ;
476 gMC->TrackPosition(lv) ;
b1aa729d 477 TVector3 pos = lv.Vect() ;
478 Int_t modid ;
479 gMC->CurrentVolID(modid);
a73f33f0 480
3a4295ee 481 Float_t energy = gMC->Etot() ; //Total energy of current track
3decf5cb 482
3a4295ee 483 //Calculating mass of current particle
484 TDatabasePDG * pdg = TDatabasePDG::Instance() ;
485 TParticlePDG * partPDG = pdg->GetParticle(gMC->TrackPid()) ;
486 Float_t mass = partPDG->Mass() ;
a73f33f0 487
3a4295ee 488 if(energy > mass){
489 pos.SetMag(TMath::Sqrt(energy*energy-mass*mass)) ;
490 TLorentzVector pTrack(pos, energy) ;
a73f33f0 491
3a4295ee 492 TParticle * part = new TParticle(gMC->TrackPid(), 0,-1,-1,-1,-1, pTrack, lv) ;
493
494 AliPHOSFastRecParticle rp(*part) ;
b1aa729d 495
3a4295ee 496 // Adds the response of PHOS to the particle
497 MakeRecParticle(modid, pos, rp) ;
498
499 // add the `track' particle to the FastRecParticles list
b1aa729d 500
3a4295ee 501 AddRecParticle(rp) ;
a73f33f0 502
3a4295ee 503 part->Delete() ;
504 }
a73f33f0 505 // stop the track as soon PHOS is reached
b1aa729d 506
3decf5cb 507 gMC->StopTrack() ;
508
509}
510