File indexing completed on 2025-01-18 09:55:45
0001
0002
0003
0004 #pragma once
0005
0006 #include <string>
0007 #include <iostream>
0008 #include <fmt/format.h>
0009 #include <spdlog/spdlog.h>
0010 #include <edm4hep/SimTrackerHitData.h>
0011
0012 namespace richgeo {
0013
0014 using CellIDType = decltype(edm4hep::SimTrackerHitData::cellID);
0015
0016
0017
0018
0019
0020 class Sensor {
0021 public:
0022 Sensor() {};
0023 ~Sensor() {};
0024 double size;
0025 dd4hep::Position surface_centroid;
0026 dd4hep::Direction surface_offset;
0027 };
0028
0029
0030
0031
0032
0033
0034 enum radiator_enum {
0035 kAerogel,
0036 kGas,
0037 nRadiators
0038 };
0039
0040
0041 static std::string RadiatorName(int num, std::shared_ptr<spdlog::logger> m_log = nullptr) {
0042 if(num==kAerogel) return "Aerogel";
0043 else if(num==kGas) return "Gas";
0044 else {
0045 if (m_log) m_log->error("unknown radiator number {}", num);
0046 else std::cerr << "ERROR: unknown radiator number " << num << std::endl;
0047 return "UNKNOWN_RADIATOR";
0048 }
0049 }
0050
0051
0052 static int RadiatorNum(std::string name, std::shared_ptr<spdlog::logger> m_log = nullptr) {
0053 if(name=="Aerogel") return kAerogel;
0054 else if(name=="Gas") return kGas;
0055 else {
0056 if (m_log) m_log->error("unknown radiator name {}", name);
0057 else std::cerr << "ERROR: unknown radiator name " << name << std::endl;
0058 return -1;
0059 }
0060 }
0061
0062 static int RadiatorNum(const char * name, std::shared_ptr<spdlog::logger> m_log = nullptr) {
0063 return RadiatorNum(std::string(name), m_log);
0064 }
0065
0066
0067 static int ParseRadiatorName(std::string input, std::shared_ptr<spdlog::logger> m_log = nullptr) {
0068 if (input.find("aerogel")!=std::string::npos) return kAerogel;
0069 else if (input.find("Aerogel")!=std::string::npos) return kAerogel;
0070 else if (input.find("gas")!=std::string::npos) return kGas;
0071 else if (input.find("Gas")!=std::string::npos) return kGas;
0072 else {
0073 if (m_log) m_log->error("failed to parse '{}' for radiator name", input);
0074 else std::cerr << "ERROR: failed to parse '" << input << "' for radiator name" << std::endl;
0075 return -1;
0076 }
0077 }
0078
0079 }