Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022, 2023, Christopher Dilks, Luigi Dello Stritto
0003 
0004 #pragma once
0005 
0006 #include <spdlog/spdlog.h>
0007 
0008 namespace eicrecon {
0009 class PhotoMultiplierHitDigiConfig {
0010 public:
0011   // Detector and readout identifiers
0012   std::string detectorName{""};
0013   std::string readoutClass{""};
0014 
0015   // random number generator seed
0016   /* FIXME: don't use 0 if `TRandomMixMax` is the RNG, it can get "stuck"
0017        * FIXME: remove this warning when this issue is resolved:
0018        *        https://github.com/eic/EICrecon/issues/539
0019        */
0020   unsigned long seed = 1; // seed for RNG (note: `0` might mean "unique" seed)
0021 
0022   // triggering
0023   double hitTimeWindow =
0024       20.0; // time gate in which 2 input hits will be grouped to 1 output hit // [ns]
0025   double timeResolution = 1 / 16.0; // time resolution (= 1 / TDC counts per unit time) // [ns]
0026   double speMean        = 80.0;     // mean ADC counts for a single photon
0027   double speError       = 16.0;     // sigma of ADC counts for a single photon
0028   double pedMean        = 200.0;    // mean ADC counts for the pedestal
0029   double pedError       = 3.0;      // sigma of ADC counts for the pedestal
0030 
0031   // noise
0032   bool enableNoise       = false;
0033   double noiseRate       = 20000; // [Hz]
0034   double noiseTimeWindow = 20.0;  // [ns]
0035 
0036   // SiPM pixels
0037   bool enablePixelGaps = false; // enable/disable removal of hits in gaps between pixels
0038 
0039   // overall safety factor
0040   /* simulations assume the detector is ideal and perfect, but reality is
0041        * often neither; use this safety factor to reduce the number of initial
0042        * photon hits for a more conservative estimate of the number of
0043        * photoelectrons, or set to 1 to apply no such factor
0044        */
0045   double safetyFactor = 1.0; // allowed range: (0,1]
0046 
0047   // quantum efficiency
0048   bool enableQuantumEfficiency = true;
0049   // - wavelength units are [nm]
0050   // FIXME: figure out how users can override this, maybe an external `yaml` file
0051   std::vector<std::pair<double, double>> quantumEfficiency = {
0052       {315, 0.00}, {325, 0.04}, {340, 0.10}, {350, 0.20}, {370, 0.30}, {400, 0.35},
0053       {450, 0.40}, {500, 0.38}, {550, 0.35}, {600, 0.27}, {650, 0.20}, {700, 0.15},
0054       {750, 0.12}, {800, 0.08}, {850, 0.06}, {900, 0.04}, {1000, 0.00}};
0055 
0056   /*
0057          std::vector<std::pair<double, double> > quantumEfficiency = { // test unit QE
0058          {325, 1.00},
0059          {900, 1.00}
0060          };
0061          */
0062 
0063   friend std::ostream& operator<<(std::ostream& os, const PhotoMultiplierHitDigiConfig& cfg);
0064 };
0065 
0066 std::ostream& operator<<(std::ostream& os, const PhotoMultiplierHitDigiConfig& cfg) {
0067   os << fmt::format("{:=^60}", " PhotoMultiplierHitDigiConfig Settings ") << std::endl;
0068   auto print_param = [&os](auto name, auto val) {
0069     os << fmt::format("  {:>20} = {:<}", name, val) << std::endl;
0070   };
0071   print_param("seed", cfg.seed);
0072   print_param("hitTimeWindow", cfg.hitTimeWindow);
0073   print_param("timeResolution", cfg.timeResolution);
0074   print_param("speMean", cfg.speMean);
0075   print_param("speError", cfg.speError);
0076   print_param("pedMean", cfg.pedMean);
0077   print_param("pedError", cfg.pedError);
0078   print_param("enablePixelGaps", cfg.enablePixelGaps);
0079   print_param("safetyFactor", cfg.safetyFactor);
0080   print_param("enableNoise", cfg.enableNoise);
0081   print_param("noiseRate", cfg.noiseRate);
0082   print_param("noiseTimeWindow", cfg.noiseTimeWindow);
0083   os << fmt::format("{:-^60}", " Quantum Efficiency vs. Wavelength ") << std::endl;
0084   for (auto& [wl, qe] : cfg.quantumEfficiency)
0085     os << fmt::format("  {:>10} {:<}", wl, qe) << std::endl;
0086   return os;
0087 }
0088 
0089 } // namespace eicrecon