Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-29 23:10:20

0001 // -*- C++ -*-
0002 //
0003 // Package:    QM/HLTObjectMonitorProtonLead
0004 // Class:      HLTObjectMonitorProtonLead
0005 //
0006 /**\class HLTObjectMonitorProtonLead HLTObjectMonitorProtonLead.cc DQM/HLTEvF/plugins/HLTObjectMonitorProtonLead.cc 
0007 
0008  Description: [one line class summary]
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Varun Sharma
0015 //         Created:  Fri, 21 Oct 2016 12:29:00 GMT
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 #include <sys/time.h>
0022 #include <cstdlib>
0023 
0024 // user include files
0025 #include "DataFormats/Common/interface/TriggerResults.h"
0026 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0027 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0028 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0029 
0030 #include "FWCore/Framework/interface/Frameworkfwd.h"
0031 #include "FWCore/Framework/interface/Event.h"
0032 #include "FWCore/Framework/interface/MakerMacros.h"
0033 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0034 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0035 
0036 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0037 
0038 //for collections
0039 #include "HLTrigger/JetMET/interface/AlphaT.h"
0040 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0041 #include "DataFormats/METReco/interface/MET.h"
0042 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
0043 #include "DataFormats/BTauReco/interface/JetTag.h"
0044 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
0045 #include "DataFormats/Math/interface/deltaR.h"
0046 #include "DataFormats/JetReco/interface/PFJet.h"
0047 #include "DataFormats/JetReco/interface/CaloJet.h"
0048 
0049 #include "DQMServices/Core/interface/DQMStore.h"
0050 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0051 
0052 #include "TMath.h"
0053 #include "TStyle.h"
0054 #include "TLorentzVector.h"
0055 
0056 #include <unordered_map>
0057 //
0058 // class declaration
0059 //
0060 
0061 //using namespace edm;
0062 using namespace trigger;
0063 using std::string;
0064 using std::unordered_map;
0065 using std::vector;
0066 
0067 class HLTObjectMonitorProtonLead : public DQMEDAnalyzer {
0068   struct hltPlot {
0069     MonitorElement* ME;
0070     string pathName;
0071     string pathNameOR;
0072     string moduleName;
0073     string moduleNameOR;
0074     int pathIndex = -99;
0075     int pathIndexOR = -99;
0076     string plotLabel;
0077     string xAxisLabel;
0078     int nBins;
0079     double xMin;
0080     double xMax;
0081     bool displayInPrimary;
0082   };
0083 
0084 public:
0085   explicit HLTObjectMonitorProtonLead(const edm::ParameterSet&);
0086   ~HLTObjectMonitorProtonLead() override;
0087 
0088   //      static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0089 
0090 private:
0091   void analyze(const edm::Event&, const edm::EventSetup&) override;
0092   void bookHistograms(DQMStore::IBooker& i, edm::Run const&, edm::EventSetup const&) override;
0093   void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
0094   vector<hltPlot*> plotList;
0095   //virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
0096   //virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
0097   double get_wall_time(void);
0098   // ----------member data ---------------------------
0099 
0100   bool debugPrint;
0101   HLTConfigProvider hltConfig_;
0102   string topDirectoryName;
0103   string mainShifterFolder;
0104   string backupFolder;
0105   unordered_map<string, bool> acceptMap;
0106   unordered_map<hltPlot*, edm::ParameterSet*> plotMap;
0107 
0108   //set Token(-s)
0109   edm::EDGetTokenT<edm::TriggerResults> triggerResultsToken_;
0110   edm::EDGetTokenT<trigger::TriggerEvent> aodTriggerToken_;
0111 
0112   //declare params
0113   //pPb run
0114   edm::ParameterSet caloAK4JetPt_pset;
0115   edm::ParameterSet caloAK4JetEta_pset;
0116   edm::ParameterSet caloAK4JetPhi_pset;
0117   edm::ParameterSet pfAK4JetPt_pset;
0118   edm::ParameterSet pfAK4JetEta_pset;
0119   edm::ParameterSet pfAK4JetPhi_pset;
0120   edm::ParameterSet caloDiAK4JetPt_pset;
0121   edm::ParameterSet caloDiAK4JetEta_pset;
0122   edm::ParameterSet caloDiAK4JetPhi_pset;
0123   edm::ParameterSet pfDiAK4JetPt_pset;
0124   edm::ParameterSet pfDiAK4JetEta_pset;
0125   edm::ParameterSet pfDiAK4JetPhi_pset;
0126   edm::ParameterSet photonPt_pset;
0127   edm::ParameterSet photonEta_pset;
0128   edm::ParameterSet photonPhi_pset;
0129   edm::ParameterSet photonPPPt_pset;
0130   edm::ParameterSet photonPPEta_pset;
0131   edm::ParameterSet photonPPPhi_pset;
0132   edm::ParameterSet caloBJetPt_pset;
0133   edm::ParameterSet caloBJetEta_pset;
0134   edm::ParameterSet caloBJetPhi_pset;
0135   edm::ParameterSet pfBJetPt_pset;
0136   edm::ParameterSet pfBJetEta_pset;
0137   edm::ParameterSet pfBJetPhi_pset;
0138   edm::ParameterSet electronPt_pset;
0139   edm::ParameterSet electronEta_pset;
0140   edm::ParameterSet electronPhi_pset;
0141   edm::ParameterSet l3muon3Pt_pset;
0142   edm::ParameterSet l3muon3Eta_pset;
0143   edm::ParameterSet l3muon3Phi_pset;
0144   edm::ParameterSet l2muon12Pt_pset;
0145   edm::ParameterSet l2muon12Eta_pset;
0146   edm::ParameterSet l2muon12Phi_pset;
0147   edm::ParameterSet l3muon12Pt_pset;
0148   edm::ParameterSet l3muon12Eta_pset;
0149   edm::ParameterSet l3muon12Phi_pset;
0150   edm::ParameterSet pAL1DoubleMuZMass_pset;
0151   edm::ParameterSet pAL2DoubleMuZMass_pset;
0152   edm::ParameterSet pAL3DoubleMuZMass_pset;
0153   edm::ParameterSet wallTime_pset;
0154 
0155   string processName_;
0156 
0157   hltPlot caloAK4JetPt_;
0158   hltPlot caloAK4JetEta_;
0159   hltPlot caloAK4JetPhi_;
0160   hltPlot pfAK4JetPt_;
0161   hltPlot pfAK4JetEta_;
0162   hltPlot pfAK4JetPhi_;
0163   hltPlot caloDiAK4JetPt_;
0164   hltPlot caloDiAK4JetEta_;
0165   hltPlot caloDiAK4JetPhi_;
0166   hltPlot pfDiAK4JetPt_;
0167   hltPlot pfDiAK4JetEta_;
0168   hltPlot pfDiAK4JetPhi_;
0169   hltPlot photonPt_;
0170   hltPlot photonEta_;
0171   hltPlot photonPhi_;
0172   hltPlot photonPPPt_;
0173   hltPlot photonPPEta_;
0174   hltPlot photonPPPhi_;
0175   hltPlot caloBJetPt_;
0176   hltPlot caloBJetEta_;
0177   hltPlot caloBJetPhi_;
0178   hltPlot pfBJetPt_;
0179   hltPlot pfBJetEta_;
0180   hltPlot pfBJetPhi_;
0181   hltPlot electronPt_;
0182   hltPlot electronEta_;
0183   hltPlot electronPhi_;
0184   hltPlot l3muon3Pt_;
0185   hltPlot l3muon3Eta_;
0186   hltPlot l3muon3Phi_;
0187   hltPlot l2muon12Pt_;
0188   hltPlot l2muon12Eta_;
0189   hltPlot l2muon12Phi_;
0190   hltPlot l3muon12Pt_;
0191   hltPlot l3muon12Eta_;
0192   hltPlot l3muon12Phi_;
0193   hltPlot pAL1DoubleMuZMass_;
0194   hltPlot pAL2DoubleMuZMass_;
0195   hltPlot pAL3DoubleMuZMass_;
0196   hltPlot wallTime_;
0197 };
0198 
0199 //
0200 // constants, enums and typedefs
0201 //
0202 
0203 //
0204 // static data member definitions
0205 //
0206 
0207 //
0208 // constructors and destructor
0209 //
0210 HLTObjectMonitorProtonLead::HLTObjectMonitorProtonLead(const edm::ParameterSet& iConfig)
0211 
0212 {
0213   //now do what ever initialization is needed
0214   debugPrint = false;
0215 
0216   topDirectoryName = "HLT/ObjectMonitor";
0217   mainShifterFolder = topDirectoryName + "/MainShifter";
0218   backupFolder = topDirectoryName + "/Backup";
0219 
0220   //parse params
0221   processName_ = iConfig.getParameter<string>("processName");
0222 
0223   caloAK4JetPt_pset = iConfig.getParameter<edm::ParameterSet>("caloAK4JetPt");
0224   plotMap[&caloAK4JetPt_] = &caloAK4JetPt_pset;
0225   caloAK4JetEta_pset = iConfig.getParameter<edm::ParameterSet>("caloAK4JetEta");
0226   plotMap[&caloAK4JetEta_] = &caloAK4JetEta_pset;
0227   caloAK4JetPhi_pset = iConfig.getParameter<edm::ParameterSet>("caloAK4JetPhi");
0228   plotMap[&caloAK4JetPhi_] = &caloAK4JetPhi_pset;
0229   pfAK4JetPt_pset = iConfig.getParameter<edm::ParameterSet>("pfAK4JetPt");
0230   plotMap[&pfAK4JetPt_] = &pfAK4JetPt_pset;
0231   pfAK4JetEta_pset = iConfig.getParameter<edm::ParameterSet>("pfAK4JetEta");
0232   plotMap[&pfAK4JetEta_] = &pfAK4JetEta_pset;
0233   pfAK4JetPhi_pset = iConfig.getParameter<edm::ParameterSet>("pfAK4JetPhi");
0234   plotMap[&pfAK4JetPhi_] = &pfAK4JetPhi_pset;
0235   caloDiAK4JetPt_pset = iConfig.getParameter<edm::ParameterSet>("caloDiAK4JetPt");
0236   plotMap[&caloDiAK4JetPt_] = &caloDiAK4JetPt_pset;
0237   caloDiAK4JetEta_pset = iConfig.getParameter<edm::ParameterSet>("caloDiAK4JetEta");
0238   plotMap[&caloDiAK4JetEta_] = &caloDiAK4JetEta_pset;
0239   caloDiAK4JetPhi_pset = iConfig.getParameter<edm::ParameterSet>("caloDiAK4JetPhi");
0240   plotMap[&caloDiAK4JetPhi_] = &caloDiAK4JetPhi_pset;
0241   pfDiAK4JetPt_pset = iConfig.getParameter<edm::ParameterSet>("pfDiAK4JetPt");
0242   plotMap[&pfDiAK4JetPt_] = &pfDiAK4JetPt_pset;
0243   pfDiAK4JetEta_pset = iConfig.getParameter<edm::ParameterSet>("pfDiAK4JetEta");
0244   plotMap[&pfDiAK4JetEta_] = &pfDiAK4JetEta_pset;
0245   pfDiAK4JetPhi_pset = iConfig.getParameter<edm::ParameterSet>("pfDiAK4JetPhi");
0246   plotMap[&pfDiAK4JetPhi_] = &pfDiAK4JetPhi_pset;
0247   photonPt_pset = iConfig.getParameter<edm::ParameterSet>("photonPt");
0248   plotMap[&photonPt_] = &photonPt_pset;
0249   photonEta_pset = iConfig.getParameter<edm::ParameterSet>("photonEta");
0250   plotMap[&photonEta_] = &photonEta_pset;
0251   photonPhi_pset = iConfig.getParameter<edm::ParameterSet>("photonPhi");
0252   plotMap[&photonPhi_] = &photonPhi_pset;
0253   photonPPPt_pset = iConfig.getParameter<edm::ParameterSet>("photonPPPt");
0254   plotMap[&photonPPPt_] = &photonPPPt_pset;
0255   photonPPEta_pset = iConfig.getParameter<edm::ParameterSet>("photonPPEta");
0256   plotMap[&photonPPEta_] = &photonPPEta_pset;
0257   photonPPPhi_pset = iConfig.getParameter<edm::ParameterSet>("photonPPPhi");
0258   plotMap[&photonPPPhi_] = &photonPPPhi_pset;
0259   caloBJetPt_pset = iConfig.getParameter<edm::ParameterSet>("caloBJetPt");
0260   plotMap[&caloBJetPt_] = &caloBJetPt_pset;
0261   caloBJetEta_pset = iConfig.getParameter<edm::ParameterSet>("caloBJetEta");
0262   plotMap[&caloBJetEta_] = &caloBJetEta_pset;
0263   caloBJetPhi_pset = iConfig.getParameter<edm::ParameterSet>("caloBJetPhi");
0264   plotMap[&caloBJetPhi_] = &caloBJetPhi_pset;
0265   pfBJetPt_pset = iConfig.getParameter<edm::ParameterSet>("pfBJetPt");
0266   plotMap[&pfBJetPt_] = &pfBJetPt_pset;
0267   pfBJetEta_pset = iConfig.getParameter<edm::ParameterSet>("pfBJetEta");
0268   plotMap[&pfBJetEta_] = &pfBJetEta_pset;
0269   pfBJetPhi_pset = iConfig.getParameter<edm::ParameterSet>("pfBJetPhi");
0270   plotMap[&pfBJetPhi_] = &pfBJetPhi_pset;
0271   electronPt_pset = iConfig.getParameter<edm::ParameterSet>("electronPt");
0272   plotMap[&electronPt_] = &electronPt_pset;
0273   electronEta_pset = iConfig.getParameter<edm::ParameterSet>("electronEta");
0274   plotMap[&electronEta_] = &electronEta_pset;
0275   electronPhi_pset = iConfig.getParameter<edm::ParameterSet>("electronPhi");
0276   plotMap[&electronPhi_] = &electronPhi_pset;
0277   l3muon3Pt_pset = iConfig.getParameter<edm::ParameterSet>("l3muon3Pt");
0278   plotMap[&l3muon3Pt_] = &l3muon3Pt_pset;
0279   l3muon3Eta_pset = iConfig.getParameter<edm::ParameterSet>("l3muon3Eta");
0280   plotMap[&l3muon3Eta_] = &l3muon3Eta_pset;
0281   l3muon3Phi_pset = iConfig.getParameter<edm::ParameterSet>("l3muon3Phi");
0282   plotMap[&l3muon3Phi_] = &l3muon3Phi_pset;
0283   l2muon12Pt_pset = iConfig.getParameter<edm::ParameterSet>("l2muon12Pt");
0284   plotMap[&l2muon12Pt_] = &l2muon12Pt_pset;
0285   l2muon12Eta_pset = iConfig.getParameter<edm::ParameterSet>("l2muon12Eta");
0286   plotMap[&l2muon12Eta_] = &l2muon12Eta_pset;
0287   l2muon12Phi_pset = iConfig.getParameter<edm::ParameterSet>("l2muon12Phi");
0288   plotMap[&l2muon12Phi_] = &l2muon12Phi_pset;
0289   l3muon12Pt_pset = iConfig.getParameter<edm::ParameterSet>("l3muon12Pt");
0290   plotMap[&l3muon12Pt_] = &l3muon12Pt_pset;
0291   l3muon12Eta_pset = iConfig.getParameter<edm::ParameterSet>("l3muon12Eta");
0292   plotMap[&l3muon12Eta_] = &l3muon12Eta_pset;
0293   l3muon12Phi_pset = iConfig.getParameter<edm::ParameterSet>("l3muon12Phi");
0294   plotMap[&l3muon12Phi_] = &l3muon12Phi_pset;
0295   pAL1DoubleMuZMass_pset = iConfig.getParameter<edm::ParameterSet>("pAL1DoubleMuZMass");
0296   plotMap[&pAL1DoubleMuZMass_] = &pAL1DoubleMuZMass_pset;
0297   pAL2DoubleMuZMass_pset = iConfig.getParameter<edm::ParameterSet>("pAL2DoubleMuZMass");
0298   plotMap[&pAL2DoubleMuZMass_] = &pAL2DoubleMuZMass_pset;
0299   pAL3DoubleMuZMass_pset = iConfig.getParameter<edm::ParameterSet>("pAL3DoubleMuZMass");
0300   plotMap[&pAL3DoubleMuZMass_] = &pAL3DoubleMuZMass_pset;
0301   wallTime_pset = iConfig.getParameter<edm::ParameterSet>("wallTime");
0302   plotMap[&wallTime_] = &wallTime_pset;
0303 
0304   for (auto item = plotMap.begin(); item != plotMap.end(); item++) {
0305     (*item->first).pathName = (*item->second).getParameter<string>("pathName");
0306     (*item->first).moduleName = (*item->second).getParameter<string>("moduleName");
0307     (*item->first).nBins = (*item->second).getParameter<int>("NbinsX");
0308     (*item->first).xMin = (*item->second).getParameter<double>("Xmin");
0309     (*item->first).xMax = (*item->second).getParameter<double>("Xmax");
0310     (*item->first).xAxisLabel = (*item->second).getParameter<string>("axisLabel");
0311     (*item->first).plotLabel = (*item->second).getParameter<string>("plotLabel");
0312     (*item->first).displayInPrimary = (*item->second).getParameter<bool>("mainWorkspace");
0313 
0314     if ((*item->second).exists("pathName_OR")) {
0315       (*item->first).pathNameOR = (*item->second).getParameter<string>("pathName_OR");
0316     }
0317     if ((*item->second).exists("moduleName_OR")) {
0318       (*item->first).moduleNameOR = (*item->second).getParameter<string>("moduleName_OR");
0319     }
0320 
0321     plotList.push_back(item->first);
0322   }
0323   plotMap.clear();
0324 
0325   //set Token(s)
0326   triggerResultsToken_ = consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>("triggerResults"));
0327   aodTriggerToken_ = consumes<trigger::TriggerEvent>(iConfig.getParameter<edm::InputTag>("triggerEvent"));
0328 }
0329 
0330 HLTObjectMonitorProtonLead::~HLTObjectMonitorProtonLead() {
0331   // do anything here that needs to be done at desctruction time
0332   // (e.g. close files, deallocate resources etc.)
0333 }
0334 
0335 //
0336 // member functions
0337 //
0338 
0339 // ------------ method called for each event  ------------
0340 void HLTObjectMonitorProtonLead::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0341   double start = get_wall_time();
0342 
0343   using namespace edm;
0344 
0345   if (debugPrint)
0346     std::cout << "Inside analyze(). " << std::endl;
0347 
0348   // access trigger results
0349   edm::Handle<edm::TriggerResults> triggerResults;
0350   iEvent.getByToken(triggerResultsToken_, triggerResults);
0351   if (!triggerResults.isValid())
0352     return;
0353 
0354   edm::Handle<trigger::TriggerEvent> aodTriggerEvent;
0355   iEvent.getByToken(aodTriggerToken_, aodTriggerEvent);
0356   if (!aodTriggerEvent.isValid())
0357     return;
0358 
0359   //reset everything to not accepted at beginning of each event
0360   unordered_map<string, bool> firedMap = acceptMap;
0361   for (auto plot : plotList)  //loop over paths
0362   {
0363     if (firedMap[plot->pathName])
0364       continue;
0365     bool triggerAccept = false;
0366     const TriggerObjectCollection objects = aodTriggerEvent->getObjects();
0367     edm::InputTag moduleFilter;
0368     std::string pathName;
0369     if (plot->pathIndex > 0 && triggerResults->accept(plot->pathIndex) && hltConfig_.saveTags(plot->moduleName)) {
0370       moduleFilter = edm::InputTag(plot->moduleName, "", processName_);
0371       pathName = plot->pathName;
0372       triggerAccept = true;
0373     } else if (plot->pathIndexOR > 0 && triggerResults->accept(plot->pathIndexOR) &&
0374                hltConfig_.saveTags(plot->moduleNameOR)) {
0375       if (firedMap[plot->pathNameOR])
0376         continue;
0377       moduleFilter = edm::InputTag(plot->moduleNameOR, "", processName_);
0378       pathName = plot->pathNameOR;
0379       triggerAccept = true;
0380     }
0381 
0382     if (triggerAccept) {
0383       unsigned int moduleFilterIndex = aodTriggerEvent->filterIndex(moduleFilter);
0384 
0385       if (moduleFilterIndex + 1 > aodTriggerEvent->sizeFilters())
0386         return;
0387       const Keys& keys = aodTriggerEvent->filterKeys(moduleFilterIndex);
0388 
0389       ////////////////////////////////
0390       ///
0391       /// single-object plots
0392       ///
0393       ////////////////////////////////
0394 
0395       //calo AK4 jet pt + eta + phi
0396       if (pathName == caloAK4JetPt_.pathName) {
0397         for (const auto& key : keys) {
0398           caloAK4JetPt_.ME->Fill(objects[key].pt());
0399           caloAK4JetEta_.ME->Fill(objects[key].eta());
0400           caloAK4JetPhi_.ME->Fill(objects[key].phi());
0401         }
0402       }
0403       //pf AK4 jet pt + eta + phi
0404       else if (pathName == pfAK4JetPt_.pathName) {
0405         for (const auto& key : keys) {
0406           pfAK4JetPt_.ME->Fill(objects[key].pt());
0407           pfAK4JetEta_.ME->Fill(objects[key].eta());
0408           pfAK4JetPhi_.ME->Fill(objects[key].phi());
0409         }
0410       }
0411       //calo AK4 di jet pt + eta + phi
0412       else if (pathName == caloDiAK4JetPt_.pathName) {
0413         for (const auto& key : keys) {
0414           caloDiAK4JetPt_.ME->Fill(objects[key].pt());
0415           caloDiAK4JetEta_.ME->Fill(objects[key].eta());
0416           caloDiAK4JetPhi_.ME->Fill(objects[key].phi());
0417         }
0418       }
0419       //pf AK4 di jet pt + eta + phi
0420       else if (pathName == pfDiAK4JetPt_.pathName) {
0421         for (const auto& key : keys) {
0422           pfDiAK4JetPt_.ME->Fill(objects[key].pt());
0423           pfDiAK4JetEta_.ME->Fill(objects[key].eta());
0424           pfDiAK4JetPhi_.ME->Fill(objects[key].phi());
0425         }
0426       }
0427       //photon pt + eta + phi
0428       else if (pathName == photonPt_.pathName) {
0429         for (const auto& key : keys) {
0430           photonPt_.ME->Fill(objects[key].pt());
0431           photonEta_.ME->Fill(objects[key].eta());
0432           photonPhi_.ME->Fill(objects[key].phi());
0433         }
0434       }
0435       //photon PPStyle pt + eta + phi
0436       else if (pathName == photonPPPt_.pathName) {
0437         for (const auto& key : keys) {
0438           photonPPPt_.ME->Fill(objects[key].pt());
0439           photonPPEta_.ME->Fill(objects[key].eta());
0440           photonPPPhi_.ME->Fill(objects[key].phi());
0441         }
0442       }
0443       //calo Bjet pt + eta + phi
0444       else if (pathName == caloBJetPt_.pathName) {
0445         for (const auto& key : keys) {
0446           caloBJetPt_.ME->Fill(objects[key].pt());
0447           caloBJetEta_.ME->Fill(objects[key].eta());
0448           caloBJetPhi_.ME->Fill(objects[key].phi());
0449         }
0450       }
0451       //PF Bjet pt + eta + phi
0452       else if (pathName == pfBJetPt_.pathName) {
0453         for (const auto& key : keys) {
0454           pfBJetPt_.ME->Fill(objects[key].pt());
0455           pfBJetEta_.ME->Fill(objects[key].eta());
0456           pfBJetPhi_.ME->Fill(objects[key].phi());
0457         }
0458       }
0459       //electron pt + eta + phi
0460       else if (pathName == electronPt_.pathName) {
0461         for (const auto& key : keys) {
0462           electronPt_.ME->Fill(objects[key].pt());
0463           electronEta_.ME->Fill(objects[key].eta());
0464           electronPhi_.ME->Fill(objects[key].phi());
0465         }
0466       } else if (pathName == l3muon3Pt_.pathName) {
0467         for (const auto& key : keys) {
0468           l3muon3Pt_.ME->Fill(objects[key].pt());
0469           l3muon3Eta_.ME->Fill(objects[key].eta());
0470           l3muon3Phi_.ME->Fill(objects[key].phi());
0471         }
0472       } else if (pathName == l2muon12Pt_.pathName) {
0473         for (const auto& key : keys) {
0474           l2muon12Pt_.ME->Fill(objects[key].pt());
0475           l2muon12Eta_.ME->Fill(objects[key].eta());
0476           l2muon12Phi_.ME->Fill(objects[key].phi());
0477         }
0478       } else if (pathName == l3muon12Pt_.pathName) {
0479         for (const auto& key : keys) {
0480           l3muon12Pt_.ME->Fill(objects[key].pt());
0481           l3muon12Eta_.ME->Fill(objects[key].eta());
0482           l3muon12Phi_.ME->Fill(objects[key].phi());
0483         }
0484       }
0485 
0486       // ////////////////////////////////
0487       // ///
0488       // /// double-object plots
0489       // ///
0490       // ////////////////////////////////
0491 
0492       else if (pathName == pAL1DoubleMuZMass_.pathName) {
0493         const double mu_mass(.105658);
0494         unsigned int kCnt0 = 0;
0495         for (const auto& key0 : keys) {
0496           unsigned int kCnt1 = 0;
0497           for (const auto& key1 : keys) {
0498             if (key0 != key1 &&
0499                 kCnt1 > kCnt0) {  // avoid filling hists with same objs && avoid double counting separate objs
0500               // if (abs(objects[key0].id()) == 13 && (objects[key0].id()+objects[key1].id()==0))  // id is not filled for l1 stage2 muons
0501               TLorentzVector mu1, mu2, dimu;
0502               mu1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), mu_mass);
0503               mu2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), mu_mass);
0504               dimu = mu1 + mu2;
0505               if (dimu.M() > pAL1DoubleMuZMass_.xMin && dimu.M() < pAL1DoubleMuZMass_.xMax)
0506                 pAL1DoubleMuZMass_.ME->Fill(dimu.M());
0507             }
0508             kCnt1 += 1;
0509           }
0510           kCnt0 += 1;
0511         }
0512       } else if (pathName == pAL2DoubleMuZMass_.pathName) {
0513         const double mu_mass(.105658);
0514         unsigned int kCnt0 = 0;
0515         for (const auto& key0 : keys) {
0516           unsigned int kCnt1 = 0;
0517           for (const auto& key1 : keys) {
0518             if (key0 != key1 &&
0519                 kCnt1 > kCnt0) {  // avoid filling hists with same objs && avoid double counting separate objs
0520               if (abs(objects[key0].id()) == 13 &&
0521                   (objects[key0].id() + objects[key1].id() == 0)) {  // check muon id and dimuon charge
0522                 TLorentzVector mu1, mu2, dimu;
0523                 mu1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), mu_mass);
0524                 mu2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), mu_mass);
0525                 dimu = mu1 + mu2;
0526                 if (dimu.M() > pAL2DoubleMuZMass_.xMin && dimu.M() < pAL2DoubleMuZMass_.xMax)
0527                   pAL2DoubleMuZMass_.ME->Fill(dimu.M());
0528               }
0529             }
0530             kCnt1 += 1;
0531           }
0532           kCnt0 += 1;
0533         }
0534       } else if (pathName == pAL3DoubleMuZMass_.pathName) {
0535         const double mu_mass(.105658);
0536         unsigned int kCnt0 = 0;
0537         for (const auto& key0 : keys) {
0538           unsigned int kCnt1 = 0;
0539           for (const auto& key1 : keys) {
0540             if (key0 != key1 &&
0541                 kCnt1 > kCnt0) {  // avoid filling hists with same objs && avoid double counting separate objs
0542               if (abs(objects[key0].id()) == 13 &&
0543                   (objects[key0].id() + objects[key1].id() == 0)) {  // check muon id and dimuon charge
0544                 TLorentzVector mu1, mu2, dimu;
0545                 mu1.SetPtEtaPhiM(objects[key0].pt(), objects[key0].eta(), objects[key0].phi(), mu_mass);
0546                 mu2.SetPtEtaPhiM(objects[key1].pt(), objects[key1].eta(), objects[key1].phi(), mu_mass);
0547                 dimu = mu1 + mu2;
0548                 if (dimu.M() > pAL3DoubleMuZMass_.xMin && dimu.M() < pAL3DoubleMuZMass_.xMax)
0549                   pAL3DoubleMuZMass_.ME->Fill(dimu.M());
0550               }
0551             }
0552             kCnt1 += 1;
0553           }
0554           kCnt0 += 1;
0555         }
0556       }
0557 
0558       firedMap[pathName] = true;
0559     }  //end if trigger accept
0560   }    //end loop over plots/paths
0561 
0562   //   sleep(1); //sleep for 1s, used to calibrate timing
0563   double end = get_wall_time();
0564   double wallTime = end - start;
0565   wallTime_.ME->Fill(wallTime);
0566 }
0567 
0568 // ------------ method called when starting to processes a run  ------------
0569 void HLTObjectMonitorProtonLead::dqmBeginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
0570   if (debugPrint)
0571     std::cout << "Calling beginRun. " << std::endl;
0572   bool changed = true;
0573   if (hltConfig_.init(iRun, iSetup, processName_, changed)) {
0574     if (debugPrint)
0575       std::cout << "Extracting HLTconfig. " << std::endl;
0576   }
0577 
0578   //get path indicies from menu
0579   string pathName_noVersion;
0580   vector<string> triggerPaths = hltConfig_.triggerNames();
0581 
0582   for (const auto& pathName : triggerPaths) {
0583     pathName_noVersion = hltConfig_.removeVersion(pathName);
0584     for (auto plot : plotList) {
0585       if (plot->pathName == pathName_noVersion) {
0586         (*plot).pathIndex = hltConfig_.triggerIndex(pathName);
0587       } else if (plot->pathNameOR == pathName_noVersion) {
0588         (*plot).pathIndexOR = hltConfig_.triggerIndex(pathName);
0589       }
0590     }
0591   }
0592   vector<hltPlot*> plotList_temp;
0593   for (auto plot : plotList) {
0594     if (plot->pathIndex > 0 || plot->pathIndexOR > 0) {
0595       plotList_temp.push_back(plot);
0596       acceptMap[plot->pathName] = false;
0597       if (plot->pathIndexOR > 0)
0598         acceptMap[plot->pathNameOR] = false;
0599     }
0600   }
0601   //now re-assign plotList to contain only the plots with paths in the menu.
0602   plotList = plotList_temp;
0603   plotList_temp.clear();
0604 }
0605 
0606 // ------------ method called when ending the processing of a run  ------------
0607 
0608 void HLTObjectMonitorProtonLead::bookHistograms(DQMStore::IBooker& ibooker,
0609                                                 edm::Run const& iRun,
0610                                                 edm::EventSetup const& iSetup) {
0611   ////////////////////////////////
0612   ///
0613   /// Main shifter workspace plots
0614   ///
0615   ////////////////////////////////
0616 
0617   //book wall time separately
0618   ibooker.setCurrentFolder(mainShifterFolder);
0619   wallTime_.ME =
0620       ibooker.book1D(wallTime_.plotLabel, wallTime_.pathName, wallTime_.nBins, wallTime_.xMin, wallTime_.xMax);
0621   wallTime_.ME->setAxisTitle(wallTime_.xAxisLabel);
0622 
0623   for (auto plot : plotList) {
0624     std::string display_pathNames = plot->pathName;
0625     if (!plot->pathNameOR.empty())
0626       display_pathNames = plot->pathName + " OR " + plot->pathNameOR;
0627 
0628     if (plot->displayInPrimary) {
0629       ibooker.setCurrentFolder(mainShifterFolder);
0630       (*plot).ME = ibooker.book1D(plot->plotLabel, display_pathNames.c_str(), plot->nBins, plot->xMin, plot->xMax);
0631       (*plot).ME->setAxisTitle(plot->xAxisLabel);
0632       //need to add OR statement
0633     } else {
0634       ibooker.setCurrentFolder(backupFolder);
0635       (*plot).ME = ibooker.book1D(plot->plotLabel, display_pathNames.c_str(), plot->nBins, plot->xMin, plot->xMax);
0636       (*plot).ME->setAxisTitle(plot->xAxisLabel);
0637     }
0638   }
0639 }
0640 
0641 double HLTObjectMonitorProtonLead::get_wall_time() {
0642   struct timeval time;
0643   if (gettimeofday(&time, nullptr))
0644     return 0;
0645   return (double)time.tv_sec + (double)time.tv_usec * .000001;
0646 }
0647 
0648 // ------------ method called when starting to processes a luminosity block  ------------
0649 /*
0650 void
0651 HLTObjectMonitorProtonLead::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
0652 {
0653 }
0654 */
0655 
0656 // ------------ method called when ending the processing of a luminosity block  ------------
0657 /*
0658 void
0659 HLTObjectMonitorProtonLead::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
0660 {
0661 }
0662 */
0663 
0664 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0665 // void
0666 // HLTObjectMonitorProtonLead::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0667 //   //The following says we do not know what parameters are allowed so do no validation
0668 //   // Please change this to state exactly what you do use, even if it is no parameters
0669 //   edm::ParameterSetDescription desc;
0670 //   desc.setUnknown();
0671 //   descriptions.addDefault(desc);
0672 // }
0673 
0674 //define this as a plug-in
0675 DEFINE_FWK_MODULE(HLTObjectMonitorProtonLead);