Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-09 07:53:20

0001 
0002 // SPDX-License-Identifier: LGPL-3.0-or-later
0003 // Copyright (C) 2022 Chao Peng, Sylvester Joosten, Wouter Deconinck, Chao, Whitney Armstrong
0004 
0005 // Reconstruct digitized outputs, paired with Jug::Digi::CalorimeterHitDigi
0006 // Author: Chao Peng
0007 // Date: 06/14/2021
0008 
0009 #pragma once
0010 
0011 #include <DD4hep/DetElement.h>
0012 #include <DD4hep/Detector.h>
0013 #include <DD4hep/IDDescriptor.h>
0014 #include <DDRec/CellIDPositionConverter.h>
0015 #include <Parsers/Primitives.h>
0016 #include <algorithms/algorithm.h>
0017 #include <algorithms/geo.h>
0018 #include <edm4eic/CalorimeterHitCollection.h>
0019 #include <edm4hep/RawCalorimeterHitCollection.h>
0020 #include <stdint.h>
0021 #include <cstddef>
0022 #include <functional>
0023 #include <gsl/pointers>
0024 #include <string>
0025 #include <string_view>
0026 
0027 #include "CalorimeterHitRecoConfig.h"
0028 #include "algorithms/interfaces/WithPodConfig.h"
0029 
0030 namespace eicrecon {
0031 
0032 using CalorimeterHitRecoAlgorithm =
0033     algorithms::Algorithm<algorithms::Input<edm4hep::RawCalorimeterHitCollection>,
0034                           algorithms::Output<edm4eic::CalorimeterHitCollection>>;
0035 
0036 class CalorimeterHitReco : public CalorimeterHitRecoAlgorithm,
0037                            public WithPodConfig<CalorimeterHitRecoConfig> {
0038 
0039 public:
0040   CalorimeterHitReco(std::string_view name)
0041       : CalorimeterHitRecoAlgorithm{name,
0042                                     {"inputRawHitCollection"},
0043                                     {"outputRecHitCollection"},
0044                                     "Reconstruct hit from digitized input."} {}
0045 
0046   void init() final;
0047   void process(const Input&, const Output&) const final;
0048 
0049 private:
0050   // unitless counterparts of the input parameters
0051   double thresholdADC{0};
0052   double stepTDC{0};
0053 
0054   std::function<double(const edm4hep::RawCalorimeterHit& h)> sampFrac;
0055 
0056   dd4hep::IDDescriptor id_spec;
0057   dd4hep::BitFieldCoder* id_dec = nullptr;
0058 
0059   mutable uint32_t NcellIDerrors = 0;
0060   uint32_t MaxCellIDerrors       = 100;
0061 
0062   std::size_t sector_idx{0}, layer_idx{0};
0063 
0064   mutable bool warned_unsupported_segmentation = false;
0065 
0066   dd4hep::DetElement m_local;
0067   std::size_t local_mask = ~static_cast<std::size_t>(0), gpos_mask = static_cast<std::size_t>(0);
0068 
0069 private:
0070   const dd4hep::Detector* m_detector{algorithms::GeoSvc::instance().detector()};
0071   const dd4hep::rec::CellIDPositionConverter* m_converter{
0072       algorithms::GeoSvc::instance().cellIDPositionConverter()};
0073 };
0074 
0075 } // namespace eicrecon