Skip to content

Commit

Permalink
Merge pull request #20026 from rmanzoni/master_tau3muDQM
Browse files Browse the repository at this point in the history
[HLT] add tau3mu trigger DQM
  • Loading branch information
cmsbuild committed Sep 3, 2017
2 parents 7dd7091 + f412c60 commit 67b29c7
Show file tree
Hide file tree
Showing 5 changed files with 310 additions and 1 deletion.
161 changes: 161 additions & 0 deletions DQMOffline/Trigger/plugins/Tau3MuMonitor.cc
@@ -0,0 +1,161 @@
#include "DQMOffline/Trigger/plugins/Tau3MuMonitor.h"

Tau3MuMonitor::Tau3MuMonitor( const edm::ParameterSet& iConfig ) :
folderName_ ( iConfig.getParameter<std::string>("FolderName") ) ,
tauToken_ ( mayConsume<reco::CompositeCandidateCollection>(iConfig.getParameter<edm::InputTag>("taus") ) ) ,
pt_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("ptPSet" ) ) ) ,
eta_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("etaPSet" ) ) ) ,
phi_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("phiPSet" ) ) ) ,
mass_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("massPSet") ) ) ,
genTriggerEventFlag_( new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("GenericTriggerEventPSet"),consumesCollector(), *this) )
{
// initialise histograms to null
tau1DPt_ = nullptr;
tau1DEta_ = nullptr;
tau1DPhi_ = nullptr;
tau1DMass_ = nullptr;
tau2DEtaPhi_ = nullptr;
}

Tau3MuMonitor::~Tau3MuMonitor() = default;

// shape the content of a "histogram PSet"
void Tau3MuMonitor::fillHistoPSetDescription(edm::ParameterSetDescription & pset)
{
pset.add<unsigned int>( "nbins" );
pset.add<double> ( "xmin" );
pset.add<double> ( "xmax" );
}

// read the information packed into an "histogram PSet"
MEbinning Tau3MuMonitor::getHistoPSet(edm::ParameterSet pset)
{
return MEbinning{
pset.getParameter<unsigned int>("nbins"),
pset.getParameter<double > ("xmin" ),
pset.getParameter<double > ("xmax" ),
};
}

// book histograms
void Tau3MuMonitor::bookHistograms(DQMStore::IBooker & ibooker,
edm::Run const & iRun,
edm::EventSetup const & iSetup)
{
std::string histname;

std::string currentFolder = folderName_ ;
ibooker.setCurrentFolder(currentFolder);

// tau 3 mu 1D pt
histname = "tau1DPt";
tau1DPt_ = ibooker.book1D(histname, "", pt_binning_.nbins, pt_binning_.xmin, pt_binning_.xmax);
tau1DPt_->setAxisTitle("3-#mu p_{T} [GeV]", 1);
tau1DPt_->setAxisTitle("counts" , 2);

// tau 3 mu 1D eta
histname = "tau1DEta";
tau1DEta_ = ibooker.book1D(histname, "", eta_binning_.nbins, eta_binning_.xmin, eta_binning_.xmax);
tau1DEta_->setAxisTitle("3-#mu #eta", 1);
tau1DEta_->setAxisTitle("counts" , 2);

// tau 3 mu 1D phi
histname = "tau1DPhi";
tau1DPhi_ = ibooker.book1D(histname, "", phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax);
tau1DPhi_->setAxisTitle("3-#mu #phi", 1);
tau1DPhi_->setAxisTitle("counts" , 2);

// tau 3 mu 1D mass
histname = "tau1DMass";
tau1DMass_ = ibooker.book1D(histname, "", mass_binning_.nbins, mass_binning_.xmin, mass_binning_.xmax);
tau1DMass_->setAxisTitle("mass_{3#mu} [GeV]", 1);
tau1DMass_->setAxisTitle("counts" , 2);

// tau 3 mu 2D eta vs phi
histname = "tau2DEtaPhi";
tau2DEtaPhi_ = ibooker.book2D(histname, "", eta_binning_.nbins, eta_binning_.xmin, eta_binning_.xmax,
phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax);
tau2DEtaPhi_->setAxisTitle("3-#mu #eta", 1);
tau2DEtaPhi_->setAxisTitle("3-#mu #phi", 2);

// Initialize the GenericTriggerEventFlag
if ( genTriggerEventFlag_ && genTriggerEventFlag_->on() ) genTriggerEventFlag_->initRun( iRun, iSetup );

}

void Tau3MuMonitor::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup)
{

// require the trigger to be fired
if (genTriggerEventFlag_->on() && !genTriggerEventFlag_->accept(iEvent, iSetup) ) return;

// check if the previous event failed because of missing tau3mu collection.
// Return silently, a warning must have been issued already at this point
if (!validProduct_) return;

// get ahold of the tau(3mu) collection
edm::Handle<reco::CompositeCandidateCollection> tauHandle;
iEvent.getByToken( tauToken_, tauHandle );

// if the handle is not valid issue a warning (only for the forst occurrency)
if (!tauHandle.isValid()) {
edm::LogWarning("ProductNotValid") << "Tau3Mu trigger product not valid";
validProduct_ = false;
return;
}

// loop and fill
for (auto const & itau : *tauHandle) {
tau1DPt_ ->Fill(itau.pt ());
tau1DEta_ ->Fill(itau.eta ());
tau1DPhi_ ->Fill(itau.phi ());
tau1DMass_ ->Fill(itau.mass());
tau2DEtaPhi_->Fill(itau.eta(), itau.phi());
}

}

void Tau3MuMonitor::fillDescriptions(edm::ConfigurationDescriptions & descriptions)
{
edm::ParameterSetDescription desc;
//
desc.add<std::string> ( "FolderName", "HLT/BPH/" );
//
desc.add<edm::InputTag>( "taus", edm::InputTag("hltTauPt10MuPts511Mass1p2to2p3Iso", "Taus") );
//
edm::ParameterSetDescription histoPSet;
edm::ParameterSetDescription ptPSet ;
edm::ParameterSetDescription etaPSet ;
edm::ParameterSetDescription phiPSet ;
edm::ParameterSetDescription massPSet ;
fillHistoPSetDescription(ptPSet ); // order matters: this must come before the PSets are added
fillHistoPSetDescription(etaPSet );
fillHistoPSetDescription(phiPSet );
fillHistoPSetDescription(massPSet);
histoPSet.add<edm::ParameterSetDescription>("ptPSet" , ptPSet );
histoPSet.add<edm::ParameterSetDescription>("etaPSet" , etaPSet );
histoPSet.add<edm::ParameterSetDescription>("phiPSet" , phiPSet );
histoPSet.add<edm::ParameterSetDescription>("massPSet", massPSet);
desc.add<edm::ParameterSetDescription>("histoPSet", histoPSet);
//
edm::ParameterSetDescription genericTriggerEventPSet;
genericTriggerEventPSet.add<bool> ("andOr" );
genericTriggerEventPSet.add<edm::InputTag> ("dcsInputTag" , edm::InputTag("scalersRawToDigi") );
genericTriggerEventPSet.add<std::vector<int> > ("dcsPartitions" , {} );
genericTriggerEventPSet.add<bool> ("andOrDcs" , false );
genericTriggerEventPSet.add<bool> ("errorReplyDcs" , true );
genericTriggerEventPSet.add<std::string> ("dbLabel" , "" );
genericTriggerEventPSet.add<bool> ("andOrHlt" , true );
genericTriggerEventPSet.add<edm::InputTag> ("hltInputTag" , edm::InputTag("TriggerResults::HLT") );
genericTriggerEventPSet.add<std::vector<std::string> >("hltPaths" , {} );
genericTriggerEventPSet.add<std::string> ("hltDBKey" , "" );
genericTriggerEventPSet.add<bool> ("errorReplyHlt" , false );
genericTriggerEventPSet.add<unsigned int> ("verbosityLevel", 0 );
desc.add<edm::ParameterSetDescription>("GenericTriggerEventPSet", genericTriggerEventPSet);
//
descriptions.add("tau3muMonitoring", desc);
}

// Define this as a plug-in
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(Tau3MuMonitor);
70 changes: 70 additions & 0 deletions DQMOffline/Trigger/plugins/Tau3MuMonitor.h
@@ -0,0 +1,70 @@
#ifndef DQMOFFLINE_TRIGGER_TAU3MUMONITOR_H
#define DQMOFFLINE_TRIGGER_TAU3MUMONITOR_H

#include <string>

// Framework
#include "CommonTools/Utils/interface/StringCutObjectSelector.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/Registry.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/MonitorElement.h"

// TriggerUtils
#include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"

// DataFormats
#include "DataFormats/Candidate/interface/CompositeCandidate.h"

struct MEbinning {
unsigned int nbins;
double xmin;
double xmax;
};

class Tau3MuMonitor : public DQMEDAnalyzer
{
public:
Tau3MuMonitor( const edm::ParameterSet& );
~Tau3MuMonitor() override;
static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
static void fillHistoPSetDescription(edm::ParameterSetDescription & pset);

protected:
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
void analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) override;

private:
static MEbinning getHistoPSet (edm::ParameterSet pset);

std::string folderName_;

bool validProduct_ = true; // internally store a flag to remember whether the needed tau3mu collection is present and valid

edm::EDGetTokenT<reco::CompositeCandidateCollection> tauToken_; // tau 3 mu collection

MonitorElement* tau1DPt_ ; // 1D tau pt histogram
MonitorElement* tau1DEta_ ; // 1D tau eta histogram
MonitorElement* tau1DPhi_ ; // 1D tau phi histogram
MonitorElement* tau1DMass_ ; // 1D tau mass histogram
MonitorElement* tau2DEtaPhi_; // 2D tau eta vs phi histogram

MEbinning pt_binning_ ; // for the 1D tau pt histogram
MEbinning eta_binning_ ; // for the 1D tau eta histogram and 2D tau eta vs phi histogram
MEbinning phi_binning_ ; // for the 1D tau phi histogram and 2D tau eta vs phi histogram
MEbinning mass_binning_; // for the 1D tau mass histogram

std::unique_ptr<GenericTriggerEventFlag> genTriggerEventFlag_; // "is trigger fired?" flag
};

#endif // DQMOFFLINE_TRIGGER_TAU3MUMONITOR_H
5 changes: 4 additions & 1 deletion DQMOffline/Trigger/python/BPHMonitor_cff.py
@@ -1,6 +1,8 @@
import FWCore.ParameterSet.Config as cms

from DQMOffline.Trigger.BPHMonitor_cfi import hltBPHmonitoring
# Tau3Mu
from DQMOffline.Trigger.Tau3MuMonitor_cff import *

# HLT_PFMETNoMu90_PFMHTNoMu90_IDTight
Dimuon20_Jpsi_BPHMonitoring = hltBPHmonitoring.clone()
Expand Down Expand Up @@ -32,6 +34,7 @@


bphMonitorHLT = cms.Sequence(
bphHLTmonitoring
bphHLTmonitoring *
tau3MuMonitorHLT
)

31 changes: 31 additions & 0 deletions DQMOffline/Trigger/python/Tau3MuMonitor_cff.py
@@ -0,0 +1,31 @@
import FWCore.ParameterSet.Config as cms

from DQMOffline.Trigger.Tau3MuMonitor_cfi import hltTau3Mumonitoring

HLT_Tau3Mu_Mu7_Mu1_TkMu1_Tau15_Monitoring = hltTau3Mumonitoring.clone()
HLT_Tau3Mu_Mu7_Mu1_TkMu1_Tau15_Monitoring.FolderName = cms.string('HLT/BPH/Tau3Mu/Mu7_Mu1_TkMu1_Tau15')
HLT_Tau3Mu_Mu7_Mu1_TkMu1_Tau15_Monitoring.taus = cms.InputTag('hltTauPt15MuPts711Mass1p3to2p1Iso', 'Taus') # 3-muon candidates
HLT_Tau3Mu_Mu7_Mu1_TkMu1_Tau15_Monitoring.GenericTriggerEventPSet.hltPaths = cms.vstring('HLT_Tau3Mu_Mu7_Mu1_TkMu1_Tau15_v*')

HLT_Tau3Mu_Mu7_Mu1_TkMu1_Tau15_Charge1_Monitoring = hltTau3Mumonitoring.clone()
HLT_Tau3Mu_Mu7_Mu1_TkMu1_Tau15_Charge1_Monitoring.FolderName = cms.string('HLT/BPH/Tau3Mu/Mu7_Mu1_TkMu1_Tau15_Charge1')
HLT_Tau3Mu_Mu7_Mu1_TkMu1_Tau15_Charge1_Monitoring.taus = cms.InputTag('hltTauPt15MuPts711Mass1p3to2p1IsoCharge1', 'Taus') # 3-muon candidates, charge = 1
HLT_Tau3Mu_Mu7_Mu1_TkMu1_Tau15_Charge1_Monitoring.GenericTriggerEventPSet.hltPaths = cms.vstring('HLT_Tau3Mu_Mu7_Mu1_TkMu1_Tau15_Charge1_v*')

HLT_Tau3Mu_Mu7_Mu1_TkMu1_IsoTau15_Monitoring = hltTau3Mumonitoring.clone()
HLT_Tau3Mu_Mu7_Mu1_TkMu1_IsoTau15_Monitoring.FolderName = cms.string('HLT/BPH/Tau3Mu/Mu7_Mu1_TkMu1_IsoTau15')
HLT_Tau3Mu_Mu7_Mu1_TkMu1_IsoTau15_Monitoring.taus = cms.InputTag('hltTauPt15MuPts711Mass1p3to2p1Iso', 'SelectedTaus') # 3-muon isolated candidates
HLT_Tau3Mu_Mu7_Mu1_TkMu1_IsoTau15_Monitoring.GenericTriggerEventPSet.hltPaths = cms.vstring('HLT_Tau3Mu_Mu7_Mu1_TkMu1_IsoTau15_v*')

HLT_Tau3Mu_Mu7_Mu1_TkMu1_IsoTau15_Charge1_Monitoring = hltTau3Mumonitoring.clone()
HLT_Tau3Mu_Mu7_Mu1_TkMu1_IsoTau15_Charge1_Monitoring.FolderName = cms.string('HLT/BPH/Tau3Mu/Mu7_Mu1_TkMu1_IsoTau15_Charge1')
HLT_Tau3Mu_Mu7_Mu1_TkMu1_IsoTau15_Charge1_Monitoring.taus = cms.InputTag('hltTauPt15MuPts711Mass1p3to2p1IsoCharge1', 'SelectedTaus') # 3-muon isolated candidates, charge = 1
HLT_Tau3Mu_Mu7_Mu1_TkMu1_IsoTau15_Charge1_Monitoring.GenericTriggerEventPSet.hltPaths = cms.vstring('HLT_Tau3Mu_Mu7_Mu1_TkMu1_IsoTau15_Charge1_v*')

tau3MuMonitorHLT = cms.Sequence(
HLT_Tau3Mu_Mu7_Mu1_TkMu1_Tau15_Monitoring +
HLT_Tau3Mu_Mu7_Mu1_TkMu1_Tau15_Charge1_Monitoring +
HLT_Tau3Mu_Mu7_Mu1_TkMu1_IsoTau15_Monitoring +
HLT_Tau3Mu_Mu7_Mu1_TkMu1_IsoTau15_Charge1_Monitoring
)

44 changes: 44 additions & 0 deletions DQMOffline/Trigger/python/Tau3MuMonitor_cfi.py
@@ -0,0 +1,44 @@
from math import pi

import FWCore.ParameterSet.Config as cms

from DQMOffline.Trigger.tau3muMonitoring_cfi import tau3muMonitoring

hltTau3Mumonitoring = tau3muMonitoring.clone()

# DQM directory
hltTau3Mumonitoring.FolderName = cms.string('HLT/BPH/Tau3Mu/')

# histogram binning
hltTau3Mumonitoring.histoPSet.ptPSet = cms.PSet(
nbins = cms.uint32( 40 ),
xmin = cms.double(- 0.5),
xmax = cms.double( 99.5),
)
hltTau3Mumonitoring.histoPSet.etaPSet = cms.PSet(
nbins = cms.uint32( 10 ),
xmin = cms.double(- 2.6),
xmax = cms.double( 2.6),
)
hltTau3Mumonitoring.histoPSet.phiPSet = cms.PSet(
nbins = cms.uint32( 10),
xmin = cms.double(-pi),
xmax = cms.double( pi),
)
hltTau3Mumonitoring.histoPSet.massPSet = cms.PSet(
nbins = cms.uint32( 40 ),
xmin = cms.double( 0.5),
xmax = cms.double( 3. ),
)

hltTau3Mumonitoring.taus = cms.InputTag("hltTauPt15MuPts711Mass1p3to2p1Iso", "Taus") # 3-muon candidates

hltTau3Mumonitoring.GenericTriggerEventPSet.andOr = cms.bool( False ) # https://github.com/cms-sw/cmssw/blob/76d343005c33105be1e01b7b7278c07d753398db/CommonTools/TriggerUtils/src/GenericTriggerEventFlag.cc#L249
hltTau3Mumonitoring.GenericTriggerEventPSet.andOrHlt = cms.bool( True ) # https://github.com/cms-sw/cmssw/blob/76d343005c33105be1e01b7b7278c07d753398db/CommonTools/TriggerUtils/src/GenericTriggerEventFlag.cc#L114
hltTau3Mumonitoring.GenericTriggerEventPSet.hltPaths = cms.vstring("HLT_Tau3Mu_Mu7_Mu1_TkMu1_IsoTau15_v*")
# determine the DCS partitions to be active https://github.com/cms-sw/cmssw/blob/b767924e38a6b75340e6e120ece95b648bd11d2d/DataFormats/Scalers/interface/DcsStatus.h#L35
# RPC (12) + DT (13-15) + CSC (16-17) + TRK (24-27) + PIX (28-29)
hltTau3Mumonitoring.GenericTriggerEventPSet.dcsPartitions = cms.vint32(12, 13, 14, 15, 16, 17, 24, 25, 26, 27, 28, 29)
# hltTau3Mumonitoring.GenericTriggerEventPSet.verbosityLevel = cms.uint32(2) # set to 2 for debugging
# hltTau3Mumonitoring.GenericTriggerEventPSet.hltInputTag = cms.InputTag("TriggerResults::reHLT") # change the process name to reHLT when running tests (if the process used to rerun the HLT is reHLT, of course)

0 comments on commit 67b29c7

Please sign in to comment.