CMS 3D CMS Logo

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