Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CEPCSW
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
maxt@ihep.ac.cn
CEPCSW
Commits
69625043
Commit
69625043
authored
4 years ago
by
lintao@ihep.ac.cn
Browse files
Options
Downloads
Patches
Plain Diff
WIP: bookkeeping of the current track and its primary track.
parent
21c86818
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
+32
-2
32 additions, 2 deletions
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h
+16
-0
16 additions, 0 deletions
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h
with
48 additions
and
2 deletions
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
+
32
−
2
View file @
69625043
...
@@ -26,6 +26,10 @@ Edm4hepWriterAnaElemTool::EndOfRunAction(const G4Run*) {
...
@@ -26,6 +26,10 @@ Edm4hepWriterAnaElemTool::EndOfRunAction(const G4Run*) {
void
void
Edm4hepWriterAnaElemTool
::
BeginOfEventAction
(
const
G4Event
*
anEvent
)
{
Edm4hepWriterAnaElemTool
::
BeginOfEventAction
(
const
G4Event
*
anEvent
)
{
msg
()
<<
"Event "
<<
anEvent
->
GetEventID
()
<<
endmsg
;
msg
()
<<
"Event "
<<
anEvent
->
GetEventID
()
<<
endmsg
;
// reset
m_track2primary
.
clear
();
}
}
void
void
...
@@ -192,7 +196,15 @@ Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) {
...
@@ -192,7 +196,15 @@ Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) {
edm_calo_contrib
.
setEnergy
(
c
.
deposit
/
CLHEP
::
GeV
);
edm_calo_contrib
.
setEnergy
(
c
.
deposit
/
CLHEP
::
GeV
);
edm_calo_contrib
.
setTime
(
c
.
time
/
CLHEP
::
ns
);
edm_calo_contrib
.
setTime
(
c
.
time
/
CLHEP
::
ns
);
edm_calo_contrib
.
setStepPosition
(
edm4hep
::
Vector3f
(
pos
));
edm_calo_contrib
.
setStepPosition
(
edm4hep
::
Vector3f
(
pos
));
edm_calo_contrib
.
setParticle
(
mcCol
->
at
(
0
));
// todo
// from the track id, get the primary track
int
pritrkid
=
m_track2primary
[
c
.
trackID
];
if
(
pritrkid
<=
0
)
{
error
()
<<
"Failed to find the primary track for trackID #"
<<
c
.
trackID
<<
endmsg
;
pritrkid
=
1
;
}
edm_calo_contrib
.
setParticle
(
mcCol
->
at
(
pritrkid
-
1
));
// todo
edm_calo_hit
.
addToContributions
(
edm_calo_contrib
);
edm_calo_hit
.
addToContributions
(
edm_calo_contrib
);
}
}
}
}
...
@@ -214,8 +226,26 @@ Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) {
...
@@ -214,8 +226,26 @@ Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) {
}
}
void
void
Edm4hepWriterAnaElemTool
::
PreUserTrackingAction
(
const
G4Track
*
)
{
Edm4hepWriterAnaElemTool
::
PreUserTrackingAction
(
const
G4Track
*
track
)
{
int
curtrkid
=
track
->
GetTrackID
();
int
curparid
=
track
->
GetParentID
();
int
pritrkid
=
curparid
;
// try to find the primary track id from the parent track id.
if
(
curparid
)
{
auto
it
=
m_track2primary
.
find
(
curparid
);
if
(
it
==
m_track2primary
.
end
())
{
error
()
<<
"Failed to find primary track for track id "
<<
curparid
<<
endmsg
;
}
else
{
pritrkid
=
it
->
second
;
}
}
else
{
// curparid is 0, it is primary
pritrkid
=
curtrkid
;
}
m_track2primary
[
curtrkid
]
=
pritrkid
;
}
}
void
void
...
...
This diff is collapsed.
Click to expand it.
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h
+
16
−
0
View file @
69625043
#ifndef Edm4hepWriterAnaElemTool_h
#ifndef Edm4hepWriterAnaElemTool_h
#define Edm4hepWriterAnaElemTool_h
#define Edm4hepWriterAnaElemTool_h
#include
<map>
#include
"GaudiKernel/AlgTool.h"
#include
"GaudiKernel/AlgTool.h"
#include
"FWCore/DataHandle.h"
#include
"FWCore/DataHandle.h"
#include
"DetSimInterface/IAnaElemTool.h"
#include
"DetSimInterface/IAnaElemTool.h"
...
@@ -62,6 +64,20 @@ private:
...
@@ -62,6 +64,20 @@ private:
DataHandle
<
edm4hep
::
SimTrackerHitCollection
>
m_SETCol
{
"SETCollection"
,
DataHandle
<
edm4hep
::
SimTrackerHitCollection
>
m_SETCol
{
"SETCollection"
,
Gaudi
::
DataHandle
::
Writer
,
this
};
Gaudi
::
DataHandle
::
Writer
,
this
};
private
:
// in order to associate the hit contribution with the primary track,
// we have a bookkeeping of every track.
// The primary track will assign the same key/value.
// Following is an example:
// 1 -> 1,
// 2 -> 2,
// 3 -> 1,
// Now, if parent of trk #4 is trk #3, using the mapping {3->1} could
// locate the primary trk #1.
std
::
map
<
int
,
int
>
m_track2primary
;
};
};
#endif
#endif
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