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  unsigned int counter=0;
63 
64  // Loop over candidates
65  for(edm::View<reco::Candidate>::const_iterator scIt = recoCandColl->begin();
66  scIt != recoCandColl->end(); ++scIt, ++counter){
67  // Now loop over electrons
68  for(edm::View<reco::GsfElectron>::const_iterator elec = electrons->begin();
69  elec != electrons->end(); ++elec) {
70 
71  reco::SuperClusterRef eSC = elec->superCluster();
72 
73  double dRval = reco::deltaR((float)eSC->eta(), (float)eSC->phi(),
74  scIt->eta(), scIt->phi());
75 
76  if( dRval < delRMatchingCut_ ) {
77  //outCol->push_back( *scIt );
78  outColRef->push_back( recoCandColl->refAt(counter) );
79  outColPtr->push_back( recoCandColl->ptrAt(counter) );
80  } // end if loop
81  } // end electron loop
82 
83  } // end candidate loop
84 
85  event.put(outColRef);
86  event.put(outColPtr);
87 }
88 
89 
90 
91 
92 // ------ method called once each job just before starting event loop ---
93 
94 
95 
97 
98 
99 
101 
102 
103 
104 //define this as a plug-in
106 
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
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
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:85
static std::atomic< unsigned int > counter
edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronCollectionToken_