CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/DQM/HLTEvF/interface/FourVectorHLTOnline.h

Go to the documentation of this file.
00001 #ifndef FOURVECTORHLTONLINE_H
00002 #define FOURVECTORHLTONLINE_H
00003 // -*- C++ -*-
00004 //
00005 // Package:    FourVectorHLTOnline
00006 // Class:      FourVectorHLTOnline
00007 // 
00016 //
00017 // Original Author:  Jeffrey Berryhill
00018 //         Created:  June 2008
00019 // Rewritten by: Vladimir Rekovic
00020 //         Date:  May 2009
00021 //
00022 // $Id: FourVectorHLTOnline.h,v 1.17 2010/03/25 15:03:37 rekovic Exp $
00023 //
00024 //
00025 
00026 // system include files
00027 #include <memory>
00028 #include <unistd.h>
00029 
00030 
00031 // user include files
00032 #include "FWCore/Framework/interface/Frameworkfwd.h"
00033 #include "FWCore/Framework/interface/EDAnalyzer.h"
00034 
00035 #include "FWCore/Framework/interface/Event.h"
00036 #include "FWCore/Framework/interface/MakerMacros.h"
00037 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
00038 #include "DataFormats/Common/interface/TriggerResults.h"
00039 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.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/HLTReco/interface/TriggerTypeDefs.h"
00058 
00059 #include "DataFormats/Math/interface/deltaR.h"
00060 
00061 #include "DQMServices/Core/interface/MonitorElement.h"
00062 
00063 
00064 
00065 #include <iostream>
00066 #include <fstream>
00067 #include <vector>
00068 
00069 namespace edm {
00070    class TriggerNames;
00071 }
00072 
00073 typedef std::multimap<float,int> fimmap ;
00074 typedef std::set<fimmap , std::less<fimmap> > mmset;
00075 
00076 class FourVectorHLTOnline : public edm::EDAnalyzer {
00077 
00078    public:
00079       explicit FourVectorHLTOnline(const edm::ParameterSet&);
00080       ~FourVectorHLTOnline();
00081 
00082       void cleanDRMatchSet(mmset& tempSet);
00083 
00084       edm::Handle<trigger::TriggerEvent> fTriggerObj;
00085 
00086    private:
00087       virtual void beginJob() ;
00088       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00089       virtual void endJob() ;
00090 
00091       // BeginRun
00092       void beginRun(const edm::Run& run, const edm::EventSetup& c);
00093 
00094       // EndRun
00095       void endRun(const edm::Run& run, const edm::EventSetup& c);
00096       void fillHltMatrix(const edm::TriggerNames & triggerNames);
00097       void setupHltMatrix(std::string label, std::vector<std::string>  paths);
00098 
00099       void setupHltLsPlots();
00100       void setupHltBxPlots();
00101       void countHLTPathHitsEndLumiBlock(const int& lumi);
00102       void countHLTGroupHitsEndLumiBlock(const int& lumi);
00103       void countHLTGroupL1HitsEndLumiBlock(const int& lumi);
00104       void countHLTGroupBXHitsEndLumiBlock(const int& lumi);
00105       int getTriggerTypeParsePathName(const std::string& pathname);
00106       const std::string getL1ConditionModuleName(const std::string& pathname);
00107       bool hasL1Passed(const std::string& pathname, const edm::TriggerNames & triggerNames);
00108       bool hasHLTPassed(const std::string& pathname, const edm::TriggerNames& triggerNames);
00109 
00110       void beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c);   
00111       void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c);   
00112 
00113       // ----------member data --------------------------- 
00114       int nev_;
00115       DQMStore * dbe_;
00116       bool fLumiFlag;
00117 
00118       /*
00119       MonitorElement* total_;
00120       MonitorElement* ME_HLTPassPass_;
00121       MonitorElement* ME_HLTPassPass_Normalized_;
00122       MonitorElement* ME_HLTPass_Normalized_Any_;
00123       MonitorElement* ME_HLTPassFail_;
00124       MonitorElement* ME_HLTPassFail_Normalized_;
00125 
00126       std::vector<MonitorElement*> v_ME_HLTPassPass_;
00127       std::vector<MonitorElement*> v_ME_HLTPassPass_Normalized_;
00128       std::vector<MonitorElement*> v_ME_HLTPass_Normalized_Any_;
00129       */
00130 
00131       MonitorElement* ME_HLTAll_LS_;
00132       MonitorElement* ME_HLT_BX_;
00133       MonitorElement* ME_HLT_CUSTOM_BX_;
00134       std::vector<MonitorElement*> v_ME_HLTAll_LS_;
00135 
00136       std::string pathsSummaryFolder_;
00137       std::string pathsSummaryHLTCorrelationsFolder_;
00138       std::string pathsSummaryFilterEfficiencyFolder_;
00139       std::string pathsSummaryFilterCountsFolder_;
00140       std::string pathsSummaryHLTPathsPerLSFolder_;
00141       std::string pathsIndividualHLTPathsPerLSFolder_;
00142       std::string pathsSummaryHLTPathsPerBXFolder_;
00143       std::string fCustomBXPath;
00144 
00145       std::vector<std::string> fGroupName;
00146 
00147       unsigned int nLS_; 
00148       unsigned int referenceBX_; 
00149       unsigned int Nbx_; 
00150 
00151       bool plotAll_;
00152       bool resetMe_;
00153       int currentRun_;
00154       
00155       unsigned int nBins_; 
00156       unsigned int nBinsOneOverEt_; 
00157       double ptMin_ ;
00158       double ptMax_ ;
00159       
00160       double electronEtaMax_;
00161       double electronEtMin_;
00162       double electronDRMatch_;
00163       double muonEtaMax_;
00164       double muonEtMin_;
00165       double muonDRMatch_;
00166       double tauEtaMax_;
00167       double tauEtMin_;
00168       double tauDRMatch_;
00169       double jetEtaMax_;
00170       double jetEtMin_;
00171       double jetDRMatch_;
00172       double bjetEtaMax_;
00173       double bjetEtMin_;
00174       double bjetDRMatch_;
00175       double photonEtaMax_;
00176       double photonEtMin_;
00177       double photonDRMatch_;
00178       double trackEtaMax_;
00179       double trackEtMin_;
00180       double trackDRMatch_;
00181       double metEtaMax_;
00182       double metMin_;
00183       double metDRMatch_;
00184       double htEtaMax_;
00185       double htMin_;
00186       double htDRMatch_;
00187       double sumEtMin_;
00188 
00189       std::vector<std::pair<std::string, std::string> > custompathnamepairs_;
00190 
00191       std::vector <std::vector <std::string> > triggerFilters_;
00192       std::vector <std::vector <uint> > triggerFilterIndices_;
00193       std::vector <std::pair<std::string, int> > fPathTempCountPair;
00194       std::vector <std::pair<std::string, std::vector<int> > > fPathBxTempCountPair;
00195       std::vector <std::pair<std::string, int> > fGroupTempCountPair;
00196       std::vector <std::pair<std::string, int> > fGroupL1TempCountPair;
00197       std::vector <std::pair<std::string, std::vector<std::string> > > fGroupNamePathsPair;
00198 
00199       std::vector<std::string> specialPaths_;
00200 
00201       std::string dirname_;
00202       std::string processname_;
00203       std::string muonRecoCollectionName_;
00204       bool monitorDaemon_;
00205       int theHLTOutputType;
00206       edm::InputTag triggerSummaryLabel_;
00207       edm::InputTag triggerResultsLabel_;
00208       HLTConfigProvider hltConfig_;
00209       // data across paths
00210       MonitorElement* scalersSelect;
00211       // helper class to store the data path
00212 
00213       edm::Handle<edm::TriggerResults> triggerResults_;
00214 
00215       class PathInfo {
00216 
00217        PathInfo():
00218         pathIndex_(-1), denomPathName_("unset"), pathName_("unset"), l1pathName_("unset"), filterName_("unset"), processName_("unset"), objectType_(-1) {};
00219 
00220        public:
00221 
00222           void setFilterHistos(MonitorElement* const filters) 
00223           {
00224               filters_   =  filters;
00225           }
00226 
00227           void setHistos(
00228 
00229             MonitorElement* const NOn, 
00230             MonitorElement* const onEtOn, 
00231             MonitorElement* const onOneOverEtOn, 
00232             MonitorElement* const onEtavsonPhiOn,  
00233             MonitorElement* const NOff, 
00234             MonitorElement* const offEtOff, 
00235             MonitorElement* const offEtavsoffPhiOff,
00236             MonitorElement* const NL1, 
00237             MonitorElement* const l1EtL1, 
00238             MonitorElement* const l1Etavsl1PhiL1,
00239             MonitorElement* const NL1On, 
00240             MonitorElement* const l1EtL1On, 
00241             MonitorElement* const l1Etavsl1PhiL1On,
00242             MonitorElement* const NL1Off,   
00243             MonitorElement* const offEtL1Off, 
00244             MonitorElement* const offEtavsoffPhiL1Off,
00245             MonitorElement* const NOnOff, 
00246             MonitorElement* const offEtOnOff, 
00247             MonitorElement* const offEtavsoffPhiOnOff,
00248             MonitorElement* const NL1OnUM, 
00249             MonitorElement* const l1EtL1OnUM, 
00250             MonitorElement* const l1Etavsl1PhiL1OnUM,
00251             MonitorElement* const NL1OffUM,   
00252             MonitorElement* const offEtL1OffUM, 
00253             MonitorElement* const offEtavsoffPhiL1OffUM,
00254             MonitorElement* const NOnOffUM, 
00255             MonitorElement* const offEtOnOffUM, 
00256             MonitorElement* const offEtavsoffPhiOnOffUM,
00257             MonitorElement* const offDRL1Off, 
00258             MonitorElement* const offDROnOff, 
00259             MonitorElement* const l1DRL1On)  
00260          {
00261 
00262               NOn_ = NOn;
00263               onEtOn_ = onEtOn;
00264               onOneOverEtOn_ = onOneOverEtOn;
00265               onEtavsonPhiOn_ = onEtavsonPhiOn;
00266               NOff_ = NOff;
00267               offEtOff_ = offEtOff;
00268               offEtavsoffPhiOff_ = offEtavsoffPhiOff;
00269               NL1_ = NL1;
00270               l1EtL1_ = l1EtL1;
00271               l1Etavsl1PhiL1_ = l1Etavsl1PhiL1;
00272               NL1On_ = NL1On;
00273               l1EtL1On_ = l1EtL1On;
00274               l1Etavsl1PhiL1On_ = l1Etavsl1PhiL1On;
00275               NL1Off_ = NL1Off;
00276               offEtL1Off_ = offEtL1Off;
00277               offEtavsoffPhiL1Off_ = offEtavsoffPhiL1Off;
00278               NOnOff_ = NOnOff;
00279               offEtOnOff_ = offEtOnOff;
00280               offEtavsoffPhiOnOff_ = offEtavsoffPhiOnOff;
00281               NL1OnUM_ = NL1OnUM;
00282               l1EtL1OnUM_ = l1EtL1OnUM;
00283               l1Etavsl1PhiL1OnUM_ = l1Etavsl1PhiL1OnUM;
00284               NL1OffUM_ = NL1OffUM;
00285               offEtL1OffUM_ = offEtL1OffUM;
00286               offEtavsoffPhiL1OffUM_ = offEtavsoffPhiL1OffUM;
00287               NOnOffUM_ = NOnOffUM;
00288               offEtOnOffUM_ = offEtOnOffUM;
00289               offEtavsoffPhiOnOffUM_ = offEtavsoffPhiOnOffUM;
00290               offDRL1Off_ =  offDRL1Off; 
00291               offDROnOff_ =  offDROnOff; 
00292               l1DRL1On_   =  l1DRL1On;
00293 
00294          }
00295 
00296          MonitorElement * getNOnHisto() {
00297           return NOn_;
00298          }
00299          MonitorElement * getOnEtOnHisto() {
00300            return onEtOn_;
00301          }
00302          MonitorElement * getOnOneOverEtOnHisto() {
00303            return onOneOverEtOn_;
00304          }
00305          MonitorElement * getOnEtaVsOnPhiOnHisto() {
00306            return onEtavsonPhiOn_;
00307          }
00308          MonitorElement * getNOffHisto() {
00309            return NOff_;
00310          }
00311          MonitorElement * getOffEtOffHisto() {
00312            return offEtOff_;
00313          }
00314          MonitorElement * getOffEtaVsOffPhiOffHisto() {
00315            return offEtavsoffPhiOff_;
00316          }
00317          MonitorElement * getNL1Histo() {
00318            return NL1_;
00319          }
00320          MonitorElement * getL1EtL1Histo() {
00321            return l1EtL1_;
00322          }
00323          MonitorElement * getL1EtaVsL1PhiL1Histo() {
00324            return l1Etavsl1PhiL1_;
00325          }
00326          MonitorElement * getNL1OnHisto() {
00327            return NL1On_;
00328          }
00329          MonitorElement * getL1EtL1OnHisto() {
00330            return l1EtL1On_;
00331          }
00332          MonitorElement * getL1EtaVsL1PhiL1OnHisto() {
00333            return l1Etavsl1PhiL1On_;
00334          }
00335          MonitorElement * getNL1OffHisto() {
00336            return NL1Off_;
00337          }
00338          MonitorElement * getOffEtL1OffHisto() {
00339            return offEtL1Off_;
00340          }
00341          MonitorElement * getOffEtaVsOffPhiL1OffHisto() {
00342            return offEtavsoffPhiL1Off_;
00343          }
00344          MonitorElement * getNOnOffHisto() {
00345            return NOnOff_;
00346          }
00347          MonitorElement * getOffEtOnOffHisto() {
00348            return offEtOnOff_;
00349          }
00350          MonitorElement * getOffEtaVsOffPhiOnOffHisto() {
00351            return offEtavsoffPhiOnOff_;
00352          }
00353          MonitorElement * getNL1OnUMHisto() {
00354            return NL1OnUM_;
00355          }
00356          MonitorElement * getL1EtL1OnUMHisto() {
00357            return l1EtL1OnUM_;
00358          }
00359          MonitorElement * getL1EtaVsL1PhiL1OnUMHisto() {
00360            return l1Etavsl1PhiL1OnUM_;
00361          }
00362          MonitorElement * getNL1OffUMHisto() {
00363            return NL1OffUM_;
00364          }
00365          MonitorElement * getOffEtL1OffUMHisto() {
00366            return offEtL1OffUM_;
00367          }
00368          MonitorElement * getOffEtaVsOffPhiL1OffUMHisto() {
00369            return offEtavsoffPhiL1OffUM_;
00370          }
00371          MonitorElement * getNOnOffUMHisto() {
00372            return NOnOffUM_;
00373          }
00374          MonitorElement * getOffEtOnOffUMHisto() {
00375            return offEtOnOffUM_;
00376          }
00377          MonitorElement * getOffEtaVsOffPhiOnOffUMHisto() {
00378            return offEtavsoffPhiOnOffUM_;
00379          }
00380          MonitorElement * getOffDRL1OffHisto() {
00381            return offDRL1Off_;
00382          }
00383          MonitorElement * getOffDROnOffHisto() {
00384            return offDROnOff_;
00385          }
00386          MonitorElement * getL1DROnL1Histo() {
00387            return l1DRL1On_;
00388          }
00389          MonitorElement * getFiltersHisto() {
00390            return filters_;
00391          }
00392          const std::string getLabel(void ) const {
00393            return filterName_;
00394          }
00395          void setLabel(std::string labelName){
00396            filterName_ = labelName;
00397            return;
00398          }
00399          const std::string getPath(void ) const {
00400            return pathName_;
00401          }
00402          const std::string getl1Path(void ) const {
00403            return l1pathName_;
00404          }
00405          const std::string getDenomPath(void ) const {
00406            return denomPathName_;
00407          }
00408          const std::string getProcess(void ) const {
00409            return processName_;
00410          }
00411          const int getObjectType(void ) const {
00412            return objectType_;
00413          }
00414 
00415         const edm::InputTag getTag(void) const{
00416           edm::InputTag tagName(filterName_,"",processName_);
00417           return tagName;
00418         }
00419 
00420         ~PathInfo() {};
00421 
00422         PathInfo(std::string denomPathName, std::string pathName, std::string l1pathName, std::string filterName, std::string processName, size_t type, float ptmin, float ptmax):
00423 
00424           denomPathName_(denomPathName), 
00425           pathName_(pathName), 
00426           l1pathName_(l1pathName), 
00427           filterName_(filterName), 
00428           processName_(processName), 
00429           objectType_(type),
00430           NOn_(0), onEtOn_(0), onOneOverEtOn_(0), onEtavsonPhiOn_(0), 
00431           NOff_(0), offEtOff_(0), offEtavsoffPhiOff_(0),
00432           NL1_(0), l1EtL1_(0), l1Etavsl1PhiL1_(0),
00433           NL1On_(0), l1EtL1On_(0), l1Etavsl1PhiL1On_(0),
00434           NL1Off_(0), offEtL1Off_(0), offEtavsoffPhiL1Off_(0),
00435           NOnOff_(0), offEtOnOff_(0), offEtavsoffPhiOnOff_(0),
00436           NL1OnUM_(0), l1EtL1OnUM_(0), l1Etavsl1PhiL1OnUM_(0),
00437           NL1OffUM_(0), offEtL1OffUM_(0), offEtavsoffPhiL1OffUM_(0),
00438           NOnOffUM_(0), offEtOnOffUM_(0), offEtavsoffPhiOnOffUM_(0),
00439           offDRL1Off_(0), offDROnOff_(0), l1DRL1On_(0), filters_(0),
00440           ptmin_(ptmin), ptmax_(ptmax)
00441 
00442         {
00443         };
00444 
00445         PathInfo(std::string denomPathName, std::string pathName, std::string l1pathName, std::string filterName, std::string processName, size_t type,
00446           MonitorElement *NOn,
00447           MonitorElement *onEtOn,
00448           MonitorElement *onOneOverEtOn,
00449           MonitorElement *onEtavsonPhiOn,
00450           MonitorElement *NOff,
00451           MonitorElement *offEtOff,
00452           MonitorElement *offEtavsoffPhiOff,
00453           MonitorElement *NL1,
00454           MonitorElement *l1EtL1,
00455           MonitorElement *l1Etavsl1PhiL1,
00456           MonitorElement *NL1On,
00457           MonitorElement *l1EtL1On,
00458           MonitorElement *l1Etavsl1PhiL1On,
00459           MonitorElement *NL1Off,
00460           MonitorElement *offEtL1Off,
00461           MonitorElement *offEtavsoffPhiL1Off,
00462           MonitorElement *NOnOff,
00463           MonitorElement *offEtOnOff,
00464           MonitorElement *offEtavsoffPhiOnOff,
00465           MonitorElement *NL1OnUM,
00466           MonitorElement *l1EtL1OnUM,
00467           MonitorElement *l1Etavsl1PhiL1OnUM,
00468           MonitorElement *NL1OffUM,
00469           MonitorElement *offEtL1OffUM,
00470           MonitorElement *offEtavsoffPhiL1OffUM,
00471           MonitorElement *NOnOffUM,
00472           MonitorElement *offEtOnOffUM,
00473           MonitorElement *offEtavsoffPhiOnOffUM,
00474           MonitorElement *offDRL1Off, 
00475           MonitorElement *offDROnOff, 
00476           MonitorElement *l1DRL1On,
00477           MonitorElement *filters,
00478           float ptmin, float ptmax
00479           ):
00480 
00481             denomPathName_(denomPathName), 
00482             pathName_(pathName), l1pathName_(l1pathName), 
00483             filterName_(filterName), processName_(processName), objectType_(type),
00484             NOn_(NOn), onEtOn_(onEtOn), onOneOverEtOn_(onOneOverEtOn), onEtavsonPhiOn_(onEtavsonPhiOn), 
00485             NOff_(NOff), offEtOff_(offEtOff), offEtavsoffPhiOff_(offEtavsoffPhiOff),
00486             NL1_(NL1), l1EtL1_(l1EtL1), l1Etavsl1PhiL1_(l1Etavsl1PhiL1),
00487             NL1On_(NL1On), l1EtL1On_(l1EtL1On), l1Etavsl1PhiL1On_(l1Etavsl1PhiL1On),
00488             NL1Off_(NL1Off), offEtL1Off_(offEtL1Off), offEtavsoffPhiL1Off_(offEtavsoffPhiL1Off),
00489             NOnOff_(NOnOff), offEtOnOff_(offEtOnOff), offEtavsoffPhiOnOff_(offEtavsoffPhiOnOff),
00490             NL1OnUM_(NL1OnUM), l1EtL1OnUM_(l1EtL1OnUM), l1Etavsl1PhiL1OnUM_(l1Etavsl1PhiL1OnUM),
00491             NL1OffUM_(NL1OffUM), offEtL1OffUM_(offEtL1OffUM), offEtavsoffPhiL1OffUM_(offEtavsoffPhiL1OffUM),
00492             NOnOffUM_(NOnOffUM), offEtOnOffUM_(offEtOnOffUM), offEtavsoffPhiOnOffUM_(offEtavsoffPhiOnOffUM),
00493             offDRL1Off_(offDRL1Off), 
00494             offDROnOff_(offDROnOff), 
00495             l1DRL1On_(l1DRL1On),
00496             filters_(filters),
00497             ptmin_(ptmin), ptmax_(ptmax)
00498         {
00499         };
00500 
00501         bool operator==(const std::string& v) 
00502         {
00503           return v==filterName_;
00504         }
00505 
00506         bool operator!=(const std::string& v) 
00507         {
00508           return v!=filterName_;
00509         }
00510 
00511         float getPtMin() const { return ptmin_; }
00512         float getPtMax() const { return ptmax_; }
00513 
00514         std::vector< std::pair<std::string,unsigned int> > filtersAndIndices;
00515 
00516 
00517       private:
00518 
00519         int pathIndex_;
00520         std::string denomPathName_;
00521         std::string pathName_;
00522         std::string l1pathName_;
00523         std::string filterName_;
00524         std::string processName_;
00525         int objectType_;
00526         
00527         // we don't own this data
00528         MonitorElement *NOn_, *onEtOn_, *onOneOverEtOn_, *onEtavsonPhiOn_;
00529         MonitorElement *NOff_, *offEtOff_, *offEtavsoffPhiOff_;
00530         MonitorElement *NL1_, *l1EtL1_, *l1Etavsl1PhiL1_;
00531         MonitorElement *NL1On_, *l1EtL1On_, *l1Etavsl1PhiL1On_;
00532         MonitorElement *NL1Off_, *offEtL1Off_, *offEtavsoffPhiL1Off_;
00533         MonitorElement *NOnOff_, *offEtOnOff_, *offEtavsoffPhiOnOff_;
00534         MonitorElement *NL1OnUM_, *l1EtL1OnUM_, *l1Etavsl1PhiL1OnUM_;
00535         MonitorElement *NL1OffUM_, *offEtL1OffUM_, *offEtavsoffPhiL1OffUM_;
00536         MonitorElement *NOnOffUM_, *offEtOnOffUM_, *offEtavsoffPhiOnOffUM_;
00537         MonitorElement *offDRL1Off_, *offDROnOff_, *l1DRL1On_;
00538         MonitorElement *filters_;
00539         
00540         float ptmin_, ptmax_;
00541         
00542         const int index() { 
00543           return pathIndex_;
00544         }
00545         const int type() { 
00546           return objectType_;
00547         }
00548 
00549 
00550      };
00551      
00552 
00553    public:
00554 
00555      // simple collection - just 
00556      class PathInfoCollection: public std::vector<PathInfo> {
00557        public:
00558 
00559          PathInfoCollection(): std::vector<PathInfo>() 
00560         {};
00561          std::vector<PathInfo>::iterator find(std::string pathName) {
00562             return std::find(begin(), end(), pathName);
00563          }
00564       };
00565 
00566       PathInfoCollection hltPaths_;
00567 
00568       PathInfoCollection hltPathsDiagonal_;
00569 
00570 };
00571 
00572 
00573 class BaseMonitor
00574 {
00575   public:
00576     virtual void clearSets( void ) = 0;
00577     virtual void setPath(FourVectorHLTOnline::PathInfoCollection::iterator v) = 0;
00578     virtual void monitorL1( const int l1Index, FourVectorHLTOnline* fv) = 0;
00579     virtual void monitorOnline(const int hltIndex, const int l1Index, FourVectorHLTOnline* fv) = 0;
00580 
00581     virtual void matchOnlineL1(const trigger::TriggerObject& onlineFV, const int& l1Index, FourVectorHLTOnline* fv, const int& NOn) = 0;
00582 
00583     virtual void fillOnlineMatch(const int l1Index, FourVectorHLTOnline* fv) = 0;
00584 
00585     virtual bool isTriggerType(int t) = 0;
00586     virtual ~BaseMonitor(){}
00587 
00588 };
00589 
00590 template <class T> 
00591 class objMonData:public BaseMonitor {
00592 public:
00593     objMonData() { EtaMax_= 2.5; EtMin_=3.0; GenJetsFlag_ = false; BJetsFlag_ = false; }
00594     void setLimits(float etaMax, float etMin, float drMatch) 
00595     {
00596      EtaMax_= etaMax; 
00597      EtMin_= etMin; 
00598      DRMatch_= drMatch;
00599     }
00600     void setTriggerType(std::vector<int> trigType) { triggerType_ = trigType; }
00601     void pushTriggerType(int trigType) { triggerType_.push_back(trigType); }
00602     void setL1TriggerType(std::vector<int> trigType) { l1triggerType_ = trigType; }
00603     void pushL1TriggerType(int trigType) { l1triggerType_.push_back(trigType); }
00604     void setPath(FourVectorHLTOnline::PathInfoCollection::iterator v) { v_ = v; }
00605     void setReco(edm::Handle<T> offColl) { offColl_ = offColl; }
00606 
00607 
00608     // Monitor methods
00609 
00610     void monitorL1(const int l1Index, FourVectorHLTOnline* fv);
00611     void monitorOnline(const int hltIndex, const int l1Index, FourVectorHLTOnline* fv);
00612     void matchOnlineL1(const trigger::TriggerObject& onlineFV, const int& l1Index, FourVectorHLTOnline* fv, const int& NOn);
00613     void fillOnlineMatch(const int l1Index, FourVectorHLTOnline* fv);
00614     void fillOnL1Match(const int l1Index, FourVectorHLTOnline* fv);
00615 
00616     void clearSets();
00617 
00618     bool isTriggerType(int t);
00619     bool isL1TriggerType(int t);
00620 
00621     mmset L1OffDRMatchSet;
00622     mmset L1MCDRMatchSet;
00623     mmset OnOffDRMatchSet;
00624     mmset OnMCDRMatchSet;
00625     mmset OnL1DRMatchSet;
00626     mmset OffMCDRMatchSet;
00627 
00628 
00629     void setBJetsFlag(bool flag) 
00630     { 
00631       BJetsFlag_ = flag; 
00632     }
00633     
00634 
00635 private:
00636 
00637     int   pdgId_;
00638     int   pdgStatus_;
00639 
00640     float EtaMax_;
00641     float EtMin_;
00642 
00643     float DRMatch_;
00644 
00645     bool GenJetsFlag_;
00646     bool BJetsFlag_;
00647 
00648     std::vector<int> triggerType_;
00649     std::vector<int> l1triggerType_;
00650 
00651     edm::Handle<T> offColl_;
00652 
00653     FourVectorHLTOnline::PathInfoCollection::iterator v_;
00654 
00655 };
00656 
00657 
00658 template <class T> 
00659 bool objMonData<T>::isTriggerType(int t)
00660 {
00661   bool rc = false;
00662 
00663   for(std::vector<int>::const_iterator it = triggerType_.begin(); it != triggerType_.end(); ++it)
00664   {
00665 
00666    if(t == *it) { rc = true; break; }
00667 
00668   } // end for
00669 
00670   if (t==0) rc = true;
00671 
00672   return rc;
00673 
00674 }
00675 
00676 
00677 template <class T> 
00678 bool objMonData<T>::isL1TriggerType(int t)
00679 {
00680   bool rc = false;
00681 
00682   for(std::vector<int>::const_iterator it = l1triggerType_.begin(); it != l1triggerType_.end(); ++it)
00683   {
00684 
00685    if(fabs(t) == fabs(*it)) { rc = true; break; }
00686 
00687   } // end for
00688 
00689   return rc;
00690 
00691 }
00692 
00693 
00694 template <class T> 
00695 void objMonData<T>::monitorL1(const int l1Index, FourVectorHLTOnline* fv)
00696 {
00697 
00698   if ( l1Index >= fv->fTriggerObj->sizeFilters() ) return;
00699 
00700   unsigned int NL1=0;
00701   unsigned int NL1OffUM=0;
00702 
00703   const trigger::TriggerObjectCollection & toc(fv->fTriggerObj->getObjects());
00704         const trigger::Vids & idtype = fv->fTriggerObj->filterIds(l1Index);
00705         const trigger::Keys & l1k = fv->fTriggerObj->filterKeys(l1Index);
00706         bool l1accept = l1k.size() > 0;
00707 
00708   if(!l1accept) return;
00709 
00710   trigger::Vids::const_iterator idtypeiter = idtype.begin(); 
00711 
00712   for (trigger::Keys::const_iterator l1ki = l1k.begin(); l1ki !=l1k.end(); ++l1ki ) {
00713 
00714    trigger::TriggerObject l1FV = toc[*l1ki];
00715    if(isL1TriggerType(*idtypeiter))
00716    {
00717 
00718 
00719 
00720       if (fabs(l1FV.eta()) <= EtaMax_ && l1FV.pt() >= EtMin_)
00721       { 
00722 
00723         NL1++;
00724 
00725         v_->getL1EtL1Histo()->Fill(l1FV.pt());
00726         v_->getL1EtaVsL1PhiL1Histo()->Fill(l1FV.eta(), l1FV.phi());
00727 
00728       }
00729       else {
00730 
00731         continue;
00732 
00733       }
00734 
00735      } // end if isL1TriggerType
00736      ++idtypeiter;
00737 
00738  } // end for l1ki
00739 
00740  if(NL1 > 0) v_->getNL1Histo()->Fill(NL1);
00741  if(NL1OffUM > 0) v_->getNL1OffUMHisto()->Fill(NL1OffUM);
00742 
00743 }
00744 
00745 
00746 template <class T> 
00747 void objMonData<T>::monitorOnline(const int hltIndex, const int l1Index, FourVectorHLTOnline* fv)
00748 {
00749 
00750   //if(! isTriggerType(v_->getObjectType()) ) return;
00751 
00752   // Get keys of objects passed by the last filter
00753   const trigger::Keys & k = fv->fTriggerObj->filterKeys(hltIndex);
00754 
00755   const trigger::TriggerObjectCollection & toc(fv->fTriggerObj->getObjects());
00756 
00757   unsigned int NOn=0;
00758 
00759   // Loop over HLT objects
00760   for (trigger::Keys::const_iterator ki = k.begin(); ki !=k.end(); ++ki ) {
00761 
00762           trigger::TriggerObject onlineFV = toc[*ki];
00763         
00764           if (fabs(onlineFV.eta()) <= EtaMax_ && onlineFV.pt() >= EtMin_)
00765           { 
00766         
00767             NOn++;    
00768         
00769             v_->getOnEtOnHisto()->Fill(onlineFV.pt());
00770             v_->getOnOneOverEtOnHisto()->Fill(1./onlineFV.pt());
00771             v_->getOnEtaVsOnPhiOnHisto()->Fill(onlineFV.eta(), onlineFV.phi());
00772         
00773           }
00774           else {
00775         
00776             return;
00777         
00778           }
00779 
00780     matchOnlineL1(onlineFV,l1Index, fv, NOn);
00781 
00782   } // end loop over HLT objects
00783   
00784   if(NOn>0) v_->getNOnHisto()->Fill(NOn);
00785 
00786 }
00787 
00788 template <class T> 
00789 void objMonData<T>::matchOnlineL1(const trigger::TriggerObject& onlineFV, const int& l1Index, FourVectorHLTOnline* fv, const int& NOn)
00790 {
00791 
00792   if ( l1Index >= fv->fTriggerObj->sizeFilters() ) return;
00793 
00794   unsigned int NOnL1UM=0;
00795 
00796   const trigger::TriggerObjectCollection & toc(fv->fTriggerObj->getObjects());
00797         const trigger::Vids & idtype = fv->fTriggerObj->filterIds(l1Index);
00798         const trigger::Keys & l1k = fv->fTriggerObj->filterKeys(l1Index);
00799 
00800   fimmap OnL1DRMatchMap;
00801   int j=0;
00802   trigger::Vids::const_iterator idtypeiter = idtype.begin(); 
00803   for (trigger::Keys::const_iterator l1ki = l1k.begin(); l1ki !=l1k.end(); ++l1ki ) 
00804   {
00805 
00806       
00807 
00808       if(isL1TriggerType(*idtypeiter))
00809       {
00810 
00811         trigger::TriggerObject l1FV = toc[*l1ki];
00812 
00813         if ( fabs(l1FV.eta()) <= EtaMax_ && l1FV.pt() >= EtMin_ )
00814         {
00815 
00816            // fill UM histos (no matching required)
00817            if(NOn == 1) {
00818 
00819             NOnL1UM++;
00820             v_->getL1EtL1OnUMHisto()->Fill(l1FV.pt());
00821             v_->getL1EtaVsL1PhiL1OnUMHisto()->Fill(l1FV.eta(),l1FV.phi());
00822 
00823             }
00824 
00825 
00826             float dR = reco::deltaR(l1FV.eta(),l1FV.phi(),onlineFV.eta(),onlineFV.phi());
00827 
00828             if ( dR < 1.0) 
00829             {
00830 
00831               OnL1DRMatchMap.insert(std::pair<float,int>(dR,j));
00832 
00833             }
00834 
00835           } // end if l1FV eta, pt
00836 
00837        } // end if isL1TriggerType
00838 
00839        ++idtypeiter;
00840        j++;
00841 
00842   } // end for
00843 
00844   if(! OnL1DRMatchMap.empty()) OnL1DRMatchSet.insert(OnL1DRMatchMap);
00845 
00846 }
00847 
00848 template <class T> 
00849 void objMonData<T>::fillOnL1Match(const int l1Index, FourVectorHLTOnline* fv)
00850 {
00851 
00852   const trigger::TriggerObjectCollection & toc(fv->fTriggerObj->getObjects());
00853         const trigger::Keys & l1k = fv->fTriggerObj->filterKeys(l1Index);
00854 
00855   unsigned int NOnL1=0;
00856 
00857   // clean the set On-L1
00858   if(OnL1DRMatchSet.size() > 1) {
00859   
00860     LogDebug("FourVectorHLTOnline") << " Cleaning L1On mmset" << std::endl;
00861     fv->cleanDRMatchSet(OnL1DRMatchSet);
00862 
00863   }
00864   // now fill histos
00865   for ( mmset::iterator setIter = OnL1DRMatchSet.begin( ); setIter != OnL1DRMatchSet.end( ); setIter++ ) 
00866   {
00867 
00868     fimmap tempMap = *setIter;
00869       
00870     fimmap::iterator it = tempMap.begin(); 
00871     int i  = (*it).second ;
00872     float dR = (*it).first;
00873     v_->getL1DROnL1Histo()->Fill(dR);
00874 
00875     if (dR > DRMatch_) continue;
00876 
00877     trigger::Keys::const_iterator l1ki = l1k.begin();
00878     for (int count = 0; count < i; count++) l1ki++;
00879 
00880     NOnL1++;
00881     v_->getL1EtL1OnHisto()->Fill(toc[*l1ki].pt());
00882     v_->getL1EtaVsL1PhiL1OnHisto()->Fill(toc[*l1ki].eta(),toc[*l1ki].phi());
00883 
00884   }
00885 
00886   v_->getNL1OnHisto()->Fill(NOnL1);
00887 
00888 }
00889 
00890 template <class T> 
00891 void objMonData<T>::fillOnlineMatch(const int l1Index, FourVectorHLTOnline* fv)
00892 {
00893 
00894 
00895   if ( l1Index >= fv->fTriggerObj->sizeFilters() ) return;
00896   fillOnL1Match(l1Index, fv);
00897 
00898 }
00899 
00900 
00901 template <class T> 
00902 void objMonData<T>::clearSets()
00903 {
00904 
00905    L1OffDRMatchSet.clear();
00906    L1MCDRMatchSet.clear();
00907    OnOffDRMatchSet.clear();
00908    OnMCDRMatchSet.clear();
00909    OnL1DRMatchSet.clear();
00910    OffMCDRMatchSet.clear();
00911 
00912 }
00913 
00914 
00915 
00916 #endif