CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
BaseTnPEfficiencyTask Class Referenceabstract

#include <BaseTnPEfficiencyTask.h>

Inheritance diagram for BaseTnPEfficiencyTask:
DQMEDAnalyzer edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator > CSCTnPEfficiencyTask DTTnPEfficiencyTask RPCTnPEfficiencyTask

Public Member Functions

 BaseTnPEfficiencyTask (const edm::ParameterSet &config)
 Constructor. More...
 
 ~BaseTnPEfficiencyTask () override
 Destructor. More...
 
- Public Member Functions inherited from DQMEDAnalyzer
void accumulate (edm::Event const &event, edm::EventSetup const &setup) final
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
void beginStream (edm::StreamID id) final
 
 DQMEDAnalyzer ()
 
void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void endRun (edm::Run const &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Protected Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &context) override
 Analyze. More...
 
void bookHistograms (DQMStore::IBooker &iBooker, edm::Run const &run, edm::EventSetup const &context) override
 
void dqmBeginRun (const edm::Run &run, const edm::EventSetup &context) override
 BeginRun. More...
 
bool hasTrigger (std::vector< int > &trigIndices, const trigger::TriggerObjectCollection &trigObjs, edm::Handle< trigger::TriggerEvent > &trigEvent, const reco::Muon &muon)
 
virtual std::string topFolder () const =0
 Return the top folder. More...
 
- Protected Member Functions inherited from DQMEDAnalyzer
uint64_t meId () const
 

Protected Attributes

const double m_borderCut
 
const bool m_detailedAnalysis
 
const double m_dxCut
 
std::map< std::string,
MonitorElement * > 
m_histos
 
const edm::EDGetTokenT
< reco::MuonCollection
m_muToken
 
int m_nEvents
 
std::vector< std::vector
< unsigned > > 
m_probeIndices
 
std::vector< std::vector
< unsigned > > 
m_tagIndices
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 
unsigned int streamId_
 

Private Attributes

const double m_dxyCut
 
const double m_dzCut
 
const double m_highPairMassCut
 
HLTConfigProvider m_hltConfig
 
const double m_lowPairMassCut
 
const edm::EDGetTokenT
< std::vector< reco::Vertex > > 
m_primaryVerticesToken
 
const StringCutObjectSelector
< reco::Candidate, true > 
m_probeSelector
 
const StringCutObjectSelector
< reco::Muon, true > 
m_tagSelector
 
const edm::EDGetTokenT
< trigger::TriggerEvent
m_triggerEventToken
 
const edm::EDGetTokenT
< edm::TriggerResults
m_triggerResultsToken
 
std::vector< int > m_trigIndices
 
const std::string m_trigName
 

Additional Inherited Members

- Public Types inherited from DQMEDAnalyzer
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static void globalEndJob (DQMEDAnalyzerGlobalCache const *)
 
static void globalEndLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &setup, LuminosityBlockContext const *context)
 
static void globalEndRunProduce (edm::Run &run, edm::EventSetup const &setup, RunContext const *context)
 
static std::unique_ptr
< DQMEDAnalyzerGlobalCache
initializeGlobalCache (edm::ParameterSet const &)
 

Detailed Description

Definition at line 35 of file BaseTnPEfficiencyTask.h.

Constructor & Destructor Documentation

BaseTnPEfficiencyTask::BaseTnPEfficiencyTask ( const edm::ParameterSet config)

Constructor.

Definition at line 24 of file BaseTnPEfficiencyTask.cc.

References LogTrace.

25  : m_nEvents(0),
26  m_muToken(consumes<reco::MuonCollection>(config.getUntrackedParameter<edm::InputTag>("inputTagMuons"))),
27  m_borderCut(config.getUntrackedParameter<double>("borderCut")),
28  m_dxCut(config.getUntrackedParameter<double>("dx_cut")),
29  m_detailedAnalysis(config.getUntrackedParameter<bool>("detailedAnalysis")),
31  consumes<std::vector<reco::Vertex>>(config.getUntrackedParameter<edm::InputTag>("inputTagPrimaryVertices"))),
33  consumes<edm::TriggerResults>(config.getUntrackedParameter<edm::InputTag>("trigResultsTag"))),
34  m_triggerEventToken(consumes<trigger::TriggerEvent>(config.getUntrackedParameter<edm::InputTag>("trigEventTag"))),
35  m_trigName(config.getUntrackedParameter<std::string>("trigName")),
37  m_dxyCut(config.getUntrackedParameter<double>("probeDxyCut")),
38  m_dzCut(config.getUntrackedParameter<double>("probeDzCut")),
40  m_lowPairMassCut(config.getUntrackedParameter<double>("lowPairMassCut")),
41  m_highPairMassCut(config.getUntrackedParameter<double>("highPairMassCut")) {
42  LogTrace("DQMOffline|MuonDPG|BaseTnPEfficiencyTask") << "[BaseTnPEfficiencyTask]: Constructor" << std::endl;
43 }
T getUntrackedParameter(std::string const &, T const &) const
const std::string m_trigName
const edm::EDGetTokenT< edm::TriggerResults > m_triggerResultsToken
const edm::EDGetTokenT< reco::MuonCollection > m_muToken
const edm::EDGetTokenT< trigger::TriggerEvent > m_triggerEventToken
#define LogTrace(id)
const edm::EDGetTokenT< std::vector< reco::Vertex > > m_primaryVerticesToken
const StringCutObjectSelector< reco::Candidate, true > m_probeSelector
const StringCutObjectSelector< reco::Muon, true > m_tagSelector
BaseTnPEfficiencyTask::~BaseTnPEfficiencyTask ( )
override

Destructor.

Definition at line 45 of file BaseTnPEfficiencyTask.cc.

References LogTrace, and m_nEvents.

45  {
46  LogTrace("DQMOffline|MuonDPG|BaseTnPEfficiencyTask")
47  << "[BaseTnPEfficiencyTask]: analyzed " << m_nEvents << " events" << std::endl;
48 }
#define LogTrace(id)

Member Function Documentation

void BaseTnPEfficiencyTask::analyze ( const edm::Event event,
const edm::EventSetup context 
)
overrideprotectedvirtual

Analyze.

Reimplemented from DQMEDAnalyzer.

Reimplemented in RPCTnPEfficiencyTask, DTTnPEfficiencyTask, and CSCTnPEfficiencyTask.

Definition at line 88 of file BaseTnPEfficiencyTask.cc.

References funct::abs(), reco::LeafCandidate::charge(), edm::Event::getByToken(), hasTrigger(), edm::HandleBase::isValid(), m_dxyCut, m_dzCut, m_highPairMassCut, m_histos, m_muToken, m_nEvents, m_primaryVerticesToken, m_probeIndices, m_probeSelector, m_tagIndices, m_tagSelector, m_triggerEventToken, m_triggerResultsToken, m_trigIndices, HLT_FULL_cff::muon, patZpeak::muons, reco::LeafCandidate::polarP4(), reco::Vertex::position(), GlobalPosition_Frontier_DevDB_cff::tag, and triggerResults.

Referenced by CSCTnPEfficiencyTask::analyze(), DTTnPEfficiencyTask::analyze(), and RPCTnPEfficiencyTask::analyze().

88  {
89  ++m_nEvents;
90 
92  if (!event.getByToken(m_muToken, muons))
93  return;
94 
96  if (!event.getByToken(m_primaryVerticesToken, vtxs))
97  return;
98  const reco::Vertex& vertex = vtxs->at(0);
99 
101  if (!event.getByToken(m_triggerResultsToken, triggerResults))
102  return;
103 
105  if (!event.getByToken(m_triggerEventToken, triggerEvent))
106  return;
107 
108  //common tnp variables
109  std::vector<unsigned> preSel_tag_indices;
110  std::vector<unsigned> tag_indices;
111  std::vector<unsigned> preSel_probe_indices;
112  std::vector<unsigned> probe_indices;
113 
114  if (muons.isValid() && vtxs.isValid()) {
115  //Is there a better way to initialize two different type variables?
116  for (auto [muon, muonColl_index] = std::tuple{std::vector<reco::Muon>::const_iterator{(*muons).begin()}, 0};
117  muon != (*muons).end();
118  ++muon, ++muonColl_index) {
119  bool trigMatch = false;
120 
121  //Getting trigger infos for tag selection
122  if (triggerResults.isValid() && triggerEvent.isValid()) {
123  const trigger::TriggerObjectCollection trigObjColl = triggerEvent->getObjects();
124  trigMatch = hasTrigger(m_trigIndices, trigObjColl, triggerEvent, *muon);
125  }
126 
127  //Probe selection
128  if (m_probeSelector(*muon) && (std::abs(muon->muonBestTrack()->dxy(vertex.position())) < m_dxyCut) &&
129  (std::abs(muon->muonBestTrack()->dz(vertex.position())) < m_dzCut)) {
130  preSel_probe_indices.push_back(muonColl_index);
131  }
132  //Tag selection
133  if (m_tagSelector(*muon) && trigMatch) {
134  preSel_tag_indices.push_back(muonColl_index);
135  }
136 
137  } //loop over muons
138  }
139 
140  //Probe selection
141  for (const auto i_tag : preSel_tag_indices) {
142  reco::Muon tag = (*muons).at(i_tag);
143  float pt_max = 0.;
144  int max_pt_idx;
145  bool pair_found = false;
146 
147  for (const auto i_probe : preSel_probe_indices) {
148  //Prevent tag and probe to be the same object
149  if (i_probe == i_tag)
150  continue;
151 
152  reco::Muon preSel_probe = (*muons).at(i_probe);
153 
154  int pair_charge_product = tag.charge() * preSel_probe.charge();
155 
156  //check if tag+probe pair is compatible with Z decay
157  if (pair_charge_product > 0)
158  continue;
159 
160  float pair_mass = (tag.polarP4() + preSel_probe.polarP4()).M();
161  m_histos.find("pairMass")->second->Fill(pair_mass);
162 
163  if (pair_mass < m_lowPairMassCut || pair_mass > m_highPairMassCut)
164  continue;
165 
166  float pair_pt = (tag.polarP4() + preSel_probe.polarP4()).Pt();
167  if (pair_pt > pt_max) {
168  pair_found = true;
169  pt_max = pair_pt;
170  max_pt_idx = i_probe;
171  }
172  }
173  if (pair_found) {
174  probe_indices.push_back(max_pt_idx);
175  tag_indices.push_back(i_tag);
176  }
177  }
178 
179  m_probeIndices.push_back(probe_indices);
180  m_tagIndices.push_back(tag_indices);
181 }
bool hasTrigger(std::vector< int > &trigIndices, const trigger::TriggerObjectCollection &trigObjs, edm::Handle< trigger::TriggerEvent > &trigEvent, const reco::Muon &muon)
std::vector< std::vector< unsigned > > m_tagIndices
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
const edm::EDGetTokenT< edm::TriggerResults > m_triggerResultsToken
const edm::EDGetTokenT< reco::MuonCollection > m_muToken
const Point & position() const
position
Definition: Vertex.h:127
const edm::EDGetTokenT< trigger::TriggerEvent > m_triggerEventToken
const edm::EDGetTokenT< std::vector< reco::Vertex > > m_primaryVerticesToken
std::vector< std::vector< unsigned > > m_probeIndices
const StringCutObjectSelector< reco::Candidate, true > m_probeSelector
std::vector< int > m_trigIndices
const PolarLorentzVector & polarP4() const final
four-momentum Lorentz vector
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::map< std::string, MonitorElement * > m_histos
static std::string const triggerResults
Definition: EdmProvDump.cc:44
bool isValid() const
Definition: HandleBase.h:70
const StringCutObjectSelector< reco::Muon, true > m_tagSelector
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
tuple muons
Definition: patZpeak.py:41
int charge() const final
electric charge
void BaseTnPEfficiencyTask::bookHistograms ( DQMStore::IBooker iBooker,
edm::Run const &  run,
edm::EventSetup const &  context 
)
overrideprotectedvirtual

Implements DQMEDAnalyzer.

Reimplemented in RPCTnPEfficiencyTask, CSCTnPEfficiencyTask, and DTTnPEfficiencyTask.

Definition at line 67 of file BaseTnPEfficiencyTask.cc.

References dqm::implementation::IBooker::book1D(), LogTrace, m_detailedAnalysis, m_histos, Pi, dqm::implementation::NavigatorBase::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, and topFolder().

Referenced by CSCTnPEfficiencyTask::bookHistograms(), DTTnPEfficiencyTask::bookHistograms(), and RPCTnPEfficiencyTask::bookHistograms().

69  {
70  LogTrace("DQMOffline|MuonDPG|BaseTnPEfficiencyTask") << "[BaseTnPEfficiencyTask]: bookHistograms" << std::endl;
71 
72  if (m_detailedAnalysis) {
73  std::string baseDir = topFolder() + "/detailed/";
74  iBooker.setCurrentFolder(baseDir);
75 
76  LogTrace("DQMOffline|MuonDPG|BaseTnPEfficiencyTask")
77  << "[BaseTnPEfficiencyTask]: booking histos in " << baseDir << std::endl;
78 
79  m_histos["probePt"] = iBooker.book1D("probePt", "probePt;probe p_{T} [GeV];Events", 125, 0., 250.);
80  m_histos["probeEta"] = iBooker.book1D("probeEta", "probeEta;probe #eta;Events", 24, -2.4, 2.4);
81  m_histos["probePhi"] = iBooker.book1D("probePhi", "probePhi;probe #phi; Events", 36, -TMath::Pi(), TMath::Pi());
82  m_histos["probeNumberOfMatchedStations"] = iBooker.book1D(
83  "probeNumberOfMatchedStations", "probeNumberOfMatchedStations;Number of matched stations;Events", 5, 0., 5);
84  m_histos["pairMass"] = iBooker.book1D("pairMass", "pairMass", 25, 70., 120.);
85  }
86 }
const double Pi
virtual std::string topFolder() const =0
Return the top folder.
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
#define LogTrace(id)
std::map< std::string, MonitorElement * > m_histos
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
void BaseTnPEfficiencyTask::dqmBeginRun ( const edm::Run run,
const edm::EventSetup context 
)
overrideprotectedvirtual

BeginRun.

Reimplemented from DQMEDAnalyzer.

Definition at line 50 of file BaseTnPEfficiencyTask.cc.

References HLTConfigProvider::init(), m_hltConfig, m_trigIndices, m_trigName, EgammaValidation_cff::pathName, HLTConfigProvider::size(), and HLTConfigProvider::triggerName().

50  {
51  bool changed = true;
52  m_hltConfig.init(run, context, "HLT", changed);
53 
54  bool enableWildCard = true;
55 
56  TString tName = TString(m_trigName);
57  TRegexp tNamePattern = TRegexp(tName, enableWildCard);
58 
59  for (unsigned iPath = 0; iPath < m_hltConfig.size(); ++iPath) {
60  TString pathName = TString(m_hltConfig.triggerName(iPath));
61  if (pathName.Contains(tNamePattern)) {
62  m_trigIndices.push_back(static_cast<int>(iPath));
63  }
64  }
65 }
unsigned int size() const
number of trigger paths in trigger table
const std::string m_trigName
const std::string & triggerName(unsigned int triggerIndex) const
std::vector< int > m_trigIndices
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
HLTConfigProvider m_hltConfig
bool BaseTnPEfficiencyTask::hasTrigger ( std::vector< int > &  trigIndices,
const trigger::TriggerObjectCollection trigObjs,
edm::Handle< trigger::TriggerEvent > &  trigEvent,
const reco::Muon muon 
)
protected

Definition at line 183 of file BaseTnPEfficiencyTask.cc.

References reco::deltaR2(), relativeConstraints::keys, m_hltConfig, and HLTConfigProvider::moduleLabels().

Referenced by analyze().

186  {
187  float dR2match = 999.;
188  for (int trigIdx : trigIndices) {
189  const std::vector<std::string> trigModuleLabels = m_hltConfig.moduleLabels(trigIdx);
190  const unsigned trigModuleIndex = trigModuleLabels.size() - 2;
191  const unsigned hltFilterIndex = trigEvent->filterIndex(edm::InputTag(trigModuleLabels[trigModuleIndex], "", "HLT"));
192  if (hltFilterIndex < trigEvent->sizeFilters()) {
193  const trigger::Keys keys = trigEvent->filterKeys(hltFilterIndex);
194  const trigger::Vids vids = trigEvent->filterIds(hltFilterIndex);
195  const unsigned nTriggers = vids.size();
196 
197  for (unsigned iTrig = 0; iTrig < nTriggers; ++iTrig) {
198  trigger::TriggerObject trigObj = trigObjs[keys[iTrig]];
199  float dR2 = deltaR2(muon, trigObj);
200  if (dR2 < dR2match)
201  dR2match = dR2;
202  }
203  }
204  }
205  return dR2match < 0.01;
206 }
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:21
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
std::vector< size_type > Keys
HLTConfigProvider m_hltConfig
std::vector< int > Vids
virtual std::string BaseTnPEfficiencyTask::topFolder ( ) const
protectedpure virtual

Return the top folder.

Implemented in RPCTnPEfficiencyTask, CSCTnPEfficiencyTask, and DTTnPEfficiencyTask.

Referenced by bookHistograms().

Member Data Documentation

const double BaseTnPEfficiencyTask::m_borderCut
protected
const bool BaseTnPEfficiencyTask::m_detailedAnalysis
protected
const double BaseTnPEfficiencyTask::m_dxCut
protected
const double BaseTnPEfficiencyTask::m_dxyCut
private

Definition at line 82 of file BaseTnPEfficiencyTask.h.

Referenced by analyze().

const double BaseTnPEfficiencyTask::m_dzCut
private

Definition at line 83 of file BaseTnPEfficiencyTask.h.

Referenced by analyze().

const double BaseTnPEfficiencyTask::m_highPairMassCut
private

Definition at line 92 of file BaseTnPEfficiencyTask.h.

Referenced by analyze().

std::map<std::string, MonitorElement*> BaseTnPEfficiencyTask::m_histos
protected
HLTConfigProvider BaseTnPEfficiencyTask::m_hltConfig
private

Definition at line 78 of file BaseTnPEfficiencyTask.h.

Referenced by dqmBeginRun(), and hasTrigger().

const double BaseTnPEfficiencyTask::m_lowPairMassCut
private

Definition at line 91 of file BaseTnPEfficiencyTask.h.

const edm::EDGetTokenT<reco::MuonCollection> BaseTnPEfficiencyTask::m_muToken
protected
int BaseTnPEfficiencyTask::m_nEvents
protected
const edm::EDGetTokenT<std::vector<reco::Vertex> > BaseTnPEfficiencyTask::m_primaryVerticesToken
private

Definition at line 73 of file BaseTnPEfficiencyTask.h.

Referenced by analyze().

std::vector<std::vector<unsigned> > BaseTnPEfficiencyTask::m_probeIndices
protected
const StringCutObjectSelector<reco::Candidate, true> BaseTnPEfficiencyTask::m_probeSelector
private

Definition at line 81 of file BaseTnPEfficiencyTask.h.

Referenced by analyze().

std::vector<std::vector<unsigned> > BaseTnPEfficiencyTask::m_tagIndices
protected

Definition at line 60 of file BaseTnPEfficiencyTask.h.

Referenced by analyze().

const StringCutObjectSelector<reco::Muon, true> BaseTnPEfficiencyTask::m_tagSelector
private

Definition at line 86 of file BaseTnPEfficiencyTask.h.

Referenced by analyze().

const edm::EDGetTokenT<trigger::TriggerEvent> BaseTnPEfficiencyTask::m_triggerEventToken
private

Definition at line 75 of file BaseTnPEfficiencyTask.h.

Referenced by analyze().

const edm::EDGetTokenT<edm::TriggerResults> BaseTnPEfficiencyTask::m_triggerResultsToken
private

Definition at line 74 of file BaseTnPEfficiencyTask.h.

Referenced by analyze().

std::vector<int> BaseTnPEfficiencyTask::m_trigIndices
private

Definition at line 89 of file BaseTnPEfficiencyTask.h.

Referenced by analyze(), and dqmBeginRun().

const std::string BaseTnPEfficiencyTask::m_trigName
private

Definition at line 77 of file BaseTnPEfficiencyTask.h.

Referenced by dqmBeginRun().