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.21 2000/12/15 10:33:59 morsch
19 Invert coordinates to make meaningful zylindrical plots.
21 Revision 1.20 2000/11/30 07:12:48 alibrary
22 Introducing new Rndm and QA classes
24 Revision 1.19 2000/10/26 14:13:05 morsch
25 - Change from coordinates theta, phi to general coordinates Coor1 and Coor2.
26 - Lego generator instance can be passed in constructor.
28 Revision 1.18 2000/10/02 21:28:14 fca
29 Removal of useless dependecies via forward declarations
31 Revision 1.17 2000/07/12 08:56:25 fca
32 Coding convention correction and warning removal
34 Revision 1.16 2000/05/26 08:35:03 fca
35 Move the check on z after z has been retrieved
37 Revision 1.15 2000/05/16 13:10:40 fca
38 New method IsNewTrack and fix for a problem in Father-Daughter relations
40 Revision 1.14 2000/04/27 10:38:21 fca
41 Correct termination of Lego Run and introduce Lego getter in AliRun
43 Revision 1.13 2000/04/26 10:17:31 fca
44 Changes in Lego for G4 compatibility
46 Revision 1.12 2000/04/07 11:12:33 fca
47 G4 compatibility changes
49 Revision 1.11 2000/03/22 13:42:26 fca
50 SetGenerator does not replace an existing generator, ResetGenerator does
52 Revision 1.10 2000/02/23 16:25:22 fca
53 AliVMC and AliGeant3 classes introduced
54 ReadEuclid moved from AliRun to AliModule
56 Revision 1.9 1999/12/03 10:54:01 fca
59 Revision 1.8 1999/10/01 09:54:33 fca
60 Correct logics for Lego StepManager
62 Revision 1.7 1999/09/29 09:24:29 fca
63 Introduction of the Copyright and cvs Log
67 //////////////////////////////////////////////////////////////
68 //////////////////////////////////////////////////////////////
70 // Utility class to evaluate the material budget from
71 // a given radius to the surface of an arbitrary cylinder
72 // along radial directions from the centre:
75 // - Interaction length
78 // Geantinos are shot in the bins in the fNtheta bins in theta
79 // and fNphi bins in phi with specified rectangular limits.
80 // The statistics are accumulated per
81 // fRadMin < r < fRadMax and <0 < z < fZMax
83 // To activate this option, you can do:
84 // Root > gAlice.RunLego();
85 // or Root > .x menu.C then select menu item "RunLego"
86 // Note that when calling gAlice->RunLego, an optional list
87 // of arguments may be specified.
91 <img src="picts/alilego.gif">
95 //////////////////////////////////////////////////////////////
100 #include "AliDebugVolume.h"
102 #include "AliLegoGenerator.h"
103 #include "AliConst.h"
107 #include "TClonesArray.h"
113 //___________________________________________
117 // Default constructor
125 //___________________________________________
126 AliLego::AliLego(const char *title, Int_t ntheta, Float_t thetamin,
127 Float_t thetamax, Int_t nphi, Float_t phimin, Float_t phimax,
128 Float_t rmin, Float_t rmax, Float_t zmax)
129 : TNamed("Lego Generator",title)
132 // specify the angular limits and the size of the rectangular box
134 fGener = new AliLegoGenerator(ntheta, thetamin, thetamax,
135 nphi, phimin, phimax, rmin, rmax, zmax);
139 fHistRadl = new TH2F("hradl","Radiation length map",
140 ntheta,thetamin,thetamax,nphi,phimin,phimax);
141 fHistAbso = new TH2F("habso","Interaction length map",
142 ntheta,thetamin,thetamax,nphi,phimin,phimax);
143 fHistGcm2 = new TH2F("hgcm2","g/cm2 length map",
144 ntheta,thetamin,thetamax,nphi,phimin,phimax);
150 fVolumesFwd = new TClonesArray("AliDebugVolume",1000);
151 fVolumesBwd = new TClonesArray("AliDebugVolume",1000);
152 fDebug = gAlice->GetDebug();
155 AliLego::AliLego(const char *title, AliLegoGenerator* generator)
156 : TNamed("Lego Generator",title)
159 // specify the angular limits and the size of the rectangular box
162 Float_t c1min, c1max, c2min, c2max;
163 Int_t n1 = fGener->NCoor1();
164 Int_t n2 = fGener->NCoor2();
166 fGener->Coor1Range(c1min, c1max);
167 fGener->Coor2Range(c2min, c2max);
169 fHistRadl = new TH2F("hradl","Radiation length map",
170 n2, c2min, c2max, n1, c1min, c1max);
171 fHistAbso = new TH2F("habso","Interaction length map",
172 n2, c2min, c2max, n1, c1min, c1max);
173 fHistGcm2 = new TH2F("hgcm2","g/cm2 length map",
174 n2, c2min, c2max, n1, c1min, c1max);
181 fVolumesFwd = new TClonesArray("AliDebugVolume",1000);
182 fVolumesBwd = new TClonesArray("AliDebugVolume",1000);
183 fDebug = gAlice->GetDebug();
186 //___________________________________________
196 if (fVolumesFwd) delete fVolumesFwd;
197 if (fVolumesBwd) delete fVolumesBwd;
200 //___________________________________________
201 void AliLego::BeginEvent()
204 // --- Set to 0 radiation length, absorption length and g/cm2 ---
212 //___________________________________________
213 void AliLego::FinishEvent()
216 // Finish the event and update the histos
219 c1 = fGener->CurCoor1();
220 c2 = fGener->CurCoor2();
221 fHistRadl->Fill(c2,c1,fTotRadl);
222 fHistAbso->Fill(c2,c1,fTotAbso);
223 fHistGcm2->Fill(c2,c1,fTotGcm2);
226 //___________________________________________
227 void AliLego::FinishRun()
230 // Store histograms in current Root file
236 // Delete histograms from memory
237 fHistRadl->Delete(); fHistRadl=0;
238 fHistAbso->Delete(); fHistAbso=0;
239 fHistGcm2->Delete(); fHistGcm2=0;
242 //___________________________________________
243 void AliLego::Copy(AliLego &lego) const
246 // Copy *this onto lego -- not implemented
248 Fatal("Copy","Not implemented!\n");
251 //___________________________________________
252 void AliLego::StepManager() {
253 // called from AliRun::Stepmanager from gustep.
254 // Accumulate the 3 parameters step by step
256 Float_t a,z,dens,radl,absl;
259 static Float_t vect[3], dir[3];
263 id = gMC->CurrentVolID(copy);
264 vol = gMC->VolName(id);
265 Float_t step = gMC->TrackStep();
268 TLorentzVector pos, mom;
269 gMC->TrackPosition(pos);
270 gMC->TrackMomentum(mom);
273 if (gMC->IsTrackEntering()) status = 1;
274 if (gMC->IsTrackExiting()) status = 2;
278 // Normal Forward stepping
282 // store volume if different from previous
285 if (fStepsForward > 0) {
286 AliDebugVolume* tmp = (AliDebugVolume*) (*fVolumesFwd)[fStepsForward-1];
287 // if (!tmp->IsEqual(vol, copy))
289 TClonesArray &lvols = *fVolumesFwd;
290 new(lvols[fStepsForward++])
291 AliDebugVolume(vol,copy,step,pos[0], pos[1], pos[2], status);
294 TClonesArray &lvols = *fVolumesFwd;
295 new(lvols[fStepsForward++])
296 AliDebugVolume(vol,copy,step,pos[0], pos[1], pos[2], status);
300 // Get current material properties
302 gMC->CurrentMaterial(a,z,dens,radl,absl);
306 // --- See if we have to stop now
307 if (TMath::Abs(pos[2]) > fGener->ZMax() ||
308 pos[0]*pos[0] +pos[1]*pos[1] > fGener->RadMax()*fGener->RadMax()) {
309 if (!gMC->IsNewTrack()) {
310 // Not the first step, add past contribution
317 // generate "mirror" particle flying back
319 fStepsBackward = fStepsForward;
321 Float_t pmom[3], orig[3];
322 Float_t polar[3] = {0.,0.,0.};
331 gAlice->SetTrack(1, gAlice->CurrentTrack(),
332 0, pmom, orig, polar, 0., kPNoProcess, ntr);
335 } // not a new track !
340 } // outside scoring region ?
342 // --- See how long we have to go
348 t = fGener->PropagateCylinder(vect,dir,fGener->RadMax(),fGener->ZMax());
351 fTotAbso += step/absl;
352 fTotRadl += step/radl;
353 fTotGcm2 += step*dens;
360 // Geometry debugging
361 // Fly back and compare volume sequence
363 if (fStepsBackward < fStepsForward) {
364 AliDebugVolume* tmp = (AliDebugVolume*) (*fVolumesBwd)[fStepsBackward];
365 if (tmp->IsEqual(vol, copy)) {
372 if (fStepsBackward < 0) {
374 if (fErrorCondition) {
376 // Dump volume sequence in case of error
378 printf("\n Dumping Volume Sequence:");
379 printf("\n ==============================================");
381 for (i = fStepsForward-1; i>=0; i--)
383 AliDebugVolume* tmp1 = (AliDebugVolume*) (*fVolumesFwd)[i];
384 AliDebugVolume* tmp2 = (AliDebugVolume*) (*fVolumesBwd)[i];
386 printf("\n Volume Fwd: %3d: %5s (%3d) step: %12.5e (x,y,z) (%12.5e %12.5e %12.5e) status: %9s\n"
388 tmp1->GetName(), tmp1->CopyNumber(), tmp1->Step(), tmp1->X(), tmp1->Y(), tmp1->Z(), tmp1->Status());
390 printf("\n Volume Bwd: %3d: %5s (%3d) step: %12.5e (x,y,z) (%12.5e %12.5e %12.5e) status: %9s\n"
392 tmp2->GetName(), tmp2->CopyNumber(), tmp2->Step(), tmp2->X(), tmp2->Y(), tmp2->Z(), tmp2->Status());
394 printf("\n ............................................................................\n");
396 printf("\n ==============================================\n");
398 fVolumesFwd->Delete();
399 fVolumesBwd->Delete();
407 TClonesArray &lvols = *fVolumesBwd;
408 new(lvols[fStepsBackward]) AliDebugVolume(vol,copy,step,pos[0], pos[1], pos[2], status);
410 AliDebugVolume* tmp = (AliDebugVolume*) (*fVolumesFwd)[fStepsBackward];
411 if (! (tmp->IsEqual(vol, copy)) && (!fErrorCondition))
413 printf("\n Problem at (x,y,z): %d %f %f %f, volumes: %s %s step: %f\n",
414 fStepsBackward, pos[0], pos[1], pos[2], tmp->GetName(), vol, step);