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