CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/L1TriggerOffline/L1Analyzer/src/L1Analyzer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    L1Analyzer
00004 // Class:      L1Analyzer
00005 // 
00013 //
00014 // Original Author:  Alex Tapper
00015 //         Created:  Thu Nov 30 20:57:38 CET 2006
00016 // $Id: L1Analyzer.cc,v 1.4 2009/06/17 14:03:51 jbrooke Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 #include "L1TriggerOffline/L1Analyzer/interface/L1Analyzer.h"
00026 
00027 // Data formats 
00028 #include "DataFormats/Candidate/interface/Candidate.h"
00029 #include "DataFormats/Candidate/interface/CandMatchMap.h"
00030 
00031 using namespace reco;
00032 using namespace edm;
00033 using namespace std;
00034 
00035 //
00036 // constructors and destructor
00037 //
00038 
00039 L1Analyzer::L1Analyzer(const edm::ParameterSet& iConfig):
00040   m_candidateSource(iConfig.getUntrackedParameter<edm::InputTag>("CandidateSource")),
00041   m_referenceSource(iConfig.getUntrackedParameter<edm::InputTag>("ReferenceSource")),
00042   m_resMatchMapSource(iConfig.getUntrackedParameter<edm::InputTag>("ResMatchMapSource")),
00043   m_effMatchMapSource(iConfig.getUntrackedParameter<edm::InputTag>("EffMatchMapSource"))
00044 {
00045   m_l1UnMatched  = new SimpleHistograms("L1Candidates",iConfig);
00046   m_refUnMatched = new SimpleHistograms("RefCandidates",iConfig); 
00047   m_l1Matched    = new SimpleHistograms("L1MatchedCandidates",iConfig);
00048   m_refMatched   = new SimpleHistograms("RefMatchedCandidates",iConfig); 
00049   m_resolution   = new ResolutionHistograms("Resolutions",iConfig); 
00050   m_efficiency   = new EfficiencyHistograms("Efficiencies",iConfig); 
00051 }
00052 
00053 L1Analyzer::~L1Analyzer()
00054 {
00055   delete m_l1UnMatched;
00056   delete m_refUnMatched;
00057   delete m_l1Matched;
00058   delete m_refMatched;
00059   delete m_resolution;
00060   delete m_efficiency;
00061 }
00062 
00063 void L1Analyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00064 {
00065 
00066   // Get the L1 candidates from the event
00067   Handle<CandidateCollection> Cands;
00068   iEvent.getByLabel(m_candidateSource,Cands);
00069 
00070   // Get the resolution matching map from the event
00071   Handle<CandMatchMap> ResMatchMap;
00072   iEvent.getByLabel(m_resMatchMapSource,ResMatchMap);
00073 
00074   // Loop over the L1 candidates looking for a match
00075   for (unsigned i=0; i<Cands->size(); i++){
00076     CandidateRef CandRef(Cands,i);
00077 
00078     // Fill unmatched histogram
00079     m_l1UnMatched->Fill(CandRef);
00080 
00081     // Loop over match map
00082     CandMatchMap::const_iterator f = ResMatchMap->find(CandRef);
00083     if (f!=ResMatchMap->end()){
00084       const CandidateRef &CandMatch = f->val;
00085 
00086       // Fill the histograms
00087       m_l1Matched->Fill(CandRef);
00088       m_refMatched->Fill(CandMatch);
00089       m_resolution->Fill(CandRef,CandMatch);
00090     }
00091   }   
00092 
00093   // Get the reference collection (either MC truth or RECO) from the event
00094   Handle<CandidateCollection> Refs;
00095   iEvent.getByLabel(m_referenceSource,Refs);
00096 
00097   // Get the efficiency matching map from the event
00098   Handle<CandMatchMap> EffMatchMap;
00099   iEvent.getByLabel(m_effMatchMapSource,EffMatchMap);
00100 
00101   // Loop over the reference collection looking for a match
00102   for (unsigned i=0; i<Refs->size(); i++){
00103     CandidateRef CandRef(Refs,i);
00104 
00105     // Fill the unmatched histograms
00106     m_refUnMatched->Fill(CandRef);
00107 
00108     // Fill the efficiency histograms
00109     m_efficiency->FillReference(CandRef);
00110 
00111     // See if this reference candidate was matched 
00112     CandMatchMap::const_iterator f = EffMatchMap->find(CandRef);
00113     if (f!=EffMatchMap->end()){
00114       // Fill the efficiency histograms
00115       m_efficiency->FillL1(CandRef);
00116     }
00117   }   
00118 
00119 }
00120 
00121 
00122 DEFINE_FWK_MODULE(L1Analyzer);
00123 
00124 
00125