Project
Loading...
Searching...
No Matches
MaterialBudgetMap.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12/*
13 * Created on: March 17, 2022
14 * Author: amorsch
15 */
16
19//
20// Utility class to evaluate the material budget from
21// a given radius to the surface of an arbitrary cylinder
22// along radial directions from the centre:
23//
24// - radiation length
25// - Interaction length
26// - g/cm2
27//
28// Geantinos are shot in the bins in the fNtheta bins in theta
29// and fNphi bins in phi with specified rectangular limits.
30// The statistics are accumulated per
31// fRadMin < r < fRadMax and <0 < z < fZMax
32//
34
35#include "TH2.h"
36#include "TMath.h"
37#include "TString.h"
38#include "TVirtualMC.h"
39#include "TFile.h"
41
43using namespace o2::steer;
44//_______________________________________________________________________
46 mTotRadl(0),
47 mTotAbso(0),
48 mTotGcm2(0),
49 mHistRadl(nullptr),
50 mHistAbso(nullptr),
51 mHistGcm2(nullptr),
52 mHistReta(nullptr),
53 mRZR(nullptr),
54 mRZA(nullptr),
55 mRZG(nullptr),
56 mStopped(0)
57{
58 //
59 // Default constructor
60 //
61}
62
63//_______________________________________________________________________
64MaterialBudgetMap::MaterialBudgetMap(const char* title, Int_t mode, Int_t nc1, Float_t c1min,
65 Float_t c1max, Int_t nphi, Float_t phimin, Float_t phimax,
66 Float_t rmin, Float_t rmax, Float_t zmax) : mMode(mode),
67 mTotRadl(0),
68 mTotAbso(0),
69 mTotGcm2(0),
70 mHistRadl(nullptr),
71 mHistAbso(nullptr),
72 mHistGcm2(nullptr),
73 mHistReta(nullptr),
74 mRZR(nullptr),
75 mRZA(nullptr),
76 mRZG(nullptr),
77 mStopped(0),
78 mRmin(rmin),
79 mRmax(rmax),
80 mZmax(zmax)
81{
82 //
83 // specify the angular limits and the size of the rectangular box
84 //
85 const char* xtitles[3] = {"#theta [degree]", "#eta", "z [cm]"};
86 mHistRadl = new TH2F("hradl", "Radiation length map",
87 nc1, c1min, c1max, nphi, phimin, phimax);
88 mHistRadl->SetYTitle("#phi [degree]");
89 mHistRadl->SetXTitle(xtitles[mMode]);
90 mHistAbso = new TH2F("habso", "Interaction length map",
91 nc1, c1min, c1max, nphi, phimin, phimax);
92 mHistAbso->SetYTitle("#phi [degree]");
93 mHistAbso->SetXTitle(xtitles[mMode]);
94 mHistGcm2 = new TH2F("hgcm2", "g/cm2 length map",
95 nc1, c1min, c1max, nphi, phimin, phimax);
96 mHistGcm2->SetYTitle("#phi [degree]");
97 mHistGcm2->SetXTitle(xtitles[mMode]);
98 mRZR = new TH2F("rzR", "Radiation length @ (r,z)",
99 zmax, -zmax, zmax, (rmax - rmin), rmin, rmax);
100 mRZR->SetXTitle("#it{z} [cm]");
101 mRZR->SetYTitle("#it{r} [cm]");
102 mRZA = static_cast<TH2F*>(mRZR->Clone("rzA"));
103 mRZA->SetTitle("Interaction length @ (r,z)");
104 mRZG = static_cast<TH2F*>(mRZR->Clone("rzG"));
105 mRZG->SetTitle("g/cm^{2} @ (r,z)");
106}
107
108//_______________________________________________________________________
110{
111 //
112 // Destructor
113 //
114 delete mHistRadl;
115 delete mHistAbso;
116 delete mHistGcm2;
117}
118
119//_______________________________________________________________________
121{
122 //
123 // --- Set to 0 radiation length, absorption length and g/cm2 ---
124 //
125 mTotRadl = 0;
126 mTotAbso = 0;
127 mTotGcm2 = 0;
128 mStopped = 0;
129}
130
131//_______________________________________________________________________
133{
134 //
135 // Finish the event and update the histos
136 //
137 mHistRadl->Fill(c1, c2, mTotRadl);
138 mHistAbso->Fill(c1, c2, mTotAbso);
139 mHistGcm2->Fill(c1, c2, mTotGcm2);
140 mTotRadl = 0;
141 mTotAbso = 0;
142 mTotGcm2 = 0;
143 mStopped = 0;
144}
145
146//_______________________________________________________________________
148{
149 //
150 // Store histograms in current Root file
151 //
152 printf("map::finish event \n");
153 auto f = new TFile("o2sim_matbudget.root", "recreate");
154 mHistRadl->Write();
155 mHistAbso->Write();
156 mHistGcm2->Write();
157 mRZR->Write();
158 mRZA->Write();
159 mRZG->Write();
160 f->Close();
161 // Delete histograms from memory
162 mHistRadl->Delete();
163 mHistRadl = nullptr;
164 mHistAbso->Delete();
165 mHistAbso = nullptr;
166 mHistGcm2->Delete();
167 mHistGcm2 = nullptr;
168 mRZR->Delete();
169 mRZR = nullptr;
170 mRZA->Delete();
171 mRZA = nullptr;
172 mRZG->Delete();
173 mRZG = nullptr;
174}
175
176//_______________________________________________________________________
178{
179 //
180 // called from AliRun::Stepmanager from gustep.
181 // Accumulate the 3 parameters step by step
182 //
183 static Float_t t;
184 Float_t a, z, dens, radl, absl;
185 Int_t i, id, copy;
186 const char* vol;
187 static Float_t vect[3], dir[3];
188
189 TString tmp1, tmp2;
190 copy = 1;
191 id = TVirtualMC::GetMC()->CurrentVolID(copy);
192 vol = TVirtualMC::GetMC()->VolName(id);
193 Float_t step = TVirtualMC::GetMC()->TrackStep();
194
195 TLorentzVector pos;
196 TVirtualMC::GetMC()->TrackPosition(pos);
197 TLorentzVector mom;
198 TVirtualMC::GetMC()->TrackMomentum(mom);
199
200 TVirtualMC::GetMC()->CurrentMaterial(a, z, dens, radl, absl);
201 Double_t r = TMath::Sqrt(pos[0] * pos[0] + pos[1] * pos[1]);
202
203 mRZR->Fill(pos[2], r, step / radl);
204 mRZA->Fill(pos[2], r, step / absl);
205 mRZG->Fill(pos[2], r, step * dens);
206 if (z < 1) {
207 return;
208 }
209 // --- See if we have to stop now
210 if (TMath::Abs(pos[2]) > TMath::Abs(mZmax) || r > mRmax) {
211 if (!TVirtualMC::GetMC()->IsNewTrack()) {
212 // Not the first step, add past contribution
213 if (!mStopped) {
214 if (absl) {
215 mTotAbso += t / absl;
216 }
217 if (radl) {
218 mTotRadl += t / radl;
219 }
220 mTotGcm2 += t * dens;
221 } // not stooped
222 } // not a new track !
223 mStopped = kTRUE;
224 TVirtualMC::GetMC()->StopTrack();
225 return;
226 } // outside scoring region ?
227
228 // --- See how long we have to go
229 for (i = 0; i < 3; ++i) {
230 vect[i] = pos[i];
231 dir[i] = mom[i];
232 }
233
234 t = eventgen::GeneratorGeantinos::PropagateCylinder(vect, dir, mRmax, mZmax);
235
236 if (step) {
237 if (absl) {
238 mTotAbso += step / absl;
239 }
240 if (radl) {
241 mTotRadl += step / radl;
242 }
243 mTotGcm2 += step * dens;
244 } // step
245}
int32_t i
bool const GPUTPCGMMerger::trackCluster * c1
bool const GPUTPCGMMerger::trackCluster const clcomparestruct * c2
uint16_t pos
Definition RawData.h:3
static Float_t PropagateCylinder(Float_t *x, Float_t *v, Float_t r, Float_t z)
void FinishPrimary(Float_t c1, Float_t c2)
GLenum mode
Definition glcorearb.h:266
GLdouble f
Definition glcorearb.h:310
GLboolean r
Definition glcorearb.h:1233
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLuint id
Definition glcorearb.h:650
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843