Skip to content

Commit

Permalink
DCH v2 digitizer, which smears the position and adds cluster informat…
Browse files Browse the repository at this point in the history
…ion (#27)

* DCH v2 digitizer, which smears the position and adds cluster information

* remove gaudi transformer linking/header

* filter out the new digitizer if DCH data extension is not found

* update test of idea vx

* fix vx test

* remove position_L/R member of data extension

* add test for DCHdigi

* add protection in case the file for CLS is not available

* add ctest

* cast variables to void to get rid of spurious compiler warning

* add edm4hep link in yaml

* use to mutable digi hit

* add association as second collection in the output

* fix path to compact file of DCH stand alone

* array index in C start at 0...

* use ref to mutable object, to be checked if association is correct

* write association in the output

* default z resolution 1 mm

* default xy resolution 0.1 mm

* expanded comment about the uid service

* comment added

* add comment about advancing the random engines

* change value in test

* output file with histograms for debugging is now configurable from steering

* remove unused function

* add shebang

* remove alias for edm4hep classes

* rename namespace of edm4hep extension to edm4hep, add interface

* implement Thomas suggestion, exit code removed

* moving back new edm4hep classes to extension namespace

* add interface back again...

* add extension::Track

* rename of cluster variables

* indentantion is compliant with local .clang-format file

* indentation corrected

* avoid downloading several times the cluster input file

* initialize variables, fix compilation in ubuntu

* major refactorization of cluster counting function

* data extension modified,
field was total number of electrons summed over all clusters during that step

* clang format of source code

* include vector of cluster sizes in the data extension

* add few comments

* move initialization of distributions to the main scope of the CalculateClusters function

* add protection against zero energy hit

* change direction and random seed for DDSim steering file

* add version v01 suffix to digitizer class name

* add protection against negative values

* add readme

* ancillary functions to calculate wire positions moved to data extension

* use new geometry functions from data extension, safer way of saving output histograms

* update comments

* update README

* update README

* additional flag to make dNdx calculation optional, plus extra comments

* update README and header doxygen

* enable dNdx calculation in the test
  • Loading branch information
atolosadelgado authored Nov 27, 2024
1 parent 5101031 commit d133342
Show file tree
Hide file tree
Showing 14 changed files with 3,822 additions and 4 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ find_package(ROOT COMPONENTS RIO Tree MathCore)
find_package(EDM4HEP)
find_package(k4FWCore)
find_package(Gaudi)
find_package(GSL)
#---------------------------------------------------------------

include(cmake/Key4hepConfig.cmake)
Expand Down
27 changes: 23 additions & 4 deletions DCHdigi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ install(FILES

install(FILES
dataFormatExtension/driftChamberHit.yaml
DESTINATION "${CMAKE_INSTALL_DATADIR}/extension" COMPONENT dev)
DESTINATION "${CMAKE_INSTALL_PREFIX}/extension" COMPONENT dev)

install(FILES
"${PROJECT_BINARY_DIR}/libextensionDict_rdict.pcm"
Expand All @@ -42,15 +42,29 @@ file(GLOB headers
${PROJECT_SOURCE_DIR}/include/*.h
)

include(CheckIncludeFileCXX)
set(CMAKE_REQUIRED_LIBRARIES DD4hep::DDRec)
CHECK_INCLUDE_FILE_CXX(DDRec/DCH_info.h DCH_INFO_H_EXIST)
set(CMAKE_REQUIRED_LIBRARIES)
set(FILES_DEPENDINGON_DCH_INFO_H "DCHdigi.cpp" )
if(NOT DCH_INFO_H_EXIST)
list(FILTER sources EXCLUDE REGEX "${FILES_DEPENDINGON_DCH_INFO_H}")
message(WARNING "Gaudi algorithm defined in ${FILES_DEPENDINGON_DCH_INFO_H} will not be built because header file DDRec/DCH_info.h was not found")
endif()

gaudi_add_module(${PackageName}
SOURCES ${sources}
LINK
k4FWCore::k4FWCore
k4FWCore::k4Interface
Gaudi::GaudiKernel
EDM4HEP::edm4hep
extensionDict
k4FWCore::k4FWCore
k4FWCore::k4Interface
DD4hep::DDRec
DD4hep::DDCore
ROOT::MathCore
ROOT::MathMore
GSL::gsl
)

target_include_directories(${PackageName} PUBLIC
Expand All @@ -71,7 +85,7 @@ install(TARGETS ${PackageName}
EXPORT ${CMAKE_PROJECT_NAME}Targets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/@{CMAKE_PROJECT_NAME}" COMPONENT dev
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}" COMPONENT dev
)

install(FILES ${scripts} DESTINATION test)
Expand All @@ -83,3 +97,8 @@ set_test_env(${test_name})
SET(test_name "test_DCHsimpleDigitizerExtendedEdm")
ADD_TEST(NAME ${test_name} COMMAND k4run test/runDCHsimpleDigitizerExtendedEdm.py)
set_test_env(${test_name})

SET(test_name "test_runDCHdigiV2")
ADD_TEST(NAME ${test_name} COMMAND sh +x test_DCHdigi.sh )
set_test_env(${test_name})
set_tests_properties(${test_name} PROPERTIES WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/DCHdigi/test/test_DCHdigi")
20 changes: 20 additions & 0 deletions DCHdigi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Drift chamber (DCH) digitizers

## DCHdigi_v01

* Each simulated hit is transformed into a digitized hit. The digitized hit position is the projection of the simulated hit position onto the sense wire (at the center of the cell)
* Smearing of the digitized hit position along the wire and radially is done according to the input parameter values (`zResolution_mm` and `xyResolution_mm`, respectively)
* The digitized hit adds dNdx information if flag `calculate_dndx` is enabled (default not). This information consist on number of clusters and their size, which are derived from precalculated distributions contained in an input file specified by the parameter `fileDataAlg`. The method and distributions corresponds to the option 3 described in F. Cuna et al, arXiv:2105.07064
* It requires that the cellID contain the layer and number of cell within the layer (nphi). It does not matter if the segmentation comes from geometrical segmentation by using twisted tubes and hyperboloids (and the cellID is created out of volume IDs), or the segmentation is virtual DD4hep segmentation
* New digitized hit class is used as an EDM4hep data extension, to be integrated into EDM4hep
* Debug histograms are created if `create_debug_histograms` option is enabled (output file name can be given)
* Stand alone test run simulation of the drift chamber based on twisted tubes, and then apply the digitizer. Dedicated directory with all the files needed is given in `DCHdigi/test/test_DCHdigi/`
* Random number generator uses the seeds calculated on an event basis by the UID service, from the podio header information (run/event number)
* This digitizer is meant to be used with `DriftChamber_o1_v02` from k4geo and is expected to work for the upcoming `DriftChamber_o1_v03`

## DCHsimpleDigitizerExtendedEdm

* Algorithm for creating digitized drift chamber hits (based on edm4hep::TrackerHit3D) from edm4hep::SimTrackerHit. Resolution along z and xy (distance to the wire) has to be specified. The smearing is applied in the wire reference frame, by means of the placement matrix of the wires
* No cluster counting information is added into the digitized output
* It relies on a dedicated data extension, similar to DCHdigi_v01
* This digitizer is meant to be used with `DriftChamber_o1_v01` from k4geo. Deprecated.
118 changes: 118 additions & 0 deletions DCHdigi/dataFormatExtension/driftChamberHit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ schema_version: 1
options:
# should getters / setters be prefixed with get / set?
getSyntax: True
setSyntax: True
# should POD members be exposed with getters/setters in classes that have them as members?
exposePODMembers: False
includeSubfolder: True
Expand Down Expand Up @@ -41,3 +42,120 @@ datatypes:
OneToOneRelations:
- extension::DriftChamberDigi digi // reference to the digitized hit
- edm4hep::SimTrackerHit sim // reference to the simulated hit

extension::DriftChamberDigiV2:
Description: "Digitized hit (before tracking) for Drift Chamber v2 (requires data extension)."
Author: "A. Tolosa-Delgado, B. Francois, CERN"
Members:
- uint64_t cellID // ID of the sensor that created this hit
- int32_t type // type of the raw data hit
- int32_t quality // quality bit flag of the hit
- float time // time of the hit [ns]
- float eDep // energy deposited on the hit [GeV]
- float eDepError // error measured on eDep [GeV]
- edm4hep::Vector3d position // point on the sensitive wire (SW) which is closest to the simhit [mm]
- edm4hep::Vector3d directionSW // direction of SW
- float distanceToWire // distance hit-wire [mm]
- uint32_t nCluster // number of clusters associated to this hit
VectorMembers:
- uint16_t nElectrons // number of electrons for each cluster

extension::MCRecoDriftChamberDigiV2Association:
Description: "Association between a DriftChamberDigi and the corresponding simulated hit"
Author: "B. Francois, CERN"
Members:
- float weight // weight of this association
OneToOneRelations:
- extension::DriftChamberDigiV2 digi // reference to the digitized hit
- edm4hep::SimTrackerHit sim // reference to the simulated hit

extension::Track:
Description: "Reconstructed track"
Author: "EDM4hep authors"
Members:
- int32_t type // flagword that defines the type of track.Bits 16-31 are used internally
- float chi2 // Chi^2 of the track fit
- int32_t ndf // number of degrees of freedom of the track fit
- float dEdx // dEdx of the track
- float dEdxError // error of dEdx
- float radiusOfInnermostHit // radius of the innermost hit that has been used in the track fit
VectorMembers:
- int32_t subdetectorHitNumbers // number of hits in particular subdetectors
- edm4hep::TrackState trackStates // track states
- edm4hep::Quantity dxQuantities // different measurements of dx quantities
OneToManyRelations:
- extension::TrackerHit trackerHits // hits that have been used to create this track
- extension::Track tracks // tracks (segments) that have been combined to create this track

# the following is just because interface looks for e.g. extension/TrackerHit3DCollection.h
extension::TrackerHit3D:
Description: "Tracker hit"
Author: "EDM4hep authors"
Members:
- uint64_t cellID // ID of the sensor that created this hit
- int32_t type // type of raw data hit
- int32_t quality // quality bit flag of the hit
- float time [ns] // time of the hit
- float eDep [GeV] // energy deposited on the hit
- float eDepError [GeV] // error measured on EDep
- edm4hep::Vector3d position [mm] // hit position
- edm4hep::CovMatrix3f covMatrix // covariance matrix of the position (x,y,z)
ExtraCode:
includes: "#include <edm4hep/Constants.h>"
declaration: "
/// Get the position covariance matrix value for the two passed dimensions\n
float getCovMatrix(edm4hep::Cartesian dimI, edm4hep::Cartesian dimJ) const { return getCovMatrix().getValue(dimI, dimJ); }\n
"
MutableExtraCode:
includes: "#include <edm4hep/Constants.h>"
declaration: "
/// Set the position covariance matrix value for the two passed dimensions\n
void setCovMatrix(float value, edm4hep::Cartesian dimI, edm4hep::Cartesian dimJ) { getCovMatrix().setValue(value, dimI, dimJ); }\n
"
extension::TrackerHitPlane:
Description: "Tracker hit plane"
Author: "EDM4hep authors"
Members:
- uint64_t cellID // ID of the sensor that created this hit
- int32_t type // type of raw data hit
- int32_t quality // quality bit flag of the hit
- float time [ns] // time of the hit
- float eDep [GeV] // energy deposited on the hit
- float eDepError [GeV] // error measured on EDep
- edm4hep::Vector2f u // measurement direction vector, u lies in the x-y plane
- edm4hep::Vector2f v // measurement direction vector, v is along z
- float du // measurement error along the direction
- float dv // measurement error along the direction
- edm4hep::Vector3d position [mm] // hit position
- edm4hep::CovMatrix3f covMatrix // covariance of the position (x,y,z)
ExtraCode:
includes: "#include <edm4hep/Constants.h>"
declaration: "
/// Get the position covariance matrix value for the two passed dimensions\n
float getCovMatrix(edm4hep::Cartesian dimI, edm4hep::Cartesian dimJ) const { return getCovMatrix().getValue(dimI, dimJ); }\n
"
MutableExtraCode:
includes: "#include <edm4hep/Constants.h>"
declaration: "
/// Set the position covariance matrix value for the two passed dimensions\n
void setCovMatrix(float value, edm4hep::Cartesian dimI, edm4hep::Cartesian dimJ) { getCovMatrix().setValue(value, dimI, dimJ); }\n
"

# end of "the following is just because interface looks for e.g. extension/TrackerHit3DCollection.h"

interfaces:
extension::TrackerHit:
Description: "Tracker hit interface class"
Author: "Thomas Madlener, DESY"
Members:
- uint64_t cellID // ID of the sensor that created this hit
- int32_t type // type of the raw data hit
- int32_t quality // quality bit flag of the hit
- float time [ns] // time of the hit
- float eDep [GeV] // energy deposited on the hit
- float eDepError [GeV] // error measured on eDep
- edm4hep::Vector3d position [mm] // hit position
Types:
- extension::TrackerHitPlane
- extension::TrackerHit3D
- extension::DriftChamberDigiV2
Loading

0 comments on commit d133342

Please sign in to comment.