Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-06-29 07:05:54

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 
0014 #pragma once
0015 
0016 #include <algorithms/algorithm.h>
0017 #include <algorithms/geo.h>
0018 #include <DD4hep/IDDescriptor.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 = algorithms::Algorithm<
0033     algorithms::Input<
0034       edm4hep::SimCalorimeterHitCollection
0035     >,
0036     algorithms::Output<
0037       edm4hep::RawCalorimeterHitCollection
0038     >
0039   >;
0040 
0041   class CalorimeterHitDigi
0042   : public CalorimeterHitDigiAlgorithm,
0043     public WithPodConfig<CalorimeterHitDigiConfig> {
0044 
0045   public:
0046     CalorimeterHitDigi(std::string_view name)
0047       : CalorimeterHitDigiAlgorithm{name,
0048                             {"inputHitCollection"},
0049                             {"outputRawHitCollection"},
0050                             "Smear energy deposit, digitize within ADC range, add pedestal, "
0051                             "convert time with smearing resolution, and sum signals."} {}
0052 
0053     void init() final;
0054     void process(const Input&, const Output&) const final;
0055 
0056   private:
0057 
0058     // unitless counterparts of inputs
0059     double           dyRangeADC{0}, stepTDC{0}, tRes{0};
0060 
0061     uint64_t         id_mask{0};
0062 
0063     std::function<double(const edm4hep::SimCalorimeterHit &h)> corrMeanScale;
0064 
0065     dd4hep::IDDescriptor id_spec;
0066 
0067   private:
0068     const algorithms::GeoSvc& m_geo = algorithms::GeoSvc::instance();
0069 
0070     mutable std::default_random_engine m_generator;
0071     mutable std::normal_distribution<double> m_gaussian;
0072 
0073   };
0074 
0075 } // namespace eicrecon