From 7a855d4e97a994f13b4e213b46bce6e2b2b85307 Mon Sep 17 00:00:00 2001 From: lintao <lintao51@gmail.com> Date: Tue, 15 Oct 2019 16:52:03 +0800 Subject: [PATCH] WIP: Create sim tracker collections. --- Simulation/DetSimAna/CMakeLists.txt | 5 +++-- Simulation/DetSimAna/src/ExampleAnaElemTool.cpp | 6 ++++++ Simulation/DetSimAna/src/ExampleAnaElemTool.h | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Simulation/DetSimAna/CMakeLists.txt b/Simulation/DetSimAna/CMakeLists.txt index 458772ae..9ce97422 100644 --- a/Simulation/DetSimAna/CMakeLists.txt +++ b/Simulation/DetSimAna/CMakeLists.txt @@ -2,6 +2,7 @@ gaudi_subdir(DetSimAna v0r0) gaudi_depends_on_subdirs( + FWCore Simulation/DetSimInterface ) @@ -20,8 +21,8 @@ set(DetSimAna_srcs message("podio_LIBRARIES: ${podio_LIBRARIES}") message("plcio_LIBRARIES: ${plcio_LIBRARIES}") gaudi_add_module(DetSimAna ${DetSimAna_srcs} - INCLUDE_DIRS DetSimInterface DD4hep GaudiKernel Geant4 + INCLUDE_DIRS DetSimInterface FWCore DD4hep GaudiKernel Geant4 ${plcio_INCLUDE_DIRS} ${podio_INCLUDE_DIRS} - LINK_LIBRARIES DetSimInterface DD4hep ${DD4hep_COMPONENT_LIBRARIES} GaudiKernel Geant4 + LINK_LIBRARIES DetSimInterface FWCore DD4hep ${DD4hep_COMPONENT_LIBRARIES} GaudiKernel Geant4 ${plcio_LIBRARIES} ${podio_LIBRARIES} ) diff --git a/Simulation/DetSimAna/src/ExampleAnaElemTool.cpp b/Simulation/DetSimAna/src/ExampleAnaElemTool.cpp index 0b59081d..518debac 100644 --- a/Simulation/DetSimAna/src/ExampleAnaElemTool.cpp +++ b/Simulation/DetSimAna/src/ExampleAnaElemTool.cpp @@ -33,6 +33,9 @@ ExampleAnaElemTool::EndOfEventAction(const G4Event* anEvent) { // save all data + // create collections. + auto trackercols = m_trackerCol.createAndPut(); + // readout defined in DD4hep auto lcdd = &(dd4hep::Detector::getInstance()); auto allReadouts = lcdd->readouts(); @@ -107,6 +110,9 @@ ExampleAnaElemTool::EndOfEventAction(const G4Event* anEvent) { dd4hep::sim::Geant4TrackerHit* trk_hit = dynamic_cast<dd4hep::sim::Geant4TrackerHit*>(h); if (trk_hit) { info() << " cast to dd4hep::sim::Geant4TrackerHit. " << endmsg; + + auto edm_trk_hit = trackercols->create(); + } dd4hep::sim::Geant4CalorimeterHit* cal_hit = dynamic_cast<dd4hep::sim::Geant4CalorimeterHit*>(h); diff --git a/Simulation/DetSimAna/src/ExampleAnaElemTool.h b/Simulation/DetSimAna/src/ExampleAnaElemTool.h index 01e6275e..156b604a 100644 --- a/Simulation/DetSimAna/src/ExampleAnaElemTool.h +++ b/Simulation/DetSimAna/src/ExampleAnaElemTool.h @@ -2,8 +2,11 @@ #define ExampleAnaElemTool_h #include "GaudiKernel/AlgTool.h" +#include "FWCore/DataHandle.h" #include "DetSimInterface/IAnaElemTool.h" +#include "plcio/SimTrackerHitCollection.h" + class ExampleAnaElemTool: public extends<AlgTool, IAnaElemTool> { public: @@ -31,6 +34,10 @@ public: StatusCode initialize() override; StatusCode finalize() override; +private: + DataHandle<plcio::SimTrackerHitCollection> m_trackerCol{"SimTrackerCol", + Gaudi::DataHandle::Writer, this}; + }; #endif -- GitLab