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