Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vtx sim digi link #28

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions VTXdigi/include/VTXdigitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -60,6 +61,8 @@ class VTXdigitizer : public Gaudi::Algorithm {
mutable DataHandle<edm4hep::SimTrackerHitCollection> m_input_sim_hits{"inputSimHits", Gaudi::DataHandle::Reader, this};
// Output digitized vertex hit collection name
mutable DataHandle<edm4hep::TrackerHit3DCollection> m_output_digi_hits{"outputDigiHits", Gaudi::DataHandle::Writer, this};
// Output link between sim hits and digitized hits
mutable DataHandle<edm4hep::TrackerHitSimTrackerHitLinkCollection> m_output_sim_digi_link{"outputSimDigiAssociation", Gaudi::DataHandle::Writer, this};

// Detector name
Gaudi::Property<std::string> m_detectorName{this, "detectorName", "Vertex", "Name of the detector (default: Vertex)"};
Expand Down
8 changes: 8 additions & 0 deletions VTXdigi/src/VTXdigitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 6 additions & 1 deletion VTXdigi/test/runVTXdigitizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading