Commit d0fcc5b0 authored by Justin Griffiths's avatar Justin Griffiths Committed by Graeme Stewart
Browse files

add weights (PanTauAlgs-01-00-05)

parent bab064a3
......@@ -25,6 +25,7 @@
//! PanTau includes
#include "PanTauAlgs/Tool_DetailsArranger.h"
#include "PanTauAlgs/PanTauSeed.h"
#include "PanTauAlgs/HelperFunctions.h"
bool sortBDTscore(ElementLink< xAOD::PFOContainer > i, ElementLink< xAOD::PFOContainer > j){
......@@ -40,6 +41,7 @@ PanTau::Tool_DetailsArranger::Tool_DetailsArranger(
m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore")
{
declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to the information store tool");
declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName, "Tool handle to the information store tool");
}
......@@ -52,6 +54,9 @@ PanTau::Tool_DetailsArranger::~Tool_DetailsArranger() {
StatusCode PanTau::Tool_DetailsArranger::initialize() {
ATH_MSG_DEBUG( name() << " initialize()" );
m_init=true;
ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) );
ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_Types_DeltaRCore", m_CoreCone) );
ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_BinEdges_Eta", m_EtaBinEdges) );
......@@ -83,7 +88,7 @@ StatusCode PanTau::Tool_DetailsArranger::execute(PanTau::PanTauSeed2* inSeed) {
std::string inputAlg = inSeed->getNameInputAlgorithm();
ATH_MSG_DEBUG( "Tool_DetailsArranger::execute called for input seed at: " << inSeed << " from inputalg: " << inputAlg);
ATH_MSG_DEBUG("Tool_DetailsArranger::execute called for input seed at: " << inSeed << " from inputalg: " << inputAlg);
bool noAnyConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoConstituentsAtAll);
bool noSelConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed2::t_NoSelectedConstituents);
......@@ -96,7 +101,7 @@ StatusCode PanTau::Tool_DetailsArranger::execute(PanTau::PanTauSeed2* inSeed) {
//if the tau is valid, overwrite with non-default values
xAOD::TauJet* tauJet = const_cast<xAOD::TauJet*>(inSeed->getTauJet());
ATH_MSG_DEBUG( "check for bad seed -> isBadSeed = " << isBadSeed);
ATH_MSG_DEBUG("check for bad seed -> isBadSeed = " << isBadSeed);
if(isBadSeed == true) {
ATH_MSG_DEBUG("This seed is not useable for detail arranging (other than validity flag)");
tauJet->setPanTauDetail(xAOD::TauJetParameters::PanTau_isPanTauCandidate, 0);
......@@ -104,10 +109,11 @@ StatusCode PanTau::Tool_DetailsArranger::execute(PanTau::PanTauSeed2* inSeed) {
}
ATH_MSG_DEBUG( "arrange for seed from inputalg: " << inputAlg);
ATH_MSG_DEBUG("arrange for seed from inputalg: " << inputAlg);
ATH_CHECK(arrangePFOLinks(inSeed, tauJet));
//Basic variables
addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_isPanTauCandidate", xAOD::TauJetParameters::PanTau_isPanTauCandidate, PanTau::Tool_DetailsArranger::t_Int);
addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_RecoMode_PanTau", xAOD::TauJetParameters::PanTau_DecayMode, PanTau::Tool_DetailsArranger::t_Int);
......@@ -141,6 +147,7 @@ StatusCode PanTau::Tool_DetailsArranger::execute(PanTau::PanTauSeed2* inSeed) {
xAOD::TauJetParameters::PanTau_BDTVar_Combined_DeltaR1stNeutralTo1stCharged, PanTau::Tool_DetailsArranger::t_Float);
addPanTauDetailToTauJet(inSeed, "Charged_HLV_SumM",
xAOD::TauJetParameters::PanTau_BDTVar_Charged_HLV_SumM, PanTau::Tool_DetailsArranger::t_Float);
return StatusCode::SUCCESS;
}
......@@ -209,7 +216,7 @@ StatusCode PanTau::Tool_DetailsArranger::arrangePFOLinks(PanTau::PanTauSeed2* in
std::vector< ElementLink< xAOD::PFOContainer > > preSelected_neutralPFOLinks = CollectConstituentsAsPFOLinks( inSeed, tauJet->protoNeutralPFOLinks(), PanTau::TauConstituent2::t_Neutral );
//clear the default links, just to be save
//clear the default links, just to be safe
tauJet->clearChargedPFOLinks();
tauJet->clearNeutralPFOLinks();
tauJet->clearPi0PFOLinks();
......@@ -459,16 +466,17 @@ StatusCode PanTau::Tool_DetailsArranger::arrangePFOLinks(PanTau::PanTauSeed2* in
//#endif //NDEBUG
// vector of 4-vectors of actual pi0s and a vector with pointers to PFOs:
std::vector< TLorentzVector > vec_pi04vec;
std::vector< std::vector< ElementLink<xAOD::PFOContainer> > > vec_pi0pfos;
createPi0Vectors(tauJet, vec_pi04vec, vec_pi0pfos);
xAOD::ParticleContainer* pi0Container=0;
ATH_CHECK( evtStore()->retrieve(pi0Container, "finalTauPi0s") );
for(unsigned int itlv=0; itlv!=vec_pi04vec.size(); ++itlv) {
for(unsigned int itlv=0; itlv!=vec_pi04vec.size(); ++itlv) {
xAOD::Particle* p = new xAOD::Particle();
pi0Container->push_back(p);
p->setPxPyPzE(vec_pi04vec.at(itlv).Px(), vec_pi04vec.at(itlv).Py(), vec_pi04vec.at(itlv).Pz(), vec_pi04vec.at(itlv).E());
......@@ -664,6 +672,7 @@ void PanTau::Tool_DetailsArranger::createPi0Vectors(xAOD::TauJet* tauJet, std::v
tauJet->panTauDetail(xAOD::TauJetParameters::PanTau_DecayMode, iDecayMode);
if (iDecayMode == xAOD::TauJetParameters::Mode_1p1n && iNumPi0PFO > 1) {
// TODO: find out if the pi0 mass is defined elsewhere in atlas code!
// float fMassPi0 = 134.98;
float fMassPi0Squared = MASS_PI0*MASS_PI0;
......@@ -702,9 +711,9 @@ void PanTau::Tool_DetailsArranger::createPi0Vectors(xAOD::TauJet* tauJet, std::v
std::vector< ElementLink<xAOD::PFOContainer> > pfovec;
pfovec.push_back(tauJet->pi0PFOLinks()[0]);
vec_pi0pfos.push_back( pfovec );
vec_pi0pfos.push_back( pfovec );//fix rare crash?
} else {
// if it's not any of the special cases above then just collect the PFOs:
for (size_t iPFO = 0; iPFO < iNumPi0PFO; iPFO++){
vPi0s.push_back(tauJet->pi0PFO(iPFO)->p4());
......
......@@ -37,6 +37,7 @@
#include "PanTauAlgs/TauConstituent.h"
#include "PanTauAlgs/PanTauSeed.h"
#include "PanTauAlgs/TauFeature.h"
#include "PanTauAlgs/HelperFunctions.h"
......@@ -67,6 +68,7 @@ PanTau::Tool_FeatureExtractor::Tool_FeatureExtractor(
//declareProperty("TrackToVertexTool", m_trackToVertexTool);
declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to the information store tool");
declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName, "Tool handle to the information store tool");
}
......@@ -75,8 +77,10 @@ PanTau::Tool_FeatureExtractor::Tool_FeatureExtractor(
StatusCode PanTau::Tool_FeatureExtractor::initialize() {
ATH_MSG_INFO(" initialize()");
m_init=true;
//ATH_CHECK( m_trackToVertexTool.retrieve() );
ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) );
ATH_CHECK( m_Tool_InformationStore.retrieve() );
ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Sum", m_varTypeName_Sum) );
......
......@@ -18,6 +18,127 @@
// ROOT includes
#include "TVector2.h"
#define GeV 1000
void PanTau::Tool_InformationStore::ABRDefaultInit(){
#ifdef XAOD_ANALYSIS
ATH_MSG_INFO("Setting Tool_InformationStore In environment ABR");
// Boolean values
MapInt m01 = {
{"UseDefaultCellBasedConfig",1},//is this one necessary
{"TauConstituents_UsePionMass",1},
{"FeatureExtractor_UseEmptySeeds",0},
{"TauConstituents_eflowRec_UseMomentumAsEnergy",0},
{"TauConstituents_UseShrinkingCone",0}
};
setMapInt(m01);
// double values
MapDouble m02 = {
{"eflowRec_Assoc_DeltaR",0.4},
{"TauConstituents_Types_DeltaRCore",0.2},
{"TauConstituents_MaxEta",9.9},
{"TauConstituents_PreselectionMinEnergy",500.},
{"TauConstituents_eflowRec_BDTThreshold_Pi0Neut",-0.04},
// PanTau BDT Cut values --- CellBased
{"DecayModeDeterminator_BDTCutValue_R10X_CellBased",0.19},
{"DecayModeDeterminator_BDTCutValue_R11X_CellBased",-0.11},
{"DecayModeDeterminator_BDTCutValue_R110_CellBased",0.37},
{"DecayModeDeterminator_BDTCutValue_R1XX_CellBased",0.07},
{"DecayModeDeterminator_BDTCutValue_R30X_CellBased",-0.01},
{"DecayModeDeterminator_BDTCutValue_R3XX_CellBased",-0.03},
// PanTau BDT Cut values --- eflowRec
{"DecayModeDeterminator_BDTCutValue_R10X_eflowRec",-0.15},
{"DecayModeDeterminator_BDTCutValue_R11X_eflowRec",-0.60},
{"DecayModeDeterminator_BDTCutValue_R110_eflowRec",-0.08},
{"DecayModeDeterminator_BDTCutValue_R1XX_eflowRec",0.03},
{"DecayModeDeterminator_BDTCutValue_R30X_eflowRec",-0.25},
{"DecayModeDeterminator_BDTCutValue_R3XX_eflowRec",-0.23}
};
setMapDouble(m02);
// String values
MapString m03 = {
{"Name_TauRecContainer","TauJets"},
{"Name_eflowRecContainer","eflowObjects_tauMode"},
{"Name_TrackParticleContainer","TrackParticleCandidate"},
{"Name_PanTauSeedsContainer","PanTau_OutputSeeds"},
{"ModeDiscriminator_ReaderOption","!Color:Silent"},
{"ModeDiscriminator_TMVAMethod","BDTG"},
{"FeatureExtractor_VarTypeName_varTypeName_Sum", "Sum"},
{"FeatureExtractor_VarTypeName_varTypeName_Ratio", "Ratio"},
{"FeatureExtractor_VarTypeName_varTypeName_EtInRing", "EtInRing"},
{"FeatureExtractor_VarTypeName_varTypeName_Isolation", "Isolation"},
{"FeatureExtractor_VarTypeName_varTypeName_Num", "Num"},
{"FeatureExtractor_VarTypeName_varTypeName_Mean", "Mean"},
{"FeatureExtractor_VarTypeName_varTypeName_StdDev", "StdDev"},
{"FeatureExtractor_VarTypeName_varTypeName_HLV", "HLV"},
{"FeatureExtractor_VarTypeName_varTypeName_Angle", "Angle"},
{"FeatureExtractor_VarTypeName_varTypeName_DeltaR", "DeltaR"},
{"FeatureExtractor_VarTypeName_varTypeName_JetMoment", "JetMoment"},
{"FeatureExtractor_VarTypeName_varTypeName_Combined", "Combined"},
{"FeatureExtractor_VarTypeName_varTypeName_JetShape", "JetShape"},
{"FeatureExtractor_VarTypeName_varTypeName_ImpactParams", "ImpactParams"},
{"FeatureExtractor_VarTypeName_varTypeName_Basic", "Basic"},
{"FeatureExtractor_VarTypeName_varTypeName_PID", "PID"},
{"FeatureExtractor_VarTypeName_varTypeName_Shots", "Shots"},
};
setMapString(m03);
// vector<double> values
// In Config_PanTau.py, this was called "vector<float> values". This was changed to "double".
// The "Units.GeV" (import AthenaCommon.SystemOfUnits as Units) was now replaced by "GeV" (#include "CLHEP/Units/SystemOfUnits.h", using CLHEP::GeV)
MapVecDouble m04 = {
{"TauConstituents_BinEdges_Eta",{0.000, 0.800, 1.400, 1.500, 1.900, 9.900}},
{"TauConstituents_Selection_Neutral_EtaBinned_EtCut",{2.1*GeV, 2.5*GeV, 2.6*GeV, 2.4*GeV, 1.9*GeV}},
{"TauConstituents_Selection_Pi0Neut_EtaBinned_EtCut",{2.1*GeV, 2.5*GeV, 2.6*GeV, 2.4*GeV, 1.9*GeV}},
{"TauConstituents_Selection_Charged_EtaBinned_EtCut",{1.0*GeV, 1.0*GeV, 1.0*GeV, 1.0*GeV, 1.0*GeV}},
{"TauConstituents_Selection_OutNeut_EtaBinned_EtCut",{1.0*GeV, 1.0*GeV, 1.0*GeV, 1.0*GeV, 1.0*GeV}},
{"TauConstituents_Selection_OutChrg_EtaBinned_EtCut",{1.0*GeV, 1.0*GeV, 1.0*GeV, 1.0*GeV, 1.0*GeV}},
{"TauConstituents_Selection_NeutLowA_EtaBinned_EtCut",{1.85*GeV, 2.25*GeV, 2.35*GeV, 2.15*GeV, 1.65*GeV}},
{"TauConstituents_Selection_NeutLowB_EtaBinned_EtCut",{1.6*GeV, 2.0*GeV, 2.1*GeV, 1.9*GeV, 1.4*GeV}},
{"eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_1prong",{2.5*GeV, 2.5*GeV, 1.9*GeV, 2.5*GeV, 2.3*GeV}},
{"eflowRec_Selection_Pi0Neut_EtaBinned_EtCut_3prong",{2.5*GeV, 2.5*GeV, 2.5*GeV, 2.5*GeV, 2.5*GeV}},
// Eta Binned P I 0 - B D T C U T S
{"CellBased_BinEdges_Eta",{0.000, 0.800, 1.400, 1.500, 1.900, 9.900}},
{"CellBased_EtaBinned_Pi0MVACut_1prong",{0.46, 0.39, 0.51, 0.47, 0.54}},
{"CellBased_EtaBinned_Pi0MVACut_3prong",{0.47, 0.52, 0.60, 0.55, 0.50}},
{"eflowRec_BinEdges_Eta",{0.000, 0.800, 1.400, 1.500, 1.900, 9.900}},
{"eflowRec_EtaBinned_Pi0MVACut_1prong",{0.09, 0.09, 0.09, 0.08, 0.05}},
{"eflowRec_EtaBinned_Pi0MVACut_3prong",{0.09, 0.09, 0.09, 0.09, 0.07}},
// P T B I N S
{"ModeDiscriminator_BinEdges_Pt",{10*GeV, 100000*GeV}},
{"ModeDiscriminator_BDTVariableDefaults_CellBased_1p0n_vs_1p1n", {-9.0, -0.2, -10.0, -0.2, -2.0}},
{"ModeDiscriminator_BDTVariableDefaults_CellBased_1p1n_vs_1pXn", {-9.0, -200.0, -0.2, -5.0, -2.0}},
{"ModeDiscriminator_BDTVariableDefaults_CellBased_3p0n_vs_3pXn", {-0.2, -9.0, -0.2, -2.0, -200.0}},
};
setMapVecDouble(m04);
// vector<string> values
MapVecString m05 = {
{"Names_InputAlgorithms",{"CellBased"}},
{"Names_ModeCases",{"1p0n_vs_1p1n","1p1n_vs_1pXn","3p0n_vs_3pXn"}},
// ---> eflowRec BDT variables
{"ModeDiscriminator_BDTVariableNames_eflowRec_1p0n_vs_1p1n",{"Charged_Ratio_EtOverEtAllConsts","Basic_NPi0NeutConsts","Neutral_PID_BDTValues_EtSort_1","Combined_DeltaR1stNeutralTo1stCharged"}},
{"ModeDiscriminator_BDTVariableNames_eflowRec_1p1n_vs_1pXn",{"Neutral_PID_BDTValues_BDTSort_2","Neutral_Ratio_EtOverEtAllConsts","Basic_NNeutralConsts","Neutral_HLV_SumM"}},
{"ModeDiscriminator_BDTVariableNames_eflowRec_3p0n_vs_3pXn",{"Basic_NPi0NeutConsts","Neutral_PID_BDTValues_BDTSort_1","Charged_HLV_SumPt","Charged_Ratio_EtOverEtAllConsts","Neutral_Mean_DRToLeading_WrtEtAllConsts"}},
// ---> CellBased BDT variables
{"ModeDiscriminator_BDTVariableNames_CellBased_1p0n_vs_1p1n",{"Neutral_PID_BDTValues_BDTSort_1","Neutral_Ratio_1stBDTEtOverEtAllConsts","Combined_DeltaR1stNeutralTo1stCharged","Charged_JetMoment_EtDRxTotalEt","Neutral_Shots_NPhotonsInSeed"}},
{"ModeDiscriminator_BDTVariableNames_CellBased_1p1n_vs_1pXn",{"Neutral_PID_BDTValues_BDTSort_2","Neutral_HLV_SumM","Neutral_Ratio_EtOverEtAllConsts","Basic_NNeutralConsts","Neutral_Shots_NPhotonsInSeed"}},
{"ModeDiscriminator_BDTVariableNames_CellBased_3p0n_vs_3pXn",{"Neutral_Ratio_EtOverEtAllConsts","Neutral_PID_BDTValues_BDTSort_1","Charged_StdDev_Et_WrtEtAllConsts","Neutral_Shots_NPhotonsInSeed","Charged_HLV_SumM"}},
{"ModeDiscriminator_BDTVariableTypes_CellBased_1p0n_vs_1p1n", {"F","F","F","F","F"}},
{"ModeDiscriminator_BDTVariableTypes_CellBased_1p1n_vs_1pXn", {"F","F","F","F","F"}},
{"ModeDiscriminator_BDTVariableTypes_CellBased_3p0n_vs_3pXn", {"F","F","F","F","F"}},
};
setMapVecString(m05);
#endif
}
PanTau::Tool_InformationStore::Tool_InformationStore(
const std::string& name ) :
......@@ -40,7 +161,11 @@ PanTau::Tool_InformationStore::~Tool_InformationStore() {
StatusCode PanTau::Tool_InformationStore::initialize() {
ATH_MSG_INFO( name() << " initialize()" );
m_init=true;
//This function does nothing in athena
ABRDefaultInit();
ATH_CHECK( this->getInfo_String("Name_TauRecContainer", m_Name_Container_TauRec) );
ATH_CHECK( this->getInfo_String("Name_TrackParticleContainer", m_Name_Container_Tracks) );
......@@ -55,7 +180,7 @@ StatusCode PanTau::Tool_InformationStore::initialize() {
// }
StatusCode PanTau::Tool_InformationStore::getInfo_Int(std::string varName, int& value) {
StatusCode PanTau::Tool_InformationStore::getInfo_Int(std::string varName, int& value) {
MapInt::const_iterator it = m_Infos_Int.find(varName);
if(it == m_Infos_Int.end()) {
ATH_MSG_ERROR("getInfo_Int: No integer information called " << varName << " present in InformationStore");
......
......@@ -8,6 +8,7 @@
#include "PanTauAlgs/Tool_InformationStore.h"
#include "PanTauAlgs/TauConstituent.h"
#include "PanTauAlgs/PanTauSeed.h"
#include "PanTauAlgs/HelperFunctions.h"
//! xAOD EDM
#include "xAODTau/TauJet.h"
......@@ -21,6 +22,7 @@ PanTau::Tool_InputConverter::Tool_InputConverter(
m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore")
{
declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Link to tool with all information");
declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName="", "Optional Name for InformationStore insance in ABR");
}
PanTau::Tool_InputConverter::~Tool_InputConverter() {
......@@ -29,7 +31,10 @@ PanTau::Tool_InputConverter::~Tool_InputConverter() {
StatusCode PanTau::Tool_InputConverter::initialize() {
ATH_MSG_INFO(" initialize()");
m_init=true;
ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName) ); //ABR only
ATH_CHECK( m_Tool_InformationStore.retrieve() );
ATH_CHECK( m_Tool_InformationStore->getInfo_Int("TauConstituents_UsePionMass", m_Config_UsePionMass) );
......
......@@ -20,12 +20,13 @@
#include "PanTauAlgs/Tool_InformationStore.h"
#include "PanTauAlgs/TauFeature.h"
#include "PanTauAlgs/PanTauSeed.h"
#include "PanTauAlgs/HelperFunctions.h"
//! Root
#include "TString.h"
#include "TFile.h"
#include "TTree.h"
#include "TH1F.h"
#include "TMVA/Reader.h"
//!Other
#include "PathResolver/PathResolver.h"
......@@ -37,11 +38,12 @@ PanTau::Tool_ModeDiscriminator::Tool_ModeDiscriminator(
m_Name_InputAlg("InvalidInputAlg"),
m_Name_ModeCase("InvalidModeCase"),
m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore"),
m_TMVA_ReaderList()
m_MVABDT_List()
{
declareProperty("Name_InputAlg", m_Name_InputAlg, "Name of the input algorithm for this instance");
declareProperty("Name_ModeCase", m_Name_ModeCase, "Name of the two modes to be distinguished for this instance");
declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Handle to the information store tool");
declareProperty("Tool_InformationStoreName",m_Tool_InformationStoreName,"Handle to the information store tool");
}
......@@ -54,10 +56,13 @@ PanTau::Tool_ModeDiscriminator::~Tool_ModeDiscriminator() {
StatusCode PanTau::Tool_ModeDiscriminator::initialize() {
ATH_MSG_DEBUG( name() << " initialize()" );
m_init=true;
ATH_MSG_DEBUG("InputAlg : " << m_Name_InputAlg);
ATH_MSG_DEBUG("Mode Case : " << m_Name_ModeCase);
ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) );
ATH_CHECK(m_Tool_InformationStore.retrieve());
//get the required information from the informationstore tool
......@@ -86,9 +91,9 @@ StatusCode PanTau::Tool_ModeDiscriminator::initialize() {
//! ////////////////////////
//! Create list of BDT variables to link to the reader
m_List_BDTVariableValues = std::vector<float>(0);
m_List_BDTVariableValues = std::vector<float*>(0);
for(unsigned int iVar=0; iVar<m_List_BDTVariableNames.size(); iVar++) {
m_List_BDTVariableValues.push_back(0);
m_List_BDTVariableValues.push_back(new float(0));
}
......@@ -117,9 +122,13 @@ StatusCode PanTau::Tool_ModeDiscriminator::initialize() {
curWeightFile += m_Name_InputAlg + "_";
curWeightFile += curPtBin + "_";
curWeightFile += curModeCase + "_";
curWeightFile += m_MethodName + ".weights.xml";
std::string resolvedWeightFileName = PathResolver::find_file(curWeightFile, "DATAPATH");
curWeightFile += m_MethodName + ".weights.root";
#ifndef XAOD_ANALYSIS
std::string resolvedWeightFileName = PathResolver::find_file(curWeightFile, "DATAPATH");
#else
std::string resolvedWeightFileName = PathResolverFindCalibFile("PanTauAlgs/weights/"+curWeightFile);
#endif
if(resolvedWeightFileName == "") {
ATH_MSG_ERROR("Weight file " << curWeightFile << " not found!");
return StatusCode::FAILURE;
......@@ -130,22 +139,24 @@ StatusCode PanTau::Tool_ModeDiscriminator::initialize() {
//! ////////////////////////
//! TMVA Readers
ATH_MSG_DEBUG("\tCreate TMVA::Readers");
TMVA::Reader* curReader = new TMVA::Reader((TString)m_ReaderOption);
if(msgLvl(MSG::DEBUG) == true) curReader->SetVerbose(true);
ATH_MSG_DEBUG("\tCreate MVAUtils::BDT");
//setup variables for reader
for(unsigned int iVar=0; iVar<m_List_BDTVariableNames.size(); iVar++) {
TString variableNameForReader = "tau_pantauFeature_" + m_Name_InputAlg + "_" + m_List_BDTVariableNames[iVar];
ATH_MSG_DEBUG("\t\tAdding variable to reader: " << variableNameForReader << " var stored at: " << &(m_List_BDTVariableValues[iVar]));
curReader->AddVariable(variableNameForReader, &(m_List_BDTVariableValues[iVar]));
ATH_MSG_DEBUG("\t\tAdding variable to reader: " << variableNameForReader << " var stored at: " << (m_List_BDTVariableValues[iVar]));
//curReader->AddVariable(variableNameForReader, &(m_List_BDTVariableValues[iVar]));
}//end loop over variables
TFile* fBDT = TFile::Open(resolvedWeightFileName.c_str());
TTree* tBDT = dynamic_cast<TTree*> (fBDT->Get("BDT"));
MVAUtils::BDT* curBDT = new MVAUtils::BDT(tBDT);
curBDT->SetPointers(m_List_BDTVariableValues);
curReader->BookMVA( m_MethodName, resolvedWeightFileName);
ATH_MSG_DEBUG("\t\tStoring new TMVA::Reader at " << curReader);
m_TMVA_ReaderList.push_back(curReader);
ATH_MSG_DEBUG("\t\tStoring new MVAUtils::BDT at " << curBDT);
m_MVABDT_List.push_back(curBDT);
}//end loop over pt bins to get weight files, reference hists and TMVA Readers
}//end loop over pt bins to get weight files, reference hists and MVAUtils::BDT objects
return StatusCode::SUCCESS;
}
......@@ -155,11 +166,14 @@ StatusCode PanTau::Tool_ModeDiscriminator::initialize() {
StatusCode PanTau::Tool_ModeDiscriminator::finalize() {
//delete the readers
for(unsigned int iReader=0; iReader<m_TMVA_ReaderList.size(); iReader++) {
TMVA::Reader* curReader = m_TMVA_ReaderList[iReader];
if(curReader != 0) delete curReader;
for(unsigned int iReader=0; iReader<m_MVABDT_List.size(); iReader++) {
MVAUtils::BDT* curBDT = m_MVABDT_List[iReader];
if(curBDT != 0) delete curBDT;
}
m_MVABDT_List.clear();
for( float* f : m_List_BDTVariableValues ) delete f;
m_List_BDTVariableValues.clear();
return StatusCode::SUCCESS;
}
......@@ -186,7 +200,7 @@ void PanTau::Tool_ModeDiscriminator::updateReaderVariables(PanTau::PanTauSeed
}
ATH_MSG_DEBUG("\tUpdate variable " << curVar << " from " << m_List_BDTVariableValues[iVar] << " to " << newValue);
m_List_BDTVariableValues[iVar] = (float)newValue;
*(m_List_BDTVariableValues[iVar]) = (float)newValue;
}//end loop over BDT vars for update
return;
......@@ -223,9 +237,9 @@ double PanTau::Tool_ModeDiscriminator::getResponse(PanTau::PanTauSeed2* inSeed,
}
//get mva response
TMVA::Reader* curReader = m_TMVA_ReaderList[ptBin];
if(curReader == 0) {
ATH_MSG_ERROR("TMVA::Reader object for current tau seed points to 0");
MVAUtils::BDT* curBDT = m_MVABDT_List[ptBin];
if(curBDT == 0) {
ATH_MSG_ERROR("MVAUtils::BDT object for current tau seed points to 0");
isOK = false;
return -2.;
}
......@@ -234,7 +248,7 @@ double PanTau::Tool_ModeDiscriminator::getResponse(PanTau::PanTauSeed2* inSeed,
// ATH_MSG_DEBUG("Values of BDT Variables: ");
// for(unsigned int iVar=0; iVar<m_List_BDTVariableNames.size(); iVar++) ATH_MSG_WARNING(m_List_BDTVariableNames.at(iVar) << ": " << m_List_BDTVariableValues.at(iVar) << " (stored at " << &(m_List_BDTVariableValues.at(iVar)) << ")");
double mvaResponse = curReader->EvaluateMVA((TString)m_MethodName);
double mvaResponse = curBDT->GetGradBoostMVA(m_List_BDTVariableValues);
ATH_MSG_DEBUG("MVA response from " << m_MethodName << " in " << m_Name_ModeCase << " is " << mvaResponse);
isOK = true;
......
......@@ -7,6 +7,7 @@
#include "PanTauAlgs/Tool_TauConstituentGetter.h"
#include "PanTauAlgs/TauConstituent.h"
#include "PanTauAlgs/HelperFunctions.h"
#include "PanTauAlgs/Tool_InformationStore.h"
#include "PanTauAlgs/Tool_InputConverter.h"
//#include "TVector3.h"
......@@ -26,6 +27,8 @@ PanTau::Tool_TauConstituentGetter::Tool_TauConstituentGetter(
{
declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Link to tool with all information");
declareProperty("Tool_InputConverter", m_Tool_InputConverter, "Link to tool to convert into TauConstituents");
declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName, "Link to tool with all information");
declareProperty("Tool_InputConverterName", m_Tool_InputConverterName, "Link to tool to convert into TauConstituents");
}
PanTau::Tool_TauConstituentGetter::~Tool_TauConstituentGetter() {
......@@ -34,6 +37,10 @@ PanTau::Tool_TauConstituentGetter::~Tool_TauConstituentGetter() {
StatusCode PanTau::Tool_TauConstituentGetter::initialize() {
ATH_MSG_INFO(" initialize()");
m_init=true;
ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) );
ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InputConverter, m_Tool_InputConverterName ) );
ATH_CHECK( m_Tool_InformationStore.retrieve() );
ATH_CHECK( m_Tool_InputConverter.retrieve() );
......
......@@ -7,6 +7,7 @@
#include "PanTauAlgs/Tool_TauConstituentSelector.h"
#include "PanTauAlgs/TauConstituent.h"
#include "PanTauAlgs/HelperFunctions.h"
#include "PanTauAlgs/Tool_InformationStore.h"
#include <math.h>
......@@ -18,6 +19,7 @@ PanTau::Tool_TauConstituentSelector::Tool_TauConstituentSelector(
m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore")
{
declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Link to tool with all information");
declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName, "Link to tool with all information");
}
PanTau::Tool_TauConstituentSelector::~Tool_TauConstituentSelector() {
......@@ -26,7 +28,9 @@ PanTau::Tool_TauConstituentSelector::~Tool_TauConstituentSelector() {
StatusCode PanTau::Tool_TauConstituentSelector::initialize() {
ATH_MSG_INFO(" initialize()");
m_init=true;
ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) );
ATH_CHECK( m_Tool_InformationStore.retrieve() );
ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_MaxEta", m_MaxEta) );
......
......@@ -29,7 +29,7 @@ PACKAGE_LIBFLAGS =
# the list of packages we depend on:
#PACKAGE_DEP = AthLinks xAODCore AthContainersInterfaces xAODRootAccess AsgTools xAODRootAccessInterfaces CxxUtils AthContainers xAODEventFormat xAODBTagging xAODBase EventPrimitives xAODTau PathResolver GeoPrimitives xAODCaloEvent xAODPFlow xAODJet CaloGeoHelpers xAODTracking FourMomUtils PATInterfaces tauRecTools
PACKAGE_DEP = AthLinks xAODCore AthContainersInterfaces xAODRootAccess AsgTools xAODRootAccessInterfaces CxxUtils AthContainers xAODEventFormat xAODBase EventPrimitives xAODTau PathResolver GeoPrimitives xAODCaloEvent xAODPFlow xAODJet CaloGeoHelpers xAODTracking FourMomUtils PATInterfaces tauRecTools
PACKAGE_DEP = AthLinks xAODCore AthContainersInterfaces xAODRootAccess AsgTools xAODRootAccessInterfaces CxxUtils AthContainers xAODEventFormat xAODBase EventPrimitives xAODTau PathResolver GeoPrimitives xAODCaloEvent xAODPFlow xAODJet xAODParticleEvent CaloGeoHelpers xAODTracking FourMomUtils PATInterfaces tauRecTools
# the list of packages we use if present, but that we can work without :
PACKAGE_TRYDEP =
......
......@@ -36,7 +36,7 @@ use xAODParticleEvent xAODParticleEvent-* Event/xAOD
public
# Specify required ROOT components to cmake (transparent to CMT)
apply_pattern cmake_add_command command="find_package(ROOT COMPONENTS MathCore MathMore Matrix TMVA)"
apply_pattern cmake_add_command command="find_package(ROOT COMPONENTS MathCore MathMore Matrix)"
# dual use changes:
apply_pattern dual_use_library files="../Root/*.cxx ../src/*.cxx"
......@@ -55,4 +55,4 @@ apply_pattern declare_python_modules files="*.py"
private
apply_tag ROOTBasicLibs
apply_tag ROOTMathLibs
apply_tag ROOTTMVALibs
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment