Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-28 09:20:35

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2026 Chun Yuen Tsang, Minho Kim
0003 
0004 // Temporary BEMC compatibility implementation until its single-sided CALOROC migration.
0005 
0006 #pragma once
0007 
0008 #include <cstdint>
0009 #include <iostream>
0010 #include <string>
0011 #include <vector>
0012 
0013 namespace eicrecon {
0014 
0015 struct CalorimeterCALOROCRecoLegacyConfig {
0016   // readout fields
0017   std::string readout{""};
0018   std::string layerField{""};
0019   std::string sectorField{""};
0020 
0021   // name of detelment or fields to find the local detector (for global->local transform)
0022   // if nothing is provided, the lowest level DetElement (from cellID) will be used
0023   std::string localDetElement{""};
0024   std::vector<std::string> localDetFields{};
0025   std::string maskPos{""};
0026   std::vector<std::string> maskPosFields{};
0027 
0028   std::string edep_to_npe_filename{""};
0029   std::vector<std::string> edep_to_npe_fields{};
0030   enum class ProxyType { sum = 0, simpson = 1, templateFit = 2 } proxy_type = ProxyType::sum;
0031 
0032   bool timeWalkCor{false};
0033   bool useNpeHitPos{false};
0034 
0035   uint16_t highGainDR{0}; // high gain dynamic range
0036   double gainRatio{1};    // gain ratio of low gain to high gain, it should be < 1
0037 
0038   std::string attenuationReferencePositionNamePos{""};
0039   std::string attenuationReferencePositionNameNeg{""};
0040 
0041   // parameters for attenuation function
0042   // [0] * exp(-|z_ref - z| / [1]) + (1 - [0]) * exp(-|z_ref - z| / [2])
0043   // specified in edm4eic::units where dimensionfull
0044   std::vector<double> attenuationParameters{0};
0045 
0046   std::vector<double> timeWalkCorrectionParameters{0};
0047   std::vector<double> lightSpeedParameters{0};
0048 
0049   // calibration parameters
0050   double slope     = 1 / 9.41e-2;
0051   double intercept = 0;
0052 };
0053 
0054 inline std::istream& operator>>(std::istream& in,
0055                                 CalorimeterCALOROCRecoLegacyConfig::ProxyType& proxyType) {
0056   std::string s;
0057   in >> s;
0058   // stringifying the enums causes them to be converted to integers before conversion to strings
0059   if (s == "sum" or s == "0") {
0060     proxyType = CalorimeterCALOROCRecoLegacyConfig::ProxyType::sum;
0061   } else if (s == "simpson" or s == "1") {
0062     proxyType = CalorimeterCALOROCRecoLegacyConfig::ProxyType::simpson;
0063   } else if (s == "templateFit" or s == "2") {
0064     proxyType = CalorimeterCALOROCRecoLegacyConfig::ProxyType::templateFit;
0065   } else {
0066     in.setstate(std::ios::failbit); // Set the fail bit if the input is not valid
0067   }
0068 
0069   return in;
0070 }
0071 inline std::ostream& operator<<(std::ostream& out,
0072                                 const CalorimeterCALOROCRecoLegacyConfig::ProxyType& proxyType) {
0073   switch (proxyType) {
0074   case CalorimeterCALOROCRecoLegacyConfig::ProxyType::sum:
0075     out << "sum";
0076     break;
0077   case CalorimeterCALOROCRecoLegacyConfig::ProxyType::simpson:
0078     out << "simpson";
0079     break;
0080   case CalorimeterCALOROCRecoLegacyConfig::ProxyType::templateFit:
0081     out << "templateFit";
0082     break;
0083   default:
0084     out.setstate(std::ios::failbit);
0085   }
0086   return out;
0087 }
0088 
0089 } // namespace eicrecon