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