CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQMOffline/Trigger/interface/FourVectorHLTOffline.h

Go to the documentation of this file.
00001 #ifndef FOURVECTORHLTOFFLINE_H
00002 #define FOURVECTORHLTOFFLINE_H
00003 // -*- C++ -*-
00004 //
00005 // Package:    FourVectorHLTOffline
00006 // Class:      FourVectorHLTOffline
00007 // 
00016 //
00017 // Original Author:  Jeffrey Berryhill
00018 //         Created:  June 2008
00019 // Rewritten by: Vladimir Rekovic
00020 //         Date:  May 2009
00021 //
00022 // $Id: FourVectorHLTOffline.h,v 1.67 2011/06/20 10:11:54 bjk Exp $
00023 //
00024 //
00025 // system include files
00026 #include <memory>
00027 #include <unistd.h>
00028 
00029 
00030 // user include files
00031 #include "FWCore/Framework/interface/Frameworkfwd.h"
00032 #include "FWCore/Framework/interface/EDAnalyzer.h"
00033 
00034 #include "FWCore/Framework/interface/Event.h"
00035 #include "FWCore/Framework/interface/MakerMacros.h"
00036 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
00037 #include "DataFormats/Common/interface/TriggerResults.h"
00038 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
00039 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00040 
00041 #include "DQMServices/Core/interface/DQMStore.h"
00042 #include "DQMServices/Core/interface/MonitorElement.h"
00043 #include "FWCore/ServiceRegistry/interface/Service.h"
00044 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00045 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00046 
00047 // added VR
00048 #include "FWCore/Framework/interface/EDAnalyzer.h"
00049 #include "DataFormats/Common/interface/Handle.h"
00050 #include "FWCore/Framework/interface/Run.h"
00051 #include "FWCore/Framework/interface/MakerMacros.h"
00052 #include "FWCore/Framework/interface/ESHandle.h"
00053 
00054 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00055 
00056 #include "DataFormats/HLTReco/interface/TriggerObject.h"
00057 #include "DataFormats/Common/interface/TriggerResults.h"
00058 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
00059 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
00060 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
00061 
00062 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00063 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
00064 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00065 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00066 #include "DataFormats/TrackReco/interface/Track.h"
00067 #include "DataFormats/TrackReco/interface/TrackExtra.h"
00068 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00069 #include "DataFormats/MuonReco/interface/Muon.h"
00070 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00071 #include "DataFormats/JetReco/interface/CaloJet.h"
00072 #include "DataFormats/TauReco/interface/CaloTauFwd.h"
00073 #include "DataFormats/TauReco/interface/CaloTau.h"
00074 #include "DataFormats/METReco/interface/CaloMETCollection.h"
00075 #include "DataFormats/METReco/interface/CaloMET.h"
00076 #include "DataFormats/BTauReco/interface/JetTag.h"
00077 #include "DataFormats/MuonReco/interface/MuonSelectors.h"
00078 #include "RecoJets/JetProducers/interface/JetIDHelper.h"
00079 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
00080 
00081 #include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
00082 #include "DataFormats/JetReco/interface/JetFloatAssociation.h"
00083 
00084 #include "DataFormats/TauReco/interface/PFTau.h"
00085 #include "DataFormats/TauReco/interface/PFTauFwd.h"
00086 #include "DataFormats/TauReco/interface/PFTauDiscriminator.h"
00087 
00088 /* MC
00089 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00090 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
00091 #include "DataFormats/JetReco/interface/GenJetCollection.h"
00092 #include "DataFormats/METReco/interface/GenMETCollection.h"
00093 #include "DataFormats/METReco/interface/GenMET.h"
00094 */
00095 #include "DataFormats/Math/interface/deltaR.h"
00096 #include  "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
00097 
00098 #include "DQMServices/Core/interface/MonitorElement.h"
00099 
00100 
00101 
00102 #include <iostream>
00103 #include <fstream>
00104 #include <vector>
00105 
00106 namespace edm {
00107    class TriggerNames;
00108 }
00109 
00110 typedef std::multimap<float,int> fimmap ;
00111 typedef std::set<fimmap , std::less<fimmap> > mmset;
00112 
00113 class FourVectorHLTOffline : public edm::EDAnalyzer {
00114 
00115    public:
00116       explicit FourVectorHLTOffline(const edm::ParameterSet&);
00117       ~FourVectorHLTOffline();
00118 
00119       void cleanDRMatchSet(mmset& tempSet);
00120 
00121       edm::Handle<trigger::TriggerEvent> fTriggerObj;
00122       edm::Handle<edm::TriggerResults> fTriggerResults;
00123       edm::Handle<reco::BeamSpot> fBeamSpotHandle;
00124 
00125    private:
00126       virtual void beginJob() ;
00127       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00128       virtual void endJob() ;
00129 
00130       // BeginRun
00131       void beginRun(const edm::Run& run, const edm::EventSetup& c);
00132 
00133       // EndRun
00134       void endRun(const edm::Run& run, const edm::EventSetup& c);
00135       void fillHltMatrix(const edm::TriggerNames & triggerNames);
00136       void setupHltMatrix(const std::string& label, std::vector<std::string> &  paths);
00137 
00138       void setupHltLsPlots();
00139       void setupHltBxPlots();
00140       void countHLTPathHitsEndLumiBlock(const int & lumi);
00141       void countHLTGroupHitsEndLumiBlock(const int & lumi);
00142       void countHLTGroupL1HitsEndLumiBlock(const int & lumi);
00143       void countHLTGroupBXHitsEndLumiBlock(const int & lumi);
00144       int getTriggerTypeParsePathName(const std::string & pathname);
00145       const std::string getL1ConditionModuleName(const std::string & pathname);
00146       bool hasL1Passed(const std::string & pathname, const edm::TriggerNames & triggerNames);
00147       bool hasHLTPassed(const std::string & pathname, const edm::TriggerNames& triggerNames);
00148       int getHltThresholdFromName(const std::string & pathname);
00149 
00150       void selectMuons(const edm::Handle<reco::MuonCollection> & muonHandle);
00151       bool isVBTFMuon(const reco::Muon& muon);
00152       void selectElectrons(const edm::Event& iEvent, const edm::EventSetup& iSetup, const edm::Handle<reco::GsfElectronCollection> & eleHandle);
00153       void selectPhotons(const edm::Handle<reco::PhotonCollection> & phoHandle);
00154       void selectJets(const edm::Event& iEvent,const edm::Handle<reco::CaloJetCollection> & jetHandle);
00155       void selectMet(const edm::Handle<reco::CaloMETCollection> & metHandle);
00156       void selectTaus(const edm::Event& iEvent);
00157       void beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c);   
00158       void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c);   
00159       std::string removeVersions(std::string histVersion);
00160 
00161 
00162       // ----------member data --------------------------- 
00163       int nev_;
00164       DQMStore * dbe_;
00165       bool fLumiFlag;
00166       bool fIsSetup;
00167 
00168       bool useUM;
00169 
00170       // JetID helper
00171       reco::helper::JetIDHelper *jetID;
00172 
00173       // Tau discriminators
00174       std::string tauDscrmtrLabel1_;
00175       std::string tauDscrmtrLabel2_;
00176       std::string tauDscrmtrLabel3_;
00177 
00178       MonitorElement* ME_HLTAll_LS;
00179       MonitorElement* ME_HLT_BX;
00180       MonitorElement* ME_HLT_CUSTOM_BX;
00181       std::vector<MonitorElement*> v_ME_HLTAll_LS;
00182       std::vector<MonitorElement*> v_ME_Total_BX;
00183       std::vector<MonitorElement*> v_ME_Total_BX_Norm;
00184 
00185       std::string pathsSummaryFolder_;
00186       std::string pathsSummaryHLTCorrelationsFolder_;
00187       std::string pathsSummaryFilterEfficiencyFolder_;
00188       std::string pathsSummaryFilterCountsFolder_;
00189       std::string pathsSummaryHLTPathsPerLSFolder_;
00190       std::string pathsIndividualHLTPathsPerLSFolder_;
00191       std::string pathsSummaryHLTPathsPerBXFolder_;
00192       std::string fCustomBXPath;
00193 
00194       std::vector<std::string> fGroupName;
00195 
00196       reco::MuonCollection * fSelectedMuons;
00197       edm::Handle<reco::MuonCollection> fSelMuonsHandle;
00198 
00199       reco::GsfElectronCollection * fSelectedElectrons;
00200       edm::Handle<reco::GsfElectronCollection> fSelElectronsHandle;
00201 
00202       reco::PhotonCollection * fSelectedPhotons;
00203       edm::Handle<reco::PhotonCollection> fSelPhotonsHandle;
00204 
00205       reco::CaloJetCollection * fSelectedJets;
00206       edm::Handle<reco::CaloJetCollection> fSelJetsHandle;
00207 
00208       reco::CaloMETCollection * fSelectedMet;
00209       edm::Handle<reco::CaloMETCollection> fSelMetHandle;
00210 
00211       //reco::CaloTauCollection * fSelectedTaus;
00212       //edm::Handle<reco::CaloTauCollection> fSelTausHandle;
00213       reco::PFTauCollection * fSelectedTaus;
00214       edm::Handle<reco::PFTauCollection> fSelTausHandle;
00215 
00216       unsigned int nLS_; 
00217       double LSsize_ ;
00218       double thresholdFactor_ ;
00219       unsigned int referenceBX_; 
00220       unsigned int Nbx_; 
00221 
00222       bool plotAll_;
00223       bool doCombineRuns_;
00224       int currentRun_;
00225       
00226       unsigned int nBins_; 
00227       unsigned int nBinsDR_; 
00228       unsigned int nBins2D_; 
00229       unsigned int nBinsOneOverEt_; 
00230       double ptMin_ ;
00231       double ptMax_ ;
00232       double dRMax_ ;
00233       
00234       double electronEtaMax_;
00235       double electronEtMin_;
00236       double electronDRMatch_;
00237       double electronL1DRMatch_;
00238       double muonEtaMax_;
00239       double muonEtMin_;
00240       double muonDRMatch_;
00241       double muonL1DRMatch_;
00242       double tauEtaMax_;
00243       double tauEtMin_;
00244       double tauDRMatch_;
00245       double tauL1DRMatch_;
00246       double jetEtaMax_;
00247       double jetEtMin_;
00248       double jetDRMatch_;
00249       double jetL1DRMatch_;
00250       double bjetEtaMax_;
00251       double bjetEtMin_;
00252       double bjetDRMatch_;
00253       double bjetL1DRMatch_;
00254       double photonEtaMax_;
00255       double photonEtMin_;
00256       double photonDRMatch_;
00257       double photonL1DRMatch_;
00258       double trackEtaMax_;
00259       double trackEtMin_;
00260       double trackDRMatch_;
00261       double trackL1DRMatch_;
00262       double metEtaMax_;
00263       double metMin_;
00264       double metDRMatch_;
00265       double metL1DRMatch_;
00266       double htEtaMax_;
00267       double htMin_;
00268       double htDRMatch_;
00269       double htL1DRMatch_;
00270       double sumEtMin_;
00271 
00272       // Muon quality cuts
00274       double dxyCut_;
00275       double normalizedChi2Cut_;
00276       int trackerHitsCut_;
00277       int pixelHitsCut_;
00278       int muonHitsCut_;
00279       bool isAlsoTrackerMuon_;
00280       int nMatchesCut_;
00281 
00282       // Electron quality cuts
00284       float eleMaxOver3x3_;
00285       // Ecal Barrel
00286       float dr03TkSumPtEB_;
00287       float dr04EcalRecHitSumEtEB_;
00288       float dr04HcalTowerSumEtEB_;
00289       float hadronicOverEmEB_;
00290       float deltaPhiSuperClusterTrackAtVtxEB_;
00291       float deltaEtaSuperClusterTrackAtVtxEB_;
00292       float sigmaIetaIetaEB_;
00293       //spikes
00294       float sigmaIetaIetaSpikesEB_;
00295       // Ecal Endcap
00296       float dr03TkSumPtEC_;
00297       float dr04EcalRecHitSumEtEC_;
00298       float dr04HcalTowerSumEtEC_;
00299       float hadronicOverEmEC_;
00300       float deltaPhiSuperClusterTrackAtVtxEC_;
00301       float deltaEtaSuperClusterTrackAtVtxEC_;
00302       float sigmaIetaIetaEC_;
00303       //spikes
00304       float sigmaIetaIetaSpikesEC_;
00305 
00306       // Jet quality cuts
00308       float emEnergyFractionJet_;
00309       float fHPDJet_;
00310       int n90Jet_;
00311 
00312       std::vector<std::pair<std::string, std::string> > custompathnamepairs_;
00313 
00314       std::vector <std::vector <std::string> > triggerFilters_;
00315       std::vector <std::vector <uint> > triggerFilterIndices_;
00316       std::vector <std::pair<std::string, float> > fPathTempCountPair;
00317       std::vector <std::pair<std::string, std::vector<int> > > fPathBxTempCountPair;
00318       std::vector <std::pair<std::string, float> > fGroupTempCountPair;
00319       std::vector <std::pair<std::string, float> > fGroupL1TempCountPair;
00320       std::vector <std::pair<std::string, std::vector<std::string> > > fGroupNamePathsPair;
00321 
00322       std::vector<std::string> specialPaths_;
00323 
00324       std::string dirname_;
00325       std::string processname_;
00326       std::string muonRecoCollectionName_;
00327       bool monitorDaemon_;
00328       int theHLTOutputType;
00329       edm::InputTag triggerSummaryLabel_;
00330       edm::InputTag triggerResultsLabel_;
00331       edm::InputTag recHitsEBTag_, recHitsEETag_;
00332       HLTConfigProvider hltConfig_;
00333       // data across paths
00334       MonitorElement* scalersSelect;
00335       // helper class to store the data path
00336 
00337       class PathInfo {
00338 
00339        PathInfo():
00340         pathIndex_(-1), denomPathName_("unset"), pathName_("unset"), l1pathName_("unset"), filterName_("unset"), processName_("unset"), objectType_(-1) {};
00341 
00342        public:
00343 
00344           void setFilterHistos(MonitorElement* const filters) 
00345           {
00346               filters_   =  filters;
00347           }
00348 
00349           void setHistos(
00350 
00351             MonitorElement* const NOn, 
00352             MonitorElement* const onEtOn, 
00353             MonitorElement* const onOneOverEtOn, 
00354             MonitorElement* const onEtavsonPhiOn,  
00355             MonitorElement* const NOff, 
00356             MonitorElement* const offEtOff, 
00357             MonitorElement* const offEtavsoffPhiOff,
00358             MonitorElement* const NL1, 
00359             MonitorElement* const l1EtL1, 
00360             MonitorElement* const l1Etavsl1PhiL1,
00361             MonitorElement* const NL1On, 
00362             MonitorElement* const l1EtL1On, 
00363             MonitorElement* const l1Etavsl1PhiL1On,
00364             MonitorElement* const NL1Off,   
00365             MonitorElement* const offEtL1Off, 
00366             MonitorElement* const offEtavsoffPhiL1Off,
00367             MonitorElement* const NOnOff, 
00368             MonitorElement* const offEtOnOff, 
00369             MonitorElement* const offEtavsoffPhiOnOff,
00370             MonitorElement* const NL1OnUM, 
00371             MonitorElement* const l1EtL1OnUM, 
00372             MonitorElement* const l1Etavsl1PhiL1OnUM,
00373             MonitorElement* const NL1OffUM,   
00374             MonitorElement* const offEtL1OffUM, 
00375             MonitorElement* const offEtavsoffPhiL1OffUM,
00376             MonitorElement* const NOnOffUM, 
00377             MonitorElement* const offEtOnOffUM, 
00378             MonitorElement* const offEtavsoffPhiOnOffUM,
00379             MonitorElement* const offDRL1Off, 
00380             MonitorElement* const offDROnOff, 
00381             MonitorElement* const l1DRL1On)  
00382          {
00383 
00384               NOn_ = NOn;
00385               onEtOn_ = onEtOn;
00386               onOneOverEtOn_ = onOneOverEtOn;
00387               onEtavsonPhiOn_ = onEtavsonPhiOn;
00388               NOff_ = NOff;
00389               offEtOff_ = offEtOff;
00390               offEtavsoffPhiOff_ = offEtavsoffPhiOff;
00391               NL1_ = NL1;
00392               l1EtL1_ = l1EtL1;
00393               l1Etavsl1PhiL1_ = l1Etavsl1PhiL1;
00394               NL1On_ = NL1On;
00395               l1EtL1On_ = l1EtL1On;
00396               l1Etavsl1PhiL1On_ = l1Etavsl1PhiL1On;
00397               NL1Off_ = NL1Off;
00398               offEtL1Off_ = offEtL1Off;
00399               offEtavsoffPhiL1Off_ = offEtavsoffPhiL1Off;
00400               NOnOff_ = NOnOff;
00401               offEtOnOff_ = offEtOnOff;
00402               offEtavsoffPhiOnOff_ = offEtavsoffPhiOnOff;
00403               NL1OnUM_ = NL1OnUM;
00404               l1EtL1OnUM_ = l1EtL1OnUM;
00405               l1Etavsl1PhiL1OnUM_ = l1Etavsl1PhiL1OnUM;
00406               NL1OffUM_ = NL1OffUM;
00407               offEtL1OffUM_ = offEtL1OffUM;
00408               offEtavsoffPhiL1OffUM_ = offEtavsoffPhiL1OffUM;
00409               NOnOffUM_ = NOnOffUM;
00410               offEtOnOffUM_ = offEtOnOffUM;
00411               offEtavsoffPhiOnOffUM_ = offEtavsoffPhiOnOffUM;
00412               offDRL1Off_ =  offDRL1Off; 
00413               offDROnOff_ =  offDROnOff; 
00414               l1DRL1On_   =  l1DRL1On;
00415 
00416          }
00417 
00418          MonitorElement * getNOnHisto() {
00419           return NOn_;
00420          }
00421          MonitorElement * getOnEtOnHisto() {
00422            return onEtOn_;
00423          }
00424          MonitorElement * getOnOneOverEtOnHisto() {
00425            return onOneOverEtOn_;
00426          }
00427          MonitorElement * getOnEtaVsOnPhiOnHisto() {
00428            return onEtavsonPhiOn_;
00429          }
00430          MonitorElement * getNOffHisto() {
00431            return NOff_;
00432          }
00433          MonitorElement * getOffEtOffHisto() {
00434            return offEtOff_;
00435          }
00436          MonitorElement * getOffEtaVsOffPhiOffHisto() {
00437            return offEtavsoffPhiOff_;
00438          }
00439          MonitorElement * getNL1Histo() {
00440            return NL1_;
00441          }
00442          MonitorElement * getL1EtL1Histo() {
00443            return l1EtL1_;
00444          }
00445          MonitorElement * getL1EtaVsL1PhiL1Histo() {
00446            return l1Etavsl1PhiL1_;
00447          }
00448          MonitorElement * getNL1OnHisto() {
00449            return NL1On_;
00450          }
00451          MonitorElement * getL1EtL1OnHisto() {
00452            return l1EtL1On_;
00453          }
00454          MonitorElement * getL1EtaVsL1PhiL1OnHisto() {
00455            return l1Etavsl1PhiL1On_;
00456          }
00457          MonitorElement * getNL1OffHisto() {
00458            return NL1Off_;
00459          }
00460          MonitorElement * getOffEtL1OffHisto() {
00461            return offEtL1Off_;
00462          }
00463          MonitorElement * getOffEtaVsOffPhiL1OffHisto() {
00464            return offEtavsoffPhiL1Off_;
00465          }
00466          MonitorElement * getNOnOffHisto() {
00467            return NOnOff_;
00468          }
00469          MonitorElement * getOffEtOnOffHisto() {
00470            return offEtOnOff_;
00471          }
00472          MonitorElement * getOffEtaVsOffPhiOnOffHisto() {
00473            return offEtavsoffPhiOnOff_;
00474          }
00475          MonitorElement * getNL1OnUMHisto() {
00476            return NL1OnUM_;
00477          }
00478          MonitorElement * getL1EtL1OnUMHisto() {
00479            return l1EtL1OnUM_;
00480          }
00481          MonitorElement * getL1EtaVsL1PhiL1OnUMHisto() {
00482            return l1Etavsl1PhiL1OnUM_;
00483          }
00484          MonitorElement * getNL1OffUMHisto() {
00485            return NL1OffUM_;
00486          }
00487          MonitorElement * getOffEtL1OffUMHisto() {
00488            return offEtL1OffUM_;
00489          }
00490          MonitorElement * getOffEtaVsOffPhiL1OffUMHisto() {
00491            return offEtavsoffPhiL1OffUM_;
00492          }
00493          MonitorElement * getNOnOffUMHisto() {
00494            return NOnOffUM_;
00495          }
00496          MonitorElement * getOffEtOnOffUMHisto() {
00497            return offEtOnOffUM_;
00498          }
00499          MonitorElement * getOffEtaVsOffPhiOnOffUMHisto() {
00500            return offEtavsoffPhiOnOffUM_;
00501          }
00502          MonitorElement * getOffDRL1OffHisto() {
00503            return offDRL1Off_;
00504          }
00505          MonitorElement * getOffDROnOffHisto() {
00506            return offDROnOff_;
00507          }
00508          MonitorElement * getL1DROnL1Histo() {
00509            return l1DRL1On_;
00510          }
00511          MonitorElement * getFiltersHisto() {
00512            return filters_;
00513          }
00514          const std::string getLabel(void ) const {
00515            return filterName_;
00516          }
00517          void setLabel(std::string labelName){
00518            filterName_ = labelName;
00519            return;
00520          }
00521          const std::string & getPath(void ) const {
00522            return pathName_;
00523          }
00524          const std::string & getl1Path(void ) const {
00525            return l1pathName_;
00526          }
00527          const int getL1ModuleIndex(void ) const {
00528            return l1ModuleIndex_;
00529          }
00530          const std::string & getDenomPath(void ) const {
00531            return denomPathName_;
00532          }
00533          const std::string & getProcess(void ) const {
00534            return processName_;
00535          }
00536          const int getObjectType(void ) const {
00537            return objectType_;
00538          }
00539 
00540         const edm::InputTag getTag(void) const{
00541           edm::InputTag tagName(filterName_,"",processName_);
00542           return tagName;
00543         }
00544 
00545         ~PathInfo() {};
00546 
00547         PathInfo(std::string denomPathName, std::string pathName, std::string l1pathName, int l1ModuleIndex, std::string filterName, std::string processName, size_t type, float ptmin, float ptmax, float hltThreshold, float l1Threshold):
00548 
00549           denomPathName_(denomPathName), 
00550           pathName_(pathName), 
00551           l1pathName_(l1pathName), 
00552           l1ModuleIndex_(l1ModuleIndex), 
00553           filterName_(filterName), 
00554           processName_(processName), 
00555           objectType_(type),
00556           NOn_(0), onEtOn_(0), onOneOverEtOn_(0), onEtavsonPhiOn_(0), 
00557           NOff_(0), offEtOff_(0), offEtavsoffPhiOff_(0),
00558           NL1_(0), l1EtL1_(0), l1Etavsl1PhiL1_(0),
00559           NL1On_(0), l1EtL1On_(0), l1Etavsl1PhiL1On_(0),
00560           NL1Off_(0), offEtL1Off_(0), offEtavsoffPhiL1Off_(0),
00561           NOnOff_(0), offEtOnOff_(0), offEtavsoffPhiOnOff_(0),
00562           NL1OnUM_(0), l1EtL1OnUM_(0), l1Etavsl1PhiL1OnUM_(0),
00563           NL1OffUM_(0), offEtL1OffUM_(0), offEtavsoffPhiL1OffUM_(0),
00564           NOnOffUM_(0), offEtOnOffUM_(0), offEtavsoffPhiOnOffUM_(0),
00565           offDRL1Off_(0), offDROnOff_(0), l1DRL1On_(0), filters_(0),
00566           ptmin_(ptmin), ptmax_(ptmax),
00567           hltThreshold_(hltThreshold), l1Threshold_(l1Threshold)
00568 
00569         {
00570         };
00571 
00572         PathInfo(std::string denomPathName, std::string pathName, std::string l1pathName, std::string filterName, std::string processName, size_t type,
00573           MonitorElement *NOn,
00574           MonitorElement *onEtOn,
00575           MonitorElement *onOneOverEtOn,
00576           MonitorElement *onEtavsonPhiOn,
00577           MonitorElement *NOff,
00578           MonitorElement *offEtOff,
00579           MonitorElement *offEtavsoffPhiOff,
00580           MonitorElement *NL1,
00581           MonitorElement *l1EtL1,
00582           MonitorElement *l1Etavsl1PhiL1,
00583           MonitorElement *NL1On,
00584           MonitorElement *l1EtL1On,
00585           MonitorElement *l1Etavsl1PhiL1On,
00586           MonitorElement *NL1Off,
00587           MonitorElement *offEtL1Off,
00588           MonitorElement *offEtavsoffPhiL1Off,
00589           MonitorElement *NOnOff,
00590           MonitorElement *offEtOnOff,
00591           MonitorElement *offEtavsoffPhiOnOff,
00592           MonitorElement *NL1OnUM,
00593           MonitorElement *l1EtL1OnUM,
00594           MonitorElement *l1Etavsl1PhiL1OnUM,
00595           MonitorElement *NL1OffUM,
00596           MonitorElement *offEtL1OffUM,
00597           MonitorElement *offEtavsoffPhiL1OffUM,
00598           MonitorElement *NOnOffUM,
00599           MonitorElement *offEtOnOffUM,
00600           MonitorElement *offEtavsoffPhiOnOffUM,
00601           MonitorElement *offDRL1Off, 
00602           MonitorElement *offDROnOff, 
00603           MonitorElement *l1DRL1On,
00604           MonitorElement *filters,
00605           float ptmin, float ptmax
00606           ):
00607 
00608             denomPathName_(denomPathName), 
00609             pathName_(pathName), l1pathName_(l1pathName), 
00610             filterName_(filterName), processName_(processName), objectType_(type),
00611             NOn_(NOn), onEtOn_(onEtOn), onOneOverEtOn_(onOneOverEtOn), onEtavsonPhiOn_(onEtavsonPhiOn), 
00612             NOff_(NOff), offEtOff_(offEtOff), offEtavsoffPhiOff_(offEtavsoffPhiOff),
00613             NL1_(NL1), l1EtL1_(l1EtL1), l1Etavsl1PhiL1_(l1Etavsl1PhiL1),
00614             NL1On_(NL1On), l1EtL1On_(l1EtL1On), l1Etavsl1PhiL1On_(l1Etavsl1PhiL1On),
00615             NL1Off_(NL1Off), offEtL1Off_(offEtL1Off), offEtavsoffPhiL1Off_(offEtavsoffPhiL1Off),
00616             NOnOff_(NOnOff), offEtOnOff_(offEtOnOff), offEtavsoffPhiOnOff_(offEtavsoffPhiOnOff),
00617             NL1OnUM_(NL1OnUM), l1EtL1OnUM_(l1EtL1OnUM), l1Etavsl1PhiL1OnUM_(l1Etavsl1PhiL1OnUM),
00618             NL1OffUM_(NL1OffUM), offEtL1OffUM_(offEtL1OffUM), offEtavsoffPhiL1OffUM_(offEtavsoffPhiL1OffUM),
00619             NOnOffUM_(NOnOffUM), offEtOnOffUM_(offEtOnOffUM), offEtavsoffPhiOnOffUM_(offEtavsoffPhiOnOffUM),
00620             offDRL1Off_(offDRL1Off), 
00621             offDROnOff_(offDROnOff), 
00622             l1DRL1On_(l1DRL1On),
00623             filters_(filters),
00624             ptmin_(ptmin), ptmax_(ptmax)
00625         {
00626         };
00627 
00628         bool operator==(const std::string& v) 
00629         {
00630           return v==filterName_;
00631         }
00632 
00633         bool operator!=(const std::string& v) 
00634         {
00635           return v!=filterName_;
00636         }
00637 
00638         float getPtMin() const { return ptmin_; }
00639         float getPtMax() const { return ptmax_; }
00640         float getHltThreshold() const { return hltThreshold_; }
00641         float getL1Threshold() const { return l1Threshold_; }
00642 
00643         std::vector< std::pair<std::string,unsigned int> > filtersAndIndices;
00644 
00645 
00646       private:
00647 
00648         int pathIndex_;
00649         std::string denomPathName_;
00650         std::string pathName_;
00651         std::string l1pathName_;
00652         int l1ModuleIndex_;
00653         std::string filterName_;
00654         std::string processName_;
00655         int objectType_;
00656         
00657         // we don't own this data
00658         MonitorElement *NOn_, *onEtOn_, *onOneOverEtOn_, *onEtavsonPhiOn_;
00659         MonitorElement *NOff_, *offEtOff_, *offEtavsoffPhiOff_;
00660         MonitorElement *NL1_, *l1EtL1_, *l1Etavsl1PhiL1_;
00661         MonitorElement *NL1On_, *l1EtL1On_, *l1Etavsl1PhiL1On_;
00662         MonitorElement *NL1Off_, *offEtL1Off_, *offEtavsoffPhiL1Off_;
00663         MonitorElement *NOnOff_, *offEtOnOff_, *offEtavsoffPhiOnOff_;
00664         MonitorElement *NL1OnUM_, *l1EtL1OnUM_, *l1Etavsl1PhiL1OnUM_;
00665         MonitorElement *NL1OffUM_, *offEtL1OffUM_, *offEtavsoffPhiL1OffUM_;
00666         MonitorElement *NOnOffUM_, *offEtOnOffUM_, *offEtavsoffPhiOnOffUM_;
00667         MonitorElement *offDRL1Off_, *offDROnOff_, *l1DRL1On_;
00668         MonitorElement *filters_;
00669         
00670         float ptmin_, ptmax_;
00671         float hltThreshold_, l1Threshold_;
00672         
00673         const int index() { 
00674           return pathIndex_;
00675         }
00676         const int type() { 
00677           return objectType_;
00678         }
00679 
00680 
00681      };
00682      
00683 
00684    public:
00685 
00686      // simple collection - just 
00687      class PathInfoCollection: public std::vector<PathInfo> {
00688        public:
00689 
00690          PathInfoCollection(): std::vector<PathInfo>() 
00691         {};
00692          std::vector<PathInfo>::iterator find(std::string pathName) {
00693             return std::find(begin(), end(), pathName);
00694          }
00695       };
00696 
00697       PathInfoCollection hltPaths_;
00698 
00699       PathInfoCollection hltPathsDiagonal_;
00700 
00701 };
00702 
00703 
00704 class BaseMonitor
00705 {
00706   public:
00707     virtual void clearSets( void ) = 0;
00708     virtual void setPath(FourVectorHLTOffline::PathInfoCollection::iterator v) = 0;
00709     virtual void monitorOffline( void ) = 0;
00710     virtual void monitorL1( const int l1Index, FourVectorHLTOffline* fv) = 0;
00711     virtual void monitorOnline(const int hltIndex, const int l1Index, FourVectorHLTOffline* fv) = 0;
00712 
00713     virtual void matchL1Offline(const trigger::TriggerObject& l1FV, FourVectorHLTOffline* fv, const int& NL1, unsigned int& NL1OffUM) = 0;
00714     virtual void matchOnlineL1(const trigger::TriggerObject& onlineFV, const int& l1Index, FourVectorHLTOffline* fv, const int& NOn) = 0;
00715     virtual void matchOnlineOffline(const trigger::TriggerObject& onlineFV, FourVectorHLTOffline* fv, const int& NOn) = 0;
00716 
00717     virtual void fillL1Match(FourVectorHLTOffline* fv) = 0;
00718     virtual void fillOnlineMatch(const int l1Index, FourVectorHLTOffline* fv) = 0;
00719 
00720     virtual bool isTriggerType(int t) = 0;
00721     virtual ~BaseMonitor(){}
00722 
00723 };
00724 
00725 template <class T> 
00726 class objMonData:public BaseMonitor {
00727 public:
00728     objMonData() { EtaMax_= 2.5; EtMin_=3.0; GenJetsFlag_ = false; BJetsFlag_ = false; fL2MuFlag = false; }
00729     void setLimits(float etaMax, float etMin, float drMatch, float l1drMatch, float dRRange, float thresholdFactor) 
00730     {
00731      EtaMax_= etaMax; 
00732      EtMin_= etMin; 
00733      DRMatch_= drMatch;
00734      L1DRMatch_= l1drMatch;
00735      DRRange_ = dRRange;
00736      thresholdFactor_ = thresholdFactor;
00737     }
00738     void setTriggerType(std::vector<int> trigType) { triggerType_ = trigType; }
00739     void pushTriggerType(int trigType) { triggerType_.push_back(trigType); }
00740     void setL1TriggerType(std::vector<int> trigType) { l1triggerType_ = trigType; }
00741     void pushL1TriggerType(int trigType) { l1triggerType_.push_back(trigType); }
00742     void setPath(FourVectorHLTOffline::PathInfoCollection::iterator v) { v_ = v; }
00743     void setReco(edm::Handle<T> offColl) { offColl_ = offColl; }
00744     void setRecoB(edm::Handle<reco::JetTagCollection> offCollB) { offCollB_ = offCollB; }
00745     void setRecoMu(edm::Handle<reco::MuonCollection> offCollMu) { offCollMu_ = offCollMu; }
00746     void setRecoEle(edm::Handle<reco::GsfElectronCollection> offCollEle) { offCollEle_ = offCollEle; }
00747 
00748 
00749 
00750     // Monitor methods
00751 
00752     void monitorOffline();
00753     void monitorL1(const int l1Index, FourVectorHLTOffline* fv);
00754     void monitorOnline(const int hltIndex, const int l1Index, FourVectorHLTOffline* fv);
00755     void matchL1Offline(const trigger::TriggerObject& l1FV, FourVectorHLTOffline* fv, const int& NL1, unsigned int& NL1OffUM);
00756     void matchOnlineL1(const trigger::TriggerObject& onlineFV, const int& l1Index, FourVectorHLTOffline* fv, const int& NOn);
00757     void matchOnlineOffline(const trigger::TriggerObject& onlineFV, FourVectorHLTOffline* fv, const int& NOn);
00758     void fillOnlineMatch(const int l1Index, FourVectorHLTOffline* fv);
00759     void fillOnOffMatch(FourVectorHLTOffline* fv);
00760     void fillOnL1Match(const int l1Index, FourVectorHLTOffline* fv);
00761     void fillL1Match(FourVectorHLTOffline* fv);
00762     void fillL1OffMatch(FourVectorHLTOffline* fv);
00763 
00764     void clearSets();
00765 
00766     bool isTriggerType(int t);
00767     bool isL1TriggerType(int t);
00768 
00769     mmset L1OffDRMatchSet;
00770     mmset L1MCDRMatchSet;
00771     mmset OnOffDRMatchSet;
00772     mmset OnMCDRMatchSet;
00773     mmset OnL1DRMatchSet;
00774     mmset OffMCDRMatchSet;
00775 
00776 
00777     void setBJetsFlag(bool flag) 
00778     { 
00779       BJetsFlag_ = flag; 
00780     }
00781     void setL2MuFlag(bool flag) 
00782     { 
00783       fL2MuFlag = flag; 
00784     }
00785     
00786 
00787 private:
00788 
00789     int   pdgId_;
00790     int   pdgStatus_;
00791 
00792     float EtaMax_;
00793     float EtMin_;
00794 
00795     float DRMatch_;
00796     float L1DRMatch_;
00797     float DRRange_;
00798     float thresholdFactor_;
00799 
00800     bool GenJetsFlag_;
00801     bool BJetsFlag_;
00802     bool fL2MuFlag;
00803 
00804     std::vector<int> triggerType_;
00805     std::vector<int> l1triggerType_;
00806 
00807     edm::Handle<T> offColl_;
00808     edm::Handle<reco::JetTagCollection> offCollB_;
00809     edm::Handle<reco::MuonCollection> offCollMu_;
00810     edm::Handle<reco::GsfElectronCollection> offCollEle_;
00811 
00812     FourVectorHLTOffline::PathInfoCollection::iterator v_;
00813 
00814 };
00815 
00816 
00817 template <class T> 
00818 bool objMonData<T>::isTriggerType(int t)
00819 {
00820   bool rc = false;
00821 
00822   for(std::vector<int>::const_iterator it = triggerType_.begin(); it != triggerType_.end(); ++it)
00823   {
00824 
00825    if(t == *it) { rc = true; break; }
00826 
00827   } // end for
00828 
00829   if (t==0) rc = true;
00830 
00831   return rc;
00832 
00833 }
00834 
00835 
00836 template <class T> 
00837 bool objMonData<T>::isL1TriggerType(int t)
00838 {
00839   bool rc = false;
00840 
00841   for(std::vector<int>::const_iterator it = l1triggerType_.begin(); it != l1triggerType_.end(); ++it)
00842   {
00843 
00844    if(fabs(t) == fabs(*it)) { rc = true; break; }
00845 
00846   } // end for
00847 
00848   return rc;
00849 
00850 }
00851 
00852 
00853 
00854 
00855 template <class T> 
00856 void objMonData<T>::monitorOffline()
00857 {
00858 
00859  if(! isTriggerType(v_->getObjectType()) ) return;
00860 
00861  unsigned int NOff = 0;
00862 
00863  if( offCollB_.isValid()) {
00864   typedef typename reco::JetTagCollection::const_iterator const_iterator;
00865   for( const_iterator iter = offCollB_->begin(), iend = offCollB_->end(); iter != iend; ++iter )
00866   {
00867 
00868     float recoEta = (*iter).first->eta();
00869     float recoPhi = (*iter).first->phi();
00870     float recoPt = (*iter).first->pt();
00871 
00872 
00873     if (fabs(recoEta) <= EtaMax_ && recoPt >=  EtMin_ )
00874     {
00875      
00876        NOff++;
00877        v_->getOffEtOffHisto()->Fill(recoPt);
00878        if(recoPt >= thresholdFactor_*v_->getHltThreshold())
00879        v_->getOffEtaVsOffPhiOffHisto()->Fill(recoEta, recoPhi);
00880 
00881     }
00882     /*
00883     else {
00884 
00885       continue;
00886 
00887     }
00888     */
00889 
00890   }
00891 
00892  }
00893  else if(offCollEle_.isValid()) {
00894 
00895   typedef typename reco::GsfElectronCollection::const_iterator const_iterator;
00896   for( const_iterator iter = offCollEle_->begin(), iend = offCollEle_->end(); iter != iend; ++iter )
00897   {
00898 
00899    if (fabs(iter->eta()) <= EtaMax_ && iter->superCluster()->energy()*sin(iter->superCluster()->position().Theta()) >=  EtMin_ )
00900    {
00901 
00902      NOff++;
00903      v_->getOffEtOffHisto()->Fill(iter->superCluster()->energy()*sin(iter->superCluster()->position().Theta()));
00904 
00905      if(iter->pt() >= thresholdFactor_*v_->getHltThreshold())
00906      v_->getOffEtaVsOffPhiOffHisto()->Fill(iter->eta(), iter->phi());
00907 
00908    }
00909    /*
00910    else {
00911 
00912      continue;
00913 
00914    }
00915    */
00916 
00917   }
00918 
00919  } // end else if
00920  else if(offColl_.isValid()) {
00921 
00922   typedef typename T::const_iterator const_iterator;
00923   for( const_iterator iter = offColl_->begin(), iend = offColl_->end(); iter != iend; ++iter )
00924   {
00925 
00926    if (fabs(iter->eta()) <= EtaMax_ && iter->pt() >=  EtMin_ )
00927    {
00928 
00929      NOff++;
00930      v_->getOffEtOffHisto()->Fill(iter->pt());
00931 
00932      if(iter->pt() >= thresholdFactor_*v_->getHltThreshold())
00933      v_->getOffEtaVsOffPhiOffHisto()->Fill(iter->eta(), iter->phi());
00934 
00935    }
00936    /*
00937    else {
00938 
00939      continue;
00940 
00941    }
00942    */
00943 
00944   }
00945 
00946  } // end else if
00947 
00948  if(NOff>0)v_->getNOffHisto()->Fill(NOff);
00949 
00950 }
00951 
00952 
00953 template <class T> 
00954 void objMonData<T>::monitorL1(const int l1Index, FourVectorHLTOffline* fv)
00955 {
00956 
00957   if ( l1Index >= fv->fTriggerObj->sizeFilters() ) return;
00958 
00959   unsigned int NL1=0;
00960   unsigned int NL1OffUM=0;
00961 
00962   const trigger::TriggerObjectCollection & toc(fv->fTriggerObj->getObjects());
00963         const trigger::Vids & idtype = fv->fTriggerObj->filterIds(l1Index);
00964         const trigger::Keys & l1k = fv->fTriggerObj->filterKeys(l1Index);
00965         bool l1accept = l1k.size() > 0;
00966 
00967   if(!l1accept) return;
00968 
00969   trigger::Vids::const_iterator idtypeiter = idtype.begin(); 
00970 
00971   for (trigger::Keys::const_iterator l1ki = l1k.begin(); l1ki !=l1k.end(); ++l1ki ) {
00972 
00973    trigger::TriggerObject l1FV = toc[*l1ki];
00974 
00975    if(isL1TriggerType(*idtypeiter))
00976    {
00977 
00978      NL1++;
00979 
00980      v_->getL1EtL1Histo()->Fill(l1FV.pt());
00981      v_->getL1EtaVsL1PhiL1Histo()->Fill(l1FV.eta(), l1FV.phi());
00982 
00983      matchL1Offline(l1FV, fv, NL1, NL1OffUM);
00984 
00985    } // end if isL1TriggerType
00986 
00987    ++idtypeiter;
00988 
00989  } // end for l1ki
00990 
00991  if(NL1 > 0) v_->getNL1Histo()->Fill(NL1);
00992  if(NL1OffUM > 0) v_->getNL1OffUMHisto()->Fill(NL1OffUM);
00993 
00994 }
00995 
00996 
00997 template <class T> 
00998 void objMonData<T>::matchL1Offline(const trigger::TriggerObject& l1FV, FourVectorHLTOffline* fv, const int& NL1, unsigned int& NL1OffUM)
00999 {
01000 
01001   fimmap L1OffDRMatchMap;
01002 
01003   if (offCollB_.isValid()) {
01004 
01005     int j=0;
01006     typedef typename reco::JetTagCollection::const_iterator const_iterator;
01007     for( const_iterator iter = offCollB_->begin(), iend = offCollB_->end(); iter != iend; ++iter )
01008     {
01009 
01010       float recoEta = (*iter).first->eta();
01011       float recoPhi = (*iter).first->phi();
01012       float recoPt = (*iter).first->pt();
01013 
01014       if (fabs(recoEta) <= EtaMax_ && recoPt >=  EtMin_ )
01015       {
01016 
01017         // fill UM histos (no matching required)
01018         if (v_->getOffEtL1OffUMHisto() != 0) {
01019           if(NL1 == 1) {
01020             
01021             NL1OffUM++;
01022             v_->getOffEtL1OffUMHisto()->Fill(recoPt);
01023             
01024             if(recoPt >= thresholdFactor_*v_->getHltThreshold())
01025               v_->getOffEtaVsOffPhiL1OffUMHisto()->Fill(recoEta,recoPhi);
01026             
01027           }
01028         }
01029 
01030          // make maps of matched objects
01031         float dR = reco::deltaR(recoEta,recoPhi,l1FV.eta(),l1FV.phi());
01032         if ( dR < DRRange_)
01033         {
01034 
01035           L1OffDRMatchMap.insert(std::pair<float,int>(dR,j));
01036 
01037         }
01038 
01039       }
01040 
01041       j++;
01042 
01043     }
01044 
01045   }
01046   else if (offCollMu_.isValid()) {
01047 
01048     int j=0;
01049     typedef typename reco::MuonCollection::const_iterator const_iterator;
01050     for( const_iterator iter = offCollMu_->begin(), iend = offCollMu_->end(); iter != iend; ++iter )
01051     {
01052 
01053       // get Eta, Phi of the MuonDetectorTrack, 
01054       // looking at the detector most inner Position
01055       // This should be close to what L1 sees
01056       float recoEta = iter->outerTrack()->innerPosition().eta();
01057       float recoPhi = iter->outerTrack()->innerPosition().phi();
01058       float recoPt = iter->pt();
01059 
01060       if (fabs(recoEta) <= EtaMax_ && recoPt >=  EtMin_ )
01061       {
01062 
01063         // fill UM histos (no matching required)
01064         if (v_->getOffEtL1OffUMHisto() != 0) {
01065           if(NL1 == 1) {
01066             
01067             NL1OffUM++;
01068             v_->getOffEtL1OffUMHisto()->Fill(recoPt);
01069             
01070             if(recoPt >= thresholdFactor_*v_->getHltThreshold())
01071               v_->getOffEtaVsOffPhiL1OffUMHisto()->Fill(recoEta,recoPhi);
01072             
01073           }
01074         }
01075 
01076          // make maps of matched objects
01077         float dR = reco::deltaR(recoEta,recoPhi,l1FV.eta(),l1FV.phi());
01078         if ( dR < DRRange_)
01079         {
01080 
01081           L1OffDRMatchMap.insert(std::pair<float,int>(dR,j));
01082 
01083         }
01084 
01085       }
01086 
01087       j++;
01088 
01089     }
01090 
01091   }
01092   else if (offCollEle_.isValid()) {
01093 
01094     int j=0;
01095     typedef typename reco::GsfElectronCollection::const_iterator const_iterator;
01096     for( const_iterator iter = offCollEle_->begin(), iend = offCollEle_->end(); iter != iend; ++iter )
01097     {
01098 
01099       if (fabs(iter->eta()) <= EtaMax_ && iter->superCluster()->energy()*sin(iter->superCluster()->position().Theta()) >=  EtMin_ )
01100       {
01101 
01102         if ( v_->getOffEtL1OffUMHisto() != 0) {
01103           // fill UM histos (no matching required)
01104           if(NL1 == 1) {
01105             
01106             NL1OffUM++;
01107             v_->getOffEtL1OffUMHisto()->Fill(iter->superCluster()->energy()*sin(iter->superCluster()->position().Theta()));
01108             
01109             if(iter->superCluster()->energy()*sin(iter->superCluster()->position().Theta()) >= thresholdFactor_*v_->getHltThreshold())
01110               v_->getOffEtaVsOffPhiL1OffUMHisto()->Fill(iter->eta(),iter->phi());
01111             
01112           }
01113         }
01114 
01115         // make maps of matched objects
01116         float dR = reco::deltaR(iter->eta(),iter->phi(),l1FV.eta(),l1FV.phi());
01117         if ( dR < DRRange_) 
01118         {
01119 
01120          L1OffDRMatchMap.insert(std::pair<float,int>(dR,j));
01121 
01122         }
01123 
01124       }
01125 
01126       j++;
01127 
01128     }
01129 
01130   }
01131   else if (offColl_.isValid()) {
01132 
01133     int j=0;
01134     typedef typename T::const_iterator const_iterator;
01135     for( const_iterator iter = offColl_->begin(), iend = offColl_->end(); iter != iend; ++iter )
01136     {
01137 
01138       if (fabs(iter->eta()) <= EtaMax_ && iter->pt() >=  EtMin_ )
01139       {
01140 
01141         // fill UM histos (no matching required)
01142         if (v_->getOffEtL1OffUMHisto()!= 0 ) {
01143           if(NL1 == 1) {
01144             
01145             NL1OffUM++;
01146             v_->getOffEtL1OffUMHisto()->Fill(iter->pt());
01147             
01148             if(iter->pt() >= thresholdFactor_*v_->getHltThreshold())
01149               v_->getOffEtaVsOffPhiL1OffUMHisto()->Fill(iter->eta(),iter->phi());
01150             
01151           }
01152         }
01153 
01154         // make maps of matched objects
01155         float dR = reco::deltaR(iter->eta(),iter->phi(),l1FV.eta(),l1FV.phi());
01156         if ( dR < DRRange_) 
01157         {
01158 
01159          L1OffDRMatchMap.insert(std::pair<float,int>(dR,j));
01160 
01161         }
01162 
01163       }
01164 
01165       j++;
01166 
01167     }
01168 
01169   }
01170   if(! L1OffDRMatchMap.empty())  L1OffDRMatchSet.insert(L1OffDRMatchMap);
01171 
01172 }
01173 
01174 
01175 template <class T> 
01176 void objMonData<T>::monitorOnline(const int hltIndex, const int l1Index, FourVectorHLTOffline* fv)
01177 {
01178 
01179   if(! isTriggerType(v_->getObjectType()) ) return;
01180 
01181   // Get keys of objects passed by the last filter
01182   const trigger::Keys & k = fv->fTriggerObj->filterKeys(hltIndex);
01183 
01184   const trigger::TriggerObjectCollection & toc(fv->fTriggerObj->getObjects());
01185 
01186   unsigned int NOn=0;
01187 
01188   // Loop over HLT objects
01189   for (trigger::Keys::const_iterator ki = k.begin(); ki !=k.end(); ++ki ) {
01190 
01191           trigger::TriggerObject onlineFV = toc[*ki];
01192         
01193           NOn++;    
01194         
01195           v_->getOnEtOnHisto()->Fill(onlineFV.pt());
01196           v_->getOnOneOverEtOnHisto()->Fill(1./onlineFV.pt());
01197           v_->getOnEtaVsOnPhiOnHisto()->Fill(onlineFV.eta(), onlineFV.phi());
01198         
01199           matchOnlineL1(onlineFV,l1Index, fv, NOn);
01200           matchOnlineOffline(onlineFV,fv, NOn);
01201 
01202   } // end loop over HLT objects
01203   
01204   if(NOn>0) v_->getNOnHisto()->Fill(NOn);
01205 
01206 }
01207 
01208 template <class T> 
01209 void objMonData<T>::matchOnlineL1(const trigger::TriggerObject& onlineFV, const int& l1Index, FourVectorHLTOffline* fv, const int& NOn)
01210 {
01211 
01212   if ( l1Index >= fv->fTriggerObj->sizeFilters() ) return;
01213 
01214   unsigned int NOnL1UM=0;
01215 
01216   const trigger::TriggerObjectCollection & toc(fv->fTriggerObj->getObjects());
01217         const trigger::Vids & idtype = fv->fTriggerObj->filterIds(l1Index);
01218         const trigger::Keys & l1k = fv->fTriggerObj->filterKeys(l1Index);
01219 
01220   fimmap OnL1DRMatchMap;
01221   int j=0;
01222   trigger::Vids::const_iterator idtypeiter = idtype.begin(); 
01223   for (trigger::Keys::const_iterator l1ki = l1k.begin(); l1ki !=l1k.end(); ++l1ki ) 
01224   {
01225 
01226       if(isL1TriggerType(*idtypeiter))
01227       {
01228 
01229         trigger::TriggerObject l1FV = toc[*l1ki];
01230 
01231         // fill UM histos (no matching required)
01232         if (v_->getL1EtL1OnUMHisto() != 0) {
01233           if(NOn == 1) {
01234             
01235             NOnL1UM++;
01236             v_->getL1EtL1OnUMHisto()->Fill(l1FV.pt());
01237             v_->getL1EtaVsL1PhiL1OnUMHisto()->Fill(l1FV.eta(),l1FV.phi());
01238             
01239           }
01240         }
01241           
01242          float dR = reco::deltaR(l1FV.eta(),l1FV.phi(),onlineFV.eta(),onlineFV.phi());
01243 
01244          if ( dR < DRRange_) 
01245          {
01246 
01247            OnL1DRMatchMap.insert(std::pair<float,int>(dR,j));
01248 
01249          }
01250 
01251        } // end if isL1TriggerType
01252 
01253        ++idtypeiter;
01254        j++;
01255 
01256   } // end for
01257 
01258   if(! OnL1DRMatchMap.empty()) OnL1DRMatchSet.insert(OnL1DRMatchMap);
01259 
01260 }
01261 
01262 
01263 template <class T> 
01264 void objMonData<T>::matchOnlineOffline(const trigger::TriggerObject& onlineFV, FourVectorHLTOffline* fv, const int& NOn)
01265 {
01266 
01267   unsigned int NOnOffUM=0;
01268 
01269   fimmap OnOffDRMatchMap;
01270 
01271   if (offCollB_.isValid()) {
01272 
01273      int j=0;
01274      typedef typename reco::JetTagCollection::const_iterator const_iterator;
01275      for( const_iterator iter = offCollB_->begin(), iend = offCollB_->end(); iter != iend; ++iter )
01276      {
01277 
01278        float recoEta = (*iter).first->eta();
01279        float recoPhi = (*iter).first->phi();
01280        float recoPt = (*iter).first->pt();
01281 
01282        if (fabs(recoEta) <= EtaMax_ && recoPt >=  EtMin_ )
01283        {
01284 
01285 
01286          // fill UM histos (no matching required)
01287          if (v_->getOffEtOnOffUMHisto() != 0) {
01288            if(NOn == 1) {
01289              
01290              NOnOffUM++;
01291              v_->getOffEtOnOffUMHisto()->Fill(recoPt);
01292              
01293              if(recoPt >= thresholdFactor_*v_->getHltThreshold())
01294                v_->getOffEtaVsOffPhiOnOffUMHisto()->Fill(recoEta,recoPhi);
01295              
01296            }
01297          }
01298 
01299           // make maps of matched objects
01300          float dR = reco::deltaR(recoEta,recoPhi,onlineFV.eta(),onlineFV.phi());
01301          if ( dR < DRRange_)
01302          {
01303 
01304            OnOffDRMatchMap.insert(std::pair<float,int>(dR,j));
01305 
01306          }
01307 
01308        }
01309 
01310        j++;
01311 
01312      }
01313 
01314   }
01315   else if (offCollMu_.isValid() && fL2MuFlag) {
01316 
01317     int j=0;
01318     typedef typename reco::MuonCollection::const_iterator const_iterator;
01319     for( const_iterator iter = offCollMu_->begin(), iend = offCollMu_->end(); iter != iend; ++iter )
01320     {
01321 
01322       // get Eta, Phi of the MuonDetectorTrack, 
01323       // looking at the detector most inner Position
01324       // This should be close to what L1 sees
01325       float recoEta = iter->outerTrack()->innerPosition().eta();
01326       float recoPhi = iter->outerTrack()->innerPosition().phi();
01327       float recoPt = iter->pt();
01328 
01329       if (fabs(recoEta) <= EtaMax_ && recoPt >=  EtMin_ )
01330       {
01331          // fill UM histos (no matching required)
01332         if (v_->getOffEtOnOffUMHisto() != 0) {
01333           if(NOn == 1) {
01334             
01335             NOnOffUM++;
01336             v_->getOffEtOnOffUMHisto()->Fill(iter->pt());
01337             
01338             if(recoPt >= thresholdFactor_*v_->getHltThreshold())
01339               v_->getOffEtaVsOffPhiOnOffUMHisto()->Fill(iter->eta(),iter->phi());
01340             
01341           }
01342         }
01343 
01344           // make maps of matched objects
01345          float dR = reco::deltaR(recoEta,recoPhi,onlineFV.eta(),onlineFV.phi());
01346          if ( dR < DRRange_)
01347          {
01348 
01349            OnOffDRMatchMap.insert(std::pair<float,int>(dR,j));
01350 
01351          }
01352 
01353        }
01354 
01355        j++;
01356 
01357 
01358      }
01359 
01360   }
01361   else if (offCollEle_.isValid()) {
01362 
01363      int j=0;
01364 
01365      typedef typename reco::GsfElectronCollection::const_iterator const_iterator;
01366      for( const_iterator iter = offCollEle_->begin(), iend = offCollEle_->end(); iter != iend; ++iter )
01367      {
01368 
01369        if (fabs(iter->eta()) <= EtaMax_ && iter->superCluster()->energy()*sin(iter->superCluster()->position().Theta()) >=  EtMin_ )
01370        {
01371 
01372          // fill UM histos (no matching required)
01373          if (v_->getOffEtOnOffUMHisto() != 0) {
01374            if(NOn == 1) {
01375              
01376              NOnOffUM++;
01377              v_->getOffEtOnOffUMHisto()->Fill(iter->superCluster()->energy()*sin(iter->superCluster()->position().Theta()));
01378              
01379              if(iter->superCluster()->energy()*sin(iter->superCluster()->position().Theta()) >= thresholdFactor_*v_->getHltThreshold())
01380                v_->getOffEtaVsOffPhiOnOffUMHisto()->Fill(iter->eta(),iter->phi());
01381              
01382            }
01383          }
01384 
01385           // make maps of matched objects
01386          float dR = reco::deltaR(iter->eta(),iter->phi(),onlineFV.eta(),onlineFV.phi());
01387          if ( dR < DRRange_)
01388          {
01389 
01390            OnOffDRMatchMap.insert(std::pair<float,int>(dR,j));
01391 
01392          }
01393 
01394        }
01395 
01396        j++;
01397 
01398 
01399      }
01400 
01401   }
01402   else if (offColl_.isValid()) {
01403 
01404      int j=0;
01405 
01406      typedef typename T::const_iterator const_iterator;
01407      for( const_iterator iter = offColl_->begin(), iend = offColl_->end(); iter != iend; ++iter )
01408      {
01409 
01410        if (fabs(iter->eta()) <= EtaMax_ && iter->pt() >=  EtMin_ )
01411        {
01412 
01413          // fill UM histos (no matching required)
01414          if (v_->getOffEtOnOffUMHisto() != 0) {
01415            if(NOn == 1) {
01416              
01417              NOnOffUM++;
01418              v_->getOffEtOnOffUMHisto()->Fill(iter->pt());
01419              
01420              if(iter->pt() >= thresholdFactor_*v_->getHltThreshold())
01421                v_->getOffEtaVsOffPhiOnOffUMHisto()->Fill(iter->eta(),iter->phi());
01422              
01423            }
01424          }
01425 
01426           // make maps of matched objects
01427          float dR = reco::deltaR(iter->eta(),iter->phi(),onlineFV.eta(),onlineFV.phi());
01428          if ( dR < DRRange_)
01429          {
01430 
01431            OnOffDRMatchMap.insert(std::pair<float,int>(dR,j));
01432 
01433          }
01434 
01435        }
01436 
01437        j++;
01438 
01439 
01440      }
01441 
01442   }
01443 
01444   if(! OnOffDRMatchMap.empty())  OnOffDRMatchSet.insert(OnOffDRMatchMap);
01445  
01446 }
01447 
01448 template <class T> 
01449 void objMonData<T>::fillL1OffMatch(FourVectorHLTOffline* fv)
01450 {
01451 
01452   float NL1Off=0;
01453 
01454   if(L1OffDRMatchSet.size() > 1) {
01455   
01456     LogDebug("FourVectorHLTOffline") << " Cleaning L1Off mmset" << std::endl;
01457     fv->cleanDRMatchSet(L1OffDRMatchSet);
01458 
01459   }
01460   // clean the set L1-Off
01461   // now fill histos
01462   for ( mmset::iterator setIter = L1OffDRMatchSet.begin( ); setIter != L1OffDRMatchSet.end( ); setIter++ ) 
01463   {
01464 
01465        fimmap tempMap = *setIter;
01466          
01467        fimmap::iterator it = tempMap.begin(); 
01468        int i  = (*it).second ;
01469        float dR = (*it).first;
01470        v_->getOffDRL1OffHisto()->Fill(dR);
01471 
01472        if (dR > L1DRMatch_) continue;
01473        if( offCollB_.isValid()) {
01474 
01475          typedef typename reco::JetTagCollection::const_iterator const_iterator;
01476          const_iterator iter = offCollB_->begin();
01477          for (int count = 0; count < i; count++) iter++;
01478 
01479 
01480          NL1Off++;
01481          v_->getOffEtL1OffHisto()->Fill((*iter).first->pt());
01482          if((*iter).first->pt() >= thresholdFactor_*v_->getHltThreshold())
01483          v_->getOffEtaVsOffPhiL1OffHisto()->Fill((*iter).first->eta(),(*iter).first->phi());
01484 
01485 
01486       }
01487       else if( offCollMu_.isValid()) {
01488 
01489         typedef typename reco::MuonCollection::const_iterator const_iterator;
01490         const_iterator iter = offCollMu_->begin();
01491         for (int count = 0; count < i; count++) iter++;
01492 
01493 
01494         NL1Off++;
01495         v_->getOffEtL1OffHisto()->Fill(iter->pt());
01496         if(iter->pt() >= thresholdFactor_*v_->getHltThreshold())
01497         v_->getOffEtaVsOffPhiL1OffHisto()->Fill(iter->outerTrack()->innerPosition().eta(),iter->outerTrack()->innerPosition().phi());
01498 
01499       }
01500       else if( offCollEle_.isValid()) {
01501 
01502          typedef typename reco::GsfElectronCollection::const_iterator const_iterator;
01503          const_iterator iter = offCollEle_->begin();
01504          for (int count = 0; count < i; count++) iter++;
01505 
01506 
01507          NL1Off++;
01508          v_->getOffEtL1OffHisto()->Fill(iter->superCluster()->energy()*sin(iter->superCluster()->position().Theta()));
01509          if(iter->pt() >= thresholdFactor_*v_->getHltThreshold())
01510          v_->getOffEtaVsOffPhiL1OffHisto()->Fill(iter->eta(),iter->phi());
01511 
01512       }
01513       else if( offColl_.isValid()) {
01514 
01515          typedef typename T::const_iterator const_iterator;
01516          const_iterator iter = offColl_->begin();
01517          for (int count = 0; count < i; count++) iter++;
01518 
01519 
01520          NL1Off++;
01521          v_->getOffEtL1OffHisto()->Fill(iter->pt());
01522          if(iter->pt() >= thresholdFactor_*v_->getHltThreshold())
01523          v_->getOffEtaVsOffPhiL1OffHisto()->Fill(iter->eta(),iter->phi());
01524 
01525       }
01526 
01527   }
01528 
01529   if(NL1Off > 0) v_->getNL1OffHisto()->Fill(NL1Off);
01530 
01531 }
01532 
01533 
01534 template <class T> 
01535 void objMonData<T>::fillOnOffMatch(FourVectorHLTOffline* fv)
01536 {
01537 
01538   unsigned int NOnOff=0;
01539 
01540   // clean the set L1-Off
01541   if(OnOffDRMatchSet.size() > 1){
01542   
01543     LogDebug("FourVectorHLTOffline") << " Cleaning OnOff mmset" << std::endl;
01544     fv->cleanDRMatchSet(OnOffDRMatchSet);
01545 
01546   }
01547   // now fill histos
01548   for ( mmset::iterator setIter = OnOffDRMatchSet.begin( ); setIter != OnOffDRMatchSet.end( ); setIter++ ) 
01549   {
01550 
01551 
01552        fimmap tempMap = *setIter;
01553          
01554        fimmap::iterator it = tempMap.begin(); 
01555        int i  = (*it).second ;
01556        float dR = (*it).first;
01557        v_->getOffDROnOffHisto()->Fill(dR);
01558        
01559 
01560        if (dR > DRMatch_) continue;
01561 
01562        if( offCollB_.isValid()) {
01563 
01564 
01565          typedef typename reco::JetTagCollection::const_iterator const_iterator;
01566          const_iterator iter = offCollB_->begin();
01567          for (int count = 0; count < i; count++) iter++;
01568 
01569 
01570          NOnOff++;
01571          v_->getOffEtOnOffHisto()->Fill((*iter).first->pt());
01572          if((*iter).first->pt() >= thresholdFactor_*v_->getHltThreshold())
01573          v_->getOffEtaVsOffPhiOnOffHisto()->Fill((*iter).first->eta(),(*iter).first->phi());
01574 
01575        }
01576        else if( offCollMu_.isValid() && fL2MuFlag) {
01577 
01578          typedef typename reco::MuonCollection::const_iterator const_iterator;
01579          const_iterator iter = offCollMu_->begin();
01580          for (int count = 0; count < i; count++) iter++;
01581 
01582 
01583          NOnOff++;
01584          v_->getOffEtOnOffHisto()->Fill(iter->pt());
01585          if(iter->pt() >= thresholdFactor_*v_->getHltThreshold())
01586          v_->getOffEtaVsOffPhiOnOffHisto()->Fill(iter->outerTrack()->innerPosition().eta(),iter->outerTrack()->innerPosition().phi());
01587 
01588       }
01589        else if( offCollEle_.isValid()) {
01590 
01591          typedef typename reco::GsfElectronCollection::const_iterator const_iterator;
01592          const_iterator iter = offCollEle_->begin();
01593          for (int count = 0; count < i; count++) iter++;
01594 
01595          NOnOff++;
01596          v_->getOffEtOnOffHisto()->Fill(iter->superCluster()->energy()*sin(iter->superCluster()->position().Theta()));
01597          if(iter->superCluster()->energy()*fabs(sin(iter->superCluster()->position().Theta())) >= thresholdFactor_*v_->getHltThreshold())
01598          v_->getOffEtaVsOffPhiOnOffHisto()->Fill(iter->eta(),iter->phi());
01599 
01600        }
01601        else if( offColl_.isValid()) {
01602 
01603          typedef typename T::const_iterator const_iterator;
01604          const_iterator iter = offColl_->begin();
01605          for (int count = 0; count < i; count++) iter++;
01606 
01607          NOnOff++;
01608          v_->getOffEtOnOffHisto()->Fill(iter->pt());
01609          if(iter->pt() >= thresholdFactor_*v_->getHltThreshold())
01610          v_->getOffEtaVsOffPhiOnOffHisto()->Fill(iter->eta(),iter->phi());
01611 
01612        }
01613 
01614   }
01615 
01616   v_->getNOnOffHisto()->Fill(NOnOff);
01617 
01618 }
01619 
01620 
01621 template <class T> 
01622 void objMonData<T>::fillOnL1Match(const int l1Index, FourVectorHLTOffline* fv)
01623 {
01624 
01625   const trigger::TriggerObjectCollection & toc(fv->fTriggerObj->getObjects());
01626         const trigger::Keys & l1k = fv->fTriggerObj->filterKeys(l1Index);
01627 
01628   unsigned int NOnL1=0;
01629 
01630   // clean the set On-L1
01631   if(OnL1DRMatchSet.size() > 1) {
01632   
01633     LogDebug("FourVectorHLTOffline") << " Cleaning L1On mmset" << std::endl;
01634     fv->cleanDRMatchSet(OnL1DRMatchSet);
01635 
01636   }
01637   // now fill histos
01638   for ( mmset::iterator setIter = OnL1DRMatchSet.begin( ); setIter != OnL1DRMatchSet.end( ); setIter++ ) 
01639   {
01640 
01641     fimmap tempMap = *setIter;
01642       
01643     fimmap::iterator it = tempMap.begin(); 
01644     int i  = (*it).second ;
01645     float dR = (*it).first;
01646     v_->getL1DROnL1Histo()->Fill(dR);
01647 
01648     if (dR > L1DRMatch_) continue;
01649 
01650     trigger::Keys::const_iterator l1ki = l1k.begin();
01651     for (int count = 0; count < i; count++) l1ki++;
01652 
01653     NOnL1++;
01654     v_->getL1EtL1OnHisto()->Fill(toc[*l1ki].pt());
01655     v_->getL1EtaVsL1PhiL1OnHisto()->Fill(toc[*l1ki].eta(),toc[*l1ki].phi());
01656 
01657   }
01658 
01659   v_->getNL1OnHisto()->Fill(NOnL1);
01660 
01661 }
01662 
01663 template <class T> 
01664 void objMonData<T>::fillOnlineMatch(const int l1Index, FourVectorHLTOffline* fv)
01665 {
01666 
01667   if(! isTriggerType(v_->getObjectType()) ) return;
01668   fillOnOffMatch(fv);
01669 
01670   if ( l1Index >= fv->fTriggerObj->sizeFilters() ) return;
01671   fillOnL1Match(l1Index, fv);
01672 
01673 }
01674 
01675 template <class T> 
01676 void objMonData<T>::fillL1Match(FourVectorHLTOffline* fv)
01677 {
01678 
01679   fillL1OffMatch(fv);
01680 
01681 }
01682 
01683 template <class T> 
01684 void objMonData<T>::clearSets()
01685 {
01686 
01687    L1OffDRMatchSet.clear();
01688    L1MCDRMatchSet.clear();
01689    OnOffDRMatchSet.clear();
01690    OnMCDRMatchSet.clear();
01691    OnL1DRMatchSet.clear();
01692    OffMCDRMatchSet.clear();
01693 
01694 }
01695 
01696 
01697 
01698 #endif