File indexing completed on 2024-09-28 07:03:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <algorithm>
0014
0015 #include "Gaudi/Property.h"
0016 #include "GaudiAlg/GaudiAlgorithm.h"
0017 #include "GaudiAlg/GaudiTool.h"
0018 #include "GaudiAlg/Transformer.h"
0019 #include "GaudiKernel/PhysicalConstants.h"
0020 #include "GaudiKernel/RndmGenerators.h"
0021 #include "GaudiKernel/ToolHandle.h"
0022
0023 #include "DDRec/CellIDPositionConverter.h"
0024 #include "DDRec/Surface.h"
0025 #include "DDRec/SurfaceManager.h"
0026
0027 #include <k4FWCore/DataHandle.h>
0028 #include <k4Interface/IGeoSvc.h>
0029
0030
0031 #include "edm4eic/PMTHitCollection.h"
0032 #include "edm4eic/RawTrackerHitCollection.h"
0033
0034 using namespace Gaudi::Units;
0035
0036 namespace Jug::Reco {
0037
0038
0039
0040
0041
0042
0043
0044
0045 class PhotoMultiplierReco : public GaudiAlgorithm {
0046 private:
0047 DataHandle<edm4eic::RawTrackerHitCollection> m_inputHitCollection{"inputHitCollection", Gaudi::DataHandle::Reader, this};
0048 DataHandle<edm4eic::PMTHitCollection> m_outputHitCollection{"outputHitCollection", Gaudi::DataHandle::Writer, this};
0049 Gaudi::Property<double> m_timeStep{this, "timeStep", 0.0625 * ns};
0050 Gaudi::Property<double> m_minNpe{this, "minNpe", 0.0};
0051 Gaudi::Property<double> m_speMean{this, "speMean", 80.0};
0052 Gaudi::Property<double> m_pedMean{this, "pedMean", 200.0};
0053
0054 SmartIF<IGeoSvc> m_geoSvc;
0055 std::shared_ptr<const dd4hep::rec::CellIDPositionConverter> m_converter;
0056
0057 public:
0058
0059 PhotoMultiplierReco(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) {
0060 declareProperty("inputHitCollection", m_inputHitCollection, "");
0061 declareProperty("outputHitCollection", m_outputHitCollection, "");
0062 }
0063
0064 StatusCode initialize() override {
0065 if (GaudiAlgorithm::initialize().isFailure()) {
0066 return StatusCode::FAILURE;
0067 }
0068 m_geoSvc = service("GeoSvc");
0069 if (!m_geoSvc) {
0070 error() << "Unable to locate Geometry Service. "
0071 << "Make sure you have GeoSvc and SimSvc in the right order in the configuration." << endmsg;
0072 return StatusCode::FAILURE;
0073 }
0074 m_converter = std::make_shared<const dd4hep::rec::CellIDPositionConverter>(*(m_geoSvc->getDetector()));
0075 return StatusCode::SUCCESS;
0076 }
0077
0078 StatusCode execute() override {
0079
0080 const auto& rawhits = *m_inputHitCollection.get();
0081
0082 auto& hits = *m_outputHitCollection.createAndPut();
0083
0084
0085 for (const auto& rh : rawhits) {
0086 float npe = (rh.getCharge() - m_pedMean) / m_speMean;
0087 if (npe >= m_minNpe) {
0088 float time = rh.getTimeStamp() * (static_cast<float>(m_timeStep) / ns);
0089 auto id = rh.getCellID();
0090
0091 auto gpos = m_converter->position(id);
0092
0093 auto pos = m_converter->findContext(id)->volumePlacement().position();
0094
0095 auto dim = m_converter->cellDimensions(id);
0096 hits.push_back(edm4eic::PMTHit{
0097 rh.getCellID(),
0098 npe,
0099 time,
0100 static_cast<float>(m_timeStep / ns),
0101 {static_cast<float>(gpos.x()), static_cast<float>(gpos.y()), static_cast<float>(gpos.z())},
0102 {static_cast<float>(dim[0] / mm), static_cast<float>(dim[1] / mm), static_cast<float>(dim[2] / mm)},
0103 0,
0104 {static_cast<float>(pos.x()), static_cast<float>(pos.y()), static_cast<float>(pos.z())}});
0105 }
0106 }
0107
0108 return StatusCode::SUCCESS;
0109 }
0110 };
0111
0112
0113 DECLARE_COMPONENT(PhotoMultiplierReco)
0114
0115 }