Belle II Software development
ROIGeneratorModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <tracking/modules/roiFinding/pxd/ROIGeneratorModule.h>
10#include <framework/dataobjects/EventMetaData.h>
11#include <tracking/dataobjects/ROIid.h>
12#include <framework/datastore/StoreArray.h>
13
14using namespace Belle2;
15
16//-----------------------------------------------------------------
17// Register the Module
18//-----------------------------------------------------------------
19
20REG_MODULE(ROIGenerator);
21
22//-----------------------------------------------------------------
23// Implementation
24//-----------------------------------------------------------------
25
27{
28 //Set module properties
29 setDescription("This module is used to generate a certain number of ROIs");
31
32 addParam("ROIListName", m_ROIListName, "name of the list of ROIs", std::string(""));
33 addParam("nROIs", m_nROIs, "number of generated ROIs", 1);
34
35 addParam("TrigDivider", m_divider, "Generates one ROI every TrigDivider events", 2);
36 addParam("Layer", m_layer, "on layer", 1);
37 addParam("Ladder", m_ladder, " ladder ", 1);
38 addParam("Sensor", m_sensor, " sensor ", 1);
39
40 addParam("MinU", m_minU, " min U (pixel column hopefully) ", 0);
41 addParam("MaxU", m_maxU, " max U (pixel column hopefully) ", 250 - 1);
42
43
44 addParam("MinV", m_minV, " min V (pixel column hopefully) ", 0);
45 addParam("MaxV", m_maxV, " max v (pixel column hopefully) ", 768 - 1);
46
47 addParam("Random", m_random, "dont use fix position, move pseudo randomly", false);
48}
49
51{
52 m_eventMetaData.isRequired();
53
54 m_ROIs.registerInDataStore(m_ROIListName); // does not report error if ROIid exists
55}
56
58{
59 int tNr = m_eventMetaData->getEvent(); // trigger number
60
61 // Only if divider tells us to...
62 if (m_divider != 0 && (tNr % m_divider) != 0)
63 return ;
64
65 ROIid tmp_ROIid;
66
67 VxdID sensorID;
68 sensorID.setLayerNumber(m_layer);
69 sensorID.setLadderNumber(m_ladder);
70 sensorID.setSensorNumber(m_sensor);
71
72 // Always create one FULL size ROI
73 int minU = m_minU, maxU = m_maxU, minV = m_minV, maxV = m_maxV;
74 int w = maxU - minU;
75 int h = maxV - minV;
76 if (m_nROIs == 1 && m_random) {
77 switch (tNr % 9) {
78 case 0:
79 minU = 0;
80 maxU = w;
81 minV = 0;
82 maxV = h;
83 break;
84 case 1:
85 minU = 0;
86 maxU = w;
87 break;
88 case 2:
89 minU = 0;
90 maxU = w;
91 minV = 768 - 1 - h;
92 maxV = 768 - 1;
93 break;
94 case 3:
95 minV = 0;
96 maxV = h;
97 break;
98 case 4:
99 break;
100 case 5:
101 minV = 768 - 1 - h;
102 maxV = 768 - 1;
103 break;
104 case 6:
105 minU = 250 - 1 - w;
106 maxU = 250 - 1;
107 minV = 0;
108 maxV = h;
109 break;
110 case 7:
111 minU = 250 - 1 - w;
112 maxU = 250 - 1;
113 break;
114 case 8:
115 minU = 250 - 1 - w;
116 maxU = 250 - 1;
117 minV = 768 - 1 - h;
118 maxV = 768 - 1;
119 break;
120 default:
121 break;
122 }
123 }
124 tmp_ROIid.setMinUid(minU);
125 tmp_ROIid.setMinVid(minV);
126 tmp_ROIid.setMaxUid(maxU);
127 tmp_ROIid.setMaxVid(maxV);
128 tmp_ROIid.setSensorID(sensorID);
129
130 m_ROIs.appendNew(tmp_ROIid);
131
132 if (m_nROIs > 1) {
133 // ... plus additional ones for debugging.
134 // maybe we should do it depending on the triggernr lateron...
135 int dU = (m_maxU - m_minU) / (m_nROIs + 1);
136 int dV = (m_maxV - m_minV) / (m_nROIs + 1);
137 for (int iROI = 1; iROI < m_nROIs; iROI++) {
138 // Create a chain of ROIs from top left to bottom right
139 minU = m_minU + dU * iROI;
140 maxU = minU + dU;
141 minV = m_minV + dV * iROI;
142 maxV = minV + dV;
143
144 tmp_ROIid.setMinUid(minU);
145 tmp_ROIid.setMinVid(minV);
146 tmp_ROIid.setMaxUid(maxU);
147 tmp_ROIid.setMaxVid(maxV);
148 tmp_ROIid.setSensorID(sensorID);
149
150 m_ROIs.appendNew(tmp_ROIid);
151 }
152 }
153}
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
void initialize() override final
Initializer.
std::string m_ROIListName
ROi list name.
int m_nROIs
number of ROIs per event
bool m_random
move single roi pseudo randomly
StoreObjPtr< EventMetaData > m_eventMetaData
EventMetaData DataStore pointer.
void event() override final
This method is called for each event.
int m_divider
generate one ROI every m_divider event
ROIGeneratorModule()
Constructor of the module.
StoreArray< ROIid > m_ROIs
ROIs StoreArray.
ROIid stores the U and V ids and the sensor id of the Region Of Interest.
Definition: ROIid.h:25
void setMaxUid(double user_maxUid)
set the maximum U id of the ROI
Definition: ROIid.h:51
void setMinUid(double user_minUid)
set the minimum U id of the ROI
Definition: ROIid.h:50
void setMaxVid(double user_maxVid)
set the maximum V id of the ROI
Definition: ROIid.h:53
void setSensorID(VxdID::baseType user_sensorID)
set the sensor ID of the ROI
Definition: ROIid.h:54
void setMinVid(double user_minVid)
set the minimum V id of the ROI
Definition: ROIid.h:52
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
void setSensorNumber(baseType sensor)
Set the sensor id.
Definition: VxdID.h:111
void setLadderNumber(baseType ladder)
Set the ladder id.
Definition: VxdID.h:109
void setLayerNumber(baseType layer)
Set the layer id.
Definition: VxdID.h:107
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.