Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CEPCSW_OTE_development
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
yudian2002@sjtu.edu.cn
CEPCSW_OTE_development
Commits
29738fe8
Unverified
Commit
29738fe8
authored
4 years ago
by
lintao@ihep.ac.cn
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #114 from mirguest/master
WIP: Set flag when primary particle is decayed.
parents
3d675d16
9cbdc744
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
+92
-0
92 additions, 0 deletions
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
with
92 additions
and
0 deletions
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
+
92
−
0
View file @
29738fe8
...
...
@@ -2,6 +2,9 @@
#include
"G4Event.hh"
#include
"G4THitsCollection.hh"
#include
"G4EventManager.hh"
#include
"G4TrackingManager.hh"
#include
"G4SteppingManager.hh"
#include
"DD4hep/Detector.h"
#include
"DD4hep/Plugins.h"
...
...
@@ -204,6 +207,11 @@ Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) {
}
edm_trk_hit
.
setMCParticle
(
mcCol
->
at
(
pritrkid
-
1
));
if
(
pritrkid
!=
trackID
)
{
// If the track is a secondary, then the primary track id and current track id is different
edm_trk_hit
.
setProducedBySecondary
(
true
);
}
}
dd4hep
::
sim
::
Geant4CalorimeterHit
*
cal_hit
=
dynamic_cast
<
dd4hep
::
sim
::
Geant4CalorimeterHit
*>
(
h
);
...
...
@@ -311,6 +319,90 @@ Edm4hepWriterAnaElemTool::PostUserTrackingAction(const G4Track* track) {
stop_mom
.
z
()
/
CLHEP
::
GeV
);
primary_particle
.
setMomentumAtEndpoint
(
mom_endpoint
);
// ===================================================================
// Update the flags of the primary particles
// ===================================================================
// processes
static
G4VProcess
*
proc_decay
=
nullptr
;
if
(
!
proc_decay
)
{
G4ProcessManager
*
pm
=
track
->
GetDefinition
()
->
GetProcessManager
();
G4int
nprocesses
=
pm
->
GetProcessListLength
();
G4ProcessVector
*
pv
=
pm
->
GetProcessList
();
for
(
G4int
i
=
0
;
i
<
nprocesses
;
++
i
){
if
((
*
pv
)[
i
]
->
GetProcessName
()
==
"Decay"
){
proc_decay
=
(
*
pv
)[
i
];
}
}
}
// flags
bool
is_decay
=
false
;
G4TrackingManager
*
tm
=
G4EventManager
::
GetEventManager
()
->
GetTrackingManager
();
G4TrackVector
*
secondaries
=
tm
->
GimmeSecondaries
();
if
(
secondaries
)
{
size_t
nSeco
=
secondaries
->
size
();
for
(
size_t
i
=
0
;
i
<
nSeco
;
++
i
)
{
G4Track
*
sectrk
=
(
*
secondaries
)[
i
];
G4ParticleDefinition
*
secparticle
=
sectrk
->
GetDefinition
();
const
G4VProcess
*
creatorProcess
=
sectrk
->
GetCreatorProcess
();
// select the necessary processes
if
(
creatorProcess
==
proc_decay
)
{
info
()
<<
"Creator Process is Decay for secondary particle: "
<<
" idx: "
<<
i
<<
" trkid: "
<<
sectrk
->
GetTrackID
()
// not valid until track
<<
" particle: "
<<
secparticle
->
GetParticleName
()
<<
" pdg: "
<<
secparticle
->
GetPDGEncoding
()
<<
" at position: "
<<
sectrk
->
GetPosition
()
//
<<
" time: "
<<
sectrk
->
GetGlobalTime
()
<<
" momentum: "
<<
sectrk
->
GetMomentum
()
//
<<
endmsg
;
is_decay
=
true
;
// create secondaries in MC particles
// todo: convert the const collection to non-const
auto
mcCol
=
const_cast
<
edm4hep
::
MCParticleCollection
*>
(
m_mcParCol
.
get
());
edm4hep
::
MCParticle
mcp
=
mcCol
->
create
();
mcp
.
setPDG
(
secparticle
->
GetPDGEncoding
());
mcp
.
setGeneratorStatus
(
0
);
// not created by Generator
mcp
.
setCreatedInSimulation
(
1
);
mcp
.
setCharge
(
secparticle
->
GetPDGCharge
());
mcp
.
setTime
(
sectrk
->
GetGlobalTime
()
/
CLHEP
::
ns
);
// todo
mcp
.
setMass
(
secparticle
->
GetPDGMass
());
const
G4ThreeVector
&
sec_init_pos
=
sectrk
->
GetPosition
();
double
x
=
sec_init_pos
.
x
()
/
CLHEP
::
mm
;
double
y
=
sec_init_pos
.
y
()
/
CLHEP
::
mm
;
double
z
=
sec_init_pos
.
z
()
/
CLHEP
::
mm
;
const
G4ThreeVector
&
sec_init_mom
=
sectrk
->
GetMomentum
();
double
px
=
sec_init_mom
.
x
()
/
CLHEP
::
GeV
;
double
py
=
sec_init_mom
.
y
()
/
CLHEP
::
GeV
;
double
pz
=
sec_init_mom
.
z
()
/
CLHEP
::
GeV
;
mcp
.
setVertex
(
edm4hep
::
Vector3d
(
x
,
y
,
z
));
// todo
mcp
.
setEndpoint
(
edm4hep
::
Vector3d
(
x
,
y
,
z
));
// todo
mcp
.
setMomentum
(
edm4hep
::
Vector3f
(
px
,
py
,
pz
));
// todo
mcp
.
setMomentumAtEndpoint
(
edm4hep
::
Vector3f
(
px
,
py
,
pz
));
//todo
mcp
.
addToParents
(
primary_particle
);
primary_particle
.
addToDaughters
(
mcp
);
}
}
}
// now update
if
(
is_decay
)
{
primary_particle
.
setDecayedInTracker
(
is_decay
);
primary_particle
.
setDecayedInCalorimeter
(
is_decay
);
}
}
else
{
// TODO: select other interested tracks
...
...
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