VMC Version 2.0
Loading...
Searching...
No Matches
TMCVerbose.cxx
Go to the documentation of this file.
1// -----------------------------------------------------------------------
2// Copyright (C) 2019 CERN and copyright holders of VMC Project.
3// This software is distributed under the terms of the GNU General Public
4// License v3 (GPL Version 3), copied verbatim in the file "LICENSE".
5//
6// See https://github.com/vmc-project/vmc for full licensing information.
7// -----------------------------------------------------------------------
8
9// Author: Ivana Hrivnacova, 27/03/2002
10
11/*************************************************************************
12 * Copyright (C) 2006, Rene Brun and Fons Rademakers. *
13 * Copyright (C) 2002, ALICE Experiment at CERN. *
14 * All rights reserved. *
15 * *
16 * For the licensing terms see $ROOTSYS/LICENSE. *
17 * For the list of contributors see $ROOTSYS/README/CREDITS. *
18 *************************************************************************/
19
20#include "Riostream.h"
21#include "TVirtualMC.h"
22#include "TVirtualMCStack.h"
23#include "TDatabasePDG.h"
24#include "TParticlePDG.h"
25#include "TArrayI.h"
26
27#include "TMCVerbose.h"
28
43
44TMCVerbose::TMCVerbose(Int_t level) : TObject(), fLevel(level), fStepNumber(0) {}
45
48
49TMCVerbose::TMCVerbose() : TObject(), fLevel(0), fStepNumber(0) {}
50
53
55
56//
57// private methods
58//
59
62
64{
65 std::cout << std::endl;
66 for (Int_t i = 0; i < 10; i++)
67 std::cout << "**********";
68 std::cout << std::endl;
69}
70
73
75{
76 // Particle
77 //
78 std::cout << " Particle = ";
79 TParticlePDG *particle = TDatabasePDG::Instance()->GetParticle(gMC->TrackPid());
80 if (particle)
81 std::cout << particle->GetName() << " ";
82 else
83 std::cout << "unknown"
84 << " ";
85
86 // Track ID
87 //
88 std::cout << " Track ID = " << gMC->GetStack()->GetCurrentTrackNumber() << " ";
89
90 // Parent ID
91 //
92 std::cout << " Parent ID = " << gMC->GetStack()->GetCurrentParentTrackNumber();
93}
94
97
99{
100 std::cout << "Step# "
101 << "X(cm) "
102 << "Y(cm) "
103 << "Z(cm) "
104 << "KinE(MeV) "
105 << "dE(MeV) "
106 << "Step(cm) "
107 << "TrackL(cm) "
108 << "Volume "
109 << "Process " << std::endl;
110}
111
112//
113// public methods
114//
115
118
120{
121 if (fLevel > 0)
122 std::cout << "--- Init MC " << std::endl;
123}
124
127
128void TMCVerbose::RunMC(Int_t nofEvents)
129{
130 if (fLevel > 0)
131 std::cout << "--- Run MC for " << nofEvents << " events" << std::endl;
132}
133
136
138{
139 if (fLevel > 0)
140 std::cout << "--- Finish Run MC " << std::endl;
141}
142
145
147{
148 if (fLevel > 0)
149 std::cout << "--- Construct geometry " << std::endl;
150}
151
154
156{
157 if (fLevel > 0)
158 std::cout << "--- Construct geometry for optical processes" << std::endl;
159}
160
163
165{
166 if (fLevel > 0)
167 std::cout << "--- Init geometry " << std::endl;
168}
169
172
174{
175 if (fLevel > 0)
176 std::cout << "--- Add particles " << std::endl;
177}
178
181
183{
184 if (fLevel > 0)
185 std::cout << "--- Add ions " << std::endl;
186}
187
190
192{
193 if (fLevel > 0)
194 std::cout << "--- Generate primaries " << std::endl;
195}
196
199
201{
202 if (fLevel > 0)
203 std::cout << "--- Begin event " << std::endl;
204}
205
208
210{
211 if (fLevel > 1)
212 std::cout << "--- Begin primary " << std::endl;
213}
214
217
219{
220 if (fLevel > 2) {
221 PrintBanner();
223 PrintBanner();
225
226 fStepNumber = 0;
227
228 return;
229 }
230
231 if (fLevel > 1)
232 std::cout << "--- Pre track " << std::endl;
233}
234
237
239{
240 if (fLevel > 2) {
241
242#if __GNUC__ >= 3
243 std::cout << std::fixed;
244#endif
245
246 // Step number
247 //
248 // std::cout << "#" << std::setw(4) << gMC->StepNumber() << " ";
249 std::cout << "#" << std::setw(4) << fStepNumber++ << " ";
250
251 // Position
252 //
253 Double_t x, y, z;
254 gMC->TrackPosition(x, y, z);
255 std::cout << std::setw(8) << std::setprecision(3) << x << " " << std::setw(8) << std::setprecision(3) << y << " "
256 << std::setw(8) << std::setprecision(3) << z << " ";
257
258 // Kinetic energy
259 //
260 Double_t px, py, pz, etot;
261 gMC->TrackMomentum(px, py, pz, etot);
262 Double_t ekin = etot - gMC->TrackMass();
263 std::cout << std::setw(9) << std::setprecision(4) << ekin * 1e03 << " ";
264
265 // Energy deposit
266 //
267 std::cout << std::setw(9) << std::setprecision(4) << gMC->Edep() * 1e03 << " ";
268
269 // Step length
270 //
271 std::cout << std::setw(8) << std::setprecision(3) << gMC->TrackStep() << " ";
272
273 // Track length
274 //
275 std::cout << std::setw(8) << std::setprecision(3) << gMC->TrackLength() << " ";
276
277 // Volume
278 //
279 if (gMC->CurrentVolName() != 0)
280 std::cout << std::setw(4) << gMC->CurrentVolName() << " ";
281 else
282 std::cout << std::setw(4) << "None"
283 << " ";
284
285 // Process
286 //
287 TArrayI processes;
288 Int_t nofProcesses = gMC->StepProcesses(processes);
289 if (nofProcesses > 0)
290 std::cout << TMCProcessName[processes[nofProcesses - 1]];
291
292 std::cout << std::endl;
293 }
294}
295
298
300{
301 if (fLevel == 2)
302 std::cout << "--- Post track " << std::endl;
303}
304
307
309{
310 if (fLevel == 1)
311 std::cout << "--- Finish primary " << std::endl;
312}
313
316
318{
319 if (fLevel > 0)
320 std::cout << "--- End of event " << std::endl;
321}
322
325
327{
328 if (fLevel > 0)
329 std::cout << "--- Finish event " << std::endl;
330}
static const char *const TMCProcessName[kMaxMCProcess]
Definition: TMCProcess.h:99
#define gMC
Definition: TVirtualMC.h:931
virtual void InitMC()
Initialize MC info.
Definition: TMCVerbose.cxx:119
virtual void AddIons()
Add ions info.
Definition: TMCVerbose.cxx:182
virtual void FinishEvent()
Finish of an event info.
Definition: TMCVerbose.cxx:326
void PrintTrackInfo() const
Prints track information.
Definition: TMCVerbose.cxx:74
virtual void AddParticles()
Add particles info.
Definition: TMCVerbose.cxx:173
virtual void BeginPrimary()
Begin of a primary track info.
Definition: TMCVerbose.cxx:209
virtual void GeneratePrimaries()
Generate primaries info.
Definition: TMCVerbose.cxx:191
virtual void RunMC(Int_t nofEvents)
MC run info.
Definition: TMCVerbose.cxx:128
virtual void ConstructGeometry()
Construct geometry info.
Definition: TMCVerbose.cxx:146
Int_t fLevel
Verbose level.
Definition: TMCVerbose.h:76
virtual void EndOfEvent()
End of event info.
Definition: TMCVerbose.cxx:317
virtual void FinishRun()
Finish MC run info.
Definition: TMCVerbose.cxx:137
void PrintStepHeader() const
Prints the header for stepping information.
Definition: TMCVerbose.cxx:98
virtual void InitGeometry()
Initialize geometry info.
Definition: TMCVerbose.cxx:164
Int_t fStepNumber
Current step number.
Definition: TMCVerbose.h:77
virtual void FinishPrimary()
Finish of a primary track info.
Definition: TMCVerbose.cxx:308
TMCVerbose()
Default constructor.
Definition: TMCVerbose.cxx:49
virtual void BeginEvent()
Begin event info.
Definition: TMCVerbose.cxx:200
virtual ~TMCVerbose()
Destructor.
Definition: TMCVerbose.cxx:54
virtual void ConstructOpGeometry()
Construct geometry for optical physics info.
Definition: TMCVerbose.cxx:155
void PrintBanner() const
Prints banner for track information.
Definition: TMCVerbose.cxx:63
virtual void Stepping()
Stepping info.
Definition: TMCVerbose.cxx:238
virtual void PreTrack()
Begin of each track info.
Definition: TMCVerbose.cxx:218
virtual void PostTrack()
Finish of each track info.
Definition: TMCVerbose.cxx:299