]>
Commit | Line | Data |
---|---|---|
4c039060 | 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 | /* | |
17 | $Log$ | |
899fde02 | 18 | Revision 1.26 2001/05/30 12:18:13 morsch |
19 | Fastidious printf commented. | |
20 | ||
09a536f9 | 21 | Revision 1.25 2001/05/23 11:59:46 morsch |
22 | Use RemoveAt method instead of delete to remove objects from TClonesArray. | |
23 | ||
5f3dc1c9 | 24 | Revision 1.24 2001/05/21 08:39:13 morsch |
25 | Use fStepBack = 1 only in debug mode. | |
26 | ||
19237f5f | 27 | Revision 1.23 2001/05/20 10:10:39 morsch |
28 | - Debug output at the beginning of new event and end of run. | |
29 | - Filter out boundary loops. | |
30 | ||
a74d2699 | 31 | Revision 1.22 2001/05/11 13:22:40 morsch |
32 | If run with debug option (from gAlice) geantinos are sent back and volume sequence forward/backward is compared. | |
33 | Can be very verbous in some cases. | |
34 | ||
7eb618fa | 35 | Revision 1.21 2000/12/15 10:33:59 morsch |
36 | Invert coordinates to make meaningful zylindrical plots. | |
37 | ||
10bd7535 | 38 | Revision 1.20 2000/11/30 07:12:48 alibrary |
39 | Introducing new Rndm and QA classes | |
40 | ||
65fb704d | 41 | Revision 1.19 2000/10/26 14:13:05 morsch |
42 | - Change from coordinates theta, phi to general coordinates Coor1 and Coor2. | |
43 | - Lego generator instance can be passed in constructor. | |
44 | ||
0b27b8c7 | 45 | Revision 1.18 2000/10/02 21:28:14 fca |
46 | Removal of useless dependecies via forward declarations | |
47 | ||
94de3818 | 48 | Revision 1.17 2000/07/12 08:56:25 fca |
49 | Coding convention correction and warning removal | |
50 | ||
8918e700 | 51 | Revision 1.16 2000/05/26 08:35:03 fca |
52 | Move the check on z after z has been retrieved | |
53 | ||
119a6af6 | 54 | Revision 1.15 2000/05/16 13:10:40 fca |
55 | New method IsNewTrack and fix for a problem in Father-Daughter relations | |
56 | ||
a01a8b12 | 57 | Revision 1.14 2000/04/27 10:38:21 fca |
58 | Correct termination of Lego Run and introduce Lego getter in AliRun | |
59 | ||
838edcaf | 60 | Revision 1.13 2000/04/26 10:17:31 fca |
61 | Changes in Lego for G4 compatibility | |
62 | ||
dffd31ef | 63 | Revision 1.12 2000/04/07 11:12:33 fca |
64 | G4 compatibility changes | |
65 | ||
875c717b | 66 | Revision 1.11 2000/03/22 13:42:26 fca |
67 | SetGenerator does not replace an existing generator, ResetGenerator does | |
68 | ||
ee1dd322 | 69 | Revision 1.10 2000/02/23 16:25:22 fca |
70 | AliVMC and AliGeant3 classes introduced | |
71 | ReadEuclid moved from AliRun to AliModule | |
72 | ||
b13db077 | 73 | Revision 1.9 1999/12/03 10:54:01 fca |
74 | Fix lego summary | |
75 | ||
00719c1b | 76 | Revision 1.8 1999/10/01 09:54:33 fca |
77 | Correct logics for Lego StepManager | |
78 | ||
f059c84a | 79 | Revision 1.7 1999/09/29 09:24:29 fca |
80 | Introduction of the Copyright and cvs Log | |
81 | ||
4c039060 | 82 | */ |
83 | ||
fe4da5cc | 84 | ////////////////////////////////////////////////////////////// |
85 | ////////////////////////////////////////////////////////////// | |
86 | // | |
87 | // Utility class to evaluate the material budget from | |
88 | // a given radius to the surface of an arbitrary cylinder | |
89 | // along radial directions from the centre: | |
90 | // | |
91 | // - radiation length | |
92 | // - Interaction length | |
93 | // - g/cm2 | |
94 | // | |
95 | // Geantinos are shot in the bins in the fNtheta bins in theta | |
96 | // and fNphi bins in phi with specified rectangular limits. | |
97 | // The statistics are accumulated per | |
98 | // fRadMin < r < fRadMax and <0 < z < fZMax | |
99 | // | |
100 | // To activate this option, you can do: | |
101 | // Root > gAlice.RunLego(); | |
102 | // or Root > .x menu.C then select menu item "RunLego" | |
103 | // Note that when calling gAlice->RunLego, an optional list | |
104 | // of arguments may be specified. | |
105 | // | |
106 | //Begin_Html | |
107 | /* | |
1439f98e | 108 | <img src="picts/alilego.gif"> |
fe4da5cc | 109 | */ |
110 | //End_Html | |
111 | // | |
112 | ////////////////////////////////////////////////////////////// | |
113 | ||
114 | #include "TMath.h" | |
94de3818 | 115 | |
1578254f | 116 | #include "AliLego.h" |
a74d2699 | 117 | |
7eb618fa | 118 | #include "AliDebugVolume.h" |
119 | #include "AliRun.h" | |
8918e700 | 120 | #include "AliLegoGenerator.h" |
fe4da5cc | 121 | #include "AliConst.h" |
875c717b | 122 | #include "AliMC.h" |
94de3818 | 123 | #include "TH2.h" |
a74d2699 | 124 | #include "../TGeant3/TGeant3.h" |
7eb618fa | 125 | #include "TString.h" |
126 | #include "TClonesArray.h" | |
127 | ||
fe4da5cc | 128 | ClassImp(AliLego) |
129 | ||
130 | ||
131 | //___________________________________________ | |
132 | AliLego::AliLego() | |
133 | { | |
8918e700 | 134 | // |
135 | // Default constructor | |
136 | // | |
137 | fHistRadl = 0; | |
138 | fHistAbso = 0; | |
139 | fHistGcm2 = 0; | |
140 | fHistReta = 0; | |
fe4da5cc | 141 | } |
142 | ||
143 | //___________________________________________ | |
0b27b8c7 | 144 | AliLego::AliLego(const char *title, Int_t ntheta, Float_t thetamin, |
145 | Float_t thetamax, Int_t nphi, Float_t phimin, Float_t phimax, | |
b13db077 | 146 | Float_t rmin, Float_t rmax, Float_t zmax) |
147 | : TNamed("Lego Generator",title) | |
fe4da5cc | 148 | { |
8918e700 | 149 | // |
150 | // specify the angular limits and the size of the rectangular box | |
151 | // | |
0b27b8c7 | 152 | fGener = new AliLegoGenerator(ntheta, thetamin, thetamax, |
b13db077 | 153 | nphi, phimin, phimax, rmin, rmax, zmax); |
154 | ||
b13db077 | 155 | |
0b27b8c7 | 156 | |
b13db077 | 157 | fHistRadl = new TH2F("hradl","Radiation length map", |
0b27b8c7 | 158 | ntheta,thetamin,thetamax,nphi,phimin,phimax); |
b13db077 | 159 | fHistAbso = new TH2F("habso","Interaction length map", |
0b27b8c7 | 160 | ntheta,thetamin,thetamax,nphi,phimin,phimax); |
b13db077 | 161 | fHistGcm2 = new TH2F("hgcm2","g/cm2 length map", |
0b27b8c7 | 162 | ntheta,thetamin,thetamax,nphi,phimin,phimax); |
7eb618fa | 163 | // |
19237f5f | 164 | fStepBack = 0; |
165 | fStepsBackward = 0; | |
166 | fStepsForward = 0; | |
167 | fStepBack = 0; | |
7eb618fa | 168 | fVolumesFwd = new TClonesArray("AliDebugVolume",1000); |
169 | fVolumesBwd = new TClonesArray("AliDebugVolume",1000); | |
19237f5f | 170 | fDebug = gAlice->GetDebug(); |
171 | fErrorCondition = 0; | |
0b27b8c7 | 172 | } |
173 | ||
174 | AliLego::AliLego(const char *title, AliLegoGenerator* generator) | |
175 | : TNamed("Lego Generator",title) | |
176 | { | |
177 | // | |
178 | // specify the angular limits and the size of the rectangular box | |
179 | // | |
180 | fGener = generator; | |
181 | Float_t c1min, c1max, c2min, c2max; | |
182 | Int_t n1 = fGener->NCoor1(); | |
183 | Int_t n2 = fGener->NCoor2(); | |
184 | ||
185 | fGener->Coor1Range(c1min, c1max); | |
186 | fGener->Coor2Range(c2min, c2max); | |
b13db077 | 187 | |
0b27b8c7 | 188 | fHistRadl = new TH2F("hradl","Radiation length map", |
10bd7535 | 189 | n2, c2min, c2max, n1, c1min, c1max); |
0b27b8c7 | 190 | fHistAbso = new TH2F("habso","Interaction length map", |
10bd7535 | 191 | n2, c2min, c2max, n1, c1min, c1max); |
0b27b8c7 | 192 | fHistGcm2 = new TH2F("hgcm2","g/cm2 length map", |
10bd7535 | 193 | n2, c2min, c2max, n1, c1min, c1max); |
7eb618fa | 194 | // |
195 | // | |
196 | fStepBack = 0; | |
197 | fStepsBackward = 0; | |
198 | fStepsForward = 0; | |
199 | fStepBack = 0; | |
200 | fVolumesFwd = new TClonesArray("AliDebugVolume",1000); | |
201 | fVolumesBwd = new TClonesArray("AliDebugVolume",1000); | |
19237f5f | 202 | fDebug = gAlice->GetDebug(); |
a74d2699 | 203 | fErrorCondition =0; |
fe4da5cc | 204 | } |
205 | ||
206 | //___________________________________________ | |
207 | AliLego::~AliLego() | |
208 | { | |
8918e700 | 209 | // |
210 | // Destructor | |
211 | // | |
212 | delete fHistRadl; | |
213 | delete fHistAbso; | |
214 | delete fHistGcm2; | |
8918e700 | 215 | delete fGener; |
7eb618fa | 216 | if (fVolumesFwd) delete fVolumesFwd; |
217 | if (fVolumesBwd) delete fVolumesBwd; | |
fe4da5cc | 218 | } |
219 | ||
b13db077 | 220 | //___________________________________________ |
dffd31ef | 221 | void AliLego::BeginEvent() |
b13db077 | 222 | { |
8918e700 | 223 | // |
224 | // --- Set to 0 radiation length, absorption length and g/cm2 --- | |
225 | // | |
dffd31ef | 226 | fTotRadl = 0; |
227 | fTotAbso = 0; | |
228 | fTotGcm2 = 0; | |
19237f5f | 229 | |
a74d2699 | 230 | if (fDebug) { |
231 | if (fErrorCondition) DumpVolumes(); | |
232 | fVolumesFwd->Delete(); | |
233 | fVolumesBwd->Delete(); | |
234 | fStepsForward = 0; | |
235 | fStepsBackward = 0; | |
236 | fErrorCondition = 0; | |
237 | if (gAlice->CurrentTrack() == 0) fStepBack = 0; | |
238 | } | |
dffd31ef | 239 | } |
240 | ||
241 | //___________________________________________ | |
242 | void AliLego::FinishEvent() | |
243 | { | |
8918e700 | 244 | // |
245 | // Finish the event and update the histos | |
246 | // | |
0b27b8c7 | 247 | Double_t c1, c2; |
248 | c1 = fGener->CurCoor1(); | |
249 | c2 = fGener->CurCoor2(); | |
10bd7535 | 250 | fHistRadl->Fill(c2,c1,fTotRadl); |
251 | fHistAbso->Fill(c2,c1,fTotAbso); | |
252 | fHistGcm2->Fill(c2,c1,fTotGcm2); | |
b13db077 | 253 | } |
254 | ||
dffd31ef | 255 | //___________________________________________ |
256 | void AliLego::FinishRun() | |
257 | { | |
8918e700 | 258 | // |
259 | // Store histograms in current Root file | |
260 | // | |
dffd31ef | 261 | fHistRadl->Write(); |
262 | fHistAbso->Write(); | |
263 | fHistGcm2->Write(); | |
dffd31ef | 264 | |
265 | // Delete histograms from memory | |
266 | fHistRadl->Delete(); fHistRadl=0; | |
267 | fHistAbso->Delete(); fHistAbso=0; | |
268 | fHistGcm2->Delete(); fHistGcm2=0; | |
a74d2699 | 269 | // |
270 | if (fErrorCondition) DumpVolumes(); | |
dffd31ef | 271 | } |
272 | ||
8918e700 | 273 | //___________________________________________ |
274 | void AliLego::Copy(AliLego &lego) const | |
275 | { | |
276 | // | |
277 | // Copy *this onto lego -- not implemented | |
278 | // | |
279 | Fatal("Copy","Not implemented!\n"); | |
280 | } | |
dffd31ef | 281 | |
b13db077 | 282 | //___________________________________________ |
7eb618fa | 283 | void AliLego::StepManager() { |
b13db077 | 284 | // called from AliRun::Stepmanager from gustep. |
285 | // Accumulate the 3 parameters step by step | |
a74d2699 | 286 | |
7eb618fa | 287 | static Float_t t; |
288 | Float_t a,z,dens,radl,absl; | |
289 | Int_t i, id, copy; | |
290 | const char* vol; | |
291 | static Float_t vect[3], dir[3]; | |
a01a8b12 | 292 | |
7eb618fa | 293 | TString tmp1, tmp2; |
294 | copy = 1; | |
295 | id = gMC->CurrentVolID(copy); | |
296 | vol = gMC->VolName(id); | |
297 | Float_t step = gMC->TrackStep(); | |
7eb618fa | 298 | |
299 | TLorentzVector pos, mom; | |
b13db077 | 300 | gMC->TrackPosition(pos); |
301 | gMC->TrackMomentum(mom); | |
7eb618fa | 302 | |
303 | Int_t status = 0; | |
304 | if (gMC->IsTrackEntering()) status = 1; | |
a74d2699 | 305 | if (gMC->IsTrackExiting()) status = 2; |
0b27b8c7 | 306 | |
a74d2699 | 307 | |
308 | ||
309 | ||
7eb618fa | 310 | if (! fStepBack) { |
09a536f9 | 311 | // printf("\n volume %s %d", vol, status); |
7eb618fa | 312 | // |
313 | // Normal Forward stepping | |
314 | // | |
315 | if (fDebug) { | |
a74d2699 | 316 | // printf("\n steps fwd %d %s %d %f", fStepsForward, vol, fErrorCondition, step); |
317 | ||
7eb618fa | 318 | // |
319 | // store volume if different from previous | |
320 | // | |
321 | ||
a74d2699 | 322 | TClonesArray &lvols = *fVolumesFwd; |
7eb618fa | 323 | if (fStepsForward > 0) { |
324 | AliDebugVolume* tmp = (AliDebugVolume*) (*fVolumesFwd)[fStepsForward-1]; | |
a74d2699 | 325 | if (tmp->IsEqual(vol, copy) && gMC->IsTrackEntering()) { |
a74d2699 | 326 | fStepsForward -= 2; |
5f3dc1c9 | 327 | fVolumesFwd->RemoveAt(fStepsForward); |
328 | fVolumesFwd->RemoveAt(fStepsForward+1); | |
a74d2699 | 329 | } |
7eb618fa | 330 | } |
a74d2699 | 331 | |
332 | new(lvols[fStepsForward++]) | |
333 | AliDebugVolume(vol,copy,step,pos[0], pos[1], pos[2], status); | |
334 | ||
7eb618fa | 335 | } // Debug |
336 | // | |
337 | // Get current material properties | |
b13db077 | 338 | |
7eb618fa | 339 | gMC->CurrentMaterial(a,z,dens,radl,absl); |
340 | ||
341 | if (z < 1) return; | |
342 | ||
343 | // --- See if we have to stop now | |
344 | if (TMath::Abs(pos[2]) > fGener->ZMax() || | |
345 | pos[0]*pos[0] +pos[1]*pos[1] > fGener->RadMax()*fGener->RadMax()) { | |
346 | if (!gMC->IsNewTrack()) { | |
347 | // Not the first step, add past contribution | |
348 | fTotAbso += t/absl; | |
349 | fTotRadl += t/radl; | |
350 | fTotGcm2 += t*dens; | |
7eb618fa | 351 | if (fDebug) { |
352 | // | |
353 | // generate "mirror" particle flying back | |
354 | // | |
355 | fStepsBackward = fStepsForward; | |
356 | ||
357 | Float_t pmom[3], orig[3]; | |
358 | Float_t polar[3] = {0.,0.,0.}; | |
359 | Int_t ntr; | |
360 | pmom[0] = -dir[0]; | |
361 | pmom[1] = -dir[1]; | |
362 | pmom[2] = -dir[2]; | |
363 | orig[0] = vect[0]; | |
364 | orig[1] = vect[1]; | |
365 | orig[2] = vect[2]; | |
366 | ||
367 | gAlice->SetTrack(1, gAlice->CurrentTrack(), | |
368 | 0, pmom, orig, polar, 0., kPNoProcess, ntr); | |
369 | } // debug | |
370 | ||
371 | } // not a new track ! | |
372 | ||
19237f5f | 373 | if (fDebug) fStepBack = 1; |
7eb618fa | 374 | gMC->StopTrack(); |
375 | return; | |
376 | } // outside scoring region ? | |
377 | ||
b13db077 | 378 | // --- See how long we have to go |
7eb618fa | 379 | for(i=0;i<3;++i) { |
380 | vect[i]=pos[i]; | |
381 | dir[i]=mom[i]; | |
382 | } | |
383 | ||
384 | t = fGener->PropagateCylinder(vect,dir,fGener->RadMax(),fGener->ZMax()); | |
385 | ||
386 | if(step) { | |
19237f5f | 387 | |
7eb618fa | 388 | fTotAbso += step/absl; |
389 | fTotRadl += step/radl; | |
390 | fTotGcm2 += step*dens; | |
391 | } | |
392 | ||
393 | ||
394 | } else { | |
395 | if (fDebug) { | |
396 | // | |
397 | // Geometry debugging | |
398 | // Fly back and compare volume sequence | |
399 | // | |
a74d2699 | 400 | TClonesArray &lvols = *fVolumesBwd; |
7eb618fa | 401 | if (fStepsBackward < fStepsForward) { |
402 | AliDebugVolume* tmp = (AliDebugVolume*) (*fVolumesBwd)[fStepsBackward]; | |
a74d2699 | 403 | if (tmp->IsEqual(vol, copy) && gMC->IsTrackEntering()) { |
404 | fStepsBackward += 2; | |
5f3dc1c9 | 405 | fVolumesBwd->RemoveAt(fStepsBackward-1); |
406 | fVolumesBwd->RemoveAt(fStepsBackward-2); | |
7eb618fa | 407 | } |
408 | } | |
a74d2699 | 409 | |
7eb618fa | 410 | fStepsBackward--; |
a74d2699 | 411 | // printf("\n steps %d %s %d", fStepsBackward, vol, fErrorCondition); |
7eb618fa | 412 | if (fStepsBackward < 0) { |
413 | gMC->StopTrack(); | |
a74d2699 | 414 | fStepBack = 0; |
7eb618fa | 415 | return; |
416 | } | |
417 | ||
7eb618fa | 418 | new(lvols[fStepsBackward]) AliDebugVolume(vol,copy,step,pos[0], pos[1], pos[2], status); |
419 | ||
420 | AliDebugVolume* tmp = (AliDebugVolume*) (*fVolumesFwd)[fStepsBackward]; | |
421 | if (! (tmp->IsEqual(vol, copy)) && (!fErrorCondition)) | |
422 | { | |
423 | printf("\n Problem at (x,y,z): %d %f %f %f, volumes: %s %s step: %f\n", | |
424 | fStepsBackward, pos[0], pos[1], pos[2], tmp->GetName(), vol, step); | |
425 | fErrorCondition = 1; | |
426 | } | |
427 | } // Debug | |
428 | } // bwd/fwd | |
b13db077 | 429 | } |
430 | ||
a74d2699 | 431 | void AliLego::DumpVolumes() |
432 | { | |
433 | // | |
434 | // Dump volume sequence in case of error | |
435 | // | |
436 | printf("\n Dumping Volume Sequence:"); | |
437 | printf("\n =============================================="); | |
438 | ||
439 | for (Int_t i = fStepsForward-1; i>=0; i--) | |
440 | { | |
441 | AliDebugVolume* tmp1 = (AliDebugVolume*) (*fVolumesFwd)[i]; | |
442 | AliDebugVolume* tmp2 = (AliDebugVolume*) (*fVolumesBwd)[i]; | |
899fde02 | 443 | if (tmp1) |
444 | printf("\n Volume Fwd: %3d: %5s (%3d) step: %12.5e (x,y,z) (%12.5e %12.5e %12.5e) status: %9s \n" | |
a74d2699 | 445 | , i, |
446 | tmp1->GetName(), tmp1->CopyNumber(), tmp1->Step(), | |
447 | tmp1->X(), tmp1->Y(), tmp1->Z(), tmp1->Status()); | |
899fde02 | 448 | if (tmp2 && i>= fStepsBackward) |
449 | printf("\n Volume Bwd: %3d: %5s (%3d) step: %12.5e (x,y,z) (%12.5e %12.5e %12.5e) status: %9s \n" | |
a74d2699 | 450 | , i, |
451 | tmp2->GetName(), tmp2->CopyNumber(), tmp2->Step(), | |
452 | tmp2->X(), tmp2->Y(), tmp2->Z(), tmp2->Status()); | |
453 | ||
454 | printf("\n ............................................................................\n"); | |
455 | } | |
456 | printf("\n ==============================================\n"); | |
457 | } | |
0b27b8c7 | 458 | |
459 | ||
460 | ||
461 | ||
7eb618fa | 462 | |
463 | ||
464 |