6 using namespace ROOT::Math::VectorUtil;
77 edm::LogInfo(
"EmDQM") <<
"The following filter types are not analyzed: \n"
78 <<
"\tHLTGlobalSumsMET\n"
79 <<
"\tHLTHtMhtFilter\n"
87 <<
"\tPFTauSelector\n"
89 <<
"\tHLTPFJetCollectionsFilter\n"
90 <<
"\tHLTPFJetCollectionsVBFFilter\n"
92 <<
"\tEtMinCaloJetSelector\n"
93 <<
"\tEtMinPFJetSelector\n"
94 <<
"\tLargestEtCaloJetSelector\n"
95 <<
"\tLargestEtPFJetSelector\n"
96 <<
"\tHLTEgammaTriggerFilterObjectWrapper\n"
97 <<
"\tHLTEgammaDoubleLegCombFilter\n"
98 <<
"\tHLT2ElectronTau\n"
99 <<
"\tHLT2ElectronMET\n"
100 <<
"\tHLT2ElectronPFTau\n"
101 <<
"\tHLTPMMassFilter\n"
102 <<
"\tHLTHcalTowerFilter\n"
105 <<
"\tHLTRHemisphere\n"
106 <<
"\tHLTElectronPFMTFilter\n"
107 <<
"\tPrimaryVertexObjectFilter\n"
108 <<
"\tHLTEgammaAllCombMassFilter\n"
124 std::vector<std::string> filterModules;
126 for (
unsigned int j = 0;
j < egammaPaths.size();
j++) {
130 edm::LogPrint(
"EmDQM") <<
"////////////////////////////////////////"
131 "/\nSingle electron paths: ";
134 edm::LogPrint(
"EmDQM") <<
"////////////////////////////////////////"
135 "/\nDouble electron paths: ";
138 edm::LogPrint(
"EmDQM") <<
"////////////////////////////////////////"
139 "/\nTriple electron paths: ";
142 edm::LogPrint(
"EmDQM") <<
"////////////////////////////////////////"
143 "/\nSingle photon paths: ";
146 edm::LogPrint(
"EmDQM") <<
"////////////////////////////////////////"
147 "/\nDouble photon paths: ";
152 for (
unsigned int i = 0;
i < egammaPaths.at(
j).size();
i++) {
176 <<
"': Unable to determine a minimum Et. Will not include "
177 "this path in the validation.";
231 std::vector<edm::ParameterSet> filterVPSet;
236 for (std::vector<std::string>::iterator
filter = filterModules.begin();
filter != filterModules.end();
242 if (moduleType ==
"Pythia6GeneratorFilter" || moduleType ==
"HLTTriggerTypeFilter" ||
243 moduleType ==
"HLTLevel1Activity" || moduleType ==
"HLTPrescaler" || moduleType ==
"HLTBool")
247 if (moduleType ==
"HLTLevel1GTSeed") {
249 }
else if (moduleType ==
"HLTEgammaL1MatchFilterRegional") {
251 }
else if (moduleType ==
"HLTEgammaEtFilter") {
253 }
else if (moduleType ==
"HLTElectronOneOEMinusOneOPFilterRegional") {
255 }
else if (moduleType ==
"HLTElectronPixelMatchFilter") {
257 }
else if (moduleType ==
"HLTEgammaGenericFilter") {
259 }
else if (moduleType ==
"HLTEgammaGenericQuadraticFilter") {
261 }
else if (moduleType ==
"HLTElectronGenericFilter") {
263 }
else if (moduleType ==
"HLTEgammaDoubleEtDeltaPhiFilter") {
265 }
else if (moduleType ==
"HLTGlobalSumsMET" || moduleType ==
"HLTHtMhtFilter" ||
266 moduleType ==
"HLTMhtFilter" || moduleType ==
"HLTJetTag" || moduleType ==
"HLT1CaloJet" ||
267 moduleType ==
"HLT1CaloMET" || moduleType ==
"HLT1CaloBJet" || moduleType ==
"HLT1Tau" ||
268 moduleType ==
"HLT1PFTau" || moduleType ==
"PFTauSelector" || moduleType ==
"HLT1PFJet" ||
269 moduleType ==
"HLTPFJetCollectionsFilter" || moduleType ==
"HLTPFJetCollectionsVBFFilter" ||
270 moduleType ==
"HLTPFJetTag" || moduleType ==
"EtMinCaloJetSelector" ||
271 moduleType ==
"EtMinPFJetSelector" || moduleType ==
"LargestEtCaloJetSelector" ||
272 moduleType ==
"LargestEtPFJetSelector" ||
273 moduleType ==
"HLTEgammaTriggerFilterObjectWrapper"
274 || moduleType ==
"HLTEgammaDoubleLegCombFilter"
277 || moduleType ==
"HLT2ElectronMET" || moduleType ==
"HLT2ElectronTau" ||
278 moduleType ==
"HLT2ElectronPFTau" || moduleType ==
"HLTPMMassFilter" ||
279 moduleType ==
"HLTHcalTowerFilter" || moduleType ==
"HLT1Photon" || moduleType ==
"HLTRFilter" ||
280 moduleType ==
"HLTRHemisphere" || moduleType ==
"HLTElectronPFMTFilter" ||
281 moduleType ==
"PrimaryVertexObjectFilter" || moduleType ==
"HLTEgammaAllCombMassFilter" ||
282 moduleType.find(
"HLTMuon") != std::string::npos)
287 << moduleType <<
"' added. Module will not be analyzed.";
292 if (!filterPSet.
empty()) {
297 if (
moduleLabel.find(
"Unseeded") != std::string::npos &&
307 << paramSet.
getParameter<
int>(
"cutnum") <<
", determined from path name.";
310 edm::LogInfo(
"EmDQM") <<
"Changed required number of candidates from "
317 filterVPSet.push_back(filterPSet);
324 if (!filterPSet.
empty()) {
334 paramSet.
addParameter<std::vector<edm::ParameterSet>>(
"filters", filterVPSet);
337 edm::LogPrint(
"EmDQM") <<
"Will not include this path in the validation due to "
338 "errors while generating the parameter set.";
357 for (std::vector<edm::ParameterSet>::iterator psetIt =
paramSets.begin(); psetIt !=
paramSets.end(); ++psetIt) {
380 for (std::vector<edm::ParameterSet>::iterator psetIt =
paramSets.begin(); psetIt !=
paramSets.end(); ++psetIt) {
391 std::vector<MonitorElement *> etahist;
392 std::vector<MonitorElement *> phihist;
393 std::vector<MonitorElement *> ethist;
394 std::vector<MonitorElement *> etahistmatch;
395 std::vector<MonitorElement *> phihistmatch;
396 std::vector<MonitorElement *> ethistmatch;
397 std::vector<MonitorElement *> histEtOfHltObjMatchToGen;
398 std::vector<MonitorElement *> histEtaOfHltObjMatchToGen;
399 std::vector<MonitorElement *> histPhiOfHltObjMatchToGen;
400 std::vector<MonitorElement *> etaphihist;
401 std::vector<MonitorElement *> etaphihistmatch;
402 std::vector<MonitorElement *> histEtaPhiOfHltObjMatchToGen;
426 histName =
"total_eff_MC_matched";
427 histTitle =
"total events passing (mc matched)";
428 totalmatch = iBooker.
book1D(
445 pdgIdString =
"Electron";
448 pdgIdString =
"Photon";
451 pdgIdString =
"Particle";
455 histTitle =
"E_{T} of " + pdgIdString +
"s";
457 histName =
"gen_eta";
458 histTitle =
"#eta of " + pdgIdString +
"s ";
460 histName =
"gen_phi";
461 histTitle =
"#phi of " + pdgIdString +
"s ";
464 histName =
"gen_etaphi";
465 histTitle =
"#eta-#phi of " + pdgIdString +
"s ";
466 etaphigen = iBooker.
book2D(
472 std::vector<std::string> HltHistTitle;
487 ethist.push_back(tmphisto);
493 etahist.push_back(tmphisto);
500 phihist.push_back(tmphisto);
504 histTitle = HltHistTitle[
i] +
" #eta-#phi (ALL)";
505 tmphisto = iBooker.
book2D(
507 etaphihist.push_back(tmphisto);
514 histEtOfHltObjMatchToGen.push_back(tmphisto);
521 histEtaOfHltObjMatchToGen.push_back(tmphisto);
529 histPhiOfHltObjMatchToGen.push_back(tmphisto);
534 tmphisto = iBooker.
book2D(
536 histEtaPhiOfHltObjMatchToGen.push_back(tmphisto);
541 histTitle = HltHistTitle[
i] +
" Et (MC matched)";
543 ethistmatch.push_back(tmphisto);
547 histTitle = HltHistTitle[
i] +
" #eta (MC matched)";
549 etahistmatch.push_back(tmphisto);
554 histTitle = HltHistTitle[
i] +
" #phi (MC matched)";
556 phihistmatch.push_back(tmphisto);
560 histTitle = HltHistTitle[
i] +
" #eta-#phi (MC matched)";
561 tmphisto = iBooker.
book2D(
563 etaphihistmatch.push_back(tmphisto);
620 std::vector<reco::LeafCandidate> allSortedGenParticles;
624 currentGenParticle++) {
628 if (!(
abs((*currentGenParticle).pdgId()) ==
pdgGen && (*currentGenParticle).status() == 1 &&
629 (*currentGenParticle).et() > 2.0))
637 allSortedGenParticles.push_back(tmpcand);
643 if (allSortedGenParticles.size() <
gencut_)
654 bool inECALgap = fabs(allSortedGenParticles[
i].
eta()) > 1.4442 && fabs(allSortedGenParticles[
i].
eta()) < 1.556;
655 if ((fabs(allSortedGenParticles[
i].
eta()) >
genEtaAcc_) || inECALgap) {
697 if (!referenceParticles.
isValid()) {
703 std::vector<const reco::Candidate *> allSortedReferenceParticles;
706 currentReferenceParticle != referenceParticles->end();
707 currentReferenceParticle++) {
708 if (currentReferenceParticle->et() <= 2.0)
716 if (currentReferenceParticle->et() <
plotEtMin)
720 allSortedReferenceParticles.push_back(&(*currentReferenceParticle));
727 return allSortedReferenceParticles.size() >=
gencut_;
735 unsigned int vPos = 0;
736 for (std::vector<edm::ParameterSet>::iterator psetIt =
paramSets.begin(); psetIt !=
paramSets.end();
770 if (cutCounter->size() < (
unsigned int)
gencut_) {
783 <<
") does not corresond to a valid TriggerEventWithRefs product. "
784 "Please check especially the process name (e.g. when running "
785 "over reprocessed datasets)";
790 if (
event.isRealData()) {
820 std::vector<reco::Particle> sortedGen;
823 reco::Particle tmpcand(genpart->charge(), genpart->p4(), genpart->vertex(), genpart->pdgId(), genpart->status());
825 sortedGen.push_back(tmpcand);
833 if (sortedGen.size() <
gencut_) {
836 sortedGen.erase(sortedGen.begin() +
gencut_, sortedGen.end());
839 etgens.at(vPos)->Fill(sortedGen[
i].
et());
855 bool accepted =
true;
866 edm::LogError(
"EmDQM") <<
"There are less generated particles than the module '"
870 std::vector<reco::Particle> sortedGenForFilter(sortedGen);
871 sortedGenForFilter.erase(sortedGenForFilter.begin() +
nCandCuts.at(
n), sortedGenForFilter.end());
896 throw(
cms::Exception(
"Release Validation Error") <<
"HLT output type not implemented: theHLTOutputTypes[n]");
915 std::vector<reco::Particle> &sortedGen,
917 std::vector<edm::Ref<T>> recoecalcands;
919 dqm->hltCollectionLabelsMissed.insert(
dqm->theHLTCollectionLabels[
n].encode());
924 dqm->hltCollectionLabelsFound.insert(
dqm->theHLTCollectionLabels[
n].encode());
930 triggerObj->
filterIndex(
dqm->theHLTCollectionLabels[
n]),
dqm->theHLTOutputTypes[
n], recoecalcands);
934 std::vector<edm::Ref<T>> isocands;
936 if (!isocands.empty()) {
937 for (
unsigned int i = 0;
i < isocands.size();
i++)
938 recoecalcands.push_back(isocands[
i]);
942 if (recoecalcands.empty()) {
948 if (recoecalcands.size() >=
dqm->nCandCuts.at(
n) && !
dqm->mcMatchedOnly_)
949 dqm->totals.at(vPos)->Fill(
n + 0.5);
955 for (
unsigned int j = 0;
j < recoecalcands.size();
j++) {
956 if (!(recoecalcands.at(
j).isAvailable())) {
957 if (
dqm->verbosity_ >=
dqm->OUTPUT_ERRORS)
958 edm::LogError(
"EmDQMInvalidRefs") <<
"Event content inconsistent: TriggerEventWithRefs contains "
959 "invalid Refs. Invalid refs for: "
960 <<
dqm->theHLTCollectionLabels[
n].label()
961 <<
". The collection that this module uses may has been dropped in "
967 if (!
dqm->mcMatchedOnly_) {
973 for (
unsigned int i = 0;
i <
dqm->nCandCuts.at(
n);
i++) {
976 float closestDeltaR = 0.5;
977 int closestEcalCandIndex = -1;
978 for (
unsigned int j = 0;
j < recoecalcands.size();
j++) {
979 float deltaR =
DeltaR(recoecalcands[
j]->momentum(), currentGenParticleMomentum);
981 if (
deltaR < closestDeltaR) {
983 closestEcalCandIndex =
j;
989 if (closestEcalCandIndex >= 0) {
990 dqm->histEtOfHltObjMatchToGens.at(vPos).at(
n)->Fill(recoecalcands[closestEcalCandIndex]->
et());
991 dqm->histEtaOfHltObjMatchToGens.at(vPos).at(
n)->Fill(recoecalcands[closestEcalCandIndex]->
eta());
992 if (!
dqm->noPhiPlots_)
993 dqm->histPhiOfHltObjMatchToGens.at(vPos).at(
n)->Fill(recoecalcands[closestEcalCandIndex]->
phi());
994 dqm->histEtaPhiOfHltObjMatchToGens.at(vPos).at(
n)->Fill(recoecalcands[closestEcalCandIndex]->
eta(),
995 recoecalcands[closestEcalCandIndex]->
phi());
1005 for (
unsigned int i = 0;
i < recoecalcands.size();
i++) {
1025 dqm->ethists.at(vPos).at(
n)->Fill(recoecalcands[
i]->
et());
1026 dqm->etahists.at(vPos).at(
n)->Fill(recoecalcands[
i]->
eta());
1027 if (!
dqm->noPhiPlots_)
1028 dqm->phihists.at(vPos).at(
n)->Fill(recoecalcands[
i]->
phi());
1029 dqm->etaphihists.at(vPos).at(
n)->Fill(recoecalcands[
i]->
eta(), recoecalcands[
i]->
phi());
1036 unsigned int matchedMcParts = 0;
1037 float mindist = 0.3;
1040 for (
unsigned int i = 0;
i <
dqm->nCandCuts.at(
n); ++
i) {
1042 bool matchThis =
false;
1045 double closestDr = 1000.;
1046 for (
unsigned int trigOb = 0; trigOb < recoecalcands.size(); ++trigOb) {
1047 double dr =
DeltaR(recoecalcands[trigOb]->momentum(), candDir);
1048 if (
dr < closestDr) {
1052 if (closestDr > mindist) {
1064 dqm->ethistmatchs.at(vPos).at(
n)->Fill(sortedGen[
i].
et());
1065 if (sortedGen[
i].
et() >
dqm->minEtForEtaEffPlot_) {
1066 dqm->etahistmatchs.at(vPos).at(
n)->Fill(sortedGen[
i].
eta());
1067 if (!
dqm->noPhiPlots_)
1068 dqm->phihistmatchs.at(vPos).at(
n)->Fill(sortedGen[
i].
phi());
1069 dqm->etaphihistmatchs.at(vPos).at(
n)->Fill(sortedGen[
i].
eta(), sortedGen[
i].
phi());
1074 if (matchedMcParts >=
dqm->nCandCuts.at(
n) && accepted ==
true)
1075 dqm->totalmatchs.at(vPos)->Fill(
n + 0.5);
1080 unsigned int vPos = 0;
1081 for (std::vector<edm::ParameterSet>::iterator psetIt =
paramSets.begin(); psetIt !=
paramSets.end();
1089 std::vector<std::string> labelsNeverFound;
1095 labelsNeverFound.push_back(
atag.encode());
1099 if (labelsNeverFound.empty())
1102 std::sort(labelsNeverFound.begin(), labelsNeverFound.end());
1108 edm::LogWarning(
"EmDQM") <<
"There were some HLTCollectionLabels which were never found:";
1110 for (
auto const &
tag : labelsNeverFound) {
1119 if (sub.length() == 0)
1131 std::vector<std::vector<std::string>>
Paths(5);
1137 if (
int(
path.find(
"HLT_")) == 0) {
1147 int totEleCount = 2 * tripleEleCount + doubleEleCount + eleCount + scCount + 2 * doubleSCCount;
1148 int totPhotonCount = doublePhotonCount + photonCount;
1150 if (totEleCount + totPhotonCount < 1)
1152 switch (totEleCount) {
1167 switch (totPhotonCount) {
1187 std::vector<std::string>
filters;
1198 if (moduleEDMType ==
"EDFilter" ||
1199 moduleType.find(
"Filter") != std::string::npos) {
1214 boost::regex reg(
"^HLT_.*?(Ele|hoton|EG|SC)([[:digit:]]+).*");
1217 if (boost::regex_match(
path, what, reg, boost::match_extra)) {
1218 minEt = boost::lexical_cast<double>(what[2]);
1233 retPSet.
addParameter<std::vector<double>>(
"PlotBounds", std::vector<double>(2, 0.0));
1237 retPSet.
addParameter<std::vector<edm::InputTag>>(
"IsoCollections",
1238 std::vector<edm::InputTag>(1,
std::string(
"none")));
1249 int candCount = 2 * tEgCount + dEgCount + egCount;
1253 if (orCount > 0 && candCount > 0) {
1254 if (egCount % (orCount + 1) == 0 && dEgCount % (orCount + 1) == 0 && tEgCount % (orCount + 1) == 0)
1255 candCount /= (orCount + 1);
1256 else if (egCount - dEgCount - tEgCount > 0)
1258 else if (dEgCount > 0)
1260 else if (tEgCount > 0)
1266 switch (candCount) {
1297 retPSet.
addParameter<std::vector<double>>(
"PlotBounds", std::vector<double>(2, 0.0));
1301 retPSet.
addParameter<std::vector<edm::InputTag>>(
"IsoCollections",
1302 std::vector<edm::InputTag>(1,
std::string(
"none")));
1314 retPSet.
addParameter<std::vector<double>>(
"PlotBounds", std::vector<double>(2, 0.0));
1318 retPSet.
addParameter<std::vector<edm::InputTag>>(
"IsoCollections",
1319 std::vector<edm::InputTag>(1,
std::string(
"none")));
1331 retPSet.
addParameter<std::vector<double>>(
"PlotBounds", std::vector<double>(2, 0.0));
1335 retPSet.
addParameter<std::vector<edm::InputTag>>(
"IsoCollections",
1336 std::vector<edm::InputTag>(1,
std::string(
"none")));
1348 retPSet.
addParameter<std::vector<double>>(
"PlotBounds", std::vector<double>(2, 0.0));
1352 retPSet.
addParameter<std::vector<edm::InputTag>>(
"IsoCollections",
1353 std::vector<edm::InputTag>(1,
std::string(
"none")));
1365 retPSet.
addParameter<std::vector<double>>(
"PlotBounds", std::vector<double>(2, 0.0));
1369 retPSet.
addParameter<std::vector<edm::InputTag>>(
"IsoCollections",
1370 std::vector<edm::InputTag>(1,
std::string(
"none")));
1428 std::vector<edm::InputTag> isoCollections;
1429 isoCollections.push_back(
varTag);
1437 if (inputType ==
"EgammaHLTR9Producer" ||
1438 inputType ==
"EgammaHLTR9IDProducer" ||
1439 inputType ==
"EgammaHLTClusterShapeProducer" ||
1440 inputType ==
"EgammaHLTEcalRecIsolationProducer" ||
1441 inputType ==
"EgammaHLTHcalIsolationProducersRegional" ||
1442 inputType ==
"EgammaHLTGsfTrackVarProducer" ||
1443 inputType ==
"EgammaHLTBcHcalIsolationProducersRegional" ||
1445 inputType ==
"EgammaHLTEcalPFClusterIsolationProducer" ||
1447 inputType ==
"EgammaHLTHcalPFClusterIsolationProducer" ||
1449 inputType ==
"EgammaHLTElectronTrackIsolationProducers"
1451 retPSet.
addParameter<std::vector<double>>(
"PlotBounds", std::vector<double>(2, 0.0));
1455 retPSet.
addParameter<std::vector<edm::InputTag>>(
"IsoCollections", isoCollections);
1463 <<
"' should do: uses a collection produced by a module of C++ type '" << inputType <<
"'.";
1517 std::vector<edm::InputTag> isoCollections;
1518 isoCollections.push_back(
varTag);
1526 if (inputType ==
"EgammaHLTR9Producer" ||
1527 inputType ==
"EgammaHLTR9IDProducer" ||
1528 inputType ==
"EgammaHLTClusterShapeProducer" ||
1529 inputType ==
"EgammaHLTEcalRecIsolationProducer" ||
1530 inputType ==
"EgammaHLTHcalIsolationProducersRegional" ||
1531 inputType ==
"EgammaHLTBcHcalIsolationProducersRegional" ||
1533 inputType ==
"EgammaHLTEcalPFClusterIsolationProducer" ||
1535 inputType ==
"EgammaHLTHcalPFClusterIsolationProducer" ||
1537 inputType ==
"EgammaHLTPhotonTrackIsolationProducersRegional"
1540 retPSet.
addParameter<std::vector<double>>(
"PlotBounds", std::vector<double>(2, 0.0));
1544 retPSet.
addParameter<std::vector<edm::InputTag>>(
"IsoCollections", isoCollections);
1552 <<
"' should do: uses a collection produced by a module of C++ type '" << inputType <<
"'.";
1601 std::vector<edm::InputTag> isoCollections;
1602 isoCollections.push_back(
varTag);
1612 if (inputType ==
"EgammaHLTElectronDetaDphiProducer" ||
1613 inputType ==
"EgammaHLTElectronTrackIsolationProducers"
1615 retPSet.
addParameter<std::vector<double>>(
"PlotBounds", std::vector<double>(2, 0.0));
1619 retPSet.
addParameter<std::vector<edm::InputTag>>(
"IsoCollections", isoCollections);
1627 <<
"' should do: uses a collection produced by a module of C++ type '" << inputType <<
"'.";
1634 dirname_ =
"HLT/HLTEgammaValidation/" + psetIt->getParameter<
std::string>(
"@module_label");
1636 pathIndex = psetIt->getUntrackedParameter<
unsigned int>(
"pathIndex", 0);
1638 reqNum = psetIt->getParameter<
unsigned int>(
"reqNum");
1639 pdgGen = psetIt->getParameter<
int>(
"pdgGen");
1641 plotEtMin = psetIt->getUntrackedParameter<
double>(
"genEtMin", 0.);
1642 plotPtMin = psetIt->getUntrackedParameter<
double>(
"PtMin", 0.);
1643 plotPtMax = psetIt->getUntrackedParameter<
double>(
"PtMax", 1000.);
1647 gencut_ = psetIt->getParameter<
int>(
"cutnum");
1653 std::vector<edm::ParameterSet>
filters = psetIt->getParameter<std::vector<edm::ParameterSet>>(
"filters");
1665 for (std::vector<edm::ParameterSet>::iterator filterconf =
filters.begin(); filterconf !=
filters.end();
1668 theHLTOutputTypes.push_back(filterconf->getParameter<
int>(
"theHLTOutputTypes"));
1674 std::vector<double> bounds = filterconf->getParameter<std::vector<double>>(
"PlotBounds");
1676 assert(bounds.size() == 2);
1677 plotBounds.push_back(std::pair<double, double>(bounds[0], bounds[1]));
1678 isoNames.push_back(filterconf->getParameter<std::vector<edm::InputTag>>(
"IsoCollections"));
1705 if (
isoNames.back().at(0).label() ==
"none") {
1713 nCandCuts.push_back(filterconf->getParameter<
int>(
"ncandcut"));