eic-smear
1.0.3
A collection of ROOT classes for Monte Carlo events and a fast-smearing code simulating detector effects for the Electron-Ion Collider task force
PerfectID.cxx
Go to the documentation of this file.
1
10
#include "
eicsmear/smear/PerfectID.h
"
11
12
#include <set>
13
#include <sstream>
14
#include <string>
15
#include <vector>
16
17
#include <TDatabasePDG.h>
18
#include <TParticlePDG.h>
19
20
namespace
{
21
22
// Returns the name of the particle species with the PDG code,
23
// or the integer converted to a string if the PDG information
24
// cannot be found.
25
std::string particleName(
int
pdg) {
26
std::stringstream stream;
27
TParticlePDG* p = TDatabasePDG::Instance()->GetParticle(pdg);
28
if
(p) {
29
stream << p->GetName();
30
}
else
{
31
stream << pdg;
32
}
// if
33
return
stream.str();
34
}
35
36
}
// anonymous namespace
37
38
namespace
Smear
{
39
40
PerfectID::PerfectID
(
const
std::vector<Int_t>& pdg)
41
: mPdg(pdg.begin(), pdg.end()) {
42
}
43
44
PerfectID::~PerfectID
() {
45
}
46
47
void
PerfectID::Smear
(
const
erhic::VirtualParticle
& in,
ParticleMCS
& out) {
48
// If the PDG list is empty, always copy PDG code.
49
// Otherwise, copy the PDG code if it is in the list.
50
bool
copy =
mPdg
.empty() ||
mPdg
.find(in.
Id
()) !=
mPdg
.end();
51
if
(copy) {
52
out.
SetId
(in.
Id
());
53
}
// if
54
}
55
56
PerfectID
*
PerfectID::Clone
(
const
char
*)
const
{
57
return
new
PerfectID
(*
this
);
58
}
59
60
void
PerfectID::Print
(Option_t*
/* option */
)
const
{
61
std::stringstream stream;
62
stream <<
"Copies PDG ID for "
;
63
if
(
mPdg
.empty()) {
64
stream <<
"all particles"
;
65
}
else
{
66
// List the PDG codes. Insert the first one into the stream,
67
// then loop from the second (if it exists) onward so we
68
// can delimit with commas.
69
std::set<Int_t>::const_iterator iter =
mPdg
.begin();
70
stream << particleName(*iter);
71
for
(++iter; iter !=
mPdg
.end(); ++iter) {
72
stream <<
", "
<< particleName(*iter);
73
}
// for
74
}
// if
75
std::cout << stream.str() << std::endl;
76
}
77
78
void
PerfectID::Insert
(Int_t i) {
79
mPdg
.insert(i);
80
}
81
82
}
// namespace Smear
PerfectID.h
Smear
Definition:
Acceptance.cxx:16
Smear::PerfectID::PerfectID
PerfectID(const std::vector< Int_t > &pdg=std::vector< int >())
Constructor.
Definition:
PerfectID.cxx:40
Smear::PerfectID::mPdg
std::set< Int_t > mPdg
PDG codes to copy. Does not operate on particles with other codes.
Definition:
PerfectID.h:67
erhic::VirtualParticle
Abstract base class for a general particle.
Definition:
VirtualParticle.h:23
Smear::ParticleMCS
A smeared Monte Carlo particle.
Definition:
ParticleMCS.h:27
Smear::PerfectID::Print
virtual void Print(Option_t *="") const
Prints information about this object.
Definition:
PerfectID.cxx:60
Smear::PerfectID::Smear
virtual void Smear(const erhic::VirtualParticle &, ParticleMCS &)
Copies the PDG code from the ParticleMC to the ParticleMCS if either the PDG code is in the initialis...
Definition:
PerfectID.cxx:47
Smear::PerfectID::Insert
virtual void Insert(Int_t)
Add a PDG code to the list.
Definition:
PerfectID.cxx:78
Smear::PerfectID
Smearer that copies the PDG ID of a particle to a smeared particle with no modification.
Definition:
PerfectID.h:27
Smear::PerfectID::~PerfectID
virtual ~PerfectID()
Destructor.
Definition:
PerfectID.cxx:44
Smear::ParticleMCS::SetId
virtual void SetId(Int_t)
Definition:
ParticleMCS.h:253
Smear::PerfectID::Clone
virtual PerfectID * Clone(const char *="") const
Returns a new copy of this object.
Definition:
PerfectID.cxx:56
erhic::VirtualParticle::Id
virtual Pid Id() const =0
Returns identity information for the Particle species.
src
smear
PerfectID.cxx
Generated on Fri Jan 31 2020 15:11:34 for eic-smear by
1.8.17