Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
garsoft
Filters
FSPEventFilter_module.cc
Go to the documentation of this file.
1
////////////////////////////////////////////////////////////////////////
2
//
3
// GENIEEventFilter_module class:
4
// Algoritm to produce a filtered event file having events with user-defined
5
// GENIE stauscode==1 (not GEANT!) particles in MCTruth
6
//
7
// eldwan.brianne@desy.de
8
//
9
////////////////////////////////////////////////////////////////////////
10
11
//Framework Includes
12
#include "
art/Framework/Core/EDFilter.h
"
13
#include "
art/Framework/Core/ModuleMacros.h
"
14
#include "
art/Framework/Principal/Event.h
"
15
#include "
art/Framework/Principal/Handle.h
"
16
#include "
canvas/Persistency/Common/Ptr.h
"
17
#include "
art/Framework/Services/Registry/ServiceHandle.h
"
18
#include "
art/Persistency/Common/PtrMaker.h
"
19
#include "
canvas/Utilities/InputTag.h
"
20
#include "
fhiclcpp/ParameterSet.h
"
21
#include "canvas/Persistency/Common/FindOne.h"
22
#include "canvas/Persistency/Common/FindOneP.h"
23
#include "canvas/Persistency/Common/FindMany.h"
24
#include "canvas/Persistency/Common/FindManyP.h"
25
26
//nusim Includes
27
#include "
nusimdata/SimulationBase/GTruth.h
"
28
#include "
nusimdata/SimulationBase/MCTruth.h
"
29
#include "
nusimdata/SimulationBase/MCParticle.h
"
30
31
namespace
gar
{
32
namespace
filt
{
33
34
class
FSPEventFilter
:
public
art::EDFilter
{
35
36
public
:
37
38
explicit
FSPEventFilter
(
fhicl::ParameterSet
const
& );
39
40
// Filters should not be copied or assigned.
41
FSPEventFilter
(
FSPEventFilter
const
&) =
delete
;
42
FSPEventFilter
(
FSPEventFilter
&&) =
delete
;
43
FSPEventFilter
&
operator =
(
FSPEventFilter
const
&) =
delete
;
44
FSPEventFilter
&
operator =
(
FSPEventFilter
&&) =
delete
;
45
46
bool
filter
(
art::Event
&
evt
);
47
void
beginJob
();
48
49
private
:
50
51
std::string
fGeneratorLabel
;
52
std::vector<int>
fPDG
;
53
54
bool
isMatched
(std::vector<int>
const
&
a
, std::vector<int>
const
&
b
)
const
;
55
56
};
// class GENIEEventFilter
57
58
//-------------------------------------------------
59
FSPEventFilter::FSPEventFilter
(
fhicl::ParameterSet
const
& pset)
60
:
EDFilter
{pset}
61
{
62
fGeneratorLabel
= pset.get<
std::string
>(
"GeneratorModuleLabel"
,
"generator"
);
63
fPDG
= pset.get< std::vector<int> >(
"PDG"
);
64
}
65
66
//-------------------------------------------------
67
void
FSPEventFilter::beginJob
()
68
{
69
70
}
71
72
//-------------------------------------------------
73
bool
FSPEventFilter::filter
(
art::Event
&
evt
)
74
{
75
auto
mcthandlelist = evt.
getHandle
< std::vector<simb::MCTruth> >(
fGeneratorLabel
);
76
if
(!mcthandlelist) {
77
throw
cet::exception
(
"FSPEventFilter"
) <<
" No simb::MCTruth branch."
78
<<
" Line "
<< __LINE__ <<
" in file "
<< __FILE__ <<
std::endl
;
79
}
80
81
art::Ptr<simb::MCTruth>
mcp(mcthandlelist, 0);
82
std::vector<int> FSP;
83
84
for
(
int
i = 0; i < mcp->
NParticles
(); ++i){
85
simb::MCParticle
part(mcp->
GetParticle
(i));
86
87
if
(part.StatusCode()== 1)
88
FSP.push_back(part.PdgCode());
89
}
90
91
return
isMatched
(
fPDG
, FSP);
// returns true if the user-defined fPDG exist(s) in the final state particles
92
}
93
94
//------------------------------------------------
95
bool
FSPEventFilter::isMatched
(std::vector<int>
const
&
a
, std::vector<int>
const
&
b
)
const
96
{
97
for
(
auto
const
a_int : a) {
98
for
(
auto
const
b_int : b) {
99
if
(a_int == b_int) {
100
return
true
;
101
}
102
}
103
}
104
return
false
;
105
}
106
107
}
//namespace filt
108
}
//namespace gar
109
110
//--------------------------------------------------
111
namespace
gar
{
112
namespace
filt
{
113
DEFINE_ART_MODULE
(
FSPEventFilter
)
114
}
//namespace gar
115
}
//namespace filt
art::EDFilter
Definition:
EDFilter.h:16
filt
Definition:
NucleonDecayFilter_module.cc:49
Handle.h
art::DataViewImpl::getHandle
Handle< PROD > getHandle(SelectorBase const &) const
Definition:
DataViewImpl.h:382
string
std::string string
Definition:
nybbler.cc:12
gar::filt::FSPEventFilter::operator=
FSPEventFilter & operator=(FSPEventFilter const &)=delete
PtrMaker.h
gar::filt::FSPEventFilter::isMatched
bool isMatched(std::vector< int > const &a, std::vector< int > const &b) const
Definition:
FSPEventFilter_module.cc:95
simb::MCParticle
Definition:
MCParticle.h:24
simb::MCTruth::NParticles
int NParticles() const
Definition:
MCTruth.h:75
MCParticle.h
Particle class.
gar::filt::FSPEventFilter
Definition:
FSPEventFilter_module.cc:34
ParameterSet.h
ServiceHandle.h
gar::filt::FSPEventFilter::beginJob
void beginJob()
Definition:
FSPEventFilter_module.cc:67
DEFINE_ART_MODULE
#define DEFINE_ART_MODULE(klass)
Definition:
ModuleMacros.h:67
EDFilter.h
a
const double a
Definition:
gUpMuFluxGen.cxx:164
Ptr.h
gar::filt::FSPEventFilter::filter
bool filter(art::Event &evt)
Definition:
FSPEventFilter_module.cc:73
ModuleMacros.h
simb::MCTruth::GetParticle
const simb::MCParticle & GetParticle(int i) const
Definition:
MCTruth.h:76
gar
General GArSoft Utilities.
Definition:
anatest_module.cc:57
art::Event
Definition:
Event.h:22
gar::filt::FSPEventFilter::fPDG
std::vector< int > fPDG
Definition:
FSPEventFilter_module.cc:52
GTruth.h
art::EDFilter::EDFilter
EDFilter(fhicl::ParameterSet const &pset)
Definition:
EDFilter.h:21
b
static bool * b
Definition:
config.cpp:1043
InputTag.h
MCTruth.h
gar::filt::FSPEventFilter::FSPEventFilter
FSPEventFilter(fhicl::ParameterSet const &)
Definition:
FSPEventFilter_module.cc:59
tca::evt
TCEvent evt
Definition:
DataStructs.cxx:7
Event.h
art::Ptr< simb::MCTruth >
fhicl::exception
cet::coded_exception< error, detail::translate > exception
Definition:
exception.h:33
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
gar::filt::FSPEventFilter::fGeneratorLabel
std::string fGeneratorLabel
Definition:
FSPEventFilter_module.cc:51
Generated by
1.8.11