CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 }
11 
12 
14 {
15 }
16 
17 
18 // ------------ method called to produce the data ------------
19 void
21 {
22 
23  std::auto_ptr< std::vector<pat::Jet> > outputs( new std::vector<pat::Jet> );
24 
26  edm::Handle< edm::View<pat::Jet> > subjetHandle;
27 
28  iEvent.getByToken( jetToken_, jetHandle );
29  iEvent.getByToken( subjetToken_, subjetHandle );
30 
31  for ( edm::View<pat::Jet>::const_iterator ijetBegin = jetHandle->begin(),
32  ijetEnd = jetHandle->end(), ijet = ijetBegin; ijet != ijetEnd; ++ijet ) {
33 
34  outputs->push_back( *ijet );
35  std::vector< edm::Ptr<reco::Candidate> > nextSubjets;
36 
37  for ( unsigned int isubjet = 0; isubjet < ijet->numberOfDaughters(); ++isubjet ) {
38  edm::Ptr<reco::Candidate> const & subjet = ijet->daughterPtr(isubjet);
39  edm::View<pat::Jet>::const_iterator ifound = find_if( subjetHandle->begin(),
40  subjetHandle->end(),
41  FindCorrectedSubjet(subjet) );
42  if ( ifound != subjetHandle->end() ) {
43  nextSubjets.push_back( subjetHandle->ptrAt( ifound - subjetHandle->begin() ) );
44 
45  }
46  }
47  outputs->back().clearDaughters();
48  for ( std::vector< edm::Ptr<reco::Candidate> >::const_iterator nextSubjet = nextSubjets.begin(),
49  nextSubjetEnd = nextSubjets.end(); nextSubjet != nextSubjetEnd; ++nextSubjet ) {
50  outputs->back().addDaughter( *nextSubjet );
51  }
52 
53 
54  }
55 
56  iEvent.put(outputs);
57 
58 }
59 
60 //define this as a plug-in
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int iEvent
Definition: GenABIO.cc:230
BoostedJetMerger(const edm::ParameterSet &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
edm::EDGetTokenT< edm::View< pat::Jet > > jetToken_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
edm::EDGetTokenT< edm::View< pat::Jet > > subjetToken_
virtual void produce(edm::Event &, const edm::EventSetup &) override