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 //////////////////////////////////////////////////////////////
19 //////////////////////////////////////////////////////////////
21 // Utility class to evaluate the material budget from
22 // a given radius to the surface of an arbitrary cylinder
23 // along radial directions from the centre:
26 // - Interaction length
29 // Geantinos are shot in the bins in the fNtheta bins in theta
30 // and fNphi bins in phi with specified rectangular limits.
31 // The statistics are accumulated per
32 // fRadMin < r < fRadMax and <0 < z < fZMax
34 // To activate this option, you can do:
35 // Root > gAlice.RunLego();
36 // or Root > .x menu.C then select menu item "RunLego"
37 // Note that when calling gAlice->RunLego, an optional list
38 // of arguments may be specified.
42 <img src="picts/alilego.gif">
46 //////////////////////////////////////////////////////////////
48 #include "TClonesArray.h"
54 #include "AliDebugVolume.h"
56 #include "AliLegoGenerator.h"
61 //_______________________________________________________________________
80 // Default constructor
84 //_______________________________________________________________________
85 AliLego::AliLego(const AliLego &lego):
110 //_______________________________________________________________________
111 AliLego::AliLego(const char *title, Int_t ntheta, Float_t thetamin,
112 Float_t thetamax, Int_t nphi, Float_t phimin, Float_t phimax,
113 Float_t rmin, Float_t rmax, Float_t zmax):
114 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);
136 fHistRadl = new TH2F("hradl","Radiation length map",
137 ntheta,thetamin,thetamax,nphi,phimin,phimax);
138 fHistAbso = new TH2F("habso","Interaction length map",
139 ntheta,thetamin,thetamax,nphi,phimin,phimax);
140 fHistGcm2 = new TH2F("hgcm2","g/cm2 length map",
141 ntheta,thetamin,thetamax,nphi,phimin,phimax);
143 fVolumesFwd = new TClonesArray("AliDebugVolume",1000);
144 fVolumesBwd = new TClonesArray("AliDebugVolume",1000);
145 fDebug = gAlice->GetDebug();
148 //_______________________________________________________________________
149 AliLego::AliLego(const char *title, AliLegoGenerator* generator):
150 TNamed("Lego Generator",title),
168 // specify the angular limits and the size of the rectangular box
171 Float_t c1min, c1max, c2min, c2max;
172 Int_t n1 = fGener->NCoor1();
173 Int_t n2 = fGener->NCoor2();
175 fGener->Coor1Range(c1min, c1max);
176 fGener->Coor2Range(c2min, c2max);
178 fHistRadl = new TH2F("hradl","Radiation length map",
179 n2, c2min, c2max, n1, c1min, c1max);
180 fHistAbso = new TH2F("habso","Interaction length map",
181 n2, c2min, c2max, n1, c1min, c1max);
182 fHistGcm2 = new TH2F("hgcm2","g/cm2 length map",
183 n2, c2min, c2max, n1, c1min, c1max);
187 fVolumesFwd = new TClonesArray("AliDebugVolume",1000);
188 fVolumesBwd = new TClonesArray("AliDebugVolume",1000);
189 fDebug = gAlice->GetDebug();
192 //_______________________________________________________________________
206 //_______________________________________________________________________
207 void AliLego::BeginEvent()
210 // --- Set to 0 radiation length, absorption length and g/cm2 ---
217 if (fErrorCondition) DumpVolumes();
218 fVolumesFwd->Delete();
219 fVolumesBwd->Delete();
223 if (gAlice->GetCurrentTrackNumber() == 0) fStepBack = 0;
227 //_______________________________________________________________________
228 void AliLego::FinishEvent()
231 // Finish the event and update the histos
234 c1 = fGener->CurCoor1();
235 c2 = fGener->CurCoor2();
236 fHistRadl->Fill(c2,c1,fTotRadl);
237 fHistAbso->Fill(c2,c1,fTotAbso);
238 fHistGcm2->Fill(c2,c1,fTotGcm2);
241 //_______________________________________________________________________
242 void AliLego::FinishRun()
245 // Store histograms in current Root file
251 // Delete histograms from memory
252 fHistRadl->Delete(); fHistRadl=0;
253 fHistAbso->Delete(); fHistAbso=0;
254 fHistGcm2->Delete(); fHistGcm2=0;
256 if (fErrorCondition) DumpVolumes();
259 //_______________________________________________________________________
260 void AliLego::Copy(AliLego&) const
263 // Copy *this onto lego -- not implemented
265 Fatal("Copy","Not implemented!\n");
268 //_______________________________________________________________________
269 void AliLego::StepManager()
272 // called from AliRun::Stepmanager from gustep.
273 // Accumulate the 3 parameters step by step
276 Float_t a,z,dens,radl,absl;
279 static Float_t vect[3], dir[3];
283 id = gMC->CurrentVolID(copy);
284 vol = gMC->VolName(id);
285 Float_t step = gMC->TrackStep();
287 TLorentzVector pos, mom;
288 gMC->TrackPosition(pos);
289 gMC->TrackMomentum(mom);
292 if (gMC->IsTrackEntering()) status = 1;
293 if (gMC->IsTrackExiting()) status = 2;
296 // printf("\n volume %s %d", vol, status);
298 // Normal Forward stepping
301 // printf("\n steps fwd %d %s %d %f", fStepsForward, vol, fErrorCondition, step);
304 // store volume if different from previous
307 TClonesArray &lvols = *fVolumesFwd;
308 if (fStepsForward > 0) {
309 AliDebugVolume* tmp = dynamic_cast<AliDebugVolume*>((*fVolumesFwd)[fStepsForward-1]);
310 if (tmp->IsVEqual(vol, copy) && gMC->IsTrackEntering()) {
312 fVolumesFwd->RemoveAt(fStepsForward);
313 fVolumesFwd->RemoveAt(fStepsForward+1);
317 new(lvols[fStepsForward++])
318 AliDebugVolume(vol,copy,step,pos[0], pos[1], pos[2], status);
322 // Get current material properties
324 gMC->CurrentMaterial(a,z,dens,radl,absl);
328 // --- See if we have to stop now
329 if (TMath::Abs(pos[2]) > fGener->ZMax() ||
330 pos[0]*pos[0] +pos[1]*pos[1] > fGener->RadMax()*fGener->RadMax()) {
331 if (!gMC->IsNewTrack()) {
332 // Not the first step, add past contribution
338 // generate "mirror" particle flying back
340 fStepsBackward = fStepsForward;
342 Float_t pmom[3], orig[3];
343 Float_t polar[3] = {0.,0.,0.};
352 gAlice->PushTrack(1, gAlice->GetCurrentTrackNumber(),
353 0, pmom, orig, polar, 0., kPNoProcess, ntr);
356 } // not a new track !
358 if (fDebug) fStepBack = 1;
361 } // outside scoring region ?
363 // --- See how long we have to go
369 t = fGener->PropagateCylinder(vect,dir,fGener->RadMax(),fGener->ZMax());
373 fTotAbso += step/absl;
374 fTotRadl += step/radl;
375 fTotGcm2 += step*dens;
381 // Geometry debugging
382 // Fly back and compare volume sequence
384 TClonesArray &lvols = *fVolumesBwd;
385 if (fStepsBackward < fStepsForward) {
386 AliDebugVolume* tmp = dynamic_cast<AliDebugVolume*>((*fVolumesBwd)[fStepsBackward]);
387 if (tmp->IsVEqual(vol, copy) && gMC->IsTrackEntering()) {
389 fVolumesBwd->RemoveAt(fStepsBackward-1);
390 fVolumesBwd->RemoveAt(fStepsBackward-2);
395 // printf("\n steps %d %s %d", fStepsBackward, vol, fErrorCondition);
396 if (fStepsBackward < 0) {
402 new(lvols[fStepsBackward]) AliDebugVolume(vol,copy,step,pos[0], pos[1], pos[2], status);
404 AliDebugVolume* tmp = dynamic_cast<AliDebugVolume*>((*fVolumesFwd)[fStepsBackward]);
405 if (! (tmp->IsVEqual(vol, copy)) && (!fErrorCondition))
407 printf("\n Problem at (x,y,z): %d %f %f %f, volumes: %s %s step: %f\n",
408 fStepsBackward, pos[0], pos[1], pos[2], tmp->GetName(), vol, step);
415 //_______________________________________________________________________
416 void AliLego::DumpVolumes()
419 // Dump volume sequence in case of error
421 printf("\n Dumping Volume Sequence:");
422 printf("\n ==============================================");
424 for (Int_t i = fStepsForward-1; i>=0; i--)
426 AliDebugVolume* tmp1 = dynamic_cast<AliDebugVolume*>((*fVolumesFwd)[i]);
427 AliDebugVolume* tmp2 = dynamic_cast<AliDebugVolume*>((*fVolumesBwd)[i]);
429 printf("\n Volume Fwd: %3d: %5s (%3d) step: %12.5e (x,y,z) (%12.5e %12.5e %12.5e) status: %9s \n"
431 tmp1->GetName(), tmp1->CopyNumber(), tmp1->Step(),
432 tmp1->X(), tmp1->Y(), tmp1->Z(), tmp1->Status());
433 if (tmp2 && i>= fStepsBackward)
434 printf("\n Volume Bwd: %3d: %5s (%3d) step: %12.5e (x,y,z) (%12.5e %12.5e %12.5e) status: %9s \n"
436 tmp2->GetName(), tmp2->CopyNumber(), tmp2->Step(),
437 tmp2->X(), tmp2->Y(), tmp2->Z(), tmp2->Status());
439 printf("\n ............................................................................\n");
441 printf("\n ==============================================\n");