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.
5 
6 #include "DataFormats/Math/interface/deltaR.h" // reco::deltaR
7 
8 
10 {
11 
12  const edm::InputTag allelectrons("gsfElectrons");
14  params.getUntrackedParameter<edm::InputTag>("ReferenceElectronCollection",
15  allelectrons);
16  scCollection_ =
17  params.getParameter<edm::InputTag>("src");
18 
19  delRMatchingCut_ = params.getUntrackedParameter<double>("deltaR",
20  0.30);
21 
22  produces< edm::PtrVector<reco::Candidate> >();
23  produces< edm::RefToBaseVector<reco::Candidate> >();
24 }
25 
26 
27 
28 
30 {
31 
32 }
33 
34 
35 //
36 // member functions
37 //
38 
39 
40 // ------------ method called to produce the data ------------
41 
43  const edm::EventSetup &eventSetup)
44 {
45  // Create the output collection
46  std::auto_ptr< edm::RefToBaseVector<reco::Candidate> >
48  std::auto_ptr< edm::PtrVector<reco::Candidate> >
49  outColPtr( new edm::PtrVector<reco::Candidate> );
50 
51 
52  // Read electrons
54  event.getByLabel(electronCollection_, electrons);
55 
56 
57 
58  //Read candidates
60  event.getByLabel( scCollection_ , recoCandColl);
61 
62 
63  const edm::PtrVector<reco::Candidate>& ptrVect = recoCandColl->ptrVector();
64  const edm::RefToBaseVector<reco::Candidate>& refs = recoCandColl->refVector();
65  unsigned int counter=0;
66 
67  // Loop over candidates
68  for(edm::View<reco::Candidate>::const_iterator scIt = recoCandColl->begin();
69  scIt != recoCandColl->end(); ++scIt, ++counter){
70  // Now loop over electrons
71  for(edm::View<reco::GsfElectron>::const_iterator elec = electrons->begin();
72  elec != electrons->end(); ++elec) {
73 
74  reco::SuperClusterRef eSC = elec->superCluster();
75 
76  double dRval = reco::deltaR((float)eSC->eta(), (float)eSC->phi(),
77  scIt->eta(), scIt->phi());
78 
79  if( dRval < delRMatchingCut_ ) {
80  //outCol->push_back( *scIt );
81  outColRef->push_back( refs[counter] );
82  outColPtr->push_back( ptrVect[counter] );
83  } // end if loop
84  } // end electron loop
85 
86  } // end candidate loop
87 
88  event.put(outColRef);
89  event.put(outColPtr);
90 }
91 
92 
93 
94 
95 // ------ method called once each job just before starting event loop ---
96 
97 
98 
100 
101 
102 
104 
105 
106 
107 //define this as a plug-in
109 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double deltaR(double eta1, double phi1, double eta2, double phi2)
Definition: deltaR.h:19
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
ElectronMatchedCandidateProducer(const edm::ParameterSet &)
virtual void produce(edm::Event &, const edm::EventSetup &)