Belle II Software  release-08-01-10
SVDClusterFilterModule.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 <svd/modules/svdPerformance/SVDClusterFilterModule.h>
10 #include <vxd/geometry/GeoCache.h>
11 #include <vxd/geometry/SensorInfoBase.h>
12 
13 #include <framework/datastore/StoreArray.h>
14 
15 
16 using namespace Belle2;
17 
18 //-----------------------------------------------------------------
19 // Register the Module
20 //-----------------------------------------------------------------
21 REG_MODULE(SVDClusterFilter);
22 
23 //-----------------------------------------------------------------
24 // Implementation
25 //-----------------------------------------------------------------
26 
28 {
29  B2DEBUG(1, "Constructor");
30  // Set module properties
31  setDescription("generates a new StoreArray from the input StoreArray which has all specified Clusters removed");
32 
33  // Parameter definitions
34  addParam("inputArrayName", m_inputArrayName, "StoreArray with the input clusters", std::string("SVDClusters"));
35  addParam("outputINArrayName", m_outputINArrayName, "StoreArray with the output clusters", std::string(""));
36  addParam("outputOUTArrayName", m_outputOUTArrayName, "StoreArray with the output clusters", std::string(""));
37  addParam("layerNum", m_layerNum, "layer number (0 -> no selection)", int(0));
38  addParam("XShell", m_xShell, "X-Shell ID (+1 -> +X, -1 -> -X, 0 -> both)", int(0));
39  addParam("YShell", m_yShell, "Y-Shell ID (+1 -> +Y, -1 -> -Y, 0 -> both)", int(0));
40  addParam("minSNR", m_minClSNR, "minimum cluster SNR", float(0));
41 
42 }
43 
45 {
46  B2DEBUG(1, "Destructor");
47 }
48 
49 
51 {
52 
53  B2DEBUG(10, "inputArrayName: " << m_inputArrayName);
54  B2DEBUG(1, "outputINArrayName: " << m_outputINArrayName);
55  B2DEBUG(1, "outputOUTArrayName: " << m_outputOUTArrayName);
56  B2DEBUG(1, "layerNum: " << m_layerNum);
57  B2DEBUG(1, "X-Shell: " << m_xShell);
58  B2DEBUG(1, "Y-Shell: " << m_yShell);
59  B2DEBUG(1, "minSNR: " << m_minClSNR);
60 
61 
63  inputArray.isRequired();
64 
65  m_selectedClusters.registerSubset(inputArray, m_outputINArrayName);
66  m_selectedClusters.inheritAllRelations();
67  if (m_outputOUTArrayName != "") {
68  m_notSelectedClusters.registerSubset(inputArray, m_outputOUTArrayName);
69  m_notSelectedClusters.inheritAllRelations();
70  }
72 }
73 
74 
76 {
77 }
78 
79 
81 {
82  B2DEBUG(1, std::endl << "NEW EVENT: " << m_layerNum << std::endl);
83 
84  StoreArray<SVDCluster> inputClusterArray(m_inputArrayName);
85 
86  m_selectedClusters.select([this](const SVDCluster * aCluster) {
87 
88 
89  bool inVxdID = (this->m_outVxdID).find(aCluster->getSensorID()) == (this->m_outVxdID).end();
90  bool aboveSNR = aCluster->getSNR() > this->m_minClSNR;
91 
92  if (!inVxdID)
93  B2DEBUG(10, "not selected VxdID (OUT): " << aCluster->getSensorID().getLayerNumber() << "." <<
94  aCluster->getSensorID().getLadderNumber());
95 
96  if (!aboveSNR)
97  B2DEBUG(10, "below SNR (OUT):" << aCluster->getSNR());
98 
99  if (aboveSNR && inVxdID)
100  B2DEBUG(10, "keeping " << aCluster->getSensorID().getLayerNumber() << "." << aCluster->getSensorID().getLadderNumber() << " SNR = "
101  << aCluster->getSNR());
102 
103  return (inVxdID && aboveSNR);
104 
105  });
106 
107  if (m_outputOUTArrayName != "") {
108  m_notSelectedClusters.select([this](const SVDCluster * aCluster) {
109 
110  bool inVxdID = (this->m_outVxdID).find(aCluster->getSensorID()) == (this->m_outVxdID).end();
111  bool aboveSNR = aCluster->getSNR() > this->m_minClSNR;
112 
113  if (inVxdID)
114  B2DEBUG(10, "selected VxdID (IN): " << aCluster->getSensorID().getLayerNumber() << "." <<
115  aCluster->getSensorID().getLadderNumber());
116 
117  if (aboveSNR)
118  B2DEBUG(10, "above SNR (IN):" << aCluster->getSNR());
119 
120  if (!(aboveSNR && inVxdID))
121  B2DEBUG(10, "rejecting " << aCluster->getSensorID().getLayerNumber() << "." << aCluster->getSensorID().getLadderNumber() <<
122  " SNR = " << aCluster->getSNR());
123 
124  return (!(inVxdID && aboveSNR));
125 
126  });
127  }
128 }
129 
131 {
132 
134 
135  for (auto layer : geoCache.getLayers(VXD::SensorInfoBase::SVD)) {
136  int currentLayer = layer.getLayerNumber();
137 
138  bool layer_IN = true;
139 
140  if ((m_layerNum != 0) && (currentLayer != m_layerNum))
141  layer_IN = false;
142 
143  for (auto ladder : geoCache.getLadders(layer))
144  for (Belle2::VxdID sensor : geoCache.getSensors(ladder)) {
145 
146  bool xShell_IN = true;
147  bool yShell_IN = true;
148 
149  const VXD::SensorInfoBase& theSensorInfo = geoCache.getSensorInfo(sensor);
150  const ROOT::Math::XYZVector globPos = theSensorInfo.pointToGlobal(ROOT::Math::XYZVector(0, 0, 0));
151  if (globPos.X()*m_xShell < 0)
152  xShell_IN = false;
153 
154  if (globPos.Y()*m_yShell < 0)
155  xShell_IN = false;
156 
157  if (!(layer_IN && xShell_IN && yShell_IN))
158  m_outVxdID.insert(sensor);
159 
160  }
161  }
162 
163  B2DEBUG(10, "list of VxdID OUT:");
164  for (auto it = m_outVxdID.begin(); it != m_outVxdID.end(); it++)
165  B2DEBUG(10, it->getLayerNumber() << "." << it->getLadderNumber() << "." << it->getSensorNumber());
166 
167 }
168 
170 {
171 }
172 
174 {
175 }
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
std::string m_outputOUTArrayName
StoreArray with the NOT selected output clusters.
std::string m_outputINArrayName
StoreArray with the selectd output clusters.
SVDClusterFilterModule()
Constructor: Sets the description, the properties and the parameters of the module.
virtual void initialize() override
init the module
virtual void event() override
processes the event
std::set< VxdID > m_outVxdID
set containing the VxdID of the DUT sensors
virtual void endRun() override
end the run
virtual void terminate() override
terminates the module
int m_xShell
X shell identificator: +1(+X), -1 (-X), 0(both)
int m_layerNum
the layer number from which the clusters should be excluded m_sensorID
SelectSubset< SVDCluster > m_notSelectedClusters
all clusters on the layer with m_layerNum
virtual void beginRun() override
initializes the module
SelectSubset< SVDCluster > m_selectedClusters
all clusters NOT on the layer with m_layerNum
int m_yShell
Y shell identificator: +1(+Y), -1 (-Y), 0(both)
std::string m_inputArrayName
StoreArray with the input clusters.
float m_minClSNR
minimum cluster SNR
void create_outVxdID_set()
creates the set containing the VxdID of the DUT sensors
virtual ~SVDClusterFilterModule()
if required
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition: SVDCluster.h:29
float getSNR() const
Get cluster SNR.
Definition: SVDCluster.h:159
VxdID getSensorID() const
Get the sensor ID.
Definition: SVDCluster.h:102
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:39
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
Base class to provide Sensor Information for PXD and SVD.
ROOT::Math::XYZVector pointToGlobal(const ROOT::Math::XYZVector &local, bool reco=false) const
Convert a point from local to global coordinates.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
baseType getLadderNumber() const
Get the ladder id.
Definition: VxdID.h:98
baseType getLayerNumber() const
Get the layer id.
Definition: VxdID.h:96
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.