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
9
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
ee805fe4
Commit
ee805fe4
authored
4 years ago
by
lintao@ihep.ac.cn
Browse files
Options
Downloads
Patches
Plain Diff
WIP: An example to decode the CellID using the DD4hep way.
parent
35e658aa
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Examples/CMakeLists.txt
+7
-0
7 additions, 0 deletions
Examples/CMakeLists.txt
Examples/src/DumpIDAlg/DumpIDAlg.cpp
+94
-0
94 additions, 0 deletions
Examples/src/DumpIDAlg/DumpIDAlg.cpp
Examples/src/DumpIDAlg/DumpIDAlg.h
+39
-0
39 additions, 0 deletions
Examples/src/DumpIDAlg/DumpIDAlg.h
with
140 additions
and
0 deletions
Examples/CMakeLists.txt
+
7
−
0
View file @
ee805fe4
...
@@ -6,6 +6,11 @@ find_package(podio REQUIRED)
...
@@ -6,6 +6,11 @@ find_package(podio REQUIRED)
find_package
(
LCIO REQUIRED
)
find_package
(
LCIO REQUIRED
)
find_package
(
EDM4HEP REQUIRED
)
find_package
(
EDM4HEP REQUIRED
)
find_package
(
K4FWCore REQUIRED
)
find_package
(
K4FWCore REQUIRED
)
find_package
(
DD4hep COMPONENTS DDRec DDParsers REQUIRED
)
gaudi_depends_on_subdirs
(
Detector/DetInterface
)
set
(
Examples_srcs
set
(
Examples_srcs
src/HelloWorld/*.cpp
src/HelloWorld/*.cpp
...
@@ -13,6 +18,7 @@ set(Examples_srcs
...
@@ -13,6 +18,7 @@ set(Examples_srcs
src/SecondAlg/*.cpp
src/SecondAlg/*.cpp
# src/PlcioTest/*.cpp
# src/PlcioTest/*.cpp
src/Edm4hepTest/*.cpp
src/Edm4hepTest/*.cpp
src/DumpIDAlg/*.cpp
)
)
# Headers and Libraries
# Headers and Libraries
...
@@ -23,6 +29,7 @@ gaudi_install_headers(Examples)
...
@@ -23,6 +29,7 @@ gaudi_install_headers(Examples)
gaudi_add_module
(
Examples
${
Examples_srcs
}
gaudi_add_module
(
Examples
${
Examples_srcs
}
INCLUDE_DIRS K4FWCore GaudiAlgLib GaudiKernel
${
podio_INCLUDE_DIRS
}
${
LCIO_INCLUDE_DIRS
}
INCLUDE_DIRS K4FWCore GaudiAlgLib GaudiKernel
${
podio_INCLUDE_DIRS
}
${
LCIO_INCLUDE_DIRS
}
LINK_LIBRARIES K4FWCore GaudiAlgLib GaudiKernel
${
LCIO_LIBRARIES
}
LINK_LIBRARIES K4FWCore GaudiAlgLib GaudiKernel
${
LCIO_LIBRARIES
}
DD4hep
${
DD4hep_COMPONENT_LIBRARIES
}
# Force loading the libraries.
# Force loading the libraries.
-Wl,--no-as-needed EDM4HEP::edm4hep EDM4HEP::edm4hepDict
${
podio_LIBRARIES
}
podio::podioRootIO -Wl,--as-needed
-Wl,--no-as-needed EDM4HEP::edm4hep EDM4HEP::edm4hepDict
${
podio_LIBRARIES
}
podio::podioRootIO -Wl,--as-needed
)
)
...
...
This diff is collapsed.
Click to expand it.
Examples/src/DumpIDAlg/DumpIDAlg.cpp
0 → 100644
+
94
−
0
View file @
ee805fe4
#include
"DumpIDAlg.h"
#include
"edm4hep/EventHeaderCollection.h"
#include
"edm4hep/MCParticleCollection.h"
#include
"edm4hep/SimCalorimeterHitCollection.h"
#include
"edm4hep/CaloHitContributionCollection.h"
#include
"DD4hep/Detector.h"
#include
"DD4hep/IDDescriptor.h"
#include
"DD4hep/Plugins.h"
DECLARE_COMPONENT
(
DumpIDAlg
)
DumpIDAlg
::
DumpIDAlg
(
const
std
::
string
&
name
,
ISvcLocator
*
svcLoc
)
:
GaudiAlgorithm
(
name
,
svcLoc
),
m_dd4hep_geo
(
nullptr
),
m_decoder
(
nullptr
)
{
}
StatusCode
DumpIDAlg
::
initialize
()
{
m_geosvc
=
service
<
IGeoSvc
>
(
"GeoSvc"
);
if
(
!
m_geosvc
)
{
error
()
<<
"Failed to find GeoSvc."
<<
endmsg
;
return
StatusCode
::
FAILURE
;
}
m_dd4hep_geo
=
m_geosvc
->
lcdd
();
if
(
!
m_dd4hep_geo
)
{
error
()
<<
"failed to retrieve dd4hep_geo: "
<<
m_dd4hep_geo
<<
endmsg
;
return
StatusCode
::
FAILURE
;
}
// get the DD4hep readout
auto
readouts
=
m_dd4hep_geo
->
readouts
();
const
std
::
string
name_readout
=
"EcalBarrelCollection"
;
if
(
readouts
.
find
(
name_readout
)
!=
readouts
.
end
())
{
dd4hep
::
Readout
readout
=
m_dd4hep_geo
->
readout
(
name_readout
);
auto
m_idspec
=
readout
.
idSpec
();
info
()
<<
"The idspec is "
<<
m_idspec
.
fieldDescription
()
<<
" for "
<<
name_readout
<<
endmsg
;
dd4hep
::
DDSegmentation
::
BitFieldCoder
*
decoder
=
m_idspec
.
decoder
();
m_decoder
=
decoder
;
}
if
(
!
m_decoder
)
{
error
()
<<
"Failed to get the decoder. "
<<
endmsg
;
return
StatusCode
::
FAILURE
;
}
return
GaudiAlgorithm
::
initialize
();
}
StatusCode
DumpIDAlg
::
execute
()
{
auto
ecalBarrelCol
=
m_EcalBarrelCol
.
get
();
for
(
auto
calohit
:
*
ecalBarrelCol
)
{
auto
cellid
=
calohit
.
getCellID
();
int
id_system
=
m_decoder
->
get
(
cellid
,
"system"
);
int
id_module
=
m_decoder
->
get
(
cellid
,
"module"
);
int
id_stave
=
m_decoder
->
get
(
cellid
,
"stave"
);
int
id_tower
=
m_decoder
->
get
(
cellid
,
"tower"
);
int
id_layer
=
m_decoder
->
get
(
cellid
,
"layer"
);
int
id_wafer
=
m_decoder
->
get
(
cellid
,
"wafer"
);
int
id_cellX
=
m_decoder
->
get
(
cellid
,
"cellX"
);
int
id_cellY
=
m_decoder
->
get
(
cellid
,
"cellY"
);
info
()
<<
"Calo hit cellid: "
<<
cellid
<<
" system: "
<<
id_system
<<
" module: "
<<
id_module
<<
" stave: "
<<
id_stave
<<
" tower: "
<<
id_tower
<<
" layer: "
<<
id_layer
<<
" wafer: "
<<
id_wafer
<<
" cellX: "
<<
id_cellX
<<
" cellY: "
<<
id_cellY
<<
endmsg
;
}
return
StatusCode
::
SUCCESS
;
}
StatusCode
DumpIDAlg
::
finalize
()
{
return
GaudiAlgorithm
::
finalize
();
}
This diff is collapsed.
Click to expand it.
Examples/src/DumpIDAlg/DumpIDAlg.h
0 → 100644
+
39
−
0
View file @
ee805fe4
#ifndef DumpIDAlg_h
#define DumpIDAlg_h
#include
"FWCore/DataHandle.h"
#include
"GaudiAlg/GaudiAlgorithm.h"
#include
"DetInterface/IGeoSvc.h"
#include
"DD4hep/Detector.h"
namespace
edm4hep
{
class
EventHeaderCollection
;
class
MCParticleCollection
;
class
SimCalorimeterHitCollection
;
class
CaloHitContributionCollection
;
}
class
DumpIDAlg
:
public
GaudiAlgorithm
{
public:
DumpIDAlg
(
const
std
::
string
&
name
,
ISvcLocator
*
svcLoc
);
virtual
StatusCode
initialize
();
virtual
StatusCode
execute
();
virtual
StatusCode
finalize
();
private:
SmartIF
<
IGeoSvc
>
m_geosvc
;
dd4hep
::
Detector
*
m_dd4hep_geo
;
dd4hep
::
DDSegmentation
::
BitFieldCoder
*
m_decoder
;
DataHandle
<
edm4hep
::
SimCalorimeterHitCollection
>
m_EcalBarrelCol
{
"EcalBarrelCollection"
,
Gaudi
::
DataHandle
::
Reader
,
this
};
};
#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