SUSYBSMAnalysis
HSCP
plugins
HSCParticleSelector.cc
Go to the documentation of this file.
1
#include <memory>
2
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
3
#include "
FWCore/Framework/interface/MakerMacros.h
"
4
#include "
FWCore/Framework/interface/EDFilter.h
"
5
6
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
7
#include "
DataFormats/Common/interface/Handle.h
"
8
#include "
DataFormats/Common/interface/View.h
"
9
10
#include "
AnalysisDataFormats/SUSYBSMObjects/interface/HSCParticle.h
"
11
#include "
SUSYBSMAnalysis/HSCP/interface/CandidateSelector.h
"
12
13
//
14
// class declaration
15
//
16
class
HSCParticleSelector
:
public
edm::EDFilter
{
17
public
:
18
explicit
HSCParticleSelector
(
const
edm::ParameterSet
&);
19
~HSCParticleSelector
()
override
;
20
21
private
:
22
void
beginJob
()
override
;
23
bool
filter
(
edm::Event
&,
const
edm::EventSetup
&)
override
;
24
void
endJob
()
override
;
25
26
edm::EDGetTokenT<susybsm::HSCParticleCollection>
sourceToken_
;
27
28
bool
Filter_
;
29
std::vector<CandidateSelector*>
Selectors
;
30
};
31
33
HSCParticleSelector::HSCParticleSelector
(
const
edm::ParameterSet
& iConfig) {
34
// What is being produced
35
produces<susybsm::HSCParticleCollection>();
36
37
// Input products
38
sourceToken_
= consumes<susybsm::HSCParticleCollection>(iConfig.
getParameter
<
edm::InputTag
>(
"source"
));
39
Filter_
= iConfig.
getParameter
<
bool
>(
"filter"
);
40
41
// Load all the selections
42
std::vector<edm::ParameterSet>
SelectionParameters
=
43
iConfig.
getParameter
<std::vector<edm::ParameterSet> >(
"SelectionParameters"
);
44
for
(
unsigned
int
i
= 0;
i
<
SelectionParameters
.size();
i
++) {
45
Selectors
.push_back(
new
CandidateSelector
(
SelectionParameters
[
i
]));
46
}
47
}
48
50
HSCParticleSelector::~HSCParticleSelector
() {}
51
53
void
HSCParticleSelector::beginJob
() {}
54
56
void
HSCParticleSelector::endJob
() {}
57
59
bool
HSCParticleSelector::filter
(
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup) {
60
// Source Collection
61
edm::Handle<susybsm::HSCParticleCollection>
SourceHandle;
62
if
(!
iEvent
.getByToken(
sourceToken_
, SourceHandle)) {
63
edm::LogError
(
""
) <<
">>> HSCParticleCollection does not exist !!!"
;
64
return
false
;
65
}
66
susybsm::HSCParticleCollection
Source
= *SourceHandle.
product
();
67
68
// Output Collection
69
susybsm::HSCParticleCollection
*
output
=
new
susybsm::HSCParticleCollection
;
70
std::unique_ptr<susybsm::HSCParticleCollection>
result
(
output
);
71
72
// cleanup the collection based on the input selection
73
for
(susybsm::HSCParticleCollection::iterator hscpcandidate =
Source
.begin(); hscpcandidate <
Source
.end();
74
++hscpcandidate) {
75
bool
decision =
false
;
76
for
(
unsigned
int
i
= 0;
i
<
Selectors
.size();
i
++) {
77
decision |=
Selectors
[
i
]->isSelected(*hscpcandidate);
78
}
79
if
(decision) {
80
susybsm::HSCParticle
* newhscp =
new
susybsm::HSCParticle
(*hscpcandidate);
81
output
->push_back(*newhscp);
82
}
83
}
84
85
bool
filterResult = !
Filter_
|| (
Filter_
&& !
output
->empty());
86
87
iEvent
.put(
std::move
(
result
));
88
89
return
filterResult;
90
}
91
92
DEFINE_FWK_MODULE
(
HSCParticleSelector
);
susybsm::HSCParticle
Definition:
HSCParticle.h:42
Handle.h
mps_fire.i
i
Definition:
mps_fire.py:428
MessageLogger.h
edm::Handle::product
T const * product() const
Definition:
Handle.h:70
HSCParticleSelector::endJob
void endJob() override
Definition:
HSCParticleSelector.cc:56
convertSQLitetoXML_cfg.output
output
Definition:
convertSQLitetoXML_cfg.py:72
edm::EDGetTokenT< susybsm::HSCParticleCollection >
EDFilter.h
susybsm::HSCParticleCollection
std::vector< HSCParticle > HSCParticleCollection
Definition:
HSCParticle.h:86
edm::Handle
Definition:
AssociativeIterator.h:50
HSCParticleSelector::~HSCParticleSelector
~HSCParticleSelector() override
Definition:
HSCParticleSelector.cc:50
HSCParticleSelector::sourceToken_
edm::EDGetTokenT< susybsm::HSCParticleCollection > sourceToken_
Definition:
HSCParticleSelector.cc:26
HSCParticleSelector
Definition:
HSCParticleSelector.cc:16
MakerMacros.h
HSCParticleSelector::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition:
HSCParticleSelector.cc:59
HSCParticleSelector::HSCParticleSelector
HSCParticleSelector(const edm::ParameterSet &)
Definition:
HSCParticleSelector.cc:33
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
HSCParticle.h
CandidateSelector.h
HSCParticleProducer_cff.SelectionParameters
SelectionParameters
Definition:
HSCParticleProducer_cff.py:89
edm::ParameterSet
Definition:
ParameterSet.h:47
iEvent
int iEvent
Definition:
GenABIO.cc:224
HSCParticleSelector::beginJob
void beginJob() override
Definition:
HSCParticleSelector.cc:53
edm::EDFilter
Definition:
EDFilter.h:38
HSCParticleSelector::Selectors
std::vector< CandidateSelector * > Selectors
Definition:
HSCParticleSelector.cc:29
edm::EventSetup
Definition:
EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition:
MessageLogger.h:123
CandidateSelector
Definition:
CandidateSelector.h:18
eostools.move
def move(src, dest)
Definition:
eostools.py:511
Frameworkfwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
mps_fire.result
result
Definition:
mps_fire.py:311
View.h
HSCParticleSelector::Filter_
bool Filter_
Definition:
HSCParticleSelector.cc:28
edm::Event
Definition:
Event.h:73
edm::InputTag
Definition:
InputTag.h:15
CollectionTags_cfi.Source
Source
Definition:
CollectionTags_cfi.py:11
Generated for CMSSW Reference Manual by
1.8.16