15 #include <boost/algorithm/string/replace.hpp> 38 : hltProcessName_(
pset.getParameter<
string>(
"hltProcessName")),
39 destination_(
pset.getUntrackedParameter<
string>(
"destination")),
40 requiredTriggers_(
pset.getUntrackedParameter<
vstring>(
"requiredTriggers")),
45 isLastFilter_(islastfilter),
46 hasTargetRecoCuts(targetParams_.exists(
"recoCuts")),
47 hasProbeRecoCuts(probeParams_.exists(
"recoCuts")),
48 targetMuonSelector_(targetParams_.getUntrackedParameter<
string>(
"recoCuts",
"")),
49 targetZ0Cut_(targetParams_.getUntrackedParameter<double>(
"z0Cut", 0.)),
50 targetD0Cut_(targetParams_.getUntrackedParameter<double>(
"d0Cut", 0.)),
51 targetptCutZ_(targetParams_.getUntrackedParameter<double>(
"ptCut_Z", 20.)),
52 targetptCutJpsi_(targetParams_.getUntrackedParameter<double>(
"ptCut_Jpsi", 20.)),
53 probeMuonSelector_(probeParams_.getUntrackedParameter<
string>(
"recoCuts",
"")),
54 probeZ0Cut_(probeParams_.getUntrackedParameter<double>(
"z0Cut", 0.)),
55 probeD0Cut_(probeParams_.getUntrackedParameter<double>(
"d0Cut", 0.)),
56 triggerSelector_(targetParams_.getUntrackedParameter<
string>(
"hltCuts",
"")),
57 hasTriggerCuts_(targetParams_.exists(
"hltCuts")) {
64 TPRegexp levelRegexp(
"L[1-3]");
67 TObjArray* levelArray = levelRegexp.MatchS(
moduleLabel_);
68 if (levelArray->GetEntriesFast() > 0) {
69 triggerLevel_ =
static_cast<const char*
>(((TObjString*)levelArray->At(0))->GetString());
75 TPRegexp ptRegexp(
"Mu([0-9]*)");
76 TObjArray* objArray = ptRegexp.MatchS(
hltPath_);
77 if (objArray->GetEntriesFast() >= 2) {
78 auto* ptCutString = (TObjString*)objArray->At(1);
79 cutMinPt_ = atoi(ptCutString->GetString());
86 TPRegexp suffixPtCut(
"Mu[0-9]+$");
109 book1D(iBooker,
"efficiencyEta_" +
suffix,
"eta",
";#eta;");
110 book1D(iBooker,
"efficiencyPhi_" +
suffix,
"phi",
";#phi;");
111 book1D(iBooker,
"efficiencyTurnOn_" +
suffix,
"pt",
";p_{T};");
121 book1D(iBooker,
"efficiencyCharge_" +
suffix,
"charge",
";charge;");
186 for (
size_t i = 0;
i < targetMuons.size();
i++) {
205 if (
muon.isTrackerMuon())
207 else if (
muon.isStandAloneMuon())
223 if (
matches[
i] >= targetMuons.size())
233 unsigned int numTriggers =
trigNames.size();
234 bool passTrigger =
false;
238 for (
unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
239 passTrigger = (
trigNames.triggerName(hltIndex).find(requiredTrigger) != std::string::npos &&
247 for (
unsigned long matche :
matches) {
248 if (matche < targetMuons.size())
254 if (nonSameSignPath.rfind(
"_SameSign") < nonSameSignPath.length()) {
256 nonSameSignPath = boost::replace_all_copy<string>(nonSameSignPath,
"_SameSign",
"");
257 nonSameSignPath = nonSameSignPath.substr(0, nonSameSignPath.rfind(
"_v") + 2);
259 bool passTriggerSS =
false;
261 for (
unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
263 passTriggerSS || (
trigNames.triggerName(hltIndex).substr(0, nonSameSignPath.size()) == nonSameSignPath &&
270 if (nonDZPath.rfind(
"_DZ") < nonDZPath.length()) {
272 nonDZPath = boost::replace_all_copy<string>(nonDZPath,
"_DZ",
"");
273 nonDZPath = nonDZPath.substr(0, nonDZPath.rfind(
"_v") + 2);
275 bool passTriggerDZ =
false;
277 for (
unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
278 passTriggerDZ = passTriggerDZ || (
trigNames.triggerName(hltIndex).find(nonDZPath) != std::string::npos &&
288 LogWarning(
"HLTMuonVal") <<
"Invalid binning parameters!";
321 targetPset =
pset.getUntrackedParameterSet(
target);
325 vector<string>::const_iterator iter;
327 for (iter =
names.begin(); iter !=
names.end(); ++iter) {
330 else if (targetPset.
existsAs<
T>(*iter,
false))
336 template <
class T1,
class T2>
338 const vector<T2>& collection2,
340 const size_t n1 = collection1.size();
341 const size_t n2 = collection2.size();
343 vector<size_t>
result(n1, -1);
344 vector<vector<double> > deltaRMatrix(n1, vector<double>(n2,
NOMATCH));
346 for (
size_t i = 0;
i < n1;
i++)
347 for (
size_t j = 0;
j < n2;
j++) {
348 deltaRMatrix[
i][
j] =
deltaR(collection1[
i], collection2[
j]);
352 for (
size_t k = 0;
k < n1;
k++) {
357 for (
size_t i = 0;
i < n1;
i++)
358 for (
size_t j = 0;
j < n2;
j++)
367 deltaRMatrix[i_min] = vector<double>(n2,
NOMATCH);
368 for (
size_t i = 0;
i < n1;
i++)
389 if (
mu.isTrackerMuon())
391 else if (
mu.isStandAloneMuon())
395 reducedMuons.push_back(
mu);
416 for (
unsigned short key :
keys) {
418 if (triggerSelector(foundObject))
419 selectedObjects.push_back(foundObject);
423 return selectedObjects;
434 float*
edges =
nullptr;
447 const string& binningTypeX,
448 const string& binningTypeY,
449 const string&
title) {
457 float* edgesX =
nullptr;
461 float* edgesY =
nullptr;
constexpr int32_t ceil(float num)
reco::MuonCollection selectedMuons(const reco::MuonCollection &, const reco::BeamSpot &, bool, const StringCutObjectSelector< reco::Muon > &, double, double)
T getParameter(std::string const &) const
StringCutObjectSelector< reco::Muon > probeMuonSelector_
The single EDProduct to be saved for each event (AOD case)
const std::string EFFICIENCY_SUFFIXES[2]
virtual void setCurrentFolder(std::string const &fullpath)
std::map< std::string, std::vector< double > > binParams_
std::string triggerLevel_
std::map< std::string, MonitorElement * > hists_
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
const std::string names[nVars_]
std::vector< Muon > MuonCollection
collection of Muon objects
HLTMuonMatchAndPlot(const edm::ParameterSet &, std::string, std::string, bool)
Constructor.
std::vector< std::string > requiredTriggers_
T getUntrackedParameter(std::string const &, T const &) const
void book2D(DQMStore::IBooker &, const std::string &, const std::string &, const std::string &, const std::string &)
std::string hltProcessName_
std::vector< size_t > matchByDeltaR(const std::vector< T1 > &, const std::vector< T2 > &, const double maxDeltaR=NOMATCH)
void fillMapFromPSet(std::map< std::string, T > &, const edm::ParameterSet &, const std::string &)
trigger::TriggerObjectCollection selectedTriggerObjects(const trigger::TriggerObjectCollection &, const trigger::TriggerEvent &, bool hasTriggerCuts, const StringCutObjectSelector< trigger::TriggerObject > &triggerSelector)
static std::string const triggerResults
void book1D(DQMStore::IBooker &, std::string, const std::string &, std::string)
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
static const char *const trigNames[]
void analyze(edm::Handle< reco::MuonCollection > &, edm::Handle< reco::BeamSpot > &, edm::Handle< reco::VertexCollection > &, edm::Handle< trigger::TriggerEvent > &, edm::Handle< edm::TriggerResults > &, const edm::TriggerNames &)
StringCutObjectSelector< reco::Muon > targetMuonSelector_
std::vector< size_type > Keys
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
ParameterSet const & getParameterSet(ParameterSetID const &id)
StringCutObjectSelector< trigger::TriggerObject > triggerSelector_
void endRun(const edm::Run &, const edm::EventSetup &)
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
std::vector< std::string > getParameterNames() const
std::map< std::string, double > plotCuts_
void fillEdges(size_t &nBins, float *&edges, const std::vector< double > &binning)
void beginRun(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &)