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
Li Zhihao
CEPCSW
Commits
94a8dcd8
Commit
94a8dcd8
authored
2 years ago
by
lintao@ihep.ac.cn
Browse files
Options
Downloads
Patches
Plain Diff
WIP: access the geometry service and get the constants from DD4hep.
parent
27f04d74
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
+48
-2
48 additions, 2 deletions
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h
+8
-0
8 additions, 0 deletions
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h
with
56 additions
and
2 deletions
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
+
48
−
2
View file @
94a8dcd8
#include
"Edm4hepWriterAnaElemTool.h"
#include
"Edm4hepWriterAnaElemTool.h"
#include
"G4Step.hh"
#include
"G4Event.hh"
#include
"G4Event.hh"
#include
"G4THitsCollection.hh"
#include
"G4THitsCollection.hh"
#include
"G4EventManager.hh"
#include
"G4EventManager.hh"
...
@@ -19,6 +20,23 @@ DECLARE_COMPONENT(Edm4hepWriterAnaElemTool)
...
@@ -19,6 +20,23 @@ DECLARE_COMPONENT(Edm4hepWriterAnaElemTool)
void
void
Edm4hepWriterAnaElemTool
::
BeginOfRunAction
(
const
G4Run
*
)
{
Edm4hepWriterAnaElemTool
::
BeginOfRunAction
(
const
G4Run
*
)
{
G4cout
<<
"Begin Run of detector simultion..."
<<
G4endl
;
G4cout
<<
"Begin Run of detector simultion..."
<<
G4endl
;
// access geometry service
m_geosvc
=
service
<
IGeomSvc
>
(
"GeomSvc"
);
if
(
m_geosvc
)
{
dd4hep
::
Detector
*
dd4hep_geo
=
m_geosvc
->
lcdd
();
// try to get the constants
R
=
dd4hep_geo
->
constant
<
double
>
(
"tracker_region_rmax"
)
/
dd4hep
::
mm
*
CLHEP
::
mm
;
Z
=
dd4hep_geo
->
constant
<
double
>
(
"tracker_region_zmax"
)
/
dd4hep
::
mm
*
CLHEP
::
mm
;
info
()
<<
"Tracker Region "
<<
" R: "
<<
R
<<
" Z: "
<<
Z
<<
endmsg
;
}
else
{
error
()
<<
"Failed to find GeomSvc."
<<
endmsg
;
}
}
}
void
void
...
@@ -498,8 +516,36 @@ Edm4hepWriterAnaElemTool::PostUserTrackingAction(const G4Track* track) {
...
@@ -498,8 +516,36 @@ Edm4hepWriterAnaElemTool::PostUserTrackingAction(const G4Track* track) {
}
}
void
void
Edm4hepWriterAnaElemTool
::
UserSteppingAction
(
const
G4Step
*
)
{
Edm4hepWriterAnaElemTool
::
UserSteppingAction
(
const
G4Step
*
aStep
)
{
auto
aTrack
=
aStep
->
GetTrack
();
// try to get user track info
auto
trackinfo
=
dynamic_cast
<
CommonUserTrackInfo
*>
(
aTrack
->
GetUserInformation
());
// ========================================================================
// Note:
// if there is no track info, then do nothing.
// ========================================================================
if
(
trackinfo
)
{
// back scattering is defined as following:
// - pre point is not in tracker
// - post point is in tracker
// For details, look at Mokka's source code:
// https://llrforge.in2p3.fr/trac/Mokka/browser/trunk/source/Kernel/src/SteppingAction.cc
const
auto
&
pre_pos
=
aStep
->
GetPreStepPoint
()
->
GetPosition
();
const
auto
&
post_pos
=
aStep
->
GetPostStepPoint
()
->
GetPosition
();
bool
is_pre_in_tracker
=
pre_pos
.
perp
()
<
R
&&
std
::
fabs
(
pre_pos
.
z
())
<
Z
;
bool
is_post_in_tracker
=
post_pos
.
perp
()
<
R
&&
std
::
fabs
(
post_pos
.
z
())
<
Z
;
if
((
!
is_pre_in_tracker
)
and
is_post_in_tracker
)
{
// set back scattering
auto
idxedm4hep
=
trackinfo
->
idxEdm4hep
();
mcCol
->
at
(
idxedm4hep
).
setBackscatter
(
true
);
info
()
<<
" set back scatter for MCParticle "
<<
" (ID: "
<<
idxedm4hep
<<
")"
<<
endmsg
;
}
}
}
}
StatusCode
StatusCode
...
...
This diff is collapsed.
Click to expand it.
Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h
+
8
−
0
View file @
94a8dcd8
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
#include
"DetSimInterface/CommonUserEventInfo.hh"
#include
"DetSimInterface/CommonUserEventInfo.hh"
#include
"DetSimInterface/CommonUserTrackInfo.hh"
#include
"DetSimInterface/CommonUserTrackInfo.hh"
#include
"DetInterface/IGeomSvc.h"
#include
"edm4hep/MCParticleCollection.h"
#include
"edm4hep/MCParticleCollection.h"
#include
"edm4hep/SimTrackerHitCollection.h"
#include
"edm4hep/SimTrackerHitCollection.h"
#include
"edm4hep/SimCalorimeterHitCollection.h"
#include
"edm4hep/SimCalorimeterHitCollection.h"
...
@@ -143,6 +145,12 @@ private:
...
@@ -143,6 +145,12 @@ private:
std
::
map
<
int
,
int
>
m_track2primary
;
std
::
map
<
int
,
int
>
m_track2primary
;
CommonUserEventInfo
*
m_userinfo
=
nullptr
;
CommonUserEventInfo
*
m_userinfo
=
nullptr
;
// get the limitation of R/Z in tracker
SmartIF
<
IGeomSvc
>
m_geosvc
;
double
R
=
0
;
double
Z
=
0
;
};
};
#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