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};");
112 book1D(iBooker,
"efficiencyNVertex_" +
suffix,
"NVertex",
";NVertex;");
122 book1D(iBooker,
"efficiencyCharge_" +
suffix,
"charge",
";charge;");
123 book1D(iBooker,
"efficiencyZ0_" +
suffix,
"z0",
";z0;");
124 book1D(iBooker,
"efficiency_DZ_Mu_" +
suffix,
"z0",
";z0;");
189 for (
size_t i = 0;
i < targetMuons.size();
i++) {
208 if (
muon.isTrackerMuon())
210 else if (
muon.isStandAloneMuon())
228 if (
matches[
i] >= targetMuons.size())
238 unsigned int numTriggers =
trigNames.size();
241 for (
unsigned long matche :
matches) {
242 if (matche < targetMuons.size())
248 if (nonDZPath.rfind(
"_DZ") < nonDZPath.length()) {
250 nonDZPath = boost::replace_all_copy<string>(nonDZPath,
"_DZ",
"");
251 nonDZPath = nonDZPath.substr(0, nonDZPath.rfind(
"_v") + 2);
253 bool passTriggerDZ =
false;
256 for (
unsigned int hltIndex = 0; hltIndex < numTriggers; ++hltIndex) {
257 passTriggerDZ = passTriggerDZ || (
trigNames.triggerName(hltIndex).find(nonDZPath) != std::string::npos &&
261 if (dzPath && targetMuons.size() > 1 && passTriggerDZ) {
262 const Track* track0 =
nullptr;
263 const Track* track1 =
nullptr;
264 if (targetMuons.at(0).isTrackerMuon())
265 track0 = &*targetMuons.at(0).innerTrack();
266 else if (targetMuons.at(0).isStandAloneMuon())
267 track0 = &*targetMuons.at(0).outerTrack();
268 if (targetMuons.at(1).isTrackerMuon())
269 track1 = &*targetMuons.at(1).innerTrack();
270 else if (targetMuons.at(1).isStandAloneMuon())
271 track1 = &*targetMuons.at(1).outerTrack();
273 if (track0 && track1) {
286 LogWarning(
"HLTMuonVal") <<
"Invalid binning parameters!";
320 targetPset =
pset.getUntrackedParameterSet(
target);
324 vector<string>::const_iterator iter;
326 for (iter =
names.begin(); iter !=
names.end(); ++iter) {
329 else if (targetPset.
existsAs<
T>(*iter,
false))
335 template <
class T1,
class T2>
337 const vector<T2>& collection2,
339 const size_t n1 = collection1.size();
340 const size_t n2 = collection2.size();
342 vector<size_t>
result(n1, -1);
343 vector<vector<double> > deltaRMatrix(n1, vector<double>(n2,
NOMATCH));
345 for (
size_t i = 0;
i < n1;
i++)
346 for (
size_t j = 0;
j < n2;
j++) {
347 deltaRMatrix[
i][
j] =
deltaR(collection1[
i], collection2[
j]);
351 for (
size_t k = 0;
k < n1;
k++) {
356 for (
size_t i = 0;
i < n1;
i++)
357 for (
size_t j = 0;
j < n2;
j++)
366 deltaRMatrix[i_min] = vector<double>(n2,
NOMATCH);
367 for (
size_t i = 0;
i < n1;
i++)
388 if (
mu.isTrackerMuon())
390 else if (
mu.isStandAloneMuon())
394 reducedMuons.push_back(
mu);
415 for (
unsigned short key :
keys) {
417 if (triggerSelector(foundObject))
418 selectedObjects.push_back(foundObject);
422 return selectedObjects;
433 float*
edges =
nullptr;
446 const string& binningTypeX,
447 const string& binningTypeY,
448 const string&
title) {
456 float* edgesX =
nullptr;
460 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.
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...
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_
bool fillEdges(size_t &nBins, float *&edges, const std::vector< double > &binning)
void beginRun(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &)