37 string moduleLabel,
bool islastfilter) :
38 hltProcessName_(pset.getParameter<
string>(
"hltProcessName")),
39 destination_(pset.getUntrackedParameter<
string>(
"destination")),
40 requiredTriggers_(pset.getUntrackedParameter<
vstring>(
"requiredTriggers")),
44 moduleLabel_(moduleLabel),
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"))
65 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 TObjString * ptCutString = (TObjString *)objArray->At(1);
79 cutMinPt_ = atoi(ptCutString->GetString());
91 TPRegexp suffixPtCut(
"Mu[0-9]+$");
94 if (baseDir[baseDir.size() - 1] !=
'/') baseDir +=
'/';
107 book1D(iBooker,
"hltPt",
"pt",
";p_{T} of HLT object");
108 book1D(iBooker,
"hltEta",
"eta",
";#eta of HLT object");
109 book1D(iBooker,
"hltPhi",
"phi",
";#phi of HLT object");
110 book1D(iBooker,
"resolutionEta",
"resolutionEta",
";#eta^{reco}-#eta^{HLT};");
111 book1D(iBooker,
"resolutionPhi",
"resolutionPhi",
";#phi^{reco}-#phi^{HLT};");
113 book1D(iBooker,
"deltaR",
"deltaR",
";#Deltar(reco, HLT);");
115 book1D(iBooker,
"resolutionPt",
"resolutionRel",
116 ";(p_{T}^{reco}-p_{T}^{HLT})/|p_{T}^{reco}|;");
118 for (
size_t i = 0;
i < 2;
i++) {
122 book1D(iBooker,
"efficiencyEta_" + suffix,
"eta",
";#eta;");
123 book1D(iBooker,
"efficiencyPhi_" + suffix,
"phi",
";#phi;");
124 book1D(iBooker,
"efficiencyTurnOn_" + suffix,
"pt",
";p_{T};");
125 book1D(iBooker,
"efficiencyVertex_" + suffix,
"NVertex",
";NVertex;");
128 book2D(iBooker,
"efficiencyPhiVsEta_" + suffix,
"etaCoarse",
129 "phiCoarse",
";#eta;#phi");
133 book1D(iBooker,
"efficiencyD0_" + suffix,
"d0",
";d0;");
134 book1D(iBooker,
"efficiencyZ0_" + suffix,
"z0",
";z0;");
135 book1D(iBooker,
"efficiencyCharge_" + suffix,
"charge",
";charge;");
137 book1D(iBooker,
"fakerateEta_" + suffix,
"eta",
";#eta;");
138 book1D(iBooker,
"fakerateVertex_" + suffix,
"NVertex",
";NVertex;");
139 book1D(iBooker,
"fakeratePhi_" + suffix,
"phi",
";#phi;");
140 book1D(iBooker,
"fakerateTurnOn_" + suffix,
"pt",
";p_{T};");
142 book1D(iBooker,
"massVsEtaZ_" + suffix,
"etaCoarse",
";#eta");
143 book1D(iBooker,
"massVsEtaJpsi_" + suffix,
"etaCoarse",
";#eta");
144 book1D(iBooker,
"massVsPtZ_" + suffix,
"ptCoarse",
";p_{T}");
145 book1D(iBooker,
"massVsPtJpsi_" + suffix,
"ptCoarse",
";p_{T}");
146 book1D(iBooker,
"massVsVertexZ_" + suffix,
"NVertex",
";NVertex");
147 book1D(iBooker,
"massVsVertexJpsi_" + suffix,
"NVertex",
";NVertex");
233 for (
size_t i = 0;
i < hltMuons.size();
i++) {
245 bool pairalreadyconsidered =
false;
246 for (
size_t i = 0;
i < targetMuons.size();
i++) {
251 if (matches[
i] < targetMuons.size()) {
253 double ptRes = (muon.
pt() - hltMuon.
pt()) / muon.
pt();
254 hists_[
"resolutionPt"]->Fill(ptRes);
258 double etaRes = muon.
eta() - hltMuon.
eta();
259 double phiRes = muon.
phi() - hltMuon.
phi();
260 hists_[
"resolutionEta"]->Fill(etaRes);
261 hists_[
"resolutionPhi"]->Fill(phiRes);
266 for (
size_t j = 0; j < 2; j++) {
271 if (suffix ==
"numer" && matches[
i] >= targetMuons.size())
continue;
288 hists_[
"efficiencyVertex_" +
suffix]->Fill(vertices->size());
305 if(matches[
i] >= targetMuons.size())
continue;
306 for (
size_t k = 0;
k < targetMuons.size();
k++) {
308 Muon & theProbe = targetMuons[
k];
309 if (muon.
charge() != theProbe.
charge() && !pairalreadyconsidered) {
310 double mass = (muon.
p4() + theProbe.
p4()).M();
311 if(mass > 60 && mass < 120) {
313 hists_[
"massVsEtaZ_denom"]->Fill(theProbe.
eta());
314 hists_[
"massVsPtZ_denom"]->Fill(theProbe.
pt());
315 hists_[
"massVsVertexZ_denom"]->Fill(vertices->size());
316 if(matches[
k] < targetMuons.size()) {
317 hists_[
"massVsEtaZ_numer"]->Fill(theProbe.
eta());
318 hists_[
"massVsPtZ_numer"]->Fill(theProbe.
pt());
319 hists_[
"massVsVertexZ_numer"]->Fill(vertices->size());
321 pairalreadyconsidered =
true;
323 if(mass > 1 && mass < 4) {
325 hists_[
"massVsEtaJpsi_denom"]->Fill(theProbe.
eta());
326 hists_[
"massVsPtJpsi_denom"]->Fill(theProbe.
pt());
327 hists_[
"massVsVertexJpsi_denom"]->Fill(vertices->size());
328 if(matches[
k] < targetMuons.size()) {
329 hists_[
"massVsEtaJpsi_numer"]->Fill(theProbe.
eta());
330 hists_[
"massVsPtJpsi_numer"]->Fill(theProbe.
pt());
331 hists_[
"massVsVertexJpsi_numer"]->Fill(vertices->size());
333 pairalreadyconsidered =
true;
341 vector<size_t> hltMatches =
matchByDeltaR(hltMuons, targetMuons,
343 for (
size_t i = 0;
i < hltMuons.size();
i++) {
345 bool isFake = hltMatches[
i] > hltMuons.size();
346 for (
size_t j = 0; j < 2; j++) {
349 if (suffix ==
"numer" && ! isFake)
continue;
350 hists_[
"fakerateVertex_" +
suffix]->Fill(vertices->size());
368 if (binning.size() < 3) {
369 LogWarning(
"HLTMuonVal") <<
"Invalid binning parameters!";
374 if (binning.size() == 3) {
376 edges =
new float[nBins + 1];
377 const double min = binning[1];
378 const double binwidth = (binning[2] - binning[1]) / nBins;
379 for (
size_t i = 0;
i <= nBins;
i++) edges[
i] = min + (binwidth *
i);
384 nBins = binning.size() - 1;
385 edges =
new float[nBins + 1];
386 for (
size_t i = 0;
i <= nBins;
i++) edges[
i] = binning[
i];
411 vector<string>::const_iterator iter;
413 for (iter = names.begin(); iter != names.end(); ++iter) {
414 if (targetPset.
existsAs<
T>(* iter,
true))
416 else if (targetPset.
existsAs<
T>(* iter,
false))
425 template <
class T1,
class T2>
428 const vector<T2> & collection2,
432 const size_t n1 = collection1.size();
433 const size_t n2 = collection2.size();
435 vector<size_t>
result(n1, -1);
436 vector<vector<double> > deltaRMatrix(n1, vector<double>(n2,
NOMATCH));
438 for (
size_t i = 0;
i < n1;
i++)
439 for (
size_t j = 0; j < n2; j++) {
440 deltaRMatrix[
i][j] =
deltaR(collection1[
i], collection2[j]);
444 for (
size_t k = 0;
k < n1;
k++) {
449 for (
size_t i = 0;
i < n1;
i++)
450 for (
size_t j = 0; j < n2; j++)
451 if (deltaRMatrix[
i][j] < minDeltaR) {
454 minDeltaR = deltaRMatrix[
i][j];
457 if (minDeltaR < maxDeltaR) {
458 result[i_min] = j_min;
459 deltaRMatrix[i_min] = vector<double>(n2,
NOMATCH);
460 for (
size_t i = 0;
i < n1;
i++)
476 double d0Cut,
double z0Cut)
484 for (
auto const&
mu : allMuons){
486 if (
mu.isTrackerMuon()) track = & *
mu.innerTrack();
487 else if (
mu.isStandAloneMuon()) track = & *
mu.outerTrack();
488 if (track && selector(
mu) &&
491 reducedMuons.push_back(
mu);
510 size_t filterIndex = triggerSummary.
filterIndex(filterTag);
516 for (
size_t j = 0; j < keys.size(); j++ ){
518 if (triggerSelector(foundObject))
519 selectedObjects.push_back(foundObject);
523 return selectedObjects;
530 string binningType,
string title)
545 if (
hists_[name]->getTH1F()->GetSumw2N())
557 string binningTypeX,
string binningTypeY,
576 nBinsX, edgesX, nBinsY, edgesY);
578 if (
hists_[name]->getTH2F()->GetSumw2N())
579 hists_[name]->getTH2F()->Sumw2();
T getParameter(std::string const &) const
virtual double pt() const final
transverse momentum
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_
The single EDProduct to be saved for each event (AOD case)
trigger::size_type sizeFilters() const
static const HistoName names[]
const std::string EFFICIENCY_SUFFIXES[2]
virtual double eta() const final
momentum pseudorapidity
virtual TrackRef innerTrack() const
void analyze(edm::Handle< reco::MuonCollection > &, edm::Handle< reco::BeamSpot > &, edm::Handle< reco::VertexCollection > &, edm::Handle< trigger::TriggerEvent > &, edm::Handle< edm::TriggerResults > &)
bool isTrackerMuon() 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_
bool isStandAloneMuon() const
std::vector< Muon > MuonCollection
collection of Muon objects
HLTMuonMatchAndPlot(const edm::ParameterSet &, std::string, std::string, bool)
Constructor.
virtual double phi() const final
momentum azimuthal angle
virtual int charge() const final
electric charge
trigger::TriggerObjectCollection selectedTriggerObjects(const trigger::TriggerObjectCollection &, const trigger::TriggerEvent &, bool hasTriggerCuts, const StringCutObjectSelector< trigger::TriggerObject > triggerSelector)
void fillMapFromPSet(std::map< std::string, T > &, const edm::ParameterSet &, std::string)
std::string hltProcessName_
std::vector< size_t > matchByDeltaR(const std::vector< T1 > &, const std::vector< T2 > &, const double maxDeltaR=NOMATCH)
const TriggerObjectCollection & getObjects() const
MonitorElement * book1D(Args &&...args)
static std::string const triggerResults
std::vector< std::string > getParameterNames() const
void book2D(DQMStore::IBooker &, std::string, std::string, std::string, std::string)
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...
double deltaR(double eta1, double eta2, double phi1, double phi2)
std::vector< std::string > vstring
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
void setCurrentFolder(const std::string &fullpath)
StringCutObjectSelector< reco::Muon > targetMuonSelector_
MonitorElement * book2D(Args &&...args)
ParameterSet const & getParameterSet(std::string const &) const
std::vector< size_type > Keys
StringCutObjectSelector< trigger::TriggerObject > triggerSelector_
void endRun(const edm::Run &, const edm::EventSetup &)
void book1D(DQMStore::IBooker &, std::string, std::string, std::string)
const Point & position() const
position
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
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 &)