Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunereco
dunereco
HitFinderDUNE
NumberOfHitsFilter_module.cc
Go to the documentation of this file.
1
////////////////////////////////////////////////////////////////////////
2
//
3
// Very simple module to filter out events with too many hits
4
// - Designed to prevent jobs hanging on very large events
5
//
6
// Leigh Whitehead - leigh.howard.whitehead@cern.ch
7
//
8
////////////////////////////////////////////////////////////////////////
9
10
// Framework includes
11
#include "
art/Framework/Core/EDFilter.h
"
12
#include "
art/Framework/Principal/Event.h
"
13
#include "
art/Framework/Principal/Run.h
"
14
#include "
art/Framework/Principal/Handle.h
"
15
#include "
art/Framework/Services/Registry/ServiceHandle.h
"
16
#include "art_root_io/TFileService.h"
17
#include "
art/Framework/Core/ModuleMacros.h
"
18
#include "
art/Framework/Services/Registry/ActivityRegistry.h
"
19
#include "
messagefacility/MessageLogger/MessageLogger.h
"
20
#include "
fhiclcpp/ParameterSet.h
"
21
22
#include "
lardataobj/RecoBase/Hit.h
"
23
#include "
lardata/DetectorInfoServices/DetectorPropertiesService.h
"
24
25
namespace
hit
{
26
class
NumberOfHitsFilter
;
27
}
28
29
class
hit::NumberOfHitsFilter
:
public
art::EDFilter
{
30
public
:
31
32
explicit
NumberOfHitsFilter
(
fhicl::ParameterSet
const
& pset);
33
virtual
~NumberOfHitsFilter
();
34
35
void
beginJob
()
override
;
36
bool
filter
(
art::Event
&
evt
)
override
;
37
bool
beginRun
(
art::Run
&
r
)
override
;
38
void
endJob
()
override
;
39
40
private
:
41
42
bool
fLimitPerTPC
;
43
unsigned
int
fHitLimit
;
44
std::string
fHitModule
;
45
bool
fScaleThresholdForReadoutWindow
;
46
};
47
48
//-----------------------------------------------------------------------
49
hit::NumberOfHitsFilter::NumberOfHitsFilter
(
fhicl::ParameterSet
const
& pset):
50
EDFilter
(pset)
51
{
52
fLimitPerTPC
= pset.
get
<
bool
>(
"LimitPerTPC"
);
53
fHitLimit
= pset.
get
<
unsigned
int
>(
"HitLimit"
);
54
fHitModule
= pset.
get
<
std::string
>(
"HitModule"
);
55
fScaleThresholdForReadoutWindow
= pset.
get
<
bool
>(
"ScaleThresholdForReadoutWindow"
);
56
}
57
58
//-----------------------------------------------------------------------
59
hit::NumberOfHitsFilter::~NumberOfHitsFilter
(){}
60
61
//-----------------------------------------------------------------------
62
void
hit::NumberOfHitsFilter::beginJob
() {}
63
//-----------------------------------------------------------------------
64
bool
hit::NumberOfHitsFilter::beginRun
(
art::Run
&
r
){
65
if
(
fScaleThresholdForReadoutWindow
){
66
unsigned
int
fSize =
art::ServiceHandle<detinfo::DetectorPropertiesService const>
{}->DataForJob().ReadOutWindowSize();
67
fHitLimit
= (
unsigned
int
)(
fHitLimit
*fSize/6000.);
68
std::cout<<
"Scale HitLimit based on readout window size "
<<fSize<<
std::endl
;
69
std::cout<<
"HitLimit = "
<<
fHitLimit
<<
std::endl
;
70
}
71
return
true
;
72
}
73
//-----------------------------------------------------------------------
74
bool
hit::NumberOfHitsFilter::filter
(
art::Event
&
evt
){
75
76
// Get the hit collection from the event
77
auto
allHits = evt.
getValidHandle
<std::vector<recob::Hit> >(
fHitModule
);
78
79
bool
result
=
true
;
80
81
if
(
fLimitPerTPC
){
82
// Find the number of hits per TPC and then filter based on a large value
83
std::map<unsigned int,unsigned int> hitsPerTPC;
84
85
for
(
auto
const
hit
: *allHits){
86
hitsPerTPC[
hit
.WireID().TPC]++;
87
}
88
89
for
(
auto
const
m
: hitsPerTPC){
90
if
(
m
.second >
fHitLimit
){
91
result =
false
;
92
break
;
93
}
94
}
95
}
96
else
{
97
// This is the simplest thing we can do, just cut on the total number of hits
98
if
(allHits->size() >
fHitLimit
){
99
result =
false
;
100
}
101
}
102
103
104
return
result
;
105
}
106
107
void
hit::NumberOfHitsFilter::endJob
() {}
108
109
DEFINE_ART_MODULE
(
hit::NumberOfHitsFilter
)
hit::NumberOfHitsFilter::NumberOfHitsFilter
NumberOfHitsFilter(fhicl::ParameterSet const &pset)
Definition:
NumberOfHitsFilter_module.cc:49
art::ServiceHandle
Definition:
ServiceHandle.h:37
art::EDFilter
Definition:
EDFilter.h:16
result
static QCString result
Definition:
fortranscanner.cpp:56614
hit::NumberOfHitsFilter::~NumberOfHitsFilter
virtual ~NumberOfHitsFilter()
Definition:
NumberOfHitsFilter_module.cc:59
Handle.h
string
std::string string
Definition:
nybbler.cc:12
hit::NumberOfHitsFilter::beginJob
void beginJob() override
Definition:
NumberOfHitsFilter_module.cc:62
DetectorPropertiesService.h
hit::NumberOfHitsFilter::fHitLimit
unsigned int fHitLimit
Definition:
NumberOfHitsFilter_module.cc:43
hit::NumberOfHitsFilter::fHitModule
std::string fHitModule
Definition:
NumberOfHitsFilter_module.cc:44
hit::NumberOfHitsFilter
Definition:
NumberOfHitsFilter_module.cc:29
art::Run
Definition:
Run.h:17
MessageLogger.h
ParameterSet.h
ServiceHandle.h
DEFINE_ART_MODULE
#define DEFINE_ART_MODULE(klass)
Definition:
ModuleMacros.h:67
EDFilter.h
hit::NumberOfHitsFilter::beginRun
bool beginRun(art::Run &r) override
Definition:
NumberOfHitsFilter_module.cc:64
fhicl::ParameterSet::get
T get(std::string const &key) const
Definition:
ParameterSet.h:271
art::DataViewImpl::getValidHandle
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition:
DataViewImpl.h:441
ModuleMacros.h
hit::NumberOfHitsFilter::endJob
void endJob() override
Definition:
NumberOfHitsFilter_module.cc:107
hit
Detector simulation of raw signals on wires.
Definition:
NumberOfHitsFilter_module.cc:25
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
cache_state.m
m
Definition:
cache_state.py:415
Hit.h
Declaration of signal hit object.
art::Event
Definition:
Event.h:22
ActivityRegistry.h
hit::NumberOfHitsFilter::fScaleThresholdForReadoutWindow
bool fScaleThresholdForReadoutWindow
Definition:
NumberOfHitsFilter_module.cc:45
art::EDFilter::EDFilter
EDFilter(fhicl::ParameterSet const &pset)
Definition:
EDFilter.h:21
hit::NumberOfHitsFilter::filter
bool filter(art::Event &evt) override
Definition:
NumberOfHitsFilter_module.cc:74
tca::evt
TCEvent evt
Definition:
DataStructs.cxx:7
Event.h
hit::NumberOfHitsFilter::fLimitPerTPC
bool fLimitPerTPC
Definition:
NumberOfHitsFilter_module.cc:42
Run.h
plot_model.r
r
Definition:
plot_model.py:57
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11