From 916e7fb09e66393ea4a221ea2c8ee707229ea930 Mon Sep 17 00:00:00 2001 From: Brieuc Francois Date: Thu, 8 Aug 2024 10:12:12 +0200 Subject: [PATCH] Vtx sim digi link (#28) * Add a Digi Sim link for VTX * Update VTX tests to IDEA v03 * Update VTX tests to IDEA v03 --- VTXdigi/include/VTXdigitizer.h | 3 +++ VTXdigi/src/VTXdigitizer.cpp | 8 ++++++++ VTXdigi/test/runVTXdigitizer.py | 7 ++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/VTXdigi/include/VTXdigitizer.h b/VTXdigi/include/VTXdigitizer.h index 7e91170..e0cf0de 100644 --- a/VTXdigi/include/VTXdigitizer.h +++ b/VTXdigi/include/VTXdigitizer.h @@ -21,6 +21,7 @@ namespace edm4hep { using TrackerHit3DCollection = edm4hep::TrackerHitCollection; } // namespace edm4hep #endif +#include "edm4hep/TrackerHitSimTrackerHitLinkCollection.h" // DD4HEP #include "DD4hep/Detector.h" // for dd4hep::VolumeManager @@ -60,6 +61,8 @@ class VTXdigitizer : public Gaudi::Algorithm { mutable DataHandle m_input_sim_hits{"inputSimHits", Gaudi::DataHandle::Reader, this}; // Output digitized vertex hit collection name mutable DataHandle m_output_digi_hits{"outputDigiHits", Gaudi::DataHandle::Writer, this}; + // Output link between sim hits and digitized hits + mutable DataHandle m_output_sim_digi_link{"outputSimDigiAssociation", Gaudi::DataHandle::Writer, this}; // Detector name Gaudi::Property m_detectorName{this, "detectorName", "Vertex", "Name of the detector (default: Vertex)"}; diff --git a/VTXdigi/src/VTXdigitizer.cpp b/VTXdigi/src/VTXdigitizer.cpp index 1011d00..94b04d0 100644 --- a/VTXdigi/src/VTXdigitizer.cpp +++ b/VTXdigi/src/VTXdigitizer.cpp @@ -6,6 +6,7 @@ VTXdigitizer::VTXdigitizer(const std::string& aName, ISvcLocator* aSvcLoc) : Gaudi::Algorithm(aName, aSvcLoc), m_geoSvc("GeoSvc", "VTXdigitizer") { declareProperty("inputSimHits", m_input_sim_hits, "Input sim vertex hit collection name"); declareProperty("outputDigiHits", m_output_digi_hits, "Output digitized vertex hit collection name"); + declareProperty("outputSimDigiAssociation", m_output_sim_digi_link, "Output link between sim hits and digitized hits"); } VTXdigitizer::~VTXdigitizer() {} @@ -51,8 +52,10 @@ StatusCode VTXdigitizer::execute(const EventContext&) const { // Digitize the sim hits edm4hep::TrackerHit3DCollection* output_digi_hits = m_output_digi_hits.createAndPut(); + edm4hep::TrackerHitSimTrackerHitLinkCollection* output_sim_digi_link_col = m_output_sim_digi_link.createAndPut(); for (const auto& input_sim_hit : *input_sim_hits) { auto output_digi_hit = output_digi_hits->create(); + auto output_sim_digi_link = output_sim_digi_link_col->create(); // smear the hit position: need to go in the local frame of the silicon sensor to smear in the direction along/perpendicular to the stave @@ -167,6 +170,11 @@ StatusCode VTXdigitizer::execute(const EventContext&) const { output_digi_hit.setTime(input_sim_hit.getTime() + m_gauss_time.shoot()); output_digi_hit.setCellID(cellID); + + // Set the link between sim and digi hit + output_sim_digi_link.setFrom(output_digi_hit); + output_sim_digi_link.setTo(input_sim_hit); + } return StatusCode::SUCCESS; } diff --git a/VTXdigi/test/runVTXdigitizer.py b/VTXdigi/test/runVTXdigitizer.py index 49d2031..943542e 100644 --- a/VTXdigi/test/runVTXdigitizer.py +++ b/VTXdigi/test/runVTXdigitizer.py @@ -66,7 +66,7 @@ path_to_detector = os.environ.get("K4GEO", "") # Previously used "FCCDETECTORS" print(path_to_detector) detectors_to_use=[ - 'FCCee/IDEA/compact/IDEA_o1_v02/IDEA_o1_v02.xml', + 'FCCee/IDEA/compact/IDEA_o1_v03/IDEA_o1_v03.xml', # 'FCCee/CLD/compact/CLD_o2_v05/CLD_o2_v05.xml', ] # prefix all xmls with path_to_detector @@ -162,6 +162,7 @@ vtxb_digitizer = VTXdigitizer("VTXBdigitizer", inputSimHits = SimG4SaveTrackerHitsB.SimTrackHits.Path, outputDigiHits = SimG4SaveTrackerHitsB.SimTrackHits.Path.replace("sim", "digi"), + outputSimDigiAssociation = SimG4SaveTrackerHitsB.SimTrackHits.Path.replace("simTrackerHits", "simDigiAssociation"), detectorName = "Vertex", readoutName = "VertexBarrelCollection", xResolution = vertexBarrelResolution_x, @@ -174,6 +175,7 @@ vtxe_digitizer = VTXdigitizer("VTXEdigitizer", inputSimHits = SimG4SaveTrackerHitsE.SimTrackHits.Path, outputDigiHits = SimG4SaveTrackerHitsE.SimTrackHits.Path.replace("sim", "digi"), + outputSimDigiAssociation = SimG4SaveTrackerHitsE.SimTrackHits.Path.replace("simTrackerHits", "simDigiAssociation"), detectorName = "Vertex", readoutName = "VertexEndcapCollection", xResolution = vertexEndcapResolution_x, @@ -188,6 +190,7 @@ vtxib_digitizer = VTXdigitizer("VTXIBdigitizer", inputSimHits = SimG4SaveTrackerHitsIB.SimTrackHits.Path, outputDigiHits = SimG4SaveTrackerHitsIB.SimTrackHits.Path.replace("sim", "digi"), + outputSimDigiAssociation = SimG4SaveTrackerHitsIB.SimTrackHits.Path.replace("simTrackerHits", "simDigiAssociation"), detectorName = "Vertex", readoutName = "VTXIBCollection", xResolution = innerVertexResolution_x, # mm, r-phi direction @@ -200,6 +203,7 @@ vtxob_digitizer = VTXdigitizer("VTXOBdigitizer", inputSimHits = SimG4SaveTrackerHitsOB.SimTrackHits.Path, outputDigiHits = SimG4SaveTrackerHitsOB.SimTrackHits.Path.replace("sim", "digi"), + outputSimDigiAssociation = SimG4SaveTrackerHitsOB.SimTrackHits.Path.replace("simTrackerHits", "simDigiAssociation"), detectorName = "Vertex", readoutName = "VTXOBCollection", xResolution = outerVertexResolution_x, # mm, r-phi direction @@ -212,6 +216,7 @@ vtxd_digitizer = VTXdigitizer("VTXDdigitizer", inputSimHits = SimG4SaveTrackerHitsD.SimTrackHits.Path, outputDigiHits = SimG4SaveTrackerHitsD.SimTrackHits.Path.replace("sim", "digi"), + outputSimDigiAssociation = SimG4SaveTrackerHitsD.SimTrackHits.Path.replace("simTrackerHits", "simDigiAssociation"), detectorName = "Vertex", readoutName = "VTXDCollection", xResolution = outerVertexResolution_x, # mm, r direction