31 using namespace trigger;
32 using namespace l1extra;
43 const vector<string>& moduleLabels) :
44 hltProcessName_(pset.getParameter<
string>(
"hltProcessName")),
45 destination_(pset.getUntrackedParameter<
string>(
"destination")),
46 requiredTriggers_(pset.getUntrackedParameter<
vstring>(
"requiredTriggers")),
50 moduleLabels_(moduleLabels),
51 hasTargetRecoCuts(targetParams_.exists(
"recoCuts")),
52 hasProbeRecoCuts(probeParams_.exists(
"recoCuts")),
53 targetMuonSelector_(targetParams_.getUntrackedParameter<
string>(
"recoCuts",
"")),
54 targetZ0Cut_(targetParams_.getUntrackedParameter<double>(
"z0Cut",0.)),
55 targetD0Cut_(targetParams_.getUntrackedParameter<double>(
"d0Cut",0.)),
56 probeMuonSelector_(probeParams_.getUntrackedParameter<
string>(
"recoCuts",
"")),
57 probeZ0Cut_(probeParams_.getUntrackedParameter<double>(
"z0Cut",0.)),
58 probeD0Cut_(probeParams_.getUntrackedParameter<double>(
"d0Cut",0.))
78 TPRegexp levelRegexp(
"L[1-3]");
80 TObjArray * levelArray = levelRegexp.MatchS(
moduleLabels_[nModules - 1]);
81 if (levelArray->GetEntriesFast() > 0) {
82 triggerLevel_ = ((TObjString *)levelArray->At(0))->GetString();
88 TPRegexp ptRegexp(
"Mu([0-9]*)");
89 TObjArray * objArray = ptRegexp.MatchS(
hltPath_);
90 if (objArray->GetEntriesFast() >= 2) {
91 TObjString * ptCutString = (TObjString *)objArray->At(1);
92 cutMinPt_ = atoi(ptCutString->GetString());
102 TPRegexp suffixPtCut(
"Mu[0-9]+$");
105 if (baseDir[baseDir.size() - 1] !=
'/') baseDir +=
'/';
113 book1D(
"deltaR",
"deltaR",
";#Deltar(reco, HLT);");
114 book1D(
"hltPt",
"pt",
";p_{T} of HLT object");
115 book1D(
"hltEta",
"eta",
";#eta of HLT object");
116 book1D(
"hltPhi",
"phi",
";#phi of HLT object");
117 book1D(
"resolutionEta",
"resolutionEta",
";#eta^{reco}-#eta^{HLT};");
118 book1D(
"resolutionPhi",
"resolutionPhi",
";#phi^{reco}-#phi^{HLT};");
119 book1D(
"resolutionPt",
"resolutionRel",
120 ";(p_{T}^{reco}-p_{T}^{HLT})/|p_{T}^{reco}|;");
122 for (
size_t i = 0;
i < 2;
i++) {
126 book1D(
"efficiencyEta_" + suffix,
"eta",
";#eta;");
127 book1D(
"efficiencyPhi_" + suffix,
"phi",
";#phi;");
128 book1D(
"efficiencyTurnOn_" + suffix,
"pt",
";p_{T};");
129 book1D(
"efficiencyD0_" + suffix,
"d0",
";d0;");
130 book1D(
"efficiencyZ0_" + suffix,
"z0",
";z0;");
131 book1D(
"efficiencyCharge_" + suffix,
"charge",
";charge;");
132 book1D(
"efficiencyVertex_" + suffix,
"NVertex",
";NVertex;");
134 book2D(
"efficiencyPhiVsEta_" + suffix,
"etaCoarse",
"phiCoarse",
137 book1D(
"fakerateEta_" + suffix,
"eta",
";#eta;");
138 book1D(
"fakerateVertex_" + suffix,
"NVertex",
";NVertex;");
139 book1D(
"fakeratePhi_" + suffix,
"phi",
";#phi;");
140 book1D(
"fakerateTurnOn_" + suffix,
"pt",
";p_{T};");
142 book1D(
"massVsEtaZ_" + suffix,
"etaCoarse",
";#eta");
143 book1D(
"massVsEtaJpsi_" + suffix,
"etaCoarse",
";#eta");
144 book1D(
"massVsPtZ_" + suffix,
"ptCoarse",
";p_{T}");
145 book1D(
"massVsPtJpsi_" + suffix,
"ptCoarse",
";p_{T}");
146 book1D(
"massVsVertexZ_" + suffix,
"NVertex",
";NVertex");
147 book1D(
"massVsVertexJpsi_" + suffix,
"NVertex",
";NVertex");
179 iEvent.
getByLabel(
"offlinePrimaryVertices", vertices);
190 edm::LogError(
"HLTMuonMatchAndPlot")<<
"Missing triggerSummary with label " <<
inputTags_[
"triggerSummary"] <<std::endl;
196 edm::LogError(
"HLTMuonMatchAndPlot")<<
"Missing triggerResults with label " <<
inputTags_[
"triggerResults"] <<std::endl;
248 if (triggerIndex < triggerResults->
size() ||
249 !triggerResults->accept(triggerIndex))
261 for (
size_t i = 0;
i < hltMuons.size();
i++) {
268 vector<size_t> matches =
matchByDeltaR(targetMuons, hltMuons,
273 bool pairalreadyconsidered =
false;
274 for (
size_t i = 0;
i < targetMuons.size();
i++) {
279 if (matches[
i] < targetMuons.size()) {
281 double ptRes = (muon.
pt() - hltMuon.
pt()) / muon.
pt();
282 double etaRes = muon.
eta() - hltMuon.
eta();
283 double phiRes = muon.
phi() - hltMuon.
phi();
284 hists_[
"resolutionEta"]->Fill(etaRes);
285 hists_[
"resolutionPhi"]->Fill(phiRes);
286 hists_[
"resolutionPt"]->Fill(ptRes);
291 for (
size_t j = 0;
j < 2;
j++) {
296 if (suffix ==
"numer" && matches[
i] >= targetMuons.size())
continue;
308 const Track * track = 0;
312 double d0 = track->
dxy(beamSpot->position());
313 double z0 = track->
dz(beamSpot->position());
314 hists_[
"efficiencyVertex_" +
suffix]->Fill(vertices->size());
325 if(matches[
i] >= targetMuons.size())
continue;
326 for (
size_t k = 0;
k < targetMuons.size();
k++) {
328 if(muon.
pt() < 20.0)
continue;
329 Muon & theProbe = targetMuons[
k];
330 if (muon.
charge() != theProbe.
charge() && !pairalreadyconsidered) {
331 double mass = (muon.
p4() + theProbe.
p4()).M();
332 if(mass > 60 && mass < 120) {
333 hists_[
"massVsEtaZ_denom"]->Fill(theProbe.
eta());
334 hists_[
"massVsPtZ_denom"]->Fill(theProbe.
pt());
335 hists_[
"massVsVertexZ_denom"]->Fill(vertices->size());
336 if(matches[
k] < targetMuons.size()) {
337 hists_[
"massVsEtaZ_numer"]->Fill(theProbe.
eta());
338 hists_[
"massVsPtZ_numer"]->Fill(theProbe.
pt());
339 hists_[
"massVsVertexZ_numer"]->Fill(vertices->size());
341 pairalreadyconsidered =
true;
343 if(mass > 1 && mass < 4) {
344 hists_[
"massVsEtaJpsi_denom"]->Fill(theProbe.
eta());
345 hists_[
"massVsPtJpsi_denom"]->Fill(theProbe.
pt());
346 hists_[
"massVsVertexJpsi_denom"]->Fill(vertices->size());
347 if(matches[
k] < targetMuons.size()) {
348 hists_[
"massVsEtaJpsi_numer"]->Fill(theProbe.
eta());
349 hists_[
"massVsPtJpsi_numer"]->Fill(theProbe.
pt());
350 hists_[
"massVsVertexJpsi_numer"]->Fill(vertices->size());
352 pairalreadyconsidered =
true;
359 vector<size_t> hltMatches =
matchByDeltaR(hltMuons, targetMuons,
361 for (
size_t i = 0;
i < hltMuons.size();
i++) {
363 bool isFake = hltMatches[
i] > hltMuons.size();
364 for (
size_t j = 0;
j < 2;
j++) {
367 if (suffix ==
"numer" && ! isFake)
continue;
368 hists_[
"fakerateVertex_" +
suffix]->Fill(vertices->size());
383 const vector<double>&
binning) {
385 if (binning.size() < 3) {
386 LogWarning(
"HLTMuonVal") <<
"Invalid binning parameters!";
391 if (binning.size() == 3) {
393 edges =
new float[nBins + 1];
394 const double min = binning[1];
395 const double binwidth = (binning[2] - binning[1]) / nBins;
396 for (
size_t i = 0;
i <= nBins;
i++) edges[
i] = min + (binwidth *
i);
401 nBins = binning.size() - 1;
402 edges =
new float[nBins + 1];
403 for (
size_t i = 0;
i <= nBins;
i++) edges[
i] = binning[
i];
427 vector<string>::const_iterator iter;
429 for (iter = names.begin(); iter != names.end(); ++iter) {
430 if (targetPset.
existsAs<
T>(* iter,
true))
432 else if (targetPset.
existsAs<
T>(* iter,
false))
441 template <
class T1,
class T2>
444 const vector<T2> & collection2,
445 const double maxDeltaR) {
447 const size_t n1 = collection1.size();
448 const size_t n2 = collection2.size();
450 vector<size_t>
result(n1, -1);
451 vector<vector<double> > deltaRMatrix(n1, vector<double>(n2,
NOMATCH));
453 for (
size_t i = 0;
i < n1;
i++)
454 for (
size_t j = 0;
j < n2;
j++) {
455 deltaRMatrix[
i][
j] =
deltaR(collection1[
i], collection2[
j]);
459 for (
size_t k = 0;
k < n1;
k++) {
462 double minDeltaR = maxDeltaR;
464 for (
size_t i = 0;
i < n1;
i++)
465 for (
size_t j = 0;
j < n2;
j++)
466 if (deltaRMatrix[
i][
j] < minDeltaR) {
469 minDeltaR = deltaRMatrix[
i][
j];
472 if (minDeltaR < maxDeltaR) {
473 result[i_min] = j_min;
474 deltaRMatrix[i_min] = vector<double>(n2,
NOMATCH);
475 for (
size_t i = 0;
i < n1;
i++)
491 double d0Cut,
double z0Cut)
498 MuonCollection::iterator iter = reducedMuons.begin();
499 while (iter != reducedMuons.end()) {
500 const Track * track = 0;
501 if (iter->isTrackerMuon()) track = & * iter->innerTrack();
502 else if (iter->isStandAloneMuon()) track = & * iter->outerTrack();
503 if (track && selector(* iter) &&
507 else reducedMuons.erase(iter);
524 if (!pset.
exists(
"hltCuts"))
532 size_t filterIndex = triggerSummary.
filterIndex(filterTag);
538 for (
size_t j = 0;
j < keys.size();
j++ ){
540 if (selector(foundObject))
541 selectedObjects.push_back(foundObject);
545 return selectedObjects;
576 string binningTypeY,
string title)
594 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]
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
virtual TrackRef innerTrack() const
edm::ParameterSet targetParams_
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
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void book1D(std::string, std::string, std::string)
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)
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
void fillMapFromPSet(std::map< std::string, T > &, const edm::ParameterSet &, std::string)
void analyze(const edm::Event &, const edm::EventSetup &)
std::string hltProcessName_
void beginRun(const edm::Run &, const edm::EventSetup &)
std::vector< size_t > matchByDeltaR(const std::vector< T1 > &, const std::vector< T2 > &, const double maxDeltaR=NOMATCH)
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(std::string, std::string, std::string, std::string)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
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)
StringCutObjectSelector< reco::Muon > targetMuonSelector_
ParameterSet const & getParameterSet(std::string const &) const
virtual int charge() const GCC11_FINAL
electric charge
std::vector< size_type > Keys
std::map< std::string, edm::InputTag > inputTags_
trigger::TriggerObjectCollection selectedTriggerObjects(const trigger::TriggerObjectCollection &, const trigger::TriggerEvent &, const edm::ParameterSet &)
TH2F * getTH2F(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
void endRun(const edm::Run &, const edm::EventSetup &)
const Point & position() const
position
HLTMuonMatchAndPlot(const edm::ParameterSet &, std::string, const std::vector< std::string > &)
Constructor.
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
virtual float pt() const GCC11_FINAL
transverse momentum
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.
void setCurrentFolder(const std::string &fullpath)