Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-18 08:30:19

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2026 Minho Kim
0003 
0004 #pragma once
0005 
0006 #include <DD4hep/Detector.h>
0007 #include <DD4hep/IDDescriptor.h>
0008 #include <Parsers/Primitives.h>
0009 #include <algorithms/algorithm.h>
0010 #include <algorithms/geo.h>
0011 #include <edm4hep/EventHeaderCollection.h>
0012 #include <edm4hep/SimCalorimeterHitCollection.h>
0013 #include <cstddef>
0014 #include <gsl/pointers>
0015 #include <map>
0016 #include <string>
0017 #include <string_view>
0018 #include <vector>
0019 
0020 #include "algorithms/calorimetry/EdepToNpeConversionConfig.h"
0021 #include "algorithms/interfaces/UniqueIDGenSvc.h"
0022 #include "algorithms/interfaces/WithPodConfig.h"
0023 
0024 namespace eicrecon {
0025 
0026 using EdepToNpeConversionAlgorithm = algorithms::Algorithm<
0027     algorithms::Input<edm4hep::EventHeaderCollection, edm4hep::SimCalorimeterHitCollection>,
0028     algorithms::Output<edm4hep::SimCalorimeterHitCollection>>;
0029 
0030 class EdepToNpeConversion : public EdepToNpeConversionAlgorithm,
0031                             public WithPodConfig<EdepToNpeConversionConfig> {
0032 
0033 public:
0034   EdepToNpeConversion(std::string_view name)
0035       : EdepToNpeConversionAlgorithm{name, {"EventHeader", "inputHits"}, {"outputHits"}, {}} {}
0036   void init() final;
0037   void process(const Input&, const Output&) const final;
0038 
0039 private:
0040   double get_edep_to_npe_factor(const edm4hep::SimCalorimeterHit& hit) const;
0041 
0042   const dd4hep::Detector* m_detector{algorithms::GeoSvc::instance().detector()};
0043   const algorithms::UniqueIDGenSvc& m_uid = algorithms::UniqueIDGenSvc::instance();
0044 
0045   dd4hep::IDDescriptor m_id_spec;
0046   const dd4hep::BitFieldCoder* m_id_dec = nullptr;
0047   std::vector<std::size_t> m_field_idxs{};
0048   std::map<std::vector<int>, double> m_edep_to_npe_lut{};
0049 };
0050 
0051 } // namespace eicrecon