Skip to content

Commit

Permalink
new algorithm for Andrea
Browse files Browse the repository at this point in the history
  • Loading branch information
doloresgarcia committed Jun 26, 2024
1 parent e4385e5 commit 7936715
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 5 deletions.
58 changes: 58 additions & 0 deletions Tracking/include/Evaluation_efficiency.h
Original file line number Diff line number Diff line change
@@ -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<extension::TrackCollection> m_input_tracks{"inputTracks", Gaudi::DataHandle::Writer, this};

};
29 changes: 29 additions & 0 deletions Tracking/src/Evaluation_efficiency.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "Evaluation_efficiency.h"
#include <iostream>
#include <sstream>
#include <vector>




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; }

17 changes: 12 additions & 5 deletions Tracking/src/GenFitter_evaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 <float> 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 <float> ListGlobalInputs;
Expand Down Expand Up @@ -197,7 +204,7 @@ StatusCode GenFitter_eval::execute(const EventContext&) const {
// std::cout << "Input Hit collection size inputHits_VTXOB: " << it <<std::endl;
int it_3 = 0;

std::vector <float> ListHitMC_CDC;
// std::vector <float> ListHitMC_CDC;
std::vector <float> ListHitType_CDC;
for (const auto& input_sim_hit : *input_hits_CDC) {
ListGlobalInputs.push_back(input_sim_hit.getLeftPosition().x);
Expand Down Expand Up @@ -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<int>()]);
hit_extension.setEDep(ListHitMC_VTXIB[index_id.item<int>()]);
hit_extension.setPosition(hit.getPosition());
// output_track.addToTrackerHits(hit_extension);
} else if ((torch::sum(mask_VTOB)>0).item<bool>()){
Expand All @@ -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<int>()]);
hit_extension.setEDep(ListHitMC_VTXOB[index_id.item<int>()]);
hit_extension.setPosition(hit.getPosition());
output_track.addToTrackerHits(hit_extension);
} else if ((torch::sum(mask_CDC)>0).item<bool>()){
Expand All @@ -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<int>()]);
hit_extension.setEDep(ListHitMC_CDC[index_id.item<int>()]);
// hit_extension.setEDep(0);
hit_extension.setPosition(hit.getLeftPosition());
output_track.addToTrackerHits(hit_extension);
Expand Down

0 comments on commit 7936715

Please sign in to comment.