CMS 3D CMS Logo

BoostedJetMerger.cc
Go to the documentation of this file.
2 
3 
5  jetToken_(consumes<edm::View<pat::Jet> >( iConfig.getParameter<edm::InputTag>("jetSrc") )),
6  subjetToken_(consumes<edm::View<pat::Jet> >( iConfig.getParameter<edm::InputTag>("subjetSrc") ))
7 {
8  //register products
9  produces<std::vector<pat::Jet> > ();
10  produces<std::vector<pat::Jet> > ("SubJets");
11 }
12 
13 
15 {
16 }
17 
18 
19 // ------------ method called to produce the data ------------
20 void
22 {
23 
24  auto outputs = std::make_unique<std::vector<pat::Jet>>();
25  auto outputSubjets = std::make_unique<std::vector<pat::Jet>>();
26 
27  edm::RefProd< std::vector<pat::Jet> > h_subJetsOut = iEvent.getRefBeforePut< std::vector<pat::Jet> >( "SubJets" );
28 
30  edm::Handle< edm::View<pat::Jet> > subjetHandle;
31 
32  iEvent.getByToken( jetToken_, jetHandle );
33  iEvent.getByToken( subjetToken_, subjetHandle );
34 
35  for ( edm::View<pat::Jet>::const_iterator ijetBegin = jetHandle->begin(),
36  ijetEnd = jetHandle->end(), ijet = ijetBegin; ijet != ijetEnd; ++ijet ) {
37 
38  outputs->push_back( *ijet );
39  std::vector< edm::Ptr<reco::Candidate> > nextSubjets;
40 
41  for ( unsigned int isubjet = 0; isubjet < ijet->numberOfDaughters(); ++isubjet ) {
42  edm::Ptr<reco::Candidate> const & subjet = ijet->daughterPtr(isubjet);
43  edm::View<pat::Jet>::const_iterator ifound = find_if( subjetHandle->begin(),
44  subjetHandle->end(),
45  FindCorrectedSubjet(subjet) );
46  if ( ifound != subjetHandle->end() ) {
47 
48  outputSubjets->push_back( *ifound );
49 
50  edm::Ref<std::vector<pat::Jet> > subjetRef ( h_subJetsOut, outputSubjets->size() - 1);
51  edm::Ptr< pat::Jet > subjetPtr ( h_subJetsOut.id(), subjetRef.key(), h_subJetsOut.productGetter() );
52  nextSubjets.push_back( subjetPtr );
53  }
54  }
55  outputs->back().clearDaughters();
56  for ( std::vector< edm::Ptr<reco::Candidate> >::const_iterator nextSubjet = nextSubjets.begin(),
57  nextSubjetEnd = nextSubjets.end(); nextSubjet != nextSubjetEnd; ++nextSubjet ) {
58  outputs->back().addDaughter( *nextSubjet );
59  }
60 
61 
62  }
63 
64 
65  iEvent.put(std::move(outputs));
66  iEvent.put(std::move(outputSubjets), "SubJets");
67 
68 }
69 
70 //define this as a plug-in
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Definition: HeavyIon.h:7
int iEvent
Definition: GenABIO.cc:230
BoostedJetMerger(const edm::ParameterSet &)
Definition: Jet.py:1
edm::EDGetTokenT< edm::View< pat::Jet > > jetToken_
RefProd< PROD > getRefBeforePut()
Definition: Event.h:147
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::EDGetTokenT< edm::View< pat::Jet > > subjetToken_
virtual void produce(edm::Event &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:510