24 using namespace trigger;
25 using namespace l1extra;
36 string moduleLabel,
bool islastfilter) :
37 hltProcessName_(pset.getParameter<
string>(
"hltProcessName")),
38 destination_(pset.getUntrackedParameter<
string>(
"destination")),
39 requiredTriggers_(pset.getUntrackedParameter<
vstring>(
"requiredTriggers")),
44 isLastFilter_(islastfilter),
45 hasTargetRecoCuts(targetParams_.exists(
"recoCuts")),
46 hasProbeRecoCuts(probeParams_.exists(
"recoCuts")),
47 targetMuonSelector_(targetParams_.getUntrackedParameter<
string>(
"recoCuts",
"")),
48 targetZ0Cut_(targetParams_.getUntrackedParameter<double>(
"z0Cut",0.)),
49 targetD0Cut_(targetParams_.getUntrackedParameter<double>(
"d0Cut",0.)),
50 targetptCutZ_(targetParams_.getUntrackedParameter<double>(
"ptCut_Z",20.)),
51 targetptCutJpsi_(targetParams_.getUntrackedParameter<double>(
"ptCut_Jpsi",20.)),
52 probeMuonSelector_(probeParams_.getUntrackedParameter<
string>(
"recoCuts",
"")),
53 probeZ0Cut_(probeParams_.getUntrackedParameter<double>(
"z0Cut",0.)),
54 probeD0Cut_(probeParams_.getUntrackedParameter<double>(
"d0Cut",0.)),
55 triggerSelector_(targetParams_.getUntrackedParameter<
string>(
"hltCuts",
"")),
56 hasTriggerCuts_(targetParams_.exists(
"hltCuts"))
64 TPRegexp levelRegexp(
"L[1-3]");
66 TObjArray * levelArray = levelRegexp.MatchS(
moduleLabel_);
67 if (levelArray->GetEntriesFast() > 0) {
68 triggerLevel_ = ((TObjString *)levelArray->At(0))->GetString();
74 TPRegexp ptRegexp(
"Mu([0-9]*)");
75 TObjArray * objArray = ptRegexp.MatchS(
hltPath_);
76 if (objArray->GetEntriesFast() >= 2) {
77 TObjString * ptCutString = (TObjString *)objArray->At(1);
78 cutMinPt_ = atoi(ptCutString->GetString());
90 TPRegexp suffixPtCut(
"Mu[0-9]+$");
93 if (baseDir[baseDir.size() - 1] !=
'/') baseDir +=
'/';
106 book1D(iBooker,
"hltPt",
"pt",
";p_{T} of HLT object");
107 book1D(iBooker,
"hltEta",
"eta",
";#eta of HLT object");
108 book1D(iBooker,
"hltPhi",
"phi",
";#phi of HLT object");
109 book1D(iBooker,
"resolutionEta",
"resolutionEta",
";#eta^{reco}-#eta^{HLT};");
110 book1D(iBooker,
"resolutionPhi",
"resolutionPhi",
";#phi^{reco}-#phi^{HLT};");
112 book1D(iBooker,
"deltaR",
"deltaR",
";#Deltar(reco, HLT);");
114 book1D(iBooker,
"resolutionPt",
"resolutionRel",
115 ";(p_{T}^{reco}-p_{T}^{HLT})/|p_{T}^{reco}|;");
117 for (
size_t i = 0;
i < 2;
i++) {
121 book1D(iBooker,
"efficiencyEta_" + suffix,
"eta",
";#eta;");
122 book1D(iBooker,
"efficiencyPhi_" + suffix,
"phi",
";#phi;");
123 book1D(iBooker,
"efficiencyTurnOn_" + suffix,
"pt",
";p_{T};");
124 book1D(iBooker,
"efficiencyVertex_" + suffix,
"NVertex",
";NVertex;");
127 book2D(iBooker,
"efficiencyPhiVsEta_" + suffix,
"etaCoarse",
128 "phiCoarse",
";#eta;#phi");
132 book1D(iBooker,
"efficiencyD0_" + suffix,
"d0",
";d0;");
133 book1D(iBooker,
"efficiencyZ0_" + suffix,
"z0",
";z0;");
134 book1D(iBooker,
"efficiencyCharge_" + suffix,
"charge",
";charge;");
136 book1D(iBooker,
"fakerateEta_" + suffix,
"eta",
";#eta;");
137 book1D(iBooker,
"fakerateVertex_" + suffix,
"NVertex",
";NVertex;");
138 book1D(iBooker,
"fakeratePhi_" + suffix,
"phi",
";#phi;");
139 book1D(iBooker,
"fakerateTurnOn_" + suffix,
"pt",
";p_{T};");
141 book1D(iBooker,
"massVsEtaZ_" + suffix,
"etaCoarse",
";#eta");
142 book1D(iBooker,
"massVsEtaJpsi_" + suffix,
"etaCoarse",
";#eta");
143 book1D(iBooker,
"massVsPtZ_" + suffix,
"ptCoarse",
";p_{T}");
144 book1D(iBooker,
"massVsPtJpsi_" + suffix,
"ptCoarse",
";p_{T}");
145 book1D(iBooker,
"massVsVertexZ_" + suffix,
"NVertex",
";NVertex");
146 book1D(iBooker,
"massVsVertexJpsi_" + suffix,
"NVertex",
";NVertex");
232 for (
size_t i = 0;
i < hltMuons.size();
i++) {
244 bool pairalreadyconsidered =
false;
245 for (
size_t i = 0;
i < targetMuons.size();
i++) {
250 if (matches[
i] < targetMuons.size()) {
252 double ptRes = (muon.
pt() - hltMuon.
pt()) / muon.
pt();
253 hists_[
"resolutionPt"]->Fill(ptRes);
257 double etaRes = muon.
eta() - hltMuon.
eta();
258 double phiRes = muon.
phi() - hltMuon.
phi();
259 hists_[
"resolutionEta"]->Fill(etaRes);
260 hists_[
"resolutionPhi"]->Fill(phiRes);
265 for (
size_t j = 0;
j < 2;
j++) {
270 if (suffix ==
"numer" && matches[
i] >= targetMuons.size())
continue;
283 const Track * track = 0;
287 hists_[
"efficiencyVertex_" +
suffix]->Fill(vertices->size());
291 double d0 = track->
dxy(beamSpot->position());
292 double z0 = track->
dz(beamSpot->position());
304 if(matches[
i] >= targetMuons.size())
continue;
305 for (
size_t k = 0;
k < targetMuons.size();
k++) {
307 Muon & theProbe = targetMuons[
k];
308 if (muon.
charge() != theProbe.
charge() && !pairalreadyconsidered) {
309 double mass = (muon.
p4() + theProbe.
p4()).M();
310 if(mass > 60 && mass < 120) {
312 hists_[
"massVsEtaZ_denom"]->Fill(theProbe.
eta());
313 hists_[
"massVsPtZ_denom"]->Fill(theProbe.
pt());
314 hists_[
"massVsVertexZ_denom"]->Fill(vertices->size());
315 if(matches[
k] < targetMuons.size()) {
316 hists_[
"massVsEtaZ_numer"]->Fill(theProbe.
eta());
317 hists_[
"massVsPtZ_numer"]->Fill(theProbe.
pt());
318 hists_[
"massVsVertexZ_numer"]->Fill(vertices->size());
320 pairalreadyconsidered =
true;
322 if(mass > 1 && mass < 4) {
324 hists_[
"massVsEtaJpsi_denom"]->Fill(theProbe.
eta());
325 hists_[
"massVsPtJpsi_denom"]->Fill(theProbe.
pt());
326 hists_[
"massVsVertexJpsi_denom"]->Fill(vertices->size());
327 if(matches[
k] < targetMuons.size()) {
328 hists_[
"massVsEtaJpsi_numer"]->Fill(theProbe.
eta());
329 hists_[
"massVsPtJpsi_numer"]->Fill(theProbe.
pt());
330 hists_[
"massVsVertexJpsi_numer"]->Fill(vertices->size());
332 pairalreadyconsidered =
true;
340 vector<size_t> hltMatches =
matchByDeltaR(hltMuons, targetMuons,
342 for (
size_t i = 0;
i < hltMuons.size();
i++) {
344 bool isFake = hltMatches[
i] > hltMuons.size();
345 for (
size_t j = 0;
j < 2;
j++) {
348 if (suffix ==
"numer" && ! isFake)
continue;
349 hists_[
"fakerateVertex_" +
suffix]->Fill(vertices->size());
367 if (binning.size() < 3) {
368 LogWarning(
"HLTMuonVal") <<
"Invalid binning parameters!";
373 if (binning.size() == 3) {
375 edges =
new float[nBins + 1];
376 const double min = binning[1];
377 const double binwidth = (binning[2] - binning[1]) / nBins;
378 for (
size_t i = 0;
i <= nBins;
i++) edges[
i] = min + (binwidth *
i);
383 nBins = binning.size() - 1;
384 edges =
new float[nBins + 1];
385 for (
size_t i = 0;
i <= nBins;
i++) edges[
i] = binning[
i];
410 vector<string>::const_iterator iter;
412 for (iter = names.begin(); iter != names.end(); ++iter) {
413 if (targetPset.
existsAs<
T>(* iter,
true))
415 else if (targetPset.
existsAs<
T>(* iter,
false))
424 template <
class T1,
class T2>
427 const vector<T2> & collection2,
428 const double maxDeltaR)
431 const size_t n1 = collection1.size();
432 const size_t n2 = collection2.size();
434 vector<size_t>
result(n1, -1);
435 vector<vector<double> > deltaRMatrix(n1, vector<double>(n2,
NOMATCH));
437 for (
size_t i = 0;
i < n1;
i++)
438 for (
size_t j = 0;
j < n2;
j++) {
439 deltaRMatrix[
i][
j] =
deltaR(collection1[
i], collection2[
j]);
443 for (
size_t k = 0;
k < n1;
k++) {
448 for (
size_t i = 0;
i < n1;
i++)
449 for (
size_t j = 0;
j < n2;
j++)
450 if (deltaRMatrix[
i][
j] < minDeltaR) {
453 minDeltaR = deltaRMatrix[
i][
j];
456 if (minDeltaR < maxDeltaR) {
457 result[i_min] = j_min;
458 deltaRMatrix[i_min] = vector<double>(n2,
NOMATCH);
459 for (
size_t i = 0;
i < n1;
i++)
475 double d0Cut,
double z0Cut)
483 for (
auto const&
mu : allMuons){
484 const Track * track = 0;
485 if (
mu.isTrackerMuon()) track = & *
mu.innerTrack();
486 else if (
mu.isStandAloneMuon()) track = & *
mu.outerTrack();
487 if (track && selector(
mu) &&
490 reducedMuons.push_back(
mu);
509 size_t filterIndex = triggerSummary.
filterIndex(filterTag);
515 for (
size_t j = 0;
j < keys.size();
j++ ){
517 if (triggerSelector(foundObject))
518 selectedObjects.push_back(foundObject);
522 return selectedObjects;
529 string binningType,
string title)
544 if (
hists_[name]->getTH1F()->GetSumw2N())
556 string binningTypeX,
string binningTypeY,
575 nBinsX, edgesX, nBinsY, edgesY);
577 if (
hists_[name]->getTH2F()->GetSumw2N())
578 hists_[name]->getTH2F()->Sumw2();
T getParameter(std::string const &) const
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 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
virtual double phi() const final
momentum azimuthal angle
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.
Single trigger physics object (e.g., an isolated muon)
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)
virtual int charge() const final
electric charge
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< 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 double eta() const final
momentum pseudorapidity
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)
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
void beginRun(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &)
virtual double pt() const final
transverse momentum