CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronMatchedCandidateProducer.cc
Go to the documentation of this file.
4 
5 #include "DataFormats/Math/interface/deltaR.h" // reco::deltaR
6 
7 
9 {
10 
11  const edm::InputTag allelectrons("gsfElectrons");
13  consumes<edm::View<reco::GsfElectron> >(params.getUntrackedParameter<edm::InputTag>("ReferenceElectronCollection",
14  allelectrons));
16  consumes<edm::View<reco::Candidate> >(params.getParameter<edm::InputTag>("src"));
17 
18  delRMatchingCut_ = params.getUntrackedParameter<double>("deltaR",
19  0.30);
20 
21  produces< edm::PtrVector<reco::Candidate> >();
22  produces< edm::RefToBaseVector<reco::Candidate> >();
23 }
24 
25 
26 
27 
29 {
30 
31 }
32 
33 
34 //
35 // member functions
36 //
37 
38 
39 // ------------ method called to produce the data ------------
40 
42  const edm::EventSetup &eventSetup)
43 {
44  // Create the output collection
45  std::auto_ptr< edm::RefToBaseVector<reco::Candidate> >
47  std::auto_ptr< edm::PtrVector<reco::Candidate> >
48  outColPtr( new edm::PtrVector<reco::Candidate> );
49 
50 
51  // Read electrons
53  event.getByToken(electronCollectionToken_, electrons);
54 
55 
56 
57  //Read candidates
59  event.getByToken( scCollectionToken_ , recoCandColl);
60 
61 
62  const edm::PtrVector<reco::Candidate>& ptrVect = recoCandColl->ptrVector();
63  const edm::RefToBaseVector<reco::Candidate>& refs = recoCandColl->refVector();
64  unsigned int counter=0;
65 
66  // Loop over candidates
67  for(edm::View<reco::Candidate>::const_iterator scIt = recoCandColl->begin();
68  scIt != recoCandColl->end(); ++scIt, ++counter){
69  // Now loop over electrons
70  for(edm::View<reco::GsfElectron>::const_iterator elec = electrons->begin();
71  elec != electrons->end(); ++elec) {
72 
73  reco::SuperClusterRef eSC = elec->superCluster();
74 
75  double dRval = reco::deltaR((float)eSC->eta(), (float)eSC->phi(),
76  scIt->eta(), scIt->phi());
77 
78  if( dRval < delRMatchingCut_ ) {
79  //outCol->push_back( *scIt );
80  outColRef->push_back( refs[counter] );
81  outColPtr->push_back( ptrVect[counter] );
82  } // end if loop
83  } // end electron loop
84 
85  } // end candidate loop
86 
87  event.put(outColRef);
88  event.put(outColPtr);
89 }
90 
91 
92 
93 
94 // ------ method called once each job just before starting event loop ---
95 
96 
97 
99 
100 
101 
103 
104 
105 
106 //define this as a plug-in
108 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual void produce(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
edm::EDGetTokenT< edm::View< reco::Candidate > > scCollectionToken_
ElectronMatchedCandidateProducer(const edm::ParameterSet &)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
static std::atomic< unsigned int > counter
edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronCollectionToken_