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

hide code from AthAnalysisBase (tauRecTools-00-01-10)

	* Removed TMVA from package, using MVAUtils
	* fixed a crash in TauCalibrateLC::finalize
	* Tagging tauRecTools-00-01-08

2016-08-25 Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>
	* Fixed the package to build correctly with -Wl,--no-undefined
	  enabled.
	* Cleaned up the CMakeLists.txt file to only build the code under
	  Root/ into the installed library. Since headers are only public
	  for those classes. Sources under src/ are only built into the
	  component library now.
	* As it turns out, StoreGateSvc::contains doesn't like const type
	  declarations. Even if the code worked in standalone mode, it had
	  to be simplified a bit for the offline build.
	  (This was in Root/TauProcessorTool.cxx.)
	* Made src/TauVertexFinder.h only include the
	  "InDetTrackSelectionTool/IInDetTrackSelectionTool.h" interface
	  header instead of the
	  "InDetTrackSelectionTool/InDetTrackSelectionTool.h" implementation
	  header. As using the latter one lead to linking problems.
...
(Long ChangeLog diff - truncated)


Former-commit-id: 39ddfdb7
parent dadcec4d
# $Id: CMakeLists.txt 772349 2016-09-08 23:01:15Z griffith $
################################################################################
# Package: tauRecTools
################################################################################
......@@ -6,29 +7,31 @@
atlas_subdir( tauRecTools )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
atlas_depends_on_subdirs(
PUBLIC
Calorimeter/CaloUtils
Control/AthLinks
Control/AthToolSupport/AsgTools
Control/CxxUtils
Event/xAOD/xAODCaloEvent
Event/xAOD/xAODEventInfo
Event/xAOD/xAODPFlow
Event/xAOD/xAODTau
Event/xAOD/xAODTracking
Reconstruction/Particle
PRIVATE
Calorimeter/CaloInterface
Control/AthContainers
Event/FourMomUtils
Event/NavFourMom
Event/xAOD/xAODCaloEvent
Event/xAOD/xAODJet
Event/xAOD/xAODPFlow
GaudiKernel
InnerDetector/InDetRecTools/InDetRecToolInterfaces
InnerDetector/InDetRecTools/InDetTrackSelectionTool
Reconstruction/Jet/JetEDM
Reconstruction/Particle
Reconstruction/RecoTools/ITrackToVertex
Reconstruction/RecoTools/RecoToolInterfaces
Reconstruction/MVAUtils
Tools/PathResolver
Tracking/TrkEvent/TrkLinks
Tracking/TrkEvent/TrkParametersIdentificationHelpers
......@@ -40,24 +43,30 @@ atlas_depends_on_subdirs( PUBLIC
Tracking/TrkVertexFitter/TrkVxEdmCnv )
# External dependencies:
find_package( Boost COMPONENTS filesystem thread system )
find_package( ROOT COMPONENTS TMVA Core Tree MathCore Hist RIO pthread )
find_package( Boost )
find_package( ROOT COMPONENTS Core Tree Hist RIO )
# Component(s) in the package:
atlas_add_library( tauRecToolsLib
src/*.cxx
Root/*.cxx
tauRecTools/*.h Root/*.cxx
PUBLIC_HEADERS tauRecTools
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} AthLinks AsgTools CxxUtils xAODEventInfo xAODTau xAODTracking CaloUtilsLib TrkVertexFittersLib TrkVxEdmCnvLib
PRIVATE_LINK_LIBRARIES AthContainers FourMomUtils NavFourMom xAODCaloEvent xAODJet xAODPFlow GaudiKernel InDetRecToolInterfaces JetEDM Particle ITrackToVertex RecoToolInterfaces PathResolver TrkLinks TrkParametersIdentificationHelpers TrkTrackSummary VxVertex TrkToolInterfaces TrkVertexFitterInterfaces )
LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} AthLinks AsgTools
CxxUtils xAODCaloEvent xAODEventInfo xAODPFlow xAODTau xAODTracking
CaloUtilsLib Particle
PRIVATE_LINK_LIBRARIES FourMomUtils xAODJet PathResolver MVAUtils )
atlas_add_component( tauRecTools
src/components/*.cxx
src/*.h src/*.cxx src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} CaloUtilsLib AthLinks AsgTools CxxUtils xAODEventInfo xAODTau xAODTracking AthContainers FourMomUtils NavFourMom xAODCaloEvent xAODJet xAODPFlow GaudiKernel InDetRecToolInterfaces JetEDM Particle ITrackToVertex RecoToolInterfaces PathResolver TrkLinks TrkParametersIdentificationHelpers TrkTrackSummary VxVertex TrkToolInterfaces TrkVertexFitterInterfaces TrkVertexFittersLib TrkVxEdmCnvLib tauRecToolsLib )
LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} CaloUtilsLib xAODTau
xAODTracking AthContainers FourMomUtils NavFourMom xAODCaloEvent xAODJet
xAODPFlow MVAUtils GaudiKernel InDetRecToolInterfaces JetEDM Particle ITrackToVertex
RecoToolInterfaces TrkLinks TrkParametersIdentificationHelpers
TrkTrackSummary VxVertex TrkToolInterfaces TrkVertexFitterInterfaces
TrkVertexFittersLib TrkVxEdmCnvLib InDetTrackSelectionToolLib
tauRecToolsLib )
# Install files from the package:
atlas_install_runtime( share/*.xml )
atlas_install_data( share/* )
......@@ -21,7 +21,13 @@
//_____________________________________________________________________________
CombinedP4FromRecoTaus::CombinedP4FromRecoTaus(const std::string& name) :
TauRecToolBase(name)
TauRecToolBase(name),
// move these to another file? :
m_weight(-1111.),
m_combined_res(-1111.),
m_sigma_tauRec(-1111.),
m_sigma_constituent(-1111.),
m_corrcoeff(-1111.)
{
declareProperty( "WeightFileName", m_sWeightFileName = "");
declareProperty( "addCalibrationResultVariables", m_addCalibrationResultVariables=false);
......@@ -42,8 +48,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
std::string calibFilePath = find_file(m_sWeightFileName);
TFile * file = TFile::Open(calibFilePath.c_str(), "READ");
TH1F* histogram;
TObject* obj;
TH1F* histogram(0);
std::string histname="";
......@@ -55,14 +60,12 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
//Get m_resHists_tauRec
//histname="ConstituentEt/CorrelationCoeff_ConstituentEt_" + m_modeNames[imode];
histname="CorrelationCoeff_tauRec_" + m_modeNames[imode];
obj = file->Get(histname.c_str());
if(obj) histogram = dynamic_cast<TH1F*>(obj);
histogram = dynamic_cast<TH1F*> (file->Get(histname.c_str()));
if(histogram){
m_correlationHists.push_back(histogram);
ATH_MSG_DEBUG("Adding corr hist: ");
//histogram->Print("all");
}
}
......@@ -76,8 +79,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
//Get m_resHists_tauRec
histname = "tauRec/ResolutionEt_tauRec_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin];
obj = file->Get(histname.c_str());
if(obj) histogram = dynamic_cast<TH1F*>(obj);
histogram = dynamic_cast<TH1F*> (file->Get(histname.c_str()));
if(histogram){
m_resHists_tauRec[ietaBin].push_back(histogram);
ATH_MSG_DEBUG("Adding hist: ");
......@@ -89,8 +91,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
//Get m_meanHists_tauRec
histname = "tauRec/MeanEt_tauRec_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin];
obj = file->Get(histname.c_str());
if(obj) histogram = dynamic_cast<TH1F*>(obj);
histogram = dynamic_cast<TH1F*> (file->Get(histname.c_str()));
if(histogram) {
m_meanHists_tauRec[ietaBin].push_back(histogram);
ATH_MSG_DEBUG("Adding hist: ");
......@@ -102,8 +103,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
//Get m_resHists_CellBased2PanTau
histname = "ConstituentEt/ResolutionEt_ConstituentEt_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin];
obj = file->Get(histname.c_str());
if(obj) histogram = dynamic_cast<TH1F*>(obj);
histogram = dynamic_cast<TH1F*> (file->Get(histname.c_str()));
if(histogram){
m_resHists_CellBased2PanTau[ietaBin].push_back(histogram);
ATH_MSG_DEBUG("Adding hist: ");
......@@ -115,8 +115,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
//Get m_meanHists_CellBased2PanTau
histname = "ConstituentEt/MeanEt_ConstituentEt_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin];
obj = file->Get(histname.c_str());
if(obj) histogram = dynamic_cast<TH1F*>(obj);
histogram = dynamic_cast<TH1F*> (file->Get(histname.c_str()));
if(histogram){
m_meanHists_CellBased2PanTau[ietaBin].push_back(histogram);
ATH_MSG_DEBUG("Adding hist: ");
......@@ -138,24 +137,35 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
//_____________________________________________________________________________
StatusCode CombinedP4FromRecoTaus::execute(xAOD::TauJet& xTau) {
xAOD::TauJet* Tau = &xTau;
int tmpDecayModeProto;
xTau.panTauDetail(xAOD::TauJetParameters::PanTauDetails::PanTau_DecayModeProto, tmpDecayModeProto);
if(tmpDecayModeProto>xAOD::TauJetParameters::Mode_3pXn){
xTau.auxdecor<float>("pt_combined") = 1.;
int tmpDecayMode;
static SG::AuxElement::Decorator<float> decPtCombined("pt_combined");
static SG::AuxElement::Decorator<float> decEtaCombined("eta_combined");
static SG::AuxElement::Decorator<float> decPhiCombined("phi_combined");
static SG::AuxElement::Decorator<float> decMCombined("m_combined");
decPtCombined(xTau) = 0;
decEtaCombined(xTau) = 0;
decPhiCombined(xTau) = 0;
decMCombined(xTau) = 0;
xTau.panTauDetail(xAOD::TauJetParameters::PanTauDetails::PanTau_DecayMode, tmpDecayMode);
if(tmpDecayMode>xAOD::TauJetParameters::Mode_3pXn){
return StatusCode::SUCCESS;
}
if (xTau.ptPanTauCellBased() < 0)
{
ATH_MSG_DEBUG("ptPanTauCellBased is less than 0!");
return StatusCode::SUCCESS;
}
TLorentzVector substructureP4 = getCombinedP4(Tau);
// create xAOD variables and fill:
xTau.auxdecor<float>("pt_combined") = substructureP4.Pt();
// xTau.auxdecor<float>("eta_combined") = substructureP4.Eta();
// xTau.auxdecor<float>("phi_combined") = substructureP4.Phi();
// xTau.auxdecor<float>("m_combined") = substructureP4.M();
decPtCombined(xTau) = substructureP4.Pt();
decPtCombined(xTau) = substructureP4.Eta();
decPtCombined(xTau) = substructureP4.Phi();
decPtCombined(xTau) = substructureP4.M();
// move these to another file? :
m_weight = -1111.;
......@@ -164,30 +174,47 @@ StatusCode CombinedP4FromRecoTaus::execute(xAOD::TauJet& xTau) {
m_sigma_constituent = -1111.;
m_corrcoeff = -1111.;
if (m_addCalibrationResultVariables==true){
if (m_addCalibrationResultVariables){
substructureP4 = getCalibratedConstituentP4(Tau);
xTau.auxdecor<float>("pt_constituent") = substructureP4.Pt();
xTau.auxdecor<float>("eta_constituent") = substructureP4.Eta();
xTau.auxdecor<float>("phi_constituent") = substructureP4.Phi();
xTau.auxdecor<float>("m_constituent") = substructureP4.M();
static SG::AuxElement::Decorator<float> decPtConstituent("pt_constituent");
static SG::AuxElement::Decorator<float> decEtaConstituent("eta_constituent");
static SG::AuxElement::Decorator<float> decPhiConstituent("phi_constituent");
static SG::AuxElement::Decorator<float> decMConstituent("m_constituent");
decPtConstituent(xTau) = substructureP4.Pt();
decEtaConstituent(xTau) = substructureP4.Eta();
decPhiConstituent(xTau) = substructureP4.Phi();
decMConstituent(xTau) = substructureP4.M();
substructureP4 = getCalibratedTauRecP4(Tau);
xTau.auxdecor<float>("pt_tauRecCalibrated") = substructureP4.Pt();
xTau.auxdecor<float>("eta_tauRecCalibrated") = substructureP4.Eta();
xTau.auxdecor<float>("phi_tauRecCalibrated") = substructureP4.Phi();
xTau.auxdecor<float>("m_tauRecCalibrated") = substructureP4.M();
static SG::AuxElement::Decorator<float> decPtTauRecCalibrated("pt_tauRecCalibrated");
static SG::AuxElement::Decorator<float> decEtaTauRecCalibrated("eta_tauRecCalibrated");
static SG::AuxElement::Decorator<float> decPhiTauRecCalibrated("phi_tauRecCalibrated");
static SG::AuxElement::Decorator<float> decMTauRecCalibrated("m_tauRecCalibrated");
decPtTauRecCalibrated(xTau) = substructureP4.Pt();
decEtaTauRecCalibrated(xTau) = substructureP4.Eta();
decPhiTauRecCalibrated(xTau) = substructureP4.Phi();
decMTauRecCalibrated(xTau) = substructureP4.M();
substructureP4 = getWeightedP4(Tau);
xTau.auxdecor<float>("pt_weighted") = substructureP4.Pt();
xTau.auxdecor<float>("eta_weighted") = substructureP4.Eta();
xTau.auxdecor<float>("phi_weighted") = substructureP4.Phi();
xTau.auxdecor<float>("m_weighted") = substructureP4.M();
xTau.auxdecor<float>("weight_weighted") = m_weight;
xTau.auxdecor<float>("sigma_combined") = m_combined_res;
xTau.auxdecor<float>("sigma_tauRec") = m_sigma_tauRec;
xTau.auxdecor<float>("sigma_constituent") = m_sigma_constituent;
xTau.auxdecor<float>("correlation_coefficient") = m_corrcoeff;
static SG::AuxElement::Decorator<float> decPtWeighted("pt_weighted");
static SG::AuxElement::Decorator<float> decEtaWeighted("eta_weighted");
static SG::AuxElement::Decorator<float> decPhiWeighted("phi_weighted");
static SG::AuxElement::Decorator<float> decMWeighted("m_weighted");
decPtWeighted(xTau) = substructureP4.Pt();
decEtaWeighted(xTau) = substructureP4.Eta();
decPhiWeighted(xTau) = substructureP4.Phi();
decMWeighted(xTau) = substructureP4.M();
static SG::AuxElement::Decorator<float> decWeightWeighted("weight_weighted");
static SG::AuxElement::Decorator<float> decSigmaCombined("sigma_combined");
static SG::AuxElement::Decorator<float> decSigmaTaurec("sigma_tauRec");
static SG::AuxElement::Decorator<float> decSigmaConstituent("sigma_constituent");
static SG::AuxElement::Decorator<float> decCorrelationCoefficient("correlation_coefficient");
decWeightWeighted(xTau) = m_weight;
decSigmaCombined(xTau) = m_combined_res;
decSigmaTaurec(xTau) = m_sigma_tauRec;
decSigmaConstituent(xTau) = m_sigma_constituent;
decCorrelationCoefficient(xTau) = m_corrcoeff;
}
return StatusCode::SUCCESS;
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// local include(s)
#include "tauRecTools/HelperFunctions.h"
#include <TObjString.h>
#include <TObjArray.h>
#include <TFile.h>
#include <TTree.h>
#include <iostream>
#ifdef XAODTAU_VERSIONS_TAUJET_V3_H
xAOD::TauJetParameters::PanTauDetails PANTAU_DECAYMODE=xAOD::TauJetParameters::PanTau_DecayMode;
#else
xAOD::TauJetParameters::PanTauDetails PANTAU_DECAYMODE=xAOD::TauJetParameters::pantau_CellBasedInput_DecayMode;
#endif
//______________________________________________________________________________
void tauRecTools::createPi0Vectors(const xAOD::TauJet* xTau, std::vector<TLorentzVector>& vPi0s)
{
// reset the pi0s
vPi0s.clear();
// Since the PFO links as they come out of reconstruction, only correspond to
// calorimeter clusters, whereas we want the consts_pi0 vectors to correspond
// to real pi0s, we need to be careful to collect the PFOs correctly to pi0s
// for the cases where number of pi0s does not match to the decay mode:
size_t iNumPi0PFO = xTau->nPi0PFOs();
int iDecayMode = -1;
if (!(xTau->panTauDetail(PANTAU_DECAYMODE, iDecayMode)))
{
std::cerr << "Failed to retrieve panTauDetail decay mode\n";
return;
}
if (iDecayMode == xAOD::TauJetParameters::DecayMode::Mode_1p1n && iNumPi0PFO > 1)
{
// TODO: find out if the pi0 mass is defined elsewhere in atlas code!
// float fMassPi0 = 134.98;
float fMassPi0Squared = 18219.6004;
// combine both photons (with 0 mass from Pantau) to one pi0 vector:
const xAOD::PFO* xPfo1 = xTau->pi0PFO(0);
const xAOD::PFO* xPfo2 = xTau->pi0PFO(1);
vPi0s.push_back(xPfo1->p4() + xPfo2->p4());
// re-set the mass to one pi0:
double dNewMomentum = std::sqrt(vPi0s[0].E() * vPi0s[0].E() - fMassPi0Squared);
vPi0s[0].SetPxPyPzE(vPi0s[0].Vect().Unit().Px() * dNewMomentum,
vPi0s[0].Vect().Unit().Py() * dNewMomentum,
vPi0s[0].Vect().Unit().Pz() * dNewMomentum,
vPi0s[0].E());
}
else if (iDecayMode == xAOD::TauJetParameters::DecayMode::Mode_1pXn && iNumPi0PFO == 1)
{
// make a single pi0 from a PFO that contains two pi0s:
const xAOD::PFO* xPfo = xTau->pi0PFO(0);
// add the 2-pi0 vector preliminarily to the pi0vector:
vPi0s.push_back(xPfo->p4());
// re-set the mass back to one pi0:
double dNewMomentum = std::sqrt(vPi0s[0].E() * vPi0s[0].E() - vPi0s[0].M() / 2. * vPi0s[0].M() / 2.);
vPi0s[0].SetVectM(vPi0s[0].Vect() * (dNewMomentum / vPi0s[0].P()), vPi0s[0].M() / 2.);
// create another pi0 from the same vector:
vPi0s.push_back(vPi0s[0]);
}
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(xTau->pi0PFO(iPFO)->p4());
}
}
}
xAOD::TauTrack::TrackFlagType tauRecTools::isolateClassifiedBits(xAOD::TauTrack::TrackFlagType flag){
static const int flagsize=sizeof(flag)*8;
flag=flag<<(flagsize-xAOD::TauJetParameters::classifiedFake-1);
flag=flag>>(flagsize-xAOD::TauJetParameters::classifiedCharged+1);
return flag;
}
//bool sortTracks(xAOD::TauTrack* xTrack1, xAOD::TauTrack* xTrack2)
bool tauRecTools::sortTracks(const ElementLink<xAOD::TauTrackContainer> &l1, const ElementLink<xAOD::TauTrackContainer> &l2)
{
//should we be safe and ask if the links are available?
const xAOD::TauTrack* xTrack1 = *l1;
const xAOD::TauTrack* xTrack2 = *l2;
//return classified charged, then isolation (wide tracks), else by pt
xAOD::TauTrack::TrackFlagType f1 = isolateClassifiedBits(xTrack1->flagSet());
xAOD::TauTrack::TrackFlagType f2 = isolateClassifiedBits(xTrack2->flagSet());
if(f1==f2)
return xTrack1->pt()>xTrack2->pt();
return f1<f2;
//this somehow causes a crash
/* static uint16_t flag1 = xTrack1->flagSet() >> (xAOD::TauJetParameters::classifiedCharged - 1); */
/* static uint16_t flag2 = xTrack2->flagSet() >> (uint16_t(xAOD::TauJetParameters::classifiedCharged) - 1); */
/* return (flag1<flag2) || // sort by type, true tracks first */
/* ((flag1==flag2) && (xTrack1->pt()>xTrack2->pt())); // sort by pt if equal types */
}
//________________________________________________________________________________
std::vector<TString> tauRecTools::parseString(const TString& str, const TString& delim/*=","*/){
std::vector<TString> parsed_strings;
TObjArray* varList_ar = str.Tokenize(delim);
for(int i = 0; i != varList_ar->GetEntries(); ++i){
TString var = dynamic_cast<TObjString*> (varList_ar->At(i))->String();
if(var.Length()==0) continue;
parsed_strings.push_back(var);
}
delete varList_ar;
return parsed_strings;
}
//________________________________________________________________________________
std::vector<TString> tauRecTools::parseStringMVAUtilsBDT(const TString& str, const TString& delim/*=","*/){
std::vector<TString> parsed_strings = parseString(str, delim);
for( TString& str : parsed_strings ){
str.ReplaceAll(" ", "");
if(str.Contains(":=")){
str=str(str.Index(":=")+2, str.Length()-str.Index(":=")-2);
}
}
return parsed_strings;
}
//________________________________________________________________________________
MVAUtils::BDT* tauRecTools::configureMVABDT( std::map<TString, float*> &availableVars, const TString& weightFile){
TFile* fBDT = TFile::Open( weightFile );
if(!fBDT){
std::cerr << "ERROR Cannot find tau input BDT file: " << weightFile << std::endl;
return 0;
}
TTree* tBDT = dynamic_cast<TTree*> (fBDT->Get("BDT"));
if(!tBDT){
std::cerr << "ERROR Cannot find tau input BDT tree" << std::endl;
return 0;
}
MVAUtils::BDT* reader = new MVAUtils::BDT(tBDT);
std::vector<float*> vars;
//parsing of variables done here from TNamed object
TNamed* n_varList = dynamic_cast<TNamed*> (fBDT->Get("varList"));
std::vector<TString> varList_ar = tauRecTools::parseStringMVAUtilsBDT(n_varList->GetTitle());
for(const TString& str : varList_ar){
if(str.Length()==0) continue;
std::map<TString, float*>::iterator itr = availableVars.find(str);
if(itr==availableVars.end()){
std::cerr << "ERROR Variable : " << str << " is not available" << std::endl;;
return 0;
}
vars.push_back( itr->second );
}
reader->SetPointers( vars );
delete n_varList;
delete fBDT;
return reader;
}
......@@ -14,6 +14,7 @@
#include "tauRecTools/MvaTESEvaluator.h"
#include "tauRecTools/TauTrackClassifier.h"
#include "tauRecTools/CombinedP4FromRecoTaus.h"
#include "tauRecTools/TauChargedPFOCreator.h"
#ifdef __CINT__
......@@ -37,8 +38,9 @@
#pragma link C++ class ITauToolBase+;
#pragma link C++ class MvaTESVariableDecorator+;
#pragma link C++ class MvaTESEvaluator+;
#pragma link C++ class TauTrackClassifier+;
#pragma link C++ class TrackMVABDT+;
#pragma link C++ class tauRecTools::TauTrackClassifier+;
#pragma link C++ class tauRecTools::TrackMVABDT+;
#pragma link C++ class CombinedP4FromRecoTaus+;
#pragma link C++ class TauChargedPFOCreator+;
#endif
......@@ -4,6 +4,12 @@
// local include(s)
#include "tauRecTools/MvaTESEvaluator.h"
#include "tauRecTools/HelperFunctions.h"
#include "TFile.h"
#include "TTree.h"
#include <vector>
// tools include(s)
......@@ -12,8 +18,25 @@
//_____________________________________________________________________________
MvaTESEvaluator::MvaTESEvaluator(const std::string& name)
: TauRecToolBase(name)
, reader(0)
, mu(0)
, nVtx(0)
, center_lambda(0)
, first_eng_dens(0)
, second_lambda(0)
, presampler_frac(0)
, em_probability(0)
, interpolPt(0)
, LC_D_interpolPt(0)
, pantau_D_interpolPt(0)
, seedCalo_eta(0)
, nTracks(0)
, nPi0PFOs(0)
, PFOEngRelDiff(0)
, nMuSeg(0)
, truthPtVis(0)
{
declareProperty( "WeightFileName", m_sWeightFileName = "LC.pantau.interpolPt250GeV_mediumTaus_BDTG.weights.xml" );
declareProperty( "WeightFileName", m_sWeightFileName = "LC.pantau.interpolPt250GeV_mediumTaus_BDTG.weights.root" );
//BDT trained on medium taus: "LC.pantau.interpolPt250GeV_mediumTaus_BDTG.weights.xml"
//BDT trained on all taus: "LC.pantau.interpolPt250GeV_allTaus_BDTG.weights.xml"
}
......@@ -26,40 +49,37 @@ MvaTESEvaluator::~MvaTESEvaluator()
//_____________________________________________________________________________
StatusCode MvaTESEvaluator::initialize(){
// This loads the TMVA library
TMVA::Tools::Instance();
// Create the Reader object
reader = new TMVA::Reader( "!Color:!Silent" );
// Declare input variables to the reader
reader->AddVariable( "EventInfoAux.averageInteractionsPerCrossing" , &mu );
reader->AddVariable( "TauJetsAuxDyn.nVtx" , &nVtx );
m_availableVars.insert( std::make_pair("EventInfoAux.averageInteractionsPerCrossing", &mu) );
m_availableVars.insert( std::make_pair("TauJetsAuxDyn.nVtx", &nVtx) );
reader->AddVariable( "TauJetsAuxDyn.center_lambda" , &center_lambda );
reader->AddVariable( "TauJetsAuxDyn.first_eng_dens" , &first_eng_dens );
reader->AddVariable( "TauJetsAuxDyn.second_lambda" , &second_lambda );
reader->AddVariable( "TauJetsAuxDyn.presampler_frac" , &presampler_frac );
reader->AddVariable( "TauJetsAuxDyn.em_probability" , &em_probability );
m_availableVars.insert( std::make_pair("TauJetsAuxDyn.center_lambda", &center_lambda) );
m_availableVars.insert( std::make_pair("TauJetsAuxDyn.first_eng_dens", &first_eng_dens) );
m_availableVars.insert( std::make_pair("TauJetsAuxDyn.second_lambda", &second_lambda) );
m_availableVars.insert( std::make_pair("TauJetsAuxDyn.presampler_frac", &presampler_frac) );
m_availableVars.insert( std::make_pair("TauJetsAuxDyn.em_probability", &em_probability) );
reader->AddVariable( "TauJetsAuxDyn.LC_pantau_interpolPt" , &interpolPt );
reader->AddVariable( "TauJetsAux.LC_TES_precalib/TauJetsAuxDyn.LC_pantau_interpolPt" ,
&LC_D_interpolPt );
reader->AddVariable( "TauJetsAux.ptPanTauCellBased/TauJetsAuxDyn.LC_pantau_interpolPt" ,
&pantau_D_interpolPt );
reader->AddVariable( "TauJetsAux.seedCalo_eta" , &seedCalo_eta );
m_availableVars.insert( std::make_pair("TauJetsAuxDyn.LC_pantau_interpolPt", &interpolPt) );
m_availableVars.insert( std::make_pair("TauJetsAux.LC_TES_precalib/TauJetsAuxDyn.LC_pantau_interpolPt", &LC_D_interpolPt) );
m_availableVars.insert( std::make_pair("TauJetsAux.ptPanTauCellBased/TauJetsAuxDyn.LC_pantau_interpolPt", &pantau_D_interpolPt) );
m_availableVars.insert( std::make_pair("TauJetsAux.seedCalo_eta", &seedCalo_eta) );
reader->AddVariable( "TauJetsAuxDyn.nTracks_TauRec" , &nTracks );
reader->AddVariable( "TauJetsAuxDyn.nPi0PFOs" , &nPi0PFOs );
reader->AddVariable( "TauJetsAuxDyn.PFOEngRelDiff" , &PFOEngRelDiff );
m_availableVars.insert( std::make_pair("TauJetsAuxDyn.nTracks_TauRec", &nTracks) );
m_availableVars.insert( std::make_pair("TauJetsAuxDyn.nPi0PFOs", &nPi0PFOs) );
m_availableVars.insert( std::make_pair("TauJetsAuxDyn.PFOEngRelDiff", &PFOEngRelDiff) );
reader->AddVariable( "TauJetsAuxDyn.GhostMuonSegmentCount" , &nMuSeg );
m_availableVars.insert( std::make_pair("TauJetsAuxDyn.GhostMuonSegmentCount", &nMuSeg) );
// Spectator variables declared in the training have to be added to the reader, too
reader->AddSpectator( "TauJetsAuxDyn.truthPtVis" , &truthPtVis );
m_availableVars.insert( std::make_pair("TauJetsAuxDyn.truthPtVis", &truthPtVis) );
std::string weightFile = find_file(m_sWeightFileName);
reader->BookMVA( "BDTG", weightFile.c_str() );
reader = tauRecTools::configureMVABDT( m_availableVars, weightFile.c_str() );
if(reader==0) {
ATH_MSG_FATAL("Couldn't configure MVA");
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
......@@ -100,7 +120,7 @@ StatusCode MvaTESEvaluator::execute(xAOD::TauJet& xTau){
// "Retrieve" spectator variables
truthPtVis = 0.;
float ptMVA = float( interpolPt * reader->EvaluateRegression( 0, "BDTG" ) );
float ptMVA = float( interpolPt * reader->GetResponse() );
if(ptMVA<1) ptMVA=1;
xTau.setP4(xAOD::TauJetParameters::FinalCalib, ptMVA, xTau.etaPanTauCellBased(), xTau.phiPanTauCellBased(), 0);
......
......@@ -67,7 +67,7 @@ StatusCode MvaTESVariableDecorator::execute(xAOD::TauJet& xTau) {
xAOD::JetConstituentVector vec = jet_seed->getConstituents();