BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
MpdPlutoGenerator.cxx
Go to the documentation of this file.
1
// -------------------------------------------------------------------------
2
// ----- MpdPlutoGenerator source file -----
3
// ----- Created 13/07/04 by V. Friese / D.Bertini -----
4
// ----- Modified from FairPlutoGenerator for MPD by V. Zhezher -----
5
// -------------------------------------------------------------------------
6
#include "
MpdPlutoGenerator.h
"
7
8
#include "FairPrimaryGenerator.h"
9
#include "PParticle.h"
10
#include "
TClonesArray.h
"
11
#include "
TDatabasePDG.h
"
12
#include "
TFile.h
"
13
#include "
TLorentzVector.h
"
14
#include "
TTree.h
"
15
#include "
TVector3.h
"
16
17
#include <iostream>
18
19
const
Double_t
kProtonMass
= 0.938271998;
20
const
Double_t
kElectronMass
= 0.00051098892;
21
22
// ----- Default constructor ------------------------------------------
23
MpdPlutoGenerator::MpdPlutoGenerator
()
24
:
FairGenerator
()
25
,
iEvent
(0)
26
,
fEkin
(0)
27
,
fFileName
(NULL)
28
,
fInputFile
(NULL)
29
,
fInputTree
(NULL)
30
,
fParticles
(NULL)
31
{}
32
// ------------------------------------------------------------------------
33
34
// ----- Standard constructor -----------------------------------------
35
MpdPlutoGenerator::MpdPlutoGenerator
(
const
Char_t
* fileName,
Double_t
ekin = 25.0)
36
:
FairGenerator
()
37
,
iEvent
(0)
38
,
fFileName
(fileName)
39
,
fInputFile
(new
TFile
(fileName))
40
,
fInputTree
(NULL)
41
,
fParticles
(new
TClonesArray
(
"PParticle"
, 100))
42
{
43
fEkin
= ekin;
44
fInputTree
= (
TTree
*)
fInputFile
->Get(
"data"
);
45
fInputTree
->SetBranchAddress(
"Particles"
, &
fParticles
);
46
}
47
// ------------------------------------------------------------------------
48
49
// ----- Destructor ---------------------------------------------------
50
MpdPlutoGenerator::~MpdPlutoGenerator
()
51
{
52
CloseInput
();
53
}
54
// ------------------------------------------------------------------------
55
56
// ----- Public method ReadEvent --------------------------------------
57
Bool_t
MpdPlutoGenerator::ReadEvent
(FairPrimaryGenerator* primGen)
58
{
59
60
// Check for input file
61
if
(!
fInputFile
) {
62
cout <<
"-E MpdPlutoGenerator: Input file nor open!"
<< endl;
63
return
kFALSE
;
64
}
65
66
// Check for number of events in input file
67
if
(
iEvent
>
fInputTree
->GetEntries()) {
68
cout <<
"-E MpdPlutoGenerator: No more events in input file!"
<< endl;
69
CloseInput
();
70
return
kFALSE
;
71
}
72
TFile
* g =
gFile
;
73
fInputFile
->cd();
74
fInputTree
->GetEntry(
iEvent
++);
75
g->
cd
();
76
77
// Get PDG database
78
TDatabasePDG
* dataBase =
TDatabasePDG::Instance
();
79
80
// Get number of particle in TClonesrray
81
Int_t
nParts =
fParticles
->GetEntriesFast();
82
83
// Loop over particles in TClonesArray
84
for
(
Int_t
iPart = 0; iPart < nParts; iPart++) {
85
PParticle* part = (PParticle*)
fParticles
->At(iPart);
86
Int_t
pdgType = dataBase->
ConvertGeant3ToPdg
(part->ID());
87
88
// Check if particle type is known to database
89
if
(!pdgType) {
90
cout <<
"-W MpdPlutoGenerator: Unknown type "
<< part->ID() <<
", skipping particle."
<< endl;
91
continue
;
92
}
93
94
TLorentzVector
mom = part->Vect4();
95
Double_t
px = mom.
Px
();
96
Double_t
py = mom.
Py
();
97
Double_t
pz = mom.
Pz
();
98
99
TVector3
vertex = part->getVertex();
100
Double_t
vx = vertex.
x
();
101
Double_t
vy = vertex.
y
();
102
Double_t
vz = vertex.
z
();
103
104
// ---> Calculate beta and gamma for Lorentztransformation
105
Double_t
eBeam =
fEkin
+
kProtonMass
;
106
Double_t
pBeam =
TMath::Sqrt
(eBeam * eBeam -
kProtonMass
*
kProtonMass
);
107
Double_t
betaCM = pBeam / (eBeam +
kProtonMass
);
108
Double_t
gammaCM =
TMath::Sqrt
(1. / (1. - betaCM * betaCM));
109
110
// AZ Double_t mass = kElectronMass;
111
Double_t
mass = dataBase->
GetParticle
(pdgType)->
Mass
();
112
Double_t
e =
sqrt
(mass * mass + px * px + py * py + pz * pz);
113
pz = gammaCM * (pz - betaCM * e);
114
115
// Give track to PrimaryGenerator
116
// primGen->AddTrack(pdgType, px, py, pz, vx, vy, vz);
117
// AZ - keep track of parents
118
Int_t
parentIndx = part->GetParentIndex();
119
primGen->AddTrack(pdgType, px, py, pz, vx, vy, vz, -parentIndx - 10);
120
// AZ
121
122
}
// Loop over particle in event
123
124
return
kTRUE
;
125
}
126
// ------------------------------------------------------------------------
127
128
// ----- Public method SkipEvents --------------------------------------
129
130
Bool_t
MpdPlutoGenerator::SkipEvents
(
Int_t
count)
131
{
132
if
(count <= 0)
133
return
kTRUE
;
134
135
iEvent
= count;
136
137
std::cout <<
"-I MpdPlutoGenerator: Skipped "
<< count <<
" Events!"
<< std::endl;
138
139
return
kTRUE
;
140
}
141
142
// ----- Private method CloseInput ------------------------------------
143
void
MpdPlutoGenerator::CloseInput
()
144
{
145
if
(
fInputFile
) {
146
cout <<
"-I MpdPlutoGenerator: Closing input file "
<<
fFileName
<< endl;
147
fInputFile
->Close();
148
delete
fInputFile
;
149
}
150
fInputFile
= NULL;
151
}
152
// ------------------------------------------------------------------------
kProtonMass
const Double_t kProtonMass
Definition
MpdPlutoGenerator.cxx:19
kElectronMass
const Double_t kElectronMass
Definition
MpdPlutoGenerator.cxx:20
MpdPlutoGenerator.h
Bool_t
bool Bool_t
Int_t
int Int_t
Char_t
char Char_t
kFALSE
constexpr Bool_t kFALSE
Double_t
double Double_t
kTRUE
constexpr Bool_t kTRUE
TClonesArray.h
TDatabasePDG.h
TFile.h
gFile
#define gFile
TLorentzVector.h
TTree.h
TVector3.h
FairGenerator
MpdPlutoGenerator::fParticles
TClonesArray * fParticles
Pointer to input tree.
Definition
MpdPlutoGenerator.h:57
MpdPlutoGenerator::iEvent
Int_t iEvent
Definition
MpdPlutoGenerator.h:52
MpdPlutoGenerator::fEkin
Double_t fEkin
Event number.
Definition
MpdPlutoGenerator.h:53
MpdPlutoGenerator::fInputTree
TTree * fInputTree
Pointer to input file.
Definition
MpdPlutoGenerator.h:56
MpdPlutoGenerator::MpdPlutoGenerator
MpdPlutoGenerator()
Default constructor (should not be used).
Definition
MpdPlutoGenerator.cxx:23
MpdPlutoGenerator::CloseInput
void CloseInput()
Particle array from PLUTO.
Definition
MpdPlutoGenerator.cxx:143
MpdPlutoGenerator::SkipEvents
Bool_t SkipEvents(Int_t count)
Definition
MpdPlutoGenerator.cxx:130
MpdPlutoGenerator::~MpdPlutoGenerator
virtual ~MpdPlutoGenerator()
Destructor.
Definition
MpdPlutoGenerator.cxx:50
MpdPlutoGenerator::fFileName
const Char_t * fFileName
Target energy in lab system.
Definition
MpdPlutoGenerator.h:54
MpdPlutoGenerator::fInputFile
TFile * fInputFile
Input file name.
Definition
MpdPlutoGenerator.h:55
MpdPlutoGenerator::ReadEvent
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)
Reads on event from the input file and pushes the tracks onto the stack.
Definition
MpdPlutoGenerator.cxx:57
TClonesArray
TDatabasePDG
TDatabasePDG::Instance
static TDatabasePDG * Instance()
TDatabasePDG::ConvertGeant3ToPdg
virtual Int_t ConvertGeant3ToPdg(Int_t Geant3Number) const
TDatabasePDG::GetParticle
TParticlePDG * GetParticle(const char *name) const
TDirectoryFile::cd
Bool_t cd() override
TFile
TLorentzVector
TLorentzVector::Px
Double_t Px() const
TLorentzVector::Pz
Double_t Pz() const
TLorentzVector::Py
Double_t Py() const
TParticlePDG::Mass
Double_t Mass() const
TTree
TVector3
TVector3::z
Double_t z() const
TVector3::x
Double_t x() const
TVector3::y
Double_t y() const
sqrt
RVec< PromoteType< T > > sqrt(const RVec< T > &v)
TMath::Sqrt
Double_t Sqrt(Double_t x)
generators
MpdPlutoGenerator.cxx
Generated on
for BmnRoot by
1.17.0