Skip to content

Commit f9272e7

Browse files
authored
Merge pull request #47429 from mmusich/mm_improve_HLTObjectMonitor
Improvements to `HLTObjectMonitor`
2 parents 627c99a + 903fb1d commit f9272e7

File tree

2 files changed

+121
-45
lines changed

2 files changed

+121
-45
lines changed

DQM/HLTEvF/plugins/HLTObjectMonitor.cc

Lines changed: 108 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ class HLTObjectMonitor : public DQMEDAnalyzer {
8484

8585
public:
8686
explicit HLTObjectMonitor(const edm::ParameterSet&);
87+
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
8788

8889
private:
8990
void analyze(const edm::Event&, const edm::EventSetup&) override;
9091
void bookHistograms(DQMStore::IBooker& i, edm::Run const&, edm::EventSetup const&) override;
9192
void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
9293
vector<hltPlot*> plotList;
9394
double dxyFinder(double, double, edm::Handle<reco::RecoChargedCandidateCollection>, edm::Handle<reco::BeamSpot>);
95+
double dzFinder(double, double, edm::Handle<reco::RecoChargedCandidateCollection>, edm::Handle<reco::BeamSpot>);
9496
double get_wall_time(void);
9597
// ----------member data ---------------------------
9698

@@ -153,6 +155,7 @@ class HLTObjectMonitor : public DQMEDAnalyzer {
153155
edm::ParameterSet pAL3DoubleMuZMass_pset;
154156
edm::ParameterSet diElecMass_pset;
155157
edm::ParameterSet muonDxy_pset;
158+
edm::ParameterSet muonDz_pset;
156159
edm::ParameterSet wallTime_pset;
157160

158161
string processName_;
@@ -196,6 +199,7 @@ class HLTObjectMonitor : public DQMEDAnalyzer {
196199
hltPlot pAL3DoubleMuZMass_;
197200
hltPlot diElecMass_;
198201
hltPlot muonDxy_;
202+
hltPlot muonDz_;
199203
hltPlot wallTime_;
200204
};
201205

@@ -297,31 +301,32 @@ HLTObjectMonitor::HLTObjectMonitor(const edm::ParameterSet& iConfig)
297301
plotMap[&diElecMass_] = &diElecMass_pset;
298302
muonDxy_pset = iConfig.getParameter<edm::ParameterSet>("muonDxy");
299303
plotMap[&muonDxy_] = &muonDxy_pset;
304+
muonDz_pset = iConfig.getParameter<edm::ParameterSet>("muonDz");
305+
plotMap[&muonDz_] = &muonDz_pset;
300306
jetAK8Pt_pset = iConfig.getParameter<edm::ParameterSet>("jetAK8Pt");
301307
plotMap[&jetAK8Pt_] = &jetAK8Pt_pset;
302308
tauPt_pset = iConfig.getParameter<edm::ParameterSet>("tauPt");
303309
plotMap[&tauPt_] = &tauPt_pset;
304310
wallTime_pset = iConfig.getParameter<edm::ParameterSet>("wallTime");
305311
plotMap[&wallTime_] = &wallTime_pset;
306312

307-
for (auto item = plotMap.begin(); item != plotMap.end(); item++) {
308-
(*item->first).pathName = (*item->second).getParameter<string>("pathName");
309-
(*item->first).moduleName = (*item->second).getParameter<string>("moduleName");
310-
(*item->first).nBins = (*item->second).getParameter<int>("NbinsX");
311-
(*item->first).xMin = (*item->second).getParameter<double>("Xmin");
312-
(*item->first).xMax = (*item->second).getParameter<double>("Xmax");
313-
(*item->first).xAxisLabel = (*item->second).getParameter<string>("axisLabel");
314-
(*item->first).plotLabel = (*item->second).getParameter<string>("plotLabel");
315-
(*item->first).displayInPrimary = (*item->second).getParameter<bool>("mainWorkspace");
316-
317-
if ((*item->second).exists("pathName_OR")) {
318-
(*item->first).pathNameOR = (*item->second).getParameter<string>("pathName_OR");
313+
for (auto& [key, value] : plotMap) {
314+
key->pathName = value->getParameter<std::string>("pathName");
315+
key->moduleName = value->getParameter<std::string>("moduleName");
316+
key->nBins = value->getParameter<int>("NbinsX");
317+
key->xMin = value->getParameter<double>("Xmin");
318+
key->xMax = value->getParameter<double>("Xmax");
319+
key->xAxisLabel = value->getParameter<std::string>("axisLabel");
320+
key->plotLabel = value->getParameter<std::string>("plotLabel");
321+
key->displayInPrimary = value->getParameter<bool>("mainWorkspace");
322+
323+
if (value->exists("pathName_OR")) {
324+
key->pathNameOR = value->getParameter<std::string>("pathName_OR");
319325
}
320-
if ((*item->second).exists("moduleName_OR")) {
321-
(*item->first).moduleNameOR = (*item->second).getParameter<string>("moduleName_OR");
326+
if (value->exists("moduleName_OR")) {
327+
key->moduleNameOR = value->getParameter<std::string>("moduleName_OR");
322328
}
323-
324-
plotList.push_back(item->first);
329+
plotList.push_back(key);
325330
}
326331
plotMap.clear();
327332

@@ -560,13 +565,19 @@ void HLTObjectMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup&
560565
iEvent.getByToken(chargedCandToken_, recoChargedCands);
561566
edm::Handle<reco::BeamSpot> recoBeamSpot;
562567
iEvent.getByToken(beamSpotToken_, recoBeamSpot);
563-
double muon_dxy;
568+
double muon_dxy, muon_dz;
564569

565570
if (recoChargedCands.isValid() && recoBeamSpot.isValid()) {
566571
for (const auto& key : keys) {
567572
muon_dxy = dxyFinder(objects[key].eta(), objects[key].phi(), recoChargedCands, recoBeamSpot);
568-
if (muon_dxy != -99.)
573+
if (muon_dxy != -99.) {
569574
muonDxy_.ME->Fill(muon_dxy);
575+
}
576+
577+
muon_dz = dzFinder(objects[key].eta(), objects[key].phi(), recoChargedCands, recoBeamSpot);
578+
if (muon_dz != -99.) {
579+
muonDz_.ME->Fill(muon_dz);
580+
}
570581
}
571582
}
572583
}
@@ -826,38 +837,94 @@ double HLTObjectMonitor::dxyFinder(double eta,
826837
return dxy;
827838
}
828839

840+
double HLTObjectMonitor::dzFinder(double eta,
841+
double phi,
842+
edm::Handle<reco::RecoChargedCandidateCollection> recoChargedCands,
843+
edm::Handle<reco::BeamSpot> recoBeamSpot) {
844+
double dz = -99.;
845+
for (reco::RecoChargedCandidateCollection::const_iterator l3Muon = recoChargedCands->begin();
846+
l3Muon != recoChargedCands->end();
847+
l3Muon++) {
848+
if (deltaR(eta, phi, l3Muon->eta(), l3Muon->phi()) < 0.1) {
849+
dz = (l3Muon->vz() - recoBeamSpot->z0()) -
850+
((l3Muon->vx() - recoBeamSpot->x0()) * l3Muon->px() + (l3Muon->vy() - recoBeamSpot->y0()) * l3Muon->py()) /
851+
l3Muon->pt() * (l3Muon->pz() / l3Muon->pt());
852+
break;
853+
}
854+
}
855+
return dz;
856+
}
857+
829858
double HLTObjectMonitor::get_wall_time() {
830859
struct timeval time;
831860
if (gettimeofday(&time, nullptr))
832861
return 0;
833862
return (double)time.tv_sec + (double)time.tv_usec * .000001;
834863
}
835864

836-
// ------------ method called when starting to processes a luminosity block ------------
837-
/*
838-
void
839-
HLTObjectMonitor::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
840-
{
841-
}
842-
*/
865+
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
866+
void HLTObjectMonitor::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
867+
edm::ParameterSetDescription desc;
868+
desc.add<std::string>("processName", "HLT");
869+
870+
auto addPSet = [](edm::ParameterSetDescription& desc, const std::string& name) {
871+
edm::ParameterSetDescription pset;
872+
pset.add<std::string>("pathName", "");
873+
pset.add<std::string>("moduleName", "");
874+
pset.addOptional<std::string>("pathName_OR");
875+
pset.addOptional<std::string>("moduleName_OR");
876+
pset.add<std::string>("plotLabel", "");
877+
pset.add<std::string>("axisLabel", "");
878+
pset.add<bool>("mainWorkspace", false);
879+
pset.add<int>("NbinsX", 50);
880+
pset.add<double>("Xmin", 0.0);
881+
pset.add<double>("Xmax", 1.0);
882+
desc.add<edm::ParameterSetDescription>(name, pset);
883+
};
843884

844-
// ------------ method called when ending the processing of a luminosity block ------------
845-
/*
846-
void
847-
HLTObjectMonitor::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
848-
{
885+
addPSet(desc, "alphaT");
886+
addPSet(desc, "photonPt");
887+
addPSet(desc, "photonEta");
888+
addPSet(desc, "photonPhi");
889+
addPSet(desc, "muonPt");
890+
addPSet(desc, "muonEta");
891+
addPSet(desc, "muonPhi");
892+
addPSet(desc, "l2muonPt");
893+
addPSet(desc, "l2muonEta");
894+
addPSet(desc, "l2muonPhi");
895+
addPSet(desc, "l2NoBPTXmuonPt");
896+
addPSet(desc, "l2NoBPTXmuonEta");
897+
addPSet(desc, "l2NoBPTXmuonPhi");
898+
addPSet(desc, "electronPt");
899+
addPSet(desc, "electronEta");
900+
addPSet(desc, "electronPhi");
901+
addPSet(desc, "jetPt");
902+
addPSet(desc, "jetAK8Pt");
903+
addPSet(desc, "jetAK8Mass");
904+
addPSet(desc, "tauPt");
905+
addPSet(desc, "diMuonLowMass");
906+
addPSet(desc, "caloMetPt");
907+
addPSet(desc, "caloMetPhi");
908+
addPSet(desc, "pfMetPt");
909+
addPSet(desc, "pfMetPhi");
910+
addPSet(desc, "caloHtPt");
911+
addPSet(desc, "pfHtPt");
912+
addPSet(desc, "bJetEta");
913+
addPSet(desc, "bJetPhi");
914+
addPSet(desc, "bJetCSVCalo");
915+
addPSet(desc, "bJetCSVPF");
916+
addPSet(desc, "rsq");
917+
addPSet(desc, "mr");
918+
addPSet(desc, "diMuonMass");
919+
addPSet(desc, "pAL1DoubleMuZMass");
920+
addPSet(desc, "pAL2DoubleMuZMass");
921+
addPSet(desc, "pAL3DoubleMuZMass");
922+
addPSet(desc, "diElecMass");
923+
addPSet(desc, "muonDxy");
924+
addPSet(desc, "muonDz");
925+
addPSet(desc, "wallTime");
926+
descriptions.addWithDefaultLabel(desc);
849927
}
850-
*/
851-
852-
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
853-
// void
854-
// HLTObjectMonitor::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
855-
// //The following says we do not know what parameters are allowed so do no validation
856-
// // Please change this to state exactly what you do use, even if it is no parameters
857-
// edm::ParameterSetDescription desc;
858-
// desc.setUnknown();
859-
// descriptions.addDefault(desc);
860-
// }
861928

862929
//define this as a plug-in
863930
DEFINE_FWK_MODULE(HLTObjectMonitor);

DQM/HLTEvF/python/HLTObjectMonitor_cfi.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,19 @@
431431
plotLabel = cms.string("Muon_dxy"),
432432
axisLabel = cms.string("muon d_{xy} [mm]"),
433433
mainWorkspace = cms.bool(True),
434-
NbinsX = cms.int32(2000),
435-
Xmin = cms.double(-10),
436-
Xmax = cms.double(10)
434+
NbinsX = cms.int32(200),
435+
Xmin = cms.double(-0.1),
436+
Xmax = cms.double(0.1)
437+
),
438+
muonDz = cms.PSet(
439+
pathName = cms.string("HLT_DoubleMu43NoFiltersNoVtx"),
440+
moduleName = cms.string("hltL3fDimuonL1f0L2NVf16L3NoFiltersNoVtxFiltered43"),
441+
plotLabel = cms.string("Muon_dz"),
442+
axisLabel = cms.string("muon d_{z} [mm]"),
443+
mainWorkspace = cms.bool(True),
444+
NbinsX = cms.int32(200),
445+
Xmin = cms.double(-100),
446+
Xmax = cms.double(100)
437447
),
438448
wallTime = cms.PSet(
439449
pathName = cms.string("wall time per event"),
@@ -445,5 +455,4 @@
445455
Xmin = cms.double(0),
446456
Xmax = cms.double(0.005)
447457
)
448-
449458
)

0 commit comments

Comments
 (0)