Belle II Software  release-08-01-10
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/pxdDataReduction/PXDRawHitFilterModule.h>
10 #include <map>
11 
12 using namespace Belle2;
13 
14 //-----------------------------------------------------------------
15 // Register the Module
16 //-----------------------------------------------------------------
17 REG_MODULE(PXDRawHitFilter);
18 
19 //-----------------------------------------------------------------
20 // Implementation
21 //-----------------------------------------------------------------
22 
24 {
25  // Set module properties
26  setDescription("The module produce a StoreArray of PXDRawHit inside the ROIs.");
28 
29  // Parameter definitions
30  addParam("PXDRawHitsName", m_PXDRawHitsName, "The name of the StoreArray of PXDRawHits to be filtered", std::string(""));
31  addParam("PXDRawHitsInsideROIName", m_PXDRawHitsInsideROIName, "The name of the StoreArray of Filtered PXDRawHits",
32  std::string("PXDRawHitsIN"));
33  addParam("PXDRawHitsOutsideROIName", m_PXDRawHitsOutsideROIName, "The name of the StoreArray of Filtered PXDRawHits",
34  std::string("PXDRawHitsOUT"));
35  addParam("ROIidsName", m_ROIidsName, "The name of the StoreArray of ROIs", std::string(""));
36  addParam("CreateOutside", m_CreateOutside, "Create the StoreArray of PXD pixel outside the ROIs", false);
37 
38 }
39 
41 {
42  m_ROIs.isRequired(m_ROIidsName);
43  m_PXDRawHits.isRequired(m_PXDRawHitsName);
46  m_selectorIN.registerSubset(m_PXDRawHits);
47  } else {
49  m_selectorIN.inheritAllRelations();
50  }
51 
52  if (m_CreateOutside) {
54  m_selectorOUT.registerSubset(m_PXDRawHits);
55  } else {
57  m_selectorOUT.inheritAllRelations();
58  }
59  }
60 }
61 
63 {
64  std::multimap< VxdID, ROIid > ROIids;
65 
66  for (auto ROI : m_ROIs)
67  ROIids.insert(std::pair<VxdID, ROIid> (ROI.getSensorID(), ROI));
68 
69  m_selectorIN.select([ROIids](const PXDRawHit * thePxdRawHit) {
70  auto ROIidsRange = ROIids.equal_range(thePxdRawHit->getSensorID()) ;
71  for (auto theROI = ROIidsRange.first ; theROI != ROIidsRange.second; theROI ++)
72  if (theROI->second.Contains(*thePxdRawHit))
73  return true;
74 
75  return false;
76  });
77 
78  if (m_CreateOutside) {
79  m_selectorOUT.select([ROIids](const PXDRawHit * thePxdRawHit) {
80  auto ROIidsRange = ROIids.equal_range(thePxdRawHit->getSensorID()) ;
81  for (auto theROI = ROIidsRange.first ; theROI != ROIidsRange.second; theROI ++)
82  if (theROI->second.Contains(*thePxdRawHit))
83  return false;
84 
85  return true;
86  });
87  }
88 
89 }
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
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.