CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/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.18 2011/09/20 21:49:27 slaunwhj 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           
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             NL1_(NL1), l1EtL1_(l1EtL1), l1Etavsl1PhiL1_(l1Etavsl1PhiL1),
00486             NL1On_(NL1On), l1EtL1On_(l1EtL1On), l1Etavsl1PhiL1On_(l1Etavsl1PhiL1On),
00487             NL1Off_(NL1Off), offEtL1Off_(offEtL1Off), offEtavsoffPhiL1Off_(offEtavsoffPhiL1Off),
00488             NOnOff_(NOnOff), offEtOnOff_(offEtOnOff), offEtavsoffPhiOnOff_(offEtavsoffPhiOnOff),
00489             NL1OnUM_(NL1OnUM), l1EtL1OnUM_(l1EtL1OnUM), l1Etavsl1PhiL1OnUM_(l1Etavsl1PhiL1OnUM),
00490             NL1OffUM_(NL1OffUM), offEtL1OffUM_(offEtL1OffUM), offEtavsoffPhiL1OffUM_(offEtavsoffPhiL1OffUM),
00491             NOnOffUM_(NOnOffUM), offEtOnOffUM_(offEtOnOffUM), offEtavsoffPhiOnOffUM_(offEtavsoffPhiOnOffUM),
00492             offDRL1Off_(offDRL1Off), 
00493             offDROnOff_(offDROnOff), 
00494             l1DRL1On_(l1DRL1On),
00495             filters_(filters),
00496             ptmin_(ptmin), ptmax_(ptmax)
00497         {
00498         };
00499 
00500         bool operator==(const std::string& v) 
00501         {
00502           return v==filterName_;
00503         }
00504 
00505         bool operator!=(const std::string& v) 
00506         {
00507           return v!=filterName_;
00508         }
00509 
00510         float getPtMin() const { return ptmin_; }
00511         float getPtMax() const { return ptmax_; }
00512 
00513         std::vector< std::pair<std::string,unsigned int> > filtersAndIndices;
00514 
00515 
00516       private:
00517 
00518         int pathIndex_;
00519         std::string denomPathName_;
00520         std::string pathName_;
00521         std::string l1pathName_;
00522         std::string filterName_;
00523         std::string processName_;
00524         int objectType_;
00525         
00526         // we don't own this data
00527         MonitorElement *NOn_, *onEtOn_, *onOneOverEtOn_, *onEtavsonPhiOn_;
00528         //  MonitorElement *NOff_, *offEtOff_, *offEtavsoffPhiOff_;
00529         MonitorElement *NL1_, *l1EtL1_, *l1Etavsl1PhiL1_;
00530         MonitorElement *NL1On_, *l1EtL1On_, *l1Etavsl1PhiL1On_;
00531         MonitorElement *NL1Off_, *offEtL1Off_, *offEtavsoffPhiL1Off_;
00532         MonitorElement *NOnOff_, *offEtOnOff_, *offEtavsoffPhiOnOff_;
00533         MonitorElement *NL1OnUM_, *l1EtL1OnUM_, *l1Etavsl1PhiL1OnUM_;
00534         MonitorElement *NL1OffUM_, *offEtL1OffUM_, *offEtavsoffPhiL1OffUM_;
00535         MonitorElement *NOnOffUM_, *offEtOnOffUM_, *offEtavsoffPhiOnOffUM_;
00536         MonitorElement *offDRL1Off_, *offDROnOff_, *l1DRL1On_;
00537         MonitorElement *filters_;
00538         
00539         float ptmin_, ptmax_;
00540         
00541         const int index() { 
00542           return pathIndex_;
00543         }
00544         const int type() { 
00545           return objectType_;
00546         }
00547 
00548 
00549      };
00550      
00551 
00552    public:
00553 
00554      // simple collection - just 
00555      class PathInfoCollection: public std::vector<PathInfo> {
00556        public:
00557 
00558          PathInfoCollection(): std::vector<PathInfo>() 
00559         {};
00560          std::vector<PathInfo>::iterator find(std::string pathName) {
00561             return std::find(begin(), end(), pathName);
00562          }
00563       };
00564 
00565       PathInfoCollection hltPaths_;
00566 
00567       PathInfoCollection hltPathsDiagonal_;
00568 
00569 };
00570 
00571 
00572 class BaseMonitor
00573 {
00574   public:
00575     virtual void clearSets( void ) = 0;
00576     virtual void setPath(FourVectorHLTOnline::PathInfoCollection::iterator v) = 0;
00577     virtual void monitorL1( const int l1Index, FourVectorHLTOnline* fv) = 0;
00578     virtual void monitorOnline(const int hltIndex, const int l1Index, FourVectorHLTOnline* fv) = 0;
00579 
00580     virtual void matchOnlineL1(const trigger::TriggerObject& onlineFV, const int& l1Index, FourVectorHLTOnline* fv, const int& NOn) = 0;
00581 
00582     virtual void fillOnlineMatch(const int l1Index, FourVectorHLTOnline* fv) = 0;
00583 
00584     virtual bool isTriggerType(int t) = 0;
00585     virtual ~BaseMonitor(){}
00586 
00587 };
00588 
00589 template <class T> 
00590 class objMonData:public BaseMonitor {
00591 public:
00592     objMonData() { EtaMax_= 2.5; EtMin_=3.0; GenJetsFlag_ = false; BJetsFlag_ = false; }
00593     void setLimits(float etaMax, float etMin, float drMatch) 
00594     {
00595      EtaMax_= etaMax; 
00596      EtMin_= etMin; 
00597      DRMatch_= drMatch;
00598     }
00599     void setTriggerType(std::vector<int> trigType) { triggerType_ = trigType; }
00600     void pushTriggerType(int trigType) { triggerType_.push_back(trigType); }
00601     void setL1TriggerType(std::vector<int> trigType) { l1triggerType_ = trigType; }
00602     void pushL1TriggerType(int trigType) { l1triggerType_.push_back(trigType); }
00603     void setPath(FourVectorHLTOnline::PathInfoCollection::iterator v) { v_ = v; }
00604     void setReco(edm::Handle<T> offColl) { offColl_ = offColl; }
00605 
00606 
00607     // Monitor methods
00608 
00609     void monitorL1(const int l1Index, FourVectorHLTOnline* fv);
00610     void monitorOnline(const int hltIndex, const int l1Index, FourVectorHLTOnline* fv);
00611     void matchOnlineL1(const trigger::TriggerObject& onlineFV, const int& l1Index, FourVectorHLTOnline* fv, const int& NOn);
00612     void fillOnlineMatch(const int l1Index, FourVectorHLTOnline* fv);
00613     void fillOnL1Match(const int l1Index, FourVectorHLTOnline* fv);
00614 
00615     void clearSets();
00616 
00617     bool isTriggerType(int t);
00618     bool isL1TriggerType(int t);
00619 
00620     mmset L1OffDRMatchSet;
00621     mmset L1MCDRMatchSet;
00622     mmset OnOffDRMatchSet;
00623     mmset OnMCDRMatchSet;
00624     mmset OnL1DRMatchSet;
00625     mmset OffMCDRMatchSet;
00626 
00627 
00628     void setBJetsFlag(bool flag) 
00629     { 
00630       BJetsFlag_ = flag; 
00631     }
00632     
00633 
00634 private:
00635 
00636     int   pdgId_;
00637     int   pdgStatus_;
00638 
00639     float EtaMax_;
00640     float EtMin_;
00641 
00642     float DRMatch_;
00643 
00644     bool GenJetsFlag_;
00645     bool BJetsFlag_;
00646 
00647     std::vector<int> triggerType_;
00648     std::vector<int> l1triggerType_;
00649 
00650     edm::Handle<T> offColl_;
00651 
00652     FourVectorHLTOnline::PathInfoCollection::iterator v_;
00653 
00654 };
00655 
00656 
00657 template <class T> 
00658 bool objMonData<T>::isTriggerType(int t)
00659 {
00660   bool rc = false;
00661 
00662   for(std::vector<int>::const_iterator it = triggerType_.begin(); it != triggerType_.end(); ++it)
00663   {
00664 
00665    if(t == *it) { rc = true; break; }
00666 
00667   } // end for
00668 
00669   if (t==0) rc = true;
00670 
00671   return rc;
00672 
00673 }
00674 
00675 
00676 template <class T> 
00677 bool objMonData<T>::isL1TriggerType(int t)
00678 {
00679   bool rc = false;
00680 
00681   for(std::vector<int>::const_iterator it = l1triggerType_.begin(); it != l1triggerType_.end(); ++it)
00682   {
00683 
00684    if(fabs(t) == fabs(*it)) { rc = true; break; }
00685 
00686   } // end for
00687 
00688   return rc;
00689 
00690 }
00691 
00692 
00693 template <class T> 
00694 void objMonData<T>::monitorL1(const int l1Index, FourVectorHLTOnline* fv)
00695 {
00696 
00697   if ( l1Index >= fv->fTriggerObj->sizeFilters() ) return;
00698 
00699   unsigned int NL1=0;
00700   unsigned int NL1OffUM=0;
00701 
00702   const trigger::TriggerObjectCollection & toc(fv->fTriggerObj->getObjects());
00703         const trigger::Vids & idtype = fv->fTriggerObj->filterIds(l1Index);
00704         const trigger::Keys & l1k = fv->fTriggerObj->filterKeys(l1Index);
00705         bool l1accept = l1k.size() > 0;
00706 
00707   if(!l1accept) return;
00708 
00709   trigger::Vids::const_iterator idtypeiter = idtype.begin(); 
00710 
00711   for (trigger::Keys::const_iterator l1ki = l1k.begin(); l1ki !=l1k.end(); ++l1ki ) {
00712 
00713    trigger::TriggerObject l1FV = toc[*l1ki];
00714    if(isL1TriggerType(*idtypeiter))
00715    {
00716 
00717 
00718 
00719       if (fabs(l1FV.eta()) <= EtaMax_ && l1FV.pt() >= EtMin_)
00720       { 
00721 
00722         NL1++;
00723 
00724         v_->getL1EtL1Histo()->Fill(l1FV.pt());
00725         v_->getL1EtaVsL1PhiL1Histo()->Fill(l1FV.eta(), l1FV.phi());
00726 
00727       }
00728       else {
00729 
00730         continue;
00731 
00732       }
00733 
00734      } // end if isL1TriggerType
00735      ++idtypeiter;
00736 
00737  } // end for l1ki
00738 
00739  if(NL1 > 0) v_->getNL1Histo()->Fill(NL1);
00740  if(NL1OffUM > 0) v_->getNL1OffUMHisto()->Fill(NL1OffUM);
00741 
00742 }
00743 
00744 
00745 template <class T> 
00746 void objMonData<T>::monitorOnline(const int hltIndex, const int l1Index, FourVectorHLTOnline* fv)
00747 {
00748 
00749   //if(! isTriggerType(v_->getObjectType()) ) return;
00750 
00751   // Get keys of objects passed by the last filter
00752   const trigger::Keys & k = fv->fTriggerObj->filterKeys(hltIndex);
00753 
00754   const trigger::TriggerObjectCollection & toc(fv->fTriggerObj->getObjects());
00755 
00756   unsigned int NOn=0;
00757 
00758   // Loop over HLT objects
00759   for (trigger::Keys::const_iterator ki = k.begin(); ki !=k.end(); ++ki ) {
00760 
00761           trigger::TriggerObject onlineFV = toc[*ki];
00762         
00763           if (fabs(onlineFV.eta()) <= EtaMax_ && onlineFV.pt() >= EtMin_)
00764           { 
00765         
00766             NOn++;    
00767         
00768             v_->getOnEtOnHisto()->Fill(onlineFV.pt());
00769             v_->getOnOneOverEtOnHisto()->Fill(1./onlineFV.pt());
00770             v_->getOnEtaVsOnPhiOnHisto()->Fill(onlineFV.eta(), onlineFV.phi());
00771         
00772           }
00773           else {
00774         
00775             return;
00776         
00777           }
00778 
00779     matchOnlineL1(onlineFV,l1Index, fv, NOn);
00780 
00781   } // end loop over HLT objects
00782   
00783   if(NOn>0) v_->getNOnHisto()->Fill(NOn);
00784 
00785 }
00786 
00787 template <class T> 
00788 void objMonData<T>::matchOnlineL1(const trigger::TriggerObject& onlineFV, const int& l1Index, FourVectorHLTOnline* fv, const int& NOn)
00789 {
00790 
00791   if ( l1Index >= fv->fTriggerObj->sizeFilters() ) return;
00792 
00793   unsigned int NOnL1UM=0;
00794 
00795   const trigger::TriggerObjectCollection & toc(fv->fTriggerObj->getObjects());
00796         const trigger::Vids & idtype = fv->fTriggerObj->filterIds(l1Index);
00797         const trigger::Keys & l1k = fv->fTriggerObj->filterKeys(l1Index);
00798 
00799   fimmap OnL1DRMatchMap;
00800   int j=0;
00801   trigger::Vids::const_iterator idtypeiter = idtype.begin(); 
00802   for (trigger::Keys::const_iterator l1ki = l1k.begin(); l1ki !=l1k.end(); ++l1ki ) 
00803   {
00804 
00805       
00806 
00807       if(isL1TriggerType(*idtypeiter))
00808       {
00809 
00810         trigger::TriggerObject l1FV = toc[*l1ki];
00811 
00812         if ( fabs(l1FV.eta()) <= EtaMax_ && l1FV.pt() >= EtMin_ )
00813         {
00814 
00815            // fill UM histos (no matching required)
00816            if(NOn == 1) {
00817 
00818             NOnL1UM++;
00819             v_->getL1EtL1OnUMHisto()->Fill(l1FV.pt());
00820             v_->getL1EtaVsL1PhiL1OnUMHisto()->Fill(l1FV.eta(),l1FV.phi());
00821 
00822             }
00823 
00824 
00825             float dR = reco::deltaR(l1FV.eta(),l1FV.phi(),onlineFV.eta(),onlineFV.phi());
00826 
00827             if ( dR < 1.0) 
00828             {
00829 
00830               OnL1DRMatchMap.insert(std::pair<float,int>(dR,j));
00831 
00832             }
00833 
00834           } // end if l1FV eta, pt
00835 
00836        } // end if isL1TriggerType
00837 
00838        ++idtypeiter;
00839        j++;
00840 
00841   } // end for
00842 
00843   if(! OnL1DRMatchMap.empty()) OnL1DRMatchSet.insert(OnL1DRMatchMap);
00844 
00845 }
00846 
00847 template <class T> 
00848 void objMonData<T>::fillOnL1Match(const int l1Index, FourVectorHLTOnline* fv)
00849 {
00850 
00851   const trigger::TriggerObjectCollection & toc(fv->fTriggerObj->getObjects());
00852         const trigger::Keys & l1k = fv->fTriggerObj->filterKeys(l1Index);
00853 
00854   unsigned int NOnL1=0;
00855 
00856   // clean the set On-L1
00857   if(OnL1DRMatchSet.size() > 1) {
00858   
00859     LogDebug("FourVectorHLTOnline") << " Cleaning L1On mmset" << std::endl;
00860     fv->cleanDRMatchSet(OnL1DRMatchSet);
00861 
00862   }
00863   // now fill histos
00864   for ( mmset::iterator setIter = OnL1DRMatchSet.begin( ); setIter != OnL1DRMatchSet.end( ); setIter++ ) 
00865   {
00866 
00867     fimmap tempMap = *setIter;
00868       
00869     fimmap::iterator it = tempMap.begin(); 
00870     int i  = (*it).second ;
00871     float dR = (*it).first;
00872     v_->getL1DROnL1Histo()->Fill(dR);
00873 
00874     if (dR > DRMatch_) continue;
00875 
00876     trigger::Keys::const_iterator l1ki = l1k.begin();
00877     for (int count = 0; count < i; count++) l1ki++;
00878 
00879     NOnL1++;
00880     v_->getL1EtL1OnHisto()->Fill(toc[*l1ki].pt());
00881     v_->getL1EtaVsL1PhiL1OnHisto()->Fill(toc[*l1ki].eta(),toc[*l1ki].phi());
00882 
00883   }
00884 
00885   v_->getNL1OnHisto()->Fill(NOnL1);
00886 
00887 }
00888 
00889 template <class T> 
00890 void objMonData<T>::fillOnlineMatch(const int l1Index, FourVectorHLTOnline* fv)
00891 {
00892 
00893 
00894   if ( l1Index >= fv->fTriggerObj->sizeFilters() ) return;
00895   fillOnL1Match(l1Index, fv);
00896 
00897 }
00898 
00899 
00900 template <class T> 
00901 void objMonData<T>::clearSets()
00902 {
00903 
00904    L1OffDRMatchSet.clear();
00905    L1MCDRMatchSet.clear();
00906    OnOffDRMatchSet.clear();
00907    OnMCDRMatchSet.clear();
00908    OnL1DRMatchSet.clear();
00909    OffMCDRMatchSet.clear();
00910 
00911 }
00912 
00913 
00914 
00915 #endif