Belle II Software  release-06-01-15
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 <tracking/dataobjects/ROIid.h>
11 #include <map>
12 
13 using namespace Belle2;
14 using namespace std;
15 
16 //-----------------------------------------------------------------
17 // Register the Module
18 //-----------------------------------------------------------------
19 REG_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.");
29  setPropertyFlags(c_ParallelProcessingCertified);
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 
45  StoreArray<ROIid> roiIDs;
46  roiIDs.isRequired(m_ROIidsName);
47 
48  StoreArray<PXDRawHit> PXDRawHits(m_PXDRawHitsName);
49  PXDRawHits.isRequired();
50  if (m_PXDRawHitsName == m_PXDRawHitsInsideROIName) {
51  m_selectorIN.registerSubset(PXDRawHits);
52  } else {
53  m_selectorIN.registerSubset(PXDRawHits, m_PXDRawHitsInsideROIName);
54  m_selectorIN.inheritAllRelations();
55  }
56 
57  if (m_CreateOutside) {
58  if (m_PXDRawHitsName == m_PXDRawHitsOutsideROIName) {
59  m_selectorOUT.registerSubset(PXDRawHits);
60  } else {
61  m_selectorOUT.registerSubset(PXDRawHits, m_PXDRawHitsOutsideROIName);
62  m_selectorOUT.inheritAllRelations();
63  }
64  }
65 }
66 
68 {
69  StoreArray<PXDRawHit> PXDRawHits(m_PXDRawHitsName);
70  StoreArray<ROIid> ROIids_store_array(m_ROIidsName);
72  multimap< VxdID, ROIid > ROIids;
73 
74  for (auto ROI : ROIids_store_array)
75  ROIids.insert(pair<VxdID, ROIid> (ROI.getSensorID() , ROI));
76 
77  m_selectorIN.select([ROIids](const PXDRawHit * thePxdRawHit) {
78  auto ROIidsRange = ROIids.equal_range(thePxdRawHit->getSensorID()) ;
79  for (auto theROI = ROIidsRange.first ; theROI != ROIidsRange.second; theROI ++)
80  if (theROI->second.Contains(*thePxdRawHit))
81  return true;
82 
83  return false;
84  });
85 
86  if (m_CreateOutside) {
87  m_selectorOUT.select([ROIids](const PXDRawHit * thePxdRawHit) {
88  auto ROIidsRange = ROIids.equal_range(thePxdRawHit->getSensorID()) ;
89  for (auto theROI = ROIidsRange.first ; theROI != ROIidsRange.second; theROI ++)
90  if (theROI->second.Contains(*thePxdRawHit))
91  return false;
92 
93  return true;
94  });
95  }
96 
97 }
Base class for Modules.
Definition: Module.h:72
The module produce a StoreArray of PXDRawHit inside the ROIs.
void initialize() override final
Initialize the Module.
void event() override final
This method is the core of the module.
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
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
#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.