Skip to content

Commit

Permalink
Use Tracker3D when avaliable
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarcell committed Feb 23, 2024
1 parent 2fd7bee commit 4aef16f
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 11 deletions.
12 changes: 10 additions & 2 deletions ARCdigi/include/ARCdigitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@

// EDM4HEP
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/TrackCollection.h"
#if __has_include("edm4hep/TrackerHit3DCollection.h")
#include "edm4hep/TrackerHit3DCollection.h"
#else
#include "edm4hep/TrackerHitCollection.h"
namespace edm4hep {
using TrackerHit3DCollection = edm4hep::TrackerHitCollection;
} // namespace edm4hep
#endif

// DD4HEP
#include "DD4hep/Detector.h"

/** @class ARCdigitizer
*
* Algorithm for creating digitized (meaning 'reconstructed' for now) ARC hits (edm4hep::TrackerHit) from Geant4 hits (edm4hep::SimTrackerHit).
* Algorithm for creating digitized (meaning 'reconstructed' for now) ARC hits (edm4hep::TrackerHit3D) from Geant4 hits (edm4hep::SimTrackerHit).
*
* @author Brieuc Francois, Matthew Basso
* @date 2023-03
Expand Down Expand Up @@ -46,7 +54,7 @@ class ARCdigitizer : public GaudiAlgorithm {
// Input sim tracker hit collection name
DataHandle<edm4hep::SimTrackerHitCollection> m_input_sim_hits{"inputSimHits", Gaudi::DataHandle::Reader, this};
// Output digitized tracker hit collection name
DataHandle<edm4hep::TrackerHitCollection> m_output_digi_hits{"outputDigiHits", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::TrackerHit3DCollection> m_output_digi_hits{"outputDigiHits", Gaudi::DataHandle::Writer, this};
// Flat value for SiPM efficiency
FloatProperty m_flat_SiPM_effi{this, "flatSiPMEfficiency", -1.0, "Flat value for SiPM quantum efficiency (<0 := disabled)"};
// Apply the SiPM efficiency to digitized hits instead of simulated hits
Expand Down
2 changes: 1 addition & 1 deletion ARCdigi/src/ARCdigitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ StatusCode ARCdigitizer::execute() {
dd4hep::rec::CellIDPositionConverter converter(*m_detector);

// Write the digitized hits
edm4hep::TrackerHitCollection* output_digi_hits = m_output_digi_hits.createAndPut();
edm4hep::TrackerHit3DCollection* output_digi_hits = m_output_digi_hits.createAndPut();
for (auto it = merged_digi_hits.begin(); it != merged_digi_hits.end(); it++) {
// Throw away digitized hits based on flat SiPM efficiency
if (m_apply_SiPM_effi_to_digi && m_flat_SiPM_effi >= 0.0 && m_uniform.shoot() > m_flat_SiPM_effi)
Expand Down
12 changes: 10 additions & 2 deletions DCHdigi/include/DCHsimpleDigitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@

// EDM4HEP
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/TrackCollection.h"
#if __has_include("edm4hep/TrackerHit3DCollection.h")
#include "edm4hep/TrackerHit3DCollection.h"
#else
#include "edm4hep/TrackerHitCollection.h"
namespace edm4hep {
using TrackerHit3DCollection = edm4hep::TrackerHitCollection;
} // namespace edm4hep
#endif

// DD4HEP
#include "DD4hep/Detector.h" // for dd4hep::VolumeManager
#include "DDSegmentation/BitFieldCoder.h"

/** @class DCHsimpleDigitizer
*
* Algorithm for creating digitized drift chamber hits (still based on edm4hep::TrackerHit) from edm4hep::SimTrackerHit.
* Algorithm for creating digitized drift chamber hits (still based on edm4hep::TrackerHit3D) from edm4hep::SimTrackerHit.
* You have to specify the expected resolution in z and in xy (distance to the wire). The smearing is applied in the wire reference frame.
*
* @author Brieuc Francois
Expand Down Expand Up @@ -49,7 +57,7 @@ class DCHsimpleDigitizer : public GaudiAlgorithm {
// Input sim tracker hit collection name
DataHandle<edm4hep::SimTrackerHitCollection> m_input_sim_hits{"inputSimHits", Gaudi::DataHandle::Reader, this};
// Output digitized tracker hit collection name
DataHandle<edm4hep::TrackerHitCollection> m_output_digi_hits{"outputDigiHits", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::TrackerHit3DCollection> m_output_digi_hits{"outputDigiHits", Gaudi::DataHandle::Writer, this};

// Detector readout name
Gaudi::Property<std::string> m_readoutName{this, "readoutName", "CDCHHits", "Name of the detector readout"};
Expand Down
2 changes: 1 addition & 1 deletion DCHdigi/src/DCHsimpleDigitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ StatusCode DCHsimpleDigitizer::execute() {
debug() << "Input Sim Hit collection size: " << input_sim_hits->size() << endmsg;

// Digitize the sim hits
edm4hep::TrackerHitCollection* output_digi_hits = m_output_digi_hits.createAndPut();
edm4hep::TrackerHit3DCollection* output_digi_hits = m_output_digi_hits.createAndPut();
for (const auto& input_sim_hit : *input_sim_hits) {
auto output_digi_hit = output_digi_hits->create();
// smear the hit position: need to go in the wire local frame to smear in the direction aligned/perpendicular with the wire for z/distanceToWire, taking e.g. stereo angle into account
Expand Down
9 changes: 8 additions & 1 deletion Tracking/include/GenFitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@

// EDM4HEP
#include "edm4hep/TrackCollection.h"
#if __has_include("edm4hep/TrackerHit3DCollection.h")
#include "edm4hep/TrackerHit3DCollection.h"
#else
#include "edm4hep/TrackerHitCollection.h"
namespace edm4hep {
using TrackerHit3DCollection = edm4hep::TrackerHitCollection;
} // namespace edm4hep
#endif

// GENFIT
//#include "WireMeasurement.h"
Expand Down Expand Up @@ -42,7 +49,7 @@ class GenFitter : public GaudiAlgorithm {

private:
// Input tracker hit collection name
DataHandle<edm4hep::TrackerHitCollection> m_input_hits{"inputHits", Gaudi::DataHandle::Reader, this};
DataHandle<edm4hep::TrackerHit3DCollection> m_input_hits{"inputHits", Gaudi::DataHandle::Reader, this};
// Output track collection name
DataHandle<edm4hep::TrackCollection> m_output_tracks{"outputTracks", Gaudi::DataHandle::Writer, this};
// Transient genfit measurements used internally by genfit to run the tracking
Expand Down
2 changes: 1 addition & 1 deletion Tracking/src/GenFitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ StatusCode GenFitter::initialize() { return StatusCode::SUCCESS; }

StatusCode GenFitter::execute() {
// Get the input collection with tracker hits
const edm4hep::TrackerHitCollection* input_hits = m_input_hits.get();
const edm4hep::TrackerHit3DCollection* input_hits = m_input_hits.get();
verbose() << "Input Hit collection size: " << input_hits->size() << endmsg;

// Convert edm4hep::TrackerHitCollection to Genfit measurements
Expand Down
12 changes: 10 additions & 2 deletions VTXdigi/include/VTXdigitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@

// EDM4HEP
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/TrackCollection.h"
#if __has_include("edm4hep/TrackerHit3DCollection.h")
#include "edm4hep/TrackerHit3DCollection.h"
#else
#include "edm4hep/TrackerHitCollection.h"
namespace edm4hep {
using TrackerHit3DCollection = edm4hep::TrackerHitCollection;
} // namespace edm4hep
#endif

// DD4HEP
#include "DD4hep/Detector.h" // for dd4hep::VolumeManager
Expand All @@ -23,7 +31,7 @@

/** @class VTXdigitizer
*
* Algorithm for creating digitized (meaning 'reconstructed' for now) vertex detector hits (edm4hep::TrackerHit) from Geant4 hits (edm4hep::SimTrackerHit).
* Algorithm for creating digitized (meaning 'reconstructed' for now) vertex detector hits (edm4hep::TrackerHit3D) from Geant4 hits (edm4hep::SimTrackerHit).
*
* @author Brieuc Francois
* @date 2023-03
Expand Down Expand Up @@ -51,7 +59,7 @@ class VTXdigitizer : public GaudiAlgorithm {
// Input sim vertex hit collection name
DataHandle<edm4hep::SimTrackerHitCollection> m_input_sim_hits{"inputSimHits", Gaudi::DataHandle::Reader, this};
// Output digitized vertex hit collection name
DataHandle<edm4hep::TrackerHitCollection> m_output_digi_hits{"outputDigiHits", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::TrackerHit3DCollection> m_output_digi_hits{"outputDigiHits", Gaudi::DataHandle::Writer, this};

// Detector name
Gaudi::Property<std::string> m_detectorName{this, "detectorName", "Vertex", "Name of the detector (default: Vertex)"};
Expand Down
2 changes: 1 addition & 1 deletion VTXdigi/src/VTXdigitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ StatusCode VTXdigitizer::execute() {
unsigned nDismissedHits=0;

// Digitize the sim hits
edm4hep::TrackerHitCollection* output_digi_hits = m_output_digi_hits.createAndPut();
edm4hep::TrackerHit3DCollection* output_digi_hits = m_output_digi_hits.createAndPut();
for (const auto& input_sim_hit : *input_sim_hits) {
auto output_digi_hit = output_digi_hits->create();

Expand Down

0 comments on commit 4aef16f

Please sign in to comment.