Belle II Software development
PXDRawHitMaskingModule.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 <pxd/modules/pxdHelper/PXDRawHitMaskingModule.h>
10
11#include <framework/datastore/DataStore.h>
12#include <framework/datastore/RelationArray.h>
13#include <framework/logging/Logger.h>
14
15#include <vxd/geometry/GeoCache.h>
16
17#include <pxd/reconstruction/Pixel.h>
18#include <pxd/reconstruction/PXDPixelMasker.h>
19
20#include <set>
21
22using namespace std;
23using namespace Belle2;
24using namespace Belle2::PXD;
25
26//-----------------------------------------------------------------
27// Register the Module
28//-----------------------------------------------------------------
29REG_MODULE(PXDRawHitMasking);
30
31//-----------------------------------------------------------------
32// Implementation
33//-----------------------------------------------------------------
34
36{
37 //Set module properties
38 setDescription("This module masks the input collection of PXDRawHits into "
39 "a PXDRawHit output collection");
41
42 addParam("zeroSuppressionCut", m_0cut, "Minimum charge for a digit to carry", 0);
43 addParam("trimOutOfRange", m_trimOutOfRange, "Discard rawhits whit out-of-range coordinates", true);
44 addParam("rawHits", m_storeRawHitsName, "PXDRawHit collection name", string(""));
45 addParam("rawHitsOut", m_storeRawHitsNameOut, "PXDRawHit Out collection name", string("PXDRawHitsOut"));
46}
47
48
50{
51 //Register collections
53 m_pxdRawHitOut.registerInDataStore(m_storeRawHitsNameOut);
54}
55
57{
58
59 // if no input, nothing to do
60 if (!m_pxdRawHit || !m_pxdRawHit.getEntries()) return;
61
63
64 for (auto& it : m_pxdRawHit) {
65 VxdID sensorID = it.getSensorID();
66 if (!geo.validSensorID(sensorID)) {
67 B2WARNING("Malformed PXDRawHit, VxdID $" << hex << sensorID.getID() << ", dropping. (" << sensorID << ")");
68 continue;
69 }
70 if (m_trimOutOfRange && !goodHit(it))
71 continue;
72 // Zero-suppression cut
73 if (it.getCharge() < m_0cut) continue;
74
75 // We need some protection against bad data
76 if (sensorID.getLayerNumber() && sensorID.getLadderNumber() && sensorID.getSensorNumber()) {
77 if (PXDPixelMasker::getInstance().pixelOK(sensorID, it.getColumn(), it.getRow())) {
78 m_pxdRawHitOut.appendNew(it);
79 }
80 }
81 }
82}
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
static PXDPixelMasker & getInstance()
Main (and only) way to access the PXDPixelMasker.
int m_0cut
Minimum charge for a digit to carry.
bool m_trimOutOfRange
Discard out-of-range hits.
StoreArray< PXDRawHit > m_pxdRawHit
Required input for PXDRawHit.
virtual void initialize() override
Initialize the module.
virtual void event() override
do the filtering
PXDRawHitMaskingModule()
Constructor defining the parameters.
std::string m_storeRawHitsNameOut
Name of the collection to use for Output PXDRawHits.
std::string m_storeRawHitsName
Name of the collection to use for PXDRawHits.
bool goodHit(const PXDRawHit &rawhit) const
Utility function to check pixel coordinates.
StoreArray< PXDRawHit > m_pxdRawHitOut
Required output for PXDRawHit.
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
bool validSensorID(Belle2::VxdID id) const
Check that id is a valid sensor number.
Definition: GeoCache.cc:52
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
baseType getID() const
Get the unique id.
Definition: VxdID.h:94
baseType getSensorNumber() const
Get the sensor id.
Definition: VxdID.h:100
baseType getLadderNumber() const
Get the ladder id.
Definition: VxdID.h:98
baseType getLayerNumber() const
Get the layer id.
Definition: VxdID.h:96
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
Namespace to encapsulate code needed for simulation and reconstrucion of the PXD.
Abstract base class for different kinds of events.
STL namespace.