BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
MpdMCStack.cxx
Go to the documentation of this file.
1
// -------------------------------------------------------------------------
2
// ----- MpdMCStack source file -----
3
// ----- Created 09/10/08 by M. Al-Turany -----
4
// -------------------------------------------------------------------------
5
6
#include "
MpdMCStack.h
"
7
#ifdef BMNROOT
8
#include "CbmMCTrack.h"
9
#else
10
#include "FairMCTrack.h"
11
#endif
12
#include "FairLogger.h"
13
#include "FairRootManager.h"
14
#include "
TClonesArray.h
"
15
#include "
TDatabasePDG.h
"
16
#include "
TEveManager.h
"
17
#include "
TGeoTrack.h
"
18
#include "
TParticlePDG.h
"
19
20
#include <iostream>
21
using namespace
std
;
22
23
// ----- Default constructor -------------------------------------------
24
MpdMCStack::MpdMCStack
() {}
25
26
// ----- Standard constructor ------------------------------------------
27
MpdMCStack::MpdMCStack
(
const
char
* name,
Int_t
iVerbose)
28
:
FairTask
(name, iVerbose)
29
,
fEveTrList
(new
TObjArray
(16))
30
{}
31
32
// ----- Destructor ----------------------------------------------------
33
MpdMCStack::~MpdMCStack
() {}
34
35
// -------------------------------------------------------------------------
36
InitStatus
MpdMCStack::Init
()
37
{
38
if
(fVerbose > 1)
39
cout <<
"MpdMCStack::Init()"
<< endl;
40
41
FairRootManager* fManager = FairRootManager::Instance();
42
43
fTrackList
= (
TClonesArray
*)fManager->GetObject(
"MCTrack"
);
44
if
(
fTrackList
== 0) {
45
LOG(error) <<
"MpdMCStack::Init() branch "
<< GetName() <<
" not found! Task will be deactivated"
;
46
SetActive(
kFALSE
);
47
}
48
if
(fVerbose > 2)
49
cout <<
"MpdMCStack::Init() get track list"
<<
fTrackList
<< endl;
50
51
fEventManager
=
MpdEventManager::Instance
();
52
if
(fVerbose > 2)
53
cout <<
"MpdMCStack::Init() get instance of MpdEventManager"
<< endl;
54
55
fPro
=
new
FairGeanePro();
56
gMC3
= (TGeant3*)gMC;
57
58
x1
[0] = 0;
59
x1
[1] = 0;
60
x1
[2] = 0;
61
p1
[0] = 0;
62
p1
[1] = 0;
63
p1
[2] = 0;
64
x2
[0] = 0;
65
x2
[1] = 0;
66
x2
[2] = 0;
67
p2
[0] = 0;
68
p2
[1] = 0;
69
p2
[2] = 0;
70
for
(
Int_t
i
= 0;
i
< 15;
i
++)
71
ein
[
i
] = 0;
72
73
// Float_t length[1];
74
// length[0] = 100.0;
75
// gMC3->Eufill(1, ein, length);
76
77
fTrajFilter
= FairTrajFilter::Instance();
78
79
if
(IsActive())
80
return
kSUCCESS;
81
else
82
return
kERROR;
83
}
84
85
// -------------------------------------------------------------------------
86
void
MpdMCStack::Exec
(
Option_t
*
/*option*/
)
87
{
88
if
(!IsActive())
89
return
;
90
91
if
(fVerbose > 1)
92
cout <<
"MpdMCStack::Exec"
<< endl;
93
Reset
();
94
95
for
(
Int_t
i
= 0;
i
<
fTrackList
->GetEntriesFast();
i
++) {
96
if
(fVerbose > 2)
97
cout <<
"MpdMCStack::Exec "
<<
i
<< endl;
98
99
#ifdef BMNROOT
100
CbmMCTrack
* tr = (
CbmMCTrack
*)
fTrackList
->At(
i
);
101
#else
102
FairMCTrack* tr = (FairMCTrack*)
fTrackList
->At(
i
);
103
#endif
104
105
TVector3
Ptot;
106
tr->
GetMomentum
(Ptot);
107
Int_t
MotherId = tr->
GetMotherId
();
108
TVector3
Vertex;
109
tr->
GetStartVertex
(Vertex);
110
111
Double_t
time = tr->
GetStartT
() * 1e-09;
112
x1
[0] = Vertex.x();
113
x1
[1] = Vertex.y();
114
x1
[2] = Vertex.z();
115
p1
[0] = Ptot.
Px
();
116
p1
[1] = Ptot.
Py
();
117
p1
[2] = Ptot.
Pz
();
118
119
// TParticle* P = (TParticle*) tr->GetParticle();
120
TParticlePDG
* fParticlePDG =
TDatabasePDG::Instance
()->
GetParticle
(tr->
GetPdgCode
());
121
122
Double_t
mass = 0, ene = 0;
123
if
(fParticlePDG)
124
mass = fParticlePDG->
Mass
();
125
if
(mass >= 0)
126
ene =
TMath::Sqrt
(mass * mass + Ptot.
Mag2
());
127
128
// TParticle(Int_t pdg, Int_t status, Int_t mother1, Int_t mother2, Int_t daughter1, Int_t daughter2, Double_t
129
// px, Double_t py, Double_t pz, Double_t etot, Double_t vx, Double_t vy, Double_t vz, Double_t time)
130
TParticle
* P =
new
TParticle
(tr->
GetPdgCode
(),
i
, MotherId, -1, -1, -1, Ptot.
Px
(), Ptot.
Py
(), Ptot.
Pz
(), ene,
131
Vertex.x(), Vertex.z(), Vertex.z(), time);
132
// Int_t particle_mother_id = P->GetMother(0);
133
Float_t
particle_energy = P->
Energy
();
134
fEventManager
->ExpandEnergyLimits(particle_energy);
135
136
if
(fVerbose > 2)
137
cout <<
"MinEnergyLimit "
<<
fEventManager
->GetMinEnergyLimit() <<
" MaxEnergyLimit "
138
<<
fEventManager
->GetMaxEnergyLimit() << endl;
139
140
if
((
fEventManager
->IsPriOnly() && (P->
GetMother
(0) > -1)))
141
continue
;
142
if
((
fEventManager
->fCurrentPDG.size() != 0)
143
&& (
fEventManager
->fCurrentPDG.find(tr->
GetPdgCode
()) ==
fEventManager
->fCurrentPDG.end()))
144
continue
;
145
if
(fVerbose > 2)
146
cout <<
"PEnergy "
<< particle_energy <<
" Min "
<<
fEventManager
->GetMinEnergyCut() <<
" Max "
147
<<
fEventManager
->GetMaxEnergyCut() << endl;
148
if
((particle_energy < fEventManager->GetMinEnergyCut())
149
|| (particle_energy >
fEventManager
->GetMaxEnergyCut()))
150
continue
;
151
152
// Int_t Np = tr->GetNpoints();
153
fTrList
=
GetTrGroup
(P);
154
TEveTrack
* track =
new
TEveTrack
(P, tr->
GetPdgCode
(),
fTrPr
);
155
track->
SetLineColor
(
fEventManager
->Color(tr->
GetPdgCode
()));
156
157
// PROPAGATION
158
// Int_t GeantCode = TDatabasePDG::Instance()->ConvertPdgToGeant3(tr->GetPdgCode());
159
// gMC3->Ertrak(x1, p1, x2, p2,G eantCode, "L");
160
fPro
->SetDestinationLength(100.0);
161
fPro
->Propagate(
x1
,
p1
,
x2
,
p2
, tr->
GetPdgCode
());
162
TGeoTrack
* tr1 =
fTrajFilter
->GetCurrentTrk();
163
164
const
Double_t
* point;
165
Int_t
Np = tr1->
GetNpoints
();
166
for
(
Int_t
n
= 0;
n
< Np;
n
++) {
167
point = tr1->
GetPoint
(
n
);
168
track->
SetPoint
(
n
, point[0], point[1], point[2]);
169
TEveVector
pos =
TEveVector
(point[0], point[1], point[2]);
170
171
TEvePathMark
* path =
new
TEvePathMark
();
172
path->fV = pos;
173
path->fTime = point[3];
174
if
(
n
== 0) {
175
TEveVector
Mom =
TEveVector
(P->
Px
(), P->
Py
(), P->
Pz
());
176
path->fP = Mom;
177
}
178
179
track->
AddPathMark
(*path);
180
if
(fVerbose > 3)
181
cout <<
"Path marker added "
<< path << endl;
182
}
183
184
fTrList
->AddElement(track);
185
if
(fVerbose > 3)
186
cout <<
"Track added "
<< track->
GetName
() << endl;
187
}
188
189
// for (Int_t i = 0; i < fEveTrList->GetEntriesFast(); i++)
190
//{
191
// TEveTrackList* TrListIn = (TEveTrackList*) fEveTrList->At(i);
192
// TrListIn->FindMomentumLimits(TrListIn, kFALSE);
193
// }
194
195
// gEve->Redraw3D(kFALSE);
196
}
197
198
// -------------------------------------------------------------------------
199
void
MpdMCStack::SetParContainers
() {}
200
201
// -------------------------------------------------------------------------
202
void
MpdMCStack::Finish
() {}
203
204
// -------------------------------------------------------------------------
205
void
MpdMCStack::Reset
()
206
{
207
for
(
Int_t
i
= 0;
i
<
fEveTrList
->GetEntriesFast();
i
++) {
208
TEveTrackList
* ele = (
TEveTrackList
*)
fEveTrList
->At(
i
);
209
gEve
->RemoveElement(ele,
fEventManager
);
210
}
211
fEveTrList
->Clear();
212
}
213
214
TEveTrackList
*
MpdMCStack::GetTrGroup
(
TParticle
* P)
215
{
216
fTrList
= 0;
217
for
(
Int_t
i
= 0;
i
<
fEveTrList
->GetEntriesFast();
i
++) {
218
TEveTrackList
* TrListIn = (
TEveTrackList
*)
fEveTrList
->At(
i
);
219
220
if
(strcmp(TrListIn->
GetName
(), P->
GetName
()) == 0) {
221
fTrList
= TrListIn;
222
break
;
223
}
224
}
225
226
if
(
fTrList
== 0) {
227
fTrPr
=
new
TEveTrackPropagator
();
228
fTrList
=
new
TEveTrackList
(P->
GetName
(),
fTrPr
);
229
fTrList
->SetMainColor(
fEventManager
->Color(P->
GetPdgCode
()));
230
fTrList
->SetRnrLine(
kTRUE
);
231
232
fEveTrList
->Add(
fTrList
);
233
gEve
->AddElement(
fTrList
,
fEventManager
);
234
}
235
236
return
fTrList
;
237
}
i
int i
Definition
P4_F32vec4.h:22
Int_t
int Int_t
Float_t
float Float_t
kFALSE
constexpr Bool_t kFALSE
Double_t
double Double_t
kTRUE
constexpr Bool_t kTRUE
Option_t
const char Option_t
TClonesArray.h
TDatabasePDG.h
TEveManager.h
gEve
R__EXTERN TEveManager * gEve
TEvePathMark
TEvePathMarkT< Float_t > TEvePathMark
TEveVector
TEveVectorT< Float_t > TEveVector
TGeoTrack.h
TParticlePDG.h
CbmMCTrack
CbmMCTrack.h.
Definition
CbmMCTrack.h:26
CbmMCTrack::GetMomentum
void GetMomentum(TVector3 &momentum) const
Definition
CbmMCTrack.h:139
CbmMCTrack::GetMotherId
Int_t GetMotherId() const
Definition
CbmMCTrack.h:57
CbmMCTrack::GetStartT
Double_t GetStartT() const
Definition
CbmMCTrack.h:64
CbmMCTrack::GetStartVertex
void GetStartVertex(TVector3 &vertex) const
Definition
CbmMCTrack.h:149
CbmMCTrack::GetPdgCode
Int_t GetPdgCode() const
Accessors.
Definition
CbmMCTrack.h:56
FairTask
MpdEventManager::Instance
static MpdEventManager * Instance()
Definition
MpdEventManager.cxx:30
MpdMCStack::ein
Float_t ein[15]
Definition
MpdMCStack.h:52
MpdMCStack::GetTrGroup
TEveTrackList * GetTrGroup(TParticle *P)
Definition
MpdMCStack.cxx:214
MpdMCStack::MpdMCStack
MpdMCStack()
Default constructor.
Definition
MpdMCStack.cxx:24
MpdMCStack::fTrList
TEveTrackList * fTrList
Definition
MpdMCStack.h:50
MpdMCStack::~MpdMCStack
virtual ~MpdMCStack()
Destructor.
Definition
MpdMCStack.cxx:33
MpdMCStack::gMC3
TGeant3 * gMC3
Definition
MpdMCStack.h:53
MpdMCStack::fPro
FairGeanePro * fPro
Definition
MpdMCStack.h:54
MpdMCStack::fEveTrList
TObjArray * fEveTrList
Definition
MpdMCStack.h:48
MpdMCStack::Init
virtual InitStatus Init()
Definition
MpdMCStack.cxx:36
MpdMCStack::Exec
virtual void Exec(Option_t *option)
Executed task.
Definition
MpdMCStack.cxx:86
MpdMCStack::fTrajFilter
FairTrajFilter * fTrajFilter
Definition
MpdMCStack.h:55
MpdMCStack::fTrackList
TClonesArray * fTrackList
Definition
MpdMCStack.h:47
MpdMCStack::Finish
virtual void Finish()
Action after each event.
Definition
MpdMCStack.cxx:202
MpdMCStack::x2
Float_t x2[3]
Definition
MpdMCStack.h:52
MpdMCStack::fTrPr
TEveTrackPropagator * fTrPr
Definition
MpdMCStack.h:49
MpdMCStack::Reset
void Reset()
Definition
MpdMCStack.cxx:205
MpdMCStack::p1
Float_t p1[3]
Definition
MpdMCStack.h:52
MpdMCStack::SetParContainers
virtual void SetParContainers()
Definition
MpdMCStack.cxx:199
MpdMCStack::p2
Float_t p2[3]
Definition
MpdMCStack.h:52
MpdMCStack::fEventManager
MpdEventManager * fEventManager
Definition
MpdMCStack.h:45
MpdMCStack::x1
Float_t x1[3]
Definition
MpdMCStack.h:52
TClonesArray
TDatabasePDG::Instance
static TDatabasePDG * Instance()
TDatabasePDG::GetParticle
TParticlePDG * GetParticle(const char *name) const
TEveLine::SetLineColor
void SetLineColor(Color_t col) override
TEveTrackList
TEveTrackPropagator
TEveTrack
TEveTrack::AddPathMark
void AddPathMark(const TEvePathMark &pm)
TGeoTrack
TGeoTrack::GetPoint
Int_t GetPoint(Double_t tof, Double_t *point, Int_t istart=0) const
TGeoTrack::GetNpoints
Int_t GetNpoints() const override
TNamed::GetName
const char * GetName() const override
TObjArray
TParticlePDG
TParticlePDG::Mass
Double_t Mass() const
TParticle
TParticle::Px
Double_t Px() const
TParticle::Py
Double_t Py() const
TParticle::Energy
Double_t Energy() const
TParticle::GetPdgCode
Int_t GetPdgCode() const
TParticle::GetName
const char * GetName() const override
TParticle::Pz
Double_t Pz() const
TParticle::GetMother
Int_t GetMother(Int_t i) const
TPolyMarker3D::SetPoint
void SetPoint(Int_t n, Double_t x, Double_t y, Double_t z)
TPolyMarker3D::GetName
const char * GetName() const override
TVector3
TVector3::Px
Double_t Px() const
TVector3::Py
Double_t Py() const
TVector3::Mag2
Double_t Mag2() const
TVector3::Pz
Double_t Pz() const
MpdMCStack.h
n
*brief user defined string literal for JSON values *sa std::size_t n
Definition
json.hpp:20362
TMath::Sqrt
Double_t Sqrt(Double_t x)
std
Definition
json.hpp:4446
eventdisplay
MpdMCStack.cxx
Generated on
for BmnRoot by
1.17.0