Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-06-26 07:05:41

0001 // Copyright 2023, Christopher Dilks
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
0003 
0004 #pragma once
0005 
0006 #include <Evaluator/DD4hepUnits.h>
0007 #include <spdlog/spdlog.h>
0008 
0009 namespace eicrecon {
0010 
0011   // radiator config parameters
0012   struct RadiatorConfig {
0013     double      referenceRIndex; // reference radiator refractive index
0014     double      attenuation;     // reference radiator attenuation length [mm]; set to 0 to disable
0015     std::string smearingMode;    // smearing type: "gaussian", "uniform"
0016     double      smearing;        // smearing amount [radians]
0017   };
0018 
0019   // IRT algorithm config
0020   class IrtCherenkovParticleIDConfig {
0021     public:
0022 
0023       /////////////////////////////////////////////////////
0024       // CONFIGURATION PARAMETERS
0025       //   NOTE: some defaults are hard-coded here; override externally
0026 
0027       unsigned numRIndexBins = 100; // number of bins to interpolate the refractive index vs. energy
0028 
0029       /* radiator-specific settings; handled by `RadiatorConfig` struct (see above)
0030        * example: radiators.insert({ "Aerogel", RadiatorConfig{ ... }});
0031        *          radiators.insert({ "Gas", RadiatorConfig{ ... }});
0032        */
0033       std::map <std::string,RadiatorConfig> radiators;
0034 
0035       /* list of PDG codes to identify with this PID algorithm
0036        * example: std::vector<int> pdgList = { 11, 211, 321, 2212 };
0037        */
0038       std::vector<int> pdgList;
0039 
0040       /* cheat modes: useful for test purposes, or idealizing; the real PID should run with all
0041        * cheat modes off
0042        */
0043       bool cheatPhotonVertex  = false; // if true, use MC photon vertex, wavelength, and refractive index
0044       bool cheatTrueRadiator  = false; // if true, use MC truth to obtain true radiator, for each hit
0045 
0046       //
0047       /////////////////////////////////////////////////////
0048 
0049       // print warnings about cheat modes
0050       void PrintCheats(
0051           std::shared_ptr<spdlog::logger> m_log,
0052           spdlog::level::level_enum lvl=spdlog::level::debug,
0053           bool printAll=false
0054           )
0055       {
0056         auto print_param = [&m_log, &lvl, &printAll] (auto name, bool val, auto desc) {
0057           if(printAll) m_log->log(lvl, "  {:>20} = {:<}", name, val);
0058           else if(val) m_log->warn("CHEAT MODE '{}' ENABLED: {}", name, desc);
0059         };
0060         print_param("cheatPhotonVertex",  cheatPhotonVertex,  "use MC photon vertex, wavelength, refractive index");
0061         print_param("cheatTrueRadiator",  cheatTrueRadiator,  "use MC truth to obtain true radiator");
0062       }
0063 
0064       // boolean: true if any cheat mode is enabled
0065       bool CheatModeEnabled() const {
0066         return cheatPhotonVertex || cheatTrueRadiator;
0067       }
0068 
0069       // print all parameters
0070       void Print(
0071           std::shared_ptr<spdlog::logger> m_log,
0072           spdlog::level::level_enum lvl=spdlog::level::debug
0073           )
0074       {
0075         m_log->log(lvl, "{:=^60}"," IrtCherenkovParticleIDConfig Settings ");
0076         auto print_param = [&m_log, &lvl] (auto name, auto val) {
0077           m_log->log(lvl, "  {:>20} = {:<}", name, val);
0078         };
0079         print_param("numRIndexBins",numRIndexBins);
0080         PrintCheats(m_log, lvl, true);
0081         m_log->log(lvl, "pdgList:");
0082         for(const auto& pdg : pdgList) m_log->log(lvl, "  {}", pdg);
0083         for(const auto& [name,rad] : radiators) {
0084           m_log->log(lvl, "{:-<60}", fmt::format("--- {} config ",name));
0085           print_param("smearingMode",    rad.smearingMode);
0086           print_param("smearing",        rad.smearing);
0087           print_param("referenceRIndex", rad.referenceRIndex);
0088           print_param("attenuation",     rad.attenuation);
0089         }
0090         m_log->log(lvl, "{:=^60}","");
0091       }
0092 
0093   };
0094 }