Belle II Software development
PXDRawHitFilterModule.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/roiFinding/pxd/PXDRawHitFilterModule.h>
10#include <tracking/dataobjects/ROIid.h>
11
12#include <map>
13
14using namespace Belle2;
15
16//-----------------------------------------------------------------
17// Register the Module
18//-----------------------------------------------------------------
19REG_MODULE(PXDRawHitFilter);
20
21//-----------------------------------------------------------------
22// Implementation
23//-----------------------------------------------------------------
24
26{
27 // Set module properties
28 setDescription("The module produce a StoreArray of PXDRawHit inside the ROIs.");
30
31 // Parameter definitions
32 addParam("PXDRawHitsName", m_PXDRawHitsName, "The name of the StoreArray of PXDRawHits to be filtered", std::string(""));
33 addParam("PXDRawHitsInsideROIName", m_PXDRawHitsInsideROIName, "The name of the StoreArray of Filtered PXDRawHits",
34 std::string("PXDRawHitsIN"));
35 addParam("PXDRawHitsOutsideROIName", m_PXDRawHitsOutsideROIName, "The name of the StoreArray of Filtered PXDRawHits",
36 std::string("PXDRawHitsOUT"));
37 addParam("ROIidsName", m_ROIidsName, "The name of the StoreArray of ROIs", std::string(""));
38 addParam("CreateOutside", m_CreateOutside, "Create the StoreArray of PXD pixel outside the ROIs", false);
39
40}
41
43{
44 m_ROIs.isRequired(m_ROIidsName);
45 m_PXDRawHits.isRequired(m_PXDRawHitsName);
48 m_selectorIN.registerSubset(m_PXDRawHits);
49 } else {
51 m_selectorIN.inheritAllRelations();
52 }
53
54 if (m_CreateOutside) {
56 m_selectorOUT.registerSubset(m_PXDRawHits);
57 } else {
59 m_selectorOUT.inheritAllRelations();
60 }
61 }
62}
63
65{
66 std::multimap< VxdID, ROIid > ROIids;
67
68 for (auto ROI : m_ROIs)
69 ROIids.insert(std::pair<VxdID, ROIid> (ROI.getSensorID(), ROI));
70
71 m_selectorIN.select([ROIids](const PXDRawHit * thePxdRawHit) {
72 auto ROIidsRange = ROIids.equal_range(thePxdRawHit->getSensorID()) ;
73 for (auto theROI = ROIidsRange.first ; theROI != ROIidsRange.second; theROI ++)
74 if (theROI->second.Contains(*thePxdRawHit))
75 return true;
76
77 return false;
78 });
79
80 if (m_CreateOutside) {
81 m_selectorOUT.select([ROIids](const PXDRawHit * thePxdRawHit) {
82 auto ROIidsRange = ROIids.equal_range(thePxdRawHit->getSensorID()) ;
83 for (auto theROI = ROIidsRange.first ; theROI != ROIidsRange.second; theROI ++)
84 if (theROI->second.Contains(*thePxdRawHit))
85 return false;
86
87 return true;
88 });
89 }
90
91}
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
std::string m_PXDRawHitsName
The name of the StoreArray of PXDRawHits to be filtered.
void initialize() override final
Initialize all necessary variables.
StoreArray< PXDRawHit > m_PXDRawHits
PXDRawHits StoreArray.
SelectSubset< PXDRawHit > m_selectorIN
selector of the subset of PXDRawHits contained in the ROIs
void event() override final
Event function.
std::string m_ROIidsName
The name of the StoreArray of ROIs.
std::string m_PXDRawHitsInsideROIName
The name of the StoreArray of Filtered PXDRawHits.
PXDRawHitFilterModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::string m_PXDRawHitsOutsideROIName
The name of the StoreArray of Filtered PXDRawHits.
bool m_CreateOutside
if set, create list of outside pixels, too
SelectSubset< PXDRawHit > m_selectorOUT
selector of the subset of PXDRawHits NOT contained in the ROIs
StoreArray< ROIid > m_ROIs
ROIs StoreArray.
The PXD Raw Hit class This class stores information about PXD Pixel hits and makes them available in ...
Definition: PXDRawHit.h:24
VxdID getSensorID() const
Get the sensor ID.
Definition: PXDRawHit.h:52
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
Abstract base class for different kinds of events.