forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TMCVerbose.cxx
346 lines (280 loc) · 8.11 KB
/
TMCVerbose.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
// @(#)root/vmc:$Id$
// Author: Ivana Hrivnacova, 27/03/2002
/*************************************************************************
* Copyright (C) 2006, Rene Brun and Fons Rademakers. *
* Copyright (C) 2002, ALICE Experiment at CERN. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "Riostream.h"
#include "TVirtualMC.h"
#include "TVirtualMCStack.h"
#include "TDatabasePDG.h"
#include "TParticlePDG.h"
#include "TArrayI.h"
#include "TMCVerbose.h"
//______________________________________________________________________________
//
// Class for printing detailed info from MC application.
// Defined levels:
// 0 no output
// 1 info up to event level
// 2 info up to tracking level
// 3 detailed info for each step
//______________________________________________________________________________
ClassImp(TMCVerbose)
//_____________________________________________________________________________
TMCVerbose::TMCVerbose(Int_t level)
: TObject(),
fLevel(level),
fStepNumber(0)
{
// Standard constructor
// ---
}
//_____________________________________________________________________________
TMCVerbose::TMCVerbose()
: TObject(),
fLevel(0),
fStepNumber(0)
{
// Default constructor
// ---
}
//_____________________________________________________________________________
TMCVerbose::~TMCVerbose()
{
// Destructor
// ---
}
//
// private methods
//
//_____________________________________________________________________________
void TMCVerbose::PrintBanner() const
{
// Prints banner for track information
// ---
std::cout << std::endl;
for (Int_t i=0; i<10; i++) std::cout << "**********";
std::cout << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::PrintTrackInfo() const
{
// Prints track information
// ---
// Particle
//
std::cout << " Particle = ";
TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(gMC->TrackPid());
if (particle)
std::cout << particle->GetName() << " ";
else
std::cout << "unknown" << " ";
// Track ID
//
std::cout << " Track ID = " << gMC->GetStack()->GetCurrentTrackNumber() << " ";
// Parent ID
//
std::cout << " Parent ID = " << gMC->GetStack()->GetCurrentParentTrackNumber();
}
//_____________________________________________________________________________
void TMCVerbose::PrintStepHeader() const
{
// Prints the header for stepping information
// ---
std::cout << "Step# "
<< "X(cm) "
<< "Y(cm) "
<< "Z(cm) "
<< "KinE(MeV) "
<< "dE(MeV) "
<< "Step(cm) "
<< "TrackL(cm) "
<< "Volume "
<< "Process "
<< std::endl;
}
//
// public methods
//
//_____________________________________________________________________________
void TMCVerbose::InitMC()
{
// Initialize MC info.
// ---
if (fLevel>0)
std::cout << "--- Init MC " << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::RunMC(Int_t nofEvents)
{
// MC run info.
// ---
if (fLevel>0)
std::cout << "--- Run MC for " << nofEvents << " events" << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::FinishRun()
{
// Finish MC run info.
// ---
if (fLevel>0)
std::cout << "--- Finish Run MC " << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::ConstructGeometry()
{
// Construct geometry info
// ---
if (fLevel>0)
std::cout << "--- Construct geometry " << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::ConstructOpGeometry()
{
// Construct geometry for optical physics info
// ---
if (fLevel>0)
std::cout << "--- Construct geometry for optical processes" << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::InitGeometry()
{
// Initialize geometry info
// ---
if (fLevel>0)
std::cout << "--- Init geometry " << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::AddParticles()
{
// Add particles info
// ---
if (fLevel>0)
std::cout << "--- Add particles " << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::AddIons()
{
// Add ions info
// ---
if (fLevel>0)
std::cout << "--- Add ions " << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::GeneratePrimaries()
{
// Generate primaries info
// ---
if (fLevel>0)
std::cout << "--- Generate primaries " << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::BeginEvent()
{
// Begin event info
// ---
if (fLevel>0)
std::cout << "--- Begin event " << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::BeginPrimary()
{
// Begin of a primary track info
// ---
if (fLevel>1)
std::cout << "--- Begin primary " << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::PreTrack()
{
// Begin of each track info
// ---
if (fLevel>2) {
PrintBanner();
PrintTrackInfo();
PrintBanner();
PrintStepHeader();
fStepNumber = 0;
return;
}
if (fLevel>1)
std::cout << "--- Pre track " << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::Stepping()
{
// Stepping info
// ---
if (fLevel>2) {
#if __GNUC__ >= 3
std::cout << std::fixed;
#endif
// Step number
//
std::cout << "#" << std::setw(4) << fStepNumber++ << " ";
// Position
//
Double_t x, y, z;
gMC->TrackPosition(x, y, z);
std::cout << std::setw(8) << std::setprecision(3) << x << " "
<< std::setw(8) << std::setprecision(3) << y << " "
<< std::setw(8) << std::setprecision(3) << z << " ";
// Kinetic energy
//
Double_t px, py, pz, etot;
gMC->TrackMomentum(px, py, pz, etot);
Double_t ekin = etot - gMC->TrackMass();
std::cout << std::setw(9) << std::setprecision(4) << ekin*1e03 << " ";
// Energy deposit
//
std::cout << std::setw(9) << std::setprecision(4) << gMC->Edep()*1e03 << " ";
// Step length
//
std::cout << std::setw(8) << std::setprecision(3) << gMC->TrackStep() << " ";
// Track length
//
std::cout << std::setw(8) << std::setprecision(3) << gMC->TrackLength() << " ";
// Volume
//
if (gMC->CurrentVolName() != 0)
std::cout << std::setw(4) << gMC->CurrentVolName() << " ";
else
std::cout << std::setw(4) << "None" << " ";
// Process
//
TArrayI processes;
Int_t nofProcesses = gMC->StepProcesses(processes);
if (nofProcesses > 0)
std::cout << TMCProcessName[processes[nofProcesses-1]];
std::cout << std::endl;
}
}
//_____________________________________________________________________________
void TMCVerbose::PostTrack()
{
// Finish of each track info
// ---
if (fLevel==2)
std::cout << "--- Post track " << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::FinishPrimary()
{
// Finish of a primary track info
// ---
if (fLevel==2)
std::cout << "--- Finish primary " << std::endl;
}
//_____________________________________________________________________________
void TMCVerbose::FinishEvent()
{
// Finish of an event info
// ---
if (fLevel>0)
std::cout << "--- Finish event " << std::endl;
}