1#if DETECTORID_BINDINGS_ENABLED
3#define BOOST_BIND_GLOBAL_PLACEHOLDERS
4#include <boost/python.hpp>
6#include "DetDescr/DetectorID.h"
12#include "DetDescr/HcalDigiID.h"
13#include "DetDescr/HcalElectronicsID.h"
16#include "DetDescr/SimSpecialID.h"
18#include "DetDescr/TrigScintID.h"
20BOOST_PYTHON_MODULE(libDetDescr) {
55 using namespace boost::python;
57 using RawValue = DetectorID::RawValue;
59 enum_<SubdetectorIDType>(
"SubdetectorID")
60 .value(
"SD_NULL", SubdetectorIDType::SD_NULL)
61 .value(
"SD_TRACKER_TAGGER", SubdetectorIDType::SD_TRACKER_TAGGER)
62 .value(
"SD_TRIGGER_SCINT", SubdetectorIDType::SD_TRIGGER_SCINT)
63 .value(
"SD_ACTVE_TARGET", SubdetectorIDType::SD_ACTVE_TARGET)
64 .value(
"SD_TRACKER_RECOIL", SubdetectorIDType::SD_TRACKER_RECOIL)
65 .value(
"SD_ECAL", SubdetectorIDType::SD_ECAL)
66 .value(
"SD_HCAL", SubdetectorIDType::SD_HCAL)
67 .value(
"SD_SIM_SPECIAL", SubdetectorIDType::SD_SIM_SPECIAL)
68 .value(
"EID_TRACKER", SubdetectorIDType::EID_TRACKER)
69 .value(
"EID_TRIGGER_SCINT", SubdetectorIDType::EID_TRIGGER_SCINT)
70 .value(
"EID_HCAL", SubdetectorIDType::EID_HCAL)
71 .value(
"EID_HCAL", SubdetectorIDType::EID_HCAL)
74 class_<DetectorID>(
"DetectorID", init<>(args(
"self")));
75 class_<HcalAbstractID>(
"HcalAbstractID", init<>(args(
"self")));
76 class_<EcalAbstractID>(
"EcalAbstractID", init<>(args(
"self")));
77 class_<EcalID>(
"EcalID",
78 "Extension of DetectorID providing access to ECal layers and "
79 "cell numbers in a hex grid",
80 init<>(args(
"self"),
"Empty ECAL id (but not null!)"))
81 .def(init<RawValue>(args(
"self",
"rawid"),
"Create from raw number"))
82 .def(init<unsigned int, unsigned int, unsigned int>(
83 args(
"self",
"layer",
"module",
"cell"),
"Create from pieces"))
84 .def(init<unsigned int, unsigned int, unsigned int, unsigned int>(
85 args(
"self",
"layer",
"module",
"u",
"v"),
86 "Create from pieces including u/v cell"))
87 .def(init<
unsigned int,
unsigned int,
88 std::pair<unsigned int, unsigned int>>(
89 args(
"self",
"layer",
"module",
"uv"),
90 "Create from pieces including u/v cell"))
91 .def(
"module", &EcalID::module,
92 "Get the value of the module field from the ID.", args(
"self"))
93 .def(
"layer", &EcalID::layer,
94 "Get the value of the layer field from the ID.", args(
"self"))
95 .def(
"cell", &EcalID::cell,
96 "Get the value of the cell field from the ID.", args(
"self"))
100 .def(
"raw", &EcalID::raw,
"The raw value", args(
"self"));
101 class_<EcalElectronicsID>(
103 "Identifies a location in the Ecal readout chain\n"
104 "-- fiber : optical fiber number (backend number), range "
106 "-- elink : electronic link number, range assumed O(0-47)\n"
107 "-- channel : channel-on-elink, range O(0-37)\n"
108 "For transient use only i.e. we use this ID to\n"
109 "help translate the digitized data coming off the detector\n"
110 "into spatially-important EcalIDs.",
111 init<>(args(
"self"),
"Empty EcalElectronics id (but not null!)"))
113 "Create from raw number\n\n Importantly, this is NOT the PackedIndex "
114 "value, it is the entire raw value including the subsystem ID.",
115 args(
"self",
"rawid")))
116 .def(init<unsigned int, unsigned int, unsigned int>(
117 args(
"self",
"fiber",
"elink",
"channel"),
"Create from pieces"))
118 .def(
"fiber", &EcalElectronicsID::fiber,
119 "Get the value of the fiber from the ID.", args(
"self"))
120 .def(
"elink", &EcalElectronicsID::elink,
121 "Get the value of the elink from the ID.", args(
"self"))
122 .def(
"channel", &EcalElectronicsID::channel,
123 "Get the value of the channel from the ID.", args(
"self"))
124 .def(
"index", &EcalElectronicsID::index,
"Get the compact index value",
126 .def(
"idFromIndex", &EcalElectronicsID::idFromIndex, args(
"index"),
127 "Construct an electronics id from an index")
128 .def(
"raw", &EcalElectronicsID::raw,
"The raw value", args(
"self"))
129 .staticmethod(
"idFromIndex");
130 class_<EcalTriggerID>(
132 "Extension of DetectorID providing access to ECal "
133 "trigger cell information",
134 init<>(args(
"self"),
"Empty EcALTrigger id (but not null!)"))
135 .def(init<RawValue>(args(
"self",
"rawid"),
"Create from raw number"))
136 .def(init<unsigned int, unsigned int, unsigned int>(
137 args(
"self",
"layer",
"module",
"cell"),
"Create from pieces"))
138 .def(
"module", &EcalTriggerID::module,
139 "Get the value of the module field from the ID.", args(
"self"))
140 .def(
"layer", &EcalTriggerID::layer,
141 "Get the value of the layer field from the ID.", args(
"self"))
142 .def(
"triggercell", &EcalTriggerID::triggercell,
143 "Get the value of the trigger cell field from the ID.", args(
"self"))
144 .def(
"raw", &EcalTriggerID::raw,
"The raw value", args(
"self"));
147 class_<HcalID>(
"HcalID",
"Implements detector ids for Hcal subdetector",
148 init<>(args(
"self"),
"Empty HcalID (but not null)"))
149 .def(init<RawValue>(args(
"self",
"rawid"),
"Create from raw number"))
150 .def(init<unsigned int, unsigned int, unsigned int>(
151 args(
"self",
"section",
"layer",
"strip"),
"Create from pieces"))
152 .def(
"section", &HcalID::section,
153 "Get the value of the 'section' field from the ID.", args(
"self"))
154 .def(
"layer", &HcalID::layer,
155 "Get the value of the layer field from the ID.", args(
"self"))
156 .def(
"strip", &HcalID::strip,
157 "Get the value of the 'strip' (bar) field from the ID.",
159 .def(
"raw", &HcalID::raw,
"The raw value", args(
"self"));
160 class_<HcalElectronicsID>(
163 "Identifies a location in the Hcal readout chain\n"
164 "-- fiber : optical fiber number (backend number), range assumed "
166 "-- elink : electronic link number, range assumed O(0-47)\n"
167 "-- channel : channel-on-elink, range O(0-37)\n\n"
168 "For transient use only i.e. we use this ID to help translate the "
169 "digitized data coming off the detector into spatially-important "
171 init<>(args(
"self"),
"Empty HCAL id (but not null!)"))
172 .def(init<RawValue>(
"Create from raw number", args(
"self",
"rawid")))
173 .def(init<unsigned int, unsigned int, unsigned int>(
174 "Create from pieces", args(
"self",
"fiber",
"elink",
"channel")))
175 .def(
"fiber", &HcalElectronicsID::fiber,
176 "Get the value of the fiber from the ID.", args(
"self"))
177 .def(
"elink", &HcalElectronicsID::elink,
178 "Get the value of the elink from the ID.", args(
"self"))
179 .def(
"channel", &HcalElectronicsID::channel,
180 "Get the value of the channel from the ID.", args(
"self"))
181 .def(
"index", &HcalElectronicsID::index,
"Get the compact index value",
183 .def(
"idFromIndex", &HcalElectronicsID::idFromIndex, args(
"index"),
184 "Create an electronics ID from an index")
185 .def(
"raw", &HcalElectronicsID::raw,
"The raw value", args(
"self"))
186 .staticmethod(
"idFromIndex");
187 class_<HcalDigiID>(
"HcalDigiID",
188 "Extension of HcalAbstractID providing access to HCal "
190 init<>(args(
"self"),
"Empty HcalDigiID (but not null)"))
191 .def(init<RawValue>(
"Create from raw number", args(
"self",
"rawid")))
192 .def(init<unsigned int, unsigned int, unsigned int, unsigned int>(
193 "Create from pieces",
194 args(
"self",
"section",
"layer",
"strip",
"end")))
195 .def(
"section", &HcalDigiID::section,
196 "Get the value of the 'section' field from the ID.", args(
"self"))
197 .def(
"layer", &HcalDigiID::layer,
198 "Get the value of the 'layer' field from the ID.", args(
"self"))
199 .def(
"strip", &HcalDigiID::strip,
200 "Get the value of the 'strip' (bar) field from the ID.",
202 .def(
"end", &HcalDigiID::end,
203 "Get the value of the 'end' (positive/negative) field from the ID.",
205 .def(
"isNegativeEnd", &HcalDigiID::isNegativeEnd,
206 "Get whether the 'end' field from the ID is negative.", args(
"self"))
207 .def(
"raw", &HcalElectronicsID::raw,
"The raw value", args(
"self"));
208 class_<HcalTriggerID>(
210 "Extension of DetectorID providing access to HCal trigger cell",
211 init<>(args(
"self"),
"Empty HCAL trigger id (but not null!)"))
212 .def(init<RawValue>(
"Create from raw number", args(
"self",
"rawid")))
213 .def(init<unsigned int, unsigned int, unsigned int, unsigned int>(
214 "Create from pieces",
215 args(
"self",
"section",
"layer",
"superstrip",
"end")))
216 .def(
"section", &HcalTriggerID::section,
217 "Get the value of the 'section' field from the ID.", args(
"self"))
218 .def(
"layer", &HcalTriggerID::layer,
219 "Get the value of the 'layer' field from the ID.", args(
"self"))
220 .def(
"superstrip", &HcalTriggerID::superstrip,
221 "Get the value of the 'superstrip' field from the ID.", args(
"self"))
222 .def(
"end", &HcalTriggerID::end,
223 "Get the value of the 'end' field from the ID.", args(
"self"))
224 .def(
"isNegativeEnd", &HcalTriggerID::isNegativeEnd,
225 "Get whether the 'end' field from the ID is negative.", args(
"self"))
226 .def(
"isComposite", &HcalTriggerID::isComposite,
227 "Get whether the ID is the composite of two bar ends.", args(
"self"))
228 .def(
"raw", &HcalTriggerID::raw,
"The raw value", args(
"self"));
229 class_<SimSpecialID>(
"SimSpecialID",
230 "Implements detector ids for special simulation-derived "
231 "hits like scoring planes",
232 init<>(args(
"self"),
"Empty id (but not null!)"))
233 .def(init<RawValue>(
"Create from raw number", args(
"self",
"rawid")))
234 .def(
"ScoringPlaneID", &SimSpecialID::ScoringPlaneID,
235 "Create a scoring id from pieces", args(
"plane"))
236 .staticmethod(
"ScoringPlaneID")
237 .def(
"plane", &SimSpecialID::plane,
238 "Get the value of the plane field from the ID, if it is a scoring "
239 "plane. Otherwise, return -1",
241 .def(
"subtypePayload", &SimSpecialID::subtypePayload,
242 "Get the raw payload contents", args(
"self"))
243 .def(
"raw", &SimSpecialID::raw,
"The raw value", args(
"self"));
244 class_<TrackerID>(
"TrackerID",
245 "Extension of DetectorID providing access to layer and "
246 "module number for tracker IDs")
247 .def(init<RawValue>(
"Create from a raw id, but check",
248 args(
"self",
"rawid")))
249 .def(init<SubdetectorIDType, unsigned int, unsigned int>(
250 "Create from pieces", args(
"self",
"system",
"layer",
"module")))
251 .def(
"module", &TrackerID::module,
252 "Get the value of the module field from the ID", args(
"self"))
253 .def(
"layer", &TrackerID::layer,
254 "Get the value of the layer field from the ID", args(
"self"))
255 .def(
"raw", &TrackerID::raw,
"The raw value");
258 "Class that defines the detector ID of the trigger scintillator.",
259 init<>(args(
"self"),
"Default constructor"))
260 .def(init<RawValue>(
"Constructor with raw id", args(
"self",
"rawid")))
261 .def(init<unsigned int, unsigned int>(
"Create from pieces",
262 args(
"self",
"module",
"bar")));
Class that serves as a parent for ECal detector IDs of various types.
Class that identifies a location in the Ecal readout chain.
Class that defines an ECal detector ID with a cell number.
Class that defines an ECal trigger cell detector ID.
Class that serves as a parent for HCal detector IDs of various types.
Class that defines an HCal sensitive detector.
Class that defines an HCal trigger cell detector ID.
Class that defines a Tracker detector ID with a module number.