11 #include <tracking/modules/DATCON/DATCONROICalculationModule.h>
13 #include <pxd/geometry/SensorInfo.h>
14 #include <vxd/geometry/GeoCache.h>
31 setDescription(
"DATCONROICalculationModule: Calculates ROI from the "
32 "extrapolated hits (MPH), one ROI for each MPH.");
33 setPropertyFlags(c_ParallelProcessingCertified);
35 addParam(
"DATCONPXDIntercepts", m_storeDATCONPXDInterceptsName,
36 "Name of the DATCONPXDIntercepts StoreArray",
string(
"DATCONPXDIntercepts"));
37 addParam(
"DATCONMPHs", m_storeDATCONMPHName,
38 "Name of the DATCONMPH StoreArray",
string(
""));
39 addParam(
"DATCONROIids", m_storeDATCONROIidName,
40 "Name of the ROIid StoreArray for ROI created by DATCON",
string(
"DATCONROIs"));
42 addParam(
"continueROIonNextSensor", m_ContinueROIonNextSensor,
43 "Continue the ROI on the next sensor when they are close to the edge?",
bool(
true));
44 addParam(
"fixedSizeUCells", m_fixedSizeUCells,
45 "Fixed size of the ROI in u-direction.",
int(100));
46 addParam(
"fixedSizeVCells", m_fixedSizeVCells,
47 "Fixed size of the ROI in v-direction.",
int(150));
53 void DATCONROICalculationModule::initialize()
56 storeDATCONPXDIntercepts.isRequired(m_storeDATCONPXDInterceptsName);
57 m_storeDATCONPXDInterceptsName = storeDATCONPXDIntercepts.getName();
59 storeDATCONMPHs.isRequired(m_storeDATCONMPHName);
60 m_storeDATCONMPHName = storeDATCONMPHs.getName();
62 storeDATCONROIids.registerInDataStore(m_storeDATCONROIidName);
63 m_storeDATCONROIidName = storeDATCONROIids.getName();
71 DATCONROICalculationModule::event()
73 int uSize = m_fixedSizeUCells;
74 int vSize = m_fixedSizeVCells;
76 int sensorChange = 0, ladderChange = 0;
77 int uCellsRest = 0, vCellsRest = 0;
82 for (
auto& datconmph : storeDATCONMPHs) {
83 VxdID MPHSensorID = datconmph.getSensorID();
84 TVector2 localPosition = datconmph.getLocalCoordinate();
86 double uCoordinate = localPosition.X();
87 double vCoordinate = localPosition.Y();
91 int uCell = currentSensor->
getUCellID(uCoordinate, vCoordinate,
false);
92 int vCell = currentSensor->
getVCellID(vCoordinate,
false);
101 int uCellDownLeft = uCell - uSize / 2;
102 int vCellDownLeft = vCell - vSize / 2;
104 if (sensorNumber == 1) {
105 if (vCellDownLeft < 0) {
108 }
else if (sensorNumber == 2) {
109 if (vCellDownLeft < 0) {
112 vCellsRest = vSize / 2 - (vCell - vCellDownLeft);
116 if (uCellDownLeft < 0) {
119 uCellsRest = uSize / 2 - (uCell - uCellDownLeft);
123 int uCellUpRight = uCell + uSize / 2;
124 int vCellUpRight = vCell + vSize / 2;
126 if (sensorNumber == 1) {
127 if (vCellUpRight > vCells - 1) {
128 vCellUpRight = vCells - 1;
130 vCellsRest = vSize / 2 - (vCellUpRight - vCell);
132 }
else if (sensorNumber == 2) {
133 if (vCellUpRight >= vCells) {
134 vCellUpRight = vCells - 1;
138 if (uCellUpRight >= uCells) {
139 uCellUpRight = uCells - 1;
141 uCellsRest = uSize / 2 - (uCellUpRight - uCell);
144 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft, uCellUpRight, vCellDownLeft, vCellUpRight, MPHSensorID));
146 if (m_ContinueROIonNextSensor) {
147 int uCellDownLeft_tmp, vCellDownLeft_tmp, uCellUpRight_tmp, vCellUpRight_tmp;
150 if (ladderChange == -1 && sensorChange == 0) {
152 nextSensorID = MPHSensorID;
154 if (ladderNumber > 1) {
157 if (layerNumber == 1) {
159 }
else if (layerNumber == 2) {
163 uCellDownLeft_tmp = uCells - 1 - uCellsRest;
164 uCellUpRight_tmp = uCells - 1;
165 vCellDownLeft_tmp = vCellDownLeft;
166 vCellUpRight_tmp = vCellUpRight;
168 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
170 }
else if (ladderChange == +1 && sensorChange == 0) {
172 nextSensorID = MPHSensorID;
173 if (layerNumber == 1) {
174 if (ladderNumber < 8) {
179 }
else if (layerNumber == 2) {
180 if (ladderNumber < 12) {
186 uCellDownLeft_tmp = 0;
187 uCellUpRight_tmp = uCellsRest;
188 vCellDownLeft_tmp = vCellDownLeft;
189 vCellUpRight_tmp = vCellUpRight;
191 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
193 }
else if (ladderChange == 0 && sensorChange == -1) {
195 nextSensorID = MPHSensorID;
197 vCellDownLeft_tmp = vCells - 1 - vCellsRest;
198 vCellUpRight_tmp = vCells - 1;
199 uCellDownLeft_tmp = uCellDownLeft;
200 uCellUpRight_tmp = uCellUpRight;
202 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
204 }
else if (ladderChange == 0 && sensorChange == +1) {
206 nextSensorID = MPHSensorID;
208 vCellDownLeft_tmp = 0;
209 vCellUpRight_tmp = vCellsRest;
210 uCellDownLeft_tmp = uCellDownLeft;
211 uCellUpRight_tmp = uCellUpRight;
213 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
215 }
else if (ladderChange == -1 && sensorChange == -1) {
217 nextSensorID = MPHSensorID;
219 if (ladderNumber > 1) {
222 if (layerNumber == 1) {
224 }
else if (layerNumber == 2) {
228 uCellDownLeft_tmp = uCells - 1 - uCellsRest;
229 uCellUpRight_tmp = uCells - 1;
230 vCellDownLeft_tmp = vCellDownLeft;
231 vCellUpRight_tmp = vCellUpRight;
233 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
235 nextSensorID = MPHSensorID;
237 vCellDownLeft_tmp = 0;
238 vCellUpRight_tmp = vCellsRest;
239 uCellDownLeft_tmp = uCellDownLeft;
240 uCellUpRight_tmp = uCellUpRight;
242 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
244 nextSensorID = MPHSensorID;
246 if (ladderNumber > 1) {
249 if (layerNumber == 1) {
251 }
else if (layerNumber == 2) {
256 vCellDownLeft_tmp = 0;
257 vCellUpRight_tmp = vCellsRest;
258 uCellDownLeft_tmp = uCells - 1 - uCellsRest;
259 uCellUpRight_tmp = uCells - 1;
261 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
263 }
else if (ladderChange == -1 && sensorChange == +1) {
265 nextSensorID = MPHSensorID;
267 if (ladderNumber > 1) {
270 if (layerNumber == 1) {
272 }
else if (layerNumber == 2) {
276 uCellDownLeft_tmp = uCells - 1 - uCellsRest;
277 uCellUpRight_tmp = uCells - 1;
278 vCellDownLeft_tmp = vCellDownLeft;
279 vCellUpRight_tmp = vCellUpRight;
281 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
283 nextSensorID = MPHSensorID;
286 vCellDownLeft_tmp = 0;
287 vCellUpRight_tmp = vCellsRest;
288 uCellDownLeft_tmp = uCellDownLeft;
289 uCellUpRight_tmp = uCellUpRight;
291 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
293 nextSensorID = MPHSensorID;
295 if (ladderNumber > 1) {
298 if (layerNumber == 1) {
300 }
else if (layerNumber == 2) {
305 uCellDownLeft_tmp = uCells - 1 - uCellsRest;
306 uCellUpRight_tmp = uCells - 1;
307 vCellDownLeft_tmp = 0;
308 vCellUpRight_tmp = vCellsRest;
310 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
312 }
else if (ladderChange == +1 && sensorChange == -1) {
314 nextSensorID = MPHSensorID;
315 if (layerNumber == 1) {
316 if (ladderNumber < 8) {
321 }
else if (layerNumber == 2) {
322 if (ladderNumber < 12) {
328 uCellDownLeft_tmp = 0;
329 uCellUpRight_tmp = uCellsRest;
330 vCellDownLeft_tmp = vCellDownLeft;
331 vCellUpRight_tmp = vCellUpRight;
333 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
335 nextSensorID = MPHSensorID;
337 vCellDownLeft_tmp = vCells - 1 - vCellsRest;
338 vCellUpRight_tmp = vCells - 1;
339 uCellDownLeft_tmp = uCellDownLeft;
340 uCellUpRight_tmp = uCellUpRight;
342 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
344 nextSensorID = MPHSensorID;
345 if (layerNumber == 1) {
346 if (ladderNumber < 8) {
351 }
else if (layerNumber == 2) {
352 if (ladderNumber < 12) {
359 uCellDownLeft_tmp = 0;
360 uCellUpRight_tmp = uCellsRest;
361 vCellDownLeft_tmp = vCells - 1 - vCellsRest;
362 vCellUpRight_tmp = vCells - 1;
364 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
366 }
else if (ladderChange == +1 && sensorChange == +1) {
368 nextSensorID = MPHSensorID;
369 if (layerNumber == 1) {
370 if (ladderNumber < 8) {
375 }
else if (layerNumber == 2) {
376 if (ladderNumber < 12) {
382 uCellDownLeft_tmp = 0;
383 uCellUpRight_tmp = uCellsRest;
384 vCellDownLeft_tmp = vCellDownLeft;
385 vCellUpRight_tmp = vCellUpRight;
387 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
389 nextSensorID = MPHSensorID;
391 vCellDownLeft_tmp = 0;
392 vCellUpRight_tmp = vCellsRest;
393 uCellDownLeft_tmp = uCellDownLeft;
394 uCellUpRight_tmp = uCellUpRight;
396 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));
398 nextSensorID = MPHSensorID;
399 if (layerNumber == 1) {
400 if (ladderNumber < 8) {
405 }
else if (layerNumber == 2) {
406 if (ladderNumber < 12) {
413 uCellDownLeft_tmp = 0;
414 uCellUpRight_tmp = uCellsRest;
415 vCellDownLeft_tmp = 0;
416 vCellUpRight_tmp = vCellsRest;
418 storeDATCONROIids.appendNew(
ROIid(uCellDownLeft_tmp, uCellUpRight_tmp, vCellDownLeft_tmp, vCellUpRight_tmp, nextSensorID));