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
Pythia6EventFactory.cxx
Go to the documentation of this file.
1
10
#include <
eicsmear/hadronic/Pythia6EventFactory.h
>
11
12
#include <iostream>
13
#include <memory>
14
#include <string>
15
16
#include <TBranch.h>
17
#include <TClass.h>
18
#include <TCollection.h>
// For TIter
19
#include <TMCParticle.h>
20
#include <TObjArray.h>
21
#include <TProcessID.h>
22
#include <TPythia6.h>
23
#include <TTree.h>
24
25
namespace
erhic
{
26
namespace
hadronic {
27
28
Pythia6EventFactory::~Pythia6EventFactory
() {
29
}
30
31
Pythia6EventFactory::Pythia6EventFactory
(
erhic::EventMCFilterABC
* filter)
32
: mFilter(filter)
33
, mEvent(NULL) {
34
}
35
36
EventPythiaPP
*
Pythia6EventFactory::Create
() {
37
std::auto_ptr<EventPythiaPP> event(
BuildEvent
());
38
if
(
mFilter
.get()) {
39
while
(!
mFilter
->Accept(*event)) {
40
event
.reset(
BuildEvent
());
41
}
// while
42
}
// if
43
return
event
.release();
44
}
45
46
EventPythiaPP
*
Pythia6EventFactory::BuildEvent
() {
47
// Save current object count
48
int
objectNumber = TProcessID::GetObjectCount();
49
// Generate a new PYTHIA event
50
// Read the event kinematics from PYTHIA and create an event
51
TPythia6* pythia = TPythia6::Instance();
52
pythia->GenerateEvent();
53
double
Q2 = pythia->GetPARI(22);
54
double
x1 = pythia->GetPARI(33);
55
double
x2 = pythia->GetPARI(34);
56
std::auto_ptr<EventPythiaPP> event(
new
EventPythiaPP
(Q2, x1, x2));
57
// Get the particles from the current PYTHIA event.
58
// Build a ParticleMC from each and add to the event's list
59
TObjArray* particles = pythia->ImportParticles(
"All"
);
60
TIter iter(particles);
61
TMCParticle* mc(NULL);
62
// Populate particle list
63
while
((mc =
static_cast<
TMCParticle*
>
(iter.Next()))) {
64
if
(mc) {
65
std::auto_ptr<ParticleMC> p(
new
ParticleMC
(*mc));
66
p->SetParentIndex(mc->GetParent());
67
event
->Add(p.get());
68
}
// if
69
}
// while
70
// Test against filter and exit loop if the event passes the filter.
71
// Restore Object count
72
// See example in $ROOTSYS/test/Event.cxx
73
// To save space in the table keeping track of all referenced objects
74
// we assume that our events do not address each other. We reset the
75
// object count to what it was at the beginning of the event.
76
TProcessID::SetObjectCount(objectNumber);
77
return
event
.release();
78
}
79
80
std::string
Pythia6EventFactory::EventName
()
const
{
81
return
EventPythiaPP::Class()->GetName();
82
}
83
84
TBranch*
Pythia6EventFactory::Branch
(TTree&
tree
,
const
std::string& name) {
85
EventPythiaPP
* event(NULL);
86
TBranch* branch =
87
tree
.Branch(name.c_str(),
EventName
().c_str(), &event, 32000, 99);
88
tree
.ResetBranchAddress(branch);
89
return
branch;
90
}
91
92
void
Pythia6EventFactory::Fill
(TBranch& branch) {
93
if
(
mEvent
) {
94
branch.ResetAddress();
95
delete
mEvent
;
96
mEvent
= NULL;
97
}
// if
98
mEvent
=
Create
();
99
branch.SetAddress(&
mEvent
);
100
}
101
102
}
// namespace hadronic
103
}
// namespace erhic
erhic
Definition:
EventDis.cxx:14
Pythia6EventFactory.h
tree
Definition:
tree.py:1
erhic::hadronic::Pythia6EventFactory::Create
virtual EventPythiaPP * Create()
Returns a new event instance.
Definition:
Pythia6EventFactory.cxx:36
erhic::hadronic::Pythia6EventFactory::EventName
virtual std::string EventName() const
Returns the name of the event class created by this factory.
Definition:
Pythia6EventFactory.cxx:80
erhic::hadronic::Pythia6EventFactory::Branch
virtual TBranch * Branch(TTree &tree, const std::string &branchName)
Create a new branch on a tree.
Definition:
Pythia6EventFactory.cxx:84
erhic::hadronic::Pythia6EventFactory::Fill
virtual void Fill(TBranch &)
Fill a tree branch with the current event.
Definition:
Pythia6EventFactory.cxx:92
erhic::hadronic::ParticleMC
A realisation of erhic::VirtualParticle for tracks from a hadron-hadron Monte Carlo event.
Definition:
hadronic/ParticleMC.h:30
erhic::EventMCFilterABC
Abstract base class for a filter on Monte Carlo events.
Definition:
EventMCFilterABC.h:22
erhic::hadronic::Pythia6EventFactory::mFilter
std::auto_ptr< erhic::EventMCFilterABC > mFilter
Definition:
Pythia6EventFactory.h:69
erhic::hadronic::EventPythiaPP
Definition:
hadronic/EventPythia.h:20
erhic::hadronic::Pythia6EventFactory::~Pythia6EventFactory
virtual ~Pythia6EventFactory()
Destructor.
Definition:
Pythia6EventFactory.cxx:28
erhic::hadronic::Pythia6EventFactory::mEvent
EventPythiaPP * mEvent
Definition:
Pythia6EventFactory.h:70
erhic::hadronic::Pythia6EventFactory::Pythia6EventFactory
Pythia6EventFactory(EventMCFilterABC *filter)
Constructor.
Definition:
Pythia6EventFactory.cxx:31
erhic::hadronic::Pythia6EventFactory::BuildEvent
virtual EventPythiaPP * BuildEvent()
Construct an event from the current state of TPythia6.
Definition:
Pythia6EventFactory.cxx:46
src
hadronic
Pythia6EventFactory.cxx
Generated on Fri Jan 31 2020 15:11:34 for eic-smear by
1.8.17