Logo ROOT   6.16/01
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
35
36////////////////////////////////////////////////////////////////////////////////
37/// Standard constructor
38
40 : TObject(),
41 fLevel(level),
42 fStepNumber(0)
43{
44}
45
46////////////////////////////////////////////////////////////////////////////////
47/// Default constructor
48
50 : TObject(),
51 fLevel(0),
52 fStepNumber(0)
53{
54}
55
56////////////////////////////////////////////////////////////////////////////////
57/// Destructor
58
60{
61}
62
63//
64// private methods
65//
66
67////////////////////////////////////////////////////////////////////////////////
68/// Prints banner for track information
69
71{
72 std::cout << std::endl;
73 for (Int_t i=0; i<10; i++) std::cout << "**********";
74 std::cout << std::endl;
75}
76
77////////////////////////////////////////////////////////////////////////////////
78/// Prints track information
79
81{
82 // Particle
83 //
84 std::cout << " Particle = ";
85 TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(gMC->TrackPid());
86 if (particle)
87 std::cout << particle->GetName() << " ";
88 else
89 std::cout << "unknown" << " ";
90
91 // Track ID
92 //
93 std::cout << " Track ID = " << gMC->GetStack()->GetCurrentTrackNumber() << " ";
94
95 // Parent ID
96 //
97 std::cout << " Parent ID = " << gMC->GetStack()->GetCurrentParentTrackNumber();
98}
99
100////////////////////////////////////////////////////////////////////////////////
101/// Prints the header for stepping information
102
104{
105 std::cout << "Step# "
106 << "X(cm) "
107 << "Y(cm) "
108 << "Z(cm) "
109 << "KinE(MeV) "
110 << "dE(MeV) "
111 << "Step(cm) "
112 << "TrackL(cm) "
113 << "Volume "
114 << "Process "
115 << std::endl;
116}
117
118//
119// public methods
120//
121
122////////////////////////////////////////////////////////////////////////////////
123/// Initialize MC info.
124
126{
127 if (fLevel>0)
128 std::cout << "--- Init MC " << std::endl;
129}
130
131////////////////////////////////////////////////////////////////////////////////
132/// MC run info.
133
135{
136 if (fLevel>0)
137 std::cout << "--- Run MC for " << nofEvents << " events" << std::endl;
138}
139
140////////////////////////////////////////////////////////////////////////////////
141/// Finish MC run info.
142
144{
145 if (fLevel>0)
146 std::cout << "--- Finish Run MC " << std::endl;
147}
148
149////////////////////////////////////////////////////////////////////////////////
150/// Construct geometry info
151
153{
154 if (fLevel>0)
155 std::cout << "--- Construct geometry " << std::endl;
156}
157
158////////////////////////////////////////////////////////////////////////////////
159/// Construct geometry for optical physics info
160
162{
163 if (fLevel>0)
164 std::cout << "--- Construct geometry for optical processes" << std::endl;
165}
166
167////////////////////////////////////////////////////////////////////////////////
168/// Initialize geometry info
169
171{
172 if (fLevel>0)
173 std::cout << "--- Init geometry " << std::endl;
174}
175
176////////////////////////////////////////////////////////////////////////////////
177/// Add particles info
178
180{
181 if (fLevel>0)
182 std::cout << "--- Add particles " << std::endl;
183}
184
185////////////////////////////////////////////////////////////////////////////////
186/// Add ions info
187
189{
190 if (fLevel>0)
191 std::cout << "--- Add ions " << std::endl;
192}
193
194////////////////////////////////////////////////////////////////////////////////
195/// Generate primaries info
196
198{
199 if (fLevel>0)
200 std::cout << "--- Generate primaries " << std::endl;
201}
202
203////////////////////////////////////////////////////////////////////////////////
204/// Begin event info
205
207{
208 if (fLevel>0)
209 std::cout << "--- Begin event " << std::endl;
210}
211
212////////////////////////////////////////////////////////////////////////////////
213/// Begin of a primary track info
214
216{
217 if (fLevel>1)
218 std::cout << "--- Begin primary " << std::endl;
219}
220
221////////////////////////////////////////////////////////////////////////////////
222/// Begin of each track info
223
225{
226 if (fLevel>2) {
227 PrintBanner();
229 PrintBanner();
231
232 fStepNumber = 0;
233
234 return;
235 }
236
237 if (fLevel>1)
238 std::cout << "--- Pre track " << std::endl;
239}
240
241////////////////////////////////////////////////////////////////////////////////
242/// Stepping info
243
245{
246 if (fLevel>2) {
247
248#if __GNUC__ >= 3
249 std::cout << std::fixed;
250#endif
251
252 // Step number
253 //
254 std::cout << "#" << std::setw(4) << fStepNumber++ << " ";
255
256 // Position
257 //
258 Double_t x, y, z;
259 gMC->TrackPosition(x, y, z);
260 std::cout << std::setw(8) << std::setprecision(3) << x << " "
261 << std::setw(8) << std::setprecision(3) << y << " "
262 << std::setw(8) << std::setprecision(3) << z << " ";
263
264 // Kinetic energy
265 //
266 Double_t px, py, pz, etot;
267 gMC->TrackMomentum(px, py, pz, etot);
268 Double_t ekin = etot - gMC->TrackMass();
269 std::cout << std::setw(9) << std::setprecision(4) << ekin*1e03 << " ";
270
271 // Energy deposit
272 //
273 std::cout << std::setw(9) << std::setprecision(4) << gMC->Edep()*1e03 << " ";
274
275 // Step length
276 //
277 std::cout << std::setw(8) << std::setprecision(3) << gMC->TrackStep() << " ";
278
279 // Track length
280 //
281 std::cout << std::setw(8) << std::setprecision(3) << gMC->TrackLength() << " ";
282
283 // Volume
284 //
285 if (gMC->CurrentVolName() != 0)
286 std::cout << std::setw(4) << gMC->CurrentVolName() << " ";
287 else
288 std::cout << std::setw(4) << "None" << " ";
289
290 // Process
291 //
292 TArrayI processes;
293 Int_t nofProcesses = gMC->StepProcesses(processes);
294 if (nofProcesses > 0)
295 std::cout << TMCProcessName[processes[nofProcesses-1]];
296
297 std::cout << std::endl;
298 }
299}
300
301////////////////////////////////////////////////////////////////////////////////
302/// Finish of each track info
303
305{
306 if (fLevel==2)
307 std::cout << "--- Post track " << std::endl;
308}
309
310////////////////////////////////////////////////////////////////////////////////
311/// Finish of a primary track info
312
314{
315 if (fLevel==2)
316 std::cout << "--- Finish primary " << std::endl;
317}
318
319////////////////////////////////////////////////////////////////////////////////
320/// Finish of an event info
321
323{
324 if (fLevel>0)
325 std::cout << "--- Finish event " << std::endl;
326}
327
int Int_t
Definition: RtypesCore.h:41
double Double_t
Definition: RtypesCore.h:55
#define ClassImp(name)
Definition: Rtypes.h:363
static const char *const TMCProcessName[kMaxMCProcess]
Definition: TMCProcess.h:91
#define gMC
Definition: TVirtualMC.h:952
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.
Class for printing a detailed information from MC application.
Definition: TMCVerbose.h:31
virtual void InitMC()
Initialize MC info.
Definition: TMCVerbose.cxx:125
virtual void AddIons()
Add ions info.
Definition: TMCVerbose.cxx:188
virtual void FinishEvent()
Finish of an event info.
Definition: TMCVerbose.cxx:322
void PrintTrackInfo() const
Prints track information.
Definition: TMCVerbose.cxx:80
virtual void AddParticles()
Add particles info.
Definition: TMCVerbose.cxx:179
virtual void BeginPrimary()
Begin of a primary track info.
Definition: TMCVerbose.cxx:215
virtual void GeneratePrimaries()
Generate primaries info.
Definition: TMCVerbose.cxx:197
virtual void RunMC(Int_t nofEvents)
MC run info.
Definition: TMCVerbose.cxx:134
virtual void ConstructGeometry()
Construct geometry info.
Definition: TMCVerbose.cxx:152
Int_t fLevel
Verbose level.
Definition: TMCVerbose.h:66
virtual void FinishRun()
Finish MC run info.
Definition: TMCVerbose.cxx:143
void PrintStepHeader() const
Prints the header for stepping information.
Definition: TMCVerbose.cxx:103
virtual void InitGeometry()
Initialize geometry info.
Definition: TMCVerbose.cxx:170
Int_t fStepNumber
Current step number.
Definition: TMCVerbose.h:67
virtual void FinishPrimary()
Finish of a primary track info.
Definition: TMCVerbose.cxx:313
TMCVerbose()
Default constructor.
Definition: TMCVerbose.cxx:49
virtual void BeginEvent()
Begin event info.
Definition: TMCVerbose.cxx:206
virtual ~TMCVerbose()
Destructor.
Definition: TMCVerbose.cxx:59
virtual void ConstructOpGeometry()
Construct geometry for optical physics info.
Definition: TMCVerbose.cxx:161
void PrintBanner() const
Prints banner for track information.
Definition: TMCVerbose.cxx:70
virtual void Stepping()
Stepping info.
Definition: TMCVerbose.cxx:244
virtual void PreTrack()
Begin of each track info.
Definition: TMCVerbose.cxx:224
virtual void PostTrack()
Finish of each track info.
Definition: TMCVerbose.cxx:304
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