32 using namespace trigger;
33 using namespace l1extra;
44 vector<string> moduleLabels) :
45 hltProcessName_(pset.getParameter<string>(
"hltProcessName")),
46 destination_(pset.getUntrackedParameter<string>(
"destination")),
47 requiredTriggers_(pset.getUntrackedParameter<
vstring>(
"requiredTriggers")),
51 moduleLabels_(moduleLabels),
52 hasTargetRecoCuts(targetParams_.exists(
"recoCuts")),
53 hasProbeRecoCuts(probeParams_.exists(
"recoCuts")),
54 targetMuonSelector_(targetParams_.getUntrackedParameter<string>(
"recoCuts",
"")),
55 targetZ0Cut_(targetParams_.getUntrackedParameter<double>(
"z0Cut",0.)),
56 targetD0Cut_(targetParams_.getUntrackedParameter<double>(
"d0Cut",0.)),
57 probeMuonSelector_(probeParams_.getUntrackedParameter<string>(
"recoCuts",
"")),
58 probeZ0Cut_(probeParams_.getUntrackedParameter<double>(
"z0Cut",0.)),
59 probeD0Cut_(probeParams_.getUntrackedParameter<double>(
"d0Cut",0.))
79 TPRegexp levelRegexp(
"L[1-3]");
81 TObjArray * levelArray = levelRegexp.MatchS(
moduleLabels_[nModules - 1]);
82 if (levelArray->GetEntriesFast() > 0) {
83 triggerLevel_ = ((TObjString *)levelArray->At(0))->GetString();
89 TPRegexp ptRegexp(
"Mu([0-9]*)");
90 TObjArray * objArray = ptRegexp.MatchS(
hltPath_);
91 if (objArray->GetEntriesFast() >= 2) {
92 TObjString * ptCutString = (TObjString *)objArray->At(1);
93 cutMinPt_ = atoi(ptCutString->GetString());
103 TPRegexp suffixPtCut(
"Mu[0-9]+$");
106 if (baseDir[baseDir.size() - 1] !=
'/') baseDir +=
'/';
114 book1D(
"deltaR",
"deltaR",
";#Deltar(reco, HLT);");
115 book1D(
"resolutionEta",
"resolution",
116 ";(#eta^{reco}-#eta^{HLT})/|#eta^{reco}|;");
117 book1D(
"resolutionPhi",
"resolution",
118 ";(#phi^{reco}-#phi^{HLT})/|#phi^{reco}|;");
119 book1D(
"resolutionPt",
"resolution",
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 book2D(
"efficiencyPhiVsEta_" + suffix,
"etaCoarse",
"phiCoarse",
135 book1D(
"fakerateEta_" + suffix,
"eta",
";#eta;");
136 book1D(
"fakeratePhi_" + suffix,
"phi",
";#phi;");
137 book1D(
"fakerateTurnOn_" + suffix,
"pt",
";p_{T};");
143 book2D(
"massVsEta_" + suffix,
"zMass",
"etaCoarse",
";m_{#mu#mu};#eta");
174 edm::LogError(
"HLTMuonMatchAndPlot")<<
"Missing triggerSummary with label " <<
inputTags_[
"triggerSummary"] <<std::endl;
180 edm::LogError(
"HLTMuonMatchAndPlot")<<
"Missing triggerResults with label " <<
inputTags_[
"triggerResults"] <<std::endl;
186 if (triggerIndex < triggerResults->
size() ||
187 !triggerResults->accept(triggerIndex))
199 vector<size_t> matches =
matchByDeltaR(targetMuons, hltMuons,
203 for (
size_t i = 0;
i < targetMuons.size();
i++) {
208 if (matches[
i] < targetMuons.size()) {
210 double ptRes = (muon.
pt() - hltMuon.
pt()) / muon.
pt();
211 double etaRes = (muon.
eta() - hltMuon.
eta()) / fabs(muon.
eta());
212 double phiRes = (muon.
phi() - hltMuon.
phi()) / fabs(muon.
phi());
213 hists_[
"resolutionEta"]->Fill(etaRes);
214 hists_[
"resolutionPhi"]->Fill(phiRes);
215 hists_[
"resolutionPt"]->Fill(ptRes);
220 for (
size_t j = 0;
j < 2;
j++) {
225 if (suffix ==
"numer" && matches[
i] >= targetMuons.size())
continue;
237 const Track * track = 0;
241 double d0 = track->
dxy(beamSpot->position());
242 double z0 = track->
dz(beamSpot->position());
251 for (
size_t k = 0;
k < probeMuons.size();
k++) {
252 Muon & probe = targetMuons[
k];
254 double mass = (muon.
p4() + probe.
p4()).M();
264 vector<size_t> hltMatches =
matchByDeltaR(hltMuons, targetMuons,
266 for (
size_t i = 0;
i < hltMuons.size();
i++) {
268 bool isFake = hltMatches[
i] > hltMuons.size();
269 for (
size_t j = 0;
j < 2;
j++) {
272 if (suffix ==
"numer" && ! isFake)
continue;
287 vector<double> binning) {
289 if (binning.size() < 3) {
290 LogWarning(
"HLTMuonVal") <<
"Invalid binning parameters!";
295 if (binning.size() == 3) {
297 edges =
new float[nBins + 1];
298 const double min = binning[1];
299 const double binwidth = (binning[2] - binning[1]) / nBins;
300 for (
size_t i = 0;
i <= nBins;
i++) edges[
i] = min + (binwidth *
i);
305 nBins = binning.size() - 1;
306 edges =
new float[nBins + 1];
307 for (
size_t i = 0;
i <= nBins;
i++) edges[
i] = binning[
i];
331 vector<string>::const_iterator iter;
333 for (iter = names.begin(); iter != names.end(); ++iter) {
334 if (targetPset.
existsAs<
T>(* iter,
true))
336 else if (targetPset.
existsAs<
T>(* iter,
false))
345 template <
class T1,
class T2>
348 const vector<T2> & collection2,
349 const double maxDeltaR) {
351 const size_t n1 = collection1.size();
352 const size_t n2 = collection2.size();
354 vector<size_t>
result(n1, -1);
355 vector<vector<double> > deltaRMatrix(n1, vector<double>(n2,
NOMATCH));
357 for (
size_t i = 0;
i < n1;
i++)
358 for (
size_t j = 0;
j < n2;
j++) {
359 deltaRMatrix[
i][
j] =
deltaR(collection1[
i], collection2[
j]);
363 for (
size_t k = 0;
k < n1;
k++) {
366 double minDeltaR = maxDeltaR;
368 for (
size_t i = 0;
i < n1;
i++)
369 for (
size_t j = 0;
j < n2;
j++)
370 if (deltaRMatrix[
i][
j] < minDeltaR) {
373 minDeltaR = deltaRMatrix[
i][
j];
376 if (minDeltaR < maxDeltaR) {
377 result[i_min] = j_min;
378 deltaRMatrix[i_min] = vector<double>(n2,
NOMATCH);
379 for (
size_t i = 0;
i < n1;
i++)
395 double d0Cut,
double z0Cut)
402 MuonCollection::iterator iter = reducedMuons.begin();
403 while (iter != reducedMuons.end()) {
404 const Track * track = 0;
405 if (iter->isTrackerMuon()) track = & * iter->innerTrack();
406 else if (iter->isStandAloneMuon()) track = & * iter->outerTrack();
407 if (track && selector(* iter) &&
411 else reducedMuons.erase(iter);
428 if (!pset.
exists(
"hltCuts"))
436 size_t filterIndex = triggerSummary.
filterIndex(filterTag);
442 for (
size_t j = 0;
j < keys.size();
j++ ){
444 if (selector(foundObject))
445 selectedObjects.push_back(foundObject);
449 return selectedObjects;
462 TH1F *
h =
new TH1F(name.c_str(), title.c_str(), nBins,
edges);
473 string binningTypeY,
string title) {
483 TH2F *
h =
new TH2F(name.c_str(), title.c_str(),
484 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
const std::string EFFICIENCY_SUFFIXES[2]
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
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 fillEdges(size_t &nBins, float *&edges, std::vector< double > binning)
void book1D(std::string, std::string, std::string)
std::map< std::string, std::vector< double > > binParams_
std::string triggerLevel_
std::map< std::string, MonitorElement * > hists_
bool isStandAloneMuon() const
virtual double eta() const
momentum pseudorapidity
std::vector< Muon > MuonCollection
collection of Muon objects
std::vector< std::string > requiredTriggers_
Single trigger physics object (e.g., an isolated muon)
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)
HLTMuonMatchAndPlot(const edm::ParameterSet &, std::string, std::vector< std::string >)
Constructor.
ParameterSet const & getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
virtual int charge() const
electric charge
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
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 double pt() const
transverse momentum
std::vector< size_type > Keys
std::map< std::string, edm::InputTag > inputTags_
trigger::TriggerObjectCollection selectedTriggerObjects(const trigger::TriggerObjectCollection &, const trigger::TriggerEvent &, const edm::ParameterSet &)
std::vector< std::string > vstring
edm::ParameterSet probeParams_
void fillMapFromPSet(std::map< std::string, T > &, edm::ParameterSet, std::string)
void endRun(const edm::Run &, const edm::EventSetup &)
const Point & position() const
position
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
virtual double phi() const
momentum azimuthal angle
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
static const HistoName names[]
std::map< std::string, double > plotCuts_
tuple size
Write out results.
void setCurrentFolder(const std::string &fullpath)