Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-13 07:53:58

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 Chao Peng, Wouter Deconinck, Sylvester Joosten, Barak Schmookler, David Lawrence
0003 
0004 // A general digitization for CalorimeterHit from simulation
0005 // 1. Smear energy deposit with a/sqrt(E/GeV) + b + c/E or a/sqrt(E/GeV) (relative value)
0006 // 2. Digitize the energy with dynamic ADC range and add pedestal (mean +- sigma)
0007 // 3. Time conversion with smearing resolution (absolute value)
0008 // 4. Signal is summed if the SumFields are provided
0009 //
0010 // Author: Chao Peng
0011 // Date: 06/02/2021
0012 
0013 #pragma once
0014 
0015 #include <algorithms/algorithm.h>
0016 #include <algorithms/geo.h>
0017 #include <DD4hep/IDDescriptor.h>
0018 #include <edm4eic/MCRecoCalorimeterHitAssociationCollection.h>
0019 #include <edm4hep/RawCalorimeterHitCollection.h>
0020 #include <edm4hep/SimCalorimeterHitCollection.h>
0021 #include <random>
0022 #include <stdint.h>
0023 #include <string>
0024 #include <string_view>
0025 #include <functional>
0026 
0027 #include "CalorimeterHitDigiConfig.h"
0028 #include "algorithms/interfaces/WithPodConfig.h"
0029 
0030 namespace eicrecon {
0031 
0032 using CalorimeterHitDigiAlgorithm =
0033     algorithms::Algorithm<algorithms::Input<edm4hep::SimCalorimeterHitCollection>,
0034                           algorithms::Output<edm4hep::RawCalorimeterHitCollection,
0035                                              edm4eic::MCRecoCalorimeterHitAssociationCollection>>;
0036 
0037 class CalorimeterHitDigi : public CalorimeterHitDigiAlgorithm,
0038                            public WithPodConfig<CalorimeterHitDigiConfig> {
0039 
0040 public:
0041   CalorimeterHitDigi(std::string_view name)
0042       : CalorimeterHitDigiAlgorithm{
0043             name,
0044             {"inputHitCollection"},
0045             {"outputRawHitCollection", "outputRawHitAssociationCollection"},
0046             "Smear energy deposit, digitize within ADC range, add pedestal, "
0047             "convert time with smearing resolution, and sum signals."} {}
0048 
0049   void init() final;
0050   void process(const Input&, const Output&) const final;
0051 
0052 private:
0053   // unitless counterparts of inputs
0054   double stepTDC{0}, tRes{0};
0055 
0056   uint64_t id_mask{0};
0057 
0058   std::function<double(const edm4hep::SimCalorimeterHit& h)> corrMeanScale;
0059 
0060   dd4hep::IDDescriptor id_spec;
0061 
0062   enum readout_enum { kSimpleReadout, kPoissonPhotonReadout, kSipmReadout };
0063   enum readout_enum readoutType { kSimpleReadout };
0064 
0065 private:
0066   const algorithms::GeoSvc& m_geo = algorithms::GeoSvc::instance();
0067 
0068   mutable std::default_random_engine m_generator;
0069   mutable std::normal_distribution<double> m_gaussian;
0070 };
0071 
0072 } // namespace eicrecon