CMS 3D CMS Logo

JetCollectionReducer.cc
Go to the documentation of this file.
6 
12 
13 template <typename T>
15 public:
16  explicit JetCollectionReducerT(const edm::ParameterSet& iConfig);
17  ~JetCollectionReducerT() override {}
18 
19  void produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
20 
21 private:
24  std::vector<edm::EDGetTokenT<edm::View<reco::Candidate>>> collections_;
25 };
26 
27 template <typename T>
29  : jetColToken_(consumes<std::vector<T>>(iConfig.getParameter<edm::InputTag>("jetCollection"))),
30  writeEmptyCollection_(iConfig.getParameter<bool>("writeEmptyCollection")) {
31  std::vector<edm::InputTag> filtersDecTags = iConfig.getParameter<std::vector<edm::InputTag>>("triggeringCollections");
32  for (std::vector<edm::InputTag>::const_iterator inputTag = filtersDecTags.begin(); inputTag != filtersDecTags.end();
33  ++inputTag) {
35  }
36 
37  produces<std::vector<T>>();
38 }
39 
40 // ------------ method called to produce the data ------------
41 template <typename T>
43  std::unique_ptr<std::vector<T>> outJets(new std::vector<T>());
44 
45  bool filterDecision = false;
47  for (std::vector<edm::EDGetTokenT<edm::View<reco::Candidate>>>::const_iterator filter = collections_.begin();
48  filter != collections_.end();
49  filter++) {
50  iEvent.getByToken(*filter, tmpCol);
51  if (!tmpCol->empty()) {
52  filterDecision = true;
53  break;
54  }
55  }
56 
57  if (!filterDecision) {
58  if (writeEmptyCollection_)
59  iEvent.put(std::move(outJets));
60  return;
61  }
62 
63  edm::Handle<std::vector<T>> jetColHandle;
64  iEvent.getByToken(jetColToken_, jetColHandle);
65 
66  //MM: probably a better way to do it...
67  for (size_t ij = 0; ij < jetColHandle->size(); ij++) {
68  outJets->push_back((*jetColHandle)[ij]);
69  }
70 
71  iEvent.put(std::move(outJets));
72 }
73 
74 //define this as a plug-in
edm::StreamID
Definition: StreamID.h:30
electrons_cff.bool
bool
Definition: electrons_cff.py:372
JetCollectionReducerT::jetColToken_
edm::EDGetTokenT< std::vector< T > > jetColToken_
Definition: JetCollectionReducer.cc:22
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
JetCollectionReducerT::JetCollectionReducerT
JetCollectionReducerT(const edm::ParameterSet &iConfig)
Definition: JetCollectionReducer.cc:28
PFJet.h
PFJetCollectionReducer
JetCollectionReducerT< reco::PFJet > PFJetCollectionReducer
Definition: JetCollectionReducer.cc:76
edm::Handle
Definition: AssociativeIterator.h:50
CandidateFwd.h
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
JetCollectionReducerT::collections_
std::vector< edm::EDGetTokenT< edm::View< reco::Candidate > > > collections_
Definition: JetCollectionReducer.cc:24
JetCollectionReducerT::writeEmptyCollection_
bool writeEmptyCollection_
Definition: JetCollectionReducer.cc:23
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
JetCollectionReducerT
Definition: JetCollectionReducer.cc:14
edm::global::EDProducer
Definition: EDProducer.h:32
JetCollectionReducerT::produce
void produce(edm::StreamID id, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
Definition: JetCollectionReducer.cc:42
edm::View
Definition: CaloClusterFwd.h:14
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
JetCollectionReducerT::~JetCollectionReducerT
~JetCollectionReducerT() override
Definition: JetCollectionReducer.cc:17
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
Jet.h
InputTag.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
T
long double T
Definition: Basic3DVectorLD.h:48
Candidate.h
PATJetCollectionReducer
JetCollectionReducerT< pat::Jet > PATJetCollectionReducer
Definition: JetCollectionReducer.cc:75
View.h
ParameterSet.h
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:126
EDProducer.h
SimL1EmulatorRepack_Full_cff.inputTag
inputTag
Definition: SimL1EmulatorRepack_Full_cff.py:56
edm::Event
Definition: Event.h:73