diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/CMakeLists.txt b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..47d9226a5ba59df2880d36ae1e7d482da0ff093e --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/CMakeLists.txt @@ -0,0 +1,33 @@ +################################################################################ +# Package: DerivationFrameworkTau +################################################################################ + +# Declare the package name: +atlas_subdir( DerivationFrameworkTau ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Control/AthenaBaseComps + Event/xAOD/xAODTracking + GaudiKernel + PhysicsAnalysis/DerivationFramework/DerivationFrameworkInterfaces + PRIVATE + Event/xAOD/xAODTau + PhysicsAnalysis/JpsiUpsilonTools + PhysicsAnalysis/TauID/TauAnalysisTools ) + +# Component(s) in the package: +atlas_add_library( DerivationFrameworkTauLib + src/*.cxx + PUBLIC_HEADERS DerivationFrameworkTau + LINK_LIBRARIES AthenaBaseComps xAODTracking GaudiKernel JpsiUpsilonToolsLib + PRIVATE_LINK_LIBRARIES xAODTau ) + +atlas_add_component( DerivationFrameworkTau + src/components/*.cxx + LINK_LIBRARIES AthenaBaseComps xAODTracking GaudiKernel xAODTau JpsiUpsilonToolsLib DerivationFrameworkTauLib ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) +atlas_install_joboptions( share/*.py ) + diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauOverlappingElectronLLHDecoratorWrapper.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauOverlappingElectronLLHDecoratorWrapper.h new file mode 100644 index 0000000000000000000000000000000000000000..298c81e7b5b631bdd8c7c826a1ce2770af147efa --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauOverlappingElectronLLHDecoratorWrapper.h @@ -0,0 +1,55 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TauOverlappingElectronLLHDecoratorWrapper.h + * @author Z. Zinonos - zenon@cern.ch + * @date November 2015 + */ + +#ifndef DERIVATIONFRAMEWORK_TAUOVERLAPPINGELECTRONLLHDECORATORWRAPPER_H +#define DERIVATIONFRAMEWORK_TAUOVERLAPPINGELECTRONLLHDECORATORWRAPPER_H + +#include <string> + +#include "AthenaBaseComps/AthAlgTool.h" +#include "DerivationFrameworkInterfaces/IAugmentationTool.h" +#include "GaudiKernel/ToolHandle.h" + +//#include "TauAnalysisTools/ITauOverlappingElectronLLHDecorator.h" +//#include "xAODTau/TauJetContainer.h" +//#include "xAODEgamma/ElectronContainer.h" + +/** + * @short Forward declarations + */ +namespace TauAnalysisTools { class ITauOverlappingElectronLLHDecorator; } + +/** + * @class TauOverlappingElectronLLHDecoratorWrapper + * @brief wrapper tool for decorating reconstructed taus with a likelihood score of matched reconstructed electrons + */ + +namespace DerivationFramework { + + class TauOverlappingElectronLLHDecoratorWrapper : public AthAlgTool, public IAugmentationTool { + + public: + TauOverlappingElectronLLHDecoratorWrapper(const std::string& t, const std::string& n, const IInterface* p); + + StatusCode initialize(); + StatusCode finalize(); + virtual StatusCode addBranches() const; + + private: + std::string m_tauContainerName; + std::string m_electronContainerName; + + ToolHandle < TauAnalysisTools::ITauOverlappingElectronLLHDecorator > m_TauOverlappingElectronLLHDecorator; + + }; +} + +#endif + diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauPVRefitTool.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauPVRefitTool.h new file mode 100644 index 0000000000000000000000000000000000000000..1c3edd1f8f656d00a1544ff6a2fce63f2639631e --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauPVRefitTool.h @@ -0,0 +1,55 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TauPVRefitTool.h +// author: e.bouhova@cern.ch +/////////////////////////////////////////////////////////////////// + +#ifndef DERIVATIONFRAMEWORK_TAUPVREFITTOOL_H +#define DERIVATIONFRAMEWORK_TAUPVREFITTOOL_H + +#include <string> + +#include "AthenaBaseComps/AthAlgTool.h" +#include "DerivationFrameworkInterfaces/IAugmentationTool.h" +#include "xAODTracking/VertexContainer.h" +#include "xAODTracking/VertexAuxContainer.h" +#include "GaudiKernel/ToolHandle.h" + +/** + * refit any primary vertex in the PV collection that contains any + * of the TrackParticles provided via a xAOD::TrackParticleContainer + * set links to original PV container and decorate PV container with + * links to the refitted PV container +*/ + +namespace Analysis { class PrimaryVertexRefitter; } + +namespace DerivationFramework { + + class TauPVRefitTool : public AthAlgTool, public IAugmentationTool { + public: + TauPVRefitTool(const std::string& t, const std::string& n, const IInterface* p); + + StatusCode initialize(); + StatusCode finalize(); + virtual StatusCode addBranches() const; + + private: + + std::string m_linkName; + std::string m_reflinkName; + std::string m_pvrefContainerName; + std::string m_pvContainerName; + std::string m_tauTrkContainerName; + + ToolHandle < Analysis::PrimaryVertexRefitter > m_pvrefitter; + + StatusCode refit(xAOD::VertexContainer*& TauRefittedPrimaryVertices, xAOD::VertexAuxContainer*& TauRefittedPrimaryVerticesAux) const; + + }; +} + +#endif // DERIVATIONFRAMEWORK_TAUPVREFITTOOL_H diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauPVTrkSelectionTool.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauPVTrkSelectionTool.h new file mode 100644 index 0000000000000000000000000000000000000000..a048a3fd28738e5f531462bbe3f922a931c5745c --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauPVTrkSelectionTool.h @@ -0,0 +1,55 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TauPVTrkSelectionTool.h +// author: e.bouhova@cern.ch +/////////////////////////////////////////////////////////////////// + +#ifndef DERIVATIONFRAMEWORK_TAUPVTRKSELECTIONTOOL_H +#define DERIVATIONFRAMEWORK_TAUPVTRKSELECTIONTOOL_H + +#include <string> + +#include "AthenaBaseComps/AthAlgTool.h" +#include "DerivationFrameworkInterfaces/IAugmentationTool.h" +#include "xAODTracking/TrackParticleContainer.h" +#include "xAODTracking/TrackParticle.h" +#include "GaudiKernel/ToolHandle.h" + +/** + * tool for selecting tracks associated to tau candidates (xAOD::TauJetContainer) + * for the purpose of PV refit, returns a xAOD::TrackParticleContainer + * if UseTrueTracks = true, use truth matched tracks only +*/ + +namespace TauAnalysisTools { class ITauTruthTrackMatchingTool; } + +namespace DerivationFramework { + + class TauPVTrkSelectionTool : public AthAlgTool, public IAugmentationTool { + public: + TauPVTrkSelectionTool(const std::string& t, const std::string& n, const IInterface* p); + + StatusCode initialize(); + StatusCode finalize(); + virtual StatusCode addBranches() const; + + private: + + std::string m_tauPVTracksContainerName; + std::string m_tauContainerName; + + bool m_useTruth; + bool m_maxDeltaR; + bool m_minPt; + + ToolHandle < TauAnalysisTools::ITauTruthTrackMatchingTool > m_T3MT; + + StatusCode select(xAOD::TrackParticleContainer*& tauPVTracks) const; + + }; +} + +#endif // DERIVATIONFRAMEWORK_TAUPVTRKSELECTIONTOOL_H diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauSelectionWrapper.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauSelectionWrapper.h new file mode 100644 index 0000000000000000000000000000000000000000..9dfaac7293105d8b91f358089ac04e455ffdbbad --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauSelectionWrapper.h @@ -0,0 +1,54 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////// +// TauSelectionWrapper.h (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef DERIVATIONFRAMEWORK_TAUSELECTIONWRAPPER_H +#define DERIVATIONFRAMEWORK_TAUSELECTIONWRAPPER_H 1 + +#include<string> + +// Gaudi & Athena basics +#include "AthenaBaseComps/AthAlgTool.h" + +// DerivationFramework includes +#include "DerivationFrameworkInterfaces/IAugmentationTool.h" + +namespace DerivationFramework { + + /** @class TauSelectionWrapper + + the code used in this implementation is kindly stolen from: + atlasoff:: ISF/ISF_Core/ISF_Tools + + @author James Catmore -at- cern.ch + */ + class TauSelectionWrapper : public AthAlgTool, public IAugmentationTool { + + public: + /** Constructor with parameters */ + TauSelectionWrapper( const std::string& t, const std::string& n, const IInterface* p ); + + /** Destructor */ + ~TauSelectionWrapper(); + + // Athena algtool's Hooks + StatusCode initialize(); + StatusCode finalize(); + + /** Check that the current event passes this filter */ + virtual StatusCode addBranches() const; + + private: + int m_isTauFlag; + std::string m_collName; + std::string m_sgKey; + + }; + +} + +#endif diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauTruthMatchingWrapper.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauTruthMatchingWrapper.h new file mode 100644 index 0000000000000000000000000000000000000000..2a6cac45c551f4b9a5763a23d8800277ce9244d1 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/DerivationFrameworkTau/TauTruthMatchingWrapper.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TauTruthMatchingWrapper.h +// Author: Evelina Bouhova-Thacker (e.bouhova@cern.ch) +/////////////////////////////////////////////////////////////////// + +#ifndef DERIVATIONFRAMEWORK_TAUTRUTHMATCHINGWRAPPER_H +#define DERIVATIONFRAMEWORK_TAUTRUTHMATCHINGWRAPPER_H + +#include <string> + +#include "AthenaBaseComps/AthAlgTool.h" +#include "DerivationFrameworkInterfaces/IAugmentationTool.h" +#include "GaudiKernel/ToolHandle.h" + +/** + * wrapper tool for tau truth matching +*/ + +namespace TauAnalysisTools { class ITauTruthMatchingTool; } + +namespace DerivationFramework { + + class TauTruthMatchingWrapper : public AthAlgTool, public IAugmentationTool { + public: + TauTruthMatchingWrapper(const std::string& t, const std::string& n, const IInterface* p); + + StatusCode initialize(); + StatusCode finalize(); + virtual StatusCode addBranches() const; + + private: + std::string m_tauContainerName; + + ToolHandle < TauAnalysisTools::ITauTruthMatchingTool > m_tTauTruthMatchingTool; + + }; +} + +#endif // DERIVATIONFRAMEWORK_TAUPVTRKSELECTIONTOOL_H diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/cmt/requirements b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/cmt/requirements new file mode 100644 index 0000000000000000000000000000000000000000..32e073f8f01c336242c188eb17ad00459385cceb --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/cmt/requirements @@ -0,0 +1,27 @@ +package DerivationFrameworkTau +author James Catmore <james.catmore@cern.ch> + +################################################################# +# public use statements +use AtlasPolicy AtlasPolicy-* +use AthenaBaseComps AthenaBaseComps-* Control +use DerivationFrameworkInterfaces DerivationFrameworkInterfaces-* PhysicsAnalysis/DerivationFramework +use GaudiInterface GaudiInterface-* External +use xAODTracking xAODTracking-* Event/xAOD + +private +use xAODTau xAODTau-* Event/xAOD +use JpsiUpsilonTools JpsiUpsilonTools-* PhysicsAnalysis +use TauAnalysisTools TauAnalysisTools-* PhysicsAnalysis/TauID + +################################################################# +# +public + +## declare the directories CMT should know about +branches python share src DerivationFrameworkTau + +apply_pattern dual_use_library files= " *.cxx " +apply_pattern declare_joboptions files=" *.py" +apply_pattern declare_python_modules files="*.py" + diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TAUPExtraContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TAUPExtraContent.py new file mode 100644 index 0000000000000000000000000000000000000000..0c7c279db854b491b474dc22a02f78474b6ce70c --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TAUPExtraContent.py @@ -0,0 +1,185 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# Content included in addition to the smart slimming content + +# ========================================================================================================================== +# Extra content +# ========================================================================================================================== + +ExtraContentPhotons = ["Photons.Loose.Medium.Tight.author.OQ"] +ExtraContentPhotonsTruth = ["Photons.truthOrigin.truthParticleLink.truthType"] + +ExtraContentElectrons = ["Electrons.etcone20.etcone30.etcone40.ptcone20.ptcone30.ptcone40.Loose.Medium.Tight.DFCommonElectronsLHLoose.DFCommonElectronsLHMedium.DFCommonElectronsLHTight.DFCommonElectronsML.author.OQ"] +ExtraContentElectronsTruth = ["Electrons.truthOrigin.truthType.truthParticleLink"] + +ExtraContentMuons = ["Muons.DFCommonGoodMuon.ptcone20.ptcone30.ptcone40.etcone20.etcone30.etcone40"] +ExtraContentMuonsTruth = ["MuonTruthParticles.truthOrigin.truthType"] + +ExtraContentTaus = [ "TauJets.pt.eta.phi.m.charge.jetLink.isTauFlags.BDTEleScore.BDTJetScore." + + "caloIso." + + "isolFrac." + + "IsTruthMatched." + + "truthJetLink." + + "truthParticleLink." + + "ptDetectorAxis." + + "etaDetectorAxis." + + "phiDetectorAxis." + + "mDetectorAxis." + + "ptIntermediateAxis." + + "etaIntermediateAxis." + + "phiIntermediateAxis." + + "mIntermediateAxis." + + "leadTrkPt." + + "massTrkSys." + + "trFlightPathSig." + + "centFrac." + + "centFracCorrected." + + "ChPiEMEOverCaloEME." + + "ChPiEMEOverCaloEMECorrected." + + "dRmax." + + "dRmaxCorrected." + + "etOverPtLeadTrk." + + "etOverPtLeadTrkCorrected." + + "EMPOverTrkSysP." + + "EMPOverTrkSysPCorrected." + + "innerTrkAvgDist." + + "innerTrkAvgDistCorrected." + + "ipSigLeadTrk." + + "ipSigLeadTrkCorrected." + + "massTrkSys." + + "massTrkSysCorrected." + + "mEflowApprox." + + "mEflowApproxCorrected." + + "ptRatioEflowApprox." + + "ptRatioEflowApproxCorrected." + + "SumPtTrkFrac." + + "SumPtTrkFracCorrected." + + "trFlightPathSig." + + "trFlightPathSigCorrected." + + "ptPanTauCellBased." + + "ptPanTauCellBasedProto." + + "etaPanTauCellBased." + + "etaPanTauCellBasedProto." + + "phiPanTauCellBased." + + "phiPanTauCellBasedProto." + + "mPanTauCellBased." + + "mPanTauCellBasedProto." + + "pantau_CellBasedInput_BDTValue_1p0n_vs_1p1n." + + "pantau_CellBasedInput_BDTValue_1p1n_vs_1pXn." + + "pantau_CellBasedInput_BDTValue_3p0n_vs_3pXn." + + "pantau_CellBasedInput_BDTVar_Basic_NNeutralConsts." + + "pantau_CellBasedInput_BDTVar_Charged_HLV_SumM." + + "pantau_CellBasedInput_BDTVar_Charged_JetMoment_EtDRxTotalEt." + + "pantau_CellBasedInput_BDTVar_Charged_StdDev_Et_WrtEtAllConsts." + + "pantau_CellBasedInput_BDTVar_Combined_DeltaR1stNeutralTo1stCharged." + + "pantau_CellBasedInput_BDTVar_Neutral_HLV_SumM." + + "pantau_CellBasedInput_BDTVar_Neutral_PID_BDTValues_BDTSort_1." + + "pantau_CellBasedInput_BDTVar_Neutral_PID_BDTValues_BDTSort_2." + + "pantau_CellBasedInput_BDTVar_Neutral_Ratio_1stBDTEtOverEtAllConsts." + + "pantau_CellBasedInput_BDTVar_Neutral_Ratio_EtOverEtAllConsts." + + "pantau_CellBasedInput_BDTVar_Neutral_Shots_NPhotonsInSeed." + + "pantau_CellBasedInput_DecayMode." + + "pantau_CellBasedInput_DecayModeProto." + + "pantau_CellBasedInput_isPanTauCandidate", + "TauChargedParticleFlowObjects", + "TauNeutralParticleFlowObjects", + "TauHadronicParticleFlowObjects", + "TauShotParticleFlowObjects", + "TauPi0Clusters" ] +ExtraContentTausTruth = [] + +# ========================================================================================================================== + +ExtraContentTAUP1 = ExtraContentPhotons \ + + ExtraContentElectrons \ + + ExtraContentMuons \ + + ExtraContentTaus + +ExtraContentTAUP2 = ExtraContentTaus + +ExtraContentTAUP3 = ExtraContentPhotons \ + + ExtraContentElectrons \ + + ExtraContentMuons \ + + ExtraContentTaus + +ExtraContentTruthTAUP1 = ExtraContentPhotonsTruth \ + + ExtraContentElectronsTruth \ + + ExtraContentMuonsTruth \ + + ExtraContentTausTruth + +ExtraContentTruthTAUP2 = ExtraContentElectronsTruth \ + + ExtraContentMuonsTruth \ + + ExtraContentTausTruth + +ExtraContentTruthTAUP3 = ExtraContentPhotonsTruth \ + + ExtraContentElectronsTruth \ + + ExtraContentMuonsTruth \ + + ExtraContentTausTruth + +# ========================================================================================================================== +# Extra containers +# ========================================================================================================================== + +ExtraContainersElectrons = ["ForwardElectrons"] + +ExtraContainersJets = [] + +ExtraContainersTrigger = ["LVL1EmTauRoIs", +# + "HLT_TrigRoiDescriptorCollection_forID", + "HLT_TrigRoiDescriptorCollection_forID1", + "HLT_TrigRoiDescriptorCollection_forID2", + "HLT_TrigRoiDescriptorCollection_forID3", + "HLT_TrigRoiDescriptorCollection_forMS", + "HLT_TrigRoiDescriptorCollection_initialRoI", + "HLT_TrigRoiDescriptorCollection_secondaryRoI_EF", + "HLT_TrigRoiDescriptorCollection_secondaryRoI_HLT", + "HLT_TrigRoiDescriptorCollection_secondaryRoI_L2", +# + "HLT_xAOD__EmTauRoIContainer_L1TopoEM", + "HLT_xAOD__EmTauRoIContainer_L1TopoTau", +# + "HLT_xAOD__JetContainer_TrigTauJet", +# + "HLT_xAOD__TauJetContainer_TrigTauRecPreselection", +# + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Tau_EFID", + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Tau_FTF", + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Tau_IDTrig", + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_TauCore_FTF", + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_TauIso_FTF"] + +# ========================================================================================================================== + +ExtraContainersTAUP1 = ExtraContainersElectrons \ + + ExtraContainersJets \ + + ExtraContainersTrigger + +ExtraContainersTAUP2 = ExtraContainersTrigger \ + + ["HLT_xAOD__TauJetContainer_TrigTauRecMerged"] + +ExtraContainersTAUP3 = ExtraContainersElectrons \ + + ExtraContainersJets \ + + ExtraContainersTrigger \ + + ["HLT_xAOD__TauJetContainer_TrigTauRecMerged"] + +ExtraContainersTruthTAUP1 = ["TruthEvents", + "TruthParticles", + "TruthVertices", + "AntiKt4TruthJets", + #"BTagging_AntiKt4Truth", JRC TEMPORARILY COMMENTED + "AntiKt4TruthWZJets"] + +ExtraContainersTruthTAUP2 = ["TruthEvents", + "TruthParticles", + "TruthVertices"] +# "AntiKt4TruthJets", + #"BTagging_AntiKt4Truth", JRC TEMPORARILY COMMENTED +# "AntiKt4TruthWZJets"] + +ExtraContainersTruthTAUP3 = ["TruthEvents", + "TruthParticles", + "TruthVertices", + "AntiKt4TruthJets", + #"BTagging_AntiKt4Truth", JRC TEMPORARILY COMMENTED + "AntiKt4TruthWZJets"] diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TauCommon.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TauCommon.py new file mode 100644 index 0000000000000000000000000000000000000000..0c68557df1ff5a74be13a46735885d3ffa18c8fb --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TauCommon.py @@ -0,0 +1,70 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +#******************************************************************** +# TauCommon.py +# Schedules all tools needed for tau object selection and writes +# results into SG. These may then be accessed along the train. +#******************************************************************** +from DerivationFrameworkCore.DerivationFrameworkMaster import * + +#==================================================================== +# MAKE TAU ENUMS AVAILABLE +#==================================================================== +#import PyCintex +#PyCintex.loadDictionary('xAODTauDict') +#from ROOT import xAOD__TauJetParameters__IsTauFlag + +#==================================================================== +# AUGMENTATION TOOLS +#==================================================================== +from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__AsgSelectionToolWrapper +from TauAnalysisTools.TauAnalysisToolsConf import TauAnalysisTools__TauSelectionTool +DFCommonTauWrapperTools = [] + +# Loose +DFCommonTausSelectorLoose = TauAnalysisTools__TauSelectionTool(name="DFCommonTausSelectorLoose") +DFCommonTausSelectorLoose.JetIDWP = 2 +DFCommonTausSelectorLoose.SelectionCuts = 1<<6 +#TauAnalysisTools::CutJetIDWP should be used but issue with the dictionnary +ToolSvc += DFCommonTausSelectorLoose +DFCommonTausLooseWrapper = DerivationFramework__AsgSelectionToolWrapper( name = "DFCommonTausLooseWrapper", + AsgSelectionTool = DFCommonTausSelectorLoose, + StoreGateEntryName = "DFCommonTausLoose", + ContainerName = "TauJets") +ToolSvc += DFCommonTausLooseWrapper +print DFCommonTausLooseWrapper +DFCommonTauWrapperTools.append(DFCommonTausLooseWrapper) + +# Medium +DFCommonTausSelectorMedium = TauAnalysisTools__TauSelectionTool(name="DFCommonTausSelectorMedium") +DFCommonTausSelectorMedium.JetIDWP = 3 +DFCommonTausSelectorMedium.SelectionCuts = 1<<6 +ToolSvc += DFCommonTausSelectorMedium +DFCommonTausMediumWrapper = DerivationFramework__AsgSelectionToolWrapper( name = "DFCommonTausMediumWrapper", + AsgSelectionTool = DFCommonTausSelectorMedium, + StoreGateEntryName = "DFCommonTausMedium", + ContainerName = "TauJets") +ToolSvc += DFCommonTausMediumWrapper +print DFCommonTausMediumWrapper +DFCommonTauWrapperTools.append(DFCommonTausMediumWrapper) + +# Tight +DFCommonTausSelectorTight = TauAnalysisTools__TauSelectionTool(name="DFCommonTausSelectorTight") +DFCommonTausSelectorTight.JetIDWP = 4 +DFCommonTausSelectorTight.SelectionCuts = 1<<6 +ToolSvc += DFCommonTausSelectorTight +DFCommonTausTightWrapper = DerivationFramework__AsgSelectionToolWrapper( name = "DFCommonTausTightWrapper", + AsgSelectionTool = DFCommonTausSelectorTight, + StoreGateEntryName = "DFCommonTausTight", + ContainerName = "TauJets") +ToolSvc += DFCommonTausTightWrapper +print DFCommonTausTightWrapper +DFCommonTauWrapperTools.append(DFCommonTausTightWrapper) + +#======================================= +# CREATE THE DERIVATION KERNEL ALGORITHM +#======================================= + +from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__CommonAugmentation +DerivationFrameworkJob += CfgMgr.DerivationFramework__CommonAugmentation("TauCommonKernel", + AugmentationTools = DFCommonTauWrapperTools) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TauTruthCommon.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TauTruthCommon.py new file mode 100644 index 0000000000000000000000000000000000000000..2a4642c9c4b26cf3c3d77a9579b308e297aa6f7f --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/TauTruthCommon.py @@ -0,0 +1,55 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +#******************************************************************** +# TauTruthCommon.py +# Schedules all tools needed for tau truth object selection and writes +# results into SG. These may then be accessed along the train. +#******************************************************************** +from DerivationFrameworkCore.DerivationFrameworkMaster import * + +#==================================================================== +# AUGMENTATION TOOLS +#==================================================================== +# Tau Truth making and matching +if DerivationFrameworkIsMonteCarlo: + + from DerivationFrameworkTau.DerivationFrameworkTauConf import DerivationFramework__TauTruthMatchingWrapper + from TauAnalysisTools.TauAnalysisToolsConf import TauAnalysisTools__TauTruthMatchingTool + + DFCommonTauTruthWrapperTools = [] + + # Tau Truth making and matching + # Set up the MCTruthClassifier + from MCTruthClassifier.MCTruthClassifierConf import MCTruthClassifier + DFCommonTauTruthClassifier = MCTruthClassifier(name = "DFCommonTauTruthClassifier", + ParticleCaloExtensionTool="") + ToolSvc += DFCommonTauTruthClassifier + + # Build the truth taus + from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__TruthCollectionMakerTau + DFCommonTruthTauTool = DerivationFramework__TruthCollectionMakerTau(name = "DFCommonTruthTauTool", + NewCollectionName = "TruthTaus", + MCTruthClassifier = DFCommonTauTruthClassifier) + ToolSvc += DFCommonTruthTauTool + DFCommonTauTruthWrapperTools.append(DFCommonTruthTauTool) + + # Matching + # Only do if working with AOD + from RecExConfig.ObjKeyStore import objKeyStore + if objKeyStore.isInInput( "xAOD::TauJetContainer", "TauJets" ): + DFCommonTauTruthMatchingTool = TauAnalysisTools__TauTruthMatchingTool(name="DFCommonTauTruthMatchingTool") + ToolSvc += DFCommonTauTruthMatchingTool + DFCommonTauTruthMatchingWrapper = DerivationFramework__TauTruthMatchingWrapper( name = "DFCommonTauTruthMatchingWrapper", + TauTruthMatchingTool = DFCommonTauTruthMatchingTool, + TauContainerName = "TauJets") + ToolSvc += DFCommonTauTruthMatchingWrapper + print DFCommonTauTruthMatchingWrapper + DFCommonTauTruthWrapperTools.append(DFCommonTauTruthMatchingWrapper) + + #======================================= + # CREATE THE DERIVATION KERNEL ALGORITHM + #======================================= + + from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__CommonAugmentation + DerivationFrameworkJob += CfgMgr.DerivationFramework__CommonAugmentation("TauTruthCommonKernel", + AugmentationTools = DFCommonTauTruthWrapperTools) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/__init__.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..74583d364ec2ca794156596c7254d9b234a940c6 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/python/__init__.py @@ -0,0 +1,2 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP1.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP1.py new file mode 100644 index 0000000000000000000000000000000000000000..a188d365c461a84990fb398df0a24efde8bb1bef --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP1.py @@ -0,0 +1,169 @@ +# ************************************************************************************************************************** +# TAUP1.py +# reductionConf flag TAUP1 in Reco_tf.py +# ************************************************************************************************************************** +from DerivationFrameworkCore.DerivationFrameworkMaster import * +from DerivationFrameworkInDet.InDetCommon import * +from DerivationFrameworkJetEtMiss.JetCommon import * +from DerivationFrameworkJetEtMiss.ExtendedJetCommon import * +from DerivationFrameworkJetEtMiss.METCommon import * +from DerivationFrameworkEGamma.EGammaCommon import * +from DerivationFrameworkMuons.MuonsCommon import * +if DerivationFrameworkIsMonteCarlo: + from DerivationFrameworkMCTruth.MCTruthCommon import * + from DerivationFrameworkTau.TauTruthCommon import * +from DerivationFrameworkTau.TauCommon import * + +# ========================================================================================================================== +# Set up stream +# ========================================================================================================================== +streamName = derivationFlags.WriteDAOD_TAUP1Stream.StreamName +fileName = buildFileName( derivationFlags.WriteDAOD_TAUP1Stream ) +TAUP1Stream = MSMgr.NewPoolRootStream( streamName, fileName ) +TAUP1Stream.AcceptAlgs(["TAUP1Kernel"]) + +# ========================================================================================================================== +# Thinning tool +# ========================================================================================================================== +from DerivationFrameworkCore.ThinningHelper import ThinningHelper +TAUP1ThinningHelper = ThinningHelper( "TAUP1ThinningHelper" ) +TAUP1ThinningHelper.TriggerChains = "HLT_e24.*|HLT_e60.*" +TAUP1ThinningHelper.AppendToStream( TAUP1Stream ) + +# MET/Jet tracks +thinning_expression = "(InDetTrackParticles.pt > 0.5*GeV) && (InDetTrackParticles.numberOfPixelHits > 0) && (InDetTrackParticles.numberOfSCTHits > 5) && (abs(DFCommonInDetTrackZ0AtPV) < 1.5)" +from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning +TAUP1MetTPThinningTool = DerivationFramework__TrackParticleThinning( + name = "TAUP1MetTPThinningTool", + ThinningService = TAUP1ThinningHelper.ThinningSvc(), + SelectionString = thinning_expression, + InDetTrackParticlesKey = "InDetTrackParticles", + ApplyAnd = True) +ToolSvc += TAUP1MetTPThinningTool + +from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__JetTrackParticleThinning +TAUP1JetTPThinningTool = DerivationFramework__JetTrackParticleThinning( + name = "TAUP1JetTPThinningTool", + ThinningService = TAUP1ThinningHelper.ThinningSvc(), + JetKey = "AntiKt4LCTopoJets", + InDetTrackParticlesKey = "InDetTrackParticles", + ApplyAnd = True) +ToolSvc += TAUP1JetTPThinningTool + +# Tracks associated with electrons +from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning +TAUP1ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( + name = "TAUP1ElectronTPThinningTool", + ThinningService = TAUP1ThinningHelper.ThinningSvc(), + SGKey = "Electrons", + InDetTrackParticlesKey = "InDetTrackParticles") +ToolSvc += TAUP1ElectronTPThinningTool + +# Tracks associated with muons +from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__MuonTrackParticleThinning +TAUP1MuonTPThinningTool = DerivationFramework__MuonTrackParticleThinning( + name = "TAUP1MuonTPThinningTool", + ThinningService = TAUP1ThinningHelper.ThinningSvc(), + MuonKey = "Muons", + InDetTrackParticlesKey = "InDetTrackParticles") +ToolSvc += TAUP1MuonTPThinningTool + +# Tracks associated with taus +from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TauTrackParticleThinning +TAUP1TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( + name = "TAUP1TauTPThinningTool", + ThinningService = TAUP1ThinningHelper.ThinningSvc(), + TauKey = "TauJets", + InDetTrackParticlesKey = "InDetTrackParticles", + ConeSize = 0.6) +ToolSvc += TAUP1TauTPThinningTool + +# ========================================================================================================================== +# Skimming tool +# ========================================================================================================================== +elRequirement = "( count( (Electrons.DFCommonElectronsIsEMLoose || Electrons.DFCommonElectronsLHLoose) && (Electrons.pt > 20.0*GeV) && (abs(Electrons.eta) < 2.6) ) >= 1 )" +muRequirement = "( count( (Muons.pt > 10.0*GeV) && (abs(Muons.eta) < 2.0) && Muons.DFCommonGoodMuon ) < 1 )" +tauRequirement = "( count( (TauJets.pt > 12.0*GeV) && (abs(TauJets.eta) < 2.6) && (abs(TauJets.charge) == 1.0) ) >= 1 )" + +expression = elRequirement + " && " + muRequirement + " && " + tauRequirement + +from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__xAODStringSkimmingTool +TAUP1SkimmingTool = DerivationFramework__xAODStringSkimmingTool( + name = "TAUP1SkimmingTool", + expression = expression) + +ToolSvc += TAUP1SkimmingTool + +# ========================================================================================================================== +# Kernel algorithm +# ========================================================================================================================== +augmentationTools = [] +# JRC: This is now done in TauCommon.py +# if DerivationFrameworkIsMonteCarlo: +# augmentationTools += [DFCommonTauTruthMatchingWrapper] + +from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel +DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel( + "TAUP1Kernel", + SkimmingTools = [TAUP1SkimmingTool], + ThinningTools = [TAUP1MetTPThinningTool, + TAUP1JetTPThinningTool, + TAUP1ElectronTPThinningTool, + TAUP1MuonTPThinningTool, + TAUP1TauTPThinningTool], + AugmentationTools = augmentationTools) + +# ========================================================================================================================== +# Add the containers to the output stream (slimming done here) +# ========================================================================================================================== +from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper +from DerivationFrameworkTau.TAUPExtraContent import * + +TAUP1SlimmingHelper = SlimmingHelper("TAUP1SlimmingHelper") +TAUP1SlimmingHelper.SmartCollections = ["Electrons", + "Photons", + "Muons", + "TauJets", + "MET_Reference_AntiKt4EMTopo", + "MET_Reference_AntiKt4LCTopo", + "AntiKt4EMTopoJets", + "AntiKt4LCTopoJets", + "BTagging_AntiKt4EMTopo", + "BTagging_AntiKt4LCTopo", + "InDetTrackParticles", + "PrimaryVertices"] + +if DerivationFrameworkIsMonteCarlo: + TAUP1SlimmingHelper.StaticContent = ["xAOD::TruthParticleContainer#TruthElectrons", + "xAOD::TruthParticleAuxContainer#TruthElectronsAux.", + "xAOD::TruthParticleContainer#TruthMuons", + "xAOD::TruthParticleAuxContainer#TruthMuonsAux.", + "xAOD::TruthParticleContainer#TruthTaus", + "xAOD::TruthParticleAuxContainer#TruthTausAux.", + "xAOD::TruthParticleContainer#TruthPhotons", + "xAOD::TruthParticleAuxContainer#TruthPhotonsAux.", + "xAOD::TruthParticleContainer#TruthNeutrinos", + "xAOD::TruthParticleAuxContainer#TruthNeutrinosAux."] + +TAUP1SlimmingHelper.IncludeMuonTriggerContent = True +TAUP1SlimmingHelper.IncludeTauTriggerContent = True +TAUP1SlimmingHelper.IncludeEGammaTriggerContent = True +TAUP1SlimmingHelper.IncludeEtMissTriggerContent = True +TAUP1SlimmingHelper.IncludeJetTriggerContent = True +TAUP1SlimmingHelper.IncludeBJetTriggerContent = True + +TAUP1SlimmingHelper.ExtraVariables = ExtraContentTAUP1 +TAUP1SlimmingHelper.AllVariables = ExtraContainersTAUP1 + +if globalflags.DataSource() == "geant4": + TAUP1SlimmingHelper.ExtraVariables += ExtraContentTruthTAUP1 + TAUP1SlimmingHelper.AllVariables += ExtraContainersTruthTAUP1 + +TAUP1SlimmingHelper.AppendContentToStream(TAUP1Stream) + +TAUP1Stream.AddItem("xAOD::EventShape#*") +TAUP1Stream.AddItem("xAOD::EventShapeAuxInfo#*") + +# Add MET_RefFinalFix +# JRC TEMPORARILY COMMENTED +# addMETOutputs(TAUP1Stream) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP2.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP2.py new file mode 100644 index 0000000000000000000000000000000000000000..3d99456f7582c4e46b1a391d358cbefe03bdd10b --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP2.py @@ -0,0 +1,170 @@ +# ************************************************************************************************************************** +# TAUP2.py +# reductionConf flag TAUP2 in Reco_tf.py +# ************************************************************************************************************************** +from DerivationFrameworkCore.DerivationFrameworkMaster import * +from DerivationFrameworkInDet.InDetCommon import * +from DerivationFrameworkJetEtMiss.JetCommon import * +from DerivationFrameworkJetEtMiss.ExtendedJetCommon import * +from DerivationFrameworkJetEtMiss.METCommon import * +from DerivationFrameworkEGamma.EGammaCommon import * +from DerivationFrameworkMuons.MuonsCommon import * +if DerivationFrameworkIsMonteCarlo: + from DerivationFrameworkMCTruth.MCTruthCommon import * + from DerivationFrameworkTau.TauTruthCommon import * +from DerivationFrameworkTau.TauCommon import * + +# ========================================================================================================================== +# Set up stream +# ========================================================================================================================== +streamName = derivationFlags.WriteDAOD_TAUP2Stream.StreamName +fileName = buildFileName( derivationFlags.WriteDAOD_TAUP2Stream ) +TAUP2Stream = MSMgr.NewPoolRootStream( streamName, fileName ) +TAUP2Stream.AcceptAlgs(["TAUP2Kernel"]) + +# ========================================================================================================================== +# Thinning tool +# ========================================================================================================================== +# from DerivationFrameworkCore.ThinningHelper import ThinningHelper +# TAUP2ThinningHelper = ThinningHelper( "TAUP2ThinningHelper" ) +# TAUP2ThinningHelper.TriggerChains = "HLT_e24.*|HLT_e60.*" +# TAUP2ThinningHelper.AppendToStream( TAUP2Stream ) +# +# # MET/Jet tracks +# thinning_expression = "(InDetTrackParticles.pt > 0.5*GeV) && (InDetTrackParticles.numberOfPixelHits > 0) && (InDetTrackParticles.numberOfSCTHits > 5) && (abs(DFCommonInDetTrackZ0AtPV) < 1.5)" +# from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning +# TAUP2MetTPThinningTool = DerivationFramework__TrackParticleThinning( +# name = "TAUP2MetTPThinningTool", +# ThinningService = TAUP2ThinningHelper.ThinningSvc(), +# SelectionString = thinning_expression, +# InDetTrackParticlesKey = "InDetTrackParticles", +# ApplyAnd = True) +# ToolSvc += TAUP2MetTPThinningTool +# +# from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__JetTrackParticleThinning +# TAUP2JetTPThinningTool = DerivationFramework__JetTrackParticleThinning( +# name = "TAUP2JetTPThinningTool", +# ThinningService = TAUP2ThinningHelper.ThinningSvc(), +# JetKey = "AntiKt4LCTopoJets", +# InDetTrackParticlesKey = "InDetTrackParticles", +# ApplyAnd = True) +# ToolSvc += TAUP2JetTPThinningTool +# +# # Tracks associated with electrons +# from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning +# TAUP2ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( +# name = "TAUP2ElectronTPThinningTool", +# ThinningService = TAUP2ThinningHelper.ThinningSvc(), +# SGKey = "Electrons", +# InDetTrackParticlesKey = "InDetTrackParticles") +# ToolSvc += TAUP2ElectronTPThinningTool +# +# # Tracks associated with muons +# from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__MuonTrackParticleThinning +# TAUP2MuonTPThinningTool = DerivationFramework__MuonTrackParticleThinning( +# name = "TAUP2MuonTPThinningTool", +# ThinningService = TAUP2ThinningHelper.ThinningSvc(), +# MuonKey = "Muons", +# InDetTrackParticlesKey = "InDetTrackParticles") +# ToolSvc += TAUP2MuonTPThinningTool +# +# # Tracks associated with taus +# from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TauTrackParticleThinning +# TAUP2TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( +# name = "TAUP2TauTPThinningTool", +# ThinningService = TAUP2ThinningHelper.ThinningSvc(), +# TauKey = "TauJets", +# InDetTrackParticlesKey = "InDetTrackParticles", +# ConeSize = 0.6) +# ToolSvc += TAUP2TauTPThinningTool + +# ========================================================================================================================== +# Skimming tool +# ========================================================================================================================== +# elRequirement = "( count( (Electrons.DFCommonElectronsIsEMLoose || Electrons.DFCommonElectronsLHLoose) && (Electrons.pt > 20.0*GeV) && (abs(Electrons.eta) < 2.6) ) >= 1 )" +# muRequirement = "( count( (Muons.pt > 10.0*GeV) && (abs(Muons.eta) < 2.0) && Muons.DFCommonGoodMuon ) < 1 )" +# tauRequirement = "( count( (TauJets.pt > 12.0*GeV) && (abs(TauJets.eta) < 2.6) && (abs(TauJets.charge) == 1.0) ) >= 1 )" +# +# expression = elRequirement + " && " + muRequirement + " && " + tauRequirement +# +# from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__xAODStringSkimmingTool +# TAUP2SkimmingTool = DerivationFramework__xAODStringSkimmingTool( +# name = "TAUP2SkimmingTool", +# expression = expression) +# +# ToolSvc += TAUP2SkimmingTool + +# ========================================================================================================================== +# Kernel algorithm +# ========================================================================================================================== +augmentationTools = [] +# JRC: This is now done in TauCommon.py +# if DerivationFrameworkIsMonteCarlo: +# augmentationTools += [DFCommonTauTruthMatchingWrapper] + +from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel +DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel( + "TAUP2Kernel", +# SkimmingTools = [TAUP2SkimmingTool], +# ThinningTools = [TAUP2MetTPThinningTool, +# TAUP2JetTPThinningTool, +# TAUP2ElectronTPThinningTool, +# TAUP2MuonTPThinningTool, +# TAUP2TauTPThinningTool], + AugmentationTools = augmentationTools) + +# ========================================================================================================================== +# Add the containers to the output stream (slimming done here) +# ========================================================================================================================== +from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper +from DerivationFrameworkTau.TAUPExtraContent import * + +TAUP2SlimmingHelper = SlimmingHelper("TAUP2SlimmingHelper") +TAUP2SlimmingHelper.SmartCollections = [ +# "Electrons", +# "Photons", +# "Muons", + "TauJets"] +# "MET_Reference_AntiKt4EMTopo", +# "MET_Reference_AntiKt4LCTopo", +# "AntiKt4EMTopoJets", +# "AntiKt4LCTopoJets", +# "BTagging_AntiKt4EMTopo", +# "BTagging_AntiKt4LCTopo", +# "InDetTrackParticles", +# "PrimaryVertices"] + +if DerivationFrameworkIsMonteCarlo: + TAUP2SlimmingHelper.StaticContent = ["xAOD::TruthParticleContainer#TruthElectrons", + "xAOD::TruthParticleAuxContainer#TruthElectronsAux.", + "xAOD::TruthParticleContainer#TruthMuons", + "xAOD::TruthParticleAuxContainer#TruthMuonsAux.", + "xAOD::TruthParticleContainer#TruthTaus", + "xAOD::TruthParticleAuxContainer#TruthTausAux."] +# "xAOD::TruthParticleContainer#TruthPhotons", +# "xAOD::TruthParticleAuxContainer#TruthPhotonsAux.", +# "xAOD::TruthParticleContainer#TruthNeutrinos", +# "xAOD::TruthParticleAuxContainer#TruthNeutrinosAux."] + +# TAUP2SlimmingHelper.IncludeMuonTriggerContent = True +# TAUP2SlimmingHelper.IncludeTauTriggerContent = True +# TAUP2SlimmingHelper.IncludeEGammaTriggerContent = True +# TAUP2SlimmingHelper.IncludeEtMissTriggerContent = True +# TAUP2SlimmingHelper.IncludeJetTriggerContent = True +# TAUP2SlimmingHelper.IncludeBJetTriggerContent = True + +TAUP2SlimmingHelper.ExtraVariables = ExtraContentTAUP2 +TAUP2SlimmingHelper.AllVariables = ExtraContainersTAUP2 + +if globalflags.DataSource() == "geant4": + TAUP2SlimmingHelper.ExtraVariables += ExtraContentTruthTAUP2 + TAUP2SlimmingHelper.AllVariables += ExtraContainersTruthTAUP2 + +TAUP2SlimmingHelper.AppendContentToStream(TAUP2Stream) + +TAUP2Stream.AddItem("xAOD::EventShape#*") +TAUP2Stream.AddItem("xAOD::EventShapeAuxInfo#*") + +# Add MET_RefFinalFix +# JRC TEMPORARILY COMMENTED +# addMETOutputs(TAUP2Stream) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP3.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP3.py new file mode 100644 index 0000000000000000000000000000000000000000..47ffb560e663f699974d113c0bc59a7e75c62867 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/share/TAUP3.py @@ -0,0 +1,171 @@ +# ************************************************************************************************************************** +# TAUP3.py +# reductionConf flag TAUP3 in Reco_tf.py +# ************************************************************************************************************************** +from DerivationFrameworkCore.DerivationFrameworkMaster import * +from DerivationFrameworkInDet.InDetCommon import * +from DerivationFrameworkJetEtMiss.JetCommon import * +from DerivationFrameworkJetEtMiss.ExtendedJetCommon import * +from DerivationFrameworkJetEtMiss.METCommon import * +from DerivationFrameworkEGamma.EGammaCommon import * +from DerivationFrameworkMuons.MuonsCommon import * +if DerivationFrameworkIsMonteCarlo: + from DerivationFrameworkMCTruth.MCTruthCommon import * + from DerivationFrameworkTau.TauTruthCommon import * +from DerivationFrameworkTau.TauCommon import * + +# ========================================================================================================================== +# Thinning tool +# ========================================================================================================================== +# MET/Jet tracks +thinning_expression = "(InDetTrackParticles.pt > 0.5*GeV) && (InDetTrackParticles.numberOfPixelHits > 0) && (InDetTrackParticles.numberOfSCTHits > 5) && (abs(DFCommonInDetTrackZ0AtPV) < 1.5)" +from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning +TAUP3MetTPThinningTool = DerivationFramework__TrackParticleThinning( + name = "TAUP3MetTPThinningTool", + ThinningService = "TAUP3ThinningSvc", + SelectionString = thinning_expression, + InDetTrackParticlesKey = "InDetTrackParticles", + ApplyAnd = True) +ToolSvc += TAUP3MetTPThinningTool + +from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__JetTrackParticleThinning +TAUP3JetTPThinningTool = DerivationFramework__JetTrackParticleThinning( + name = "TAUP3JetTPThinningTool", + ThinningService = "TAUP3ThinningSvc", + JetKey = "AntiKt4LCTopoJets", + InDetTrackParticlesKey = "InDetTrackParticles", + ApplyAnd = True) +ToolSvc += TAUP3JetTPThinningTool + +# Tracks associated with electrons +from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning +TAUP3ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( + name = "TAUP3ElectronTPThinningTool", + ThinningService = "TAUP3ThinningSvc", + SGKey = "Electrons", + InDetTrackParticlesKey = "InDetTrackParticles") +ToolSvc += TAUP3ElectronTPThinningTool + +# Tracks associated with muons +from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__MuonTrackParticleThinning +TAUP3MuonTPThinningTool = DerivationFramework__MuonTrackParticleThinning( + name = "TAUP3MuonTPThinningTool", + ThinningService = "TAUP3ThinningSvc", + MuonKey = "Muons", + InDetTrackParticlesKey = "InDetTrackParticles") +ToolSvc += TAUP3MuonTPThinningTool + +# Tracks associated with taus +from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TauTrackParticleThinning +TAUP3TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( + name = "TAUP3TauTPThinningTool", + ThinningService = "TAUP3ThinningSvc", + TauKey = "TauJets", + InDetTrackParticlesKey = "InDetTrackParticles", + ConeSize = 0.6) +ToolSvc += TAUP3TauTPThinningTool + +# ========================================================================================================================== +# Skimming tool +# ========================================================================================================================== +muRequirement = "( count( (Muons.pt > 22.0*GeV) && Muons.DFCommonGoodMuon ) >= 1 )" +tauRequirement = "( count( (TauJets.pt > 18.0*GeV) && (abs(TauJets.charge)==1.0) && ((TauJets.nTracks == 1) || (TauJets.nTracks == 3)) ) >= 1 )" + +expression = muRequirement + " && " + tauRequirement + +from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__xAODStringSkimmingTool +TAUP3SkimmingTool = DerivationFramework__xAODStringSkimmingTool( + name = "TAUP3SkimmingTool", + expression = expression) + +ToolSvc += TAUP3SkimmingTool + +# ========================================================================================================================== +# Kernel algorithm +# ========================================================================================================================== +augmentationTools = [] +# JRC: This is now done in TauCommon.py +# if DerivationFrameworkIsMonteCarlo: +# augmentationTools += [DFCommonTauTruthMatchingWrapper] + +from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel +DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel( + "TAUP3Kernel", + SkimmingTools = [TAUP3SkimmingTool], + ThinningTools = [TAUP3MetTPThinningTool, + TAUP3JetTPThinningTool, + TAUP3ElectronTPThinningTool, + TAUP3MuonTPThinningTool, + TAUP3TauTPThinningTool], + AugmentationTools = augmentationTools) + +# ========================================================================================================================== +# Set up stream +# ========================================================================================================================== +streamName = derivationFlags.WriteDAOD_TAUP3Stream.StreamName +fileName = buildFileName( derivationFlags.WriteDAOD_TAUP3Stream ) +TAUP3Stream = MSMgr.NewPoolRootStream( streamName, fileName ) +TAUP3Stream.AcceptAlgs(["TAUP3Kernel"]) + +# SPECIAL LINES FOR THINNING +# Thinning service name must match the one passed to the thinning tools +from AthenaServices.Configurables import ThinningSvc, createThinningSvc +augStream = MSMgr.GetStream( streamName ) +evtStream = augStream.GetEventStream() +svcMgr += createThinningSvc( + svcName = "TAUP3ThinningSvc", + outStreams = [evtStream]) + +# ========================================================================================================================== +# Add the containers to the output stream (slimming done here) +# ========================================================================================================================== +from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper +from DerivationFrameworkTau.TAUPExtraContent import * + +TAUP3SlimmingHelper = SlimmingHelper("TAUP3SlimmingHelper") +TAUP3SlimmingHelper.SmartCollections = ["Electrons", + "Photons", + "Muons", + "TauJets", + "MET_Reference_AntiKt4EMTopo", + "MET_Reference_AntiKt4LCTopo", + "AntiKt4EMTopoJets", + "AntiKt4LCTopoJets", + "BTagging_AntiKt4EMTopo", + "BTagging_AntiKt4LCTopo", + "InDetTrackParticles", + "PrimaryVertices"] + +if DerivationFrameworkIsMonteCarlo: + TAUP3SlimmingHelper.StaticContent = ["xAOD::TruthParticleContainer#TruthElectrons", + "xAOD::TruthParticleAuxContainer#TruthElectronsAux.", + "xAOD::TruthParticleContainer#TruthMuons", + "xAOD::TruthParticleAuxContainer#TruthMuonsAux.", + "xAOD::TruthParticleContainer#TruthTaus", + "xAOD::TruthParticleAuxContainer#TruthTausAux.", + "xAOD::TruthParticleContainer#TruthPhotons", + "xAOD::TruthParticleAuxContainer#TruthPhotonsAux.", + "xAOD::TruthParticleContainer#TruthNeutrinos", + "xAOD::TruthParticleAuxContainer#TruthNeutrinosAux."] + +TAUP3SlimmingHelper.IncludeMuonTriggerContent = True +TAUP3SlimmingHelper.IncludeEGammaTriggerContent = True +TAUP3SlimmingHelper.IncludeEtMissTriggerContent = True +TAUP3SlimmingHelper.IncludeJetTriggerContent = True +TAUP3SlimmingHelper.IncludeBJetTriggerContent = True + +TAUP3SlimmingHelper.ExtraVariables = ExtraContentTAUP3 +TAUP3SlimmingHelper.AllVariables = ExtraContainersTAUP3 + +if globalflags.DataSource() == "geant4": + TAUP3SlimmingHelper.ExtraVariables += ExtraContentTruthTAUP3 + TAUP3SlimmingHelper.AllVariables += ExtraContainersTruthTAUP3 + +TAUP3SlimmingHelper.AppendContentToStream(TAUP3Stream) + +TAUP3Stream.AddItem("xAOD::EventShape#*") +TAUP3Stream.AddItem("xAOD::EventShapeAuxInfo#*") + +# Add MET_RefFinalFix +# JRC TEMPORARILY COMMENTED +# addMETOutputs(TAUP3Stream) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauOverlappingElectronLLHDecoratorWrapper.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauOverlappingElectronLLHDecoratorWrapper.cxx new file mode 100644 index 0000000000000000000000000000000000000000..80c75d97ba69d646750646a9548abc5661d3960a --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauOverlappingElectronLLHDecoratorWrapper.cxx @@ -0,0 +1,73 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TauOverlappingElectronLLHDecoratorWrapper.cxx + * @author Z. Zinonos - zenon@cern.ch + * @date November 2015 + */ + +#include "DerivationFrameworkTau/TauOverlappingElectronLLHDecoratorWrapper.h" + +#include "TauAnalysisTools/ITauOverlappingElectronLLHDecorator.h" +#include "xAODTau/TauJetContainer.h" + +namespace DerivationFramework { + + TauOverlappingElectronLLHDecoratorWrapper::TauOverlappingElectronLLHDecoratorWrapper(const std::string& t, const std::string& n, const IInterface* p) : + AthAlgTool(t, n, p), + m_tauContainerName("TauJets"), + m_electronContainerName("Electrons"), + m_TauOverlappingElectronLLHDecorator("TauAnalysisTools::TauOverlappingElectronLLHDecorator") + { + declareInterface<DerivationFramework::IAugmentationTool>(this); + declareProperty("TauContainerName", m_tauContainerName); + declareProperty("ElectronContainerName", m_electronContainerName); + declareProperty("TauOverlappingElectronLLHDecorator", m_TauOverlappingElectronLLHDecorator); + } + + StatusCode TauOverlappingElectronLLHDecoratorWrapper::initialize() + { + if (m_tauContainerName.empty()) { + ATH_MSG_ERROR("No StoreGate key provided for tau container of the TauOverlappingElectronLLHDecorator wrapper tool!"); + return StatusCode::FAILURE; + } + + if (m_electronContainerName.empty()) { + ATH_MSG_ERROR("No StoreGate key provided for electron container of the TauOverlappingElectronLLHDecorator wrapper tool!"); + return StatusCode::FAILURE; + } + + + CHECK( m_TauOverlappingElectronLLHDecorator.retrieve() ); + + ATH_MSG_VERBOSE("initialize() ..."); + + return StatusCode::SUCCESS; + } + + StatusCode TauOverlappingElectronLLHDecoratorWrapper::finalize() + { + return StatusCode::SUCCESS; + } + + StatusCode TauOverlappingElectronLLHDecoratorWrapper::addBranches() const + { + /** retrieve container */ + const xAOD::TauJetContainer* xTauContainer = evtStore()->retrieve< const xAOD::TauJetContainer >( m_tauContainerName ); + if( ! xTauContainer ) { + ATH_MSG_ERROR ("Couldn't retrieve tau container with key: " << m_tauContainerName ); + return StatusCode::FAILURE; + } + + CHECK(m_TauOverlappingElectronLLHDecorator->initializeEvent()); + + for(auto xTau : *xTauContainer){ + CHECK( m_TauOverlappingElectronLLHDecorator->decorate(*xTau) ); + } + + return StatusCode::SUCCESS; + } +} + diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauPVRefitTool.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauPVRefitTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..283037371d943cb98bd908c4efd49c8a87fcf5c5 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauPVRefitTool.cxx @@ -0,0 +1,136 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TauPVRefitTool.cxx +// Author: Evelina Bouhova-Thacker (e.bouhova@cern.ch) +// +/////////////////////////////////////////////////////////////////// + +#include "DerivationFrameworkTau/TauPVRefitTool.h" +#include "JpsiUpsilonTools/PrimaryVertexRefitter.h" +#include "xAODTracking/Vertex.h" + +namespace DerivationFramework { + + TauPVRefitTool::TauPVRefitTool(const std::string& t, const std::string& n, const IInterface* p) : + AthAlgTool(t,n,p), + m_linkName("PVLink"), + m_reflinkName("TauRefittedPVLink"), + m_pvrefContainerName("TauRefittedPrimaryVertices"), + m_pvContainerName("PrimaryVertices"), + m_tauTrkContainerName("TauPVTracks"), + m_pvrefitter("Analysis::PrimaryVertexRefitter") + { + declareInterface<DerivationFramework::IAugmentationTool>(this); + declareProperty("PVLinkName", m_linkName); + declareProperty("RefittedLinkName", m_reflinkName); + declareProperty("PVRefContainerName", m_pvrefContainerName); + declareProperty("PVContainerName", m_pvContainerName); + declareProperty("TauTrkContainerName", m_tauTrkContainerName); + declareProperty("PrimaryVertexRefitterTool", m_pvrefitter); + } + + StatusCode TauPVRefitTool::initialize() + { + if (m_pvrefContainerName=="") { + ATH_MSG_ERROR("No SG name provided for the output of the tau PV refitter tool!"); + return StatusCode::FAILURE; + } + CHECK( m_pvrefitter.retrieve() ); + return StatusCode::SUCCESS; + } + + StatusCode TauPVRefitTool::finalize() + { + return StatusCode::SUCCESS; + } + + StatusCode TauPVRefitTool::addBranches() const + { + // check that container we want to write in SG does not yet exist + if (evtStore()->contains<std::vector<float> >(m_pvrefContainerName)) { + ATH_MSG_ERROR("Tool is attempting to write a StoreGate key " << m_pvrefContainerName << " which already exists. Please use a different key"); + return StatusCode::FAILURE; + } + + xAOD::VertexContainer* TauRefittedPrimaryVertices(0); + xAOD::VertexAuxContainer* TauRefittedPrimaryVerticesAux(0); + + CHECK(refit(TauRefittedPrimaryVertices,TauRefittedPrimaryVerticesAux)); + ATH_MSG_DEBUG ("number of refitted PVs " << TauRefittedPrimaryVertices->size()); + + if (!evtStore()->contains<xAOD::VertexContainer>(m_pvrefContainerName)) + CHECK(evtStore()->record(TauRefittedPrimaryVertices, m_pvrefContainerName)); + if (!evtStore()->contains<xAOD::VertexAuxContainer>(m_pvrefContainerName+"Aux.")) + CHECK(evtStore()->record(TauRefittedPrimaryVerticesAux, m_pvrefContainerName+"Aux.")); + + return StatusCode::SUCCESS; + } + + StatusCode TauPVRefitTool::refit(xAOD::VertexContainer*& TauRefittedPrimaryVertices, xAOD::VertexAuxContainer*& TauRefittedPrimaryVerticesAux) const + { + TauRefittedPrimaryVertices = new xAOD::VertexContainer; + TauRefittedPrimaryVerticesAux = new xAOD::VertexAuxContainer; + TauRefittedPrimaryVertices->setStore(TauRefittedPrimaryVerticesAux); + + // Get PV collection from StoreGate + const xAOD::VertexContainer* pv_cont = evtStore()->retrieve< const xAOD::VertexContainer >( m_pvContainerName ); + if (pv_cont == 0) return StatusCode::SUCCESS; + ATH_MSG_DEBUG ("number of PVs " << pv_cont->size()); + + // Get selected tau tracks + std::vector<const xAOD::TrackParticle*> tps; tps.clear(); + xAOD::TrackParticleContainer* trk_cont = evtStore()->retrieve< xAOD::TrackParticleContainer >( m_tauTrkContainerName ); + for (auto trk: *trk_cont) tps.push_back(trk); + ATH_MSG_DEBUG ("tps size " << tps.size()); + + std::vector<unsigned int> pv_index; pv_index.clear(); + unsigned int ipv = 0, ipv2 = 0; + // loop over PV container and refit + for (auto pv: *pv_cont ) { + const xAOD::Vertex* pv_ref = m_pvrefitter->refitVertex(pv,tps); + if (pv_ref) { + if (pv_ref->nTrackParticles() < pv->nTrackParticles()) { + TauRefittedPrimaryVertices->push_back(const_cast<xAOD::Vertex*>(pv_ref)); + pv_index.push_back(ipv); + } else { + delete pv_ref; + } + } else { + delete pv_ref; + } + ipv++; + } + + // loop over PV container and set links + for (auto pv: *pv_cont ) { + ElementLink<xAOD::VertexContainer> pvLink; + static SG::AuxElement::Decorator< ElementLink<xAOD::VertexContainer> > mDecor_pvLink(m_reflinkName); + ElementLink<xAOD::VertexContainer> ref_pvLink; + static SG::AuxElement::Decorator< ElementLink<xAOD::VertexContainer> > mDecor_ref_pvLink(m_linkName); + if (TauRefittedPrimaryVertices->size() == 0) mDecor_pvLink(*pv) = pvLink; + unsigned int irpv = 0; + for (auto rpv: *TauRefittedPrimaryVertices ) { + if (ipv2 == pv_index[irpv]) { + ATH_MSG_DEBUG (" pv x " << pv->x() << " y " << pv->y() << " z " << pv->z() << " ntrks " << pv->nTrackParticles() << " ndf " << pv->numberDoF() << " chi2 " << pv->chiSquared()); + ATH_MSG_DEBUG ("ref pv x " << rpv->x() << " y " << rpv->y() << " z " << rpv->z() << " ntrks " << rpv->nTrackParticles() << " ndf " << rpv->numberDoF() << " chi2 " << rpv->chiSquared()); + pvLink.setElement(rpv); + pvLink.setStorableObject(*TauRefittedPrimaryVertices); + mDecor_pvLink(*pv) = pvLink; + + ref_pvLink.setElement(pv); + ref_pvLink.setStorableObject(*pv_cont); + mDecor_ref_pvLink(*rpv) = ref_pvLink; + } else { + mDecor_pvLink(*pv) = pvLink; + } + irpv++; + } + ipv2++; + } + + return StatusCode::SUCCESS; + } +} diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauPVTrkSelectionTool.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauPVTrkSelectionTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9df5c9fb4ca8b821a5dd8d7104b4f32868e68e97 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauPVTrkSelectionTool.cxx @@ -0,0 +1,104 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TauPVTrkSelectionTool.cxx +// Author: Evelina Bouhova-Thacker (e.bouhova@cern.ch) +// +/////////////////////////////////////////////////////////////////// + +#include "DerivationFrameworkTau/TauPVTrkSelectionTool.h" +#include "xAODTracking/Vertex.h" +#include "TauAnalysisTools/ITauTruthTrackMatchingTool.h" +#include "xAODTau/TauJetContainer.h" + +namespace DerivationFramework { + + TauPVTrkSelectionTool::TauPVTrkSelectionTool(const std::string& t, const std::string& n, const IInterface* p) : + AthAlgTool(t,n,p), + m_tauPVTracksContainerName("TauPVTracks"), + m_tauContainerName("TauJets"), + m_useTruth(false), + m_maxDeltaR(0.2), + m_minPt(20000.), + m_T3MT("TauAnalysisTools::TauTruthTrackMatchingTool") + { + declareInterface<DerivationFramework::IAugmentationTool>(this); + declareProperty("TauPVTracksContainerName", m_tauPVTracksContainerName); + declareProperty("TauContainerName", m_tauContainerName); + declareProperty("UseTrueTracks", m_useTruth); + declareProperty("maxDeltaR", m_maxDeltaR); + declareProperty("minPt", m_minPt); + declareProperty("TauTruthTrackMatchingTool", m_T3MT); + } + + StatusCode TauPVTrkSelectionTool::initialize() + { + if (m_tauPVTracksContainerName=="") { + ATH_MSG_ERROR("No SG name provided for the output of the tau PV track selector tool!"); + return StatusCode::FAILURE; + } + CHECK( m_T3MT.retrieve() ); + return StatusCode::SUCCESS; + } + + StatusCode TauPVTrkSelectionTool::finalize() + { + return StatusCode::SUCCESS; + } + + StatusCode TauPVTrkSelectionTool::addBranches() const + { + // check that container we want to write in SG does not yet exist + if (evtStore()->contains<std::vector<float> >(m_tauPVTracksContainerName)) { + ATH_MSG_ERROR("Tool is attempting to write a StoreGate key " << m_tauPVTracksContainerName << " which already exists. Please use a different key"); + return StatusCode::FAILURE; + } + + xAOD::TrackParticleContainer* tauPVTracks(0); + + CHECK(select(tauPVTracks)); + ATH_MSG_DEBUG ("number of tau tracks for PV refit " << tauPVTracks->size()); + + if (!evtStore()->contains<xAOD::TrackParticleContainer>(m_tauPVTracksContainerName)) + CHECK(evtStore()->record(tauPVTracks, m_tauPVTracksContainerName)); + + return StatusCode::SUCCESS; + } + + StatusCode TauPVTrkSelectionTool::select(xAOD::TrackParticleContainer*& tauPVTracks) const + { + tauPVTracks = new xAOD::TrackParticleContainer(SG::VIEW_ELEMENTS); + + // Get tau collection from StoreGate + const xAOD::TauJetContainer* tau_cont = evtStore()->retrieve< const xAOD::TauJetContainer >( m_tauContainerName ); + if (tau_cont == 0) return StatusCode::SUCCESS; + ATH_MSG_DEBUG ("number of taus " << tau_cont->size()); + // loop over tau container to select tracks for the PV refit + for (auto pTau: *tau_cont ) { + int tauNtracks = pTau->nTracks(); + bool good_tau = pTau->isTau(xAOD::TauJetParameters::JetBDTSigMedium); + float tau_pt = pTau->pt(); + float tau_eta = pTau->eta(); + 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++) { + const xAOD::TrackParticle* tauTrk = pTau->track(i); + 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)); + } 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)); + } + } + } + ATH_MSG_DEBUG ("tauPVTracks size " << tauPVTracks->size()); + + return StatusCode::SUCCESS; + } +} diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauSelectionWrapper.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauSelectionWrapper.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f0deb5e707c8f54f8d2cb10a30cfe981d492a181 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauSelectionWrapper.cxx @@ -0,0 +1,91 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TauSelectionWrapper.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Author: James Catmore (James.Catmore@cern.ch) +// Wrapper around the passSelection() method of xAOD egamma +// Writes result to SG for later selection by string parser + +#include "DerivationFrameworkTau/TauSelectionWrapper.h" +#include "xAODTau/TauJetContainer.h" +#include <vector> +#include <string> + +// Constructor +DerivationFramework::TauSelectionWrapper::TauSelectionWrapper( const std::string& t, + const std::string& n, + const IInterface* p ) : + AthAlgTool(t,n,p), + m_isTauFlag(-1), + m_collName("TauRecContainer"), + m_sgKey("") + { + declareInterface<DerivationFramework::IAugmentationTool>(this); + declareProperty("IsTauFlag",m_isTauFlag); + declareProperty("CollectionName", m_collName); + declareProperty("StoreGateEntryName", m_sgKey); + } + +// Destructor +DerivationFramework::TauSelectionWrapper::~TauSelectionWrapper() { +} + +// Athena initialize and finalize +StatusCode DerivationFramework::TauSelectionWrapper::initialize() +{ + if (m_isTauFlag==-1) { + ATH_MSG_ERROR("No tau flag variables for the tau selection wrapper tool!"); + return StatusCode::FAILURE; + } + if (m_collName=="") { + ATH_MSG_ERROR("No tau container provided for the tau selection wrapper tool!"); + return StatusCode::FAILURE; + } + if (m_sgKey=="") { + ATH_MSG_ERROR("No StoreGate key provided for the output of the tau selection wrapper tool!"); + return StatusCode::FAILURE; + } + ATH_MSG_VERBOSE("initialize() ..."); + return StatusCode::SUCCESS; +} +StatusCode DerivationFramework::TauSelectionWrapper::finalize() +{ + ATH_MSG_VERBOSE("finalize() ..."); + return StatusCode::SUCCESS; +} + +// Augmentation +StatusCode DerivationFramework::TauSelectionWrapper::addBranches() const +{ + + // Retrieve data + const xAOD::TauJetContainer* taus = evtStore()->retrieve< const xAOD::TauJetContainer >( m_collName ); + if( !taus ) { + ATH_MSG_ERROR("Couldn't retrieve tau container with key: " << m_collName); + return StatusCode::FAILURE; + } + + // Make vectors for the cut results + std::vector<int>* isTauSelectionResult = new std::vector<int>; + // Loop over taus, set decisions + xAOD::TauJetParameters::IsTauFlag isTauFlag = (xAOD::TauJetParameters::IsTauFlag)m_isTauFlag; + xAOD::TauJetContainer::const_iterator tauBegin = taus->begin(); + xAOD::TauJetContainer::const_iterator tauEnd = taus->end(); + for (xAOD::TauJetContainer::const_iterator tauIt = taus->begin(); tauIt!=taus->end(); ++tauIt) { + if ( (*tauIt)->isTau(isTauFlag) ) {isTauSelectionResult->push_back(1);} + else {isTauSelectionResult->push_back(0);} + } + + // 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"); + return StatusCode::FAILURE; + } + CHECK(evtStore()->record(isTauSelectionResult,m_sgKey)); + return StatusCode::SUCCESS; + +} + diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauTruthMatchingWrapper.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauTruthMatchingWrapper.cxx new file mode 100644 index 0000000000000000000000000000000000000000..1c0d38750c23868167f0028ba3ab5597a04b5c1d --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/TauTruthMatchingWrapper.cxx @@ -0,0 +1,54 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// TauTruthMatchingWrapper.cxx +// Author: Evelina Bouhova-Thacker (e.bouhova@cern.ch) +/////////////////////////////////////////////////////////////////// + +#include "DerivationFrameworkTau/TauTruthMatchingWrapper.h" +#include "xAODTracking/Vertex.h" +#include "TauAnalysisTools/ITauTruthMatchingTool.h" +#include "xAODTau/TauJetContainer.h" + +namespace DerivationFramework { + + TauTruthMatchingWrapper::TauTruthMatchingWrapper(const std::string& t, const std::string& n, const IInterface* p) : + AthAlgTool(t,n,p), + m_tauContainerName("TauJets"), + m_tTauTruthMatchingTool("TauAnalysisTools::TauTruthMatchingTool") + { + declareInterface<DerivationFramework::IAugmentationTool>(this); + declareProperty("TauContainerName", m_tauContainerName); + declareProperty("TauTruthMatchingTool", m_tTauTruthMatchingTool); + } + + StatusCode TauTruthMatchingWrapper::initialize() + { + CHECK( m_tTauTruthMatchingTool.retrieve() ); + return StatusCode::SUCCESS; + } + + StatusCode TauTruthMatchingWrapper::finalize() + { + return StatusCode::SUCCESS; + } + + StatusCode TauTruthMatchingWrapper::addBranches() const + { + // retrieve container + const xAOD::TauJetContainer* xTauContainer = evtStore()->retrieve< const xAOD::TauJetContainer >( m_tauContainerName ); + if( ! xTauContainer ) { + ATH_MSG_ERROR ("Couldn't retrieve tau container with key: " << m_tauContainerName ); + return StatusCode::FAILURE; + } + + CHECK(m_tTauTruthMatchingTool->initializeEvent()); + + for(auto xTau : *xTauContainer) + m_tTauTruthMatchingTool->applyTruthMatch(*xTau); + + return StatusCode::SUCCESS; + } +} diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/components/DerivationFrameworkTau_entries.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/components/DerivationFrameworkTau_entries.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b030e55abf783f5f0e26b901b297f01e6a9d284c --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/components/DerivationFrameworkTau_entries.cxx @@ -0,0 +1,22 @@ +#include "GaudiKernel/DeclareFactoryEntries.h" +#include "DerivationFrameworkTau/TauSelectionWrapper.h" +#include "DerivationFrameworkTau/TauTruthMatchingWrapper.h" +#include "DerivationFrameworkTau/TauPVRefitTool.h" +#include "DerivationFrameworkTau/TauPVTrkSelectionTool.h" +#include "DerivationFrameworkTau/TauOverlappingElectronLLHDecoratorWrapper.h" + +using namespace DerivationFramework; + +DECLARE_TOOL_FACTORY( TauSelectionWrapper ) +DECLARE_TOOL_FACTORY( TauTruthMatchingWrapper ) +DECLARE_TOOL_FACTORY( TauPVRefitTool ) +DECLARE_TOOL_FACTORY( TauPVTrkSelectionTool ) +DECLARE_TOOL_FACTORY( TauOverlappingElectronLLHDecoratorWrapper ) + +DECLARE_FACTORY_ENTRIES( DerivationFrameworkTau ) { + DECLARE_TOOL( TauSelectionWrapper ) + DECLARE_TOOL( TauTruthMatchingWrapper ) + DECLARE_TOOL( TauPVRefitTool ) + DECLARE_TOOL( TauPVTrkSelectionTool ) + DECLARE_TOOL( TauOverlappingElectronLLHDecoratorWrapper ) +} diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/components/DerivationFrameworkTau_load.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkTau/src/components/DerivationFrameworkTau_load.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391