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.27 2001/07/20 09:32:18 morsch
19 Protection against uncomplete backward stepping in dumping added.
21 Revision 1.26 2001/05/30 12:18:13 morsch
22 Fastidious printf commented.
24 Revision 1.25 2001/05/23 11:59:46 morsch
25 Use RemoveAt method instead of delete to remove objects from TClonesArray.
27 Revision 1.24 2001/05/21 08:39:13 morsch
28 Use fStepBack = 1 only in debug mode.
30 Revision 1.23 2001/05/20 10:10:39 morsch
31 - Debug output at the beginning of new event and end of run.
32 - Filter out boundary loops.
34 Revision 1.22 2001/05/11 13:22:40 morsch
35 If run with debug option (from gAlice) geantinos are sent back and volume sequence forward/backward is compared.
36 Can be very verbous in some cases.
38 Revision 1.21 2000/12/15 10:33:59 morsch
39 Invert coordinates to make meaningful zylindrical plots.
41 Revision 1.20 2000/11/30 07:12:48 alibrary
42 Introducing new Rndm and QA classes
44 Revision 1.19 2000/10/26 14:13:05 morsch
45 - Change from coordinates theta, phi to general coordinates Coor1 and Coor2.
46 - Lego generator instance can be passed in constructor.
48 Revision 1.18 2000/10/02 21:28:14 fca
49 Removal of useless dependecies via forward declarations
51 Revision 1.17 2000/07/12 08:56:25 fca
52 Coding convention correction and warning removal
54 Revision 1.16 2000/05/26 08:35:03 fca
55 Move the check on z after z has been retrieved
57 Revision 1.15 2000/05/16 13:10:40 fca
58 New method IsNewTrack and fix for a problem in Father-Daughter relations
60 Revision 1.14 2000/04/27 10:38:21 fca
61 Correct termination of Lego Run and introduce Lego getter in AliRun
63 Revision 1.13 2000/04/26 10:17:31 fca
64 Changes in Lego for G4 compatibility
66 Revision 1.12 2000/04/07 11:12:33 fca
67 G4 compatibility changes
69 Revision 1.11 2000/03/22 13:42:26 fca
70 SetGenerator does not replace an existing generator, ResetGenerator does
72 Revision 1.10 2000/02/23 16:25:22 fca
73 AliVMC and AliGeant3 classes introduced
74 ReadEuclid moved from AliRun to AliModule
76 Revision 1.9 1999/12/03 10:54:01 fca
79 Revision 1.8 1999/10/01 09:54:33 fca
80 Correct logics for Lego StepManager
82 Revision 1.7 1999/09/29 09:24:29 fca
83 Introduction of the Copyright and cvs Log
87 //////////////////////////////////////////////////////////////
88 //////////////////////////////////////////////////////////////
90 // Utility class to evaluate the material budget from
91 // a given radius to the surface of an arbitrary cylinder
92 // along radial directions from the centre:
95 // - Interaction length
98 // Geantinos are shot in the bins in the fNtheta bins in theta
99 // and fNphi bins in phi with specified rectangular limits.
100 // The statistics are accumulated per
101 // fRadMin < r < fRadMax and <0 < z < fZMax
103 // To activate this option, you can do:
104 // Root > gAlice.RunLego();
105 // or Root > .x menu.C then select menu item "RunLego"
106 // Note that when calling gAlice->RunLego, an optional list
107 // of arguments may be specified.
111 <img src="picts/alilego.gif">
115 //////////////////////////////////////////////////////////////
121 #include "AliDebugVolume.h"
123 #include "AliLegoGenerator.h"
124 #include "AliConst.h"
127 #include "../TGeant3/TGeant3.h"
129 #include "TClonesArray.h"
134 //___________________________________________
138 // Default constructor
149 //___________________________________________
150 AliLego::AliLego(const char *title, Int_t ntheta, Float_t thetamin,
151 Float_t thetamax, Int_t nphi, Float_t phimin, Float_t phimax,
152 Float_t rmin, Float_t rmax, Float_t zmax)
153 : TNamed("Lego Generator",title)
156 // specify the angular limits and the size of the rectangular box
158 fGener = new AliLegoGenerator(ntheta, thetamin, thetamax,
159 nphi, phimin, phimax, rmin, rmax, zmax);
163 fHistRadl = new TH2F("hradl","Radiation length map",
164 ntheta,thetamin,thetamax,nphi,phimin,phimax);
165 fHistAbso = new TH2F("habso","Interaction length map",
166 ntheta,thetamin,thetamax,nphi,phimin,phimax);
167 fHistGcm2 = new TH2F("hgcm2","g/cm2 length map",
168 ntheta,thetamin,thetamax,nphi,phimin,phimax);
174 fVolumesFwd = new TClonesArray("AliDebugVolume",1000);
175 fVolumesBwd = new TClonesArray("AliDebugVolume",1000);
176 fDebug = gAlice->GetDebug();
180 AliLego::AliLego(const char *title, AliLegoGenerator* generator)
181 : TNamed("Lego Generator",title)
184 // specify the angular limits and the size of the rectangular box
187 Float_t c1min, c1max, c2min, c2max;
188 Int_t n1 = fGener->NCoor1();
189 Int_t n2 = fGener->NCoor2();
191 fGener->Coor1Range(c1min, c1max);
192 fGener->Coor2Range(c2min, c2max);
194 fHistRadl = new TH2F("hradl","Radiation length map",
195 n2, c2min, c2max, n1, c1min, c1max);
196 fHistAbso = new TH2F("habso","Interaction length map",
197 n2, c2min, c2max, n1, c1min, c1max);
198 fHistGcm2 = new TH2F("hgcm2","g/cm2 length map",
199 n2, c2min, c2max, n1, c1min, c1max);
206 fVolumesFwd = new TClonesArray("AliDebugVolume",1000);
207 fVolumesBwd = new TClonesArray("AliDebugVolume",1000);
208 fDebug = gAlice->GetDebug();
212 //___________________________________________
222 if (fVolumesFwd) delete fVolumesFwd;
223 if (fVolumesBwd) delete fVolumesBwd;
226 //___________________________________________
227 void AliLego::BeginEvent()
230 // --- Set to 0 radiation length, absorption length and g/cm2 ---
237 if (fErrorCondition) DumpVolumes();
238 fVolumesFwd->Delete();
239 fVolumesBwd->Delete();
243 if (gAlice->CurrentTrack() == 0) fStepBack = 0;
247 //___________________________________________
248 void AliLego::FinishEvent()
251 // Finish the event and update the histos
254 c1 = fGener->CurCoor1();
255 c2 = fGener->CurCoor2();
256 fHistRadl->Fill(c2,c1,fTotRadl);
257 fHistAbso->Fill(c2,c1,fTotAbso);
258 fHistGcm2->Fill(c2,c1,fTotGcm2);
261 //___________________________________________
262 void AliLego::FinishRun()
265 // Store histograms in current Root file
271 // Delete histograms from memory
272 fHistRadl->Delete(); fHistRadl=0;
273 fHistAbso->Delete(); fHistAbso=0;
274 fHistGcm2->Delete(); fHistGcm2=0;
276 if (fErrorCondition) DumpVolumes();
279 //___________________________________________
280 void AliLego::Copy(AliLego &lego) const
283 // Copy *this onto lego -- not implemented
285 Fatal("Copy","Not implemented!\n");
288 //___________________________________________
289 void AliLego::StepManager() {
290 // called from AliRun::Stepmanager from gustep.
291 // Accumulate the 3 parameters step by step
294 Float_t a,z,dens,radl,absl;
297 static Float_t vect[3], dir[3];
301 id = gMC->CurrentVolID(copy);
302 vol = gMC->VolName(id);
303 Float_t step = gMC->TrackStep();
305 TLorentzVector pos, mom;
306 gMC->TrackPosition(pos);
307 gMC->TrackMomentum(mom);
310 if (gMC->IsTrackEntering()) status = 1;
311 if (gMC->IsTrackExiting()) status = 2;
317 // printf("\n volume %s %d", vol, status);
319 // Normal Forward stepping
322 // printf("\n steps fwd %d %s %d %f", fStepsForward, vol, fErrorCondition, step);
325 // store volume if different from previous
328 TClonesArray &lvols = *fVolumesFwd;
329 if (fStepsForward > 0) {
330 AliDebugVolume* tmp = (AliDebugVolume*) (*fVolumesFwd)[fStepsForward-1];
331 if (tmp->IsEqual(vol, copy) && gMC->IsTrackEntering()) {
333 fVolumesFwd->RemoveAt(fStepsForward);
334 fVolumesFwd->RemoveAt(fStepsForward+1);
338 new(lvols[fStepsForward++])
339 AliDebugVolume(vol,copy,step,pos[0], pos[1], pos[2], status);
343 // Get current material properties
345 gMC->CurrentMaterial(a,z,dens,radl,absl);
349 // --- See if we have to stop now
350 if (TMath::Abs(pos[2]) > fGener->ZMax() ||
351 pos[0]*pos[0] +pos[1]*pos[1] > fGener->RadMax()*fGener->RadMax()) {
352 if (!gMC->IsNewTrack()) {
353 // Not the first step, add past contribution
359 // generate "mirror" particle flying back
361 fStepsBackward = fStepsForward;
363 Float_t pmom[3], orig[3];
364 Float_t polar[3] = {0.,0.,0.};
373 gAlice->SetTrack(1, gAlice->CurrentTrack(),
374 0, pmom, orig, polar, 0., kPNoProcess, ntr);
377 } // not a new track !
379 if (fDebug) fStepBack = 1;
382 } // outside scoring region ?
384 // --- See how long we have to go
390 t = fGener->PropagateCylinder(vect,dir,fGener->RadMax(),fGener->ZMax());
394 fTotAbso += step/absl;
395 fTotRadl += step/radl;
396 fTotGcm2 += step*dens;
403 // Geometry debugging
404 // Fly back and compare volume sequence
406 TClonesArray &lvols = *fVolumesBwd;
407 if (fStepsBackward < fStepsForward) {
408 AliDebugVolume* tmp = (AliDebugVolume*) (*fVolumesBwd)[fStepsBackward];
409 if (tmp->IsEqual(vol, copy) && gMC->IsTrackEntering()) {
411 fVolumesBwd->RemoveAt(fStepsBackward-1);
412 fVolumesBwd->RemoveAt(fStepsBackward-2);
417 // printf("\n steps %d %s %d", fStepsBackward, vol, fErrorCondition);
418 if (fStepsBackward < 0) {
424 new(lvols[fStepsBackward]) AliDebugVolume(vol,copy,step,pos[0], pos[1], pos[2], status);
426 AliDebugVolume* tmp = (AliDebugVolume*) (*fVolumesFwd)[fStepsBackward];
427 if (! (tmp->IsEqual(vol, copy)) && (!fErrorCondition))
429 printf("\n Problem at (x,y,z): %d %f %f %f, volumes: %s %s step: %f\n",
430 fStepsBackward, pos[0], pos[1], pos[2], tmp->GetName(), vol, step);
437 void AliLego::DumpVolumes()
440 // Dump volume sequence in case of error
442 printf("\n Dumping Volume Sequence:");
443 printf("\n ==============================================");
445 for (Int_t i = fStepsForward-1; i>=0; i--)
447 AliDebugVolume* tmp1 = (AliDebugVolume*) (*fVolumesFwd)[i];
448 AliDebugVolume* tmp2 = (AliDebugVolume*) (*fVolumesBwd)[i];
450 printf("\n Volume Fwd: %3d: %5s (%3d) step: %12.5e (x,y,z) (%12.5e %12.5e %12.5e) status: %9s \n"
452 tmp1->GetName(), tmp1->CopyNumber(), tmp1->Step(),
453 tmp1->X(), tmp1->Y(), tmp1->Z(), tmp1->Status());
454 if (tmp2 && i>= fStepsBackward)
455 printf("\n Volume Bwd: %3d: %5s (%3d) step: %12.5e (x,y,z) (%12.5e %12.5e %12.5e) status: %9s \n"
457 tmp2->GetName(), tmp2->CopyNumber(), tmp2->Step(),
458 tmp2->X(), tmp2->Y(), tmp2->Z(), tmp2->Status());
460 printf("\n ............................................................................\n");
462 printf("\n ==============================================\n");