15 #include <boost/algorithm/string/replace.hpp>
28 using namespace trigger;
29 using namespace l1extra;
38 : hltProcessName_(pset.getParameter<
string>(
"hltProcessName")),
39 destination_(pset.getUntrackedParameter<
string>(
"destination")),
40 requiredTriggers_(pset.getUntrackedParameter<
vstring>(
"requiredTriggers")),
43 hltPath_(std::
move(hltPath)),
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]+$");
89 if (baseDir[baseDir.size() - 1] !=
'/')
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++) {
192 if (
suffix ==
"numer" && matches[
i] >= targetMuons.size())
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 &&
240 triggerResults->wasrun(hltIndex) && triggerResults->accept(hltIndex));
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 &&
264 triggerResults->wasrun(hltIndex) && triggerResults->accept(hltIndex));
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 &&
279 triggerResults->wasrun(hltIndex) && triggerResults->accept(hltIndex));
287 if (binning.size() < 3) {
288 LogWarning(
"HLTMuonVal") <<
"Invalid binning parameters!";
293 if (binning.size() == 3) {
295 edges =
new float[nBins + 1];
296 const double min = binning[1];
297 const double binwidth = (binning[2] - binning[1]) / nBins;
298 for (
size_t i = 0;
i <= nBins;
i++)
299 edges[
i] = min + (binwidth *
i);
304 nBins = binning.size() - 1;
305 edges =
new float[nBins + 1];
306 for (
size_t i = 0;
i <= nBins;
i++)
307 edges[
i] = binning[
i];
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++)
359 if (deltaRMatrix[
i][
j] < minDeltaR) {
362 minDeltaR = deltaRMatrix[
i][
j];
365 if (minDeltaR < maxDeltaR) {
366 result[i_min] = j_min;
367 deltaRMatrix[i_min] = vector<double>(n2,
NOMATCH);
368 for (
size_t i = 0;
i < n1;
i++)
387 for (
auto const&
mu : allMuons) {
389 if (
mu.isTrackerMuon())
390 track = &*
mu.innerTrack();
391 else if (
mu.isStandAloneMuon())
392 track = &*
mu.outerTrack();
393 if (track && selector(
mu) && fabs(track->
dxy(beamSpot.
position())) < d0Cut &&
395 reducedMuons.push_back(
mu);
410 size_t filterIndex = triggerSummary.
filterIndex(filterTag);
416 for (
unsigned short key : keys) {
418 if (triggerSelector(foundObject))
419 selectedObjects.push_back(foundObject);
423 return selectedObjects;
434 float* edges =
nullptr;
438 if (
hists_[name]->getTH1F()->GetSumw2N())
447 const string& binningTypeX,
448 const string& binningTypeY,
449 const string&
title) {
457 float* edgesX =
nullptr;
461 float* edgesY =
nullptr;
464 hists_[
name] = iBooker.
book2D(name.c_str(), title.c_str(), nBinsX, edgesX, nBinsY, edgesY);
466 if (
hists_[name]->getTH2F()->GetSumw2N())
467 hists_[name]->enableSumw2();
constexpr int32_t ceil(float num)
T getUntrackedParameter(std::string const &, T const &) const
reco::MuonCollection selectedMuons(const reco::MuonCollection &, const reco::BeamSpot &, bool, const StringCutObjectSelector< reco::Muon > &, double, double)
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
StringCutObjectSelector< reco::Muon > probeMuonSelector_
double pt() const final
transverse momentum
The single EDProduct to be saved for each event (AOD case)
trigger::size_type sizeFilters() const
const std::string EFFICIENCY_SUFFIXES[2]
virtual void setCurrentFolder(std::string const &fullpath)
virtual TrackRef innerTrack() const
ParameterSet const & getParameterSet(ParameterSetID const &id)
const Keys & filterKeys(trigger::size_type index) const
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
std::map< std::string, std::vector< double > > binParams_
std::string triggerLevel_
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
std::map< std::string, MonitorElement * > hists_
const std::string names[nVars_]
bool isTrackerMuon() const override
std::vector< Muon > MuonCollection
collection of Muon objects
HLTMuonMatchAndPlot(const edm::ParameterSet &, std::string, std::string, bool)
Constructor.
std::vector< std::string > requiredTriggers_
Single trigger physics object (e.g., an isolated muon)
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)
tuple key
prepare the HTCondor submission files and eventually submit them
static std::string const triggerResults
std::vector< std::string > getParameterNames() const
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
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...
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_
ParameterSet const & getParameterSet(std::string const &) const
std::string const & triggerName(unsigned int index) const
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())
T getParameter(std::string const &) const
StringCutObjectSelector< trigger::TriggerObject > triggerSelector_
void endRun(const edm::Run &, const edm::EventSetup &)
const Point & position() const
position
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())
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
double phi() const final
momentum azimuthal angle
std::map< std::string, double > plotCuts_
void fillEdges(size_t &nBins, float *&edges, const std::vector< double > &binning)
int charge() const final
electric charge
void beginRun(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &)
bool isStandAloneMuon() const override
double eta() const final
momentum pseudorapidity