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