Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
duneana
duneana
ProductFilters
MissingProductFilter_module.cc
Go to the documentation of this file.
1
////////////////////////////////////////////////////////////////////////
2
//
3
// Very simple module to filter events without all of the expected
4
// products in the event.
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
#include "
canvas/Utilities/InputTag.h
"
22
23
#include "
lardataobj/RecoBase/SpacePoint.h
"
24
#include "
lardataobj/RecoBase/Track.h
"
25
#include "
lardataobj/RecoBase/Shower.h
"
26
#include "
lardataobj/RecoBase/PFParticle.h
"
27
#include "
lardataobj/RecoBase/OpFlash.h
"
28
29
namespace
mpf
{
30
class
MissingProductFilter
;
31
}
32
33
class
mpf::MissingProductFilter
:
public
art::EDFilter
{
34
public
:
35
36
explicit
MissingProductFilter
(
fhicl::ParameterSet
const
& pset);
37
virtual
~MissingProductFilter
();
38
39
void
beginJob
()
override
;
40
bool
filter
(
art::Event
&
evt
)
override
;
41
void
endJob
()
override
;
42
43
private
:
44
45
std::vector<std::string>
fModules
;
46
};
47
48
//-----------------------------------------------------------------------
49
mpf::MissingProductFilter::MissingProductFilter
(
fhicl::ParameterSet
const
& pset):
50
EDFilter
(pset)
51
{
52
fModules
= pset.
get
<std::vector<std::string>>(
"Modules"
);
53
}
54
55
//-----------------------------------------------------------------------
56
mpf::MissingProductFilter::~MissingProductFilter
(){}
57
58
//-----------------------------------------------------------------------
59
void
mpf::MissingProductFilter::beginJob
() {}
60
61
//-----------------------------------------------------------------------
62
bool
mpf::MissingProductFilter::filter
(
art::Event
&
evt
){
63
64
bool
prodMissing =
false
;
65
66
// Can we do it all together?
67
for
(
const
std::string
&
s
:
fModules
){
68
69
try
{
70
if
(
s
==
"reco3d"
){
71
evt.
getValidHandle
<std::vector<recob::SpacePoint>>(
s
);
72
}
73
else
if
(
s
==
"pandora"
){
74
evt.
getValidHandle
<std::vector<recob::PFParticle>>(
s
);
75
}
76
else
if
(
s
==
"pandoraTrack"
){
77
evt.
getValidHandle
<std::vector<recob::Track>>(
s
);
78
}
79
else
if
(
s
==
"pandoraShower"
){
80
evt.
getValidHandle
<std::vector<recob::Shower>>(
s
);
81
}
82
else
if
(
s
==
"opflash"
||
s
==
"opflashInternal"
||
s
==
"opflashExternal"
){
83
evt.
getValidHandle
<std::vector<recob::OpFlash>>(
s
);
84
}
85
else
{
86
std::cerr <<
"Product "
<<
s
<<
" is not considered by the module and will be ignored."
<<
std::endl
;
87
}
88
}
89
catch
(...){
90
prodMissing =
true
;
91
std::cout <<
"Product "
<<
s
<<
" is missing. Event will be filtered out."
<<
std::endl
;
92
break
;
93
}
94
95
}
96
97
if
(!prodMissing){
98
std::cout <<
"All products present, keeping this event"
<<
std::endl
;
99
}
100
return
!prodMissing;
101
102
}
103
104
void
mpf::MissingProductFilter::endJob
() {}
105
106
DEFINE_ART_MODULE
(
mpf::MissingProductFilter
)
art::EDFilter
Definition:
EDFilter.h:16
mpf::MissingProductFilter::fModules
std::vector< std::string > fModules
Definition:
MissingProductFilter_module.cc:45
mpf::MissingProductFilter::endJob
void endJob() override
Definition:
MissingProductFilter_module.cc:104
Handle.h
mpf::MissingProductFilter
Definition:
MissingProductFilter_module.cc:33
string
std::string string
Definition:
nybbler.cc:12
mpf::MissingProductFilter::~MissingProductFilter
virtual ~MissingProductFilter()
Definition:
MissingProductFilter_module.cc:56
mpf
Definition:
MissingProductFilter_module.cc:29
MessageLogger.h
ParameterSet.h
ServiceHandle.h
DEFINE_ART_MODULE
#define DEFINE_ART_MODULE(klass)
Definition:
ModuleMacros.h:67
EDFilter.h
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
mpf::MissingProductFilter::filter
bool filter(art::Event &evt) override
Definition:
MissingProductFilter_module.cc:62
ModuleMacros.h
art::Event
Definition:
Event.h:22
SpacePoint.h
OpFlash.h
ActivityRegistry.h
Track.h
Provides recob::Track data product.
art::EDFilter::EDFilter
EDFilter(fhicl::ParameterSet const &pset)
Definition:
EDFilter.h:21
InputTag.h
Shower.h
PFParticle.h
mpf::MissingProductFilter::MissingProductFilter
MissingProductFilter(fhicl::ParameterSet const &pset)
Definition:
MissingProductFilter_module.cc:49
tca::evt
TCEvent evt
Definition:
DataStructs.cxx:7
Event.h
mpf::MissingProductFilter::beginJob
void beginJob() override
Definition:
MissingProductFilter_module.cc:59
Run.h
s
static QCString * s
Definition:
config.cpp:1042
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11