]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliLego.cxx
Correction of minor typing mistakes
[u/mrichter/AliRoot.git] / STEER / AliLego.cxx
CommitLineData
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$
94de3818 18Revision 1.17 2000/07/12 08:56:25 fca
19Coding convention correction and warning removal
20
8918e700 21Revision 1.16 2000/05/26 08:35:03 fca
22Move the check on z after z has been retrieved
23
119a6af6 24Revision 1.15 2000/05/16 13:10:40 fca
25New method IsNewTrack and fix for a problem in Father-Daughter relations
26
a01a8b12 27Revision 1.14 2000/04/27 10:38:21 fca
28Correct termination of Lego Run and introduce Lego getter in AliRun
29
838edcaf 30Revision 1.13 2000/04/26 10:17:31 fca
31Changes in Lego for G4 compatibility
32
dffd31ef 33Revision 1.12 2000/04/07 11:12:33 fca
34G4 compatibility changes
35
875c717b 36Revision 1.11 2000/03/22 13:42:26 fca
37SetGenerator does not replace an existing generator, ResetGenerator does
38
ee1dd322 39Revision 1.10 2000/02/23 16:25:22 fca
40AliVMC and AliGeant3 classes introduced
41ReadEuclid moved from AliRun to AliModule
42
b13db077 43Revision 1.9 1999/12/03 10:54:01 fca
44Fix lego summary
45
00719c1b 46Revision 1.8 1999/10/01 09:54:33 fca
47Correct logics for Lego StepManager
48
f059c84a 49Revision 1.7 1999/09/29 09:24:29 fca
50Introduction of the Copyright and cvs Log
51
4c039060 52*/
53
fe4da5cc 54//////////////////////////////////////////////////////////////
55//////////////////////////////////////////////////////////////
56//
57// Utility class to evaluate the material budget from
58// a given radius to the surface of an arbitrary cylinder
59// along radial directions from the centre:
60//
61// - radiation length
62// - Interaction length
63// - g/cm2
64//
65// Geantinos are shot in the bins in the fNtheta bins in theta
66// and fNphi bins in phi with specified rectangular limits.
67// The statistics are accumulated per
68// fRadMin < r < fRadMax and <0 < z < fZMax
69//
70// To activate this option, you can do:
71// Root > gAlice.RunLego();
72// or Root > .x menu.C then select menu item "RunLego"
73// Note that when calling gAlice->RunLego, an optional list
74// of arguments may be specified.
75//
76//Begin_Html
77/*
1439f98e 78<img src="picts/alilego.gif">
fe4da5cc 79*/
80//End_Html
81//
82//////////////////////////////////////////////////////////////
83
84#include "TMath.h"
94de3818 85
1578254f 86#include "AliLego.h"
8918e700 87#include "AliLegoGenerator.h"
fe4da5cc 88#include "AliRun.h"
89#include "AliConst.h"
875c717b 90#include "AliMC.h"
94de3818 91#include "TH2.h"
fe4da5cc 92
93ClassImp(AliLego)
94
95
96//___________________________________________
97AliLego::AliLego()
98{
8918e700 99 //
100 // Default constructor
101 //
102 fHistRadl = 0;
103 fHistAbso = 0;
104 fHistGcm2 = 0;
105 fHistReta = 0;
fe4da5cc 106}
107
108//___________________________________________
8918e700 109AliLego::AliLego(const char *title, Int_t ntheta, Float_t themin,
110 Float_t themax, Int_t nphi, Float_t phimin, Float_t phimax,
b13db077 111 Float_t rmin, Float_t rmax, Float_t zmax)
112 : TNamed("Lego Generator",title)
fe4da5cc 113{
8918e700 114 //
115 // specify the angular limits and the size of the rectangular box
116 //
b13db077 117 fGener = new AliLegoGenerator(ntheta, themin, themax,
118 nphi, phimin, phimax, rmin, rmax, zmax);
119
ee1dd322 120 gAlice->ResetGenerator(fGener);
b13db077 121
122 Float_t etamin = -TMath::Log(TMath::Tan(TMath::Min((Double_t)themax*kDegrad/2,TMath::Pi()/2-1.e-10)));
123 Float_t etamax = -TMath::Log(TMath::Tan(TMath::Max((Double_t)themin*kDegrad/2, 1.e-10)));
124
125 fHistRadl = new TH2F("hradl","Radiation length map",
126 nphi,phimin,phimax,ntheta,themin,themax);
127 fHistAbso = new TH2F("habso","Interaction length map",
128 nphi,phimin,phimax,ntheta,themin,themax);
129 fHistGcm2 = new TH2F("hgcm2","g/cm2 length map",
130 nphi,phimin,phimax,ntheta,themin,themax);
131 fHistReta = new TH2F("hetar","Radiation length vs. eta",
132 nphi,phimin,phimax,ntheta,etamin,etamax);
133
fe4da5cc 134}
135
136//___________________________________________
137AliLego::~AliLego()
138{
8918e700 139 //
140 // Destructor
141 //
142 delete fHistRadl;
143 delete fHistAbso;
144 delete fHistGcm2;
145 delete fHistReta;
146 gAlice->ResetGenerator(0);
147 delete fGener;
fe4da5cc 148}
149
b13db077 150//___________________________________________
dffd31ef 151void AliLego::BeginEvent()
b13db077 152{
8918e700 153 //
154 // --- Set to 0 radiation length, absorption length and g/cm2 ---
155 //
dffd31ef 156 fTotRadl = 0;
157 fTotAbso = 0;
158 fTotGcm2 = 0;
159}
160
161//___________________________________________
162void AliLego::FinishEvent()
163{
8918e700 164 //
165 // Finish the event and update the histos
166 //
dffd31ef 167 Double_t thed, phid, eta;
168 thed = fGener->CurTheta()*kRaddeg;
169 phid = fGener->CurPhi()*kRaddeg;
170 eta = -TMath::Log(TMath::Tan(TMath::Max(
b13db077 171 TMath::Min((Double_t)(fGener->CurTheta())/2,
172 TMath::Pi()/2-1.e-10),1.e-10)));
173
dffd31ef 174 fHistRadl->Fill(phid,thed,fTotRadl);
175 fHistAbso->Fill(phid,thed,fTotAbso);
176 fHistGcm2->Fill(phid,thed,fTotGcm2);
177 fHistReta->Fill(phid,eta,fTotRadl);
b13db077 178}
179
dffd31ef 180//___________________________________________
181void AliLego::FinishRun()
182{
8918e700 183 //
184 // Store histograms in current Root file
185 //
dffd31ef 186 fHistRadl->Write();
187 fHistAbso->Write();
188 fHistGcm2->Write();
189 fHistReta->Write();
190
191 // Delete histograms from memory
192 fHistRadl->Delete(); fHistRadl=0;
193 fHistAbso->Delete(); fHistAbso=0;
194 fHistGcm2->Delete(); fHistGcm2=0;
195 fHistReta->Delete(); fHistReta=0;
196
197}
198
8918e700 199//___________________________________________
200void AliLego::Copy(AliLego &lego) const
201{
202 //
203 // Copy *this onto lego -- not implemented
204 //
205 Fatal("Copy","Not implemented!\n");
206}
dffd31ef 207
b13db077 208//___________________________________________
209void AliLego::StepManager()
210{
211// called from AliRun::Stepmanager from gustep.
212// Accumulate the 3 parameters step by step
213
214 static Float_t t;
215 Float_t a,z,dens,radl,absl;
216 Int_t i;
217
218 Float_t step = gMC->TrackStep();
219
220 Float_t vect[3], dir[3];
221 TLorentzVector pos, mom;
222
119a6af6 223 gMC->CurrentMaterial(a,z,dens,radl,absl);
224
a01a8b12 225 if (z < 1) return;
226
b13db077 227 gMC->TrackPosition(pos);
228 gMC->TrackMomentum(mom);
b13db077 229// --- See if we have to stop now
230 if (TMath::Abs(pos[2]) > fGener->ZMax() ||
231 pos[0]*pos[0] +pos[1]*pos[1] > fGener->RadMax()*fGener->RadMax()) {
a01a8b12 232 if (!gMC->IsNewTrack()) {
b13db077 233 // Not the first step, add past contribution
234 fTotAbso += t/absl;
235 fTotRadl += t/radl;
236 fTotGcm2 += t*dens;
237 }
238 gMC->StopTrack();
239 return;
240 }
241
242// --- See how long we have to go
243 for(i=0;i<3;++i) {
244 vect[i]=pos[i];
245 dir[i]=mom[i];
246 }
247
248 t = fGener->PropagateCylinder(vect,dir,fGener->RadMax(),fGener->ZMax());
249
250 if(step) {
251 fTotAbso += step/absl;
252 fTotRadl += step/radl;
253 fTotGcm2 += step*dens;
254 }
255}
256