24 using namespace trigger;
25 using namespace l1extra;
36 const vector<string>& moduleLabels) :
37 hltProcessName_(pset.getParameter<
string>(
"hltProcessName")),
38 destination_(pset.getUntrackedParameter<
string>(
"destination")),
39 requiredTriggers_(pset.getUntrackedParameter<
vstring>(
"requiredTriggers")),
43 moduleLabels_(moduleLabels),
44 hasTargetRecoCuts(targetParams_.exists(
"recoCuts")),
45 hasProbeRecoCuts(probeParams_.exists(
"recoCuts")),
46 targetMuonSelector_(targetParams_.getUntrackedParameter<
string>(
"recoCuts",
"")),
47 targetZ0Cut_(targetParams_.getUntrackedParameter<double>(
"z0Cut",0.)),
48 targetD0Cut_(targetParams_.getUntrackedParameter<double>(
"d0Cut",0.)),
49 targetptCutZ_(targetParams_.getUntrackedParameter<double>(
"ptCut_Z",20.)),
50 targetptCutJpsi_(targetParams_.getUntrackedParameter<double>(
"ptCut_Jpsi",20.)),
51 probeMuonSelector_(probeParams_.getUntrackedParameter<
string>(
"recoCuts",
"")),
52 probeZ0Cut_(probeParams_.getUntrackedParameter<double>(
"z0Cut",0.)),
53 probeD0Cut_(probeParams_.getUntrackedParameter<double>(
"d0Cut",0.)),
54 triggerSelector_(targetParams_.getUntrackedParameter<
string>(
"hltCuts",
"")),
55 hasTriggerCuts_(targetParams_.exists(
"hltCuts"))
63 TPRegexp levelRegexp(
"L[1-3]");
65 TObjArray * levelArray = levelRegexp.MatchS(
moduleLabels_[nModules - 1]);
66 if (levelArray->GetEntriesFast() > 0) {
67 triggerLevel_ = ((TObjString *)levelArray->At(0))->GetString();
73 TPRegexp ptRegexp(
"Mu([0-9]*)");
74 TObjArray * objArray = ptRegexp.MatchS(
hltPath_);
75 if (objArray->GetEntriesFast() >= 2) {
76 TObjString * ptCutString = (TObjString *)objArray->At(1);
77 cutMinPt_ = atoi(ptCutString->GetString());
89 TPRegexp suffixPtCut(
"Mu[0-9]+$");
92 if (baseDir[baseDir.size() - 1] !=
'/') baseDir +=
'/';
100 book1D(iBooker,
"deltaR",
"deltaR",
";#Deltar(reco, HLT);");
101 book1D(iBooker,
"hltPt",
"pt",
";p_{T} of HLT object");
102 book1D(iBooker,
"hltEta",
"eta",
";#eta of HLT object");
103 book1D(iBooker,
"hltPhi",
"phi",
";#phi of HLT object");
104 book1D(iBooker,
"resolutionEta",
"resolutionEta",
";#eta^{reco}-#eta^{HLT};");
105 book1D(iBooker,
"resolutionPhi",
"resolutionPhi",
";#phi^{reco}-#phi^{HLT};");
106 book1D(iBooker,
"resolutionPt",
"resolutionRel",
107 ";(p_{T}^{reco}-p_{T}^{HLT})/|p_{T}^{reco}|;");
109 for (
size_t i = 0;
i < 2;
i++) {
113 book1D(iBooker,
"efficiencyEta_" + suffix,
"eta",
";#eta;");
114 book1D(iBooker,
"efficiencyPhi_" + suffix,
"phi",
";#phi;");
115 book1D(iBooker,
"efficiencyTurnOn_" + suffix,
"pt",
";p_{T};");
116 book1D(iBooker,
"efficiencyD0_" + suffix,
"d0",
";d0;");
117 book1D(iBooker,
"efficiencyZ0_" + suffix,
"z0",
";z0;");
118 book1D(iBooker,
"efficiencyCharge_" + suffix,
"charge",
";charge;");
119 book1D(iBooker,
"efficiencyVertex_" + suffix,
"NVertex",
";NVertex;");
121 book2D(iBooker,
"efficiencyPhiVsEta_" + suffix,
"etaCoarse",
122 "phiCoarse",
";#eta;#phi");
124 book1D(iBooker,
"fakerateEta_" + suffix,
"eta",
";#eta;");
125 book1D(iBooker,
"fakerateVertex_" + suffix,
"NVertex",
";NVertex;");
126 book1D(iBooker,
"fakeratePhi_" + suffix,
"phi",
";#phi;");
127 book1D(iBooker,
"fakerateTurnOn_" + suffix,
"pt",
";p_{T};");
129 book1D(iBooker,
"massVsEtaZ_" + suffix,
"etaCoarse",
";#eta");
130 book1D(iBooker,
"massVsEtaJpsi_" + suffix,
"etaCoarse",
";#eta");
131 book1D(iBooker,
"massVsPtZ_" + suffix,
"ptCoarse",
";p_{T}");
132 book1D(iBooker,
"massVsPtJpsi_" + suffix,
"ptCoarse",
";p_{T}");
133 book1D(iBooker,
"massVsVertexZ_" + suffix,
"NVertex",
";NVertex");
134 book1D(iBooker,
"massVsVertexJpsi_" + suffix,
"NVertex",
";NVertex");
205 if (triggerIndex < triggerResults->
size() ||
206 !triggerResults->accept(triggerIndex))
219 for (
size_t i = 0;
i < hltMuons.size();
i++) {
231 bool pairalreadyconsidered =
false;
232 for (
size_t i = 0;
i < targetMuons.size();
i++) {
237 if (matches[
i] < targetMuons.size()) {
239 double ptRes = (muon.
pt() - hltMuon.
pt()) / muon.
pt();
240 double etaRes = muon.
eta() - hltMuon.
eta();
241 double phiRes = muon.
phi() - hltMuon.
phi();
242 hists_[
"resolutionEta"]->Fill(etaRes);
243 hists_[
"resolutionPhi"]->Fill(phiRes);
244 hists_[
"resolutionPt"]->Fill(ptRes);
249 for (
size_t j = 0;
j < 2;
j++) {
254 if (suffix ==
"numer" && matches[
i] >= targetMuons.size())
continue;
266 const Track * track = 0;
270 double d0 = track->
dxy(beamSpot->position());
271 double z0 = track->
dz(beamSpot->position());
272 hists_[
"efficiencyVertex_" +
suffix]->Fill(vertices->size());
283 if(matches[
i] >= targetMuons.size())
continue;
284 for (
size_t k = 0;
k < targetMuons.size();
k++) {
286 Muon & theProbe = targetMuons[
k];
287 if (muon.
charge() != theProbe.
charge() && !pairalreadyconsidered) {
288 double mass = (muon.
p4() + theProbe.
p4()).M();
289 if(mass > 60 && mass < 120) {
291 hists_[
"massVsEtaZ_denom"]->Fill(theProbe.
eta());
292 hists_[
"massVsPtZ_denom"]->Fill(theProbe.
pt());
293 hists_[
"massVsVertexZ_denom"]->Fill(vertices->size());
294 if(matches[
k] < targetMuons.size()) {
295 hists_[
"massVsEtaZ_numer"]->Fill(theProbe.
eta());
296 hists_[
"massVsPtZ_numer"]->Fill(theProbe.
pt());
297 hists_[
"massVsVertexZ_numer"]->Fill(vertices->size());
299 pairalreadyconsidered =
true;
301 if(mass > 1 && mass < 4) {
303 hists_[
"massVsEtaJpsi_denom"]->Fill(theProbe.
eta());
304 hists_[
"massVsPtJpsi_denom"]->Fill(theProbe.
pt());
305 hists_[
"massVsVertexJpsi_denom"]->Fill(vertices->size());
306 if(matches[
k] < targetMuons.size()) {
307 hists_[
"massVsEtaJpsi_numer"]->Fill(theProbe.
eta());
308 hists_[
"massVsPtJpsi_numer"]->Fill(theProbe.
pt());
309 hists_[
"massVsVertexJpsi_numer"]->Fill(vertices->size());
311 pairalreadyconsidered =
true;
318 vector<size_t> hltMatches =
matchByDeltaR(hltMuons, targetMuons,
320 for (
size_t i = 0;
i < hltMuons.size();
i++) {
322 bool isFake = hltMatches[
i] > hltMuons.size();
323 for (
size_t j = 0;
j < 2;
j++) {
326 if (suffix ==
"numer" && ! isFake)
continue;
327 hists_[
"fakerateVertex_" +
suffix]->Fill(vertices->size());
345 if (binning.size() < 3) {
346 LogWarning(
"HLTMuonVal") <<
"Invalid binning parameters!";
351 if (binning.size() == 3) {
353 edges =
new float[nBins + 1];
354 const double min = binning[1];
355 const double binwidth = (binning[2] - binning[1]) / nBins;
356 for (
size_t i = 0;
i <= nBins;
i++) edges[
i] = min + (binwidth *
i);
361 nBins = binning.size() - 1;
362 edges =
new float[nBins + 1];
363 for (
size_t i = 0;
i <= nBins;
i++) edges[
i] = binning[
i];
388 vector<string>::const_iterator iter;
390 for (iter = names.begin(); iter != names.end(); ++iter) {
391 if (targetPset.
existsAs<
T>(* iter,
true))
393 else if (targetPset.
existsAs<
T>(* iter,
false))
402 template <
class T1,
class T2>
405 const vector<T2> & collection2,
406 const double maxDeltaR)
409 const size_t n1 = collection1.size();
410 const size_t n2 = collection2.size();
412 vector<size_t>
result(n1, -1);
413 vector<vector<double> > deltaRMatrix(n1, vector<double>(n2,
NOMATCH));
415 for (
size_t i = 0;
i < n1;
i++)
416 for (
size_t j = 0;
j < n2;
j++) {
417 deltaRMatrix[
i][
j] =
deltaR(collection1[
i], collection2[
j]);
421 for (
size_t k = 0;
k < n1;
k++) {
426 for (
size_t i = 0;
i < n1;
i++)
427 for (
size_t j = 0;
j < n2;
j++)
428 if (deltaRMatrix[
i][
j] < minDeltaR) {
431 minDeltaR = deltaRMatrix[
i][
j];
434 if (minDeltaR < maxDeltaR) {
435 result[i_min] = j_min;
436 deltaRMatrix[i_min] = vector<double>(n2,
NOMATCH);
437 for (
size_t i = 0;
i < n1;
i++)
453 double d0Cut,
double z0Cut)
461 for (
auto const&
mu : allMuons){
462 const Track * track = 0;
463 if (
mu.isTrackerMuon()) track = & *
mu.innerTrack();
464 else if (
mu.isStandAloneMuon()) track = & *
mu.outerTrack();
465 if (track && selector(
mu) &&
468 reducedMuons.push_back(
mu);
488 size_t filterIndex = triggerSummary.
filterIndex(filterTag);
494 for (
size_t j = 0;
j < keys.size();
j++ ){
496 if (triggerSelector(foundObject))
497 selectedObjects.push_back(foundObject);
501 return selectedObjects;
508 string binningType,
string title)
535 string binningTypeX,
string binningTypeY,
554 nBinsX, edgesX, nBinsY, edgesY);
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)
std::vector< std::string > moduleLabels_
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
std::vector< std::string > requiredTriggers_
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)
TH1F * getTH1F(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
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
TH2F * getTH2F(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
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
HLTMuonMatchAndPlot(const edm::ParameterSet &, std::string, const std::vector< std::string > &)
Constructor.
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)
tuple size
Write out results.
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