BmnRoot
26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
MpdMCTracks.cxx
Go to the documentation of this file.
1
// -------------------------------------------------------------------------
2
// ----- MpdMCTracks source file -----
3
// ----- Created 10/12/07 by M. Al-Turany -----
4
// -------------------------------------------------------------------------
5
#include "
MpdMCTracks.h
"
6
7
#include "FairLogger.h"
8
#include "FairRootManager.h"
9
#include "
TEveManager.h
"
// for gEve
10
#include "
TEvePathMark.h
"
11
#include "
TEveVector.h
"
12
#include "
TGeoTrack.h
"
13
#include "
TMathBase.h
"
14
#include "
TObjArray.h
"
15
16
#include <iostream>
17
using namespace
std;
18
19
// ----- Default constructor -------------------------------------------
20
MpdMCTracks::MpdMCTracks
()
21
:
FairTask
(
"MpdMCTracks"
, 0)
22
,
fTrackList
(NULL)
23
,
fTrPr
(NULL)
24
,
fEventManager
(NULL)
25
,
fEveTrList
(NULL)
26
,
fTrList
(NULL)
27
{}
28
29
// ----- Standard constructor ------------------------------------------
30
MpdMCTracks::MpdMCTracks
(
const
char
* name,
Int_t
iVerbose)
31
:
FairTask
(name, iVerbose)
32
,
fTrackList
(NULL)
33
,
fTrPr
(NULL)
34
,
fEventManager
(NULL)
35
,
fEveTrList
(new
TObjArray
(16))
36
,
fTrList
(NULL)
37
{}
38
39
// ----- Destructor ----------------------------------------------------
40
MpdMCTracks::~MpdMCTracks
() {}
41
42
// -------------------------------------------------------------------------
43
InitStatus
MpdMCTracks::Init
()
44
{
45
LOG(debug) <<
"MpdMCTracks::Init()"
;
46
47
FairRootManager* fManager = FairRootManager::Instance();
48
fEventManager
=
MpdEventManager::Instance
();
49
LOG(debug1) <<
"MpdMCTracks::Init() get instance of MpdEventManager "
;
50
51
fTrackList
= (
TClonesArray
*)fManager->GetObject(
"GeoTracks"
);
52
if
(
fTrackList
== 0) {
53
LOG(error) <<
"MpdMCTracks::Init() branch "
<< GetName() <<
" not found! Task will be deactivated"
;
54
SetActive(
kFALSE
);
55
}
56
LOG(debug1) <<
"MpdMCTracks::Init() get track list "
<<
fTrackList
;
57
58
if
(IsActive())
59
return
kSUCCESS;
60
else
61
return
kERROR;
62
}
63
64
// -------------------------------------------------------------------------
65
void
MpdMCTracks::Exec
(
Option_t
*
/*option*/
)
66
{
67
if
(!IsActive())
68
return
;
69
LOG(debug1) <<
"MpdMCTracks::Exec"
;
70
71
Reset
();
72
73
TGeoTrack
* tr;
74
const
Double_t
* point;
75
for
(
Int_t
i
= 0;
i
<
fTrackList
->GetEntriesFast();
i
++) {
76
LOG(debug3) <<
"MpdMCTracks::Exec "
<<
i
;
77
tr = (
TGeoTrack
*)
fTrackList
->At(
i
);
78
79
TParticle
* P = (
TParticle
*)tr->
GetParticle
();
80
Int_t
particle_mother_id = P->
GetMother
(0);
81
Float_t
particle_energy = P->
Energy
();
82
fEventManager
->ExpandEnergyLimits(particle_energy);
83
84
LOG(debug3) <<
"MinEnergyLimit "
<<
fEventManager
->GetMinEnergyLimit() <<
" MaxEnergyLimit "
85
<<
fEventManager
->GetMaxEnergyLimit();
86
LOG(debug3) <<
"Particle name: "
<< P->
GetName
() <<
" (pdg = "
<< P->
GetPdgCode
() <<
")"
;
87
LOG(debug3) <<
"Parent track id = "
<< particle_mother_id;
88
LOG(debug3) <<
"Particle energy: "
<< particle_energy <<
" (cut: "
<<
fEventManager
->GetMinEnergyCut() <<
" - "
89
<<
fEventManager
->GetMaxEnergyCut() <<
")"
;
90
LOG(debug3) <<
"Particle Px : Py : Pz = "
<< P->
Px
() <<
" : "
<< P->
Py
() <<
" : "
<< P->
Pz
();
91
LOG(debug3) <<
"Particle Vx : Vy : Vz: "
<< P->
Vx
() <<
" : "
<< P->
Vy
() <<
" : "
<< P->
Vz
();
92
93
if
((
fEventManager
->IsPriOnly() && (particle_mother_id > -1)))
94
continue
;
95
if
((
fEventManager
->fCurrentPDG.size() != 0)
96
&& (
fEventManager
->fCurrentPDG.find(tr->
GetPDG
()) ==
fEventManager
->fCurrentPDG.end()))
97
continue
;
98
if
((particle_energy < fEventManager->GetMinEnergyCut())
99
|| (particle_energy >
fEventManager
->GetMaxEnergyCut()))
100
continue
;
101
102
fTrList
=
GetTrGroup
(P);
103
TEveTrack
* track =
new
TEveTrack
(P, tr->
GetPDG
(),
fTrPr
);
104
track->
SetLineColor
(
fEventManager
->Color(tr->
GetPDG
()));
105
106
Int_t
Np = tr->
GetNpoints
();
107
for
(
Int_t
n = 0; n < Np; n++) {
108
point = tr->
GetPoint
(n);
109
110
track->
SetPoint
(n, point[0], point[1], point[2]);
111
TEveVector
pos =
TEveVector
(point[0], point[1], point[2]);
112
113
TEvePathMark
* path =
new
TEvePathMark
();
114
path->fV = pos;
115
path->fTime = point[3];
116
if
(n == 0) {
117
TEveVector
Mom =
TEveVector
(P->
Px
(), P->
Py
(), P->
Pz
());
118
path->fP = Mom;
119
}
120
121
track->
AddPathMark
(*path);
122
LOG(debug4) <<
"Path marker added: "
<< path <<
". X : Y : Z = "
<< point[0] <<
" : "
<< point[1] <<
" : "
123
<< point[2];
124
125
delete
path;
126
}
127
128
fTrList
->AddElement(track);
129
LOG(debug3) <<
"Track added "
<< track->
GetName
();
130
}
131
132
// for (Int_t i = 0; i < fEveTrList->GetEntriesFast(); i++)
133
//{
134
// TEveTrackList* TrListIn = (TEveTrackList*) fEveTrList->At(i);
135
// TrListIn->FindMomentumLimits(TrListIn, kFALSE);
136
// }
137
138
// gEve->Redraw3D(kFALSE);
139
}
140
141
// -------------------------------------------------------------------------
142
void
MpdMCTracks::SetParContainers
() {}
143
144
// -------------------------------------------------------------------------
145
void
MpdMCTracks::Finish
() {}
146
147
// -------------------------------------------------------------------------
148
void
MpdMCTracks::Reset
()
149
{
150
for
(
Int_t
i
= 0;
i
<
fEveTrList
->GetEntriesFast();
i
++) {
151
TEveTrackList
* ele = (
TEveTrackList
*)
fEveTrList
->At(
i
);
152
gEve
->RemoveElement(ele,
fEventManager
->EveMCTracks);
153
}
154
fEveTrList
->Clear();
155
}
156
157
TEveTrackList
*
MpdMCTracks::GetTrGroup
(
TParticle
* P)
158
{
159
fTrList
= 0;
160
for
(
Int_t
i
= 0;
i
<
fEveTrList
->GetEntriesFast();
i
++) {
161
TEveTrackList
* TrListIn = (
TEveTrackList
*)
fEveTrList
->At(
i
);
162
if
(strcmp(TrListIn->
GetName
(), P->
GetName
()) == 0) {
163
fTrList
= TrListIn;
164
break
;
165
}
166
}
167
168
if
(
fTrList
== 0) {
169
fTrPr
=
new
TEveTrackPropagator
();
170
fTrList
=
new
TEveTrackList
(P->
GetName
(),
fTrPr
);
171
// set track color by particle PDG from MpdEventManager
172
fTrList
->SetMainColor(
fEventManager
->Color(P->
GetPdgCode
()));
173
fTrList
->SetRnrLine(
kTRUE
);
174
fEveTrList
->Add(
fTrList
);
175
176
fEventManager
->AddEventElement(
fTrList
,
MCTrackList
);
177
}
178
179
return
fTrList
;
180
}
MCTrackList
@ MCTrackList
Definition
MpdEventManager.h:25
MpdMCTracks.h
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
TEveManager.h
gEve
R__EXTERN TEveManager * gEve
TEvePathMark.h
TEvePathMark
TEvePathMarkT< Float_t > TEvePathMark
TEveVector.h
TEveVector
TEveVectorT< Float_t > TEveVector
TGeoTrack.h
TMathBase.h
TObjArray.h
FairTask
MpdEventManager::Instance
static MpdEventManager * Instance()
Definition
MpdEventManager.cxx:30
MpdMCTracks::Reset
void Reset()
Definition
MpdMCTracks.cxx:148
MpdMCTracks::Exec
virtual void Exec(Option_t *option)
Executed task.
Definition
MpdMCTracks.cxx:65
MpdMCTracks::fTrackList
TClonesArray * fTrackList
Definition
MpdMCTracks.h:49
MpdMCTracks::GetTrGroup
TEveTrackList * GetTrGroup(TParticle *P)
Definition
MpdMCTracks.cxx:157
MpdMCTracks::~MpdMCTracks
virtual ~MpdMCTracks()
Destructor.
Definition
MpdMCTracks.cxx:40
MpdMCTracks::Finish
virtual void Finish()
Action after each event.
Definition
MpdMCTracks.cxx:145
MpdMCTracks::Init
virtual InitStatus Init()
Definition
MpdMCTracks.cxx:43
MpdMCTracks::fEveTrList
TObjArray * fEveTrList
Definition
MpdMCTracks.h:52
MpdMCTracks::fTrPr
TEveTrackPropagator * fTrPr
Definition
MpdMCTracks.h:50
MpdMCTracks::fTrList
TEveTrackList * fTrList
Definition
MpdMCTracks.h:53
MpdMCTracks::MpdMCTracks
MpdMCTracks()
Default constructor.
Definition
MpdMCTracks.cxx:20
MpdMCTracks::fEventManager
MpdEventManager * fEventManager
Definition
MpdMCTracks.h:51
MpdMCTracks::SetParContainers
virtual void SetParContainers()
Definition
MpdMCTracks.cxx:142
TClonesArray
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
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::Vy
Double_t Vy() const
TParticle::Vx
Double_t Vx() const
TParticle::GetMother
Int_t GetMother(Int_t i) const
TParticle::Vz
Double_t Vz() const
TPolyMarker3D::SetPoint
void SetPoint(Int_t n, Double_t x, Double_t y, Double_t z)
TPolyMarker3D::GetName
const char * GetName() const override
TVirtualGeoTrack::GetParticle
TObject * GetParticle() const
TVirtualGeoTrack::GetPDG
Int_t GetPDG() const
eventdisplay
MpdMCTracks.cxx
Generated on
for BmnRoot by
1.17.0