Belle II Software development
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
16using namespace Belle2;
17
18//-----------------------------------------------------------------
19// Register the Module
20//-----------------------------------------------------------------
21REG_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
75
77{
78 B2DEBUG(1, std::endl << "NEW EVENT: " << m_layerNum << std::endl);
79
81
82 m_selectedClusters.select([this](const SVDCluster * aCluster) {
83
84
85 bool inVxdID = (this->m_outVxdID).find(aCluster->getSensorID()) == (this->m_outVxdID).end();
86 bool aboveSNR = aCluster->getSNR() > this->m_minClSNR;
87
88 if (!inVxdID)
89 B2DEBUG(10, "not selected VxdID (OUT): " << aCluster->getSensorID().getLayerNumber() << "." <<
90 aCluster->getSensorID().getLadderNumber());
91
92 if (!aboveSNR)
93 B2DEBUG(10, "below SNR (OUT):" << aCluster->getSNR());
94
95 if (aboveSNR && inVxdID)
96 B2DEBUG(10, "keeping " << aCluster->getSensorID().getLayerNumber() << "." << aCluster->getSensorID().getLadderNumber() << " SNR = "
97 << aCluster->getSNR());
98
99 return (inVxdID && aboveSNR);
100
101 });
102
103 if (m_outputOUTArrayName != "") {
104 m_notSelectedClusters.select([this](const SVDCluster * aCluster) {
105
106 bool inVxdID = (this->m_outVxdID).find(aCluster->getSensorID()) == (this->m_outVxdID).end();
107 bool aboveSNR = aCluster->getSNR() > this->m_minClSNR;
108
109 if (inVxdID)
110 B2DEBUG(10, "selected VxdID (IN): " << aCluster->getSensorID().getLayerNumber() << "." <<
111 aCluster->getSensorID().getLadderNumber());
112
113 if (aboveSNR)
114 B2DEBUG(10, "above SNR (IN):" << aCluster->getSNR());
115
116 if (!(aboveSNR && inVxdID))
117 B2DEBUG(10, "rejecting " << aCluster->getSensorID().getLayerNumber() << "." << aCluster->getSensorID().getLadderNumber() <<
118 " SNR = " << aCluster->getSNR());
119
120 return (!(inVxdID && aboveSNR));
121
122 });
123 }
124}
125
127{
128
130
131 for (auto layer : geoCache.getLayers(VXD::SensorInfoBase::SVD)) {
132 int currentLayer = layer.getLayerNumber();
133
134 bool layer_IN = true;
135
136 if ((m_layerNum != 0) && (currentLayer != m_layerNum))
137 layer_IN = false;
138
139 for (auto ladder : geoCache.getLadders(layer))
140 for (Belle2::VxdID sensor : geoCache.getSensors(ladder)) {
141
142 bool xShell_IN = true;
143 bool yShell_IN = true;
144
145 const VXD::SensorInfoBase& theSensorInfo = geoCache.getSensorInfo(sensor);
146 const ROOT::Math::XYZVector globPos = theSensorInfo.pointToGlobal(ROOT::Math::XYZVector(0, 0, 0));
147 if (globPos.X()*m_xShell < 0)
148 xShell_IN = false;
149
150 if (globPos.Y()*m_yShell < 0)
151 xShell_IN = false;
152
153 if (!(layer_IN && xShell_IN && yShell_IN))
154 m_outVxdID.insert(sensor);
155
156 }
157 }
158
159 B2DEBUG(10, "list of VxdID OUT:");
160 for (auto it = m_outVxdID.begin(); it != m_outVxdID.end(); it++)
161 B2DEBUG(10, it->getLayerNumber() << "." << it->getLadderNumber() << "." << it->getSensorNumber());
162
163}
164
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
Module()
Constructor.
Definition Module.cc:30
std::string m_outputOUTArrayName
StoreArray with the NOT selected output clusters.
std::string m_outputINArrayName
StoreArray with the selected output clusters.
SVDClusterFilterModule()
Constructor: Sets the description, the properties and the parameters of the module.
virtual void initialize() override
init the module
virtual ~SVDClusterFilterModule() override
if required
virtual void event() override
processes the event
std::set< VxdID > m_outVxdID
set containing the VxdID of the DUT sensors
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
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
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.
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
Class to facilitate easy access to sensor information of the VXD like coordinate transformations or p...
Definition GeoCache.h:38
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:32
baseType getLadderNumber() const
Get the ladder id.
Definition VxdID.h:97
baseType getLayerNumber() const
Get the layer id.
Definition VxdID.h:95
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.