LDMX Software
HcalDetectorMap.cxx
2
3#include <sstream>
4
7
8namespace hcal {
9
11 public:
12 HcalDetectorMapLoader(const std::string& name, const std::string& tagname,
13 const framework::config::Parameters& parameters,
16 tagname, parameters, process),
17 the_map_{nullptr} {
18 want_d2e_ = parameters.get<bool>("want_d2e");
19 connections_table_ = parameters.get<std::string>("connections_table");
20 }
21
22 virtual std::pair<const framework::ConditionsObject*,
25 if (!the_map_) {
26 the_map_ = new HcalDetectorMap(connections_table_, want_d2e_);
27 }
28
29 return std::make_pair(
30 the_map_, framework::ConditionsIOV(context.getRun(), context.getRun(),
31 true, true));
32 }
33
39
40 private:
41 HcalDetectorMap* the_map_;
42 std::string connections_table_;
43 bool want_d2e_;
44};
45
46HcalDetectorMap::HcalDetectorMap(const std::string& connections_table,
47 bool want_d2e)
48 : framework::ConditionsObject(CONDITIONS_OBJECT_NAME),
49 ldmx::ElectronicsMap<ldmx::HcalElectronicsID, ldmx::HcalDigiID>(
50 want_d2e) {
51 this->clear();
52 conditions::StreamCSVLoader csv(connections_table);
53 while (csv.nextRow()) {
64 int polarfire = csv.getInteger("Polarfire");
65 int hgcroc = csv.getInteger("HGCROC");
66 int chan = csv.getInteger("Channel");
67
88 int link = 2 * hgcroc; // link count starts from 0
89 if (chan >= 36) {
90 link += 1;
91 chan -= 36;
92 }
93
94 // one quadbar groups 4 strips and each quadbar is connected to 2 CMBs - one
95 // in each end
96 int end = csv.getInteger("CMB") % 2;
97 if (end == 0)
98 end = 1; // negative end (?)
99 else
100 end = 0; // positive end (?)
101
102 // The Bar field in the map represents a numbering *within a quadbar* not
103 // the strip number.
104 //
105 // This gives correct range for the strip numbers [0,7] and [0,11] but the
106 // actual order of the quadbars has to be checked
107
108 auto quad_bar{csv.getInteger("QuadBar")};
109 auto bar_number{csv.getInteger("Bar")};
110 // Strip = (4 - Bar) + 4 * (QuadBar - 1)
111 // QuadBar starts at 1 so we need to subtract to get first value
112 // to be zero
113 auto strip{(bar_number - 1) +
114 4 * (quad_bar - 1)}; // This is flipped from the original
115 if (csv.getInteger("Plane") % 2 == 1)
116 strip = (4 - bar_number) +
117 4 * (quad_bar - 1); // Plane 2 is backward by mistake
118 ldmx::HcalDigiID detid(0 /*section - only one section during test beam*/,
119 csv.getInteger("Plane") /*layer_*/, strip /*strip*/,
120 end /*end*/);
121 ldmx::HcalElectronicsID eleid(polarfire /*polarfire fpga*/, link /*elink*/,
122 chan /*channel*/);
123
124 if (this->exists(eleid)) {
125 std::stringstream ss;
126 ss << "Two different mappings for electronics channel " << eleid;
127 EXCEPTION_RAISE("DuplicateMapping", ss.str());
128 }
129 this->addEntry(eleid, detid);
130 }
131}
132
133} // namespace hcal
Base class for provider of conditions information like pedestals, gains, electronics maps,...
#define DECLARE_CONDITIONS_PROVIDER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class that provides header information about an event such as event number and timestamp.
Class which contains logic for how the detector items connect to and relate with the reconstruction c...
bool nextRow()
Advance to next row if possible.
int getInteger(const std::string &colname, bool ignore_case=true) const
Get the value for the given column in the current row as an integer.
Specialization of the GeneralCSVLoader for loading from a file/stream.
Class which defines the run/event/type range for which a given condition is valid,...
Base class for all providers of conditions objects.
const Process & process() const
Get the process handle.
ConditionsObjectProvider(const std::string &objname, const std::string &tagname, const framework::config::Parameters &parameters, Process &process)
Class constructor.
Base class for all conditions objects, very simple.
Class which represents the process under execution.
Definition Process.h:36
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
virtual void releaseConditionsObject(const framework::ConditionsObject *co)
Take no action on release, as the object is permanently owned by the Provider.
virtual std::pair< const framework::ConditionsObject *, framework::ConditionsIOV > getCondition(const ldmx::EventHeader &context)
Pure virtual getCondition function.
Class which provides various information about how the parts of the Hcal connect to each other.
HcalDetectorMap(const std::string &connections_table, bool want_d2e)
Default constructor which builds the necessary maps.
static constexpr const char * CONDITIONS_OBJECT_NAME
The name of the EID <-> DetID map for the ECal.
void addEntry(ldmx::HcalElectronicsID eid, ldmx::HcalDigiID did)
Provides header information an event such as event number and timestamp.
Definition EventHeader.h:44
int getRun() const
Return the run number.
Definition EventHeader.h:84
Extension of HcalAbstractID providing access to HCal digi information.
Definition HcalDigiID.h:13
Identifies a location in the Hcal readout chain.
All classes in the ldmx-sw project use this namespace.