File indexing completed on 2024-06-29 07:05:29
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 "JugBase/DataHandle.h"
0028 #include "JugBase/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
0056 public:
0057
0058 PhotoMultiplierReco(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) {
0059 declareProperty("inputHitCollection", m_inputHitCollection, "");
0060 declareProperty("outputHitCollection", m_outputHitCollection, "");
0061 }
0062
0063 StatusCode initialize() override {
0064 if (GaudiAlgorithm::initialize().isFailure()) {
0065 return StatusCode::FAILURE;
0066 }
0067 m_geoSvc = service("GeoSvc");
0068 if (!m_geoSvc) {
0069 error() << "Unable to locate Geometry Service. "
0070 << "Make sure you have GeoSvc and SimSvc in the right order in the configuration." << endmsg;
0071 return StatusCode::FAILURE;
0072 }
0073 return StatusCode::SUCCESS;
0074 }
0075
0076 StatusCode execute() override {
0077
0078 const auto& rawhits = *m_inputHitCollection.get();
0079
0080 auto& hits = *m_outputHitCollection.createAndPut();
0081
0082
0083 for (const auto& rh : rawhits) {
0084 float npe = (rh.getCharge() - m_pedMean) / m_speMean;
0085 if (npe >= m_minNpe) {
0086 float time = rh.getTimeStamp() * (static_cast<float>(m_timeStep) / ns);
0087 auto id = rh.getCellID();
0088
0089 auto gpos = m_geoSvc->cellIDPositionConverter()->position(id);
0090
0091 auto pos = m_geoSvc->cellIDPositionConverter()->findContext(id)->volumePlacement().position();
0092
0093 auto dim = m_geoSvc->cellIDPositionConverter()->cellDimensions(id);
0094 hits.push_back(edm4eic::PMTHit{
0095 rh.getCellID(),
0096 npe,
0097 time,
0098 static_cast<float>(m_timeStep / ns),
0099 {static_cast<float>(gpos.x()), static_cast<float>(gpos.y()), static_cast<float>(gpos.z())},
0100 {static_cast<float>(dim[0] / mm), static_cast<float>(dim[1] / mm), static_cast<float>(dim[2] / mm)},
0101 0,
0102 {static_cast<float>(pos.x()), static_cast<float>(pos.y()), static_cast<float>(pos.z())}});
0103 }
0104 }
0105
0106 return StatusCode::SUCCESS;
0107 }
0108 };
0109
0110
0111 DECLARE_COMPONENT(PhotoMultiplierReco)
0112
0113 }