Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CEPCSW
Manage
Activity
Members
Labels
Plan
Issues
6
Issue boards
Milestones
Wiki
Code
Merge requests
7
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cepc
CEPCSW
Commits
b856dd5d
Commit
b856dd5d
authored
4 months ago
by
lintao@ihep.ac.cn
Browse files
Options
Downloads
Patches
Plain Diff
GtPythiaTool: add mother and daughter.
parent
23fc4295
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!147
GtPythiaTool: add mother and daughter.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Generator/src/GtPythiaTool.cpp
+85
-61
85 additions, 61 deletions
Generator/src/GtPythiaTool.cpp
with
85 additions
and
61 deletions
Generator/src/GtPythiaTool.cpp
+
85
−
61
View file @
b856dd5d
#include
"GtPythiaTool.hh"
DECLARE_COMPONENT
(
GtPythiaTool
)
StatusCode
GtPythiaTool
::
initialize
()
{
StatusCode
sc
;
m_pythia
=
std
::
make_unique
<
Pythia8
::
Pythia
>
();
// configure with the card file first
m_pythia
->
readFile
(
m_card
.
value
());
// tune with the additional commands
for
(
auto
cmd
:
m_cmds
.
value
())
{
m_pythia
->
readString
(
cmd
);
}
// initialize pythia
m_pythia
->
init
();
return
sc
;
}
StatusCode
GtPythiaTool
::
finalize
()
{
StatusCode
sc
;
return
sc
;
}
bool
GtPythiaTool
::
mutate
(
Gen
::
GenEvent
&
event
)
{
// generate the event
while
(
!
m_pythia
->
next
())
{
// if failed, try again
}
// get the particles
auto
&
pythia_particles
=
m_pythia
->
event
;
// loop over the particles
for
(
int
i
=
0
;
i
<
pythia_particles
.
size
();
++
i
)
{
auto
&
p
=
pythia_particles
[
i
];
// create the MCParticle
auto
mcp
=
event
.
getMCVec
().
create
();
// set the properties
mcp
.
setPDG
(
p
.
id
());
int
status
=
0
;
if
(
p
.
isFinal
())
{
status
=
1
;
}
else
{
status
=
0
;
}
mcp
.
setGeneratorStatus
(
status
);
mcp
.
setCharge
(
p
.
charge
());
mcp
.
setTime
(
p
.
tau
());
mcp
.
setMass
(
p
.
m
());
mcp
.
setVertex
(
edm4hep
::
Vector3d
(
p
.
xProd
(),
p
.
yProd
(),
p
.
zProd
()));
mcp
.
setEndpoint
(
edm4hep
::
Vector3d
(
p
.
xDec
(),
p
.
yDec
(),
p
.
zDec
()));
mcp
.
setMomentum
(
edm4hep
::
Vector3f
(
p
.
px
(),
p
.
py
(),
p
.
pz
()));
}
return
true
;
}
bool
GtPythiaTool
::
finish
()
{
return
true
;
}
bool
GtPythiaTool
::
configure_gentool
()
{
return
true
;
#include
"GtPythiaTool.hh"
DECLARE_COMPONENT
(
GtPythiaTool
)
StatusCode
GtPythiaTool
::
initialize
()
{
StatusCode
sc
;
m_pythia
=
std
::
make_unique
<
Pythia8
::
Pythia
>
();
// configure with the card file first
m_pythia
->
readFile
(
m_card
.
value
());
// tune with the additional commands
for
(
auto
cmd
:
m_cmds
.
value
())
{
m_pythia
->
readString
(
cmd
);
}
// initialize pythia
m_pythia
->
init
();
return
sc
;
}
StatusCode
GtPythiaTool
::
finalize
()
{
StatusCode
sc
;
return
sc
;
}
bool
GtPythiaTool
::
mutate
(
Gen
::
GenEvent
&
event
)
{
// generate the event
while
(
!
m_pythia
->
next
())
{
// if failed, try again
}
// get the particles
auto
&
pythia_particles
=
m_pythia
->
event
;
// loop over the particles
for
(
int
i
=
0
;
i
<
pythia_particles
.
size
();
++
i
)
{
auto
&
p
=
pythia_particles
[
i
];
// create the MCParticle
auto
mcp
=
event
.
getMCVec
().
create
();
// set the properties
mcp
.
setPDG
(
p
.
id
());
int
status
=
0
;
if
(
p
.
isFinal
())
{
status
=
1
;
}
else
{
status
=
0
;
}
mcp
.
setGeneratorStatus
(
status
);
mcp
.
setCharge
(
p
.
charge
());
mcp
.
setTime
(
p
.
tProd
());
mcp
.
setMass
(
p
.
m
());
mcp
.
setVertex
(
edm4hep
::
Vector3d
(
p
.
xProd
(),
p
.
yProd
(),
p
.
zProd
()));
// update the endpoint later
mcp
.
setEndpoint
(
edm4hep
::
Vector3d
(
p
.
xProd
(),
p
.
yProd
(),
p
.
zProd
()));
mcp
.
setMomentum
(
edm4hep
::
Vector3f
(
p
.
px
(),
p
.
py
(),
p
.
pz
()));
}
// setup the relationships (mother and daughter)
for
(
int
i
=
0
;
i
<
pythia_particles
.
size
();
++
i
)
{
auto
&
p
=
pythia_particles
[
i
];
auto
mcp
=
event
.
getMCVec
()[
i
];
auto
mother_list
=
p
.
motherList
();
for
(
auto
idx
:
mother_list
)
{
auto
mother
=
event
.
getMCVec
()[
idx
];
mcp
.
addToParents
(
mother
);
}
auto
daughter_list
=
p
.
daughterList
();
bool
need_endpoint
=
true
;
for
(
auto
idx
:
daughter_list
)
{
auto
daughter
=
event
.
getMCVec
()[
idx
];
mcp
.
addToDaughters
(
daughter
);
// Update the endpoint to the daughter's vertex
if
(
need_endpoint
)
{
mcp
.
setEndpoint
(
daughter
.
getVertex
());
need_endpoint
=
false
;
}
}
}
return
true
;
}
bool
GtPythiaTool
::
finish
()
{
return
true
;
}
bool
GtPythiaTool
::
configure_gentool
()
{
return
true
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment