EICrecon
JANA based reconstruction for the EPIC detector
Loading...
Searching...
No Matches
RichGeo.h
Go to the documentation of this file.
1// Copyright (C) 2022, 2023, Christopher Dilks
2// Subject to the terms in the LICENSE file found in the top-level directory.
3
4#pragma once
5
6#include <string>
7#include <iostream>
8#include <fmt/format.h>
9#include <spdlog/spdlog.h>
10#include <edm4hep/SimTrackerHitData.h>
11
12namespace richgeo {
13
14using CellIDType = decltype(edm4hep::SimTrackerHitData::cellID);
15
16// sensors
17// -----------------------------------------------------------------------
18/* keep track of information for a sensor
19 */
20class Sensor {
21public:
22 Sensor() {};
23 ~Sensor() {};
24 double size;
25 dd4hep::Position surface_centroid;
26 dd4hep::Direction surface_offset; // surface centroid = volume centroid + `surface_offset`
27};
28
29// radiators
30// -----------------------------------------------------------------------
31/* in many places in the reconstruction, we need to track which radiator
32 * we are referring to; these are common methods to enumerate them
33 */
35
36// return radiator name associated with index
37[[maybe_unused]] static std::string RadiatorName(int num,
38 std::shared_ptr<spdlog::logger> m_log = nullptr) {
39 if (num == kAerogel)
40 return "Aerogel";
41 else if (num == kGas)
42 return "Gas";
43 else {
44 if (m_log)
45 m_log->error("unknown radiator number {}", num);
46 else
47 std::cerr << "ERROR: unknown radiator number " << num << std::endl;
48 return "UNKNOWN_RADIATOR";
49 }
50}
51
52// return radiator index associated with name
53[[maybe_unused]] static int RadiatorNum(std::string name,
54 std::shared_ptr<spdlog::logger> m_log = nullptr) {
55 if (name == "Aerogel")
56 return kAerogel;
57 else if (name == "Gas")
58 return kGas;
59 else {
60 if (m_log)
61 m_log->error("unknown radiator name {}", name);
62 else
63 std::cerr << "ERROR: unknown radiator name " << name << std::endl;
64 return -1;
65 }
66}
67
68[[maybe_unused]] static int RadiatorNum(const char* name,
69 std::shared_ptr<spdlog::logger> m_log = nullptr) {
70 return RadiatorNum(std::string(name), m_log);
71}
72
73// search string `input` for a radiator name; return corresponding index
74[[maybe_unused]] static int ParseRadiatorName(std::string input,
75 std::shared_ptr<spdlog::logger> m_log = nullptr) {
76 if (input.find("aerogel") != std::string::npos)
77 return kAerogel;
78 else if (input.find("Aerogel") != std::string::npos)
79 return kAerogel;
80 else if (input.find("gas") != std::string::npos)
81 return kGas;
82 else if (input.find("Gas") != std::string::npos)
83 return kGas;
84 else {
85 if (m_log)
86 m_log->error("failed to parse '{}' for radiator name", input);
87 else
88 std::cerr << "ERROR: failed to parse '" << input << "' for radiator name" << std::endl;
89 return -1;
90 }
91}
92
93} // namespace richgeo
Definition RichGeo.h:20
Sensor()
Definition RichGeo.h:22
double size
Definition RichGeo.h:24
dd4hep::Direction surface_offset
Definition RichGeo.h:26
~Sensor()
Definition RichGeo.h:23
dd4hep::Position surface_centroid
Definition RichGeo.h:25
Definition ActsGeo.h:18
radiator_enum
Definition RichGeo.h:34
@ kAerogel
Definition RichGeo.h:34
@ kGas
Definition RichGeo.h:34
@ nRadiators
Definition RichGeo.h:34
decltype(edm4hep::SimTrackerHitData::cellID) CellIDType
Definition RichGeo.h:14