From 79367150767cf631cbc4c61f62eb0a474a439e77 Mon Sep 17 00:00:00 2001 From: doloresgarcia Date: Wed, 26 Jun 2024 17:33:19 +0200 Subject: [PATCH] new algorithm for Andrea --- Tracking/include/Evaluation_efficiency.h | 58 ++++++++++++++++++++++++ Tracking/src/Evaluation_efficiency.cpp | 29 ++++++++++++ Tracking/src/GenFitter_evaluation.cpp | 17 +++++-- 3 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 Tracking/include/Evaluation_efficiency.h create mode 100644 Tracking/src/Evaluation_efficiency.cpp diff --git a/Tracking/include/Evaluation_efficiency.h b/Tracking/include/Evaluation_efficiency.h new file mode 100644 index 0000000..380971e --- /dev/null +++ b/Tracking/include/Evaluation_efficiency.h @@ -0,0 +1,58 @@ +#pragma once + +// GAUDI +#include "Gaudi/Property.h" +// #include "GaudiAlg/GaudiAlgorithm.h" +#include "Gaudi/Algorithm.h" +// K4FWCORE +#include "k4FWCore/DataHandle.h" + +// EDM4HEP +#if __has_include("edm4hep/TrackerHit3DCollection.h") +#include "edm4hep/TrackerHit3DCollection.h" +#else +#include "edm4hep/TrackerHit3D.h" +#include "extension/TrackerHit3D.h" +namespace edm4hep { + using TrackerHit3DCollection = edm4hep::TrackerHitCollection; +} // namespace edm4hep +#endif + +#include "extension/TrackCollection.h" +#include "extension/TrackCollection.h" + +// GENFIT +//#include "WireMeasurement.h" + +/** @class Evaluation_efficiency + * + * + * + * @author Andrea De Vita, Maria Dolores Garcia, Brieuc Francois + * @date 2024-06 + * + */ + +class Evaluation_efficiency : public Gaudi::Algorithm { +public: + explicit Evaluation_efficiency(const std::string&, ISvcLocator*); + virtual ~Evaluation_efficiency(); + /** Initialize. + * @return status code + */ + virtual StatusCode initialize() final; + /** Execute. + * @return status code + */ + virtual StatusCode execute(const EventContext&) const final; + /** Finalize. + * @return status code + */ + virtual StatusCode finalize() final; + +private: + + // Output track collection name + mutable DataHandle m_input_tracks{"inputTracks", Gaudi::DataHandle::Writer, this}; + +}; diff --git a/Tracking/src/Evaluation_efficiency.cpp b/Tracking/src/Evaluation_efficiency.cpp new file mode 100644 index 0000000..ae395ff --- /dev/null +++ b/Tracking/src/Evaluation_efficiency.cpp @@ -0,0 +1,29 @@ +#include "Evaluation_efficiency.h" +#include +#include +#include + + + + +DECLARE_COMPONENT(Evaluation_efficiency) + +GenFitter::Evaluation_efficiency(const std::string& aName, ISvcLocator* aSvcLoc) : Gaudi::Algorithm(aName, aSvcLoc) { + declareProperty("inputTracks", m_input_tracks, "Input track collection name"); +} + +Evaluation_efficiency::~Evaluation_efficiency() {} + +StatusCode Evaluation_efficiency::initialize() { + return StatusCode::SUCCESS;} + + +StatusCode Evaluation_efficiency::execute(const EventContext&) const { + // Get the input collection with tracker hits + + + return StatusCode::SUCCESS; +} + +StatusCode GenFitter::finalize() { return StatusCode::SUCCESS; } + diff --git a/Tracking/src/GenFitter_evaluation.cpp b/Tracking/src/GenFitter_evaluation.cpp index 1ade84a..c171b60 100644 --- a/Tracking/src/GenFitter_evaluation.cpp +++ b/Tracking/src/GenFitter_evaluation.cpp @@ -116,7 +116,7 @@ StatusCode GenFitter_eval::execute(const EventContext&) const { const edm4hep::SimTrackerHitCollection* inputHits_VTXIB_sim = m_input_hits_VTXOB_sim.get(); const edm4hep::SimTrackerHitCollection* inputHits_VTXOB_sim = m_input_hits_VTXOB_sim.get(); const edm4hep::SimTrackerHitCollection* inputHits_CDC_sim = m_input_hits_CDC_sim.get(); - const extension::MCRecoDriftChamberDigiAssociation* inputAssociation_CDC_sim = m_input_Association_CDC.get(); + //const extension::MCRecoDriftChamberDigiAssociation* inputAssociation_CDC_sim = m_input_Association_CDC.get(); std::cout << "Input Hit collection size VTXD: " << inputHits_VTXD_sim->size() << std::endl; // std::cout << "Input Hit collection size VTXIB: " << inputHits_VTXIB->size() << std::endl; // std::cout << "Input Hit collection size VTXOB: " << inputHits_VTXOB->size() << std::endl; @@ -143,6 +143,13 @@ StatusCode GenFitter_eval::execute(const EventContext&) const { auto index_MC = object_id_MC.index; ListHitMC_VTXOB.push_back(index_MC); } + std::vector ListHitMC_CDC; + for (const auto& input_sim_hit : *inputHits_CDC_sim) { + auto MC_particle = input_sim_hit.getParticle(); + auto object_id_MC = MC_particle.getObjectID(); + auto index_MC = object_id_MC.index; + ListHitMC_CDC.push_back(index_MC); + } // size_t size_total = size_CDC+size_VTXD+size_VTXIB+size_VTXOB; std::vector ListGlobalInputs; @@ -197,7 +204,7 @@ StatusCode GenFitter_eval::execute(const EventContext&) const { // std::cout << "Input Hit collection size inputHits_VTXOB: " << it < ListHitMC_CDC; + // std::vector ListHitMC_CDC; std::vector ListHitType_CDC; for (const auto& input_sim_hit : *input_hits_CDC) { ListGlobalInputs.push_back(input_sim_hit.getLeftPosition().x); @@ -285,7 +292,7 @@ StatusCode GenFitter_eval::execute(const EventContext&) const { auto hit_extension = output_hits->create(); hit_extension.setCellID(hit.getCellID()); hit_extension.setType(1); - // hit_extension.setEDep(ListHitMC_VTXIB[index_id.item()]); + hit_extension.setEDep(ListHitMC_VTXIB[index_id.item()]); hit_extension.setPosition(hit.getPosition()); // output_track.addToTrackerHits(hit_extension); } else if ((torch::sum(mask_VTOB)>0).item()){ @@ -294,7 +301,7 @@ StatusCode GenFitter_eval::execute(const EventContext&) const { auto hit_extension = output_hits->create(); hit_extension.setCellID(hit.getCellID()); hit_extension.setType(1); - // hit_extension.setEDep(ListHitMC_VTXOB[index_id.item()]); + hit_extension.setEDep(ListHitMC_VTXOB[index_id.item()]); hit_extension.setPosition(hit.getPosition()); output_track.addToTrackerHits(hit_extension); } else if ((torch::sum(mask_CDC)>0).item()){ @@ -303,7 +310,7 @@ StatusCode GenFitter_eval::execute(const EventContext&) const { auto hit_extension = output_hits->create(); hit_extension.setCellID(hit.getCellID()); hit_extension.setType(0); - //hit_extension.setEDep(ListHitMC_CDC[index_id.item()]); + hit_extension.setEDep(ListHitMC_CDC[index_id.item()]); // hit_extension.setEDep(0); hit_extension.setPosition(hit.getLeftPosition()); output_track.addToTrackerHits(hit_extension);