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
eb7d8cfd
Commit
eb7d8cfd
authored
5 years ago
by
lintao@ihep.ac.cn
Browse files
Options
Downloads
Patches
Plain Diff
WIP: support to read the old style DD4hep hit collection.
parent
e673ead9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Simulation/DetSimAna/src/ExampleAnaElemTool.cpp
+61
-1
61 additions, 1 deletion
Simulation/DetSimAna/src/ExampleAnaElemTool.cpp
with
61 additions
and
1 deletion
Simulation/DetSimAna/src/ExampleAnaElemTool.cpp
+
61
−
1
View file @
eb7d8cfd
#include
"ExampleAnaElemTool.h"
#include
"G4Event.hh"
#include
"G4THitsCollection.hh"
#include
"DD4hep/Detector.h"
#include
"DD4hep/Plugins.h"
#include
"DDG4/Geant4Converter.h"
#include
"DDG4/Geant4Mapping.h"
#include
"DDG4/Geant4HitCollection.h"
#include
"DDG4/Geant4Data.h"
#include
"DDG4/Geant4Hits.h"
DECLARE_COMPONENT
(
ExampleAnaElemTool
)
...
...
@@ -56,8 +59,65 @@ ExampleAnaElemTool::EndOfEventAction(const G4Event* anEvent) {
<<
" #"
<<
icol
<<
" has "
<<
nhits
<<
" hits."
<<
endmsg
;
// There are different types (new and old)
dd4hep
::
sim
::
Geant4HitCollection
*
coll
=
dynamic_cast
<
dd4hep
::
sim
::
Geant4HitCollection
*>
(
collect
);
if
(
coll
)
{
info
()
<<
" cast to dd4hep::sim::Geant4HitCollection. "
<<
endmsg
;
for
(
size_t
i
=
0
;
i
<
nhits
;
++
i
)
{
dd4hep
::
sim
::
Geant4HitData
*
h
=
coll
->
hit
(
i
);
dd4hep
::
sim
::
Geant4Tracker
::
Hit
*
trk_hit
=
dynamic_cast
<
dd4hep
::
sim
::
Geant4Tracker
::
Hit
*>
(
h
);
if
(
0
!=
trk_hit
)
{
dd4hep
::
sim
::
Geant4HitData
::
Contribution
&
t
=
trk_hit
->
truth
;
int
trackID
=
t
.
trackID
;
// t.trackID = m_truth->particleID(trackID);
}
// Geant4Calorimeter::Hit* cal_hit = dynamic_cast<Geant4Calorimeter::Hit*>(h);
// if ( 0 != cal_hit ) {
// Geant4HitData::Contributions& c = cal_hit->truth;
// for(Geant4HitData::Contributions::iterator j=c.begin(); j!=c.end(); ++j) {
// Geant4HitData::Contribution& t = *j;
// int trackID = t.trackID;
// // t.trackID = m_truth->particleID(trackID);
// }
// }
}
continue
;
}
typedef
G4THitsCollection
<
dd4hep
::
sim
::
Geant4Hit
>
HitCollection
;
HitCollection
*
coll2
=
dynamic_cast
<
HitCollection
*>
(
collect
);
if
(
coll2
)
{
info
()
<<
" cast to G4THitsCollection<dd4hep::sim::Geant4Hit>. "
<<
endmsg
;
for
(
size_t
i
=
0
;
i
<
nhits
;
++
i
)
{
dd4hep
::
sim
::
Geant4Hit
*
h
=
dynamic_cast
<
dd4hep
::
sim
::
Geant4Hit
*>
(
coll2
->
GetHit
(
i
));
if
(
!
h
)
{
warning
()
<<
"Failed to cast to dd4hep::sim::Geant4Hit. "
<<
endmsg
;
continue
;
}
dd4hep
::
sim
::
Geant4TrackerHit
*
trk_hit
=
dynamic_cast
<
dd4hep
::
sim
::
Geant4TrackerHit
*>
(
h
);
if
(
trk_hit
)
{
info
()
<<
" cast to dd4hep::sim::Geant4TrackerHit. "
<<
endmsg
;
}
dd4hep
::
sim
::
Geant4CalorimeterHit
*
cal_hit
=
dynamic_cast
<
dd4hep
::
sim
::
Geant4CalorimeterHit
*>
(
h
);
if
(
cal_hit
)
{
info
()
<<
" cast to dd4hep::sim::Geant4CalorimeterHit. "
<<
endmsg
;
}
}
continue
;
}
warning
()
<<
"Failed to convert to collection "
<<
collect
->
GetName
()
<<
endmsg
;
}
}
...
...
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