Belle II Software  release-08-01-10
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/pxdDataReduction/ROIGeneratorModule.h>
10 #include <framework/datastore/StoreArray.h>
11 
12 using namespace Belle2;
13 
14 //-----------------------------------------------------------------
15 // Register the Module
16 //-----------------------------------------------------------------
17 
18 REG_MODULE(ROIGenerator);
19 
20 //-----------------------------------------------------------------
21 // Implementation
22 //-----------------------------------------------------------------
23 
25 {
26  //Set module properties
27  setDescription("This module is used to generate a certain number of ROIs");
29 
30  addParam("ROIListName", m_ROIListName, "name of the list of ROIs", std::string(""));
31  addParam("nROIs", m_nROIs, "number of generated ROIs", 1);
32 
33  addParam("TrigDivider", m_divider, "Generates one ROI every TrigDivider events", 2);
34  addParam("Layer", m_layer, "on layer", 1);
35  addParam("Ladder", m_ladder, " ladder ", 1);
36  addParam("Sensor", m_sensor, " sensor ", 1);
37 
38  addParam("MinU", m_minU, " min U (pixel column hopefully) ", 0);
39  addParam("MaxU", m_maxU, " max U (pixel column hopefully) ", 250 - 1);
40 
41 
42  addParam("MinV", m_minV, " min V (pixel column hopefully) ", 0);
43  addParam("MaxV", m_maxV, " max v (pixel column hopefully) ", 768 - 1);
44 
45  addParam("Random", m_random, "dont use fix position, move pseudo randomly", false);
46 }
47 
49 {
50  m_eventMetaData.isRequired();
51 
52  m_ROIs.registerInDataStore(m_ROIListName); // does not report error if ROIid exists
53 }
54 
56 {
57  int tNr = m_eventMetaData->getEvent(); // trigger number
58 
59  // Only if divider tells us to...
60  if (m_divider != 0 && (tNr % m_divider) != 0)
61  return ;
62 
63  ROIid tmp_ROIid;
64 
65  VxdID sensorID;
66  sensorID.setLayerNumber(m_layer);
67  sensorID.setLadderNumber(m_ladder);
68  sensorID.setSensorNumber(m_sensor);
69 
70  // Always create one FULL size ROI
71  int minU = m_minU, maxU = m_maxU, minV = m_minV, maxV = m_maxV;
72  int w = maxU - minU;
73  int h = maxV - minV;
74  if (m_nROIs == 1 && m_random) {
75  switch (tNr % 9) {
76  case 0:
77  minU = 0;
78  maxU = w;
79  minV = 0;
80  maxV = h;
81  break;
82  case 1:
83  minU = 0;
84  maxU = w;
85  break;
86  case 2:
87  minU = 0;
88  maxU = w;
89  minV = 768 - 1 - h;
90  maxV = 768 - 1;
91  break;
92  case 3:
93  minV = 0;
94  maxV = h;
95  break;
96  case 4:
97  break;
98  case 5:
99  minV = 768 - 1 - h;
100  maxV = 768 - 1;
101  break;
102  case 6:
103  minU = 250 - 1 - w;
104  maxU = 250 - 1;
105  minV = 0;
106  maxV = h;
107  break;
108  case 7:
109  minU = 250 - 1 - w;
110  maxU = 250 - 1;
111  break;
112  case 8:
113  minU = 250 - 1 - w;
114  maxU = 250 - 1;
115  minV = 768 - 1 - h;
116  maxV = 768 - 1;
117  break;
118  default:
119  break;
120  }
121  }
122  tmp_ROIid.setMinUid(minU);
123  tmp_ROIid.setMinVid(minV);
124  tmp_ROIid.setMaxUid(maxU);
125  tmp_ROIid.setMaxVid(maxV);
126  tmp_ROIid.setSensorID(sensorID);
127 
128  m_ROIs.appendNew(tmp_ROIid);
129 
130  if (m_nROIs > 1) {
131  // ... plus additional ones for debugging.
132  // maybe we should do it depending on the triggernr lateron...
133  int dU = (m_maxU - m_minU) / (m_nROIs + 1);
134  int dV = (m_maxV - m_minV) / (m_nROIs + 1);
135  for (int iROI = 1; iROI < m_nROIs; iROI++) {
136  // Create a chain of ROIs from top left to bottom right
137  minU = m_minU + dU * iROI;
138  maxU = minU + dU;
139  minV = m_minV + dV * iROI;
140  maxV = minV + dV;
141 
142  tmp_ROIid.setMinUid(minU);
143  tmp_ROIid.setMinVid(minV);
144  tmp_ROIid.setMaxUid(maxU);
145  tmp_ROIid.setMaxVid(maxV);
146  tmp_ROIid.setSensorID(sensorID);
147 
148  m_ROIs.appendNew(tmp_ROIid);
149  }
150  }
151 }
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
REG_MODULE(arichBtest)
Register the Module.
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
Abstract base class for different kinds of events.