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