CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1Analyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Analyzer
4 // Class: L1Analyzer
5 //
13 //
14 // Original Author: Alex Tapper
15 // Created: Thu Nov 30 20:57:38 CET 2006
16 // $Id: L1Analyzer.cc,v 1.3 2007/11/13 21:11:35 tapper Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
26 
27 // Data formats
30 
31 using namespace reco;
32 using namespace edm;
33 using namespace std;
34 
35 //
36 // constructors and destructor
37 //
38 
40  m_candidateSource(iConfig.getUntrackedParameter<edm::InputTag>("CandidateSource")),
41  m_referenceSource(iConfig.getUntrackedParameter<edm::InputTag>("ReferenceSource")),
42  m_resMatchMapSource(iConfig.getUntrackedParameter<edm::InputTag>("ResMatchMapSource")),
43  m_effMatchMapSource(iConfig.getUntrackedParameter<edm::InputTag>("EffMatchMapSource"))
44 {
45  m_l1UnMatched = new SimpleHistograms("L1Candidates",iConfig);
46  m_refUnMatched = new SimpleHistograms("RefCandidates",iConfig);
47  m_l1Matched = new SimpleHistograms("L1MatchedCandidates",iConfig);
48  m_refMatched = new SimpleHistograms("RefMatchedCandidates",iConfig);
49  m_resolution = new ResolutionHistograms("Resolutions",iConfig);
50  m_efficiency = new EfficiencyHistograms("Efficiencies",iConfig);
51 }
52 
54 {
55  delete m_l1UnMatched;
56  delete m_refUnMatched;
57  delete m_l1Matched;
58  delete m_refMatched;
59  delete m_resolution;
60  delete m_efficiency;
61 }
62 
64 {
65 
66  // Get the L1 candidates from the event
68  iEvent.getByLabel(m_candidateSource,Cands);
69 
70  // Get the resolution matching map from the event
71  Handle<CandMatchMap> ResMatchMap;
72  iEvent.getByLabel(m_resMatchMapSource,ResMatchMap);
73 
74  // Loop over the L1 candidates looking for a match
75  for (unsigned i=0; i<Cands->size(); i++){
76  CandidateRef CandRef(Cands,i);
77 
78  // Fill unmatched histogram
79  m_l1UnMatched->Fill(CandRef);
80 
81  // Loop over match map
82  CandMatchMap::const_iterator f = ResMatchMap->find(CandRef);
83  if (f!=ResMatchMap->end()){
84  const CandidateRef &CandMatch = f->val;
85 
86  // Fill the histograms
87  m_l1Matched->Fill(CandRef);
88  m_refMatched->Fill(CandMatch);
89  m_resolution->Fill(CandRef,CandMatch);
90  }
91  }
92 
93  // Get the reference collection (either MC truth or RECO) from the event
95  iEvent.getByLabel(m_referenceSource,Refs);
96 
97  // Get the efficiency matching map from the event
98  Handle<CandMatchMap> EffMatchMap;
99  iEvent.getByLabel(m_effMatchMapSource,EffMatchMap);
100 
101  // Loop over the reference collection looking for a match
102  for (unsigned i=0; i<Refs->size(); i++){
103  CandidateRef CandRef(Refs,i);
104 
105  // Fill the unmatched histograms
106  m_refUnMatched->Fill(CandRef);
107 
108  // Fill the efficiency histograms
109  m_efficiency->FillReference(CandRef);
110 
111  // See if this reference candidate was matched
112  CandMatchMap::const_iterator f = EffMatchMap->find(CandRef);
113  if (f!=EffMatchMap->end()){
114  // Fill the efficiency histograms
115  m_efficiency->FillL1(CandRef);
116  }
117  }
118 
119 }
120 
121 
123 
124 
125 
edm::InputTag m_referenceSource
Definition: L1Analyzer.h:54
int i
Definition: DBlmapReader.cc:9
edm::InputTag m_resMatchMapSource
Definition: L1Analyzer.h:55
void FillL1(const reco::CandidateRef &l1)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: L1Analyzer.cc:63
SimpleHistograms * m_l1UnMatched
Definition: L1Analyzer.h:61
SimpleHistograms * m_refUnMatched
Definition: L1Analyzer.h:61
void Fill(const reco::CandidateRef cand)
int iEvent
Definition: GenABIO.cc:243
SimpleHistograms * m_l1Matched
Definition: L1Analyzer.h:60
EfficiencyHistograms * m_efficiency
Definition: L1Analyzer.h:63
void Fill(const reco::CandidateRef &l1, const reco::CandidateRef &ref)
double f[11][100]
ResolutionHistograms * m_resolution
Definition: L1Analyzer.h:62
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
edm::InputTag m_effMatchMapSource
Definition: L1Analyzer.h:56
void FillReference(const reco::CandidateRef &ref)
SimpleHistograms * m_refMatched
Definition: L1Analyzer.h:60
L1Analyzer(const edm::ParameterSet &)
Definition: L1Analyzer.cc:39
edm::InputTag m_candidateSource
Definition: L1Analyzer.h:53