VMC Examples
Version 6.8
Toggle main menu visibility
Loading...
Searching...
No Matches
examples
E02
src
Ex02Particle.cxx
Go to the documentation of this file.
1
//------------------------------------------------
2
// The Virtual Monte Carlo examples
3
// Copyright (C) 2007 - 2014 Ivana Hrivnacova
4
// All rights reserved.
5
//
6
// For the licensing terms see geant4_vmc/LICENSE.
7
// Contact: root-vmc@cern.ch
8
//-------------------------------------------------
9
10
/// \file Ex02Particle.cxx
11
/// \brief Implementation of the Ex02Particle class
12
///
13
/// Geant4 ExampleN02 adapted to Virtual Monte Carlo
14
///
15
/// \date 21/04/2002
16
/// \author I. Hrivnacova; IPN, Orsay
17
18
#include "
Ex02Particle.h
"
19
20
#include <TObjArray.h>
21
#include <TParticle.h>
22
23
#include <iostream>
24
25
using namespace
std;
26
27
/// \cond CLASSIMP
28
ClassImp(
Ex02Particle
)
29
/// \endcond
30
31
//_____________________________________________________________________________
32
Ex02Particle
::
Ex02Particle
(Int_t
id
, TParticle* particle)
33
:
fID
(
id
),
fParticle
(particle),
fMother
(),
fDaughters
()
34
{
35
/// Standard constructor
36
/// \param id The particle id
37
/// \param particle The particle definition (TParticle)
38
}
39
40
//_____________________________________________________________________________
41
Ex02Particle::Ex02Particle
(Int_t
id
, TParticle* particle,
Ex02Particle
* mother)
42
:
fID
(id),
fParticle
(particle),
fMother
(mother),
fDaughters
()
43
{
44
/// Standard constructor
45
/// \param id The particle id
46
/// \param particle The particle definition (TParticle)
47
/// \param mother The particle mother
48
}
49
50
//_____________________________________________________________________________
51
Ex02Particle::Ex02Particle
() :
fID
(0),
fParticle
(0),
fMother
(),
fDaughters
()
52
{
53
/// Default constructor
54
}
55
56
//_____________________________________________________________________________
57
Ex02Particle::~Ex02Particle
()
58
{
59
/// Destructor
60
61
delete
fParticle
;
62
}
63
64
//
65
// public methods
66
//
67
68
//_____________________________________________________________________________
69
void
Ex02Particle::SetMother
(
Ex02Particle
* particle)
70
{
71
/// Set particle mother
72
/// \param particle The mother particle
73
74
fMother
.SetObject(particle);
75
}
76
77
//_____________________________________________________________________________
78
void
Ex02Particle::AddDaughter
(
Ex02Particle
* particle)
79
{
80
/// Add particles daughter
81
/// \param particle The daughter particle
82
83
fDaughters
.Add(particle);
84
}
85
86
//_____________________________________________________________________________
87
void
Ex02Particle::Print
(Option_t*
/*option*/
)
const
88
{
89
/// Print particle properties.
90
91
cout <<
"Track ID: "
<<
fID
<< endl;
92
93
fParticle
->Print();
94
95
if
(
GetMother
()) {
96
cout <<
"Mother: "
<<
GetMother
()->
GetParticle
()->GetName()
97
<<
" with ID: "
<<
GetMother
()->
GetID
() << endl;
98
}
99
else
100
cout <<
"Primary "
<< endl;
101
102
cout <<
"Number of daughters: "
<<
GetNofDaughters
() << endl;
103
cout << endl;
104
}
105
106
//_____________________________________________________________________________
107
void
Ex02Particle::PrintDaughters
()
const
108
{
109
/// Print particles daughters.
110
111
for
(Int_t i = 0; i <
GetNofDaughters
(); i++) {
112
cout << i <<
"th daughter: "
<< endl;
113
if
(
GetDaughter
(i))
114
GetDaughter
(i)->
Print
();
115
else
116
cout <<
"0x0"
;
117
}
118
cout << endl;
119
}
120
121
//_____________________________________________________________________________
122
Int_t
Ex02Particle::GetID
()
const
123
{
124
/// \return The particle Id.
125
126
return
fID
;
127
}
128
129
//_____________________________________________________________________________
130
TParticle*
Ex02Particle::GetParticle
()
const
131
{
132
/// \return The particle definition (TParticle).
133
134
return
fParticle
;
135
}
136
137
//_____________________________________________________________________________
138
Ex02Particle
*
Ex02Particle::GetMother
()
const
139
{
140
/// \return The particle mother.
141
142
return
(
Ex02Particle
*)
fMother
.GetObject();
143
}
144
145
//_____________________________________________________________________________
146
Int_t
Ex02Particle::GetNofDaughters
()
const
147
{
148
/// \return The number of daughters.
149
150
return
fDaughters
.GetEntriesFast();
151
}
152
153
//_____________________________________________________________________________
154
Ex02Particle
*
Ex02Particle::GetDaughter
(Int_t i)
const
155
{
156
/// \return \em i -th daughter
157
/// \param i The daughter index
158
159
if
(i < 0 || i >=
GetNofDaughters
())
160
Fatal(
"GetDaughter"
,
"Index out of range"
);
161
162
return
(
Ex02Particle
*)
fDaughters
.At(i);
163
}
Ex02Particle.h
Definition of the Ex02Particle class.
Ex02Particle
Extended TParticle with pointers to mother and daughter particles.
Definition
Ex02Particle.h:34
Ex02Particle::SetMother
void SetMother(Ex02Particle *particle)
Definition
Ex02Particle.cxx:69
Ex02Particle::~Ex02Particle
virtual ~Ex02Particle()
Definition
Ex02Particle.cxx:57
Ex02Particle::GetID
Int_t GetID() const
Definition
Ex02Particle.cxx:122
Ex02Particle::GetNofDaughters
Int_t GetNofDaughters() const
Definition
Ex02Particle.cxx:146
Ex02Particle::GetDaughter
Ex02Particle * GetDaughter(Int_t i) const
Definition
Ex02Particle.cxx:154
Ex02Particle::Ex02Particle
Ex02Particle(Int_t id, TParticle *particle)
Definition
Ex02Particle.cxx:32
Ex02Particle::PrintDaughters
void PrintDaughters() const
Definition
Ex02Particle.cxx:107
Ex02Particle::Print
virtual void Print(Option_t *option="") const
Definition
Ex02Particle.cxx:87
Ex02Particle::fID
Int_t fID
The particle Id.
Definition
Ex02Particle.h:56
Ex02Particle::GetMother
Ex02Particle * GetMother() const
Definition
Ex02Particle.cxx:138
Ex02Particle::fDaughters
TRefArray fDaughters
The particle daughters.
Definition
Ex02Particle.h:59
Ex02Particle::fParticle
TParticle * fParticle
The particle definition.
Definition
Ex02Particle.h:57
Ex02Particle::Ex02Particle
Ex02Particle()
Definition
Ex02Particle.cxx:51
Ex02Particle::GetParticle
TParticle * GetParticle() const
Definition
Ex02Particle.cxx:130
Ex02Particle::fMother
TRef fMother
The particle mother.
Definition
Ex02Particle.h:58
Ex02Particle::AddDaughter
void AddDaughter(Ex02Particle *particle)
Definition
Ex02Particle.cxx:78
Generated on
for VMC Examples by
1.17.0