CMS 3D CMS Logo

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