18 m_Name_InputAlg(
"InvalidInputAlg"),
19 m_Name_ModeCase(
"InvalidModeCase"),
20 m_Tool_InformationStore(
"PanTau::Tool_InformationStore/Tool_InformationStore"),
41 ATH_CHECK(m_Tool_InformationStore.retrieve());
44 ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble(
"ModeDiscriminator_BinEdges_Pt", m_BinEdges_Pt));
45 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"ModeDiscriminator_ReaderOption", m_ReaderOption) );
46 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"ModeDiscriminator_TMVAMethod", m_MethodName) );
49 std::string varNameList_Full =
"ModeDiscriminator_BDTVariableNames_" + m_Name_InputAlg +
"_" + m_Name_ModeCase;
50 ATH_CHECK( m_Tool_InformationStore->getInfo_VecString(varNameList_Full, m_List_BDTVariableNames) );
52 std::string varDefaultValueList_Full =
"ModeDiscriminator_BDTVariableDefaults_" + m_Name_InputAlg +
"_" + m_Name_ModeCase;
53 ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble(varDefaultValueList_Full, m_List_BDTVariableDefaultValues) );
58 if ( m_List_BDTVariableDefaultValues.size() != m_List_BDTVariableNames.size() ) {
59 ATH_MSG_ERROR(
"Number of variable names does not match number of default values! Check jobOptions!");
60 return StatusCode::FAILURE;
64 for (
unsigned int iPtBin=0; iPtBin<(m_BinEdges_Pt.size() - 1); iPtBin++) {
66 std::string bin_lowerStr = m_HelperFunctions.convertNumberToString(m_BinEdges_Pt[iPtBin]/1000.);
67 std::string bin_upperStr = m_HelperFunctions.convertNumberToString(m_BinEdges_Pt[iPtBin+1]/1000.);
68 std::string curPtBin =
"ET_" + bin_lowerStr +
"_" + bin_upperStr;
71 std::string curWeightFile = m_calib_path + (m_calib_path.length() ?
"/" :
"");
72 curWeightFile +=
"TrainModes_";
73 curWeightFile += m_Name_InputAlg +
"_";
74 curWeightFile += curPtBin +
"_";
75 curWeightFile += m_Name_ModeCase +
"_";
76 curWeightFile += m_MethodName +
".weights.root";
80 if (resolvedWeightFileName.empty()) {
81 ATH_MSG_ERROR(
"Weight file " << curWeightFile <<
" not found!");
82 return StatusCode::FAILURE;
86 std::unique_ptr<TFile> fBDT = std::make_unique<TFile>( resolvedWeightFileName.c_str() );
87 TTree* tBDT =
dynamic_cast<TTree*
> (fBDT->Get(
"BDT"));
88 std::unique_ptr<MVAUtils::BDT> curBDT = std::make_unique<MVAUtils::BDT>(tBDT);
89 if (curBDT ==
nullptr) {
90 ATH_MSG_ERROR(
"Failed to create MVAUtils::BDT for " << resolvedWeightFileName );
91 return StatusCode::FAILURE;
94 m_MVABDT_List.push_back(std::move(curBDT));
98 return StatusCode::SUCCESS;
110 for (
unsigned int iVar=0; iVar<m_List_BDTVariableNames.size(); iVar++) {
111 std::string curVar = m_Name_InputAlg +
"_" + m_List_BDTVariableNames[iVar];
116 ATH_MSG_DEBUG(
"\tUse default value as the feature (the one below this line) was not calculated");
117 newValue = m_List_BDTVariableDefaultValues[iVar];
122 list_BDTVariableValues[iVar] =
static_cast<float>(newValue);
130 std::vector<float> list_BDTVariableValues(m_List_BDTVariableNames.size());
132 updateReaderVariables(inSeed, list_BDTVariableValues);
143 for (
unsigned int iPtBin=0; iPtBin<m_BinEdges_Pt.size()-1; iPtBin++) {
144 if (inSeed->
p4().Pt() > m_BinEdges_Pt[iPtBin] && inSeed->
p4().Pt() < m_BinEdges_Pt[iPtBin+1]) {
150 ATH_MSG_WARNING(
"Could not find ptBin for tau seed with pt " << inSeed->
p4().Pt());
158 return m_MVABDT_List[ptBin]->GetGradBoostMVA(list_BDTVariableValues);