Skip to content

Commit

Permalink
DCHdigi_v01 now uses close-to-ready EDM4hep class
Browse files Browse the repository at this point in the history
  • Loading branch information
atolosadelgado committed Dec 18, 2024
1 parent 897feb8 commit 0d6de6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
10 changes: 5 additions & 5 deletions DCHdigi/include/DCHdigi_v01.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Processor produces collection of Digitized hits of Drift Chamber v2<br>
* @param DCH_simhits The name of input collection, type edm4hep::SimTrackerHitCollection <br>
* (default name empty) <br>
* @param DCH_DigiCollection The name of out collection, type extension::DriftChamberDigiV2Collection <br>
* @param DCH_DigiCollection The name of out collection, type extension::SenseWireHitCollection <br>
* (default name DCH_DigiCollection) <br>
* @param DCH_name DCH subdetector name <br>
* (default value DCH_v2) <br>
Expand Down Expand Up @@ -50,8 +50,8 @@
#include "edm4hep/SimTrackerHitCollection.h"

// EDM4HEP extension
#include "extension/DriftChamberDigiV2Collection.h"
#include "extension/MCRecoDriftChamberDigiV2AssociationCollection.h"
#include "extension/SenseWireHitCollection.h"
#include "extension/SenseWireHitSimTrackerHitLinkCollection.h"

// DD4hep
#include "DD4hep/Detector.h" // for dd4hep::VolumeManager
Expand All @@ -77,14 +77,14 @@

struct DCHdigi_v01 final
: k4FWCore::MultiTransformer<
std::tuple<extension::DriftChamberDigiV2Collection, extension::MCRecoDriftChamberDigiV2AssociationCollection>(
std::tuple<extension::SenseWireHitCollection, extension::SenseWireHitSimTrackerHitLinkCollection>(
const edm4hep::SimTrackerHitCollection&, const edm4hep::EventHeaderCollection&)> {
DCHdigi_v01(const std::string& name, ISvcLocator* svcLoc);

StatusCode initialize() override;
StatusCode finalize() override;

std::tuple<extension::DriftChamberDigiV2Collection, extension::MCRecoDriftChamberDigiV2AssociationCollection>
std::tuple<extension::SenseWireHitCollection, extension::SenseWireHitSimTrackerHitLinkCollection>
operator()(const edm4hep::SimTrackerHitCollection&, const edm4hep::EventHeaderCollection&) const override;

private:
Expand Down
23 changes: 11 additions & 12 deletions DCHdigi/src/DCHdigi_v01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <iostream>
#include <sstream>

#include "extension/MutableDriftChamberDigiV2.h"
#include "extension/MutableSenseWireHit.h"

///////////////////////////////////////////////////////////////////////////////////////
////////////////////// DCHdigi_v01 constructor ////////////////////////////
Expand Down Expand Up @@ -96,7 +96,7 @@ StatusCode DCHdigi_v01::initialize() {
///////////////////////////////////////////////////////////////////////////////////////
/////////////////////// operator() ////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
std::tuple<extension::DriftChamberDigiV2Collection, extension::MCRecoDriftChamberDigiV2AssociationCollection>
std::tuple<extension::SenseWireHitCollection, extension::SenseWireHitSimTrackerHitLinkCollection>
DCHdigi_v01::operator()(const edm4hep::SimTrackerHitCollection& input_sim_hits,
const edm4hep::EventHeaderCollection& headers) const {
// initialize seed for random engine
Expand All @@ -105,8 +105,8 @@ DCHdigi_v01::operator()(const edm4hep::SimTrackerHitCollection& input_sim_hits,
debug() << "Input Sim Hit collection size: " << input_sim_hits.size() << endmsg;

// Create the collections we are going to return
extension::DriftChamberDigiV2Collection output_digi_hits;
extension::MCRecoDriftChamberDigiV2AssociationCollection output_digi_sim_association;
extension::SenseWireHitCollection output_digi_hits;
extension::SenseWireHitSimTrackerHitLinkCollection output_digi_sim_association;

//loop over hit collection
for (const auto& input_sim_hit : input_sim_hits) {
Expand Down Expand Up @@ -157,21 +157,20 @@ DCHdigi_v01::operator()(const edm4hep::SimTrackerHitCollection& input_sim_hits,
auto directionSW = Convert_TVector3_to_EDM4hepVector(wire_direction_ez, 1. / MM_TO_CM);
float distanceToWire = distanceToWire_smeared / MM_TO_CM;

extension::MutableDriftChamberDigiV2 oDCHdigihit;
extension::MutableSenseWireHit oDCHdigihit;
oDCHdigihit.setCellID(input_sim_hit.getCellID());
oDCHdigihit.setType(type);
oDCHdigihit.setQuality(quality);
oDCHdigihit.setTime(input_sim_hit.getTime());
oDCHdigihit.setEDep(input_sim_hit.getEDep());
oDCHdigihit.setEDepError(eDepError);
oDCHdigihit.setPosition(positionSW);
oDCHdigihit.setDirectionSW(directionSW);
// oDCHdigihit.setDirectionSW(directionSW);
oDCHdigihit.setDistanceToWire(distanceToWire);
// For the sake of speed, let the dNdx calculation be optional
if( m_calculate_dndx.value() )
{
auto [nCluster, nElectrons_v] = CalculateClusters(input_sim_hit);
oDCHdigihit.setNCluster(nCluster);
// to return the total number of electrons within the step, do the following:
// int nElectronsTotal = std::accumulate( nElectrons_v.begin(), nElectrons_v.end(), 0);
// oDCHdigihit.setNElectronsTotal(nElectronsTotal);
Expand All @@ -182,16 +181,16 @@ DCHdigi_v01::operator()(const edm4hep::SimTrackerHitCollection& input_sim_hits,

output_digi_hits.push_back(oDCHdigihit);

extension::MutableMCRecoDriftChamberDigiV2Association oDCHsimdigi_association;
oDCHsimdigi_association.setDigi(oDCHdigihit);
oDCHsimdigi_association.setSim(input_sim_hit);
extension::MutableSenseWireHitSimTrackerHitLink oDCHsimdigi_association;
oDCHsimdigi_association.setFrom(oDCHdigihit);
oDCHsimdigi_association.setTo(input_sim_hit);
output_digi_sim_association.push_back(oDCHsimdigi_association);

} // end loop over hit collection

/////////////////////////////////////////////////////////////////
return std::make_tuple<extension::DriftChamberDigiV2Collection,
extension::MCRecoDriftChamberDigiV2AssociationCollection>(
return std::make_tuple<extension::SenseWireHitCollection,
extension::SenseWireHitSimTrackerHitLinkCollection>(
std::move(output_digi_hits), std::move(output_digi_sim_association));
}

Expand Down

0 comments on commit 0d6de6b

Please sign in to comment.