Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:44:27

0001 #include "DQMOffline/Muon/interface/TriggerMatchEfficiencyPlotter.h"
0002 /** \class TriggerMatch monitor
0003  *  *  *
0004  *   *   *  DQM monitoring source for Trigger matching efficiency plotter  feature added to miniAOD
0005  *    *    *
0006  *     *     *  \author Bibhuprasad Mahakud (Purdue University, West Lafayette, USA)
0007  *      *      */
0008 
0009 // Framework
0010 #include <FWCore/Framework/interface/Event.h>
0011 #include "DataFormats/Common/interface/Handle.h"
0012 #include <FWCore/Framework/interface/ESHandle.h>
0013 #include <FWCore/Framework/interface/MakerMacros.h>
0014 #include <FWCore/Framework/interface/EventSetup.h>
0015 #include <FWCore/ParameterSet/interface/ParameterSet.h>
0016 #include "DQMServices/Core/interface/DQMStore.h"
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018 #include "FWCore/Framework/interface/Run.h"
0019 
0020 #include <iostream>
0021 #include <cstdio>
0022 #include <string>
0023 #include <cmath>
0024 #include "TF1.h"
0025 #include "TH1F.h"
0026 
0027 using namespace edm;
0028 using namespace std;
0029 
0030 //#define DEBUG
0031 
0032 TriggerMatchEfficiencyPlotter::TriggerMatchEfficiencyPlotter(const edm::ParameterSet &ps) {
0033 #ifdef DEBUG
0034   cout << "TriggerMatchEfficiencyPlotter(): Constructor " << endl;
0035 #endif
0036   parameters = ps;
0037 
0038   triggerhistName1_ = parameters.getParameter<string>("triggerhistName1");
0039   triggerhistName2_ = parameters.getParameter<string>("triggerhistName2");
0040   theFolder = parameters.getParameter<string>("folder");
0041 }
0042 TriggerMatchEfficiencyPlotter::~TriggerMatchEfficiencyPlotter() {}
0043 
0044 void TriggerMatchEfficiencyPlotter::dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) {
0045   ibooker.setCurrentFolder(theFolder);
0046 
0047   // efficiency plot
0048   h_eff_Path1_eta_tight = ibooker.book1D(
0049       "matchingEff_eta_" + triggerhistName1_ + "_tight", triggerhistName1_ + ":matching Eff. vs #eta", 8, -2.5, 2.5);
0050   h_eff_Path1_pt_tight = ibooker.book1D(
0051       "matchingEff_pt_" + triggerhistName1_ + "_tight", triggerhistName1_ + ":matching Eff. vs pt", 10, 20, 220);
0052   h_eff_Path1_phi_tight = ibooker.book1D(
0053       "matchingEff_phi_" + triggerhistName1_ + "_tight", triggerhistName1_ + ":matching Eff. vs #phi", 8, -3.0, 3.0);
0054   h_eff_Path2_eta_tight = ibooker.book1D(
0055       "matchingEff_eta_" + triggerhistName2_ + "_tight", triggerhistName2_ + ":matching Eff. vs #eta", 8, -2.5, 2.5);
0056   h_eff_Path2_pt_tight = ibooker.book1D(
0057       "matchingEff_pt_" + triggerhistName2_ + "_tight", triggerhistName2_ + ":matching Eff. vs pt", 10, 20, 220);
0058   h_eff_Path2_phi_tight = ibooker.book1D(
0059       "matchingEff_phi_" + triggerhistName2_ + "_tight", triggerhistName2_ + ":matching Eff. vs #phi", 8, -3.0, 3.0);
0060 
0061   // This prevents this ME to be normalized when drawn into the GUI
0062   h_eff_Path1_eta_tight->setEfficiencyFlag();
0063   h_eff_Path1_pt_tight->setEfficiencyFlag();
0064   h_eff_Path1_phi_tight->setEfficiencyFlag();
0065   h_eff_Path2_eta_tight->setEfficiencyFlag();
0066   h_eff_Path2_pt_tight->setEfficiencyFlag();
0067   h_eff_Path2_phi_tight->setEfficiencyFlag();
0068 
0069   // AXIS TITLES....
0070   h_eff_Path1_eta_tight->setAxisTitle("#eta", 1);
0071   h_eff_Path1_pt_tight->setAxisTitle("pt", 1);
0072   h_eff_Path1_phi_tight->setAxisTitle("#phi", 1);
0073   h_eff_Path2_eta_tight->setAxisTitle("#eta", 1);
0074   h_eff_Path2_pt_tight->setAxisTitle("pt", 1);
0075   h_eff_Path2_phi_tight->setAxisTitle("#phi", 1);
0076 
0077   /// --- Tight Muon trigger mathcing efficiency
0078   string inputdir = "Muons_miniAOD/TriggerMatchMonitor/EfficiencyInput";
0079   string numpath_eta_path1 = inputdir + "/passHLT" + triggerhistName1_ + "_eta_Tight";
0080   string denpath_eta_path1 = inputdir + "/totalHLT" + triggerhistName1_ + "_eta_Tight";
0081 
0082   string numpath_pt_path1 = inputdir + "/passHLT" + triggerhistName1_ + "_pt_Tight";
0083   string denpath_pt_path1 = inputdir + "/totalHLT" + triggerhistName1_ + "_pt_Tight";
0084 
0085   string numpath_phi_path1 = inputdir + "/passHLT" + triggerhistName1_ + "_phi_Tight";
0086   string denpath_phi_path1 = inputdir + "/totalHLT" + triggerhistName1_ + "_phi_Tight";
0087 
0088   string numpath_eta_path2 = inputdir + "/passHLT" + triggerhistName2_ + "_eta_Tight";
0089   string denpath_eta_path2 = inputdir + "/totalHLT" + triggerhistName2_ + "_eta_Tight";
0090 
0091   string numpath_pt_path2 = inputdir + "/passHLT" + triggerhistName2_ + "_pt_Tight";
0092   string denpath_pt_path2 = inputdir + "/totalHLT" + triggerhistName2_ + "_pt_Tight";
0093 
0094   string numpath_phi_path2 = inputdir + "/passHLT" + triggerhistName2_ + "_phi_Tight";
0095   string denpath_phi_path2 = inputdir + "/totalHLT" + triggerhistName2_ + "_phi_Tight";
0096 
0097   MonitorElement *Numerator_eta_path1 = igetter.get(numpath_eta_path1);
0098   MonitorElement *Denominator_eta_path1 = igetter.get(denpath_eta_path1);
0099 
0100   MonitorElement *Numerator_pt_path1 = igetter.get(numpath_pt_path1);
0101   MonitorElement *Denominator_pt_path1 = igetter.get(denpath_pt_path1);
0102 
0103   MonitorElement *Numerator_phi_path1 = igetter.get(numpath_phi_path1);
0104   MonitorElement *Denominator_phi_path1 = igetter.get(denpath_phi_path1);
0105 
0106   MonitorElement *Numerator_eta_path2 = igetter.get(numpath_eta_path2);
0107   MonitorElement *Denominator_eta_path2 = igetter.get(denpath_eta_path2);
0108 
0109   MonitorElement *Numerator_pt_path2 = igetter.get(numpath_pt_path2);
0110   MonitorElement *Denominator_pt_path2 = igetter.get(denpath_pt_path2);
0111 
0112   MonitorElement *Numerator_phi_path2 = igetter.get(numpath_phi_path2);
0113   MonitorElement *Denominator_phi_path2 = igetter.get(denpath_phi_path2);
0114 
0115   if (Numerator_eta_path1 && Denominator_eta_path1) {
0116     TH1F *h_numerator_eta_path1 = Numerator_eta_path1->getTH1F();
0117     TH1F *h_denominator_eta_path1 = Denominator_eta_path1->getTH1F();
0118     TH1F *h_eff_eta_path1 = h_eff_Path1_eta_tight->getTH1F();
0119 
0120     if (h_eff_eta_path1->GetSumw2N() == 0)
0121       h_eff_eta_path1->Sumw2();
0122     h_eff_eta_path1->Divide(h_numerator_eta_path1, h_denominator_eta_path1, 1., 1., "B");
0123   }
0124 
0125   if (Numerator_pt_path1 && Denominator_pt_path1) {
0126     TH1F *h_numerator_pt_path1 = Numerator_pt_path1->getTH1F();
0127     TH1F *h_denominator_pt_path1 = Denominator_pt_path1->getTH1F();
0128     TH1F *h_eff_pt_path1 = h_eff_Path1_pt_tight->getTH1F();
0129 
0130     if (h_eff_pt_path1->GetSumw2N() == 0)
0131       h_eff_pt_path1->Sumw2();
0132     h_eff_pt_path1->Divide(h_numerator_pt_path1, h_denominator_pt_path1, 1., 1., "B");
0133   }
0134 
0135   if (Numerator_phi_path1 && Denominator_phi_path1) {
0136     TH1F *h_numerator_phi_path1 = Numerator_phi_path1->getTH1F();
0137     TH1F *h_denominator_phi_path1 = Denominator_phi_path1->getTH1F();
0138     TH1F *h_eff_phi_path1 = h_eff_Path1_phi_tight->getTH1F();
0139 
0140     if (h_eff_phi_path1->GetSumw2N() == 0)
0141       h_eff_phi_path1->Sumw2();
0142     h_eff_phi_path1->Divide(h_numerator_phi_path1, h_denominator_phi_path1, 1., 1., "B");
0143   }
0144 
0145   //trigger path2
0146   if (Numerator_eta_path2 && Denominator_eta_path2) {
0147     TH1F *h_numerator_eta_path2 = Numerator_eta_path2->getTH1F();
0148     TH1F *h_denominator_eta_path2 = Denominator_eta_path2->getTH1F();
0149     TH1F *h_eff_eta_path2 = h_eff_Path2_eta_tight->getTH1F();
0150 
0151     if (h_eff_eta_path2->GetSumw2N() == 0)
0152       h_eff_eta_path2->Sumw2();
0153     h_eff_eta_path2->Divide(h_numerator_eta_path2, h_denominator_eta_path2, 1., 1., "B");
0154   }
0155 
0156   if (Numerator_pt_path2 && Denominator_pt_path2) {
0157     TH1F *h_numerator_pt_path2 = Numerator_pt_path2->getTH1F();
0158     TH1F *h_denominator_pt_path2 = Denominator_pt_path2->getTH1F();
0159     TH1F *h_eff_pt_path2 = h_eff_Path2_pt_tight->getTH1F();
0160 
0161     if (h_eff_pt_path2->GetSumw2N() == 0)
0162       h_eff_pt_path2->Sumw2();
0163     h_eff_pt_path2->Divide(h_numerator_pt_path2, h_denominator_pt_path2, 1., 1., "B");
0164   }
0165 
0166   if (Numerator_phi_path2 && Denominator_phi_path2) {
0167     TH1F *h_numerator_phi_path2 = Numerator_phi_path2->getTH1F();
0168     TH1F *h_denominator_phi_path2 = Denominator_phi_path2->getTH1F();
0169     TH1F *h_eff_phi_path2 = h_eff_Path2_phi_tight->getTH1F();
0170 
0171     if (h_eff_phi_path2->GetSumw2N() == 0)
0172       h_eff_phi_path2->Sumw2();
0173     h_eff_phi_path2->Divide(h_numerator_phi_path2, h_denominator_phi_path2, 1., 1., "B");
0174   }
0175 }