From 692a431d558a27cf2320e34b7f50c73bd2a2370f Mon Sep 17 00:00:00 2001
From: Dirk Uwe Duschinger <dirk.duschinger@cern.ch>
Date: Fri, 20 May 2016 13:47:10 +0200
Subject: [PATCH] readded initializeEvent functions in wrapper tools
 (DerivationFrameworkTau-00-01-36)

	* Modified for MVA TES
	* Corrected ChangeLog
	* Tagged as DerivationFrameworkTau-00-01-35

2016-05-18 Justin Griffiths <justin.adam.griffiths@cern.ch>

	* Modified TauPVTrkSelectionTool.cxx, compat b/w TAT and TauJet_v3
	* Tagged as DerivationFrameworkTau-00-01-31

2016-05-12 Darren Temple <dtemple@cern.ch>

	* TAUPExtraContent.py added further L1Topo and FTK containers to TAUP3
	* Corrected and completed ChangeLog
	* Tagged as DerivationFrameworkTau-00-01-30

2016-05-02 Justin Griffiths <justin.adam.griffiths@cern.ch>

	* Modified TauPVTrkSelectionTool.cxx
	* Tagged as DerivationFrameworkTau-00-01-29
...
(Long ChangeLog diff - truncated)


Former-commit-id: 9822123180747dd9a7a83535034649c473c4a0e3
---
 .../python/TAUPExtraContent.py                | 20 +++++++++++++++++--
 .../python/TauJetsCPContent.py                |  9 +++++++++
 .../python/TauMVATESContent.py                | 17 ++++++++++++++++
 .../DerivationFrameworkTau/share/TAUP1.py     |  9 +++++++++
 .../DerivationFrameworkTau/share/TAUP3.py     |  9 +++++++++
 .../src/TauPVTrkSelectionTool.cxx             | 10 ++++++++--
 .../src/TauSelectionWrapper.cxx               |  1 +
 7 files changed, 71 insertions(+), 4 deletions(-)
 create mode 100644 PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TauJetsCPContent.py
 create mode 100644 PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TauMVATESContent.py

diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TAUPExtraContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TAUPExtraContent.py
index 0c7c279db854b..0d3df156d6694 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TAUPExtraContent.py
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TAUPExtraContent.py
@@ -122,7 +122,7 @@ ExtraContentTruthTAUP3                           =   ExtraContentPhotonsTruth
 
 ExtraContainersElectrons                         = ["ForwardElectrons"]
 
-ExtraContainersJets                              = []
+ExtraContainersJets                              = ["CaloCalTopoClusters"]
 
 ExtraContainersTrigger                           = ["LVL1EmTauRoIs",
 #
@@ -161,7 +161,23 @@ ExtraContainersTAUP2                             =   ExtraContainersTrigger
 ExtraContainersTAUP3                             =   ExtraContainersElectrons                                               \
                                                    + ExtraContainersJets                                                    \
                                                    + ExtraContainersTrigger                                                 \
-                                                   + ["HLT_xAOD__TauJetContainer_TrigTauRecMerged"]
+                                                   + ["HLT_xAOD__TauJetContainer_TrigTauRecMerged",
+#
+                                                      "HLT_xAOD__MuonRoIContainer_L1TopoMuon",
+#
+                                                      "HLT_xAOD__JetRoIContainer_L1TopoJet",
+#
+                                                      "HLT_xAOD__TrigCompositeContainer_L1TopoMET",
+                                                      "HLT_xAOD__TrigCompositeContainer_L1TopoComposite",
+#
+                                                      "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Tau_FTK",
+                                                      "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Tau_FTK_IDTrig",
+                                                      "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Tau_FTKRefit",
+                                                      "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Tau_FTKRefit_IDTrig",
+#
+                                                      "HLT_xAOD__VertexContainer_PrimVertexFTK",
+                                                      "HLT_xAOD__VertexContainer_PrimVertexFTKRaw",
+                                                      "HLT_xAOD__VertexContainer_PrimVertexFTKRefit"]
 
 ExtraContainersTruthTAUP1                        = ["TruthEvents",
                                                     "TruthParticles",
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TauJetsCPContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TauJetsCPContent.py
new file mode 100644
index 0000000000000..14290fb80ba30
--- /dev/null
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TauJetsCPContent.py
@@ -0,0 +1,9 @@
+# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+
+TauJetsCPContent = [
+"AntiKt4LCTopoJets",
+"InDetTrackParticles",
+"InDetTrackParticlesAux.phi.vertexLink.theta.qOverP.truthParticleLink.truthMatchProbability",
+"TauJets",
+"TauJetsAux.pt.eta.phi.m.trackLinks.wideTrackLinks.otherTrackLinks.jetLink.vertexLink.secondaryVertexLink.hadronicPFOLinks.shotPFOLinks.chargedPFOLinks.neutralPFOLinks.pi0PFOLinks.protoChargedPFOLinks.protoNeutralPFOLinks.protoPi0PFOLinks.charge.isTauFlags.BDTJetScore.BDTEleScore.conversionTrackLinks.charged_PFOLinks.neutral_PFOLinks.pi0_PFOLinks.cellBased_Charged_PFOLinks.cellBased_Neutral_PFOLinks.cellBased_Pi0_PFOLinks.eflowRec_Charged_PFOLinks.eflowRec_Neutral_PFOLinks.eflowRec_Pi0_PFOLinks.shot_PFOLinks"
+]
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TauMVATESContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TauMVATESContent.py
new file mode 100644
index 0000000000000..3c229362f7174
--- /dev/null
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TauMVATESContent.py
@@ -0,0 +1,17 @@
+# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+
+
+from DerivationFrameworkTau.TauJetsCPContent import TauJetsCPContent as taucore
+
+TauMVATESContent=taucore
+TauMVATESContent += [ 
+    "TauJets",
+    "TauJetsAux.ptDetectorAxis.phiDetectorAxis.etaDetectorAxis.mDetectorAxis.ptPanTauCellBased.etaPanTauCellBased.phiPanTauCellBased.mPanTauCellBased.pantau_CellBasedInput_DecayMode.pantau_CellBasedInput_DecayModeProto",
+    "TauNeutralParticleFlowObjects",
+    "TauNeutralParticleFlowObjectsAux.pt.eta.phi.m",
+    "TauChargedParticleFlowObjects",
+    "TauChargedParticleFlowObjectsAux.pt.eta.phi.m",
+    "CaloCalTopoClusters",
+    "CaloCalTopoClustersAux.CENTER_LAMBDA.FIRST_ENG_DENS.EM_PROBABILITY.SECOND_LAMBDA.e_sampl.eta0.phi0.rawE.rawEta.rawPhi.rawM.altE.altEta.altPhi.altM.calE.calEta.calPhi.calM",
+                      ]
+
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP1.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP1.py
index a188d365c461a..9792549d9e7f2 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP1.py
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP1.py
@@ -50,6 +50,14 @@ TAUP1JetTPThinningTool                           = DerivationFramework__JetTrack
                                                      ApplyAnd                  = True)
 ToolSvc                                         += TAUP1JetTPThinningTool
 
+from DerivationFrameworkCalo.DerivationFrameworkCaloConf import DerivationFramework__CaloClusterThinning
+TAUP1CaloClusterThinning                         = DerivationFramework__CaloClusterThinning(
+                                                     name                      = "TAUP1ClusterThinning",
+                                                     ThinningService           = TAUP1ThinningHelper.ThinningSvc(),
+                                                     SGKey                     = "TauJets",
+                                                     TopoClCollectionSGKey     = "CaloCalTopoClusters")
+ToolSvc                                         += TAUP1CaloClusterThinning
+
 # Tracks associated with electrons
 from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning
 TAUP1ElectronTPThinningTool                      = DerivationFramework__EgammaTrackParticleThinning(
@@ -108,6 +116,7 @@ DerivationFrameworkJob                          += CfgMgr.DerivationFramework__D
                                                      SkimmingTools             = [TAUP1SkimmingTool],
                                                      ThinningTools             = [TAUP1MetTPThinningTool,
                                                                                   TAUP1JetTPThinningTool,
+                                                                                  TAUP1CaloClusterThinning,
                                                                                   TAUP1ElectronTPThinningTool,
                                                                                   TAUP1MuonTPThinningTool,
                                                                                   TAUP1TauTPThinningTool],
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP3.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP3.py
index 47ffb560e663f..7541840e9c23b 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP3.py
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP3.py
@@ -37,6 +37,14 @@ TAUP3JetTPThinningTool                           = DerivationFramework__JetTrack
                                                      ApplyAnd                  = True)
 ToolSvc                                         += TAUP3JetTPThinningTool
 
+from DerivationFrameworkCalo.DerivationFrameworkCaloConf import DerivationFramework__CaloClusterThinning
+TAUP3CaloClusterThinning                         = DerivationFramework__CaloClusterThinning(
+                                                     name                      = "TAUP3ClusterThinning",
+                                                     ThinningService           = "TAUP3ThinningSvc",
+                                                     SGKey                     = "TauJets",
+                                                     TopoClCollectionSGKey     = "CaloCalTopoClusters")
+ToolSvc                                         += TAUP3CaloClusterThinning
+
 # Tracks associated with electrons
 from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning
 TAUP3ElectronTPThinningTool                      = DerivationFramework__EgammaTrackParticleThinning(
@@ -94,6 +102,7 @@ DerivationFrameworkJob                          += CfgMgr.DerivationFramework__D
                                                      SkimmingTools             = [TAUP3SkimmingTool],
                                                      ThinningTools             = [TAUP3MetTPThinningTool,
                                                                                   TAUP3JetTPThinningTool,
+                                                                                  TAUP3CaloClusterThinning,
                                                                                   TAUP3ElectronTPThinningTool,
                                                                                   TAUP3MuonTPThinningTool,
                                                                                   TAUP3TauTPThinningTool],
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauPVTrkSelectionTool.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauPVTrkSelectionTool.cxx
index 9df5c9fb4ca8b..56094f39e1cb8 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauPVTrkSelectionTool.cxx
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauPVTrkSelectionTool.cxx
@@ -84,16 +84,22 @@ namespace DerivationFramework {
       bool pass_selection = false;
       if (tau_pt > m_minPt && (fabs(tau_eta) < 1.37 || (fabs(tau_eta) > 1.52 && fabs(tau_eta) < 2.5))) pass_selection = true;
       for (int i = 0; i < tauNtracks; i++) {
+#ifdef XAODTAU_VERSIONS_TAUJET_V3_H
+        const xAOD::TauTrack* tauTrk = pTau->track(i);
+	const xAOD::TrackParticle* tauTrk_trk = tauTrk->track();
+#else
         const xAOD::TrackParticle* tauTrk = pTau->track(i);
+	const xAOD::TrackParticle* tauTrk_trk = tauTrk;
+#endif	
         if (m_useTruth) {
           // identify tracks matched to tau decay products (hadrons only)
           if (!m_T3MT->classifyTrack(*tauTrk)) continue;
-          if (tauTrk->auxdecor<char>("IsHadronicTrack")) tauPVTracks->push_back(const_cast<xAOD::TrackParticle*>(tauTrk));
+          if (tauTrk->auxdecor<char>("IsHadronicTrack")) tauPVTracks->push_back(const_cast<xAOD::TrackParticle*>(tauTrk_trk));
         } else {
           // use all tau tracks
           //TauTracks.push_back(const_cast<xAOD::TrackParticle*>(tauTrk));
           float dR = pTau->p4().DeltaR(tauTrk->p4());
-          if (good_tau && pass_selection && dR < m_maxDeltaR) tauPVTracks->push_back(const_cast<xAOD::TrackParticle*>(tauTrk));
+          if (good_tau && pass_selection && dR < m_maxDeltaR) tauPVTracks->push_back(const_cast<xAOD::TrackParticle*>(tauTrk_trk));
         }
       }
     }
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauSelectionWrapper.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauSelectionWrapper.cxx
index f0deb5e707c8f..eca4027894789 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauSelectionWrapper.cxx
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauSelectionWrapper.cxx
@@ -82,6 +82,7 @@ StatusCode DerivationFramework::TauSelectionWrapper::addBranches() const
      // Write decision to SG for access by downstream algs 
      if (evtStore()->contains<std::vector<int> >(m_sgKey)) {
      	ATH_MSG_ERROR("Tool is attempting to write a StoreGate key " << m_sgKey << " which already exists. Please use a different key");
+	delete isTauSelectionResult;
      	return StatusCode::FAILURE;
      }
      CHECK(evtStore()->record(isTauSelectionResult,m_sgKey));       
-- 
GitLab