1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.29 2002/10/14 14:57:32 hristov
19 Merging the VirtualMC branch to the main development branch (HEAD)
21 Revision 1.28.6.2 2002/07/24 10:08:13 alibrary
24 Revision 1.28.6.1 2002/06/10 14:43:06 hristov
27 Revision 1.28 2001/10/21 18:38:44 hristov
28 Several pointers were set to zero in the default constructors to avoid memory management problems
30 Revision 1.27 2001/07/20 09:32:18 morsch
31 Protection against uncomplete backward stepping in dumping added.
33 Revision 1.26 2001/05/30 12:18:13 morsch
34 Fastidious printf commented.
36 Revision 1.25 2001/05/23 11:59:46 morsch
37 Use RemoveAt method instead of delete to remove objects from TClonesArray.
39 Revision 1.24 2001/05/21 08:39:13 morsch
40 Use fStepBack = 1 only in debug mode.
42 Revision 1.23 2001/05/20 10:10:39 morsch
43 - Debug output at the beginning of new event and end of run.
44 - Filter out boundary loops.
46 Revision 1.22 2001/05/11 13:22:40 morsch
47 If run with debug option (from gAlice) geantinos are sent back and volume sequence forward/backward is compared.
48 Can be very verbous in some cases.
50 Revision 1.21 2000/12/15 10:33:59 morsch
51 Invert coordinates to make meaningful zylindrical plots.
53 Revision 1.20 2000/11/30 07:12:48 alibrary
54 Introducing new Rndm and QA classes
56 Revision 1.19 2000/10/26 14:13:05 morsch
57 - Change from coordinates theta, phi to general coordinates Coor1 and Coor2.
58 - Lego generator instance can be passed in constructor.
60 Revision 1.18 2000/10/02 21:28:14 fca
61 Removal of useless dependecies via forward declarations
63 Revision 1.17 2000/07/12 08:56:25 fca
64 Coding convention correction and warning removal
66 Revision 1.16 2000/05/26 08:35:03 fca
67 Move the check on z after z has been retrieved
69 Revision 1.15 2000/05/16 13:10:40 fca
70 New method IsNewTrack and fix for a problem in Father-Daughter relations
72 Revision 1.14 2000/04/27 10:38:21 fca
73 Correct termination of Lego Run and introduce Lego getter in AliRun
75 Revision 1.13 2000/04/26 10:17:31 fca
76 Changes in Lego for G4 compatibility
78 Revision 1.12 2000/04/07 11:12:33 fca
79 G4 compatibility changes
81 Revision 1.11 2000/03/22 13:42:26 fca
82 SetGenerator does not replace an existing generator, ResetGenerator does
84 Revision 1.10 2000/02/23 16:25:22 fca
85 AliVMC and AliGeant3 classes introduced
86 ReadEuclid moved from AliRun to AliModule
88 Revision 1.9 1999/12/03 10:54:01 fca
91 Revision 1.8 1999/10/01 09:54:33 fca
92 Correct logics for Lego StepManager
94 Revision 1.7 1999/09/29 09:24:29 fca
95 Introduction of the Copyright and cvs Log
99 //////////////////////////////////////////////////////////////
100 //////////////////////////////////////////////////////////////
102 // Utility class to evaluate the material budget from
103 // a given radius to the surface of an arbitrary cylinder
104 // along radial directions from the centre:
106 // - radiation length
107 // - Interaction length
110 // Geantinos are shot in the bins in the fNtheta bins in theta
111 // and fNphi bins in phi with specified rectangular limits.
112 // The statistics are accumulated per
113 // fRadMin < r < fRadMax and <0 < z < fZMax
115 // To activate this option, you can do:
116 // Root > gAlice.RunLego();
117 // or Root > .x menu.C then select menu item "RunLego"
118 // Note that when calling gAlice->RunLego, an optional list
119 // of arguments may be specified.
123 <img src="picts/alilego.gif">
127 //////////////////////////////////////////////////////////////
129 #include "TClonesArray.h"
134 #include "AliConst.h"
135 #include "AliDebugVolume.h"
137 #include "AliLegoGenerator.h"
143 //_______________________________________________________________________
162 // Default constructor
166 //_______________________________________________________________________
167 AliLego::AliLego(const AliLego &lego):
192 //_______________________________________________________________________
193 AliLego::AliLego(const char *title, Int_t ntheta, Float_t thetamin,
194 Float_t thetamax, Int_t nphi, Float_t phimin, Float_t phimax,
195 Float_t rmin, Float_t rmax, Float_t zmax):
196 TNamed("Lego Generator",title),
214 // specify the angular limits and the size of the rectangular box
216 fGener = new AliLegoGenerator(ntheta, thetamin, thetamax,
217 nphi, phimin, phimax, rmin, rmax, zmax);
218 fHistRadl = new TH2F("hradl","Radiation length map",
219 ntheta,thetamin,thetamax,nphi,phimin,phimax);
220 fHistAbso = new TH2F("habso","Interaction length map",
221 ntheta,thetamin,thetamax,nphi,phimin,phimax);
222 fHistGcm2 = new TH2F("hgcm2","g/cm2 length map",
223 ntheta,thetamin,thetamax,nphi,phimin,phimax);
225 fVolumesFwd = new TClonesArray("AliDebugVolume",1000);
226 fVolumesBwd = new TClonesArray("AliDebugVolume",1000);
227 fDebug = gAlice->GetDebug();
230 //_______________________________________________________________________
231 AliLego::AliLego(const char *title, AliLegoGenerator* generator):
232 TNamed("Lego Generator",title),
250 // specify the angular limits and the size of the rectangular box
253 Float_t c1min, c1max, c2min, c2max;
254 Int_t n1 = fGener->NCoor1();
255 Int_t n2 = fGener->NCoor2();
257 fGener->Coor1Range(c1min, c1max);
258 fGener->Coor2Range(c2min, c2max);
260 fHistRadl = new TH2F("hradl","Radiation length map",
261 n2, c2min, c2max, n1, c1min, c1max);
262 fHistAbso = new TH2F("habso","Interaction length map",
263 n2, c2min, c2max, n1, c1min, c1max);
264 fHistGcm2 = new TH2F("hgcm2","g/cm2 length map",
265 n2, c2min, c2max, n1, c1min, c1max);
269 fVolumesFwd = new TClonesArray("AliDebugVolume",1000);
270 fVolumesBwd = new TClonesArray("AliDebugVolume",1000);
271 fDebug = gAlice->GetDebug();
274 //_______________________________________________________________________
288 //_______________________________________________________________________
289 void AliLego::BeginEvent()
292 // --- Set to 0 radiation length, absorption length and g/cm2 ---
299 if (fErrorCondition) DumpVolumes();
300 fVolumesFwd->Delete();
301 fVolumesBwd->Delete();
305 if (gAlice->CurrentTrack() == 0) fStepBack = 0;
309 //_______________________________________________________________________
310 void AliLego::FinishEvent()
313 // Finish the event and update the histos
316 c1 = fGener->CurCoor1();
317 c2 = fGener->CurCoor2();
318 fHistRadl->Fill(c2,c1,fTotRadl);
319 fHistAbso->Fill(c2,c1,fTotAbso);
320 fHistGcm2->Fill(c2,c1,fTotGcm2);
323 //_______________________________________________________________________
324 void AliLego::FinishRun()
327 // Store histograms in current Root file
333 // Delete histograms from memory
334 fHistRadl->Delete(); fHistRadl=0;
335 fHistAbso->Delete(); fHistAbso=0;
336 fHistGcm2->Delete(); fHistGcm2=0;
338 if (fErrorCondition) DumpVolumes();
341 //_______________________________________________________________________
342 void AliLego::Copy(AliLego&) const
345 // Copy *this onto lego -- not implemented
347 Fatal("Copy","Not implemented!\n");
350 //_______________________________________________________________________
351 void AliLego::StepManager()
354 // called from AliRun::Stepmanager from gustep.
355 // Accumulate the 3 parameters step by step
358 Float_t a,z,dens,radl,absl;
361 static Float_t vect[3], dir[3];
365 id = gMC->CurrentVolID(copy);
366 vol = gMC->VolName(id);
367 Float_t step = gMC->TrackStep();
369 TLorentzVector pos, mom;
370 gMC->TrackPosition(pos);
371 gMC->TrackMomentum(mom);
374 if (gMC->IsTrackEntering()) status = 1;
375 if (gMC->IsTrackExiting()) status = 2;
378 // printf("\n volume %s %d", vol, status);
380 // Normal Forward stepping
383 // printf("\n steps fwd %d %s %d %f", fStepsForward, vol, fErrorCondition, step);
386 // store volume if different from previous
389 TClonesArray &lvols = *fVolumesFwd;
390 if (fStepsForward > 0) {
391 AliDebugVolume* tmp = dynamic_cast<AliDebugVolume*>((*fVolumesFwd)[fStepsForward-1]);
392 if (tmp->IsVEqual(vol, copy) && gMC->IsTrackEntering()) {
394 fVolumesFwd->RemoveAt(fStepsForward);
395 fVolumesFwd->RemoveAt(fStepsForward+1);
399 new(lvols[fStepsForward++])
400 AliDebugVolume(vol,copy,step,pos[0], pos[1], pos[2], status);
404 // Get current material properties
406 gMC->CurrentMaterial(a,z,dens,radl,absl);
410 // --- See if we have to stop now
411 if (TMath::Abs(pos[2]) > fGener->ZMax() ||
412 pos[0]*pos[0] +pos[1]*pos[1] > fGener->RadMax()*fGener->RadMax()) {
413 if (!gMC->IsNewTrack()) {
414 // Not the first step, add past contribution
420 // generate "mirror" particle flying back
422 fStepsBackward = fStepsForward;
424 Float_t pmom[3], orig[3];
425 Float_t polar[3] = {0.,0.,0.};
434 gAlice->SetTrack(1, gAlice->CurrentTrack(),
435 0, pmom, orig, polar, 0., kPNoProcess, ntr);
438 } // not a new track !
440 if (fDebug) fStepBack = 1;
443 } // outside scoring region ?
445 // --- See how long we have to go
451 t = fGener->PropagateCylinder(vect,dir,fGener->RadMax(),fGener->ZMax());
455 fTotAbso += step/absl;
456 fTotRadl += step/radl;
457 fTotGcm2 += step*dens;
463 // Geometry debugging
464 // Fly back and compare volume sequence
466 TClonesArray &lvols = *fVolumesBwd;
467 if (fStepsBackward < fStepsForward) {
468 AliDebugVolume* tmp = dynamic_cast<AliDebugVolume*>((*fVolumesBwd)[fStepsBackward]);
469 if (tmp->IsVEqual(vol, copy) && gMC->IsTrackEntering()) {
471 fVolumesBwd->RemoveAt(fStepsBackward-1);
472 fVolumesBwd->RemoveAt(fStepsBackward-2);
477 // printf("\n steps %d %s %d", fStepsBackward, vol, fErrorCondition);
478 if (fStepsBackward < 0) {
484 new(lvols[fStepsBackward]) AliDebugVolume(vol,copy,step,pos[0], pos[1], pos[2], status);
486 AliDebugVolume* tmp = dynamic_cast<AliDebugVolume*>((*fVolumesFwd)[fStepsBackward]);
487 if (! (tmp->IsVEqual(vol, copy)) && (!fErrorCondition))
489 printf("\n Problem at (x,y,z): %d %f %f %f, volumes: %s %s step: %f\n",
490 fStepsBackward, pos[0], pos[1], pos[2], tmp->GetName(), vol, step);
497 //_______________________________________________________________________
498 void AliLego::DumpVolumes()
501 // Dump volume sequence in case of error
503 printf("\n Dumping Volume Sequence:");
504 printf("\n ==============================================");
506 for (Int_t i = fStepsForward-1; i>=0; i--)
508 AliDebugVolume* tmp1 = dynamic_cast<AliDebugVolume*>((*fVolumesFwd)[i]);
509 AliDebugVolume* tmp2 = dynamic_cast<AliDebugVolume*>((*fVolumesBwd)[i]);
511 printf("\n Volume Fwd: %3d: %5s (%3d) step: %12.5e (x,y,z) (%12.5e %12.5e %12.5e) status: %9s \n"
513 tmp1->GetName(), tmp1->CopyNumber(), tmp1->Step(),
514 tmp1->X(), tmp1->Y(), tmp1->Z(), tmp1->Status());
515 if (tmp2 && i>= fStepsBackward)
516 printf("\n Volume Bwd: %3d: %5s (%3d) step: %12.5e (x,y,z) (%12.5e %12.5e %12.5e) status: %9s \n"
518 tmp2->GetName(), tmp2->CopyNumber(), tmp2->Step(),
519 tmp2->X(), tmp2->Y(), tmp2->Z(), tmp2->Status());
521 printf("\n ............................................................................\n");
523 printf("\n ==============================================\n");