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 targetMuonEtaMax_(targetParams_.getUntrackedParameter<double>(
"recoMaxEtaCut", 0.)),
47 targetMuonEtaMin_(targetParams_.getUntrackedParameter<double>(
"recoMinEtaCut", 0.)),
48 targetIsMuonGlb_(targetParams_.getUntrackedParameter<
bool>(
"recoGlbMuCut",
false)),
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 probeMuonEtaMax_(probeParams_.getUntrackedParameter<double>(
"recoMaxEtaCut", 0.)),
54 probeMuonEtaMin_(probeParams_.getUntrackedParameter<double>(
"recoMinEtaCut", 0.)),
55 probeIsMuonGlb_(probeParams_.getUntrackedParameter<
bool>(
"recoGlbMuCut",
false)),
56 probeZ0Cut_(probeParams_.getUntrackedParameter<double>(
"z0Cut", 0.)),
57 probeD0Cut_(probeParams_.getUntrackedParameter<double>(
"d0Cut", 0.)),
58 triggerEtaMaxCut_(targetParams_.getUntrackedParameter<double>(
"hltMaxEtaCut", 0.)),
59 triggerEtaMinCut_(targetParams_.getUntrackedParameter<double>(
"hltMinEtaCut", 0.)) {
66 TPRegexp levelRegexp(
"L[1-3]");
69 TObjArray* levelArray = levelRegexp.MatchS(
moduleLabel_);
70 if (levelArray->GetEntriesFast() > 0) {
71 triggerLevel_ =
static_cast<const char*
>(((TObjString*)levelArray->At(0))->GetString());
77 TPRegexp ptRegexp(
"Mu([0-9]*)");
78 TObjArray* objArray = ptRegexp.MatchS(
hltPath_);
79 if (objArray->GetEntriesFast() >= 2) {
80 auto* ptCutString = (TObjString*)objArray->At(1);
81 cutMinPt_ = atoi(ptCutString->GetString());
88 TPRegexp suffixPtCut(
"Mu[0-9]+$");
111 book1D(iBooker,
"efficiencyEta_" +
suffix,
"eta",
";#eta;");
112 book1D(iBooker,
"efficiencyPhi_" +
suffix,
"phi",
";#phi;");
113 book1D(iBooker,
"efficiencyTurnOn_" +
suffix,
"pt",
";p_{T};");
114 book1D(iBooker,
"efficiencyNVertex_" +
suffix,
"NVertex",
";NVertex;");
124 book1D(iBooker,
"efficiencyCharge_" +
suffix,
"charge",
";charge;");
125 book1D(iBooker,
"efficiencyZ0_" +
suffix,
"z0",
";z0;");
126 book1D(iBooker,
"efficiency_DZ_Mu_" +
suffix,
"z0",
";z0;");
188 for (
size_t i = 0;
i < targetMuons.size();
i++) {
207 if (
muon.isTrackerMuon())
209 else if (
muon.isStandAloneMuon())
227 if (
matches[
i] >= targetMuons.size())
237 unsigned int numTriggers =
trigNames.size();
240 for (
unsigned long matche :
matches) {
241 if (matche < targetMuons.size())
247 if (nonDZPath.rfind(
"_DZ") < nonDZPath.length()) {
249 nonDZPath = boost::replace_all_copy<string>(nonDZPath,
"_DZ",
"");
250 nonDZPath = nonDZPath.substr(0, nonDZPath.rfind(
"_v") + 2);
252 bool passTriggerDZ =
false;
255 for (
unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
256 passTriggerDZ = passTriggerDZ || (
trigNames.triggerName(hltIndex).find(nonDZPath) != std::string::npos &&
260 if (dzPath && targetMuons.size() > 1 && passTriggerDZ) {
261 const Track* track0 =
nullptr;
262 const Track* track1 =
nullptr;
263 if (targetMuons.at(0).isTrackerMuon())
264 track0 = &*targetMuons.at(0).innerTrack();
265 else if (targetMuons.at(0).isStandAloneMuon())
266 track0 = &*targetMuons.at(0).outerTrack();
267 if (targetMuons.at(1).isTrackerMuon())
268 track1 = &*targetMuons.at(1).innerTrack();
269 else if (targetMuons.at(1).isStandAloneMuon())
270 track1 = &*targetMuons.at(1).outerTrack();
272 if (track0 && track1) {
285 LogWarning(
"HLTMuonVal") <<
"Invalid binning parameters!";
319 targetPset =
pset.getUntrackedParameterSet(
target);
323 vector<string>::const_iterator iter;
325 for (iter =
names.begin(); iter !=
names.end(); ++iter) {
328 else if (targetPset.
existsAs<
T>(*iter,
false))
334 template <
class T1,
class T2>
336 const vector<T2>& collection2,
338 const size_t n1 = collection1.size();
339 const size_t n2 = collection2.size();
341 vector<size_t>
result(n1, -1);
342 vector<vector<double> > deltaRMatrix(n1, vector<double>(n2,
NOMATCH));
344 for (
size_t i = 0;
i < n1;
i++)
345 for (
size_t j = 0;
j < n2;
j++) {
346 deltaRMatrix[
i][
j] =
deltaR(collection1[
i], collection2[
j]);
350 for (
size_t k = 0;
k < n1;
k++) {
355 for (
size_t i = 0;
i < n1;
i++)
356 for (
size_t j = 0;
j < n2;
j++)
365 deltaRMatrix[i_min] = vector<double>(n2,
NOMATCH);
366 for (
size_t i = 0;
i < n1;
i++)
376 bool isTargetMuons) {
386 if (
mu.isTrackerMuon())
388 else if (
mu.isStandAloneMuon())
391 bool muID = IsMuonGlb ?
mu.isGlobalMuon() :
mu.isStandAloneMuon();
392 if (
track && muID &&
abs(
mu.eta()) < RecoMuonEtaMax &&
abs(
mu.eta()) >= RecoMuonEtaMin &&
394 reducedMuons.push_back(
mu);
408 for (
unsigned short key :
keys) {
411 selectedObjects.push_back(foundObject);
415 return selectedObjects;
426 float*
edges =
nullptr;
439 const string& binningTypeX,
440 const string& binningTypeY,
441 const string&
title) {
449 float* edgesX =
nullptr;
453 float* edgesY =
nullptr;
constexpr int32_t ceil(float num)
T getParameter(std::string const &) const
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.
T getUntrackedParameter(std::string const &, T const &) const
void book2D(DQMStore::IBooker &, const std::string &, const std::string &, const std::string &, const std::string &)
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
trigger::TriggerObjectCollection selectedTriggerObjects(const trigger::TriggerObjectCollection &, const trigger::TriggerEvent &)
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 &)
reco::MuonCollection selectedMuons(const reco::MuonCollection &, const reco::BeamSpot &, bool)
Abs< T >::type abs(const T &t)
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 &)
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)
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_
bool fillEdges(size_t &nBins, float *&edges, const std::vector< double > &binning)
void beginRun(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &)