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