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 # Package: tauRecTools
################################################################################ ################################################################################
...@@ -6,29 +7,31 @@ ...@@ -6,29 +7,31 @@
atlas_subdir( tauRecTools ) atlas_subdir( tauRecTools )
# Declare the package's dependencies: # Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC atlas_depends_on_subdirs(
PUBLIC
Calorimeter/CaloUtils Calorimeter/CaloUtils
Control/AthLinks Control/AthLinks
Control/AthToolSupport/AsgTools Control/AthToolSupport/AsgTools
Control/CxxUtils Control/CxxUtils
Event/xAOD/xAODCaloEvent
Event/xAOD/xAODEventInfo Event/xAOD/xAODEventInfo
Event/xAOD/xAODPFlow
Event/xAOD/xAODTau Event/xAOD/xAODTau
Event/xAOD/xAODTracking Event/xAOD/xAODTracking
Reconstruction/Particle
PRIVATE PRIVATE
Calorimeter/CaloInterface Calorimeter/CaloInterface
Control/AthContainers Control/AthContainers
Event/FourMomUtils Event/FourMomUtils
Event/NavFourMom Event/NavFourMom
Event/xAOD/xAODCaloEvent
Event/xAOD/xAODJet Event/xAOD/xAODJet
Event/xAOD/xAODPFlow
GaudiKernel GaudiKernel
InnerDetector/InDetRecTools/InDetRecToolInterfaces InnerDetector/InDetRecTools/InDetRecToolInterfaces
InnerDetector/InDetRecTools/InDetTrackSelectionTool InnerDetector/InDetRecTools/InDetTrackSelectionTool
Reconstruction/Jet/JetEDM Reconstruction/Jet/JetEDM
Reconstruction/Particle
Reconstruction/RecoTools/ITrackToVertex Reconstruction/RecoTools/ITrackToVertex
Reconstruction/RecoTools/RecoToolInterfaces Reconstruction/RecoTools/RecoToolInterfaces
Reconstruction/MVAUtils
Tools/PathResolver Tools/PathResolver
Tracking/TrkEvent/TrkLinks Tracking/TrkEvent/TrkLinks
Tracking/TrkEvent/TrkParametersIdentificationHelpers Tracking/TrkEvent/TrkParametersIdentificationHelpers
...@@ -40,24 +43,30 @@ atlas_depends_on_subdirs( PUBLIC ...@@ -40,24 +43,30 @@ atlas_depends_on_subdirs( PUBLIC
Tracking/TrkVertexFitter/TrkVxEdmCnv ) Tracking/TrkVertexFitter/TrkVxEdmCnv )
# External dependencies: # External dependencies:
find_package( Boost COMPONENTS filesystem thread system ) find_package( Boost )
find_package( ROOT COMPONENTS TMVA Core Tree MathCore Hist RIO pthread ) find_package( ROOT COMPONENTS Core Tree Hist RIO )
# Component(s) in the package: # Component(s) in the package:
atlas_add_library( tauRecToolsLib atlas_add_library( tauRecToolsLib
src/*.cxx tauRecTools/*.h Root/*.cxx
Root/*.cxx
PUBLIC_HEADERS tauRecTools PUBLIC_HEADERS tauRecTools
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} AthLinks AsgTools CxxUtils xAODEventInfo xAODTau xAODTracking CaloUtilsLib TrkVertexFittersLib TrkVxEdmCnvLib LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} AthLinks AsgTools
PRIVATE_LINK_LIBRARIES AthContainers FourMomUtils NavFourMom xAODCaloEvent xAODJet xAODPFlow GaudiKernel InDetRecToolInterfaces JetEDM Particle ITrackToVertex RecoToolInterfaces PathResolver TrkLinks TrkParametersIdentificationHelpers TrkTrackSummary VxVertex TrkToolInterfaces TrkVertexFitterInterfaces ) CxxUtils xAODCaloEvent xAODEventInfo xAODPFlow xAODTau xAODTracking
CaloUtilsLib Particle
PRIVATE_LINK_LIBRARIES FourMomUtils xAODJet PathResolver MVAUtils )
atlas_add_component( tauRecTools atlas_add_component( tauRecTools
src/components/*.cxx src/*.h src/*.cxx src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} 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: # Install files from the package:
atlas_install_runtime( share/*.xml ) atlas_install_runtime( share/*.xml )
atlas_install_data( share/* ) atlas_install_data( share/* )
...@@ -21,7 +21,13 @@ ...@@ -21,7 +21,13 @@
//_____________________________________________________________________________ //_____________________________________________________________________________
CombinedP4FromRecoTaus::CombinedP4FromRecoTaus(const std::string& name) : 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( "WeightFileName", m_sWeightFileName = "");
declareProperty( "addCalibrationResultVariables", m_addCalibrationResultVariables=false); declareProperty( "addCalibrationResultVariables", m_addCalibrationResultVariables=false);
...@@ -42,8 +48,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() { ...@@ -42,8 +48,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
std::string calibFilePath = find_file(m_sWeightFileName); std::string calibFilePath = find_file(m_sWeightFileName);
TFile * file = TFile::Open(calibFilePath.c_str(), "READ"); TFile * file = TFile::Open(calibFilePath.c_str(), "READ");
TH1F* histogram; TH1F* histogram(0);
TObject* obj;
std::string histname=""; std::string histname="";
...@@ -55,14 +60,12 @@ StatusCode CombinedP4FromRecoTaus::initialize() { ...@@ -55,14 +60,12 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
//Get m_resHists_tauRec //Get m_resHists_tauRec
//histname="ConstituentEt/CorrelationCoeff_ConstituentEt_" + m_modeNames[imode]; //histname="ConstituentEt/CorrelationCoeff_ConstituentEt_" + m_modeNames[imode];
histname="CorrelationCoeff_tauRec_" + m_modeNames[imode]; histname="CorrelationCoeff_tauRec_" + m_modeNames[imode];
obj = file->Get(histname.c_str()); histogram = dynamic_cast<TH1F*> (file->Get(histname.c_str()));
if(obj) histogram = dynamic_cast<TH1F*>(obj);
if(histogram){ if(histogram){
m_correlationHists.push_back(histogram); m_correlationHists.push_back(histogram);
ATH_MSG_DEBUG("Adding corr hist: "); ATH_MSG_DEBUG("Adding corr hist: ");
//histogram->Print("all"); //histogram->Print("all");
} }
} }
...@@ -76,8 +79,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() { ...@@ -76,8 +79,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
//Get m_resHists_tauRec //Get m_resHists_tauRec
histname = "tauRec/ResolutionEt_tauRec_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin]; histname = "tauRec/ResolutionEt_tauRec_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin];
obj = file->Get(histname.c_str()); histogram = dynamic_cast<TH1F*> (file->Get(histname.c_str()));
if(obj) histogram = dynamic_cast<TH1F*>(obj);
if(histogram){ if(histogram){
m_resHists_tauRec[ietaBin].push_back(histogram); m_resHists_tauRec[ietaBin].push_back(histogram);
ATH_MSG_DEBUG("Adding hist: "); ATH_MSG_DEBUG("Adding hist: ");
...@@ -89,8 +91,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() { ...@@ -89,8 +91,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
//Get m_meanHists_tauRec //Get m_meanHists_tauRec
histname = "tauRec/MeanEt_tauRec_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin]; histname = "tauRec/MeanEt_tauRec_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin];
obj = file->Get(histname.c_str()); histogram = dynamic_cast<TH1F*> (file->Get(histname.c_str()));
if(obj) histogram = dynamic_cast<TH1F*>(obj);
if(histogram) { if(histogram) {
m_meanHists_tauRec[ietaBin].push_back(histogram); m_meanHists_tauRec[ietaBin].push_back(histogram);
ATH_MSG_DEBUG("Adding hist: "); ATH_MSG_DEBUG("Adding hist: ");
...@@ -102,8 +103,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() { ...@@ -102,8 +103,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
//Get m_resHists_CellBased2PanTau //Get m_resHists_CellBased2PanTau
histname = "ConstituentEt/ResolutionEt_ConstituentEt_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin]; histname = "ConstituentEt/ResolutionEt_ConstituentEt_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin];
obj = file->Get(histname.c_str()); histogram = dynamic_cast<TH1F*> (file->Get(histname.c_str()));
if(obj) histogram = dynamic_cast<TH1F*>(obj);
if(histogram){ if(histogram){
m_resHists_CellBased2PanTau[ietaBin].push_back(histogram); m_resHists_CellBased2PanTau[ietaBin].push_back(histogram);
ATH_MSG_DEBUG("Adding hist: "); ATH_MSG_DEBUG("Adding hist: ");
...@@ -115,8 +115,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() { ...@@ -115,8 +115,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
//Get m_meanHists_CellBased2PanTau //Get m_meanHists_CellBased2PanTau
histname = "ConstituentEt/MeanEt_ConstituentEt_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin]; histname = "ConstituentEt/MeanEt_ConstituentEt_" + m_modeNames[imode] + "_" + m_etaBinNames[ietaBin];
obj = file->Get(histname.c_str()); histogram = dynamic_cast<TH1F*> (file->Get(histname.c_str()));
if(obj) histogram = dynamic_cast<TH1F*>(obj);
if(histogram){ if(histogram){
m_meanHists_CellBased2PanTau[ietaBin].push_back(histogram); m_meanHists_CellBased2PanTau[ietaBin].push_back(histogram);
ATH_MSG_DEBUG("Adding hist: "); ATH_MSG_DEBUG("Adding hist: ");
...@@ -138,24 +137,35 @@ StatusCode CombinedP4FromRecoTaus::initialize() { ...@@ -138,24 +137,35 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
//_____________________________________________________________________________ //_____________________________________________________________________________
StatusCode CombinedP4FromRecoTaus::execute(xAOD::TauJet& xTau) { StatusCode CombinedP4FromRecoTaus::execute(xAOD::TauJet& xTau) {
xAOD::TauJet* Tau = &xTau; xAOD::TauJet* Tau = &xTau;
int tmpDecayModeProto; int tmpDecayMode;
xTau.panTauDetail(xAOD::TauJetParameters::PanTauDetails::PanTau_DecayModeProto, tmpDecayModeProto); static SG::AuxElement::Decorator<float> decPtCombined("pt_combined");
if(tmpDecayModeProto>xAOD::TauJetParameters::Mode_3pXn){ static SG::AuxElement::Decorator<float> decEtaCombined("eta_combined");
xTau.auxdecor<float>("pt_combined") = 1.; 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; return StatusCode::SUCCESS;
} }
if (xTau.ptPanTauCellBased() < 0)
{
ATH_MSG_DEBUG("ptPanTauCellBased is less than 0!");
return StatusCode::SUCCESS;
}
TLorentzVector substructureP4 = getCombinedP4(Tau); TLorentzVector substructureP4 = getCombinedP4(Tau);
// create xAOD variables and fill: // create xAOD variables and fill:
xTau.auxdecor<float>("pt_combined") = substructureP4.Pt(); decPtCombined(xTau) = substructureP4.Pt();
// xTau.auxdecor<float>("eta_combined") = substructureP4.Eta(); decPtCombined(xTau) = substructureP4.Eta();
// xTau.auxdecor<float>("phi_combined") = substructureP4.Phi(); decPtCombined(xTau) = substructureP4.Phi();
// xTau.auxdecor<float>("m_combined") = substructureP4.M(); decPtCombined(xTau) = substructureP4.M();
// move these to another file? : // move these to another file? :
m_weight = -1111.; m_weight = -1111.;
...@@ -164,30 +174,47 @@ StatusCode CombinedP4FromRecoTaus::execute(xAOD::TauJet& xTau) { ...@@ -164,30 +174,47 @@ StatusCode CombinedP4FromRecoTaus::execute(xAOD::TauJet& xTau) {
m_sigma_constituent = -1111.; m_sigma_constituent = -1111.;
m_corrcoeff = -1111.; m_corrcoeff = -1111.;
if (m_addCalibrationResultVariables==true){ if (m_addCalibrationResultVariables){
substructureP4 = getCalibratedConstituentP4(Tau); substructureP4 = getCalibratedConstituentP4(Tau);
xTau.auxdecor<float>("pt_constituent") = substructureP4.Pt(); static SG::AuxElement::Decorator<float> decPtConstituent("pt_constituent");
xTau.auxdecor<float>("eta_constituent") = substructureP4.Eta(); static SG::AuxElement::Decorator<float> decEtaConstituent("eta_constituent");
xTau.auxdecor<float>("phi_constituent") = substructureP4.Phi(); static SG::AuxElement::Decorator<float> decPhiConstituent("phi_constituent");
xTau.auxdecor<float>("m_constituent") = substructureP4.M(); 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); substructureP4 = getCalibratedTauRecP4(Tau);
xTau.auxdecor<float>("pt_tauRecCalibrated") = substructureP4.Pt(); static SG::AuxElement::Decorator<float> decPtTauRecCalibrated("pt_tauRecCalibrated");
xTau.auxdecor<float>("eta_tauRecCalibrated") = substructureP4.Eta(); static SG::AuxElement::Decorator<float> decEtaTauRecCalibrated("eta_tauRecCalibrated");
xTau.auxdecor<float>("phi_tauRecCalibrated") = substructureP4.Phi(); static SG::AuxElement::Decorator<float> decPhiTauRecCalibrated("phi_tauRecCalibrated");
xTau.auxdecor<float>("m_tauRecCalibrated") = substructureP4.M(); 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); substructureP4 = getWeightedP4(Tau);
xTau.auxdecor<float>("pt_weighted") = substructureP4.Pt(); static SG::AuxElement::Decorator<float> decPtWeighted("pt_weighted");
xTau.auxdecor<float>("eta_weighted") = substructureP4.Eta(); static SG::AuxElement::Decorator<float> decEtaWeighted("eta_weighted");
xTau.auxdecor<float>("phi_weighted") = substructureP4.Phi(); static SG::AuxElement::Decorator<float> decPhiWeighted("phi_weighted");
xTau.auxdecor<float>("m_weighted") = substructureP4.M(); static SG::AuxElement::Decorator<float> decMWeighted("m_weighted");
decPtWeighted(xTau) = substructureP4.Pt();
xTau.auxdecor<float>("weight_weighted") = m_weight; decEtaWeighted(xTau) = substructureP4.Eta();
xTau.auxdecor<float>("sigma_combined") = m_combined_res; decPhiWeighted(xTau) = substructureP4.Phi();
xTau.auxdecor<float>("sigma_tauRec") = m_sigma_tauRec; decMWeighted(xTau) = substructureP4.M();
xTau.auxdecor<float>("sigma_constituent") = m_sigma_constituent;
xTau.auxdecor<float>("correlation_coefficient") = m_corrcoeff; 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; 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 @@ ...@@ -14,6 +14,7 @@
#include "tauRecTools/MvaTESEvaluator.h" #include "tauRecTools/MvaTESEvaluator.h"
#include "tauRecTools/TauTrackClassifier.h" #include "tauRecTools/TauTrackClassifier.h"
#include "tauRecTools/CombinedP4FromRecoTaus.h" #include "tauRecTools/CombinedP4FromRecoTaus.h"
#include "tauRecTools/TauChargedPFOCreator.h"
#ifdef __CINT__ #ifdef __CINT__
...@@ -37,8 +38,9 @@ ...@@ -37,8 +38,9 @@
#pragma link C++ class ITauToolBase+; #pragma link C++ class ITauToolBase+;
#pragma link C++ class MvaTESVariableDecorator+; #pragma link C++ class MvaTESVariableDecorator+;
#pragma link C++ class MvaTESEvaluator+; #pragma link C++ class MvaTESEvaluator+;
#pragma link C++ class TauTrackClassifier+; #pragma link C++ class tauRecTools::TauTrackClassifier+;
#pragma link C++ class TrackMVABDT+; #pragma link C++ class tauRecTools::TrackMVABDT+;
#pragma link C++ class CombinedP4FromRecoTaus+; #pragma link C++ class CombinedP4FromRecoTaus+;
#pragma link C++ class TauChargedPFOCreator+;
#endif #endif
...@@ -4,6 +4,12 @@ ...@@ -4,6 +4,12 @@
// local include(s) // local include(s)
#include "tauRecTools/MvaTESEvaluator.h" #include "tauRecTools/MvaTESEvaluator.h"
#include "tauRecTools/HelperFunctions.h"
#include "TFile.h"
#include "TTree.h"
#include <vector>
// tools include(s) // tools include(s)
...@@ -12,8 +18,25 @@ ...@@ -12,8 +18,25 @@
//_____________________________________________________________________________ //_____________________________________________________________________________
MvaTESEvaluator::MvaTESEvaluator(const std::string& name) MvaTESEvaluator::MvaTESEvaluator(const std::string& name)
: TauRecToolBase(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)