Skip to content

Commit 36eab51

Browse files
committed
Implement summary plot creation for Muons
- Muon track validator now takes a vector of input tags for label, associatormap, and muonHistoParameters (same size, same order) - Summary plots can be used to compare efficiency and fake rate of muon objects both at the HLT and Offline - A single MuonTrackValidator object is used at the HLT to produce summary plots comparing all collections - Offline still split into multiple MuonTrackValidator objects, grouped per type (standard, refit, displaced, TeV, cosmic) - Update MuonTrackValidator logging information
1 parent 82830fd commit 36eab51

File tree

9 files changed

+968
-508
lines changed

9 files changed

+968
-508
lines changed

Validation/RecoMuon/plugins/MuonTrackValidator.cc

Lines changed: 694 additions & 311 deletions
Large diffs are not rendered by default.

Validation/RecoMuon/plugins/MuonTrackValidator.h

Lines changed: 59 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class MuonTrackValidator : public DQMEDAnalyzer, protected MuonTrackValidatorBas
2626
/// Constructor
2727
MuonTrackValidator(const edm::ParameterSet& pset) : MuonTrackValidatorBase(pset) {
2828
dirName_ = pset.getParameter<std::string>("dirName");
29-
associatormap = pset.getParameter<edm::InputTag>("associatormap");
29+
associatormap = pset.getParameter<std::vector<edm::InputTag>>("associatormap");
3030
UseAssociators = pset.getParameter<bool>("UseAssociators");
3131
useGEMs_ = pset.getParameter<bool>("useGEMs");
3232
useME0_ = pset.getParameter<bool>("useME0");
@@ -42,7 +42,7 @@ class MuonTrackValidator : public DQMEDAnalyzer, protected MuonTrackValidatorBas
4242
tpset.getParameter<bool>("intimeOnly"),
4343
tpset.getParameter<bool>("chargedOnly"),
4444
tpset.getParameter<bool>("stableOnly"),
45-
tpset.getParameter<std::vector<int> >("pdgId"));
45+
tpset.getParameter<std::vector<int>>("pdgId"));
4646

4747
cosmictpSelector = CosmicTrackingParticleSelector(tpset.getParameter<double>("ptMin"),
4848
tpset.getParameter<double>("minRapidity"),
@@ -51,9 +51,10 @@ class MuonTrackValidator : public DQMEDAnalyzer, protected MuonTrackValidatorBas
5151
tpset.getParameter<double>("lip"),
5252
tpset.getParameter<int>("minHit"),
5353
tpset.getParameter<bool>("chargedOnly"),
54-
tpset.getParameter<std::vector<int> >("pdgId"));
54+
tpset.getParameter<std::vector<int>>("pdgId"));
5555

5656
BiDirectional_RecoToSim_association = pset.getParameter<bool>("BiDirectional_RecoToSim_association");
57+
doSummaryPlots_ = pset.getParameter<bool>("doSummaryPlots");
5758

5859
// dump cfg parameters
5960
edm::LogVerbatim("MuonTrackValidator") << "constructing MuonTrackValidator: " << pset.dump();
@@ -64,12 +65,36 @@ class MuonTrackValidator : public DQMEDAnalyzer, protected MuonTrackValidatorBas
6465
tp_refvector_Token = consumes<TrackingParticleRefVector>(label_tp);
6566
else
6667
tp_Token = consumes<TrackingParticleCollection>(label_tp);
67-
pileupinfo_Token = consumes<std::vector<PileupSummaryInfo> >(label_pileupinfo);
68+
pileupinfo_Token = consumes<std::vector<PileupSummaryInfo>>(label_pileupinfo);
69+
70+
if (!UseAssociators && label.size() != associatormap.size()) {
71+
throw cms::Exception("Configuration")
72+
<< "Different number of labels and associators provided!" << '\n'
73+
<< "Please, make sure to configure the muonValidator with the same number and ordering "
74+
"of labels and associators!";
75+
}
76+
77+
if (label.size() == 1 && doSummaryPlots_) {
78+
edm::LogWarning("MuonTrackValidator")
79+
<< "Cannot produce summary plots for a single collection label, disabling summary plots creation!" << '\n';
80+
doSummaryPlots_ = false;
81+
}
82+
83+
if (label.size() != histoParameters.size()) {
84+
throw cms::Exception("Configuration")
85+
<< "Different number of labels and histoParameters provided!" << '\n'
86+
<< "Please, make sure to configure the muonValidator with the same number and ordering "
87+
"of labels and histoParameters!";
88+
}
89+
90+
track_Collection_Token.reserve(label.size());
91+
simToRecoCollection_Token.reserve(label.size());
92+
recoToSimCollection_Token.reserve(label.size());
6893
for (unsigned int www = 0; www < label.size(); www++) {
69-
track_Collection_Token.push_back(consumes<edm::View<reco::Track> >(label[www]));
94+
track_Collection_Token.push_back(consumes<edm::View<reco::Track>>(label[www]));
95+
simToRecoCollection_Token.push_back(consumes<reco::SimToRecoCollection>(associatormap[www]));
96+
recoToSimCollection_Token.push_back(consumes<reco::RecoToSimCollection>(associatormap[www]));
7097
}
71-
simToRecoCollection_Token = consumes<reco::SimToRecoCollection>(associatormap);
72-
recoToSimCollection_Token = consumes<reco::RecoToSimCollection>(associatormap);
7398

7499
if (parametersDefiner == "LhcParametersDefinerForTP") {
75100
lhcParametersDefinerTP_ = std::make_unique<ParametersDefinerForTP>(bsSrc, consumesCollector());
@@ -89,26 +114,29 @@ class MuonTrackValidator : public DQMEDAnalyzer, protected MuonTrackValidatorBas
89114
MABH = true;
90115
// reset string associators to the map label
91116
associators.clear();
92-
associators.push_back(associatormap.label());
93-
edm::LogVerbatim("MuonTrackValidator") << "--> associators reset to: " << associators[0];
117+
associators.reserve(associatormap.size());
118+
std::transform(
119+
associatormap.begin(), associatormap.end(), std::back_inserter(associators), [](const edm::InputTag& tag) {
120+
return tag.label();
121+
});
94122
} else {
95123
for (auto const& associator : associators) {
96124
consumes<reco::TrackToTrackingParticleAssociator>(edm::InputTag(associator));
97125
}
98126
}
99127

100-
// inform on which SimHits will be counted
101-
if (usetracker)
102-
edm::LogVerbatim("MuonTrackValidator") << "\n usetracker = TRUE : Tracker SimHits WILL be counted";
103-
else
104-
edm::LogVerbatim("MuonTrackValidator") << "\n usetracker = FALSE : Tracker SimHits WILL NOT be counted";
105-
if (usemuon)
106-
edm::LogVerbatim("MuonTrackValidator") << " usemuon = TRUE : Muon SimHits WILL be counted";
107-
else
108-
edm::LogVerbatim("MuonTrackValidator") << " usemuon = FALSE : Muon SimHits WILL NOT be counted" << std::endl;
109-
110128
// loop over the reco::Track collections to validate: check for inconsistent input settings
111129
for (unsigned int www = 0; www < label.size(); www++) {
130+
// inform on which SimHits will be counted
131+
if (histoParameters[www].usetracker)
132+
edm::LogVerbatim("MuonTrackValidator") << "\n usetracker = TRUE : Tracker SimHits WILL be counted";
133+
else
134+
edm::LogVerbatim("MuonTrackValidator") << "\n usetracker = FALSE : Tracker SimHits WILL NOT be counted";
135+
if (histoParameters[www].usemuon)
136+
edm::LogVerbatim("MuonTrackValidator") << " usemuon = TRUE : Muon SimHits WILL be counted";
137+
else
138+
edm::LogVerbatim("MuonTrackValidator") << " usemuon = FALSE : Muon SimHits WILL NOT be counted" << std::endl;
139+
112140
std::string recoTracksLabel = label[www].label();
113141
std::string recoTracksInstance = label[www].instance();
114142

@@ -119,17 +147,17 @@ class MuonTrackValidator : public DQMEDAnalyzer, protected MuonTrackValidatorBas
119147
recoTracksLabel == "ctfWithMaterialTracksP5" ||
120148
recoTracksLabel == "hltIterL3OIMuonTrackSelectionHighPurity" || recoTracksLabel == "hltIterL3MuonMerged" ||
121149
recoTracksLabel == "hltIterL3MuonAndMuonFromL1Merged") {
122-
if (usemuon) {
150+
if (histoParameters[www].usemuon) {
123151
edm::LogWarning("MuonTrackValidator")
124152
<< "\n*** WARNING : inconsistent input tracksTag = " << label[www] << "\n with usemuon == true"
125153
<< "\n ---> resetting to usemuon == false ";
126-
usemuon = false;
154+
histoParameters[www].usemuon = false;
127155
}
128-
if (!usetracker) {
156+
if (!histoParameters[www].usetracker) {
129157
edm::LogWarning("MuonTrackValidator")
130158
<< "\n*** WARNING : inconsistent input tracksTag = " << label[www] << "\n with usetracker == false"
131159
<< "\n ---> resetting to usetracker == true ";
132-
usetracker = true;
160+
histoParameters[www].usetracker = true;
133161
}
134162
}
135163

@@ -138,17 +166,17 @@ class MuonTrackValidator : public DQMEDAnalyzer, protected MuonTrackValidatorBas
138166
recoTracksLabel == "seedsOfDisplacedSTAmuons" || recoTracksLabel == "displacedStandAloneMuons" ||
139167
recoTracksLabel == "refittedStandAloneMuons" || recoTracksLabel == "cosmicMuons" ||
140168
recoTracksLabel == "cosmicMuons1Leg" || recoTracksLabel == "hltL2Muons") {
141-
if (usetracker) {
169+
if (histoParameters[www].usetracker) {
142170
edm::LogWarning("MuonTrackValidator")
143171
<< "\n*** WARNING : inconsistent input tracksTag = " << label[www] << "\n with usetracker == true"
144172
<< "\n ---> resetting to usetracker == false ";
145-
usetracker = false;
173+
histoParameters[www].usetracker = false;
146174
}
147-
if (!usemuon) {
175+
if (!histoParameters[www].usemuon) {
148176
edm::LogWarning("MuonTrackValidator")
149177
<< "\n*** WARNING : inconsistent input tracksTag = " << label[www] << "\n with usemuon == false"
150178
<< "\n ---> resetting to usemuon == true ";
151-
usemuon = true;
179+
histoParameters[www].usemuon = true;
152180
}
153181
}
154182

@@ -163,9 +191,9 @@ class MuonTrackValidator : public DQMEDAnalyzer, protected MuonTrackValidatorBas
163191

164192
private:
165193
std::string dirName_;
166-
edm::InputTag associatormap;
167-
edm::EDGetTokenT<reco::SimToRecoCollection> simToRecoCollection_Token;
168-
edm::EDGetTokenT<reco::RecoToSimCollection> recoToSimCollection_Token;
194+
std::vector<edm::InputTag> associatormap;
195+
std::vector<edm::EDGetTokenT<reco::SimToRecoCollection>> simToRecoCollection_Token;
196+
std::vector<edm::EDGetTokenT<reco::RecoToSimCollection>> recoToSimCollection_Token;
169197
edm::EDGetTokenT<SimHitTPAssociationProducer::SimHitTPAssociationList> _simHitTpMapTag;
170198

171199
std::unique_ptr<ParametersDefinerForTP> lhcParametersDefinerTP_;
@@ -184,6 +212,7 @@ class MuonTrackValidator : public DQMEDAnalyzer, protected MuonTrackValidatorBas
184212
bool BiDirectional_RecoToSim_association;
185213
// flag MuonAssociatorByHits
186214
bool MABH;
215+
bool doSummaryPlots_;
187216
};
188217

189218
#endif

0 commit comments

Comments
 (0)