Belle II Software  release-05-02-19
PXDRawHitFilterModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Paoloni *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <tracking/modules/pxdDataReduction/PXDRawHitFilterModule.h>
12 #include <tracking/dataobjects/ROIid.h>
13 #include <map>
14 
15 using namespace Belle2;
16 using namespace std;
17 
18 //-----------------------------------------------------------------
19 // Register the Module
20 //-----------------------------------------------------------------
21 REG_MODULE(PXDRawHitFilter)
22 
23 //-----------------------------------------------------------------
24 // Implementation
25 //-----------------------------------------------------------------
26 
28 {
29  // Set module properties
30  setDescription("The module produce a StoreArray of PXDRawHit inside the ROIs.");
31  setPropertyFlags(c_ParallelProcessingCertified);
32 
33  // Parameter definitions
34  addParam("PXDRawHitsName", m_PXDRawHitsName, "The name of the StoreArray of PXDRawHits to be filtered", std::string(""));
35  addParam("PXDRawHitsInsideROIName", m_PXDRawHitsInsideROIName, "The name of the StoreArray of Filtered PXDRawHits",
36  std::string("PXDRawHitsIN"));
37  addParam("PXDRawHitsOutsideROIName", m_PXDRawHitsOutsideROIName, "The name of the StoreArray of Filtered PXDRawHits",
38  std::string("PXDRawHitsOUT"));
39  addParam("ROIidsName", m_ROIidsName, "The name of the StoreArray of ROIs", std::string(""));
40  addParam("CreateOutside", m_CreateOutside, "Create the StoreArray of PXD pixel outside the ROIs", false);
41 
42 }
43 
45 {
46 
47  StoreArray<ROIid> roiIDs;
48  roiIDs.isRequired(m_ROIidsName);
49 
50  StoreArray<PXDRawHit> PXDRawHits(m_PXDRawHitsName);
51  PXDRawHits.isRequired();
52  if (m_PXDRawHitsName == m_PXDRawHitsInsideROIName) {
53  m_selectorIN.registerSubset(PXDRawHits);
54  } else {
55  m_selectorIN.registerSubset(PXDRawHits, m_PXDRawHitsInsideROIName);
56  m_selectorIN.inheritAllRelations();
57  }
58 
59  if (m_CreateOutside) {
60  if (m_PXDRawHitsName == m_PXDRawHitsOutsideROIName) {
61  m_selectorOUT.registerSubset(PXDRawHits);
62  } else {
63  m_selectorOUT.registerSubset(PXDRawHits, m_PXDRawHitsOutsideROIName);
64  m_selectorOUT.inheritAllRelations();
65  }
66  }
67 }
68 
70 {
71  StoreArray<PXDRawHit> PXDRawHits(m_PXDRawHitsName);
72  StoreArray<ROIid> ROIids_store_array(m_ROIidsName);
74  multimap< VxdID, ROIid > ROIids;
75 
76  for (auto ROI : ROIids_store_array)
77  ROIids.insert(pair<VxdID, ROIid> (ROI.getSensorID() , ROI));
78 
79  m_selectorIN.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 true;
84 
85  return false;
86  });
87 
88  if (m_CreateOutside) {
89  m_selectorOUT.select([ROIids](const PXDRawHit * thePxdRawHit) {
90  auto ROIidsRange = ROIids.equal_range(thePxdRawHit->getSensorID()) ;
91  for (auto theROI = ROIidsRange.first ; theROI != ROIidsRange.second; theROI ++)
92  if (theROI->second.Contains(*thePxdRawHit))
93  return false;
94 
95  return true;
96  });
97  }
98 
99 }
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::PXDRawHit
The PXD Raw Hit class This class stores information about PXD Pixel hits and makes them available in ...
Definition: PXDRawHit.h:36
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::PXDRawHitFilterModule::initialize
void initialize() override final
Initialize the Module.
Definition: PXDRawHitFilterModule.cc:44
Belle2::PXDRawHit::getSensorID
VxdID getSensorID() const
Get the sensor ID.
Definition: PXDRawHit.h:64
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::PXDRawHitFilterModule
The module produce a StoreArray of PXDRawHit inside the ROIs.
Definition: PXDRawHitFilterModule.h:39
Belle2::PXDRawHitFilterModule::event
void event() override final
This method is the core of the module.
Definition: PXDRawHitFilterModule.cc:69