49 #include "TDirectory.h"
55 #include <unordered_set>
69 , m_energyScale(1.
e-3)
74 , m_calibArea(
"CalibArea-08")
77 , m_analysisHistPattern(
"")
82 , m_refNPVHist(nullptr)
83 , m_refMuHist(nullptr)
85 , m_recognizedSystematics()
86 , m_recommendedSystematics()
88 , m_currentUncSet(nullptr)
91 , m_fileValidHist(nullptr)
92 , m_caloMassWeight(nullptr)
93 , m_TAMassWeight(nullptr)
94 , m_combMassWeightCaloMassDef(CompMassDef::UNKNOWN)
95 , m_combMassWeightTAMassDef(CompMassDef::UNKNOWN)
96 , m_combMassParam(CompParametrization::UNKNOWN)
100 , m_resHelper(nullptr)
101 , m_namePrefix(
"JET_")
102 , m_accTagScaleFactor(
"temp_SF")
103 , m_accEffSF(
"temp_effSF")
104 , m_accSigeffSF(
"temp_sigeffSF")
105 , m_accEfficiency(
"temp_efficiency")
106 , m_accTagResult(
"temp_accept")
107 , m_absEtaGluonFraction(true)
108 , m_pseudoDataJERsmearingMode(false)
127 ATH_MSG_ERROR(Form(
"Failed to pre-set applySystematicVariation to no variation"));
131 :
asg::AsgTool(toCopy.m_name+
"_copy")
132 , m_isInit(toCopy.m_isInit)
133 , m_name(toCopy.m_name+
"_copy")
134 , m_energyScale(1.
e-3)
135 , m_release(toCopy.m_release)
136 , m_jetDef(toCopy.m_jetDef)
137 , m_mcType(toCopy.m_mcType)
138 , m_configFile(toCopy.m_configFile)
139 , m_calibArea(toCopy.m_calibArea)
141 , m_analysisFile(toCopy.m_analysisFile)
142 , m_analysisHistPattern(toCopy.m_analysisHistPattern)
143 , m_systFilters(toCopy.m_systFilters)
144 , m_defAnaFile(toCopy.m_defAnaFile)
145 , m_refNPV(toCopy.m_refNPV)
146 , m_refMu(toCopy.m_refMu)
150 , m_recognizedSystematics(toCopy.m_recognizedSystematics)
151 , m_recommendedSystematics(toCopy.m_recommendedSystematics)
152 , m_currentSystSet(toCopy.m_currentSystSet)
153 , m_currentUncSet(nullptr)
156 , m_fileValidHist(toCopy.m_fileValidHist)
157 , m_caloMassWeight(nullptr)
158 , m_TAMassWeight(nullptr)
159 , m_combMassWeightCaloMassDef(CompMassDef::
UNKNOWN)
160 , m_combMassWeightTAMassDef(CompMassDef::
UNKNOWN)
161 , m_combMassParam(CompParametrization::
UNKNOWN)
162 , m_userSeed(toCopy.m_userSeed)
163 , m_rand(toCopy.m_rand)
164 , m_isData(toCopy.m_isData)
166 , m_namePrefix(toCopy.m_namePrefix)
167 , m_accTagScaleFactor(toCopy.m_accTagScaleFactor)
168 , m_accEffSF(toCopy.m_accEffSF)
169 , m_accSigeffSF(toCopy.m_accSigeffSF)
170 , m_accEfficiency(toCopy.m_accEfficiency)
171 , m_accTagResult(toCopy.m_accTagResult)
172 , m_absEtaGluonFraction(toCopy.m_absEtaGluonFraction)
173 , m_pseudoDataJERsmearingMode(toCopy.m_pseudoDataJERsmearingMode)
177 for (
size_t iGroup = 0; iGroup < toCopy.
m_groups.size(); ++iGroup)
181 ATH_MSG_ERROR(Form(
"Failed to re-set applySystematicVariation in new tool copy"));
188 for (
size_t iGroup = 0; iGroup <
m_groups.size(); ++iGroup)
216 return StatusCode::FAILURE;
220 return StatusCode::SUCCESS;
229 return StatusCode::FAILURE;
233 return StatusCode::SUCCESS;
242 return StatusCode::FAILURE;
245 ATH_MSG_INFO(Form(
"Preparing to initialize the JetUncertaintiesTool named %s",
m_name.c_str()));
253 if (configFilePath ==
"")
256 return StatusCode::FAILURE;
260 if (settings.ReadFile(configFilePath.Data(),kEnvGlobal))
262 ATH_MSG_ERROR(
"Cannot read config file: " << configFilePath.Data());
263 return StatusCode::FAILURE;
267 ATH_MSG_INFO(Form(
"================================================"));
273 ATH_MSG_INFO(Form(
" Location: %s",configFilePath.Data()));
277 m_release = settings.GetValue(
"UncertaintyRelease",
"UNKNOWN");
281 TString allowedJetDefStr = settings.GetValue(
"SupportedJetDefs",
"");
282 if (allowedJetDefStr ==
"")
284 ATH_MSG_ERROR(
"Cannot find supported jet definitions in config");
285 return StatusCode::FAILURE;
287 std::vector<TString> allowedJetDefs = jet::utils::vectorize<TString>(allowedJetDefStr,
" ,");
288 bool foundJetDef =
false;
289 for (
size_t iDef = 0; iDef < allowedJetDefs.size(); ++iDef)
290 if (!allowedJetDefs.at(iDef).CompareTo(
m_jetDef.c_str(),TString::kIgnoreCase))
299 return StatusCode::FAILURE;
304 TString allowedMCtypeStr = settings.GetValue(
"SupportedMCTypes",
"");
305 if (allowedMCtypeStr ==
"")
308 return StatusCode::FAILURE;
310 std::vector<TString> allowedMCtypes = jet::utils::vectorize<TString>(allowedMCtypeStr,
" ,");
311 bool foundMCtype =
false;
312 for (
size_t iType = 0; iType < allowedMCtypes.size(); ++iType)
313 if (!allowedMCtypes.at(iType).CompareTo(
m_mcType.c_str(),TString::kIgnoreCase))
316 m_mcType = allowedMCtypes.at(iType);
322 return StatusCode::FAILURE;
328 TString histFileName = settings.GetValue(
"UncertaintyRootFile",
"");
329 if (histFileName ==
"")
332 return StatusCode::FAILURE;
334 ATH_MSG_INFO(Form(
" UncertaintyFile: \"%s\"",histFileName.Data()));
338 if (histFilePath ==
"")
340 ATH_MSG_ERROR(
"Cannot find the path of the uncertainty histogram file");
341 return StatusCode::FAILURE;
343 ATH_MSG_INFO(Form(
" Location: %s",histFilePath.Data()));
346 TFile* histFile =
new TFile(histFilePath,
"READ");
347 if (!histFile || histFile->IsZombie())
349 ATH_MSG_ERROR(
"Cannot open uncertainty histogram file: " << histFileName.Data());
350 return StatusCode::FAILURE;
356 m_defAnaFile = settings.GetValue(
"AnalysisRootFile",
"");
364 if (analysisFilePath ==
"")
366 ATH_MSG_ERROR(
"Cannot find the path of the analysis histogram file");
367 return StatusCode::FAILURE;
369 ATH_MSG_INFO(Form(
" Location: %s",analysisFilePath.Data()));
376 if (analysisFilePath ==
"")
378 ATH_MSG_ERROR(
"Cannot find the path of the default analysis histogram file");
379 return StatusCode::FAILURE;
381 ATH_MSG_INFO(Form(
" Location: %s",analysisFilePath.Data()));
390 TString validHistForFile = settings.GetValue(
"FileValidHistogram",
"");
391 if (validHistForFile !=
"")
394 TString validHistForFileParam = settings.GetValue(
"FileValidHistParam",
"");
395 if (validHistForFileParam ==
"")
397 ATH_MSG_ERROR(
"Specified a FileValidHistogram without an accompanying FileValidHistParam: " << validHistForFile.Data());
398 return StatusCode::FAILURE;
410 return StatusCode::FAILURE;
416 const TString caloMassWeight = TString(settings.GetValue(
"CombMassWeightCaloHist",
""));
417 const TString TAMassWeight = TString(settings.GetValue(
"CombMassWeightTAHist",
""));
418 if (caloMassWeight !=
"" && TAMassWeight !=
"")
424 return StatusCode::FAILURE;
426 return StatusCode::FAILURE;
429 const TString combMassParam = TString(settings.GetValue(
"CombMassWeightParam",
"PtMass"));
433 ATH_MSG_ERROR(
"Unexpected combined mass parametrization: " << combMassParam.Data());
434 return StatusCode::FAILURE;
437 ATH_MSG_INFO(
" Found and loaded combined mass weight factors");
443 const TString caloWeightMassDef = settings.GetValue(
"CombMassWeightCaloMassDef",
"Calo");
444 const TString TAWeightMassDef = settings.GetValue(
"CombMassWeightTAMassDef",
"TA");
445 if (caloWeightMassDef !=
"")
450 if (TAWeightMassDef !=
"")
456 else if (caloMassWeight !=
"" && TAMassWeight ==
"")
458 ATH_MSG_ERROR(
" Found combined mass weight factors for the calo term, but not the TA term");
459 return StatusCode::FAILURE;
461 else if (caloMassWeight ==
"" && TAMassWeight !=
"")
463 ATH_MSG_ERROR(
" Found combined mass weight factors for the TA term, but not the calo term");
464 return StatusCode::FAILURE;
469 m_name_EffSF = TString(settings.GetValue(
"TagSFEffName",
"temp_effSF"));
470 m_name_Efficiency = TString(settings.GetValue(
"TagEfficiencyName",
"temp_efficiency"));
471 m_name_TagResult = TString(settings.GetValue(
"TagResultName",
"temp_accept")).ReplaceAll(
"accept",
"Tagged");
484 TString refNPV = settings.GetValue(
"Pileup.NPVRef",
"");
485 TString refMu = settings.GetValue(
"Pileup.MuRef",
"");
486 if ( (refNPV !=
"" && refMu ==
"") || (refNPV ==
"" && refMu !=
"") )
489 return StatusCode::FAILURE;
491 else if ( refNPV !=
"" && refMu !=
"")
495 if (utils::isTypeObjFromString<float>(refNPV))
496 m_refNPV = utils::getTypeObjFromString<float>(refNPV);
501 return StatusCode::FAILURE;
504 if (utils::isTypeObjFromString<float>(refMu))
505 m_refMu = utils::getTypeObjFromString<float>(refMu);
510 return StatusCode::FAILURE;
518 std::string varString =
"";
519 for (
size_t iFilter = 0; iFilter <
m_systFilters.size(); ++iFilter)
523 ATH_MSG_ERROR(
"Unable to parse VariablesToShift due to unknown variable, please check for typos: " <<
m_systFilters.at(iFilter));
524 return StatusCode::FAILURE;
526 if (!varString.empty())
530 ATH_MSG_INFO(Form(
" VariablesToShift: %s",varString.c_str()));
537 return StatusCode::FAILURE;
547 ATH_MSG_INFO(Form(
"%6s %-40s : %s",
"",
"JES uncert. comp.",
"Description"));
548 ATH_MSG_INFO(Form(
"%6s %-40s -%s",
"",
"-----------------",
"-----------"));
549 for (
size_t iGroup = 0; iGroup < 999; ++iGroup)
552 const TString
prefix = Form(
"JESGroup.%zu.",iGroup);
556 if (
helper.initialize(settings).isFailure())
557 return StatusCode::FAILURE;
560 if (!
helper.isGroup())
continue;
569 return StatusCode::FAILURE;
571 for (
size_t iComp = 0; iComp < 999; ++iComp)
574 const TString
prefix = Form(
"JESComponent.%zu.",iComp);
578 if (
helper.initialize(settings).isFailure())
579 return StatusCode::FAILURE;
596 return StatusCode::FAILURE;
601 size_t numCompsBeforeMerger = 0;
602 for (
size_t iGroup = 0; iGroup <
m_groups.size(); ++iGroup) {
603 numCompsBeforeMerger +=
m_groups.at(iGroup)->getNumComponents();
615 for (
size_t iGroup = 0; iGroup <
m_groups.size(); ++iGroup)
617 const int groupNum =
m_groups.at(iGroup)->getGroupNum();
618 const int subgroupNum =
m_groups.at(iGroup)->getSubgroupNum();
622 if (!groupNum || !subgroupNum)
continue;
625 if (groupNum == subgroupNum)
627 ATH_MSG_ERROR(Form(
"Specified group %d (%s) as the parent of itself, blocking for safety",groupNum,
m_groups.at(iGroup)->getName().Data()));
628 return StatusCode::FAILURE;
632 for (
size_t iParentGroup = 0; iParentGroup <
m_groups.size(); ++iParentGroup)
634 if (iParentGroup == iGroup)
continue;
636 const int parentGroupNum =
m_groups.at(iParentGroup)->getGroupNum();
637 if (parentGroupNum == subgroupNum)
640 if (
m_groups.at(iParentGroup)->addSubgroup(
m_groups.at(iGroup)).isFailure())
642 ATH_MSG_ERROR(Form(
"Failed to add group %d (%s) as a subgroup of group %d (%s)",groupNum,
m_groups.at(iGroup)->getName().Data(),parentGroupNum,
m_groups.at(iParentGroup)->getName().Data()));
643 return StatusCode::FAILURE;
651 std::vector<UncertaintyGroup*> localGroupVec;
652 for (
size_t iGroup = 0; iGroup <
m_groups.size(); ++iGroup)
653 localGroupVec.push_back(
m_groups.at(iGroup));
656 for (
size_t iGroup = 0; iGroup < localGroupVec.size(); ++iGroup)
659 if (!localGroupVec.at(iGroup)->getSubgroupNum())
660 m_groups.push_back(localGroupVec.at(iGroup));
665 size_t numCompsAfterMerger = 0;
666 for (
size_t iGroup = 0; iGroup <
m_groups.size(); ++iGroup) {
667 numCompsAfterMerger +=
m_groups.at(iGroup)->getNumComponents();
678 if (numCompsBeforeMerger != numCompsAfterMerger)
680 ATH_MSG_ERROR(Form(
"Something went wrong merging groups: %zu before merger and %zu after merger",numCompsBeforeMerger,numCompsAfterMerger));
681 for (
size_t iGroup = 0; iGroup <
m_groups.size(); ++iGroup)
685 return StatusCode::FAILURE;
692 for (
size_t iGroup = 0; iGroup <
m_groups.size(); ++iGroup)
694 if (
m_groups.at(iGroup)->getNumComponents() == 0)
697 return StatusCode::FAILURE;
699 if (
m_groups.at(iGroup)->initialize(histFile).isFailure())
700 return StatusCode::FAILURE;
713 return StatusCode::FAILURE;
715 if (systVar.
basename().find(
"JER") != std::string::npos) {
718 return StatusCode::FAILURE;
726 for (
size_t iGroup = 0; iGroup <
m_groups.size(); ++iGroup)
728 std::set<CompScaleVar::TypeEnum> scaleVars =
m_groups.at(iGroup)->getScaleVars();
736 return StatusCode::FAILURE;
744 for (
size_t iFilter = 0; iFilter <
m_systFilters.size(); ++iFilter)
746 bool filterIsSane =
false;
747 for (
size_t iGroup = 0; iGroup <
m_groups.size(); ++iGroup)
757 ATH_MSG_ERROR(
" One of the specified VariablesToShift is not associated with any components, please check for typos: " <<
m_systFilters.at(iFilter));
758 return StatusCode::FAILURE;
764 size_t numCompInGroups = 0;
765 for (
size_t iGroup = 0; iGroup <
m_groups.size(); ++iGroup)
766 numCompInGroups +=
m_groups.at(iGroup)->getNumComponents();
776 ATH_MSG_INFO(Form(
"================================================"));
799 if (
group.groupNum == 0)
802 return StatusCode::FAILURE;
804 for (
size_t iGroup = 0; iGroup <
m_groups.size(); ++iGroup)
807 ATH_MSG_ERROR(
"Group number matches previous group (" <<
m_groups.at(iGroup)->getName().Data() <<
"): " <<
group.name.Data());
808 return StatusCode::FAILURE;
816 return StatusCode::FAILURE;
820 if (!
m_groups.back()->getSubgroupNum())
822 size_t numGroups = 0;
823 for (
size_t iGroup = 0; iGroup <
m_groups.size(); ++iGroup)
824 if (!
m_groups.at(iGroup)->getSubgroupNum())
828 ,
m_groups.back()->getDesc().Data() ));
830 return StatusCode::SUCCESS;
835 const bool isSimpleGroup =
helper.isCompGroup();
839 ATH_MSG_DEBUG(Form(
"Starting to process %s named %s",isSimpleGroup?
"simple component group":
"standard component",component.
name.Data()));
848 ATH_MSG_ERROR(
"Failed to build simple group for component: " << component.
name.Data());
849 return StatusCode::FAILURE;
851 const size_t groupIndex =
m_groups.size();
853 ATH_MSG_DEBUG(Form(
"Created new group \"%s\" for a simple component at index %zu",simpleGroup->
getName().Data(),groupIndex));
855 if (!
m_groups.back()->getSubgroupNum())
857 size_t numGroups = 0;
858 for (
size_t iGroup = 0; iGroup <
m_groups.size(); ++iGroup)
859 if (!
m_groups.at(iGroup)->getSubgroupNum())
863 ,
m_groups.back()->getDesc().Data() ));
873 return StatusCode::FAILURE;
875 if (
m_groups.at(groupIndex)->addComponent(compObject).isFailure())
876 return StatusCode::FAILURE;
877 ATH_MSG_DEBUG(Form(
"Added single component \"%s\" to simple group \"%s\" (index %zu)",compObject->
getName().Data(),
m_groups.at(groupIndex)->getName().Data(),groupIndex));
881 for (
size_t iSubComp = 0; iSubComp < component.
subComps.size(); ++iSubComp)
892 return StatusCode::FAILURE;
894 if (
m_groups.at(groupIndex)->addComponent(subCompObject).isFailure())
895 return StatusCode::FAILURE;
896 ATH_MSG_DEBUG(Form(
"Added component \"%s\" (%zu of %zu) to simple group \"%s\" (index %zu)",subCompObject->
getName().Data(),iSubComp+1,component.
subComps.size(),
m_groups.at(groupIndex)->getName().Data(),groupIndex));
902 size_t groupIndex = 0;
905 ATH_MSG_ERROR(
"No groups exist to add the component to: " << component.
name.Data());
906 return StatusCode::FAILURE;
908 for (
size_t iGroup = 0; iGroup <
m_groups.size(); ++iGroup)
917 return StatusCode::FAILURE;
924 return StatusCode::FAILURE;
926 if (
m_groups.at(groupIndex)->addComponent(compObject).isFailure())
927 return StatusCode::FAILURE;
928 ATH_MSG_DEBUG(Form(
"Added component \"%s\" to group \"%s\" (index %zu)",compObject->
getName().Data(),
m_groups.at(groupIndex)->getName().Data(),groupIndex));
931 return StatusCode::SUCCESS;
937 if (component.
name ==
"")
939 ATH_MSG_ERROR(
"Attempting to create a component with no name");
944 ATH_MSG_ERROR(
"Attempting to create a component with no parametrization: " << component.
name.Data());
949 ATH_MSG_ERROR(
"Attempting to create a component with no variable to scale: " << component.
name.Data());
962 ATH_MSG_ERROR(
"Attempted to create pileup component without NPV reference value: " << component.
name.Data());
967 ATH_MSG_ERROR(
"Attempted to create pileup component without mu reference value: " << component.
name.Data());
993 ATH_MSG_ERROR(
"Attempting to create a flavour uncertainty component without having specified an AnalysisRootFile");
1016 else if (component.
name.Contains(
"PunchThrough",TString::kIgnoreCase))
1027 else if (component.
name.Contains(
"Closeby",TString::kIgnoreCase))
1043 ATH_MSG_ERROR(
"Asking to create a combined mass term without specifying weights: " << component.
name.Data());
1071 ATH_MSG_ERROR(
"Failed to build calo-group for combined mass component: " << component.
name.Data());
1076 std::vector<TString> caloComps = jet::utils::vectorize<TString>(component.
caloMassTerm,
", ");
1077 std::vector<TString> caloMassDefs = jet::utils::vectorize<TString>(component.
caloMassDef,
", ");
1078 if (caloComps.size() != caloMassDefs.size())
1080 ATH_MSG_ERROR(
"Unbalanced number of calo mass terms and calo mass definitions, " << caloComps.size() <<
" vs " << caloMassDefs.size() <<
" for combined mass component: " << component.
name.Data());
1085 for (
size_t iComp = 0; iComp < caloComps.size(); ++iComp)
1091 caloCompH.
name = caloComps.at(iComp);
1096 ATH_MSG_ERROR(
"Failed to parse calo mass definition " << iComp <<
" (" << caloMassDefs.at(iComp).Data() <<
") for combined mass component: " << component.
name.Data());
1126 ATH_MSG_ERROR(
"Failed to build TA-group for combined mass component: " << component.
name.Data());
1131 std::vector<TString> TAComps = jet::utils::vectorize<TString>(component.
TAMassTerm,
", ");
1132 std::vector<TString> TAMassDefs = jet::utils::vectorize<TString>(component.
TAMassDef,
", ");
1133 if (TAComps.size() != TAMassDefs.size())
1135 ATH_MSG_ERROR(
"Unbalanced number of TA mass terms and TA mass definitions, " << TAComps.size() <<
" vs " << TAMassDefs.size() <<
" for combined mass component: " << component.
name.Data());
1140 for (
size_t iComp = 0; iComp < TAComps.size(); ++iComp)
1146 TACompH.
name = TAComps.at(iComp);
1151 ATH_MSG_ERROR(
"Failed to parse TA mass definition " << iComp <<
" (" << TAMassDefs.at(iComp).Data() <<
") for combined mass component: " << component.
name.Data());
1167 if (cmuc->
setTATerm(TAGroup).isFailure())
1175 else if (component.
name.Contains(
"Large",TString::kIgnoreCase) && component.
name.Contains(
"Topology",TString::kIgnoreCase))
1185 ATH_MSG_ERROR(Form(
"No LargeRJetTruthLabels specified for Large-R jet topology component %s",component.
name.Data()));
1235 ATH_MSG_ERROR(
"Failed to find the type of component to build: " << component.
name.Data());
1251 return baseNames.find(systematic.
basename()) != baseNames.end();
1278 const std::set<CompScaleVar::TypeEnum> scaleVars = systematic.
getScaleVars();
1280 for (
size_t iFilter = 0; iFilter <
m_systFilters.size(); ++iFilter)
1284 passesFilter =
true;
1298 registry.registerSystematic(systematic);
1303 if (
registry.addSystematicToRecommended(systematic) != StatusCode::SUCCESS)
1305 ATH_MSG_ERROR(
"Failed to add systematic to list of recommended systematics: " << systematic.
name());
1306 return StatusCode::FAILURE;
1309 return StatusCode::SUCCESS;
1321 std::string remappedName = systConfig.
name();
1322 size_t found = remappedName.find(
"_PseudoData");
1323 if (
found != std::string::npos) {
1324 remappedName.erase(
found, std::string(
"_PseudoData").
length());
1330 return StatusCode::FAILURE;
1335 return StatusCode::FAILURE;
1341 return StatusCode::FAILURE;
1346 return StatusCode::SUCCESS;
1354 filteredSet = iter->second;
1359 return StatusCode::FAILURE;
1363 return StatusCode::SUCCESS;
1374 uncSet = iter->second;
1382 ATH_MSG_ERROR(
"Failed to create UncertaintySet for filtered CP::SystematicSet: " << filteredSet.
name());
1384 return StatusCode::FAILURE;
1386 m_systSetMap.insert(std::make_pair(filteredSet,uncSet));
1389 return StatusCode::SUCCESS;
1403 if (
release.BeginsWith(
"2011_"))
1405 else if (
release.BeginsWith(
"2012_"))
1407 else if (
release.BeginsWith(
"2015_") ||
release.BeginsWith(
"2016"))
1417 ATH_MSG_FATAL(
"Tool must be initialized before calling getRefMu");
1422 ATH_MSG_FATAL(
"Tool contains a histogram for refMu, cannot return float");
1432 ATH_MSG_FATAL(
"Tool must be initialized before calling getRefNPV");
1437 ATH_MSG_FATAL(
"Tool contains a histogram for refNPV, cannot return float");
1447 ATH_MSG_FATAL(
"Tool must be initialized before calling getRefMu");
1457 ATH_MSG_FATAL(
"Tool must be initialized before calling getRefNPV");
1468 ATH_MSG_FATAL(
"Tool must be initialized before calling getNumComponents");
1484 ATH_MSG_FATAL(
"Tool must be initialized before calling getComponentIndex");
1488 for (
size_t iComp = 0; iComp <
m_groups.size(); ++iComp)
1489 if (
m_groups.at(iComp)->getName().CompareTo(
name,TString::kIgnoreCase) == 0)
1500 ATH_MSG_FATAL(
"Tool must be initialized before calling getComponentName");
1515 ATH_MSG_FATAL(
"Tool must be initialized before calling getComponentDesc");
1530 ATH_MSG_FATAL(
"Tool must be initialized before calling getComponentCategory");
1545 ATH_MSG_FATAL(
"Tool must be initialized before calling getComponentIsReducible");
1560 ATH_MSG_FATAL(
"Tool must be initialized before asking for information pertaining to a given component index");
1561 return StatusCode::FAILURE;
1567 return StatusCode::FAILURE;
1571 return StatusCode::SUCCESS;
1576 return varSet.size() == 1 && *(varSet.begin()) ==
var;
1672 if (!eInfo)
return false;
1679 ATH_MSG_FATAL(
"Tool must be initialized before calling getValidity");
1701 ATH_MSG_ERROR(
"Asked for the validity of a set which scales multiple variables without specifying the variable of interest:" <<
m_groups.at(
index)->getName().Data());
1729 ATH_MSG_FATAL(
"Tool must be initialized before calling getUncertainty");
1755 ATH_MSG_ERROR(
"Asked for the uncertainty of a set which scales multiple variables without specifying the variable of interest:" <<
m_groups.at(
index)->getName().Data());
1776 if (!eInfo)
return false;
1783 ATH_MSG_FATAL(
"Tool must be initialized before calling getValidUncertainty");
1806 ATH_MSG_ERROR(
"Asked for the valid uncertainty of a set which scales multiple variables without specifying the variable of interest:" <<
m_groups.at(
index)->getName().Data());
1829 ATH_MSG_FATAL(
"Tool must be initialized before calling getNominalResolution");
1834 ATH_MSG_ERROR(
"The ResolutionHelper class was not created");
1847 ATH_MSG_ERROR(
"Parametrization involves mass but mass def is unknown");
1916 ATH_MSG_ERROR(
"Failed to read histogram due to unknown parametrization type in " <<
getName());
1933 if (caloRes == 0 || TARes == 0)
return 0;
1935 const double caloFactor = (caloRes == 0) ? 0 : 1./(caloRes*caloRes);
1936 const double TAFactor = ( TARes == 0) ? 0 : 1./(TARes*TARes);
1938 if (caloFactor + TAFactor == 0)
return 0;
1940 return caloFactor/(caloFactor+TAFactor);
1954 if (caloRes == 0 || TARes == 0)
return 0;
1956 const double caloFactor = 1./(caloRes*caloRes);
1957 const double TAFactor = 1./(TARes*TARes);
1959 if (caloFactor + TAFactor == 0)
return 0;
1961 return TAFactor/(caloFactor+TAFactor);
1974 ATH_MSG_FATAL(
"Tool must be initialized before calling getComponentCategories");
1982 for (
size_t iComp = 0; iComp <
m_groups.size(); ++iComp)
1987 for (std::unordered_set<std::string>::const_iterator iter =
categories.begin() ; iter !=
categories.end(); ++iter)
1997 ATH_MSG_FATAL(
"Tool must be initialized before calling getComponentsInCategory");
2010 std::vector<size_t> components;
2011 for (
size_t iComp = 0; iComp <
m_groups.size(); ++iComp)
2012 if (
m_groups.at(iComp)->getCategory() == categoryEnum)
2013 components.push_back(iComp);
2022 ATH_MSG_FATAL(
"Tool must be initialized before calling getComponentNamesInCategory");
2027 std::vector<std::string>
names;
2028 for (
size_t iComp = 0; iComp < components.size(); ++iComp)
2050 ATH_MSG_FATAL(
"Tool must be initialized before calling getCorrelationMatrix");
2054 std::cout <<
"Creating with max values " << valEta1 <<
" " << valEta2 << std::endl;
2070 ATH_MSG_FATAL(
"Tool must be initialized before calling getCorrelationMatrix");
2098 ATH_MSG_FATAL(
"Tool must be initialized before calling applyCorrection");
2110 std::vector< std::pair<CompScaleVar::TypeEnum,double> > uncSet;
2114 bool allValid =
true;
2115 for (
size_t iVar = 0; iVar < validitySet.size(); ++iVar)
2117 const bool validity = validitySet.at(iVar).second;
2133 bool hasMassRes =
false;
2134 bool hasPtRes =
false;
2135 bool hasFvRes =
false;
2142 ATH_MSG_ERROR(
"Varying both absolute and relative mass resolution components simultaneously is not supported");
2152 ATH_MSG_ERROR(
"Varying both absolute and relative pT resolution components simultaneously is not supported");
2162 ATH_MSG_ERROR(
"Varying both absolute and relative four-vector resolution components simultaneously is not supported");
2171 for (
size_t iVar = 0; iVar < uncSet.size(); ++iVar)
2175 const double shift = 1 + uncSet.at(iVar).second;
2176 const double smear = uncSet.at(iVar).second;
2180 double smearingFactor = 1;
2242 ATH_MSG_ERROR(
"Smearing the mass without specifying the topology is not supported");
2248 ATH_MSG_ERROR(
"Smearing the mass using multiple topology definitions is not supported");
2306 for (
size_t iJet = 0; iJet <
inputs.size(); ++iJet)
2325 static unsigned long long eventNum = 0;
2332 ATH_MSG_ERROR(
"Failed to retrieve default EventInfo object");
2337 if (eInfoObj && eventNum == eInfoConst->
eventNumber())
2347 eInfoObj = eInfoPair.first;
2348 eInfoAux = eInfoPair.second;
2358 ATH_MSG_ERROR(
"Failed to retrieve default NPV value from PrimaryVertices");
2366 for (itr = vertices->
begin(); itr != vertices->
end(); ++itr)
2367 if ( (*itr)->nTrackParticles() > 1)
2371 accNPV(*eInfoObj) = NPV;
2499 else if (variation < 0 && !m_resHelper->smearOnlyMC())
2505 const double sigmaNom =
std::max(sigmaMC,sigmaData);
2513 const double sigmaSmear = sqrt(
pow(sigmaNom + fabs(variation)*relativeFactor,2) -
pow(sigmaNom,2));
2517 ATH_MSG_ERROR(
"A seed of 1e5 times the jet phi is used in JetCalibTools so using it here leads to correlated smearing");
2527 if(seed == 0) seed =
m_isData ? 34545654 : 45583453;
2533 double smearingFactor = -1;
2534 while (smearingFactor < 0)
2535 smearingFactor =
m_rand.Gaus(1.,sigmaSmear);
2536 return smearingFactor;
2553 const float value = accD12(constJet);
2555 return StatusCode::SUCCESS;
2558 ATH_MSG_ERROR(
"Split12 moment (D12) is not available on the jet, please make sure to set Split12 before calling the tool");
2559 return StatusCode::FAILURE;
2569 const float value = accD23(constJet);
2571 return StatusCode::SUCCESS;
2574 ATH_MSG_ERROR(
"Split23 moment (D23) is not available on the jet, please make sure to set Split23 before calling the tool");
2575 return StatusCode::FAILURE;
2587 if (Tau21wasAvailable)
2591 ATH_MSG_ERROR(
"The Tau21 moment was previously available but is not available on this jet. This functionality is not supported.");
2592 return StatusCode::FAILURE;
2594 const float value = accTau21(constJet);
2596 return StatusCode::SUCCESS;
2598 if (TauNNwasAvailable)
2602 ATH_MSG_ERROR(
"The Tau2 and Tau1 moments were previously available but are not available on this jet. This functionality is not supported.");
2603 return StatusCode::FAILURE;
2605 const float tau2 = accTau2(constJet);
2606 const float tau1 = accTau1(constJet);
2607 accTau21(
jet) = fabs(tau1) > 1.e-6 ? shift*(tau2/tau1) : -999;
2608 return StatusCode::SUCCESS;
2623 ATH_MSG_ERROR(
"Neither Tau21 nor Tau1+Tau2 moments are available on the jet, please make sure one of these options is available before calling the tool.");
2624 return StatusCode::FAILURE;
2636 if (Tau32wasAvailable)
2640 ATH_MSG_ERROR(
"The Tau32 moment was previously available but is not available on this jet. This functionality is not supported.");
2641 return StatusCode::FAILURE;
2643 const float value = accTau32(constJet);
2645 return StatusCode::SUCCESS;
2647 if (TauNNwasAvailable)
2651 ATH_MSG_ERROR(
"The Tau3 and Tau2 moments were previously available but are not available on this jet. This functionality is not supported.");
2652 return StatusCode::FAILURE;
2654 const float tau3 = accTau3(constJet);
2655 const float tau2 = accTau2(constJet);
2656 accTau32(
jet) = fabs(tau2) > 1.e-6 ? shift*(tau3/tau2) : -999;
2657 return StatusCode::SUCCESS;
2672 ATH_MSG_ERROR(
"Neither Tau32 nor Tau2+Tau3 moments are available on the jet, please make sure one of these options is available before calling the tool");
2673 return StatusCode::FAILURE;
2684 static const bool Tau21wtawasAvailable = accTau21wta.
isAvailable(
jet);
2685 static const bool Tau21WTAwasAvailable = accTau21WTA.
isAvailable(
jet);
2690 if (Tau21wtawasAvailable)
2694 ATH_MSG_ERROR(
"The Tau21_wta moment was previously available but is not available on this jet. This functionality is not supported.");
2695 return StatusCode::FAILURE;
2697 const float value = accTau21wta(constJet);
2699 return StatusCode::SUCCESS;
2701 if (Tau21WTAwasAvailable)
2705 ATH_MSG_ERROR(
"The Tau21_WTA moment was previously available but is not available on this jet. This functionality is not supported.");
2706 return StatusCode::FAILURE;
2708 const float value = accTau21WTA(constJet);
2710 return StatusCode::SUCCESS;
2712 if (TauNNwtawasAvailable)
2716 ATH_MSG_ERROR(
"The Tau2_wta and Tau1_wta moments were previously available but are not available on this jet. This functionality is not supported.");
2717 return StatusCode::FAILURE;
2719 const float tau2 = accTau2wta(constJet);
2720 const float tau1 = accTau1wta(constJet);
2721 accTau21wta(
jet) = fabs(tau1) > 1.e-6 ? shift*(tau2/tau1) : -999;
2722 return StatusCode::SUCCESS;
2724 if (TauNNWTAwasAvailable)
2728 ATH_MSG_ERROR(
"The Tau2_WTA and Tau1_WTA moments were previously available but are not available on this jet. This functionality is not supported.");
2729 return StatusCode::FAILURE;
2731 const float tau2 = accTau2WTA(constJet);
2732 const float tau1 = accTau1WTA(constJet);
2733 accTau21WTA(
jet) = fabs(tau1) > 1.e-6 ? shift*(tau2/tau1) : -999;
2734 return StatusCode::SUCCESS;
2737 ATH_MSG_ERROR(
"Neither Tau21_wta nor Tau1_wta+Tau2_wta moments are available on the jet, please make sure one of these options is available before calling the tool");
2738 return StatusCode::FAILURE;
2748 static const bool Tau32wtawasAvailable = accTau32wta.
isAvailable(
jet);
2749 static const bool Tau32WTAwasAvailable = accTau32WTA.
isAvailable(
jet);
2754 if (Tau32wtawasAvailable)
2758 ATH_MSG_ERROR(
"The Tau32_wta moment was previously available but is not available on this jet. This functionality is not supported.");
2759 return StatusCode::FAILURE;
2761 const float value = accTau32wta(constJet);
2763 return StatusCode::SUCCESS;
2765 if (Tau32WTAwasAvailable)
2769 ATH_MSG_ERROR(
"The Tau32_WTA moment was previously available but is not available on this jet. This functionality is not supported.");
2770 return StatusCode::FAILURE;
2772 const float value = accTau32WTA(constJet);
2774 return StatusCode::SUCCESS;
2776 if (TauNNwtawasAvailable)
2780 ATH_MSG_ERROR(
"The Tau3_wta and Tau2_wta moments were previously available but are not available on this jet. This functionality is not supported.");
2781 return StatusCode::FAILURE;
2783 const float tau3 = accTau3wta(constJet);
2784 const float tau2 = accTau2wta(constJet);
2785 accTau32wta(
jet) = fabs(tau2) > 1.e-6 ? shift*(tau3/tau2) : -999;
2786 return StatusCode::SUCCESS;
2788 if (TauNNWTAwasAvailable)
2792 ATH_MSG_ERROR(
"The Tau3_WTA and Tau2_WTA moments were previously available but are not available on this jet. This functionality is not supported.");
2793 return StatusCode::FAILURE;
2795 const float tau3 = accTau3WTA(constJet);
2796 const float tau2 = accTau2WTA(constJet);
2797 accTau32WTA(
jet) = fabs(tau2) > 1.e-6 ? shift*(tau3/tau2) : -999;
2798 return StatusCode::SUCCESS;
2825 ATH_MSG_ERROR(
"Neither Tau32_wta nor Tau2_wta+Tau3_wta moments are available on the jet, please make sure one of these options is available before calling the tool");
2826 return StatusCode::FAILURE;
2843 ATH_MSG_ERROR(
"The D2 moment was previously available but is not available on this jet. This functionality is not supported.");
2844 return StatusCode::FAILURE;
2846 const float value = accD2(constJet);
2848 return StatusCode::SUCCESS;
2850 if (ECFwasAvailable)
2854 ATH_MSG_ERROR(
"The ECF1, ECF2, and ECF3 moments were previously available but are not available on this jet. This functionality is not supported.");
2855 return StatusCode::FAILURE;
2857 const float ecf1 = accECF1(constJet);
2858 const float ecf2 = accECF2(constJet);
2859 const float ecf3 = accECF3(constJet);
2860 accD2(
jet) = fabs(ecf2) > 1.e-6 ? shift * (
pow(ecf1/ecf2,3)*ecf3) : -999;
2861 return StatusCode::SUCCESS;
2879 ATH_MSG_ERROR(
"Neither D2 nor ECF1+ECF2+ECF3 moments are available on the jet, please make sure one of these options is available before calling the tool");
2880 return StatusCode::FAILURE;
2897 ATH_MSG_ERROR(
"The C2 moment was previously available but is not available on this jet. This functionality is not supported.");
2898 return StatusCode::FAILURE;
2900 const float value = accC2(constJet);
2902 return StatusCode::SUCCESS;
2904 if (ECFwasAvailable)
2908 ATH_MSG_ERROR(
"The ECF1, ECF2, and ECF3 moments were previously available but are not available on this jet. This functionality is not supported.");
2909 return StatusCode::FAILURE;
2911 const float ecf1 = accECF1(constJet);
2912 const float ecf2 = accECF2(constJet);
2913 const float ecf3 = accECF3(constJet);
2914 accC2(
jet) = fabs(ecf2) > 1.e-6 ? shift * (ecf3*ecf1/
pow(ecf2,2)) : -999;
2915 return StatusCode::SUCCESS;
2918 ATH_MSG_ERROR(
"Neither C2 nor ECF1+ECF2+ECF3 moments are available on the jet, please make sure one of these options is available before calling the tool");
2919 return StatusCode::FAILURE;
2929 const float value = accQw(constJet);
2931 return StatusCode::SUCCESS;
2934 ATH_MSG_ERROR(
"Qw moment is not available on the jet, please make sure to set Qw before calling the tool");
2935 return StatusCode::FAILURE;
2942 if (TagScaleFactorwasAvailable)
2946 ATH_MSG_ERROR(
"TagScaleFactor was previously available but is not available on this jet. This functionality is not supported.");
2947 return StatusCode::FAILURE;
2952 return StatusCode::SUCCESS;
2964 if ( shift*
value < 0.0 ){
2969 return StatusCode::SUCCESS;
2974 if ( shift*
value < 0.0 ){
2980 return StatusCode::SUCCESS;
2985 if ( shift*
value < 0.0 ){
2990 return StatusCode::SUCCESS;
2994 ATH_MSG_ERROR(
"TagScaleFactor is not available on the jet, please make sure you called BoostedJetTaggers tag() function before calling this function.");
2995 return StatusCode::FAILURE;
3002 if (TagScaleFactorwasAvailable)
3006 ATH_MSG_ERROR(
"TagScaleFactor was previously available but is not available on this jet. This functionality is not supported.");
3007 return StatusCode::FAILURE;
3012 return StatusCode::SUCCESS;
3019 float sigeffSF = 1.0;
3020 float updated_efficiency =
efficiency + shift;
3022 if ( updated_efficiency < 1
e-5 ) updated_efficiency=1
e-5;
3023 if ( updated_efficiency > 1.0-1
e-5 ) updated_efficiency=1.0-1
e-5;
3030 return StatusCode::SUCCESS;
3034 if ( std::abs(effSF - 1.0) < 1
e-5 && std::abs(shift)>0 ) {
3039 float variatedIneffSFsig = (1. - sigeffSF*updated_efficiency)/(1. - updated_efficiency);
3044 return StatusCode::SUCCESS;
3049 return StatusCode::SUCCESS;
3053 ATH_MSG_ERROR(
"TagScaleFactor is not available on the jet, please make sure you called BoostedJetTaggers tag() function before calling this function.");
3054 return StatusCode::FAILURE;