diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/CMakeLists.txt b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/CMakeLists.txt index 2ac5f4da23c3da046e6849f74423ae172547253c..a3ba64909251df27b18573b6d637911f12b20b85 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/CMakeLists.txt +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/CMakeLists.txt @@ -1,7 +1,7 @@ ################################################################################ # Package: DerivationFrameworkEGamma ################################################################################ - + # Declare the package name: atlas_subdir( DerivationFrameworkEGamma ) @@ -22,6 +22,7 @@ atlas_depends_on_subdirs( PUBLIC GaudiKernel PhysicsAnalysis/CommonTools/ExpressionEvaluation PhysicsAnalysis/MCTruthClassifier + PhysicsAnalysis/ElectronPhotonID/EgammaAnalysisHelpers Calorimeter/CaloCalibHitRec ) # External dependencies: @@ -32,14 +33,14 @@ atlas_add_library( DerivationFrameworkEGammaLib src/*.cxx PUBLIC_HEADERS DerivationFrameworkEGamma PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES AsgTools AthenaBaseComps PATCoreLib EgammaAnalysisInterfacesLib ExpressionEvaluationLib MCTruthClassifierLib + LINK_LIBRARIES AsgTools AthenaBaseComps PATCoreLib EgammaAnalysisInterfacesLib ExpressionEvaluationLib MCTruthClassifierLib CaloCalibHitRecLib EgammaAnalysisHelpersLib PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} xAODBase xAODCaloEvent xAODEgamma xAODMissingET xAODMuon xAODTruth ) atlas_add_component( DerivationFrameworkEGamma src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} LINK_LIBRARIES ${ROOT_LIBRARIES} AsgTools AthenaBaseComps PATCoreLib EgammaAnalysisInterfacesLib xAODBase - xAODCaloEvent xAODEgamma xAODMissingET xAODMuon xAODTruth GaudiKernel ExpressionEvaluationLib MCTruthClassifierLib DerivationFrameworkEGammaLib ) + xAODCaloEvent xAODEgamma xAODMissingET xAODMuon xAODTruth GaudiKernel ExpressionEvaluationLib MCTruthClassifierLib CaloCalibHitRecLib DerivationFrameworkEGammaLib ) # Install files from the package: atlas_install_python_modules( python/*.py ) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGCrackVetoCleaningTool.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGCrackVetoCleaningTool.h new file mode 100644 index 0000000000000000000000000000000000000000..abc091e607d550ac4eb0534deb65d495bfd59fe7 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGCrackVetoCleaningTool.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// EGCrackVetoCleaningTool.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef DERIVATIONFRAMEWORK_EGCRACKVETOCLEANINGTOOL_H +#define DERIVATIONFRAMEWORK_EGCRACKVETOCLEANINGTOOL_H + +#include <string> + +#include "AthenaBaseComps/AthAlgTool.h" +#include "DerivationFrameworkInterfaces/IAugmentationTool.h" +#include "GaudiKernel/ToolHandle.h" + +namespace DerivationFramework { + + class EGCrackVetoCleaningTool : public AthAlgTool, public IAugmentationTool { + public: + EGCrackVetoCleaningTool(const std::string& t, const std::string& n, const IInterface* p); + + StatusCode initialize(); + StatusCode finalize(); + virtual StatusCode addBranches() const; + + private: + std::string m_sgName; + std::string m_containerName; + }; +} + +#endif // DERIVATIONFRAMEWORK_EGCRACKVETOCLEANINGTOOL_H diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGElectronAmbiguityTool.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGElectronAmbiguityTool.h new file mode 100644 index 0000000000000000000000000000000000000000..f437bef6b3fed551bb774e93930cd3f648055676 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGElectronAmbiguityTool.h @@ -0,0 +1,55 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// EGElectronAmbiguityTool.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef DERIVATIONFRAMEWORK_EGELECTRONAMBIGUITYTOOL_H +#define DERIVATIONFRAMEWORK_EGELECTRONAMBIGUITYTOOL_H + +#include <string> + +#include "GaudiKernel/ToolHandle.h" + +#include "AthenaBaseComps/AthAlgTool.h" +#include "DerivationFrameworkInterfaces/IAugmentationTool.h" + +#include "xAODEgamma/Electron.h" +#include "xAODTracking/Vertex.h" +#include "xAODTracking/TrackParticle.h" + +namespace DerivationFramework { + + class EGElectronAmbiguityTool : public AthAlgTool, public IAugmentationTool { + + public: + EGElectronAmbiguityTool(const std::string& t, const std::string& n, const IInterface* p); + + virtual StatusCode addBranches() const; + + private: + std::string m_containerName, m_VtxContainerName, m_tpContainerName; + + StatusCode decorateSimple(const xAOD::Electron *ele, const xAOD::Vertex *pvtx) const; + void helix(const xAOD::TrackParticle *trkP, const xAOD::Vertex *pvtx, std::vector<double>& h) const; + + bool m_isMC; + + // cuts to select the electron to run on + double m_elepTCut; + std::string m_idCut; + + // cuts to select the other track + unsigned int m_nSiCut; + double m_dctCut, m_sepCut, m_dzCut; + + // cuts to define the various types : + // ambi = -1 : no other track, 0 : other track exists but no good gamma reco, 1 : gamma*, 2 : material conversion + double m_rvECCut, m_meeAtVtxECCut,m_meeICCut; + + }; +} + +#endif // DERIVATIONFRAMEWORK_EGCONVERSIONINFOTOOL_H diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGElectronLikelihoodToolWrapper.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGElectronLikelihoodToolWrapper.h new file mode 100644 index 0000000000000000000000000000000000000000..b50f5d47e13b17719d7e182e5591a0fcefb5414e --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGElectronLikelihoodToolWrapper.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// EGLikelihoodToolWrapper.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Author: Giovanni Marchiori (giovanni.marchiori@cern.ch) +// Note: while EGSelectionToolWrapper permits to only store the boolean +// accept and the isEM-like mask (works for both isEM and likelihood selectors), +// this tool (EGElectronLikelihoodToolWrapper) allows also to store +// the double TResult output (i.e. the value of the likelihood or the ECIDS BDT) +// if StoreTResult is set to true. Otherwise one can simply use the other tool. + + +#ifndef DERIVATIONFRAMEWORK_EGELECTRONLIKELIHOODTOOLWRAPPER_H +#define DERIVATIONFRAMEWORK_EGELECTRONLIKELIHOODTOOLWRAPPER_H + +#include <string> + +#include "AthenaBaseComps/AthAlgTool.h" +#include "DerivationFrameworkInterfaces/IAugmentationTool.h" +#include "EgammaAnalysisInterfaces/IElectronPhotonShowerShapeFudgeTool.h" +#include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h" +#include "AsgTools/IAsgTool.h" +#include "GaudiKernel/ToolHandle.h" + +namespace DerivationFramework { + + class EGElectronLikelihoodToolWrapper : public AthAlgTool, public IAugmentationTool { + public: + EGElectronLikelihoodToolWrapper(const std::string& t, const std::string& n, const IInterface* p); + + StatusCode initialize(); + StatusCode finalize(); + virtual StatusCode addBranches() const; + + private: + ToolHandle<IAsgElectronLikelihoodTool> m_tool; + ToolHandle<IElectronPhotonShowerShapeFudgeTool> m_fudgeMCTool; + std::string m_cut; + std::string m_sgName; + std::string m_containerName; + bool m_storeTResult; + }; +} + +#endif // DERIVATIONFRAMEWORK_EGELECTRONLIKELIHOODTOOLWRAPPER_H diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGPhotonCleaningWrapper.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGPhotonCleaningWrapper.h new file mode 100644 index 0000000000000000000000000000000000000000..b25bcf8b2cc54181bb9a6138a97e084845e95f95 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGPhotonCleaningWrapper.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// EGPhotonCleaningWrapper.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef DERIVATIONFRAMEWORK_EGPHOTONCLEANINGWRAPPER_H +#define DERIVATIONFRAMEWORK_EGPHOTONCLEANINGWRAPPER_H + +#include <string> + +#include "AthenaBaseComps/AthAlgTool.h" +#include "DerivationFrameworkInterfaces/IAugmentationTool.h" +#include "EgammaAnalysisInterfaces/IElectronPhotonShowerShapeFudgeTool.h" +#include "GaudiKernel/ToolHandle.h" + +namespace DerivationFramework { + + class EGPhotonCleaningWrapper : public AthAlgTool, public IAugmentationTool { + public: + EGPhotonCleaningWrapper(const std::string& t, const std::string& n, const IInterface* p); + + StatusCode initialize(); + StatusCode finalize(); + virtual StatusCode addBranches() const; + + private: + ToolHandle<IElectronPhotonShowerShapeFudgeTool> m_fudgeMCTool; + std::string m_sgName; + std::string m_containerName; + }; +} + +#endif // DERIVATIONFRAMEWORK_EGSELECTIONTOOLWRAPPER_H diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGSelectionToolWrapper.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGSelectionToolWrapper.h index 8b0bc47b10ed5354daecdd80dc92bbfc3e1a71b1..c68ae0a5b4555525b5f1623489acff5cb5a8bcfd 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGSelectionToolWrapper.h +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGSelectionToolWrapper.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -15,6 +15,8 @@ #include "DerivationFrameworkInterfaces/IAugmentationTool.h" #include "EgammaAnalysisInterfaces/IAsgEGammaIsEMSelector.h" #include "EgammaAnalysisInterfaces/IElectronPhotonShowerShapeFudgeTool.h" +#include "PATCore/IAsgSelectionTool.h" +#include "AsgTools/IAsgTool.h" #include "GaudiKernel/ToolHandle.h" namespace DerivationFramework { @@ -28,8 +30,8 @@ namespace DerivationFramework { virtual StatusCode addBranches() const; private: - //ToolHandle<IAsgSelectionTool> m_tool; - ToolHandle<IAsgEGammaIsEMSelector> m_tool; // provides isemValue, but will not work with likelihood.. + ToolHandle<IAsgSelectionTool> m_tool; // can't use isemValue, but can use TAccept and then getInvertedCutBitSet to retrieve isem-like value for both cut-based and LH selectors + //ToolHandle<IAsgEGammaIsEMSelector> m_tool; // provides isemValue, but will not work with likelihood.. ToolHandle<IElectronPhotonShowerShapeFudgeTool> m_fudgeMCTool; std::string m_cut; std::string m_sgName; diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGammaPassSelectionWrapper.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGammaPassSelectionWrapper.h deleted file mode 100644 index 547df92ee7b718e4686bd3d541a35f5c0c398e22..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/EGammaPassSelectionWrapper.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////// -// EGammaPassSelectionWrapper.h (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -#ifndef DERIVATIONFRAMEWORK_EGAMMAPASSSELECTONWRAPPER_H -#define DERIVATIONFRAMEWORK_EGAMMAPASSSELECTONWRAPPER_H 1 - -#include<string> - -// Gaudi & Athena basics -#include "AthenaBaseComps/AthAlgTool.h" - -// DerivationFramework includes -#include "DerivationFrameworkInterfaces/IAugmentationTool.h" - -namespace DerivationFramework { - - /** @class EGammaPassSelectionWrapper - - the code used in this implementation is kindly stolen from: - atlasoff:: ISF/ISF_Core/ISF_Tools - - @author James Catmore -at- cern.ch - */ - class EGammaPassSelectionWrapper : public AthAlgTool, public IAugmentationTool { - - public: - /** Constructor with parameters */ - EGammaPassSelectionWrapper( const std::string& t, const std::string& n, const IInterface* p ); - - /** Destructor */ - ~EGammaPassSelectionWrapper(); - - // Athena algtool's Hooks - StatusCode initialize(); - StatusCode finalize(); - - /** Check that the current event passes this filter */ - virtual StatusCode addBranches() const; - - private: - std::vector<std::string> m_qualFlags; - std::string m_collName; - std::string m_sgPrefix; - - }; - -} - -#endif diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/TruthCaloShowerDecorator.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/TruthCaloShowerDecorator.h new file mode 100644 index 0000000000000000000000000000000000000000..dcc6dc61966f9ee336566ee7ee401b9c9935f53c --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/DerivationFrameworkEGamma/TruthCaloShowerDecorator.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef DERIVATIONFRAMEWORK_TRUTHCALOSHOWERDECORATOR_H +#define DERIVATIONFRAMEWORK_TRUTHCALOSHOWERDECORATOR_H + +#include "AthenaBaseComps/AthAlgTool.h" +#include "DerivationFrameworkInterfaces/IAugmentationTool.h" +#include "GaudiKernel/ToolHandle.h" +#include "CaloCalibHitRec/CalibHitToCaloCellTool.h" +#include <vector> + + +namespace DerivationFramework { + + class TruthCaloShowerDecorator : public AthAlgTool, public IAugmentationTool { + public: + TruthCaloShowerDecorator(const std::string& t, const std::string& n, const IInterface* p); + + StatusCode initialize(); + StatusCode finalize(); + virtual StatusCode addBranches() const; + + private: + + /** @brief Name of the input electron container **/ + std::string m_electronContainerName; + /** @brief Name of the truth particle container **/ + std::string m_truthParticleContainerName; + /** @brief barcode cut for egamma helpers **/ + int m_singleParticleBarcode; + + ToolHandle<CalibHitToCaloCellTool> m_calibhitToCaloCellTool; + //std::vector<std::string> m_truthClusterContainerNames; + + }; +} + +#endif // DERIVATIONFRAMEWORK_TRUTHCALOSHOWERDECORATOR_H diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM1ExtraContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM1ExtraContent.py index e3b257ff5d28574c32954b7d5cbc073ec9760741..c9f84c6756f3b96fcdd09ff6b134a686170f3e8e 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM1ExtraContent.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM1ExtraContent.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration #Content included in addition to the Smart Slimming Content @@ -91,34 +91,50 @@ ExtraContainersTruth=["TruthEvents", ExtraContainersElectrons=["Electrons", "GSFTrackParticles", - "egammaClusters"] + "egammaClusters", + "CaloCalTopoClusters", + "NewSwElectrons", # only if DoCellReweighting is ON + "MaxVarSwElectrons", # if variations are ON + "MinVarSwElectrons" # if variations are ON + ] # for trigger studies ExtraContainersTrigger=[ - # to access the HLT egamma xAOD collections "HLT_xAOD__ElectronContainer_egamma_Electrons", - "HLT_xAOD__PhotonContainer_egamma_Photons", - #L2Calo collections + "HLT_xAOD__ElectronContainer_egamma_ElectronsAux.", + "HLT_xAOD__PhotonContainer_egamma_Photons", + "HLT_xAOD__PhotonContainer_egamma_PhotonsAux.", "HLT_xAOD__TrigRingerRingsContainer_TrigT2CaloEgamma", - "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgamma", - # to access information about EF clusters and tracks + "HLT_xAOD__TrigRingerRingsContainer_TrigT2CaloEgammaAux.", + "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgamma", + "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgammaAux.", "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFex", + "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFexAux.", + "HLT_xAOD__TrigRNNOutputContainer_TrigRingerNeuralFex", + "HLT_xAOD__TrigRNNOutputContainer_TrigRingerNeuralFexAux.", "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrig", - # For trigger matching + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrigAux.", "HLT_xAOD__TrigPassBitsContainer_passbits", - # for L1 studies + "HLT_xAOD__TrigPassBitsContainer_passbitsAux.", "LVL1EmTauRoIs", - "HLT_TrigRoiDescriptorCollection_initialRoI", #Athena - "HLT_xAOD__RoiDescriptorStore_initialRoI" #AthAnalysis + "LVL1EmTauRoIsAux.", + "HLT_TrigRoiDescriptorCollection_initialRoI", + "HLT_TrigRoiDescriptorCollection_initialRoIAux.", + "HLT_xAOD__RoiDescriptorStore_initialRoI", + "HLT_xAOD__RoiDescriptorStore_initialRoIAux.", + "HLT_xAOD__TrigElectronContainer_L2ElectronFex", + "HLT_xAOD__TrigElectronContainer_L2ElectronFexAux." ] -ExtraContainersTriggerDataOnly=[ - "HLT_xAOD__TrigElectronContainer_L2ElectronFex" - ] +ExtraContainersTriggerDataOnly=[] ExtraVariablesEventShape=[ "TopoClusterIsoCentralEventShape.DensitySigma.Density.DensityArea", - "TopoClusterIsoForwardEventShape.DensitySigma.Density.DensityArea" + "TopoClusterIsoForwardEventShape.DensitySigma.Density.DensityArea", + "NeutralParticleFlowIsoCentralEventShape.Density.DensityArea.DensitySigma", + "NeutralParticleFlowIsoForwardEventShape.Density.DensityArea.DensitySigma", + "ParticleFlowIsoCentralEventShape.Density.DensityArea.DensitySigma", + "ParticleFlowIsoForwardEventShape.Density.DensityArea.DensitySigma" ] #should slim electron/fwdelectrons/cluster collections and keep only relevant subset of variables.. diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM2ExtraContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM2ExtraContent.py index 8c3a2fb8e39691cb1493ee432492acd075f3d4a1..e248b0a25cb25bd3e53edc2e5ba0b26f78482d46 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM2ExtraContent.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM2ExtraContent.py @@ -91,15 +91,32 @@ ExtraContainersElectrons=["Electrons","GSFTrackParticles","egammaClusters"] # for trigger studies ExtraContainersTrigger = [ "HLT_xAOD__ElectronContainer_egamma_Electrons", - #L2Calo collections + "HLT_xAOD__ElectronContainer_egamma_ElectronsAux.", + "HLT_xAOD__PhotonContainer_egamma_Photons", + "HLT_xAOD__PhotonContainer_egamma_PhotonsAux.", "HLT_xAOD__TrigRingerRingsContainer_TrigT2CaloEgamma", - "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgamma", - # to access information about EF clusters and tracks + "HLT_xAOD__TrigRingerRingsContainer_TrigT2CaloEgammaAux.", + "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgamma", + "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgammaAux.", "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFex", + "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFexAux.", + "HLT_xAOD__TrigRNNOutputContainer_TrigRingerNeuralFex", + "HLT_xAOD__TrigRNNOutputContainer_TrigRingerNeuralFexAux.", "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrig", - # For trigger matching - "HLT_xAOD__TrigPassBitsContainer_passbits"] + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrigAux.", + "HLT_xAOD__TrigPassBitsContainer_passbits", + "HLT_xAOD__TrigPassBitsContainer_passbitsAux.", + "LVL1EmTauRoIs", + "LVL1EmTauRoIsAux.", + "HLT_TrigRoiDescriptorCollection_initialRoI", + "HLT_TrigRoiDescriptorCollection_initialRoIAux.", + "HLT_xAOD__RoiDescriptorStore_initialRoI", + "HLT_xAOD__RoiDescriptorStore_initialRoIAux.", + "HLT_xAOD__TrigElectronContainer_L2ElectronFex", + "HLT_xAOD__TrigElectronContainer_L2ElectronFexAux." +] +ExtraContainersTriggerDataOnly = [] # should probably slim electron/cluster collections and keep only relevant subset of variables.. # no Jpsi with Fwd electrons so no ForwardElectrons, InDetTrackParticlesForwrd, ForwardElectronClusters diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM3ExtraContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM3ExtraContent.py index a9963636cd5b9381071701daaae82a494b43d5cf..990c084d3c0fb1c978d9ae9dabd4c83d75d482e5 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM3ExtraContent.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM3ExtraContent.py @@ -3,23 +3,15 @@ #Content included in addition to the Smart Slimming Content ExtraContentElectrons=[ - "Electrons.etcone20", - "Electrons.etcone30", - "Electrons.etcone40", - "Electrons.ptcone20", - "Electrons.ptcone30", - "Electrons.ptcone40", "Electrons.Loose", "Electrons.Medium", - "Electrons.Tight", - "Electrons.DFCommonElectronsLHLoose", - "Electrons.DFCommonElectronsLHMedium", - "Electrons.DFCommonElectronsLHTight", - "Electrons.DFCommonElectronsML", - "Electrons.author", - "Electrons.OQ" + "Electrons.Tight" ] +# only if DoCellReweighting is ON +ExtraContentElectrons += ["NewSwElectrons.trackParticleLinks.pt.eta.phi.m.caloClusterLinks.author.OQ.ethad1.ethad.f1.f3.f3core.e233.e237.e277.weta1.weta2.e2tsts1.fracs1.wtots1.emins1.emaxs1.etcone20.ptcone30.deltaEta1.deltaPhi1.deltaPhi2.deltaPhiRescaled2.deltaPhiFromLastMeasurement.Loose.Medium.Tight.LHLoose.DFCommonElectronsLHLoose.DFCommonElectronsLHLooseBL.DFCommonElectronsLHMedium.DFCommonElectronsLHTight.DFCommonElectronsML.ptcone20.ptcone30.ptcone40.ptvarcone20.ptvarcone30.ptvarcone40.topoetcone20.topoetcone30.topoetcone40.charge.Reta.Rphi.Eratio.Rhad.Rhad1.DeltaE.topoetcone20ptCorrection.topoetcone30ptCorrection.topoetcone40ptCorrection.etcone20ptCorrection.etcone30ptCorrection.etcone40ptCorrection.ambiguityLink.truthParticleLink.truthOrigin.truthType.truthPdgId.firstEgMotherTruthType.firstEgMotherTruthOrigin.firstEgMotherTruthParticleLink.firstEgMotherPdgId.lastEgMotherTruthType.lastEgMotherTruthOrigin.lastEgMotherTruthParticleLink.lastEgMotherPdgId.ambiguityType"] +# might need to add extra variables for Min/Max variations... but not for the moment + ExtraElectronsTruth=[ "Electrons.truthOrigin", "Electrons.truthType", @@ -106,29 +98,46 @@ ExtraContainersPhotons=["Photons", "egammaClusters", "ForwardElectrons", "ForwardElectronClusters", + "NewSwPhotons", # only if DoCellReweighting is ON + "MaxVarSwPhotons", # if variations are ON + "MinVarSwPhotons" # if variations are ON ] # for trigger studies ExtraContainersTrigger=[ - # to access the HLT egamma xAOD collections "HLT_xAOD__ElectronContainer_egamma_Electrons", + "HLT_xAOD__ElectronContainer_egamma_ElectronsAux.", "HLT_xAOD__PhotonContainer_egamma_Photons", + "HLT_xAOD__PhotonContainer_egamma_PhotonsAux.", + "HLT_xAOD__PhotonContainer_egamma_Iso_Photons", + "HLT_xAOD__PhotonContainer_egamma_Iso_PhotonsAux.", "HLT_xAOD__TrigElectronContainer_L2ElectronFex", + "HLT_xAOD__TrigElectronContainer_L2ElectronFexAux.", "HLT_xAOD__TrigPhotonContainer_L2PhotonFex", - # to access information about EF clusters and tracks + "HLT_xAOD__TrigPhotonContainer_L2PhotonFexAux.", "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFex", + "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFexAux.", "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_EFID", - # for L1 studies + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_EFIDAux.", "LVL1EmTauRoIs", + "LVL1EmTauRoIsAux.", "HLT_TrigPassBitsCollection_passbits", + "HLT_TrigPassBitsCollection_passbitsAux.", "HLT_TrigPassFlagsCollection_passflags", - "HLT_TrigRoiDescriptorCollection_initialRoI" + "HLT_TrigPassFlagsCollection_passflagsAux.", + "HLT_TrigRoiDescriptorCollection_initialRoI", + "HLT_TrigRoiDescriptorCollection_initialRoIAux." ] ExtraContainersTriggerDataOnly=[ "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgamma", + "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgammaAux.", "HLT_xAOD__CaloClusterContainer_TrigCaloClusterMaker", + "HLT_xAOD__CaloClusterContainer_TrigCaloClusterMakerAux.", "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_FTF", + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_FTFAux.", "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_L2ID", - "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrig" + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_L2IDAux.", + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrig", + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrigAux." ] diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM4ExtraContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM4ExtraContent.py index 8c50357fdeb058bfe829b5b179ea5a54613511be..27a494b113c2beb84d53433e74742388f00609ab 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM4ExtraContent.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM4ExtraContent.py @@ -1,24 +1,13 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration #Content included in addition to the Smart Slimming Content ExtraContentElectrons=[ - "Electrons.etcone20", - "Electrons.etcone30", - "Electrons.etcone40", - "Electrons.ptcone20", - "Electrons.ptcone30", - "Electrons.ptcone40", "Electrons.Loose", "Electrons.Medium", "Electrons.Tight", - "Electrons.DFCommonElectronsLHLoose", - "Electrons.DFCommonElectronsLHMedium", - "Electrons.DFCommonElectronsLHTight", - "Electrons.DFCommonElectronsML", - "Electrons.author", - "Electrons.OQ" ] + ExtraElectronsTruth=[ "Electrons.truthOrigin", "Electrons.truthType", @@ -77,22 +66,6 @@ ExtraContentHLTPhotons=[ "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFex.calE.calEta.calPhi.calM.e_sampl.eta_sampl.etaCalo.phiCalo.ETACALOFRAME.PHICALOFRAME" ] -#cells = ("Cells5x5","Cells3x5","Cells3x7","Cells7x11") -#layers_gains = ( "_Lr0", "_Lr1", "_Lr2", "_Lr3", -# "_Lr0_LwG", "_Lr1_LwG", "_Lr2_LwG", "_Lr3_LwG", -# "_Lr0_LwG", "_Lr1_MdG", "_Lr2_MdG", "_Lr3_MdG", -# "_Lr0_LwG", "_Lr1_HiG", "_Lr2_HiG", "_Lr3_HiG" ) -# -#for cell in cells: -# ExtraContentPhotons.append("Photons."+cell) -# for layer in layers_gains: -# ExtraContentPhotons.append("Photons."+cell+layer) -# -#for cell in cells: -# ExtraContentElectrons.append("Electrons."+cell) -# for layer in layers_gains: -# ExtraContentElectrons.append("Electrons."+cell+layer) -# from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import GainDecorator, getGainDecorations GainDecoratorTool = GainDecorator() ExtraContentPhotons.extend( getGainDecorations(GainDecoratorTool) ) @@ -114,30 +87,39 @@ ExtraContainersTruth=["TruthEvents", ExtraContainersPhotons=["Photons", "GSFTrackParticles", - "egammaClusters" + "egammaClusters", + "NewSwPhotons", # only if DoCellReweighting is ON + "MaxVarSwPhotons", # if variations are ON + "MinVarSwPhotons" # if variations are ON ] -# for trigger studies +# for trigger studies and for trigger matching ExtraContainersTrigger=[ - # to access the HLT egamma xAOD collections - "HLT_xAOD__ElectronContainer_egamma_Electrons", + "HLT_xAOD__MuonContainer_MuonEFInfo", + "HLT_xAOD__MuonContainer_MuonEFInfoAux.", + "HLT_xAOD__MuonContainer_MuonEFInfo_FullScan", + "HLT_xAOD__MuonContainer_MuonEFInfo_FullScanAux.", "HLT_xAOD__PhotonContainer_egamma_Photons", - "HLT_xAOD__TrigElectronContainer_L2ElectronFex", + "HLT_xAOD__PhotonContainer_egamma_PhotonsAux.", + "HLT_xAOD__PhotonContainer_egamma_Iso_Photons", + "HLT_xAOD__PhotonContainer_egamma_Iso_PhotonsAux.", "HLT_xAOD__TrigPhotonContainer_L2PhotonFex", - # to access information about EF clusters and tracks + "HLT_xAOD__TrigPhotonContainer_L2PhotonFexAux.", "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFex", - "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_EFID", - # for L1 studies + "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFexAux.", "LVL1EmTauRoIs", + "LVL1EmTauRoIsAux.", "HLT_TrigPassBitsCollection_passbits", + "HLT_TrigPassBitsCollection_passbitsAux.", "HLT_TrigPassFlagsCollection_passflags", - "HLT_TrigRoiDescriptorCollection_initialRoI" - ] + "HLT_TrigPassFlagsCollection_passflagsAux.", + "HLT_TrigRoiDescriptorCollection_initialRoI", + "HLT_TrigRoiDescriptorCollection_initialRoIAux." + ] ExtraContainersTriggerDataOnly=[ "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgamma", + "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgammaAux.", "HLT_xAOD__CaloClusterContainer_TrigCaloClusterMaker", - "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_FTF", - "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_L2ID", - "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrig" + "HLT_xAOD__CaloClusterContainer_TrigCaloClusterMakerAux." ] diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM5ExtraContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM5ExtraContent.py index 0f3aafeef9180dc389d328f309fbc41a96bce865..eca0e30a85720475ece329349965f899bc0f4bce 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM5ExtraContent.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM5ExtraContent.py @@ -95,27 +95,31 @@ ExtraContainersElectrons=["Electrons", # for trigger studies ExtraContainersTrigger=[ - # to access the HLT egamma xAOD collections "HLT_xAOD__ElectronContainer_egamma_Electrons", + "HLT_xAOD__ElectronContainer_egamma_ElectronsAux.", "HLT_xAOD__PhotonContainer_egamma_Photons", + "HLT_xAOD__PhotonContainer_egamma_PhotonsAux.", "HLT_xAOD__TrigElectronContainer_L2ElectronFex", + "HLT_xAOD__TrigElectronContainer_L2ElectronFexAux.", "HLT_xAOD__TrigPhotonContainer_L2PhotonFex", - # to access information about EF clusters and tracks + "HLT_xAOD__TrigPhotonContainer_L2PhotonFexAux.", "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFex", + "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFexAux.", "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_EFID", - # for L1 studies + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_EFIDAux.", "LVL1EmTauRoIs", + "LVL1EmTauRoIsAux.", "HLT_TrigPassBitsCollection_passbits", + "HLT_TrigPassBitsCollection_passbitsAux.", "HLT_TrigPassFlagsCollection_passflags", - "HLT_TrigRoiDescriptorCollection_initialRoI" + "HLT_TrigPassFlagsCollection_passflagsAux.", + "HLT_TrigRoiDescriptorCollection_initialRoI", + "HLT_TrigRoiDescriptorCollection_initialRoIAux." ] ExtraContainersTriggerDataOnly=[ "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgamma", - "HLT_xAOD__CaloClusterContainer_TrigCaloClusterMaker", - "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_FTF", - "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_L2ID", - "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrig" + "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgammaAux." ] #should probably slim electron/fwdelectrons/cluster collections and keep only relevant subset of variables.. diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM7ExtraContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM7ExtraContent.py index 33f8a33e4eadb20780d3448489ba8aec302c6009..2088e310366dd84b952298f48ad02feeaf5be89d 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM7ExtraContent.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM7ExtraContent.py @@ -94,13 +94,33 @@ ExtraContainersElectrons=["Electrons", "egammaClusters"] # for trigger studies -ExtraContainersTrigger = [ +ExtraContainersTrigger=[ "HLT_xAOD__ElectronContainer_egamma_Electrons", - #L2Calo collections + "HLT_xAOD__ElectronContainer_egamma_ElectronsAux.", + "HLT_xAOD__PhotonContainer_egamma_Photons", + "HLT_xAOD__PhotonContainer_egamma_PhotonsAux.", "HLT_xAOD__TrigRingerRingsContainer_TrigT2CaloEgamma", - "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgamma", - # to access information about EF clusters and tracks + "HLT_xAOD__TrigRingerRingsContainer_TrigT2CaloEgammaAux.", + "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgamma", + "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgammaAux.", "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFex", + "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFexAux.", + "HLT_xAOD__TrigRNNOutputContainer_TrigRingerNeuralFex", + "HLT_xAOD__TrigRNNOutputContainer_TrigRingerNeuralFexAux.", "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrig", - # For trigger matching - "HLT_xAOD__TrigPassBitsContainer_passbits"] + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrigAux.", + "HLT_xAOD__TrigPassBitsContainer_passbits", + "HLT_xAOD__TrigPassBitsContainer_passbitsAux.", + "LVL1EmTauRoIs", + "LVL1EmTauRoIsAux.", + "HLT_TrigRoiDescriptorCollection_initialRoI", + "HLT_TrigRoiDescriptorCollection_initialRoIAux.", + "HLT_xAOD__RoiDescriptorStore_initialRoI", + "HLT_xAOD__RoiDescriptorStore_initialRoIAux.", + "HLT_xAOD__TrigElectronContainer_L2ElectronFex", + "HLT_xAOD__TrigElectronContainer_L2ElectronFexAux." + ] + +ExtraContainersTriggerDataOnly=[ + ] + diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM8ExtraContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM8ExtraContent.py index e372ead0cb897fce9dd82ff6235c35fd1f52079e..b2b8645ca4251d4bd4e0ace83b67d891cf574728 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM8ExtraContent.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM8ExtraContent.py @@ -79,28 +79,6 @@ ExtraContainersElectrons=["Electrons", "ForwardElectronClusters"] # for trigger studies -ExtraContainersTrigger=[ - # to access the HLT egamma xAOD collections - "HLT_xAOD__ElectronContainer_egamma_Electrons", - "HLT_xAOD__PhotonContainer_egamma_Photons", - "HLT_xAOD__TrigElectronContainer_L2ElectronFex", - "HLT_xAOD__TrigPhotonContainer_L2PhotonFex", - # to access information about EF clusters and tracks - "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFex", - "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_EFID", - # for L1 studies - "LVL1EmTauRoIs", - "HLT_TrigPassBitsCollection_passbits", - "HLT_TrigPassFlagsCollection_passflags", - "HLT_TrigRoiDescriptorCollection_initialRoI" - ] - -ExtraContainersTriggerDataOnly=[ - "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgamma", - "HLT_xAOD__CaloClusterContainer_TrigCaloClusterMaker", - "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_FTF", - "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_L2ID", - "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrig" - ] +ExtraContainersTrigger=[] +ExtraContainersTriggerDataOnly=[] -#should slim electron/fwdelectrons/cluster collections and keep only relevant subset of variables.. diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM9ExtraContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM9ExtraContent.py index 07e1c96e7ff0de9849122549e43a3bcaf4688132..35c6d8b288ff654a72a9b3ae088299afbadb3429 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM9ExtraContent.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGAM9ExtraContent.py @@ -89,27 +89,41 @@ ExtraContainersPhotons=["Photons", # for trigger studies ExtraContainersTrigger=[ - # to access the HLT egamma xAOD collections "HLT_xAOD__ElectronContainer_egamma_Electrons", + "HLT_xAOD__ElectronContainer_egamma_ElectronsAux.", "HLT_xAOD__PhotonContainer_egamma_Photons", + "HLT_xAOD__PhotonContainer_egamma_PhotonsAux.", + "HLT_xAOD__PhotonContainer_egamma_Iso_Photons", + "HLT_xAOD__PhotonContainer_egamma_Iso_PhotonsAux.", "HLT_xAOD__TrigElectronContainer_L2ElectronFex", + "HLT_xAOD__TrigElectronContainer_L2ElectronFexAux.", "HLT_xAOD__TrigPhotonContainer_L2PhotonFex", - # to access information about EF clusters and tracks + "HLT_xAOD__TrigPhotonContainer_L2PhotonFexAux.", "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFex", + "HLT_xAOD__CaloClusterContainer_TrigEFCaloCalibFexAux.", "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_EFID", - # for L1 studies + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_EFIDAux.", "LVL1EmTauRoIs", + "LVL1EmTauRoIsAux.", "HLT_TrigPassBitsCollection_passbits", + "HLT_TrigPassBitsCollection_passbitsAux.", "HLT_TrigPassFlagsCollection_passflags", - "HLT_TrigRoiDescriptorCollection_initialRoI" + "HLT_TrigPassFlagsCollection_passflagsAux.", + "HLT_TrigRoiDescriptorCollection_initialRoI", + "HLT_TrigRoiDescriptorCollection_initialRoIAux." ] ExtraContainersTriggerDataOnly=[ "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgamma", + "HLT_xAOD__TrigEMClusterContainer_TrigT2CaloEgammaAux.", "HLT_xAOD__CaloClusterContainer_TrigCaloClusterMaker", + "HLT_xAOD__CaloClusterContainer_TrigCaloClusterMakerAux.", "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_FTF", + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_FTFAux.", "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_L2ID", - "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrig" + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_L2IDAux.", + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrig", + "HLT_xAOD__TrackParticleContainer_InDetTrigTrackingxAODCnv_Electron_IDTrigAux." ] #should slim electron/fwdelectrons/cluster collections and keep only relevant subset of variables.. diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py index e1905f4780c919edd7ea403f0dc4181236c37b14..738405860bb69dfc38cd650d4802c48458eb0953 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/EGammaCommon.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration #******************************************************************** # EGammaCommon.py @@ -22,7 +22,7 @@ ToolSvc += DFCommonPhotonsDirection #==================================================================== # SHOWER SHAPE FUDGING IN MC -# (PRESELECTION=16: FUDGE FACTORS GEO21->DATA12) +# (PRESELECTION=22: FUDGE FACTORS RUN2 2015+2016 DATA, Rel 21) #==================================================================== from PyUtils import AthFile @@ -37,22 +37,19 @@ if isMC: simulationFlavour = af.fileinfos['metadata']['/Simulation/Parameters']['SimulationFlavour'] isFullSim = simulationFlavour in ('default', 'MC12G4', 'FullG4') -print("EGammaCommon: isMC = ", isMC) +print "EGammaCommon: isMC = ", isMC if isMC: - print("EGammaCommon: isFullSim = ", isFullSim) + print "EGammaCommon: isFullSim = ", isFullSim if isFullSim: -#from AthenaCommon.GlobalFlags import globalflags -#print "globalflags.DataSource(): ", globalflags.DataSource() -#if globalflags.DataSource()=='geant4': from ElectronPhotonShowerShapeFudgeTool.ElectronPhotonShowerShapeFudgeToolConf import ElectronPhotonShowerShapeFudgeTool - DF_ElectronPhotonShowerShapeFudgeTool = ElectronPhotonShowerShapeFudgeTool(Preselection=16) + DF_ElectronPhotonShowerShapeFudgeTool = ElectronPhotonShowerShapeFudgeTool(Preselection=22) ToolSvc += DF_ElectronPhotonShowerShapeFudgeTool - print(DF_ElectronPhotonShowerShapeFudgeTool) + print DF_ElectronPhotonShowerShapeFudgeTool #==================================================================== -# ELECTRON SELECTION (loose, medium and tight LLH) +# ELECTRON LH SELECTORS # see http://acode-browser.usatlas.bnl.gov/lxr/source/atlas/Reconstruction/egamma/egammaTools/python/EMPIDBuilderBase.py on how to configure the selectors #==================================================================== from ROOT import LikeEnum @@ -79,44 +76,59 @@ ElectronLHSelectorTight = ConfiguredAsgElectronLikelihoodTool("ElectronLHSelecto ElectronLHSelectorTight.primaryVertexContainer = "PrimaryVertices" ToolSvc += ElectronLHSelectorTight +# LooseBL +from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AsgElectronLikelihoodTool +ElectronLHSelectorLooseBL = AsgElectronLikelihoodTool("ElectronLHSelectorLooseBL", WorkingPoint="LooseBLLHElectron") +ElectronLHSelectorLooseBL.primaryVertexContainer = "PrimaryVertices" +ToolSvc += ElectronLHSelectorLooseBL + #==================================================================== -# ELECTRON SELECTION (loose, medium and tight cut-based) +# ELECTRON CHARGE SELECTION #==================================================================== -from ROOT import egammaPID +from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AsgElectronChargeIDSelectorTool +ElectronChargeIDSelector = AsgElectronChargeIDSelectorTool("ElectronChargeIDSelectorLoose") +ElectronChargeIDSelector.primaryVertexContainer = "PrimaryVertices" +ElectronChargeIDSelector.TrainingFile = "ElectronPhotonSelectorTools/ChargeID/ECIDS_20180731rel21Summer2018.root" +ToolSvc += ElectronChargeIDSelector -from ElectronPhotonSelectorTools.ConfiguredAsgElectronIsEMSelectors import ConfiguredAsgElectronIsEMSelector +#==================================================================== +# FWD ELECTRON LH SELECTORS +#==================================================================== +from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AsgForwardElectronLikelihoodTool -# Loose -ElectronIsEMSelectorLoose = ConfiguredAsgElectronIsEMSelector("ElectronIsEMSelectorLoose", egammaPID.ElectronIDLoosePP) -ToolSvc += ElectronIsEMSelectorLoose +ForwardElectronLHSelectorLoose = AsgForwardElectronLikelihoodTool("ForwardElectronLHSelectorLoose", WorkingPoint="LooseLHForwardElectron") +ToolSvc += ForwardElectronLHSelectorLoose -# Medium -ElectronIsEMSelectorMedium = ConfiguredAsgElectronIsEMSelector("ElectronIsEMSelectorMedium", egammaPID.ElectronIDMediumPP) -ToolSvc += ElectronIsEMSelectorMedium +ForwardElectronLHSelectorMedium = AsgForwardElectronLikelihoodTool("ForwardElectronLHSelectorMedium", WorkingPoint="MediumLHForwardElectron") +ToolSvc += ForwardElectronLHSelectorMedium -# Tight -ElectronIsEMSelectorTight = ConfiguredAsgElectronIsEMSelector("ElectronIsEMSelectorTight", egammaPID.ElectronIDTightPP) -ToolSvc += ElectronIsEMSelectorTight +ForwardElectronLHSelectorTight = AsgForwardElectronLikelihoodTool("ForwardElectronLHSelectorTight", WorkingPoint="TightLHForwardElectron") +ToolSvc += ForwardElectronLHSelectorTight -#==================================================================== -# ELECTRON SELECTION (multi lepton) -#==================================================================== -from ElectronPhotonSelectorTools.ElectronPhotonSelectorToolsConf import AsgElectronMultiLeptonSelector -ElectronMLSelector = AsgElectronMultiLeptonSelector("ElectronMLSelector") -ToolSvc += ElectronMLSelector #==================================================================== # PHOTON SELECTION (loose and tight cut-based) #==================================================================== -# Loose +from ROOT import egammaPID + from ElectronPhotonSelectorTools.ConfiguredAsgPhotonIsEMSelectors import ConfiguredAsgPhotonIsEMSelector +from ElectronPhotonSelectorTools.PhotonIsEMSelectorMapping import photonPIDmenu + +# Loose PhotonIsEMSelectorLoose = ConfiguredAsgPhotonIsEMSelector("PhotonIsEMSelectorLoose", egammaPID.PhotonIDLoose) ToolSvc += PhotonIsEMSelectorLoose -# Tight +# Tight (default == pt-dependent) PhotonIsEMSelectorTight = ConfiguredAsgPhotonIsEMSelector("PhotonIsEMSelectorTight", egammaPID.PhotonIDTight) ToolSvc += PhotonIsEMSelectorTight +# Tight (pt-inclusive) +# To be removed when pt-dependent menu above is supported with scale factors +PhotonIsEMSelectorTightPtIncl = ConfiguredAsgPhotonIsEMSelector("PhotonIsEMSelectorTightPtIncl", egammaPID.PhotonIDTight,menu=photonPIDmenu.menuPtInclJan2018) +ToolSvc += PhotonIsEMSelectorTightPtIncl + + + #==================================================================== # RECTANGULAR CLUSTER TOOLS #==================================================================== @@ -151,100 +163,108 @@ EGAMCOM_caloFillRect711 = CaloFillRectangularCluster ( name = "EGAMCOMCaloFillRe fill_cluster = True) ToolSvc += EGAMCOM_caloFillRect711 + #==================================================================== # AUGMENTATION TOOLS #==================================================================== from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__AsgSelectionToolWrapper - +from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGSelectionToolWrapper +from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGElectronLikelihoodToolWrapper # decorate electrons with the output of LH very loose -ElectronPassLHVeryLoose = DerivationFramework__AsgSelectionToolWrapper( name = "ElectronPassLHVeryLoose", - AsgSelectionTool = ElectronLHSelectorVeryLoose, - CutType = "", - StoreGateEntryName = "DFCommonElectronsLHVeryLoose", - ContainerName = "Electrons") +ElectronPassLHVeryLoose = DerivationFramework__EGSelectionToolWrapper( name = "ElectronPassLHVeryLoose", + EGammaSelectionTool = ElectronLHSelectorVeryLoose, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonElectronsLHVeryLoose", + ContainerName = "Electrons") ToolSvc += ElectronPassLHVeryLoose -print(ElectronPassLHVeryLoose) +print ElectronPassLHVeryLoose # decorate electrons with the output of LH loose -ElectronPassLHLoose = DerivationFramework__AsgSelectionToolWrapper( name = "ElectronPassLHLoose", - AsgSelectionTool = ElectronLHSelectorLoose, - CutType = "", - StoreGateEntryName = "DFCommonElectronsLHLoose", - ContainerName = "Electrons") +ElectronPassLHLoose = DerivationFramework__EGSelectionToolWrapper( name = "ElectronPassLHLoose", + EGammaSelectionTool = ElectronLHSelectorLoose, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonElectronsLHLoose", + ContainerName = "Electrons") ToolSvc += ElectronPassLHLoose -print(ElectronPassLHLoose) +print ElectronPassLHLoose -# decorate electrons with the output of LH medium -ElectronPassLHMedium = DerivationFramework__AsgSelectionToolWrapper( name = "ElectronPassLHMedium", - AsgSelectionTool = ElectronLHSelectorMedium, +# decorate electrons with the output of LH loose+BL +ElectronPassLHLooseBL = DerivationFramework__EGSelectionToolWrapper( name = "ElectronPassLHLooseBL", + EGammaSelectionTool = ElectronLHSelectorLooseBL, + EGammaFudgeMCTool = "", CutType = "", - StoreGateEntryName = "DFCommonElectronsLHMedium", + StoreGateEntryName = "DFCommonElectronsLHLooseBL", ContainerName = "Electrons") -ToolSvc += ElectronPassLHMedium -print(ElectronPassLHMedium) +ToolSvc += ElectronPassLHLooseBL +print ElectronPassLHLooseBL -# decorate electrons with the output of LH tight -ElectronPassLHTight = DerivationFramework__AsgSelectionToolWrapper( name = "ElectronPassLHTight", - AsgSelectionTool = ElectronLHSelectorTight, +# decorate electrons with the output of LH medium +ElectronPassLHMedium = DerivationFramework__EGSelectionToolWrapper( name = "ElectronPassLHMedium", + EGammaSelectionTool = ElectronLHSelectorMedium, + EGammaFudgeMCTool = "", CutType = "", - StoreGateEntryName = "DFCommonElectronsLHTight", + StoreGateEntryName = "DFCommonElectronsLHMedium", ContainerName = "Electrons") -ToolSvc += ElectronPassLHTight -print(ElectronPassLHTight) - - -from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGSelectionToolWrapper - -# decorate electrons with the output of IsEM loose -ElectronPassIsEMLoose = DerivationFramework__EGSelectionToolWrapper( name = "ElectronPassIsEMLoose", - EGammaSelectionTool = ElectronIsEMSelectorLoose, - EGammaFudgeMCTool = None, - CutType = "", - StoreGateEntryName = "DFCommonElectronsIsEMLoose", - ContainerName = "Electrons") - -ToolSvc += ElectronPassIsEMLoose -print(ElectronPassIsEMLoose) - -# decorate electrons with the output of IsEM medium -ElectronPassIsEMMedium = DerivationFramework__EGSelectionToolWrapper( name = "ElectronPassIsEMMedium", - EGammaSelectionTool = ElectronIsEMSelectorMedium, - EGammaFudgeMCTool = None, - CutType = "", - StoreGateEntryName = "DFCommonElectronsIsEMMedium", - ContainerName = "Electrons") - - -ToolSvc += ElectronPassIsEMMedium -print(ElectronPassIsEMMedium) - -# decorate electrons with the output of IsEM tight -ElectronPassIsEMTight = DerivationFramework__EGSelectionToolWrapper( name = "ElectronPassIsEMTight", - EGammaSelectionTool = ElectronIsEMSelectorTight, - EGammaFudgeMCTool = None, - CutType = "", - StoreGateEntryName = "DFCommonElectronsIsEMTight", - ContainerName = "Electrons") - -ToolSvc += ElectronPassIsEMTight -print(ElectronPassIsEMTight) - -# decorate electrons with the output of MultiLepton -from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__AsgSelectionToolWrapper -ElectronPassML = DerivationFramework__AsgSelectionToolWrapper( name = "ElectronPassML", - AsgSelectionTool = ElectronMLSelector, - CutType = "", - StoreGateEntryName = "DFCommonElectronsML", - ContainerName = "Electrons") -ToolSvc += ElectronPassML -print(ElectronPassML) +ToolSvc += ElectronPassLHMedium +print ElectronPassLHMedium +# decorate electrons with the output of LH tight +ElectronPassLHTight = DerivationFramework__EGSelectionToolWrapper( name = "ElectronPassLHTight", + EGammaSelectionTool = ElectronLHSelectorTight, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonElectronsLHTight", + ContainerName = "Electrons") +ToolSvc += ElectronPassLHTight +print ElectronPassLHTight + +# decorate electrons with the output of ECIDS ---------------------------------------------------------------------- +ElectronPassECIDS = DerivationFramework__EGElectronLikelihoodToolWrapper( name = "ElectronPassECIDS", + EGammaElectronLikelihoodTool = ElectronChargeIDSelector, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonElectronsECIDS", + + ContainerName = "Electrons", + StoreTResult = True) +ToolSvc += ElectronPassECIDS +print ElectronPassECIDS + +# decorate forward electrons with the output of LH loose +ForwardElectronPassLHLoose = DerivationFramework__EGSelectionToolWrapper( name = "ForwardElectronPassLHLoose", + EGammaSelectionTool = ForwardElectronLHSelectorLoose, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonForwardElectronsLHLoose", + ContainerName = "ForwardElectrons") +ToolSvc += ForwardElectronPassLHLoose +print ForwardElectronPassLHLoose + +# decorate forward electrons with the output of LH medium +ForwardElectronPassLHMedium = DerivationFramework__EGSelectionToolWrapper( name = "ForwardElectronPassLHMedium", + EGammaSelectionTool = ForwardElectronLHSelectorMedium, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonForwardElectronsLHMedium", + ContainerName = "ForwardElectrons") +ToolSvc += ForwardElectronPassLHMedium +print ForwardElectronPassLHMedium + +# decorate forward electrons with the output of LH tight +ForwardElectronPassLHTight = DerivationFramework__EGSelectionToolWrapper( name = "ForwardElectronPassLHTight", + EGammaSelectionTool = ForwardElectronLHSelectorTight, + EGammaFudgeMCTool = "", + CutType = "", + StoreGateEntryName = "DFCommonForwardElectronsLHTight", + ContainerName = "ForwardElectrons") +ToolSvc += ForwardElectronPassLHTight +print ForwardElectronPassLHTight -from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGSelectionToolWrapper # decorate photons with the output of IsEM loose # on MC, fudge the shower shapes before computing the ID (but the original shower shapes are not overridden) -#if globalflags.DataSource()=='geant4': if isFullSim: PhotonPassIsEMLoose = DerivationFramework__EGSelectionToolWrapper( name = "PhotonPassIsEMLoose", EGammaSelectionTool = PhotonIsEMSelectorLoose, @@ -260,11 +280,10 @@ else: StoreGateEntryName = "DFCommonPhotonsIsEMLoose", ContainerName = "Photons") ToolSvc += PhotonPassIsEMLoose -print(PhotonPassIsEMLoose) +print PhotonPassIsEMLoose # decorate photons with the output of IsEM tight # on full-sim MC, fudge the shower shapes before computing the ID (but the original shower shapes are not overridden) -#if globalflags.DataSource()=='geant4': if isFullSim: PhotonPassIsEMTight = DerivationFramework__EGSelectionToolWrapper( name = "PhotonPassIsEMTight", EGammaSelectionTool = PhotonIsEMSelectorTight, @@ -280,15 +299,62 @@ else: StoreGateEntryName = "DFCommonPhotonsIsEMTight", ContainerName = "Photons") ToolSvc += PhotonPassIsEMTight -print(PhotonPassIsEMTight) +print PhotonPassIsEMTight + +# decorate photons with the output of IsEM tight pt-inclusive menu +# Can be removed once pt-dependent cuts are fully supported. +# On full-sim MC, fudge the shower shapes before computing the ID (but the original shower shapes are not overridden) +PhotonPassIsEMTightPtIncl = DerivationFramework__EGSelectionToolWrapper( name = "PhotonPassIsEMTightPtIncl", + EGammaSelectionTool = PhotonIsEMSelectorTightPtIncl, + EGammaFudgeMCTool = (DF_ElectronPhotonShowerShapeFudgeTool if isFullSim else None), + CutType = "", + StoreGateEntryName = "DFCommonPhotonsIsEMTightPtIncl", + ContainerName = "Photons") +ToolSvc += PhotonPassIsEMTightPtIncl +print PhotonPassIsEMTightPtIncl + +# decorate photons with the photon cleaning flags +# on MC, fudge the shower shapes before computing the flags +from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGPhotonCleaningWrapper +if isFullSim: + PhotonPassCleaning = DerivationFramework__EGPhotonCleaningWrapper( name = "PhotonPassCleaning", + EGammaFudgeMCTool = DF_ElectronPhotonShowerShapeFudgeTool, + StoreGateEntryName = "DFCommonPhotonsCleaning", + ContainerName = "Photons") +else: + PhotonPassCleaning = DerivationFramework__EGPhotonCleaningWrapper( name = "PhotonPassCleaning", + EGammaFudgeMCTool = None, + StoreGateEntryName = "DFCommonPhotonsCleaning", + ContainerName = "Photons") +ToolSvc += PhotonPassCleaning +print PhotonPassCleaning + +# decorate central electrons and photons with a flag to tell the the candidates are affected by the crack bug in mc16a and data 2015+2016 +from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGCrackVetoCleaningTool as DF_EGCVCT +PhotonPassCrackVeto = DF_EGCVCT(name = "PhotonPassCrackVeto", + StoreGateEntryName = "DFCommonCrackVetoCleaning", + ContainerName = "Photons") +ElectronPassCrackVeto = DF_EGCVCT(name = "ElectronPassCrackVeto", + StoreGateEntryName = "DFCommonCrackVetoCleaning", + ContainerName = "Electrons") +ToolSvc += [PhotonPassCrackVeto,ElectronPassCrackVeto] + +# decorate some electrons with an additional ambiguity flag against internal and early material conversion +from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGElectronAmbiguityTool as DF_EGEAT +ElectronAmbiguity = DF_EGEAT(name = "ElectronAdditionnalAmbiguity", + isMC = (globalflags.DataSource()!='data')) +ToolSvc += ElectronAmbiguity # list of all the decorators so far EGAugmentationTools = [DFCommonPhotonsDirection, - ElectronPassLHVeryLoose,ElectronPassLHLoose,ElectronPassLHMedium,ElectronPassLHTight, - ElectronPassIsEMLoose,ElectronPassIsEMMedium,ElectronPassIsEMTight, - PhotonPassIsEMLoose, - PhotonPassIsEMTight, - ElectronPassML] + ElectronPassLHVeryLoose, ElectronPassLHLoose, ElectronPassLHLooseBL, ElectronPassLHMedium, ElectronPassLHTight, + ForwardElectronPassLHLoose, ForwardElectronPassLHMedium, ForwardElectronPassLHTight, + ElectronPassECIDS, + PhotonPassIsEMLoose, PhotonPassIsEMTight, + PhotonPassIsEMTightPtIncl, + PhotonPassCleaning, + PhotonPassCrackVeto,ElectronPassCrackVeto, + ElectronAmbiguity] #================================================== # Truth Related tools @@ -297,13 +363,16 @@ if rec.doTruth(): # Decorate Electron with bkg electron type/origin from MCTruthClassifier.MCTruthClassifierBase import MCTruthClassifier as BkgElectronMCTruthClassifier + BkgElectronMCTruthClassifier.barcodeG4Shift=(DerivationFrameworkSimBarcodeOffset+1) + from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__BkgElectronClassification BkgElectronClassificationTool = DerivationFramework__BkgElectronClassification (name = "BkgElectronClassificationTool", - MCTruthClassifierTool = BkgElectronMCTruthClassifier) + MCTruthClassifierTool = BkgElectronMCTruthClassifier, + barcodeCut=DerivationFrameworkSimBarcodeOffset) ToolSvc += BkgElectronClassificationTool - print(BkgElectronClassificationTool) + print BkgElectronClassificationTool EGAugmentationTools.append(BkgElectronClassificationTool) # Decorate egammaTruthParticles with truth-particle-level etcone20,30,40 @@ -317,7 +386,7 @@ if rec.doTruth(): IsolationVarNamePrefix = 'etcone', ChargedParticlesOnly = False) ToolSvc += TruthEgetIsolationTool - print(TruthEgetIsolationTool) + print TruthEgetIsolationTool EGAugmentationTools.append(TruthEgetIsolationTool) # Decorate egammaTruthParticles with truth-particle-level ptcone20,30,40 @@ -329,15 +398,14 @@ if rec.doTruth(): IsolationVarNamePrefix = 'ptcone', ChargedParticlesOnly = True) ToolSvc += TruthEgptIsolationTool - print(TruthEgptIsolationTool) + print TruthEgptIsolationTool EGAugmentationTools.append(TruthEgptIsolationTool) # Compute the truth-particle-level energy density in the central eta region - from EventShapeTools.EventDensityConfig import configEventDensityTool, EventDensityAlg + from EventShapeTools.EventDensityConfig import configEventDensityTool, EventDensityAthAlg from JetRec.JetRecStandard import jtm - tc=configEventDensityTool("EDTruthCentralTool", - inputlabel = jtm.truthget.Label, - radius = 0.5, + tc=configEventDensityTool("EDTruthCentralTool", jtm.truthget, + 0.5, AbsRapidityMax = 1.5, OutputContainer = "TruthIsoCentralEventShape", OutputLevel = 3, @@ -345,9 +413,8 @@ if rec.doTruth(): ToolSvc += tc # Compute the truth-particle-level energy density in the forward eta region - tf=configEventDensityTool("EDTruthForwardTool", - inputlabel = jtm.truthget.Label, - radius = 0.5, + tf=configEventDensityTool("EDTruthForwardTool", jtm.truthget, + 0.5, AbsRapidityMin = 1.5, AbsRapidityMax = 3.0, OutputContainer = "TruthIsoForwardEventShape", @@ -358,8 +425,9 @@ if rec.doTruth(): # Schedule the two energy density tools for running from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() - topSequence += EventDensityAlg("EDTruthCentralAlg", EventDensityTool = tc ) - topSequence += EventDensityAlg("EDTruthForwardAlg", EventDensityTool = tf ) + topSequence += EventDensityAthAlg("EDTruthCentralAlg", EventDensityTool = tc ) + topSequence += EventDensityAthAlg("EDTruthForwardAlg", EventDensityTool = tf ) + #======================================= # CREATE THE DERIVATION KERNEL ALGORITHM @@ -370,5 +438,12 @@ DerivationFrameworkJob += CfgMgr.DerivationFramework__CommonAugmentation("EGamma AugmentationTools = EGAugmentationTools ) +#======================================= +# ADD TOOLS +#======================================= + +import IsolationAlgs.IsoUpdatedTrackCones as isoCones +if not hasattr(DerivationFrameworkJob,"IsolationBuilderTight1000"): + DerivationFrameworkJob += isoCones.GetUpdatedIsoTrackCones() diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPContent.py index d8c24f416f9c114992d83944796603490e7e7b87..94950a9c2c2a5c100151bc9a024e2fad3ab337f0 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPContent.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPContent.py @@ -1,14 +1,22 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration ElectronsCPContent = [ "Electrons", -"ElectronsAux.trackParticleLinks.pt.eta.phi.m.caloClusterLinks.author.OQ.ethad1.ethad.f1.f3.f3core.e233.e237.e277.weta1.weta2.e2tsts1.fracs1.wtots1.emins1.emaxs1.etcone20.ptcone30.deltaEta1.deltaPhi1.deltaPhi2.deltaPhiRescaled2.deltaPhiFromLastMeasurement.Loose.Medium.Tight.LHLoose.DFCommonElectronsLHLoose.DFCommonElectronsLHMedium.DFCommonElectronsLHTight.DFCommonElectronsML.ptcone20.ptcone30.ptcone40.ptvarcone20.ptvarcone30.ptvarcone40.topoetcone20.topoetcone30.topoetcone40.charge.Reta.Rphi.Eratio.Rhad.Rhad1.DeltaE.DFCommonElectronsIsEMLoose.DFCommonElectronsIsEMMedium.DFCommonElectronsIsEMTight.topoetcone20ptCorrection.topoetcone30ptCorrection.topoetcone40ptCorrection.etcone20ptCorrection.etcone30ptCorrection.etcone40ptCorrection.ambiguityLink.truthParticleLink.truthOrigin.truthType.truthPdgId.firstEgMotherTruthType.firstEgMotherTruthOrigin.firstEgMotherTruthParticleLink.firstEgMotherPdgId.lastEgMotherTruthType.lastEgMotherTruthOrigin.lastEgMotherTruthParticleLink.lastEgMotherPdgId.ambiguityType", +"ElectronsAux.trackParticleLinks.pt.eta.phi.m.charge.author.OQ.DFCommonElectronsLHVeryLoose.DFCommonElectronsLHLoose.DFCommonElectronsLHLooseBL.DFCommonElectronsLHMedium.DFCommonElectronsLHTight.DFCommonElectronsLHVeryLooseIsEMValue.DFCommonElectronsLHLooseIsEMValue.DFCommonElectronsLHLooseBLIsEMValue.DFCommonElectronsLHMediumIsEMValue.DFCommonElectronsLHTightIsEMValue.DFCommonElectronsECIDS.DFCommonElectronsECIDSResult.ptvarcone20.ptvarcone40_TightTTVALooseCone_pt1000.topoetcone20.topoetcone20ptCorrection.ptcone20_TightTTVALooseCone_pt500.ptcone20_TightTTVALooseCone_pt1000.ptvarcone20_TightTTVA_pt1000.ptvarcone30_TightTTVA_pt500.ptvarcone30_TightTTVA_pt1000.ptvarcone20_TightTTVALooseCone_pt1000.ptvarcone30_TightTTVALooseCone_pt500.ptvarcone30_TightTTVALooseCone_pt1000.neflowisol20.core57cellsEnergyCorrection.topoetconecoreConeSCEnergyCorrection.topoetconecoreConeEnergyCorrection.DFCommonCrackVetoCleaning.caloClusterLinks.ambiguityLink.truthParticleLink.truthOrigin.truthType.truthPdgId.firstEgMotherTruthType.firstEgMotherTruthOrigin.firstEgMotherTruthParticleLink.firstEgMotherPdgId.ambiguityType.DFCommonAddAmbiguity", "GSFTrackParticles", -"GSFTrackParticlesAux.chiSquared.phi.d0.theta.qOverP.definingParametersCovMatrix.parameterX.parameterPX.parameterPY.parameterPZ.parameterPosition.numberOfBLayerHits.numberOfBLayerOutliers.expectBLayerHit.numberOfPixelHits.numberOfPixelOutliers.numberOfPixelDeadSensors.numberOfSCTHits.numberOfSCTOutliers.numberOfSCTDeadSensors.numberOfTRTHits.numberOfTRTOutliers.numberOfTRTHighThresholdHits.numberOfTRTHighThresholdOutliers.numberOfTRTXenonHits.z0.vz.charge.vertexLink.numberOfInnermostPixelLayerHits.numberOfInnermostPixelLayerOutliers.numberOfNextToInnermostPixelLayerOutliers.expectInnermostPixelLayerHit.eProbabilityComb.truthParticleLink.originalTrackParticle.eProbabilityHT.numberOfNextToInnermostPixelLayerHits.expectNextToInnermostPixelLayerHit", +"GSFTrackParticlesAux.chiSquared.phi.d0.theta.qOverP.definingParametersCovMatrix.numberOfPixelHits.numberOfPixelOutliers.numberOfPixelDeadSensors.numberOfSCTHits.numberOfSCTOutliers.numberOfSCTDeadSensors.z0.vz.charge.vertexLink.numberOfInnermostPixelLayerHits.numberOfInnermostPixelLayerOutliers.numberOfNextToInnermostPixelLayerOutliers.expectInnermostPixelLayerHit.truthParticleLink.originalTrackParticle.numberOfNextToInnermostPixelLayerHits.expectNextToInnermostPixelLayerHit", "GSFConversionVertices", "GSFConversionVerticesAux.px.py.pz", "PrimaryVertices", "PrimaryVerticesAux.trackParticleLinks.vertexType.neutralParticleLinks", "egammaClusters", -"egammaClustersAux.calE.calEta.calPhi.e_sampl.eta_sampl.etaCalo.phiCalo.ETACALOFRAME.PHICALOFRAME" +"egammaClustersAux.calE.calEta.calPhi.e_sampl.eta_sampl.etaCalo.phiCalo.ETACALOFRAME.PHICALOFRAME.ETA2CALOFRAME.PHI2CALOFRAME.constituentClusterLinks", +"TopoClusterIsoCentralEventShape", +"TopoClusterIsoCentralEventShapeAux.Density", +"TopoClusterIsoForwardEventShape", +"TopoClusterIsoForwardEventShapeAux.Density", +"NeutralParticleFlowIsoCentralEventShape", +"NeutralParticleFlowIsoCentralEventShapeAux.Density", +"NeutralParticleFlowIsoForwardEventShape", +"NeutralParticleFlowIsoForwardEventShapeAux.Density" ] diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPDetailedContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPDetailedContent.py new file mode 100644 index 0000000000000000000000000000000000000000..fa5be95ec6489bef9e0500f3de5dca497ec682dc --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/ElectronsCPDetailedContent.py @@ -0,0 +1,11 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +ExtraElectronShowerShapes = ["Electrons.Rhad.Rhad1.e277.Reta.Rphi.weta2.f1.Eratio.DeltaE.weta1.fracs1.wtots1.f3.f3core.deltaEta1.deltaPhi1.deltaPhi2.deltaPhiRescaled2.deltaPhiFromLastMeasurement"] +ExtraElectronTruthInfo = ["Electrons.lastEgMotherTruthType.lastEgMotherTruthOrigin.lastEgMotherTruthParticleLink.lastEgMotherPdgId"] +ElectronsCPDetailedContent = ExtraElectronShowerShapes + ExtraElectronTruthInfo + +ExtraElectronGSFVar = ["GSFTrackParticles.parameterX.parameterPX.parameterPY.parameterPZ.parameterPosition.numberOfTRTHits.numberOfTRTOutliers.numberOfTRTHighThresholdHits.numberOfTRTHighThresholdOutliers.numberOfTRTXenonHits.eProbabilityComb.eProbabilityHT"] +GSFTracksCPDetailedContent = ExtraElectronGSFVar + +ElectronsAddAmbiguityContent = ["Electrons.DFCommonSimpleConvRadius.DFCommonSimpleConvPhi.DFCommonSimpleMee.DFCommonSimpleMeeAtVtx.DFCommonSimpleSeparation.DFCommonProdTrueRadius.DFCommonProdTruePhi.DFCommonProdTrueZ"] + diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/PhotonsCPContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/PhotonsCPContent.py index f53499fd1b0df974909d27c6b46783388b56435e..483f80478f6cbffe359819f758de835c1ef90f52 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/PhotonsCPContent.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/PhotonsCPContent.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration PhotonsCPContent = [ "GSFConversionVertices", @@ -6,11 +6,15 @@ PhotonsCPContent = [ "GSFTrackParticles", "GSFTrackParticlesAux.phi.theta.qOverP.numberOfPixelHits.numberOfSCTHits.vertexLink.truthParticleLink.originalTrackParticle.numberOfInnermostPixelLayerHits.expectInnermostPixelLayerHit.numberOfNextToInnermostPixelLayerHits.expectNextToInnermostPixelLayerHit", "Photons", -"PhotonsAux.pt.eta.phi.m.caloClusterLinks.ethad1.ethad.f1.e233.e237.e277.weta1.weta2.e2tsts1.fracs1.wtots1.emins1.emaxs1.vertexLinks.ptcone20.ptcone30.ptcone40.ptvarcone20.ptvarcone30.ptvarcone40.topoetcone20.topoetcone30.topoetcone40.truthParticleLink.truthOrigin.truthType.author.OQ.f3.Loose.Medium.Tight.Reta.Rphi.Eratio.Rhad.Rhad1.DeltaE.DFCommonPhotonsIsEMLoose.DFCommonPhotonsIsEMTight.topoetcone20ptCorrection.topoetcone30ptCorrection.topoetcone40ptCorrection.etcone20ptCorrection.etcone30ptCorrection.etcone40ptCorrection", +"PhotonsAux.pt.eta.phi.m.author.OQ.DFCommonPhotonsIsEMLoose.DFCommonPhotonsIsEMTight.DFCommonPhotonsIsEMTightIsEMValue.DFCommonPhotonsIsEMTightPtIncl.DFCommonPhotonsIsEMTightPtInclIsEMValue.DFCommonPhotonsCleaning.DFCommonPhotonsCleaningNoTime.DFCommonCrackVetoCleaning.ptcone20.ptcone20_TightTTVA_pt1000.neflowisol20.topoetcone20.topoetcone40.topoetcone20ptCorrection.topoetcone40ptCorrection.core57cellsEnergyCorrection.topoetconecoreConeSCEnergyCorrection.topoetconecoreConeEnergyCorrection.caloClusterLinks.vertexLinks.ambiguityLink.truthParticleLink.truthOrigin.truthType", "egammaClusters", -"egammaClustersAux.calE.calEta.calPhi.e_sampl.eta_sampl.etaCalo.phiCalo.ETACALOFRAME.PHICALOFRAME.clusterSize.altE.calM", -"egammaTopoSeededClusters", -"egammaTopoSeededClustersAux.calE.calEta.calPhi.e_sampl.eta_sampl.ETACALOFRAME.PHICALOFRAME.etaCalo.phiCalo.calM", +"egammaClustersAux.calE.calEta.calPhi.e_sampl.eta_sampl.etaCalo.phiCalo.ETACALOFRAME.PHICALOFRAME.clusterSize.altE.calM.constituentClusterLinks", "Electrons", -"ElectronsAux.trackParticleLinks.truthParticleLink.caloClusterLinks" +"ElectronsAux.trackParticleLinks.truthParticleLink.caloClusterLinks", +"TopoClusterIsoCentralEventShape", +"TopoClusterIsoCentralEventShapeAux.Density", +"TopoClusterIsoForwardEventShape", +"TopoClusterIsoForwardEventShapeAux.Density", +"NeutralParticleFlowIsoCentralEventShape", +"NeutralParticleFlowIsoCentralEventShapeAux.Density" ] diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/PhotonsCPDetailedContent.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/PhotonsCPDetailedContent.py new file mode 100644 index 0000000000000000000000000000000000000000..75d148c8bd5a189380410478551457f3ef2480fd --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/PhotonsCPDetailedContent.py @@ -0,0 +1,3 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +PhotonsCPDetailedContent = ["Photons.Rhad.Rhad1.e277.Reta.Rphi.weta2.f1.weta1.fracs1.wtots1.Eratio.DeltaE.f3"] diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/egammaDFFlags.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/egammaDFFlags.py new file mode 100644 index 0000000000000000000000000000000000000000..3cc63f4d558aa834f31e150b84ce5ef5eded6f5c --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/python/egammaDFFlags.py @@ -0,0 +1,77 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +#======================================================================= +# File: DerivationFrameworkEGamma/python/egammaDFFlags.py +#======================================================================= +__author__ = 'G. Marchiori' +__version__="$Revision: 1.0 $" +__doc__="egamma DF flags . " + +#======================================================================= +# imports +#======================================================================= +from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer +from AthenaCommon.JobProperties import jobproperties + +class Enabled(JobProperty): + """ jobproperty to disable/enable the egamma algorithms as a group (container) in one go. + Can enable/disable the full egamma + """ + statusOn=True + allowedTypes=['bool'] + StoredValue=True + +class egammaDFFlagsJobProperty(JobProperty): + """ special flag . Subclass which has get_value depending on job properties.egammaDFFlags.Enabled + so properties inheriting from this will be disables if egammaRec is not Enabled. + """ + def get_Value(self): + return self.statusOn and self.StoredValue and jobproperties.egammaDFFlags.Enabled() + +# enable or disable cell-level reweighting +class doEGammaCellReweighting (egammaDFFlagsJobProperty): + """ switch for enabling cell-level reweighting of e/gamma clusters + """ + statusOn=True + allowedTypes=['bool'] + StoredValue=True + +# enable or disable cell-level reweighting variations +class doEGammaCellReweightingVariations (egammaDFFlagsJobProperty): + """ switch for enabling cell-level reweighting of e/gamma clusters with max/min variations + """ + statusOn=True + allowedTypes=['bool'] + StoredValue=False + +class doEGammaDAODTrackThinning (egammaDFFlagsJobProperty): + """ switch for enabling track-thinning in egamma DAODs + """ + statusOn=True + allowedTypes=['bool'] + StoredValue=True + + +# class calibMVAVersion (JobProperty): +# """Version of calo cluster corrections used for calibration. +# """ +# statusOn=True +# allowedTypes=['str', 'None'] +# StoredValue="egammaMVACalib/offline/v7_pre" + +# Defines a sub-container holding the jobProperties for egamma +class egammaDFFlags(JobPropertyContainer): + """ egamma information """ + +# add the egammaRec flags container to the top container +jobproperties.add_Container(egammaDFFlags) + +# I want always the following flags in the container +_list_Egamma=[Enabled,doEGammaCellReweighting,doEGammaCellReweightingVariations,doEGammaDAODTrackThinning] + +for j in _list_Egamma: + jobproperties.egammaDFFlags.add_JobProperty(j) +del _list_Egamma + + + diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM1.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM1.py index c46ecf66adfc2dbd2ee929195fde0e0bf9b13e19..d1e4309ed85b4dd554c88177389c32231d4c9cb2 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM1.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM1.py @@ -1,5 +1,6 @@ #******************************************************************** # EGAM1.py +# Z->ee reduction for central electrons - for electron ID and calibration # reductionConf flag EGAM1 in Reco_tf.py # author: giovanni.marchiori@cern.ch #******************************************************************** @@ -10,34 +11,49 @@ from DerivationFrameworkMuons.MuonsCommon import * from DerivationFrameworkJetEtMiss.JetCommon import * from DerivationFrameworkJetEtMiss.METCommon import * from DerivationFrameworkEGamma.EGammaCommon import * +from DerivationFrameworkEGamma.EGAM1ExtraContent import * + +# read common DFEGamma settings from egammaDFFlags +from DerivationFrameworkEGamma.egammaDFFlags import jobproperties +jobproperties.egammaDFFlags.print_JobProperties("full") +# this could also go in egammaDFFlags RecomputeElectronSelectors = True #RecomputeElectronSelectors = False +#OutputLevel = DEBUG + +DoCellReweighting = jobproperties.egammaDFFlags.doEGammaCellReweighting +DoCellReweightingVariations = jobproperties.egammaDFFlags.doEGammaCellReweightingVariations +#override if needed (do at your own risk..) +#DoCellReweighting = False +#DoCellReweighting = True +#DoCellReweightingVariations = True + + +# check if we run on data or MC (DataSource = geant4) +from AthenaCommon.GlobalFlags import globalflags +print "EGAM1 globalflags.DataSource(): ", globalflags.DataSource() +if globalflags.DataSource()!='geant4': + DoCellReweighting = False + DoCellReweightingVariations = False + + #==================================================================== -# SET UP STREAM +# SET UP STREAM (to be done early in the game to set up thinning Svc #==================================================================== streamName = derivationFlags.WriteDAOD_EGAM1Stream.StreamName fileName = buildFileName( derivationFlags.WriteDAOD_EGAM1Stream ) EGAM1Stream = MSMgr.NewPoolRootStream( streamName, fileName ) -# Only events that pass the filters listed below are written out. -# Name must match that of the kernel above -# AcceptAlgs = logical OR of filters -# RequireAlgs = logical AND of filters -EGAM1Stream.AcceptAlgs(["EGAM1Kernel"]) -#Special lines for thinning -# Thinning service name must match the one passed to the thinning tools -augStream = MSMgr.GetStream( streamName ) -evtStream = augStream.GetEventStream() - +augmentationTools = [] #==================================================================== -# SKIMMING TOOLS +# SET UP SKIMMING #==================================================================== -# SELECTION FOR CALIBRATION +# 1. SELECTION FOR CALIBRATION #==================================================================== # Z->ee selection based on single e trigger: @@ -49,14 +65,12 @@ evtStream = augStream.GetEventStream() # tool? #==================================================================== -# switch to likelihood selectors only as soon as they're commissioned (and used in trigger) - if RecomputeElectronSelectors : - requirement_tag = '(Electrons.DFCommonElectronsIsEMTight || Electrons.DFCommonElectronsLHTight) && Electrons.pt > 24.5*GeV' - requirement_probe = '(Electrons.DFCommonElectronsIsEMMedium || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 19.5*GeV' + requirement_tag = '(Electrons.DFCommonElectronsLHTight) && (Electrons.pt > 24.5*GeV)' + requirement_probe = '(Electrons.DFCommonElectronsLHMedium) && (Electrons.pt > 19.5*GeV)' else : - requirement_tag = '(Electrons.Tight || Electrons.DFCommonElectronsLHTight) && Electrons.pt > 24.5*GeV' - requirement_probe = '(Electrons.Medium || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 19.5*GeV' + requirement_tag = '(Electrons.LHTight) && (Electrons.pt > 24.5*GeV)' + requirement_probe = '(Electrons.LHMedium) && (Electrons.pt > 19.5*GeV)' from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGInvariantMassTool EGAM1_ZEEMassTool1 = DerivationFramework__EGInvariantMassTool( name = "EGAM1_ZEEMassTool1", @@ -71,6 +85,7 @@ EGAM1_ZEEMassTool1 = DerivationFramework__EGInvariantMassTool( name = "EGAM1_ZEE DoTransverseMass = False, MinDeltaR = 0.0) ToolSvc += EGAM1_ZEEMassTool1 +augmentationTools += [EGAM1_ZEEMassTool1] print EGAM1_ZEEMassTool1 #==================================================================== @@ -79,11 +94,10 @@ print EGAM1_ZEEMassTool1 # OS, mee>50 GeV #==================================================================== -# switch to likelihood selectors only as soon as they're commissioned (and used in trigger) if RecomputeElectronSelectors: - requirement = '(Electrons.DFCommonElectronsIsEMMedium || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 19.5*GeV' + requirement = '(Electrons.DFCommonElectronsLHMedium) && (Electrons.pt > 19.5*GeV)' else: - requirement = '(Electrons.Medium || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 19.5*GeV' + requirement = '(Electrons.LHMedium) && (Electrons.pt > 19.5*GeV)' EGAM1_ZEEMassTool2 = DerivationFramework__EGInvariantMassTool( name = "EGAM1_ZEEMassTool2", Object1Requirements = requirement, Object2Requirements = requirement, @@ -96,26 +110,24 @@ EGAM1_ZEEMassTool2 = DerivationFramework__EGInvariantMassTool( name = "EGAM1_ZEE DoTransverseMass = False, MinDeltaR = 0.0) ToolSvc += EGAM1_ZEEMassTool2 +augmentationTools += [EGAM1_ZEEMassTool2] print EGAM1_ZEEMassTool2 -# SELECTION FOR T&P +# 2. SELECTION FOR T&P #==================================================================== -# Z->ee selection based on single e trigger, for reco (central) and ID SF(central+fwd) +# Z->ee selection based on single e trigger, for reco (central) and ID SF(central) # 1 tight e, central, pT>25 GeV -# 1 e, central, pT>15 GeV +# 1 e, central, pT>4 GeV # OS+SS, mee>50 GeV #==================================================================== -# switch to likelihood selectors only as soon as they're commissioned (and used in trigger) if RecomputeElectronSelectors : -# use medium for early data upon electron group request - requirement_tag = '(Electrons.DFCommonElectronsIsEMMedium || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 24.5*GeV' + requirement_tag = '(Electrons.DFCommonElectronsLHMedium) && (Electrons.pt > 24.5*GeV)' else : - requirement_tag = '(Electrons.Medium || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 24.5*GeV' -# central electrons: collection = Electrons, pt>14.5 GeV -requirement_probe = 'Electrons.pt > 6.5*GeV' + requirement_tag = '(Electrons.LHMedium) && (Electrons.pt > 24.5*GeV)' +requirement_probe = 'Electrons.pt > 4*GeV' EGAM1_ZEEMassTool3 = DerivationFramework__EGInvariantMassTool( name = "EGAM1_ZEEMassTool3", Object1Requirements = requirement_tag, Object2Requirements = requirement_probe, @@ -128,6 +140,7 @@ EGAM1_ZEEMassTool3 = DerivationFramework__EGInvariantMassTool( name = "EGAM1_ZEE DoTransverseMass = False, MinDeltaR = 0.0) ToolSvc += EGAM1_ZEEMassTool3 +augmentationTools += [EGAM1_ZEEMassTool3] print EGAM1_ZEEMassTool3 @@ -139,12 +152,11 @@ print EGAM1_ZEEMassTool3 # OS+SS, mee>50 GeV #==================================================================== -# switch to likelihood selectors only as soon as they're commissioned (and used in trigger) if RecomputeElectronSelectors: # use medium for early data upon electron group request - requirement_tag = '(Electrons.DFCommonElectronsIsEMMedium || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 24.5*GeV' + requirement_tag = '(Electrons.DFCommonElectronsLHMedium) && (Electrons.pt > 24.5*GeV)' else: - requirement_tag = '(Electrons.Medium || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 24.5*GeV' + requirement_tag = '(Electrons.LHMedium) && (Electrons.pt > 24.5*GeV)' requirement_probe = 'DFCommonPhotons_et > 14.5*GeV' EGAM1_ZEGMassTool = DerivationFramework__EGInvariantMassTool( name = "EGAM1_ZEGMassTool", Object1Requirements = requirement_tag, @@ -161,27 +173,23 @@ EGAM1_ZEGMassTool = DerivationFramework__EGInvariantMassTool( name = "EGAM1_ZEGM DoTransverseMass = False, MinDeltaR = 0.0) ToolSvc += EGAM1_ZEGMassTool +augmentationTools += [EGAM1_ZEGMassTool] print EGAM1_ZEGMassTool + # Skimming criteria -#expression = '( ( count(Photons.pt > 10*GeV) > 0 ) || ( count(Electrons.pt > 10*GeV) > 0 ) )' expression = 'count(EGAM1_DiElectronMass > 50.0*GeV)>=1 || count(EGAM1_DiElectronMass2 > 50.0*GeV)>=1 || count(EGAM1_DiElectronMass3 > 50.0*GeV)>=1 || count (EGAM1_ElectronPhotonMass > 50.0*GeV)>=1' from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__xAODStringSkimmingTool EGAM1SkimmingTool = DerivationFramework__xAODStringSkimmingTool( name = "EGAM1SkimmingTool", - expression = expression) + expression = expression) ToolSvc += EGAM1SkimmingTool -print "EGAM1 skimming tool:", EGAM1SkimmingTool +print "EGAM1 skimming tool: ", EGAM1SkimmingTool + #==================================================================== -# Gain and cluster energies per layer decoration tool +# SET UP AUGMENTATIONS #==================================================================== -from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import GainDecorator, getGainDecorations, getClusterEnergyPerLayerDecorator, getClusterEnergyPerLayerDecorations -EGAM1_GainDecoratorTool = GainDecorator() -ToolSvc += EGAM1_GainDecoratorTool - -cluster_sizes = (3,5), (5,7), (7,7), (7,11) -EGAM1_ClusterEnergyPerLayerDecorators = [getClusterEnergyPerLayerDecorator(neta, nphi)() for neta, nphi in cluster_sizes] #==================================================================== @@ -190,176 +198,456 @@ EGAM1_ClusterEnergyPerLayerDecorators = [getClusterEnergyPerLayerDecorator(neta, from DerivationFrameworkCalo.DerivationFrameworkCaloConf import DerivationFramework__MaxCellDecorator EGAM1_MaxCellDecoratorTool = DerivationFramework__MaxCellDecorator( name = "EGAM1_MaxCellDecoratorTool", SGKey_electrons = "Electrons", - SGKey_photons = "Photons", - ) + SGKey_photons = "Photons" ) ToolSvc += EGAM1_MaxCellDecoratorTool +augmentationTools += [EGAM1_MaxCellDecoratorTool] + + +#==================================================================== +# Cell reweighter +#==================================================================== +if DoCellReweighting: + from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import NewCellTool, ClusterDecoratorWithNewCells, EGammaReweightTool + + # first, create the container with the new cells (after reweighting) + EGAM1_NewCellTool = NewCellTool("EGAM1_NewCellTool", + #OutputLevel = DEBUG, + CellContainerName = "AODCellContainer", + ReweightCellContainerName = "NewCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons", + ReweightCoefficients2DPath = "DerivationFrameworkCalo/CellReweight_v2d/rewCoeffs10.root" ) + + print EGAM1_NewCellTool + ToolSvc += EGAM1_NewCellTool + augmentationTools += [EGAM1_NewCellTool] + + # second, run a tool that creates the clusters and objects from these new cells + EGAM1_ClusterDecoratorTool = ClusterDecoratorWithNewCells("EGAM1_ClusterDecoratorTool", + #OutputLevel=DEBUG, + OutputClusterSGKey = "EGammaSwClusterWithNewCells", + OutputClusterLink = "NewSwClusterLink", + SGKey_caloCells = "NewCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons") + print EGAM1_ClusterDecoratorTool + ToolSvc += EGAM1_ClusterDecoratorTool + augmentationTools += [EGAM1_ClusterDecoratorTool] + + + # third, schedule a tool that will be invoked by the EGammaReweightTool to create on-the-fly the shower shapes with the new cells + from egammaTools.egammaToolsFactories import EMShowerBuilder + EGAM1_EMShowerBuilderTool = EMShowerBuilder("EGAM1_EMShowerBuilderTool", + CellsName="NewCellContainer" ) + + print EGAM1_EMShowerBuilderTool + ToolSvc += EGAM1_EMShowerBuilderTool + + # fourth, decorate the new objects with their shower shapes computed from the new clusters + EGAM1_EGammaReweightTool = EGammaReweightTool("EGAM1_EGammaReweightTool", + #OutputLevel=DEBUG, + SGKey_electrons = "Electrons", + SGKey_photons = "Photons", + NewCellContainerName = "NewCellContainer", + NewElectronContainer = "NewSwElectrons", + NewPhotonContainer = "NewSwPhotons", + EMShowerBuilderTool = EGAM1_EMShowerBuilderTool, + ClusterCorrectionToolName = "DFEgammaSWToolWithNewCells", + CaloClusterLinkName = "NewSwClusterLink", + DecorateEGammaObjects = False, + DecorationPrefix = "RW_", + SaveReweightedContainer = True) + + print EGAM1_EGammaReweightTool + ToolSvc += EGAM1_EGammaReweightTool + augmentationTools += [EGAM1_EGammaReweightTool] + + if DoCellReweightingVariations: + + ########################################### REWEIGHTING VARIATIONS - MAX ###################################################### + + from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import MaxVarCellTool, ClusterDecoratorWithMaxVarCells, EGammaMaxVarReweightTool + + # first, create the container with the new cells (after reweighting) + EGAM1_MaxVarCellTool = MaxVarCellTool ("EGAM1_MaxVarCellTool", + #OutputLevel = DEBUG, + CellContainerName="AODCellContainer", + ReweightCellContainerName="MaxVarCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons", + ReweightCoefficients2DPath = "DerivationFrameworkCalo/CellReweight_v2d/rewCoeffs11.root") + + print EGAM1_MaxVarCellTool + ToolSvc += EGAM1_MaxVarCellTool + + # second, run a tool that creates the clusters and objects from these new cells + EGAM1_MaxVarClusterDecoratorTool = ClusterDecoratorWithMaxVarCells("EGAM1_MaxVarClusterDecoratorTool", + OutputClusterSGKey="EGammaSwClusterWithMaxVarCells", + OutputClusterLink="MaxVarSwClusterLink", + SGKey_caloCells = "MaxVarCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons") + print EGAM1_MaxVarClusterDecoratorTool + ToolSvc += EGAM1_MaxVarClusterDecoratorTool + + # third, schedule a tool that will be invoked by the EGammaReweightTool to create on-the-fly the shower shapes with the new cells + EGAM1_EMMaxVarShowerBuilderTool = EMShowerBuilder("EGAM1_EMMaxVarShowerBuilderTool", + CellsName="MaxVarCellContainer") + print EGAM1_EMMaxVarShowerBuilderTool + ToolSvc += EGAM1_EMMaxVarShowerBuilderTool + + # fourth, decorate the new objects with their shower shapes computed from the new clusters + EGAM1_EGammaMaxVarReweightTool = EGammaReweightTool("EGAM1_EGammaMaxVarReweightTool", + #OutputLevel = DEBUG, + SGKey_electrons = "Electrons", + SGKey_photons="Photons", + NewCellContainerName="MaxVarCellContainer", + NewElectronContainer = "MaxVarSwElectrons", + NewPhotonContainer = "MaxVarSwPhotons", + EMShowerBuilderTool = EGAM1_EMMaxVarShowerBuilderTool, + ClusterCorrectionToolName = "DFEgammaSWToolWithMaxVarCells", + CaloClusterLinkName="MaxVarSwClusterLink", + DecorateEGammaObjects = False, + DecorationPrefix = "Max_", + SaveReweightedContainer = True) + print EGAM1_EGammaMaxVarReweightTool + ToolSvc += EGAM1_EGammaMaxVarReweightTool + + + ########################################### REWEIGHTING VARIATIONS - MIN ###################################################### + + from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import MinVarCellTool, ClusterDecoratorWithMinVarCells, EGammaMinVarReweightTool + + # first, create the container with the new cells (after reweighting) + EGAM1_MinVarCellTool = MinVarCellTool ("EGAM1_MinVarCellTol", + #OutputLevel = DEBUG, + CellContainerName="AODCellContainer", + ReweightCellContainerName="MinVarCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons", + ReweightCoefficients2DPath = "DerivationFrameworkCalo/CellReweight_v2d/rewCoeffs00.root") + + + print EGAM1_MinVarCellTool + ToolSvc += EGAM1_MinVarCellTool + + # second, run a tool that creates the clusters and objects from these new cells + EGAM1_MinVarClusterDecoratorTool = ClusterDecoratorWithMinVarCells("EGAM1_MinVarClusterDecoratorTool", + OutputClusterSGKey="EGammaSwClusterWithMinVarCells", + OutputClusterLink="MinVarSwClusterLink", + SGKey_caloCells = "MinVarCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons") + print EGAM1_MinVarClusterDecoratorTool + ToolSvc += EGAM1_MinVarClusterDecoratorTool + + # third, schedule a tool that will be invoked by the EGammaReweightTool to create on-the-fly the shower shapes with the new cells + EGAM1_EMMinVarShowerBuilderTool = EMShowerBuilder("EGAM1_EMMinVarShowerBuilderTool", + CellsName="MinVarCellContainer") + print EGAM1_EMMinVarShowerBuilderTool + ToolSvc += EGAM1_EMMinVarShowerBuilderTool + + # fourth, decorate the new objects with their shower shapes computed from the new clusters + EGAM1_EGammaMinVarReweightTool = EGammaReweightTool("EGAM1_EGammaMinVarReweightTool", + #OutputLevel = DEBUG, + SGKey_electrons = "Electrons", + SGKey_photons="Photons", + NewCellContainerName="MinVarCellContainer", + NewElectronContainer = "MinVarSwElectrons", + NewPhotonContainer = "MinVarSwPhotons", + EMShowerBuilderTool = EGAM1_EMMinVarShowerBuilderTool, + ClusterCorrectionToolName = "DFEgammaSWToolWithMinVarCells", + CaloClusterLinkName="MinVarSwClusterLink", + DecorateEGammaObjects = False, + DecorationPrefix = "Min_", + SaveReweightedContainer = True) + + print EGAM1_EGammaMinVarReweightTool + ToolSvc += EGAM1_EGammaMinVarReweightTool + + augmentationTools += [EGAM1_MaxVarCellTool, EGAM1_MaxVarClusterDecoratorTool, EGAM1_EGammaMaxVarReweightTool, EGAM1_MinVarCellTool, EGAM1_MinVarClusterDecoratorTool, EGAM1_EGammaMinVarReweightTool] + + +#==================================================================== +# Gain and cluster energies per layer decoration tool +#==================================================================== +# GM: do we really need new, different tools: getClusterEnergyPerLayerDecoratorNew, getClusterEnergyPerLayerDecoratorMaxVar, getClusterEnergyPerLayerDecoratorMinVar? +from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import GainDecorator, getGainDecorations, getClusterEnergyPerLayerDecorator, getClusterEnergyPerLayerDecorations, getClusterEnergyPerLayerDecoratorNew, getClusterEnergyPerLayerDecoratorMaxVar, getClusterEnergyPerLayerDecoratorMinVar +EGAM1_GainDecoratorTool = GainDecorator() +ToolSvc += EGAM1_GainDecoratorTool +augmentationTools += [EGAM1_GainDecoratorTool] + +cluster_sizes = (3,7), (5,5), (7,11) +EGAM1_ClusterEnergyPerLayerDecorators = [getClusterEnergyPerLayerDecorator(neta, nphi)() for neta, nphi in cluster_sizes] +if DoCellReweighting: + EGAM1_ClusterEnergyPerLayerDecorators += [getClusterEnergyPerLayerDecoratorNew(neta, nphi)() for neta, nphi in cluster_sizes] + if DoCellReweightingVariations: + EGAM1_ClusterEnergyPerLayerDecorators += [getClusterEnergyPerLayerDecoratorMaxVar(neta, nphi)() for neta, nphi in cluster_sizes] + EGAM1_ClusterEnergyPerLayerDecorators += [getClusterEnergyPerLayerDecoratorMinVar(neta, nphi)() for neta, nphi in cluster_sizes] +augmentationTools += EGAM1_ClusterEnergyPerLayerDecorators + + +#==================================================================== +# SET UP THINNING +#==================================================================== + +from DerivationFrameworkCore.ThinningHelper import ThinningHelper +EGAM1ThinningHelper = ThinningHelper( "EGAM1ThinningHelper" ) +EGAM1ThinningHelper.TriggerChains = '(^(?!.*_[0-9]*(mu|j|xe|tau|ht|xs|te))(?!HLT_[eg].*_[0-9]*[eg][0-9].*)(?!HLT_eb.*)(?!.*larpeb.*)(?!HLT_.*_AFP_.*)(HLT_[eg].*))|HLT_e.*_Zee.*' +EGAM1ThinningHelper.AppendToStream( EGAM1Stream, ExtraContainersTrigger ) -#================ -# THINNING -#================ thinningTools=[] -# Tracks associated with Jets -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__JetTrackParticleThinning -EGAM1JetLCTPThinningTool = DerivationFramework__JetTrackParticleThinning( name = "EGAM1JetLCTPThinningTool", - StreamName = streamName, - JetKey = "AntiKt4EMTopoJets", - InDetTrackParticlesKey = "InDetTrackParticles", - ApplyAnd = True) -ToolSvc += EGAM1JetLCTPThinningTool -print EGAM1JetLCTPThinningTool -#thinningTools.append(EGAM1JetLCTPThinningTool) - -# Tracks associated with Muons -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__MuonTrackParticleThinning -EGAM1MuonTPThinningTool = DerivationFramework__MuonTrackParticleThinning( name = "EGAM1MuonTPThinningTool", - StreamName = streamName, - MuonKey = "Muons", - InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM1MuonTPThinningTool -print EGAM1MuonTPThinningTool -#thinningTools.append(EGAM1MuonTPThinningTool) - -# Tracks associated with Electrons -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning -EGAM1ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM1ElectronTPThinningTool", - Streamname = streamName, - SGKey = "Electrons", +if jobproperties.egammaDFFlags.doEGammaDAODTrackThinning: + + TrackThinningKeepElectronTracks = True + TrackThinningKeepPhotonTracks = True + TrackThinningKeepAllElectronTracks = True + TrackThinningKeepJetTracks = False + TrackThinningKeepMuonTracks = False + TrackThinningKeepTauTracks = False + TrackThinningKeepPVTracks = True + + # Tracks associated with Electrons + if (TrackThinningKeepElectronTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM1ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM1ElectronTPThinningTool", + ThinningService = EGAM1ThinningHelper.ThinningSvc(), + SGKey = "Electrons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Electrons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + ToolSvc += EGAM1ElectronTPThinningTool + print EGAM1ElectronTPThinningTool + thinningTools.append(EGAM1ElectronTPThinningTool) + + # Tracks associated with Electrons (all tracks, large cone, for track isolation studies of the selected electrons) + if (TrackThinningKeepAllElectronTracks) : + EGAM1ElectronTPThinningTool2 = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM1ElectronTPThinningTool2", + ThinningService = EGAM1ThinningHelper.ThinningSvc(), + SGKey = "Electrons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Electrons.pt > 4*GeV", + BestMatchOnly = False, + ConeSize = 0.6, + ApplyAnd = False) + + ToolSvc += EGAM1ElectronTPThinningTool2 + print EGAM1ElectronTPThinningTool2 + thinningTools.append(EGAM1ElectronTPThinningTool2) + + # Tracks associated with Photons + if (TrackThinningKeepPhotonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM1PhotonTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM1PhotonTPThinningTool", + ThinningService = EGAM1ThinningHelper.ThinningSvc(), + SGKey = "Photons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Photons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + ToolSvc += EGAM1PhotonTPThinningTool + print EGAM1PhotonTPThinningTool + thinningTools.append(EGAM1PhotonTPThinningTool) + + # Tracks associated with Jets + if (TrackThinningKeepJetTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__JetTrackParticleThinning + EGAM1JetTPThinningTool = DerivationFramework__JetTrackParticleThinning( name = "EGAM1JetTPThinningTool", + ThinningService = EGAM1ThinningHelper.ThinningSvc(), + JetKey = "AntiKt4EMTopoJets", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM1JetTPThinningTool + print EGAM1JetTPThinningTool + thinningTools.append(EGAM1JetTPThinningTool) + + + # Tracks associated with Muons + if (TrackThinningKeepMuonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__MuonTrackParticleThinning + EGAM1MuonTPThinningTool = DerivationFramework__MuonTrackParticleThinning( name = "EGAM1MuonTPThinningTool", + ThinningService = EGAM1ThinningHelper.ThinningSvc(), + MuonKey = "Muons", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM1MuonTPThinningTool + print EGAM1MuonTPThinningTool + thinningTools.append(EGAM1MuonTPThinningTool) + + + # Tracks associated with Taus + if (TrackThinningKeepTauTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TauTrackParticleThinning + EGAM1TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( name = "EGAM1TauTPThinningTool", + ThinningService = EGAM1ThinningHelper.ThinningSvc(), + TauKey = "TauJets", + ConeSize = 0.6, InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM1ElectronTPThinningTool -print EGAM1ElectronTPThinningTool -#thinningTools.append(EGAM1ElectronTPThinningTool) - -# Tracks associated with Photons -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning -EGAM1PhotonTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM1PhotonTPThinningTool", - StreamName = streamName, - SGKey = "Photons", - InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM1PhotonTPThinningTool -print EGAM1PhotonTPThinningTool -#thinningTools.append(EGAM1PhotonTPThinningTool) - -# Tracks associated with Taus -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TauTrackParticleThinning -EGAM1TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( name = "EGAM1TauTPThinningTool", - StreamName = streamName, - TauKey = "TauJets", - ConeSize = 0.6, - InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM1TauTPThinningTool -print EGAM1TauTPThinningTool -#thinningTools.append(EGAM1TauTPThinningTool) - -# Tracks from primary vertex -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning -EGAM1TPThinningTool = DerivationFramework__TrackParticleThinning( name = "EGAM1TPThinningTool", - StreamName = streamName, - SelectionString = "abs( DFCommonInDetTrackZ0AtPV * sin(InDetTrackParticles.theta)) < 3.0", - InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM1TPThinningTool -print EGAM1TPThinningTool -#thinningTools.append(EGAM1TPThinningTool) + ToolSvc += EGAM1TauTPThinningTool + print EGAM1TauTPThinningTool + thinningTools.append(EGAM1TauTPThinningTool) + + # Tracks from primary vertex + if (TrackThinningKeepPVTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning + EGAM1TPThinningTool = DerivationFramework__TrackParticleThinning( name = "EGAM1TPThinningTool", + ThinningService = EGAM1ThinningHelper.ThinningSvc(), + SelectionString = "InDetTrackParticles.DFCommonTightPrimary && abs( DFCommonInDetTrackZ0AtPV * sin(InDetTrackParticles.theta)) < 3.0*mm", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM1TPThinningTool + print EGAM1TPThinningTool + thinningTools.append(EGAM1TPThinningTool) +# keep topoclusters around electrons +from DerivationFrameworkCalo.DerivationFrameworkCaloConf import DerivationFramework__CaloClusterThinning +EGAM1CCTCThinningTool = DerivationFramework__CaloClusterThinning(name = "EGAM1CCTCThinningTool", + ThinningService = EGAM1ThinningHelper.ThinningSvc(), + SGKey = "Electrons", + SelectionString = "Electrons.pt>4*GeV", + TopoClCollectionSGKey = "CaloCalTopoClusters", + ConeSize = 0.5) +ToolSvc += EGAM1CCTCThinningTool +print EGAM1CCTCThinningTool +thinningTools.append(EGAM1CCTCThinningTool) -# Truth thinning -truth_cond_WZH = "((abs(TruthParticles.pdgId) >= 23) && (abs(TruthParticles.pdgId) <= 25))" # W, Z and Higgs -truth_cond_lep = "((abs(TruthParticles.pdgId) >= 11) && (abs(TruthParticles.pdgId) <= 16))" # Leptons -truth_cond_top = "((abs(TruthParticles.pdgId) == 6))" # Top quark -truth_cond_gam = "((abs(TruthParticles.pdgId) == 22) && (TruthParticles.pt > 1*GeV))" # Photon -truth_cond_finalState = '(TruthParticles.status == 1 && TruthParticles.barcode < 200000)' # stable particles -truth_expression = '(' + truth_cond_WZH + ' || ' + truth_cond_lep +' || '+truth_cond_top +' || '+truth_cond_gam + ') || (' + truth_cond_finalState+')' - -from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__GenericTruthThinning -EGAM1TruthThinningTool = DerivationFramework__GenericTruthThinning(name = "EGAM1TruthThinningTool", - StreamName = streamName, - ParticleSelectionString = truth_expression, - PreserveDescendants = False, - PreserveGeneratorDescendants = True, - PreserveAncestors = True) -from AthenaCommon.GlobalFlags import globalflags -print "EGAM1 globalflags.DataSource(): ", globalflags.DataSource() +# Truth thinning if globalflags.DataSource()=='geant4': + truth_cond_WZH = "((abs(TruthParticles.pdgId) >= 23) && (abs(TruthParticles.pdgId) <= 25))" # W, Z and Higgs + truth_cond_lep = "((abs(TruthParticles.pdgId) >= 11) && (abs(TruthParticles.pdgId) <= 16))" # Leptons + truth_cond_top = "((abs(TruthParticles.pdgId) == 6))" # Top quark + truth_cond_gam = "((abs(TruthParticles.pdgId) == 22) && (TruthParticles.pt > 1*GeV))" # Photon + truth_cond_finalState = '(TruthParticles.status == 1 && TruthParticles.barcode < 200000)' # stable particles + truth_expression = '(' + truth_cond_WZH + ' || ' + truth_cond_lep +' || '+truth_cond_top +' || '+truth_cond_gam + ') || (' + truth_cond_finalState+')' + + from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__GenericTruthThinning + EGAM1TruthThinningTool = DerivationFramework__GenericTruthThinning(name = "EGAM1TruthThinningTool", + ThinningService = EGAM1ThinningHelper.ThinningSvc(), + ParticleSelectionString = truth_expression, + PreserveDescendants = False, + PreserveGeneratorDescendants = True, + PreserveAncestors = True) + ToolSvc += EGAM1TruthThinningTool thinningTools.append(EGAM1TruthThinningTool) + print "EGAM1 thinningTools: ", thinningTools + #======================================= -# CREATE THE DERIVATION KERNEL ALGORITHM +# CREATE PRIVATE SEQUENCE #======================================= +egam1Seq = CfgMgr.AthSequencer("EGAM1Sequence") +DerivationFrameworkJob += egam1Seq +#======================================= +# CREATE THE DERIVATION KERNEL ALGORITHM +#======================================= from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel -DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel("EGAM1Kernel", - AugmentationTools = [EGAM1_ZEEMassTool1, EGAM1_ZEEMassTool2, EGAM1_ZEEMassTool3, EGAM1_ZEGMassTool, EGAM1_GainDecoratorTool, EGAM1_MaxCellDecoratorTool] + EGAM1_ClusterEnergyPerLayerDecorators, - SkimmingTools = [EGAM1SkimmingTool], - ThinningTools = thinningTools - ) + +print "EGAM1 skimming tools", [EGAM1SkimmingTool] +print "EGAM1 thinning tools", thinningTools +print "EGAM1 augmentation tools", augmentationTools +egam1Seq += CfgMgr.DerivationFramework__DerivationKernel("EGAM1Kernel", + AugmentationTools = augmentationTools, + SkimmingTools = [EGAM1SkimmingTool], + ThinningTools = thinningTools + ) + +#==================================================================== +# RESTORE JET COLLECTIONS REMOVED BETWEEN r20 AND r21 +#==================================================================== +from DerivationFrameworkJetEtMiss.ExtendedJetCommon import replaceAODReducedJets +#reducedJetList = ["AntiKt4PV0TrackJets", "AntiKt4TruthJets"] +reducedJetList = ["AntiKt4TruthJets"] +replaceAODReducedJets(reducedJetList,egam1Seq,"EGAM1") + #======================================= # ADD NON-PROMPT LEPTON VETO ALGORITHMS #======================================= -import JetTagNonPromptLepton.JetTagNonPromptLeptonConfig as Config -#DerivationFrameworkJob += Config.DecoratePromptLepton("Electrons", "AntiKt4PV0TrackJets") -#DerivationFrameworkJob += Config.DecoratePromptLepton("Muons", "AntiKt4PV0TrackJets") -DerivationFrameworkJob += Config.GetDecoratePromptLeptonAlgs() +import JetTagNonPromptLepton.JetTagNonPromptLeptonConfig as JetTagConfig +JetTagConfig.ConfigureAntiKt4PV0TrackJets(egam1Seq, "EGAM1") +egam1Seq += JetTagConfig.GetDecoratePromptLeptonAlgs(name="Electrons") + + +#==================================================================== +# SET UP STREAM SELECTION +#==================================================================== +# Only events that pass the filters listed below are written out. +# Name must match that of the kernel above +# AcceptAlgs = logical OR of filters +# RequireAlgs = logical AND of filters +EGAM1Stream.AcceptAlgs(["EGAM1Kernel"]) -#======================================================================== #==================================================================== -# CONTENT LIST +# SET UP SLIMMING #==================================================================== from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper EGAM1SlimmingHelper = SlimmingHelper("EGAM1SlimmingHelper") - -from DerivationFrameworkEGamma.EGAM1ExtraContent import * -EGAM1SlimmingHelper.SmartCollections = [ - "Electrons", +EGAM1SlimmingHelper.SmartCollections = ["Electrons", "Photons", - "Muons", + "Muons", "TauJets", "MET_Reference_AntiKt4EMTopo", "AntiKt4EMTopoJets", - "BTagging_AntiKt4EMTopo", + "AntiKt4EMTopoJets_BTagging201810", + "BTagging_AntiKt4EMTopo_201810", "InDetTrackParticles", - "PrimaryVertices" - ] + "PrimaryVertices" ] # Add egamma trigger objects EGAM1SlimmingHelper.IncludeEGammaTriggerContent = True +# Append cell-reweighted collections to dictionary +if DoCellReweighting: + EGAM1SlimmingHelper.AppendToDictionary = {"NewSwElectrons": "xAOD::ElectronContainer", "NewSwElectronsAux": "xAOD::ElectronAuxContainer"} + if DoCellReweightingVariations: + EGAM1SlimmingHelper.AppendToDictionary.update({ "MaxVarSwElectrons": "xAOD::ElectronContainer", "MaxVarSwElectronsAux": "xAOD::ElectronAuxContainer", "MinVarSwElectrons": "xAOD::ElectronContainer", "MinVarSwElectronsAux": "xAOD::ElectronAuxContainer" }) + # Extra variables EGAM1SlimmingHelper.ExtraVariables = ExtraContentAll # the next line is not needed because we save all variables for electrons, including the prompt lepton decorations -# EGAM1SlimmingHelper.ExtraVariables += Config.GetExtraPromptVariablesForDxAOD() +# EGAM1SlimmingHelper.ExtraVariables += JetTagConfig.GetExtraPromptVariablesForDxAOD() EGAM1SlimmingHelper.AllVariables = ExtraContainersElectrons EGAM1SlimmingHelper.AllVariables += ExtraContainersTrigger -if globalflags.DataSource()!='geant4': - EGAM1SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly - if globalflags.DataSource()=='geant4': EGAM1SlimmingHelper.ExtraVariables += ExtraContentAllTruth EGAM1SlimmingHelper.AllVariables += ExtraContainersTruth +else: + EGAM1SlimmingHelper.ExtraVariables += ExtraContainersTriggerDataOnly for tool in EGAM1_ClusterEnergyPerLayerDecorators: EGAM1SlimmingHelper.ExtraVariables.extend( getClusterEnergyPerLayerDecorations( tool ) ) +# Add energy density variables EGAM1SlimmingHelper.ExtraVariables += ExtraVariablesEventShape +# Add detailed shower shape variables (not needed for electrons because we save everything but it doesn't hurt..) +from DerivationFrameworkEGamma.ElectronsCPDetailedContent import * +EGAM1SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent +EGAM1SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent +from DerivationFrameworkEGamma.PhotonsCPDetailedContent import * +EGAM1SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent + # This line must come after we have finished configuring EGAM1SlimmingHelper EGAM1SlimmingHelper.AppendContentToStream(EGAM1Stream) -# Add MET_RefFinalFix -# JRC: COMMENTED TEMPORARILY -#addMETOutputs(EGAM1Stream) +#Add full CellContainer +EGAM1Stream.AddItem("CaloCellContainer#AODCellContainer") +EGAM1Stream.AddItem("CaloClusterCellLinkContainer#egammaClusters_links") + -# Add Derived Egamma CellContainer -from DerivationFrameworkEGamma.EGammaCellCommon import CellCommonThinning -CellCommonThinning(EGAM1Stream) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM2.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM2.py index caee0a9eb6d53ac228261888cb8d5ab9e8fafe5b..4681c663d174f86fc1b0cbd6bbf1a4637a0160f9 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM2.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM2.py @@ -11,30 +11,45 @@ from DerivationFrameworkMuons.MuonsCommon import * from DerivationFrameworkJetEtMiss.JetCommon import * from DerivationFrameworkJetEtMiss.METCommon import * from DerivationFrameworkEGamma.EGammaCommon import * +from DerivationFrameworkEGamma.EGAM2ExtraContent import * + +# read common DFEGamma settings from egammaDFFlags +from DerivationFrameworkEGamma.egammaDFFlags import jobproperties +jobproperties.egammaDFFlags.print_JobProperties("full") +# this could also go in egammaDFFlags RecomputeElectronSelectors = True #RecomputeElectronSelectors = False +# check if we run on data or MC +from AthenaCommon.GlobalFlags import globalflags +print "EGAM2 globalflags.DataSource(): ", globalflags.DataSource() + + + #==================================================================== -# SKIMMING TOOLS +# SET UP STREAM (to be done early in the game to set up thinning Svc +#==================================================================== +streamName = derivationFlags.WriteDAOD_EGAM2Stream.StreamName +fileName = buildFileName( derivationFlags.WriteDAOD_EGAM2Stream ) +EGAM2Stream = MSMgr.NewPoolRootStream( streamName, fileName ) + + +#==================================================================== +# SET UP SKIMMING #==================================================================== # SELECTION FOR CALIBRATION #==================================================================== # J/psi->ee selection for e/gamma calibration -# 2 tight or medium e (depends on Run2 triggers..), pT>4.5 GeV, author=1 or 3, OS, 1<Mee<5 GeV +# 2 tight or medium e (depends on Run2 triggers..), pT>4.5 GeV, OS, 1<Mee<5 GeV #==================================================================== -# author requirement not needed in Run2: forward electrons are in separate collection -# and no tracking-based (soft-e) electron reconstruction is run -# electronAuthorRequirement = '(Electrons.author==1 || Electrons.author==3)' electronPtRequirement = '(Electrons.pt > 4.5*GeV)' if RecomputeElectronSelectors : - electronQualityRequirement = '(Electrons.DFCommonElectronsIsEMMedium || Electrons.DFCommonElectronsLHMedium)' + electronQualityRequirement = '(Electrons.DFCommonElectronsLHMedium)' else : - electronQualityRequirement = '(Electrons.Medium || Electrons.DFCommonElectronsLHMedium)' -#electronQualityRequirement='(Electrons.Tight || DFCommonElectronsLHTight)' -#requirement_el = '(' + electronQualityRequirement + '&&' + electronPtRequirement + '&&' + electronAuthorRequirement + ')' + electronQualityRequirement = '(Electrons.LHMedium)' requirement_el = '(' + electronQualityRequirement + '&&' + electronPtRequirement + ')' @@ -64,9 +79,9 @@ print EGAM2_JPSIEEMassTool # dR>0.15 #==================================================================== if RecomputeElectronSelectors : - requirement_el_tag = '(Electrons.DFCommonElectronsIsEMTight || Electrons.DFCommonElectronsLHTight) && Electrons.pt > 4.5*GeV' + requirement_el_tag = '(Electrons.DFCommonElectronsLHTight) && (Electrons.pt > 4.5*GeV)' else : - requirement_el_tag = '(Electrons.Tight || Electrons.DFCommonElectronsLHTight) && Electrons.pt > 4.5*GeV' + requirement_el_tag = '(Electrons.LHTight) && (Electrons.pt > 4.5*GeV)' requirement_el_probe = 'Electrons.pt > 4.5*GeV' EGAM2_JPSIEEMassTool2 = DerivationFramework__EGInvariantMassTool( name = "EGAM2_JPSIEEMassTool2", @@ -112,6 +127,15 @@ triggers+=['HLT_e14_etcut_e5_lhtight_nod0_Jpsiee'] triggers+=['HLT_e14_lhtight_e4_etcut_Jpsiee'] triggers+=['HLT_e14_lhtight_nod0_e4_etcut_Jpsiee'] +triggers+=['HLT_e5_lhtight_nod0_e4_etcut_Jpsiee_L1RD0_FILLED'] +triggers+=['HLT_e5_lhtight_nod0_e9_etcut_Jpsiee'] +triggers+=['HLT_e5_lhtight_nod0_e14_etcut_Jpsiee'] +triggers+=['HLT_e5_lhtight_nod0_e9_etcut_Jpsiee_L1JPSI-1M5-EM7'] +triggers+=['HLT_e9_lhtight_nod0_e4_etcut_Jpsiee_L1JPSI-1M5-EM7'] +triggers+=['HLT_e5_lhtight_nod0_e14_etcut_Jpsiee_L1JPSI-1M5-EM12'] +triggers+=['HLT_e14_lhtight_nod0_e4_etcut_Jpsiee_L1JPSI-1M5-EM12'] + + from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__TriggerSkimmingTool EGAM2_TriggerSkimmingTool = DerivationFramework__TriggerSkimmingTool( name = "EGAM2_TriggerSkimmingTool", TriggerListOR = triggers) @@ -120,12 +144,17 @@ ToolSvc += EGAM2_TriggerSkimmingTool print "EGAM2 trigger skimming tool:", EGAM2_TriggerSkimmingTool +from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__FilterCombinationOR +EGAM2_SkimmingTool = DerivationFramework__FilterCombinationOR(name="EGAM2SkimmingTool", FilterList=[EGAM2_OfflineSkimmingTool,EGAM2_TriggerSkimmingTool] ) +ToolSvc+=EGAM2_SkimmingTool +print "EGAM2 skimming tool:", EGAM2_SkimmingTool + + + +#==================================================================== +# SET UP AUGMENTATIONS +#==================================================================== -#================ -# THINNING -#================ -thinningTools=[] -# TO BE ADDED #==================================================================== # Gain and cluster energies per layer decoration tool @@ -138,27 +167,140 @@ cluster_sizes = (3,5), (5,7), (7,7), (7,11) EGAM2_ClusterEnergyPerLayerDecorators = [getClusterEnergyPerLayerDecorator(neta, nphi)() for neta, nphi in cluster_sizes] +#==================================================================== +# SET UP THINNING +#==================================================================== + +from DerivationFrameworkCore.ThinningHelper import ThinningHelper +EGAM2ThinningHelper = ThinningHelper( "EGAM2ThinningHelper" ) +EGAM2ThinningHelper.TriggerChains = '(^(?!.*_[0-9]*(mu|j|xe|tau|ht|xs|te))(?!HLT_[eg].*_[0-9]*[eg][0-9].*)(?!HLT_eb.*)(?!.*larpeb.*)(?!HLT_.*_AFP_.*)(HLT_[eg].*))|HLT_e.*_Jpsiee.*' + +EGAM2ThinningHelper.AppendToStream( EGAM2Stream, ExtraContainersTrigger ) + + +thinningTools=[] + +# Track thinning +if jobproperties.egammaDFFlags.doEGammaDAODTrackThinning: + + TrackThinningKeepElectronTracks = True + TrackThinningKeepPhotonTracks = True + TrackThinningKeepJetTracks = False + TrackThinningKeepMuonTracks = False + TrackThinningKeepTauTracks = False + TrackThinningKeepPVTracks = False + + # Tracks associated with Jets + if (TrackThinningKeepJetTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__JetTrackParticleThinning + EGAM2JetTPThinningTool = DerivationFramework__JetTrackParticleThinning( name = "EGAM2JetTPThinningTool", + ThinningService = EGAM2ThinningHelper.ThinningSvc(), + JetKey = "AntiKt4EMTopoJets", + InDetTrackParticlesKey = "InDetTrackParticles", + ApplyAnd = True) + ToolSvc += EGAM2JetTPThinningTool + print EGAM2JetTPThinningTool + thinningTools.append(EGAM2JetTPThinningTool) + + # Tracks associated with Muons + if (TrackThinningKeepMuonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__MuonTrackParticleThinning + EGAM2MuonTPThinningTool = DerivationFramework__MuonTrackParticleThinning( name = "EGAM2MuonTPThinningTool", + ThinningService = EGAM2ThinningHelper.ThinningSvc(), + MuonKey = "Muons", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM2MuonTPThinningTool + print EGAM2MuonTPThinningTool + thinningTools.append(EGAM2MuonTPThinningTool) + + # Tracks associated with Electrons + if (TrackThinningKeepElectronTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM2ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM2ElectronTPThinningTool", + ThinningService = EGAM2ThinningHelper.ThinningSvc(), + SGKey = "Electrons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Electrons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + ToolSvc += EGAM2ElectronTPThinningTool + print EGAM2ElectronTPThinningTool + thinningTools.append(EGAM2ElectronTPThinningTool) + + # Tracks associated with Photons + if (TrackThinningKeepPhotonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM2PhotonTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM2PhotonTPThinningTool", + ThinningService = EGAM2ThinningHelper.ThinningSvc(), + SGKey = "Photons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Photons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + + ToolSvc += EGAM2PhotonTPThinningTool + print EGAM2PhotonTPThinningTool + thinningTools.append(EGAM2PhotonTPThinningTool) + + # Tracks associated with Taus + if (TrackThinningKeepTauTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TauTrackParticleThinning + EGAM2TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( name = "EGAM2TauTPThinningTool", + ThinningService = EGAM2ThinningHelper.ThinningSvc(), + TauKey = "TauJets", + ConeSize = 0.6, + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM2TauTPThinningTool + print EGAM2TauTPThinningTool + thinningTools.append(EGAM2TauTPThinningTool) + + # Tracks from primary vertex + if (TrackThinningKeepPVTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning + EGAM2TPThinningTool = DerivationFramework__TrackParticleThinning( name = "EGAM2TPThinningTool", + ThinningService = EGAM2ThinningHelper.ThinningSvc(), + SelectionString = "InDetTrackParticles.DFCommonTightPrimary && abs( DFCommonInDetTrackZ0AtPV * sin(InDetTrackParticles.theta)) < 3.0*mm", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM2TPThinningTool + print EGAM2TPThinningTool + thinningTools.append(EGAM2TPThinningTool) + +print "EGAM2 thinningTools: ", thinningTools + + #======================================= -# CREATE THE DERIVATION KERNEL ALGORITHM +# CREATE PRIVATE SEQUENCE #======================================= -from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__FilterCombinationOR -EGAM2_SkimmingTool = DerivationFramework__FilterCombinationOR(name="EGAM2SkimmingTool", FilterList=[EGAM2_OfflineSkimmingTool,EGAM2_TriggerSkimmingTool] ) -ToolSvc+=EGAM2_SkimmingTool +egam2Seq = CfgMgr.AthSequencer("EGAM2Sequence") +DerivationFrameworkJob += egam2Seq +#======================================= +# CREATE THE DERIVATION KERNEL ALGORITHM +#======================================= from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel -DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel("EGAM2Kernel", - AugmentationTools = [EGAM2_JPSIEEMassTool,EGAM2_JPSIEEMassTool2,EGAM2_GainDecoratorTool] + EGAM2_ClusterEnergyPerLayerDecorators, - SkimmingTools = [EGAM2_SkimmingTool] - ) +egam2Seq += CfgMgr.DerivationFramework__DerivationKernel("EGAM2Kernel", + AugmentationTools = [EGAM2_JPSIEEMassTool,EGAM2_JPSIEEMassTool2,EGAM2_GainDecoratorTool] + EGAM2_ClusterEnergyPerLayerDecorators, + SkimmingTools = [EGAM2_SkimmingTool], + ThinningTools = thinningTools + ) #==================================================================== -# SET UP STREAM +# RESTORE JET COLLECTIONS REMOVED BETWEEN r20 AND r21 +#==================================================================== +from DerivationFrameworkJetEtMiss.ExtendedJetCommon import replaceAODReducedJets +reducedJetList = ["AntiKt4TruthJets"] +replaceAODReducedJets(reducedJetList,egam2Seq,"EGAM2") + + +#==================================================================== +# SET UP STREAM SELECTION #==================================================================== -streamName = derivationFlags.WriteDAOD_EGAM2Stream.StreamName -fileName = buildFileName( derivationFlags.WriteDAOD_EGAM2Stream ) -EGAM2Stream = MSMgr.NewPoolRootStream( streamName, fileName ) # Only events that pass the filters listed below are written out. # Name must match that of the kernel above # AcceptAlgs = logical OR of filters @@ -166,13 +308,13 @@ EGAM2Stream = MSMgr.NewPoolRootStream( streamName, fileName ) EGAM2Stream.AcceptAlgs(["EGAM2Kernel"]) + #==================================================================== -# CONTENT LIST +# SET UP SLIMMING #==================================================================== from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper EGAM2SlimmingHelper = SlimmingHelper("EGAM2SlimmingHelper") -from DerivationFrameworkEGamma.EGAM2ExtraContent import * EGAM2SlimmingHelper.SmartCollections = [ "Electrons", "Photons", @@ -180,7 +322,8 @@ EGAM2SlimmingHelper.SmartCollections = [ "TauJets", "MET_Reference_AntiKt4EMTopo", "AntiKt4EMTopoJets", - "BTagging_AntiKt4EMTopo", + "AntiKt4EMTopoJets_BTagging201810", + "BTagging_AntiKt4EMTopo_201810", "InDetTrackParticles", "PrimaryVertices" ] # muons, tau, MET, b-tagging could be switched off if not needed and use too much space @@ -192,19 +335,22 @@ EGAM2SlimmingHelper.IncludeEGammaTriggerContent = True EGAM2SlimmingHelper.ExtraVariables = ExtraContentAll EGAM2SlimmingHelper.AllVariables = ExtraContainersElectrons EGAM2SlimmingHelper.AllVariables += ExtraContainersTrigger -# if globalflags.DataSource()!='geant4': -# EGAM2SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly if globalflags.DataSource()=='geant4': EGAM2SlimmingHelper.ExtraVariables += ExtraContentAllTruth EGAM2SlimmingHelper.AllVariables += ExtraContainersTruth +else: + EGAM2SlimmingHelper.ExtraVariables += ExtraContainersTriggerDataOnly for tool in EGAM2_ClusterEnergyPerLayerDecorators: EGAM2SlimmingHelper.ExtraVariables.extend( getClusterEnergyPerLayerDecorations( tool ) ) +# Add detailed shower shape variables +from DerivationFrameworkEGamma.ElectronsCPDetailedContent import * +EGAM2SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent +EGAM2SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent +from DerivationFrameworkEGamma.PhotonsCPDetailedContent import * +EGAM2SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent + # This line must come after we have finished configuring EGAM2SlimmingHelper EGAM2SlimmingHelper.AppendContentToStream(EGAM2Stream) - -# Add MET_RefFinalFix -# JRC: COMMENTED TEMPORARILY -#addMETOutputs(EGAM2Stream) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM3.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM3.py index 16cc4efab6cb6c7b839c42fff1435954b63b2825..d1e2dfa42c7c2947908e9bd7d7d40860538ef80a 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM3.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM3.py @@ -1,3 +1,4 @@ + #******************************************************************** # EGAM3.py # Z->eegamma reduction for low-pT electron and photon studies @@ -5,40 +6,66 @@ # author: giovanni.marchiori@cern.ch #******************************************************************** -# notes: - from DerivationFrameworkCore.DerivationFrameworkMaster import * from DerivationFrameworkInDet.InDetCommon import * from DerivationFrameworkMuons.MuonsCommon import * from DerivationFrameworkJetEtMiss.JetCommon import * from DerivationFrameworkJetEtMiss.METCommon import * from DerivationFrameworkEGamma.EGammaCommon import * +from DerivationFrameworkEGamma.EGAM3ExtraContent import * + +# read common DFEGamma settings from egammaDFFlags +from DerivationFrameworkEGamma.egammaDFFlags import jobproperties +jobproperties.egammaDFFlags.print_JobProperties("full") + +# this could also go in egammaDFFlags +RecomputeEGammaSelectors = True +#RecomputeEGammaSelectors = False + +DoCellReweighting = jobproperties.egammaDFFlags.doEGammaCellReweighting +DoCellReweightingVariations = jobproperties.egammaDFFlags.doEGammaCellReweightingVariations +#override if needed (do at your own risk..) +#DoCellReweighting = False +#DoCellReweighting = True + +# check if we run on data or MC (DataSource = geant4) +from AthenaCommon.GlobalFlags import globalflags +print "EGAM3 globalflags.DataSource(): ", globalflags.DataSource() +if globalflags.DataSource()!='geant4': + DoCellReweighting = False + DoCellReweightingVariations = False -RecomputeElectronSelectors = True -#RecomputeElectronSelectors = False #==================================================================== -# SKIMMING TOOLS +# SET UP STREAM (to be done early in the game to set up thinning Svc +#==================================================================== +streamName = derivationFlags.WriteDAOD_EGAM3Stream.StreamName +fileName = buildFileName( derivationFlags.WriteDAOD_EGAM3Stream ) +EGAM3Stream = MSMgr.NewPoolRootStream( streamName, fileName ) + + +#==================================================================== +# SET UP SKIMMING #==================================================================== #==================================================================== -# eegamma selection for photon studies, di-electron triggers +# eegamma and eee selection for photon efficiency studies, di-electron triggers # two opposite-sign medium el, pT>10 GeV, |eta|<2.5, mee>40 GeV -# gamma: reco, ET>10 GeV< |eta|<2.5 +# eegamma: one reco photon, ET>10 GeV< |eta|<2.5 +# eee: 3 electrons, pT>10 GeV, mee>40 GeV #==================================================================== # if skim size too large either require tight electrons (at least one) or raise electron pT threshold (at least one) -#requirement = 'DFCommonElectronsLHMedium && (DFCommonElectrons_pt > 9.5*GeV)' -if RecomputeElectronSelectors : - requirement = '(Electrons.DFCommonElectronsIsEMMedium || Electrons.DFCommonElectronsLHMedium) && (Electrons.pt > 9.5*GeV)' +if RecomputeEGammaSelectors : + requirementElectrons = '(Electrons.DFCommonElectronsLHMedium) && (Electrons.pt > 9.5*GeV)' else : - requirement = '(Electrons.Medium || Electrons.DFCommonElectronsLHMedium) && (Electrons.pt > 9.5*GeV)' + requirementElectrons = '(Electrons.LHMedium) && (Electrons.pt > 9.5*GeV)' from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGInvariantMassTool EGAM3_EEMassTool = DerivationFramework__EGInvariantMassTool( name = "EGAM3_EEMassTool", - Object1Requirements = requirement, - Object2Requirements = requirement, + Object1Requirements = requirementElectrons, + Object2Requirements = requirementElectrons, StoreGateEntryName = "EGAM3_DiElectronMass", Mass1Hypothesis = 0.511*MeV, Mass2Hypothesis = 0.511*MeV, @@ -49,25 +76,30 @@ EGAM3_EEMassTool = DerivationFramework__EGInvariantMassTool( name = "EGAM3_EEMas MinDeltaR = 0.0) ToolSvc += EGAM3_EEMassTool print EGAM3_EEMassTool - +skimmingExpression1a = '(count(DFCommonPhotons_et>9.5*GeV)>=1 && count(EGAM3_DiElectronMass > 40.0*GeV)>=1)' +skimmingExpression1b = '(count(Electrons.pt>9.5*GeV)>=3 && count(EGAM3_DiElectronMass > 40.0*GeV)>=1)' #==================================================================== # eegamma selection for low-pT electron studies with T&P # tag e: tight, |eta|<2.5, pT>25 GeV -# probe e: reco, ET>7 GeV, no eta cut +# probe e: reco, ET>7 GeV, central electron # gamma: tight, ET>10 GeV #==================================================================== # asymmetric electron cuts/single e trigger, low pT cut for subleading e (for e calibration studies at low pT) -#requirement1 = 'DFCommonElectronsLHTight && (DFCommonElectrons_pt > 24.5*GeV)' -if RecomputeElectronSelectors : - requirement1 = '(Electrons.DFCommonElectronsIsEMTight || Electrons.DFCommonElectronsLHTight) && (Electrons.pt > 24.5*GeV)' +if RecomputeEGammaSelectors : + requirementElectron1 = '(Electrons.DFCommonElectronsLHTight) && (Electrons.pt > 24.5*GeV)' +else : + requirementElectron1 = '(Electrons.LHTight) && (Electrons.pt > 24.5*GeV)' +requirementElectron2 = '(Electrons.pt > 6.5*GeV)' +if RecomputeEGammaSelectors : + requirementPhoton = 'Photons.DFCommonPhotonsIsEMTight' else : - requirement1 = '(Electrons.Tight || Electrons.DFCommonElectronsLHTight) && (Electrons.pt > 24.5*GeV)' -requirement2 = '(Electrons.pt > 6.5*GeV)' + requirementPhoton = 'Photons.Tight' + EGAM3_EEMassTool2 = DerivationFramework__EGInvariantMassTool( name = "EGAM3_EEMassTool2", - Object1Requirements = requirement1, - Object2Requirements = requirement2, + Object1Requirements = requirementElectron1, + Object2Requirements = requirementElectron2, StoreGateEntryName = "EGAM3_DiElectronMass2", Mass1Hypothesis = 0.511*MeV, Mass2Hypothesis = 0.511*MeV, @@ -80,17 +112,25 @@ EGAM3_EEMassTool2 = DerivationFramework__EGInvariantMassTool( name = "EGAM3_EEMa ToolSvc += EGAM3_EEMassTool2 print EGAM3_EEMassTool2 +skimmingExpression2 = '(count(DFCommonPhotons_et>9.5*GeV && '+ requirementPhoton + ')>=1 && count(EGAM3_DiElectronMass2 > 40.0*GeV)>=1)' + -if RecomputeElectronSelectors : - requirement1 = '(Electrons.DFCommonElectronsIsEMTight || Electrons.DFCommonElectronsLHTight) && (Electrons.pt > 24.5*GeV)' +#==================================================================== +# eegamma selection for low-pT electron studies with T&P +# tag e: tight, |eta|<2.5, pT>25 GeV +# probe e: reco, ET>7 GeV, forward electron +# gamma: tight, ET>10 GeV +#==================================================================== + +if RecomputeEGammaSelectors : + requirementElectron1 = '(Electrons.DFCommonElectronsLHTight) && (Electrons.pt > 24.5*GeV)' else : - requirement1 = '(Electrons.Tight || Electrons.DFCommonElectronsLHTight) && (Electrons.pt > 24.5*GeV)' -requirement2 = '(ForwardElectrons.pt > 6.5*GeV)' -#requirement2 = '(ForwardElectrons.pt > 9.5*GeV)' + requirementElectron1 = '(Electrons.LHTight) && (Electrons.pt > 24.5*GeV)' +requirementElectron2 = '(ForwardElectrons.pt > 6.5*GeV)' EGAM3_EEMassTool3 = DerivationFramework__EGInvariantMassTool( name = "EGAM3_EEMassTool3", - Object1Requirements = requirement1, - Object2Requirements = requirement2, + Object1Requirements = requirementElectron1, + Object2Requirements = requirementElectron2, StoreGateEntryName = "EGAM3_DiElectronMass3", Mass1Hypothesis = 0.511*MeV, Mass2Hypothesis = 0.511*MeV, @@ -102,73 +142,385 @@ EGAM3_EEMassTool3 = DerivationFramework__EGInvariantMassTool( name = "EGAM3_EEMa MinDeltaR = 0.0) ToolSvc += EGAM3_EEMassTool3 print EGAM3_EEMassTool3 - +skimmingExpression3 = '(count(DFCommonPhotons_et>9.5*GeV && '+ requirementPhoton + ')>=1 && count(EGAM3_DiElectronMass3 > 40.0*GeV)>=1)' #==================================================================== # SKIMMING TOOL #==================================================================== -if RecomputeElectronSelectors : - photon_quality = 'Photons.DFCommonPhotonsIsEMTight' -else : - photon_quality = 'Photons.Tight' +skimmingExpression = skimmingExpression1a + ' || ' + skimmingExpression1b + ' || ' + skimmingExpression2 + ' || ' + skimmingExpression3 +print "EGAM3 skimming expression: ", skimmingExpression + -expression = '(count(DFCommonPhotons_et>9.5*GeV)>=1 && count(EGAM3_DiElectronMass > 40.0*GeV)>=1) || (count(DFCommonPhotons_et>9.5*GeV && '+ photon_quality + ')>=1 && (count(EGAM3_DiElectronMass2 > 40.0*GeV)>=1 || count(EGAM3_DiElectronMass3 > 40.0*GeV)>=1))' from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__xAODStringSkimmingTool -EGAM3SkimmingTool = DerivationFramework__xAODStringSkimmingTool( name = "EGAM3SkimmingTool", - expression = expression) -ToolSvc += EGAM3SkimmingTool -print "EGAM3 skimming tool:", EGAM3SkimmingTool +EGAM3_SkimmingTool = DerivationFramework__xAODStringSkimmingTool( name = "EGAM3_SkimmingTool", + expression = skimmingExpression) +ToolSvc += EGAM3_SkimmingTool +print "EGAM3 skimming tool: ", EGAM3_SkimmingTool + + + +#==================================================================== +# SET UP AUGMENTATIONS +#==================================================================== + #==================================================================== # Gain and cluster energies per layer decoration tool #==================================================================== -from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import GainDecorator, getGainDecorations, getClusterEnergyPerLayerDecorator, getClusterEnergyPerLayerDecorations +from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import GainDecorator, getGainDecorations, getClusterEnergyPerLayerDecorator, getClusterEnergyPerLayerDecorations, getClusterEnergyPerLayerDecoratorNew, getClusterEnergyPerLayerDecoratorMaxVar, getClusterEnergyPerLayerDecoratorMinVar EGAM3_GainDecoratorTool = GainDecorator() ToolSvc += EGAM3_GainDecoratorTool -cluster_sizes = (3,5), (5,7), (7,7), (7,11) +cluster_sizes = (3,7), (5,5), (7,11) EGAM3_ClusterEnergyPerLayerDecorators = [getClusterEnergyPerLayerDecorator(neta, nphi)() for neta, nphi in cluster_sizes] +if DoCellReweighting: + EGAM3_ClusterEnergyPerLayerDecorators += [getClusterEnergyPerLayerDecoratorNew(neta, nphi)() for neta, nphi in cluster_sizes] + if DoCellReweightingVariations: + EGAM3_ClusterEnergyPerLayerDecorators += [getClusterEnergyPerLayerDecoratorMaxVar(neta, nphi)() for neta, nphi in cluster_sizes] + EGAM3_ClusterEnergyPerLayerDecorators += [getClusterEnergyPerLayerDecoratorMinVar(neta, nphi)() for neta, nphi in cluster_sizes] + + +#==================================================================== +# Max Cell sum decoration tool +#==================================================================== +from DerivationFrameworkCalo.DerivationFrameworkCaloConf import DerivationFramework__MaxCellDecorator +EGAM3_MaxCellDecoratorTool = DerivationFramework__MaxCellDecorator( name = "EGAM3_MaxCellDecoratorTool", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons" ) +ToolSvc += EGAM3_MaxCellDecoratorTool + + +#==================================================================== +# Cell reweighter +#==================================================================== +if DoCellReweighting: + from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import NewCellTool, ClusterDecoratorWithNewCells, EGammaReweightTool + + # first, create the container with the new cells (after reweighting) + EGAM3_NewCellTool = NewCellTool("EGAM3_NewCellTool", + #OutputLevel = DEBUG + CellContainerName = "AODCellContainer", + ReweightCellContainerName = "NewCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons", + ReweightCoefficients2DPath = "DerivationFrameworkCalo/CellReweight_v2d/rewCoeffs10.root" ) + print EGAM3_NewCellTool + ToolSvc += EGAM3_NewCellTool + + # second, run a tool that creates the clusters and objects from these new cells + EGAM3_ClusterDecoratorTool = ClusterDecoratorWithNewCells("EGAM3_ClusterDecoratorTool", + #OutputLevel=DEBUG, + OutputClusterSGKey = "EGammaSwClusterWithNewCells", + OutputClusterLink = "NewSwClusterLink", + SGKey_caloCells = "NewCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons") + print EGAM3_ClusterDecoratorTool + ToolSvc += EGAM3_ClusterDecoratorTool + + # third, run a tool that creates the shower shapes with the new cells + from egammaTools.egammaToolsFactories import EMShowerBuilder + EGAM3_EMShowerBuilderTool = EMShowerBuilder("EGAM3_EMShowerBuilderTool", + CellsName="NewCellContainer") + print EGAM3_EMShowerBuilderTool + ToolSvc += EGAM3_EMShowerBuilderTool + + # fourth, decorate the new objects with their shower shapes computed from the new clusters + EGAM3_EGammaReweightTool = EGammaReweightTool("EGAM3_EGammaReweightTool", + #OutputLevel=DEBUG, + SGKey_electrons = "Electrons", + SGKey_photons="Photons", + NewCellContainerName="NewCellContainer", + NewElectronContainer = "NewSwElectrons", + #NewElectronContainer = "", # no container for electrons + NewPhotonContainer = "NewSwPhotons", + EMShowerBuilderTool = EGAM3_EMShowerBuilderTool, + ClusterCorrectionToolName = "DFEgammaSWToolWithNewCells", + CaloClusterLinkName="NewSwClusterLink", + DecorateEGammaObjects = False, + DecorationPrefix = "RW_", + SaveReweightedContainer = True) + + print EGAM3_EGammaReweightTool + ToolSvc += EGAM3_EGammaReweightTool + + if DoCellReweightingVariations: + + ########################################### REWEIGHTING VARIATIONS - MAX ###################################################### + + from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import MaxVarCellTool, ClusterDecoratorWithMaxVarCells, EGammaMaxVarReweightTool + + # first, create the container with the new cells (after reweighting) + EGAM3_MaxVarCellTool = MaxVarCellTool ("EGAM3_MaxVarCellTool", + #OutputLevel = DEBUG, + CellContainerName="AODCellContainer", + ReweightCellContainerName="MaxVarCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons", + ReweightCoefficients2DPath = "DerivationFrameworkCalo/CellReweight_v2d/rewCoeffs11.root") + + print EGAM3_MaxVarCellTool + ToolSvc += EGAM3_MaxVarCellTool + + # second, run a tool that creates the clusters and objects from these new cells + EGAM3_MaxVarClusterDecoratorTool = ClusterDecoratorWithMaxVarCells("EGAM3_MaxVarClusterDecoratorTool", + OutputClusterSGKey="EGammaSwClusterWithMaxVarCells", + OutputClusterLink="MaxVarSwClusterLink", + SGKey_caloCells = "MaxVarCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons") + print EGAM3_MaxVarClusterDecoratorTool + ToolSvc += EGAM3_MaxVarClusterDecoratorTool + + # third, schedule a tool that will be invoked by the EGammaReweightTool to create on-the-fly the shower shapes with the new cells + EGAM3_EMMaxVarShowerBuilderTool = EMShowerBuilder("EGAM3_EMMaxVarShowerBuilderTool", + CellsName="MaxVarCellContainer") + print EGAM3_EMMaxVarShowerBuilderTool + ToolSvc += EGAM3_EMMaxVarShowerBuilderTool + + # fourth, decorate the new objects with their shower shapes computed from the new clusters + EGAM3_EGammaMaxVarReweightTool = EGammaReweightTool("EGAM3_EGammaMaxVarReweightTool", + #OutputLevel = DEBUG, + SGKey_electrons = "Electrons", + SGKey_photons="Photons", + NewCellContainerName="MaxVarCellContainer", + #NewElectronContainer = "MaxVarSwElectrons", + NewElectronContainer = "", + NewPhotonContainer = "MaxVarSwPhotons", + EMShowerBuilderTool = EGAM3_EMMaxVarShowerBuilderTool, + ClusterCorrectionToolName = "DFEgammaSWToolWithMaxVarCells", + CaloClusterLinkName="MaxVarSwClusterLink", + DecorateEGammaObjects = False, + DecorationPrefix = "Max_", + SaveReweightedContainer = True) + print EGAM3_EGammaMaxVarReweightTool + ToolSvc += EGAM3_EGammaMaxVarReweightTool + + + ########################################### REWEIGHTING VARIATIONS - MIN ###################################################### + + from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import MinVarCellTool, ClusterDecoratorWithMinVarCells, EGammaMinVarReweightTool + + # first, create the container with the new cells (after reweighting) + EGAM3_MinVarCellTool = MinVarCellTool ("EGAM3_MinVarCellTol", + #OutputLevel = DEBUG, + CellContainerName="AODCellContainer", + ReweightCellContainerName="MinVarCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons", + ReweightCoefficients2DPath = "DerivationFrameworkCalo/CellReweight_v2d/rewCoeffs00.root") + + + print EGAM3_MinVarCellTool + ToolSvc += EGAM3_MinVarCellTool + + # second, run a tool that creates the clusters and objects from these new cells + EGAM3_MinVarClusterDecoratorTool = ClusterDecoratorWithMinVarCells("EGAM3_MinVarClusterDecoratorTool", + OutputClusterSGKey="EGammaSwClusterWithMinVarCells", + OutputClusterLink="MinVarSwClusterLink", + SGKey_caloCells = "MinVarCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons") + print EGAM3_MinVarClusterDecoratorTool + ToolSvc += EGAM3_MinVarClusterDecoratorTool + + # third, schedule a tool that will be invoked by the EGammaReweightTool to create on-the-fly the shower shapes with the new cells + EGAM3_EMMinVarShowerBuilderTool = EMShowerBuilder("EGAM3_EMMinVarShowerBuilderTool", + CellsName="MinVarCellContainer") + print EGAM3_EMMinVarShowerBuilderTool + ToolSvc += EGAM3_EMMinVarShowerBuilderTool + + # fourth, decorate the new objects with their shower shapes computed from the new clusters + EGAM3_EGammaMinVarReweightTool = EGammaReweightTool("EGAM3_EGammaMinVarReweightTool", + #OutputLevel = DEBUG, + SGKey_electrons = "Electrons", + SGKey_photons="Photons", + NewCellContainerName="MinVarCellContainer", + #NewElectronContainer = "MinVarSwElectrons", + NewElectronContainer = "", + NewPhotonContainer = "MinVarSwPhotons", + EMShowerBuilderTool = EGAM3_EMMinVarShowerBuilderTool, + ClusterCorrectionToolName = "DFEgammaSWToolWithMinVarCells", + CaloClusterLinkName="MinVarSwClusterLink", + DecorateEGammaObjects = False, + DecorationPrefix = "Min_", + SaveReweightedContainer = True) + + print EGAM3_EGammaMinVarReweightTool + ToolSvc += EGAM3_EGammaMinVarReweightTool + + +#==================================================================== +# SET UP THINNING +#==================================================================== +from DerivationFrameworkCore.ThinningHelper import ThinningHelper +EGAM3ThinningHelper = ThinningHelper( "EGAM3ThinningHelper" ) +EGAM3ThinningHelper.TriggerChains = '(^(?!.*_[0-9]*(mu|j|xe|tau|ht|xs|te))(?!HLT_[eg].*_[0-9]*[eg][0-9].*)(?!HLT_eb.*)(?!.*larpeb.*)(?!HLT_.*_AFP_.*)(HLT_[eg].*))' +if globalflags.DataSource()!='geant4': + ExtraContainersTrigger += ExtraContainersTriggerDataOnly +EGAM3ThinningHelper.AppendToStream( EGAM3Stream, ExtraContainersTrigger ) -#================ -# THINNING -#================ thinningTools=[] -# TO BE ADDED + +# Track thinning +if jobproperties.egammaDFFlags.doEGammaDAODTrackThinning: + + TrackThinningKeepElectronTracks = True + TrackThinningKeepPhotonTracks = True + TrackThinningKeepAllPhotonTracks = True + TrackThinningKeepJetTracks = False + TrackThinningKeepMuonTracks = False + TrackThinningKeepTauTracks = False + TrackThinningKeepPVTracks = False + + # Tracks associated with Jets + if (TrackThinningKeepJetTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__JetTrackParticleThinning + EGAM3JetTPThinningTool = DerivationFramework__JetTrackParticleThinning( name = "EGAM3JetTPThinningTool", + ThinningService = EGAM3ThinningHelper.ThinningSvc(), + JetKey = "AntiKt4EMTopoJets", + InDetTrackParticlesKey = "InDetTrackParticles", + ApplyAnd = True) + ToolSvc += EGAM3JetTPThinningTool + print EGAM3JetTPThinningTool + thinningTools.append(EGAM3JetTPThinningTool) + + # Tracks associated with Muons + if (TrackThinningKeepMuonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__MuonTrackParticleThinning + EGAM3MuonTPThinningTool = DerivationFramework__MuonTrackParticleThinning( name = "EGAM3MuonTPThinningTool", + ThinningService = EGAM3ThinningHelper.ThinningSvc(), + MuonKey = "Muons", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM3MuonTPThinningTool + print EGAM3MuonTPThinningTool + thinningTools.append(EGAM3MuonTPThinningTool) + + # Tracks associated with Electrons + if (TrackThinningKeepElectronTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM3ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM3ElectronTPThinningTool", + ThinningService = EGAM3ThinningHelper.ThinningSvc(), + SGKey = "Electrons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Electrons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + ToolSvc += EGAM3ElectronTPThinningTool + print EGAM3ElectronTPThinningTool + thinningTools.append(EGAM3ElectronTPThinningTool) + + # Tracks associated with Photons + if (TrackThinningKeepPhotonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM3PhotonTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM3PhotonTPThinningTool", + ThinningService = EGAM3ThinningHelper.ThinningSvc(), + SGKey = "Photons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Photons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + + ToolSvc += EGAM3PhotonTPThinningTool + print EGAM3PhotonTPThinningTool + thinningTools.append(EGAM3PhotonTPThinningTool) + + # Tracks associated with Photons (all tracks, large cone, for track isolation studies of the selected photon) + if (TrackThinningKeepAllPhotonTracks) : + EGAM3PhotonTPThinningTool2 = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM3PhotonTPThinningTool2", + ThinningService = EGAM3ThinningHelper.ThinningSvc(), + SGKey = "Photons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Photons.pt > 9.5*GeV", + BestMatchOnly = False, + ConeSize = 0.6, + ApplyAnd = False) + + ToolSvc += EGAM3PhotonTPThinningTool2 + print EGAM3PhotonTPThinningTool2 + thinningTools.append(EGAM3PhotonTPThinningTool2) + + # Tracks associated with Taus + if (TrackThinningKeepTauTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TauTrackParticleThinning + EGAM3TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( name = "EGAM3TauTPThinningTool", + ThinningService = EGAM3ThinningHelper.ThinningSvc(), + TauKey = "TauJets", + ConeSize = 0.6, + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM3TauTPThinningTool + print EGAM3TauTPThinningTool + thinningTools.append(EGAM3TauTPThinningTool) + + # Tracks from primary vertex + if (TrackThinningKeepPVTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning + EGAM3TPThinningTool = DerivationFramework__TrackParticleThinning( name = "EGAM3TPThinningTool", + ThinningService = EGAM3ThinningHelper.ThinningSvc(), + SelectionString = "abs( DFCommonInDetTrackZ0AtPV * sin(InDetTrackParticles.theta)) < 3.0", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM3TPThinningTool + print EGAM3TPThinningTool + thinningTools.append(EGAM3TPThinningTool) + + +print "EGAM3 thinningTools: ", thinningTools + + +#======================================= +# CREATE PRIVATE SEQUENCE +#======================================= +egam3Seq = CfgMgr.AthSequencer("EGAM3Sequence") +DerivationFrameworkJob += egam3Seq #======================================= # CREATE THE DERIVATION KERNEL ALGORITHM #======================================= from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel -DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel("EGAM3Kernel", - AugmentationTools = [EGAM3_EEMassTool,EGAM3_EEMassTool2,EGAM3_EEMassTool3,EGAM3_GainDecoratorTool] + EGAM3_ClusterEnergyPerLayerDecorators, - SkimmingTools = [EGAM3SkimmingTool], - ThinningTools = thinningTools - ) +augmentationTools = [EGAM3_EEMassTool,EGAM3_EEMassTool2,EGAM3_EEMassTool3,EGAM3_GainDecoratorTool,EGAM3_MaxCellDecoratorTool] +if DoCellReweighting: + augmentationTools += [EGAM3_NewCellTool, EGAM3_ClusterDecoratorTool, EGAM3_EGammaReweightTool] + if DoCellReweightingVariations: + augmentationTools += [EGAM3_MaxVarCellTool, EGAM3_MaxVarClusterDecoratorTool, EGAM3_EGammaMaxVarReweightTool, EGAM3_MinVarCellTool, EGAM3_MinVarClusterDecoratorTool, EGAM3_EGammaMinVarReweightTool] + +augmentationTools += EGAM3_ClusterEnergyPerLayerDecorators +print "EGAM3 augmentationTools", augmentationTools +egam3Seq += CfgMgr.DerivationFramework__DerivationKernel("EGAM3Kernel", + AugmentationTools = augmentationTools, + SkimmingTools = [EGAM3_SkimmingTool], + ThinningTools = thinningTools + ) #==================================================================== -# SET UP STREAM +# RESTORE JET COLLECTIONS REMOVED BETWEEN r20 AND r21 +#==================================================================== +from DerivationFrameworkJetEtMiss.ExtendedJetCommon import replaceAODReducedJets +reducedJetList = ["AntiKt4TruthJets"] +replaceAODReducedJets(reducedJetList,egam3Seq,"EGAM3") + + +#==================================================================== +# SET UP STREAM SELECTION #==================================================================== -streamName = derivationFlags.WriteDAOD_EGAM3Stream.StreamName -fileName = buildFileName( derivationFlags.WriteDAOD_EGAM3Stream ) -EGAM3Stream = MSMgr.NewPoolRootStream( streamName, fileName ) # Only events that pass the filters listed below are written out. # Name must match that of the kernel above # AcceptAlgs = logical OR of filters # RequireAlgs = logical AND of filters EGAM3Stream.AcceptAlgs(["EGAM3Kernel"]) -augStream = MSMgr.GetStream( streamName ) -evtStream = augStream.GetEventStream() - #==================================================================== -# CONTENT LIST +# SET UP SLIMMING #==================================================================== from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper -from DerivationFrameworkEGamma.EGAM3ExtraContent import * EGAM3SlimmingHelper = SlimmingHelper("EGAM3SlimmingHelper") EGAM3SlimmingHelper.SmartCollections = ["Electrons", @@ -177,34 +529,48 @@ EGAM3SlimmingHelper.SmartCollections = ["Electrons", "TauJets", "MET_Reference_AntiKt4EMTopo", "AntiKt4EMTopoJets", - "BTagging_AntiKt4EMTopo", + "AntiKt4EMTopoJets_BTagging201810", + "BTagging_AntiKt4EMTopo_201810", "InDetTrackParticles", "PrimaryVertices" ] # Add egamma trigger objects EGAM3SlimmingHelper.IncludeEGammaTriggerContent = True +# Append cell-reweighted collections to dictionary +if DoCellReweighting: + EGAM3SlimmingHelper.AppendToDictionary = {"NewSwPhotons": "xAOD::PhotonContainer", "NewSwPhotonsAux": "xAOD::PhotonAuxContainer", "NewSwElectrons": "xAOD::ElectronContainer", "NewSwElectronsAux": "xAOD::ElectronAuxContainer" } + if DoCellReweightingVariations: + EGAM3SlimmingHelper.AppendToDictionary.update({ "MaxVarSwPhotons": "xAOD::PhotonContainer", "MaxVarSwPhotonsAux": "xAOD::PhotonAuxContainer", "MinVarSwPhotons": "xAOD::PhotonContainer", "MinVarSwPhotonsAux": "xAOD::PhotonAuxContainer" }) + EGAM3SlimmingHelper.AppendToDictionary.update({ "MaxVarSwElectrons": "xAOD::ElectronContainer", "MaxVarSwElectronsAux": "xAOD::ElectronAuxContainer", "MinVarSwElectrons": "xAOD::ElectronContainer", "MinVarSwElectronsAux": "xAOD::ElectronAuxContainer" }) + + # Extra variables EGAM3SlimmingHelper.ExtraVariables = ExtraContentAll EGAM3SlimmingHelper.AllVariables = ExtraContainersPhotons EGAM3SlimmingHelper.AllVariables += ExtraContainersTrigger -if globalflags.DataSource()!='geant4': - EGAM3SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly if globalflags.DataSource()=='geant4': EGAM3SlimmingHelper.ExtraVariables += ExtraContentAllTruth EGAM3SlimmingHelper.AllVariables += ExtraContainersTruth +else: + EGAM3SlimmingHelper.ExtraVariables += ExtraContainersTriggerDataOnly for tool in EGAM3_ClusterEnergyPerLayerDecorators: EGAM3SlimmingHelper.ExtraVariables.extend( getClusterEnergyPerLayerDecorations( tool ) ) + +# Add detailed shower shape variables +from DerivationFrameworkEGamma.ElectronsCPDetailedContent import * +EGAM3SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent +EGAM3SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent +from DerivationFrameworkEGamma.PhotonsCPDetailedContent import * +EGAM3SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent + # This line must come after we have finished configuring EGAM3SlimmingHelper EGAM3SlimmingHelper.AppendContentToStream(EGAM3Stream) -# Add MET_RefFinalFix -# JRC: COMMENTED TEMPORARILY -#addMETOutputs(EGAM3Stream) - -# Add AODCellContainer (have to find how to keep only cells belonging to e/gamma objects) +#Add full CellContainer EGAM3Stream.AddItem("CaloCellContainer#AODCellContainer") +EGAM3Stream.AddItem("CaloClusterCellLinkContainer#egammaClusters_links") diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM4.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM4.py index e0b7f7bf3aabe1bd18be955577b3e4b040d30143..ce8f65ec744ad2ba56bba2d945e3a6222cf2b120 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM4.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM4.py @@ -11,26 +11,53 @@ from DerivationFrameworkMuons.MuonsCommon import * from DerivationFrameworkJetEtMiss.JetCommon import * from DerivationFrameworkJetEtMiss.METCommon import * from DerivationFrameworkEGamma.EGammaCommon import * +from DerivationFrameworkEGamma.EGAM4ExtraContent import * + +# read common DFEGamma settings from egammaDFFlags +from DerivationFrameworkEGamma.egammaDFFlags import jobproperties +jobproperties.egammaDFFlags.print_JobProperties("full") +DoCellReweighting = jobproperties.egammaDFFlags.doEGammaCellReweighting +DoCellReweightingVariations = jobproperties.egammaDFFlags.doEGammaCellReweightingVariations +#override if needed (do at your own risk..) +#DoCellReweighting = False +#DoCellReweighting = True + +# check if we run on data or MC (DataSource = geant4) +from AthenaCommon.GlobalFlags import globalflags +print "EGAM4 globalflags.DataSource(): ", globalflags.DataSource() +if globalflags.DataSource()!='geant4': + DoCellReweighting = False + DoCellReweightingVariations = False #==================================================================== -# SKIMMING TOOLS +# SET UP STREAM (to be done early in the game to set up thinning Svc #==================================================================== +streamName = derivationFlags.WriteDAOD_EGAM4Stream.StreamName +fileName = buildFileName( derivationFlags.WriteDAOD_EGAM4Stream ) +EGAM4Stream = MSMgr.NewPoolRootStream( streamName, fileName ) #==================================================================== -# mumugamma selection for photon studies, single & di-muon triggers +# SET UP SKIMMING +#==================================================================== + + +#==================================================================== +# mumugamma and mumue selection for photon studies, single & di-muon triggers # two opposite-sign muons, pT>15 GeV, |eta|<2.5, mmumu>40 GeV # gamma: reco, ET>10 GeV, |eta|<2.5 +# mumueegamma: one reco photon, ET>10 GeV< |eta|<2.5 +# mumue: one reco electron, pT>10 GeV #==================================================================== #requirement = 'Muons.pt>9.5*GeV && abs(Muons.eta)<2.7 && Muons.DFCommonGoodMuon' -requirement = 'Muons.pt>9.5*GeV && abs(Muons.eta)<2.7 && Muons.DFCommonMuonsPreselection' +requirementMuons = 'Muons.pt>9.5*GeV && abs(Muons.eta)<2.7 && Muons.DFCommonMuonsPreselection' from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGInvariantMassTool EGAM4_MuMuMassTool = DerivationFramework__EGInvariantMassTool( name = "EGAM4_MuMuMassTool", - Object1Requirements = requirement, - Object2Requirements = requirement, + Object1Requirements = requirementMuons, + Object2Requirements = requirementMuons, StoreGateEntryName = "EGAM4_DiMuonMass", Mass1Hypothesis = 105*MeV, Mass2Hypothesis = 105*MeV, @@ -42,70 +69,386 @@ EGAM4_MuMuMassTool = DerivationFramework__EGInvariantMassTool( name = "EGAM4_MuM ToolSvc += EGAM4_MuMuMassTool print EGAM4_MuMuMassTool +skimmingExpression1a = 'count(DFCommonPhotons_et>9.5*GeV)>=1 && count(EGAM4_DiMuonMass > 40.0*GeV)>=1' +skimmingExpression1b = 'count(Electrons.pt>9.5*GeV)>=1 && count(EGAM4_DiMuonMass > 40.0*GeV)>=1' + #==================================================================== # SKIMMING TOOL #==================================================================== -expression = 'count(DFCommonPhotons_et>9.5*GeV)>=1 && count(EGAM4_DiMuonMass > 40.0*GeV)>=1' +skimmingExpression = skimmingExpression1a + ' || ' + skimmingExpression1b +print "EGAM4 skimming expression: ", skimmingExpression from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__xAODStringSkimmingTool -EGAM4SkimmingTool = DerivationFramework__xAODStringSkimmingTool( name = "EGAM4SkimmingTool", - expression = expression) -ToolSvc += EGAM4SkimmingTool -print "EGAM4 skimming tool:", EGAM4SkimmingTool +EGAM4_SkimmingTool = DerivationFramework__xAODStringSkimmingTool( name = "EGAM4_SkimmingTool", + expression = skimmingExpression) +ToolSvc += EGAM4_SkimmingTool +print "EGAM4 skimming tool: ", EGAM4_SkimmingTool -#================ -# THINNING -#================ -thinningTools=[] -# TO BE ADDED +#==================================================================== +# SET UP AUGMENTATIONS +#==================================================================== + #==================================================================== # Gain and cluster energies per layer decoration tool #==================================================================== -from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import GainDecorator, getGainDecorations, getClusterEnergyPerLayerDecorator, getClusterEnergyPerLayerDecorations +# GM: do we really need new, different tools: getClusterEnergyPerLayerDecoratorNew, getClusterEnergyPerLayerDecoratorMaxVar, getClusterEnergyPerLayerDecoratorMinVar? +from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import GainDecorator, getGainDecorations, getClusterEnergyPerLayerDecorator, getClusterEnergyPerLayerDecorations, getClusterEnergyPerLayerDecoratorNew, getClusterEnergyPerLayerDecoratorMaxVar, getClusterEnergyPerLayerDecoratorMinVar EGAM4_GainDecoratorTool = GainDecorator() ToolSvc += EGAM4_GainDecoratorTool -cluster_sizes = (3,5), (5,7), (7,7), (7,11) +cluster_sizes = (3,7), (5,5), (7,11) EGAM4_ClusterEnergyPerLayerDecorators = [getClusterEnergyPerLayerDecorator(neta, nphi)() for neta, nphi in cluster_sizes] +if DoCellReweighting: + EGAM4_ClusterEnergyPerLayerDecorators += [getClusterEnergyPerLayerDecoratorNew(neta, nphi)() for neta, nphi in cluster_sizes] + if DoCellReweightingVariations: + EGAM4_ClusterEnergyPerLayerDecorators += [getClusterEnergyPerLayerDecoratorMaxVar(neta, nphi)() for neta, nphi in cluster_sizes] + EGAM4_ClusterEnergyPerLayerDecorators += [getClusterEnergyPerLayerDecoratorMinVar(neta, nphi)() for neta, nphi in cluster_sizes] + + + +#==================================================================== +# Max Cell sum decoration tool +#==================================================================== +from DerivationFrameworkCalo.DerivationFrameworkCaloConf import DerivationFramework__MaxCellDecorator +EGAM4_MaxCellDecoratorTool = DerivationFramework__MaxCellDecorator( name = "EGAM4_MaxCellDecoratorTool", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons") +ToolSvc += EGAM4_MaxCellDecoratorTool + + +#==================================================================== +# Cell reweighter +#==================================================================== +if DoCellReweighting: + from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import NewCellTool, ClusterDecoratorWithNewCells, EGammaReweightTool + + # first, create the container with the new cells (after reweighting) + EGAM4_NewCellTool = NewCellTool("EGAM4_NewCellTool", + #OutputLevel = DEBUG + CellContainerName = "AODCellContainer", + ReweightCellContainerName="NewCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons", + ReweightCoefficients2DPath = "DerivationFrameworkCalo/CellReweight_v2d/rewCoeffs10.root" ) + print EGAM4_NewCellTool + ToolSvc += EGAM4_NewCellTool + + # second, run a tool that creates the clusters and objects from these new cells + EGAM4_ClusterDecoratorTool = ClusterDecoratorWithNewCells("EGAM4_ClusterDecoratorTool", + #OutputLevel=DEBUG, + OutputClusterSGKey = "EGammaSwClusterWithNewCells", + OutputClusterLink = "NewSwClusterLink", + SGKey_caloCells = "NewCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons") + print EGAM4_ClusterDecoratorTool + ToolSvc += EGAM4_ClusterDecoratorTool + + # third, run a tool that creates the shower shapes with the new cells + from egammaTools.egammaToolsFactories import EMShowerBuilder + EGAM4_EMShowerBuilderTool = EMShowerBuilder("EGAM4_EMShowerBuilderTool", + CellsName="NewCellContainer") + print EGAM4_EMShowerBuilderTool + ToolSvc += EGAM4_EMShowerBuilderTool + + # fourth, decorate the new objects with their shower shapes computed from the new clusters + EGAM4_EGammaReweightTool = EGammaReweightTool("EGAM4_EGammaReweightTool", + #OutputLevel=DEBUG, + SGKey_electrons = "Electrons", + SGKey_photons="Photons", + NewCellContainerName="NewCellContainer", + #NewElectronContainer = "", # no container for electrons + #NewElectronContainer = "NewSwElectrons", + NewPhotonContainer = "NewSwPhotons", + EMShowerBuilderTool = EGAM4_EMShowerBuilderTool, + ClusterCorrectionToolName = "DFEgammaSWToolWithNewCells", + CaloClusterLinkName="NewSwClusterLink", + DecorateEGammaObjects = False, + DecorationPrefix = "RW_", + SaveReweightedContainer = True) + + print EGAM4_EGammaReweightTool + ToolSvc += EGAM4_EGammaReweightTool + + if DoCellReweightingVariations: + + ########################################### REWEIGHTING VARIATIONS - MAX ###################################################### + + from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import MaxVarCellTool, ClusterDecoratorWithMaxVarCells, EGammaMaxVarReweightTool + + # first, create the container with the new cells (after reweighting) + EGAM4_MaxVarCellTool = MaxVarCellTool ("EGAM4_MaxVarCellTool", + #OutputLevel = DEBUG, + CellContainerName="AODCellContainer", + ReweightCellContainerName="MaxVarCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons", + ReweightCoefficients2DPath = "DerivationFrameworkCalo/CellReweight_v2d/rewCoeffs11.root") + + print EGAM4_MaxVarCellTool + ToolSvc += EGAM4_MaxVarCellTool + + # second, run a tool that creates the clusters and objects from these new cells + EGAM4_MaxVarClusterDecoratorTool = ClusterDecoratorWithMaxVarCells("EGAM4_MaxVarClusterDecoratorTool", + OutputClusterSGKey="EGammaSwClusterWithMaxVarCells", + OutputClusterLink="MaxVarSwClusterLink", + SGKey_caloCells = "MaxVarCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons") + print EGAM4_MaxVarClusterDecoratorTool + ToolSvc += EGAM4_MaxVarClusterDecoratorTool + + # third, schedule a tool that will be invoked by the EGammaReweightTool to create on-the-fly the shower shapes with the new cells + EGAM4_EMMaxVarShowerBuilderTool = EMShowerBuilder("EGAM4_EMMaxVarShowerBuilderTool", + CellsName="MaxVarCellContainer") + print EGAM4_EMMaxVarShowerBuilderTool + ToolSvc += EGAM4_EMMaxVarShowerBuilderTool + + # fourth, decorate the new objects with their shower shapes computed from the new clusters + EGAM4_EGammaMaxVarReweightTool = EGammaReweightTool("EGAM4_EGammaMaxVarReweightTool", + #OutputLevel = DEBUG, + SGKey_electrons = "Electrons", + SGKey_photons="Photons", + NewCellContainerName="MaxVarCellContainer", + #NewElectronContainer = "MaxVarSwElectrons", + NewElectronContainer = "", + NewPhotonContainer = "MaxVarSwPhotons", + #NewPhotonContainer = "", + EMShowerBuilderTool = EGAM4_EMMaxVarShowerBuilderTool, + ClusterCorrectionToolName = "DFEgammaSWToolWithMaxVarCells", + CaloClusterLinkName="MaxVarSwClusterLink", + DecorateEGammaObjects = False, + DecorationPrefix = "Max_", + SaveReweightedContainer = True) + print EGAM4_EGammaMaxVarReweightTool + ToolSvc += EGAM4_EGammaMaxVarReweightTool + + + ########################################### REWEIGHTING VARIATIONS - MIN ###################################################### + + from DerivationFrameworkCalo.DerivationFrameworkCaloFactories import MinVarCellTool, ClusterDecoratorWithMinVarCells, EGammaMinVarReweightTool + + # first, create the container with the new cells (after reweighting) + EGAM4_MinVarCellTool = MinVarCellTool ("EGAM4_MinVarCellTol", + #OutputLevel = DEBUG, + CellContainerName="AODCellContainer", + ReweightCellContainerName="MinVarCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons", + ReweightCoefficients2DPath = "DerivationFrameworkCalo/CellReweight_v2d/rewCoeffs00.root") + + + print EGAM4_MinVarCellTool + ToolSvc += EGAM4_MinVarCellTool + + # second, run a tool that creates the clusters and objects from these new cells + EGAM4_MinVarClusterDecoratorTool = ClusterDecoratorWithMinVarCells("EGAM4_MinVarClusterDecoratorTool", + OutputClusterSGKey="EGammaSwClusterWithMinVarCells", + OutputClusterLink="MinVarSwClusterLink", + SGKey_caloCells = "MinVarCellContainer", + SGKey_electrons = "Electrons", + SGKey_photons = "Photons") + print EGAM4_MinVarClusterDecoratorTool + ToolSvc += EGAM4_MinVarClusterDecoratorTool + + # third, schedule a tool that will be invoked by the EGammaReweightTool to create on-the-fly the shower shapes with the new cells + EGAM4_EMMinVarShowerBuilderTool = EMShowerBuilder("EGAM4_EMMinVarShowerBuilderTool", + CellsName="MinVarCellContainer") + print EGAM4_EMMinVarShowerBuilderTool + ToolSvc += EGAM4_EMMinVarShowerBuilderTool + + # fourth, decorate the new objects with their shower shapes computed from the new clusters + EGAM4_EGammaMinVarReweightTool = EGammaReweightTool("EGAM4_EGammaMinVarReweightTool", + #OutputLevel = DEBUG, + SGKey_electrons = "Electrons", + SGKey_photons="Photons", + NewCellContainerName="MinVarCellContainer", + NewElectronContainer = "", + #NewElectronContainer = "MinVarSwElectrons", + NewPhotonContainer = "MinVarSwPhotons", + #NewPhotonContainer = "", + EMShowerBuilderTool = EGAM4_EMMinVarShowerBuilderTool, + ClusterCorrectionToolName = "DFEgammaSWToolWithMinVarCells", + CaloClusterLinkName="MinVarSwClusterLink", + DecorateEGammaObjects = False, + DecorationPrefix = "Min_", + SaveReweightedContainer = True) + + print EGAM4_EGammaMinVarReweightTool + ToolSvc += EGAM4_EGammaMinVarReweightTool + + +#==================================================================== +# SET UP THINNING +#==================================================================== +from DerivationFrameworkCore.ThinningHelper import ThinningHelper +EGAM4ThinningHelper = ThinningHelper( "EGAM4ThinningHelper" ) +EGAM4ThinningHelper.TriggerChains = '(^(?!.*_[0-9]*(j|xe|tau|ht|xs|te))(?!HLT_[eg].*_[0-9]*[eg][0-9].*)(?!HLT_eb.*)(?!.*larpeb.*)(?!HLT_.*_AFP_.*)(HLT_g[1-9].*|HLT_2g[1-9].*|HLT_mu.*|HLT_2mu.*))' +if globalflags.DataSource()!='geant4': + ExtraContainersTrigger += ExtraContainersTriggerDataOnly +EGAM4ThinningHelper.AppendToStream( EGAM4Stream, ExtraContainersTrigger ) + +thinningTools=[] + +# Track thinning +if jobproperties.egammaDFFlags.doEGammaDAODTrackThinning: + + TrackThinningKeepElectronTracks = True + TrackThinningKeepPhotonTracks = True + TrackThinningKeepAllPhotonTracks = True + TrackThinningKeepJetTracks = False + TrackThinningKeepMuonTracks = True + TrackThinningKeepTauTracks = False + TrackThinningKeepPVTracks = False + + # Tracks associated with Jets + if (TrackThinningKeepJetTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__JetTrackParticleThinning + EGAM4JetTPThinningTool = DerivationFramework__JetTrackParticleThinning( name = "EGAM4JetTPThinningTool", + ThinningService = EGAM4ThinningHelper.ThinningSvc(), + JetKey = "AntiKt4EMTopoJets", + InDetTrackParticlesKey = "InDetTrackParticles", + ApplyAnd = True) + ToolSvc += EGAM4JetLCTPThinningTool + print EGAM4JetLCTPThinningTool + thinningTools.append(EGAM4JetLCTPThinningTool) + + # Tracks associated with Muons + if (TrackThinningKeepMuonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__MuonTrackParticleThinning + EGAM4MuonTPThinningTool = DerivationFramework__MuonTrackParticleThinning( name = "EGAM4MuonTPThinningTool", + ThinningService = EGAM4ThinningHelper.ThinningSvc(), + MuonKey = "Muons", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM4MuonTPThinningTool + print EGAM4MuonTPThinningTool + thinningTools.append(EGAM4MuonTPThinningTool) + + # Tracks associated with Electrons + if (TrackThinningKeepElectronTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM4ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM4ElectronTPThinningTool", + ThinningService = EGAM4ThinningHelper.ThinningSvc(), + SGKey = "Electrons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Electrons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + ToolSvc += EGAM4ElectronTPThinningTool + print EGAM4ElectronTPThinningTool + thinningTools.append(EGAM4ElectronTPThinningTool) + + # Tracks associated with Photons + if (TrackThinningKeepPhotonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM4PhotonTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM4PhotonTPThinningTool", + ThinningService = EGAM4ThinningHelper.ThinningSvc(), + SGKey = "Photons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Photons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + + ToolSvc += EGAM4PhotonTPThinningTool + print EGAM4PhotonTPThinningTool + thinningTools.append(EGAM4PhotonTPThinningTool) + + # Tracks associated with Photons (all tracks, large cone, for track isolation studies of the selected photon) + if (TrackThinningKeepAllPhotonTracks) : + EGAM4PhotonTPThinningTool2 = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM4PhotonTPThinningTool2", + ThinningService = EGAM4ThinningHelper.ThinningSvc(), + SGKey = "Photons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Photons.pt > 9.5*GeV", + BestMatchOnly = False, + ConeSize = 0.6, + ApplyAnd = False) + + ToolSvc += EGAM4PhotonTPThinningTool2 + print EGAM4PhotonTPThinningTool2 + thinningTools.append(EGAM4PhotonTPThinningTool2) + + # Tracks associated with Taus + if (TrackThinningKeepTauTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TauTrackParticleThinning + EGAM4TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( name = "EGAM4TauTPThinningTool", + ThinningService = EGAM4ThinningHelper.ThinningSvc(), + TauKey = "TauJets", + ConeSize = 0.6, + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM4TauTPThinningTool + print EGAM4TauTPThinningTool + thinningTools.append(EGAM4TauTPThinningTool) + + # Tracks from primary vertex + if (TrackThinningKeepPVTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning + EGAM4TPThinningTool = DerivationFramework__TrackParticleThinning( name = "EGAM4TPThinningTool", + ThinningService = EGAM4ThinningHelper.ThinningSvc(), + SelectionString = "InDetTrackParticles.DFCommonTightPrimary && abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta) < 3.0*mm", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM4TPThinningTool + print EGAM4TPThinningTool + thinningTools.append(EGAM4TPThinningTool) + +print "EGAM4 thinningTools: ", thinningTools #======================================= -# CREATE THE DERIVATION KERNEL ALGORITHM +# CREATE PRIVATE SEQUENCE #======================================= +egam4Seq = CfgMgr.AthSequencer("EGAM4Sequence") +DerivationFrameworkJob += egam4Seq + +#======================================= +# CREATE THE DERIVATION KERNEL ALGORITHM +#======================================= from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel -DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel("EGAM4Kernel", - #AugmentationTools = [EGAM4_MuMuMassTool,EGAM4_CellDecoratorTool], - AugmentationTools = [EGAM4_MuMuMassTool,EGAM4_GainDecoratorTool] + EGAM4_ClusterEnergyPerLayerDecorators, - SkimmingTools = [EGAM4SkimmingTool], - ThinningTools = thinningTools - ) +augmentationTools = [EGAM4_MuMuMassTool,EGAM4_GainDecoratorTool,EGAM4_MaxCellDecoratorTool] +if DoCellReweighting: + augmentationTools += [EGAM4_NewCellTool, EGAM4_ClusterDecoratorTool, EGAM4_EGammaReweightTool] + if DoCellReweightingVariations: + augmentationTools += [EGAM4_MaxVarCellTool, EGAM4_MaxVarClusterDecoratorTool, EGAM4_EGammaMaxVarReweightTool, EGAM4_MinVarCellTool, EGAM4_MinVarClusterDecoratorTool, EGAM4_EGammaMinVarReweightTool] + +augmentationTools += EGAM4_ClusterEnergyPerLayerDecorators +egam4Seq += CfgMgr.DerivationFramework__DerivationKernel("EGAM4Kernel", + AugmentationTools = augmentationTools, + SkimmingTools = [EGAM4_SkimmingTool], + ThinningTools = thinningTools + ) + #==================================================================== -# SET UP STREAM +# RESTORE JET COLLECTIONS REMOVED BETWEEN r20 AND r21 +#==================================================================== +from DerivationFrameworkJetEtMiss.ExtendedJetCommon import replaceAODReducedJets +reducedJetList = ["AntiKt4TruthJets"] +replaceAODReducedJets(reducedJetList,egam4Seq,"EGAM4") + + +#==================================================================== +# SET UP STREAM SELECTION #==================================================================== -streamName = derivationFlags.WriteDAOD_EGAM4Stream.StreamName -fileName = buildFileName( derivationFlags.WriteDAOD_EGAM4Stream ) -EGAM4Stream = MSMgr.NewPoolRootStream( streamName, fileName ) # Only events that pass the filters listed below are written out. # Name must match that of the kernel above # AcceptAlgs = logical OR of filters # RequireAlgs = logical AND of filters EGAM4Stream.AcceptAlgs(["EGAM4Kernel"]) -augStream = MSMgr.GetStream( streamName ) -evtStream = augStream.GetEventStream() - #==================================================================== -# CONTENT LIST +# SET UP SLIMMING #==================================================================== from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper -from DerivationFrameworkEGamma.EGAM4ExtraContent import * - EGAM4SlimmingHelper = SlimmingHelper("EGAM4SlimmingHelper") EGAM4SlimmingHelper.SmartCollections = ["Electrons", "Photons", @@ -113,7 +456,8 @@ EGAM4SlimmingHelper.SmartCollections = ["Electrons", "TauJets", "MET_Reference_AntiKt4EMTopo", "AntiKt4EMTopoJets", - "BTagging_AntiKt4EMTopo", + "AntiKt4EMTopoJets_BTagging201810", + "BTagging_AntiKt4EMTopo_201810", "InDetTrackParticles", "PrimaryVertices" ] @@ -121,26 +465,36 @@ EGAM4SlimmingHelper.SmartCollections = ["Electrons", EGAM4SlimmingHelper.IncludeEGammaTriggerContent = True EGAM4SlimmingHelper.IncludeMuonTriggerContent = True +# Append cell-reweighted collections to dictionary +if DoCellReweighting: + EGAM4SlimmingHelper.AppendToDictionary = {"NewSwPhotons": "xAOD::PhotonContainer", "NewSwPhotonsAux": "xAOD::PhotonAuxContainer" } + if DoCellReweightingVariations: + EGAM4SlimmingHelper.AppendToDictionary.update({ "MaxVarSwPhotons": "xAOD::PhotonContainer", "MaxVarSwPhotonsAux": "xAOD::PhotonAuxContainer", "MinVarSwPhotons": "xAOD::PhotonContainer", "MinVarSwPhotonsAux": "xAOD::PhotonAuxContainer" }) + # Extra variables EGAM4SlimmingHelper.ExtraVariables = ExtraContentAll EGAM4SlimmingHelper.AllVariables = ExtraContainersPhotons EGAM4SlimmingHelper.AllVariables += ExtraContainersTrigger -if globalflags.DataSource()!='geant4': - EGAM4SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly if globalflags.DataSource()=='geant4': EGAM4SlimmingHelper.ExtraVariables += ExtraContentAllTruth EGAM4SlimmingHelper.AllVariables += ExtraContainersTruth +else: + EGAM4SlimmingHelper.ExtraVariables += ExtraContainersTriggerDataOnly for tool in EGAM4_ClusterEnergyPerLayerDecorators: EGAM4SlimmingHelper.ExtraVariables.extend( getClusterEnergyPerLayerDecorations( tool ) ) +# Add detailed shower shape variables +from DerivationFrameworkEGamma.ElectronsCPDetailedContent import * +EGAM4SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent +EGAM4SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent +from DerivationFrameworkEGamma.PhotonsCPDetailedContent import * +EGAM4SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent + # This line must come after we have finished configuring EGAM4SlimmingHelper EGAM4SlimmingHelper.AppendContentToStream(EGAM4Stream) -# Add MET_RefFinalFix -# JRC: COMMENTED TEMPORARILY -# addMETOutputs(EGAM4Stream) - -# Add AODCellContainer (have to find how to keep only cells belonging to e/gamma objects) +#Add full CellContainer EGAM4Stream.AddItem("CaloCellContainer#AODCellContainer") +EGAM4Stream.AddItem("CaloClusterCellLinkContainer#egammaClusters_links") diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM5.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM5.py index 35e5887b51bbf98cfc96bb70ff108f0aec2345eb..5ba7064281368010b5f534d27f1a00dc0139e3af 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM5.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM5.py @@ -11,12 +11,31 @@ from DerivationFrameworkMuons.MuonsCommon import * from DerivationFrameworkJetEtMiss.JetCommon import * from DerivationFrameworkJetEtMiss.METCommon import * from DerivationFrameworkEGamma.EGammaCommon import * +from DerivationFrameworkEGamma.EGAM5ExtraContent import * + +# read common DFEGamma settings from egammaDFFlags +from DerivationFrameworkEGamma.egammaDFFlags import jobproperties +jobproperties.egammaDFFlags.print_JobProperties("full") +# this could also go in egammaDFFlags RecomputeElectronSelectors = True #RecomputeElectronSelectors = False +# check if we run on data or MC (DataSource = geant4) +from AthenaCommon.GlobalFlags import globalflags +print "EGAM5 globalflags.DataSource(): ", globalflags.DataSource() + + +#==================================================================== +# SET UP STREAM (to be done early in the game to set up thinning Svc +#==================================================================== +streamName = derivationFlags.WriteDAOD_EGAM5Stream.StreamName +fileName = buildFileName( derivationFlags.WriteDAOD_EGAM5Stream ) +EGAM5Stream = MSMgr.NewPoolRootStream( streamName, fileName ) + + #==================================================================== -# SKIMMING TOOLS +# SET UP SKIMMING #==================================================================== #==================================================================== @@ -64,11 +83,6 @@ triggers += ['HLT_e13_etcut_L1EM10_W-MT25'] triggers += ['HLT_e13_etcut_L1EM10_W-MT30'] triggers += ['HLT_e13_etcut_trkcut_L1EM12'] triggers += ['HLT_e13_etcut_trkcut_L1EM10_W-MT25_W-15DPHI-JXE-0_W-15DPHI-EMXE'] -triggers += ['HLT_e13_etcut_trkcut_xs15_mt25'] -triggers += ['HLT_e13_etcut_trkcut_xs15_j20_perf_xe15_2dphi05_mt25'] -triggers += ['HLT_e13_etcut_trkcut_xs15_j20_perf_xe15_6dphi05_mt25'] -triggers += ['HLT_e13_etcut_trkcut_j20_perf_xe15_2dphi05_mt25'] -triggers += ['HLT_e13_etcut_trkcut_j20_perf_xe15_6dphi05_mt25'] triggers += ['HLT_e13_etcut_trkcut_j20_perf_xe15_6dphi15_mt25'] triggers += ['HLT_e13_etcut_trkcut_j20_perf_xe15_6dphi15_mt25_L1EM12_W-MT25_W-15DPHI-JXE-0_W-15DPHI-EMXE_XS20'] triggers += ['HLT_e13_etcut_trkcut_j20_perf_xe15_6dphi15_mt25_L1EM12_W-MT25_W-15DPHI-JXE-0_W-15DPHI-EMXE_W-90RO2-XEHT-0'] @@ -83,8 +97,6 @@ triggers += ['HLT_e13_etcut_trkcut_xs30_j15_perf_xe30_6dphi15_mt35_L1EM12_W-MT2 triggers += ['HLT_e18_etcut_L1EM15_W-MT35'] triggers += ['HLT_e18_etcut_trkcut_L1EM15'] triggers += ['HLT_e18_etcut_trkcut_L1EM15_W-MT35_W-05DPHI-JXE-0_W-05DPHI-EMXE'] -triggers += ['HLT_e18_etcut_trkcut_xs20_mt35'] -triggers += ['HLT_e18_etcut_trkcut_xs20_j20_perf_xe20_6dphi15_mt35'] triggers += ['HLT_e18_etcut_trkcut_xs30_xe30_mt35'] triggers += ['HLT_e18_etcut_trkcut_xs30_j15_perf_xe30_6dphi05_mt35'] triggers += ['HLT_e18_etcut_trkcut_xs30_j15_perf_xe30_6dphi15_mt35'] @@ -101,10 +113,43 @@ triggers += ['HLT_e18_etcut_trkcut_xs30_j15_perf_xe30_6dphi15_mt35_L1EM15_W-MT3 triggers += ['HLT_e18_etcut_trkcut_xs30_xe30_mt35_L1EM15_W-MT35_W-05DPHI-JXE-0_W-05DPHI-EM15XE_XS30'] triggers += ['HLT_e18_etcut_trkcut_xs30_xe30_mt35_L1EM15_W-MT35_W-250RO2-XEHT-0_W-05DPHI-JXE-0_W-05DPHI-EM15XE'] triggers += ['HLT_e18_etcut_trkcut_xs30_xe30_mt35_L1EM15_W-MT35_W-250RO2-XEHT-0_W-15DPHI-JXE-0_W-15DPHI-EM15XE'] -triggers += ['HLT_e18_etcut_trkcut_j20_perf_xe20_6dphi15_mt35'] triggers += ['HLT_e18_etcut_trkcut_j20_perf_xe20_6dphi15_mt35_L1EM15_W-MT35_W-05DPHI-JXE-0_W-05DPHI-EM15XE_XS30'] triggers += ['HLT_e18_etcut_trkcut_j20_perf_xe20_6dphi15_mt35_L1EM15_W-MT35_W-250RO2-XEHT-0_W-05DPHI-JXE-0_W-05DPHI-EM15XE'] +# added for 2017 +triggers += ['HLT_e60_etcut'] +triggers += ['HLT_e60_etcut_L1EM24VHIM'] +triggers += ['HLT_e60_etcut_trkcut_L1EM24VHIM_j15_perf_xe60_6dphi15_mt35'] +triggers += ['HLT_e60_etcut_trkcut_L1EM24VHIM_xe60_mt35'] +triggers += ['HLT_e60_etcut_trkcut_L1EM24VHIM_xs30_j15_perf_xe30_6dphi15_mt35'] +triggers += ['HLT_e60_etcut_trkcut_L1EM24VHIM_xs30_xe30_mt35'] +triggers += ['HLT_e60_lhmedium_nod0'] +triggers += ['HLT_e60_lhmedium_nod0_L1EM24VHI'] +triggers += ['HLT_e60_lhmedium_nod0_L1EM24VHIM'] +triggers += ['HLT_e60_lhvloose_nod0'] +triggers += ['HLT_e60_etcut_trkcut_j15_perf_xe60_6dphi05_mt35'] +triggers += ['HLT_e60_etcut_trkcut_xs30_j15_perf_xe30_6dphi05_mt35'] +triggers += ['HLT_e70_etcut'] +triggers += ['HLT_e70_etcut_L1EM24VHIM'] +triggers += ['HLT_e70_lhloose_nod0_L1EM24VHIM_xe70noL1'] +triggers += ['HLT_e70_lhloose_nod0_xe70noL1'] +triggers += ['HLT_noalg_l1topo_L1EM15'] +triggers += ['HLT_noalg_l1topo_L1EM7'] +triggers += ['HLT_j80_xe80'] +triggers += ['HLT_xe80_tc_lcw_L1XE50'] +triggers += ['HLT_xe90_mht_L1XE50'] +triggers += ['HLT_xe90_tc_lcw_wEFMu_L1XE50'] +triggers += ['HLT_xe90_mht_wEFMu_L1XE50'] +triggers += ['HLT_xe110_mht_L1XE50'] +triggers += ['HLT_xe110_pufit_L1XE50'] + +#added for low-mu data analysis, 2017 and 2018 data +triggers += ['HLT_e15_lhloose_nod0_L1EM12'] +#added for low-mu data analysis, 2018 data +triggers += ['HLT_xe35'] +triggers += ['HLT_e15_etcut_trkcut_xe30noL1'] + + from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__TriggerSkimmingTool EGAM5_TriggerSkimmingTool = DerivationFramework__TriggerSkimmingTool( name = "EGAM5_TriggerSkimmingTool", TriggerListOR = triggers) @@ -117,9 +162,9 @@ print "EGAM5 trigger skimming tool:", EGAM5_TriggerSkimmingTool # could add track isolation (if included in single electron trigger..) if RecomputeElectronSelectors : - requirement_el = '(Electrons.DFCommonElectronsIsEMTight || Electrons.DFCommonElectronsLHTight) && Electrons.pt > 24.5*GeV' + requirement_el = '(Electrons.DFCommonElectronsLHTight) && Electrons.pt > 24.5*GeV' else : - requirement_el = '(Electrons.Tight || Electrons.DFCommonElectronsLHTight) && Electrons.pt > 24.5*GeV' + requirement_el = '(Electrons.LHTight) && Electrons.pt > 24.5*GeV' from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGTransverseMassTool EGAM5_MTTool = DerivationFramework__EGTransverseMassTool( name = "EGAM5_MTTool", @@ -151,6 +196,17 @@ ToolSvc += EGAM5_ThirdSkimmingTool print "EGAM5 offline skimming tool:", EGAM5_ThirdSkimmingTool +from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__FilterCombinationOR +EGAM5_SkimmingTool = DerivationFramework__FilterCombinationOR(name="EGAM5_SkimmingTool", FilterList=[EGAM5_TriggerSkimmingTool,EGAM5_OfflineSkimmingTool,EGAM5_ThirdSkimmingTool] ) +ToolSvc+=EGAM5_SkimmingTool + + + +#==================================================================== +# DECORATION TOOLS +#==================================================================== + + #==================================================================== # Gain and cluster energies per layer decoration tool #==================================================================== @@ -162,10 +218,9 @@ cluster_sizes = (3,5), (5,7), (7,7), (7,11) EGAM5_ClusterEnergyPerLayerDecorators = [getClusterEnergyPerLayerDecorator(neta, nphi)() for neta, nphi in cluster_sizes] -#==================================================================== -# Max Cell sum decoration tool -#==================================================================== - +#==================================================================== +# Max Cell sum decoration tool +#==================================================================== from DerivationFrameworkCalo.DerivationFrameworkCaloConf import DerivationFramework__MaxCellDecorator EGAM5_MaxCellDecoratorTool = DerivationFramework__MaxCellDecorator( name = "EGAM5_MaxCellDecoratorTool", SGKey_electrons = "Electrons", @@ -174,26 +229,141 @@ EGAM5_MaxCellDecoratorTool = DerivationFramework__MaxCellDecorator( name ToolSvc += EGAM5_MaxCellDecoratorTool + +#==================================================================== +# SET UP THINNING +#==================================================================== +from DerivationFrameworkCore.ThinningHelper import ThinningHelper +EGAM5ThinningHelper = ThinningHelper( "EGAM5ThinningHelper" ) +EGAM5ThinningHelper.TriggerChains = '(^(?!.*_[0-9]*(mu|j|xe|tau|ht|xs|te))(?!HLT_[eg].*_[0-9]*[eg][0-9].*)(?!HLT_eb.*)(?!.*larpeb.*)(?!HLT_.*_AFP_.*)(HLT_[eg].*))' +if globalflags.DataSource()!='geant4': + ExtraContainersTrigger += ExtraContainersTriggerDataOnly +EGAM5ThinningHelper.AppendToStream( EGAM5Stream, ExtraContainersTrigger ) + +thinningTools=[] + +# Track thinning +if jobproperties.egammaDFFlags.doEGammaDAODTrackThinning: + + TrackThinningKeepElectronTracks = True + TrackThinningKeepPhotonTracks = True + TrackThinningKeepJetTracks = False + TrackThinningKeepMuonTracks = False + TrackThinningKeepTauTracks = False + TrackThinningKeepPVTracks = True + + # Tracks associated with Jets + if (TrackThinningKeepJetTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__JetTrackParticleThinning + EGAM5JetTPThinningTool = DerivationFramework__JetTrackParticleThinning( name = "EGAM5JetTPThinningTool", + ThinningService = EGAM5ThinningHelper.ThinningSvc(), + JetKey = "AntiKt4EMTopoJets", + InDetTrackParticlesKey = "InDetTrackParticles", + ApplyAnd = True) + ToolSvc += EGAM5JetTPThinningTool + print EGAM5JetTPThinningTool + thinningTools.append(EGAM5JetTPThinningTool) + + # Tracks associated with Muons + if (TrackThinningKeepMuonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__MuonTrackParticleThinning + EGAM5MuonTPThinningTool = DerivationFramework__MuonTrackParticleThinning( name = "EGAM5MuonTPThinningTool", + ThinningService = EGAM5ThinningHelper.ThinningSvc(), + MuonKey = "Muons", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM5MuonTPThinningTool + print EGAM5MuonTPThinningTool + thinningTools.append(EGAM5MuonTPThinningTool) + + # Tracks associated with Electrons + if (TrackThinningKeepElectronTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM5ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM5ElectronTPThinningTool", + ThinningService = EGAM5ThinningHelper.ThinningSvc(), + SGKey = "Electrons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Electrons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + ToolSvc += EGAM5ElectronTPThinningTool + print EGAM5ElectronTPThinningTool + thinningTools.append(EGAM5ElectronTPThinningTool) + + # Tracks associated with Photons + if (TrackThinningKeepPhotonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM5PhotonTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM5PhotonTPThinningTool", + ThinningService = EGAM5ThinningHelper.ThinningSvc(), + SGKey = "Photons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Photons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + + ToolSvc += EGAM5PhotonTPThinningTool + print EGAM5PhotonTPThinningTool + thinningTools.append(EGAM5PhotonTPThinningTool) + + # Tracks associated with Taus + if (TrackThinningKeepTauTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TauTrackParticleThinning + EGAM5TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( name = "EGAM5TauTPThinningTool", + ThinningService = EGAM5ThinningHelper.ThinningSvc(), + TauKey = "TauJets", + ConeSize = 0.6, + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM5TauTPThinningTool + print EGAM5TauTPThinningTool + thinningTools.append(EGAM5TauTPThinningTool) + + # Tracks from primary vertex + if (TrackThinningKeepPVTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning + EGAM5TPThinningTool = DerivationFramework__TrackParticleThinning( name = "EGAM5TPThinningTool", + ThinningService = EGAM5ThinningHelper.ThinningSvc(), + SelectionString = "InDetTrackParticles.DFCommonTightPrimary && abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta) < 3.0*mm", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM5TPThinningTool + print EGAM5TPThinningTool + thinningTools.append(EGAM5TPThinningTool) + +print "EGAM5 thinningTools: ", thinningTools + + #======================================= -# CREATE THE DERIVATION KERNEL ALGORITHM +# CREATE PRIVATE SEQUENCE #======================================= -from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__FilterCombinationOR -EGAM5SkimmingTool = DerivationFramework__FilterCombinationOR(name="EGAM5SkimmingTool", FilterList=[EGAM5_TriggerSkimmingTool,EGAM5_OfflineSkimmingTool,EGAM5_ThirdSkimmingTool] ) -ToolSvc+=EGAM5SkimmingTool +egam5Seq = CfgMgr.AthSequencer("EGAM5Sequence") +DerivationFrameworkJob += egam5Seq + + +#======================================= +# CREATE THE DERIVATION KERNEL ALGORITHM +#======================================= from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel -DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel("EGAM5Kernel", - AugmentationTools = [EGAM5_MTTool,EGAM5_GainDecoratorTool,EGAM5_MaxCellDecoratorTool] + EGAM5_ClusterEnergyPerLayerDecorators, - SkimmingTools = [EGAM5SkimmingTool] - ) +egam5Seq += CfgMgr.DerivationFramework__DerivationKernel("EGAM5Kernel", + AugmentationTools = [EGAM5_MTTool,EGAM5_GainDecoratorTool,EGAM5_MaxCellDecoratorTool] + EGAM5_ClusterEnergyPerLayerDecorators, + SkimmingTools = [EGAM5_SkimmingTool], + ThinningTools = thinningTools + ) #==================================================================== -# SET UP STREAM +# RESTORE JET COLLECTIONS REMOVED BETWEEN r20 AND r21 +#==================================================================== +from DerivationFrameworkJetEtMiss.ExtendedJetCommon import replaceAODReducedJets +reducedJetList = ["AntiKt4TruthJets"] +replaceAODReducedJets(reducedJetList,egam5Seq,"EGAM5") + + +#==================================================================== +# SET UP STREAM SELECTION #==================================================================== -streamName = derivationFlags.WriteDAOD_EGAM5Stream.StreamName -fileName = buildFileName( derivationFlags.WriteDAOD_EGAM5Stream ) -EGAM5Stream = MSMgr.NewPoolRootStream( streamName, fileName ) # Only events that pass the filters listed below are written out. # Name must match that of the kernel above # AcceptAlgs = logical OR of filters @@ -202,19 +372,19 @@ EGAM5Stream.AcceptAlgs(["EGAM5Kernel"]) #==================================================================== -# CONTENT LIST +# SET UP SKIMMING #==================================================================== from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper EGAM5SlimmingHelper = SlimmingHelper("EGAM5SlimmingHelper") -from DerivationFrameworkEGamma.EGAM5ExtraContent import * EGAM5SlimmingHelper.SmartCollections = ["Electrons", "Photons", "Muons", "TauJets", "MET_Reference_AntiKt4EMTopo", "AntiKt4EMTopoJets", - "BTagging_AntiKt4EMTopo", + "AntiKt4EMTopoJets_BTagging201810", + "BTagging_AntiKt4EMTopo_201810", "InDetTrackParticles", "PrimaryVertices" ] @@ -225,20 +395,23 @@ EGAM5SlimmingHelper.IncludeEGammaTriggerContent = True EGAM5SlimmingHelper.ExtraVariables = ExtraContentAll EGAM5SlimmingHelper.AllVariables = ExtraContainersElectrons EGAM5SlimmingHelper.AllVariables += ExtraContainersTrigger -if globalflags.DataSource()!='geant4': - EGAM5SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly if globalflags.DataSource()=='geant4': EGAM5SlimmingHelper.ExtraVariables += ExtraContentAllTruth EGAM5SlimmingHelper.AllVariables += ExtraContainersTruth +else: + EGAM5SlimmingHelper.ExtraVariables += ExtraContainersTriggerDataOnly for tool in EGAM5_ClusterEnergyPerLayerDecorators: EGAM5SlimmingHelper.ExtraVariables.extend( getClusterEnergyPerLayerDecorations( tool ) ) +# Add detailed shower shape variables +from DerivationFrameworkEGamma.ElectronsCPDetailedContent import * +EGAM5SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent +EGAM5SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent +from DerivationFrameworkEGamma.PhotonsCPDetailedContent import * +EGAM5SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent + # This line must come after we have finished configuring EGAM5SlimmingHelper EGAM5SlimmingHelper.AppendContentToStream(EGAM5Stream) -# Add MET_RefFinalFix -# JRC: COMMENTED TEMPORARILY -#addMETOutputs(EGAM5Stream) - diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM6.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM6.py index 6cea0a839c42cbbc97c0f2209727cb3701d5ef42..56723395a2b52d27ee0d0cca93ea538abcb8d5d0 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM6.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM6.py @@ -11,30 +11,32 @@ from DerivationFrameworkMuons.MuonsCommon import * from DerivationFrameworkJetEtMiss.JetCommon import * from DerivationFrameworkJetEtMiss.METCommon import * from DerivationFrameworkEGamma.EGammaCommon import * +from DerivationFrameworkEGamma.EGAM1ExtraContent import * + +# read common DFEGamma settings from egammaDFFlags +from DerivationFrameworkEGamma.egammaDFFlags import jobproperties +jobproperties.egammaDFFlags.print_JobProperties("full") + RecomputeElectronSelectors = True #RecomputeElectronSelectors = False + +# check if we run on data or MC (DataSource = geant4) +from AthenaCommon.GlobalFlags import globalflags +print "EGAM6 globalflags.DataSource(): ", globalflags.DataSource() + + #==================================================================== -# SET UP STREAM +# SET UP STREAM (to be done early in the game to set up thinning Svc #==================================================================== streamName = derivationFlags.WriteDAOD_EGAM6Stream.StreamName fileName = buildFileName( derivationFlags.WriteDAOD_EGAM6Stream ) EGAM6Stream = MSMgr.NewPoolRootStream( streamName, fileName ) -# Only events that pass the filters listed below are written out. -# Name must match that of the kernel above -# AcceptAlgs = logical OR of filters -# RequireAlgs = logical AND of filters -EGAM6Stream.AcceptAlgs(["EGAM6Kernel"]) -#Special lines for thinning -# Thinning service name must match the one passed to the thinning tools -augStream = MSMgr.GetStream( streamName ) -evtStream = augStream.GetEventStream() - #==================================================================== -# SKIMMING TOOLS +# SET UP SKIMMING #==================================================================== # SELECTION FOR CALIBRATION @@ -49,11 +51,11 @@ evtStream = augStream.GetEventStream() # switch to likelihood selectors only as soon as they're commissioned (and used in trigger) if RecomputeElectronSelectors : - requirement_tag = '(Electrons.DFCommonElectronsIsEMTight || Electrons.DFCommonElectronsLHTight) && Electrons.pt > 24.5*GeV' - requirement_probe = '(Electrons.DFCommonElectronsIsEMMedium || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 19.5*GeV' + requirement_tag = '(Electrons.DFCommonElectronsLHTight) && Electrons.pt > 24.5*GeV' + requirement_probe = '(Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 19.5*GeV' else : - requirement_tag = '(Electrons.Tight || Electrons.DFCommonElectronsLHTight) && Electrons.pt > 24.5*GeV' - requirement_probe = '(Electrons.Medium || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 19.5*GeV' + requirement_tag = '(Electrons.LHTight) && Electrons.pt > 24.5*GeV' + requirement_probe = '(Electrons.LHMedium) && Electrons.pt > 19.5*GeV' from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGInvariantMassTool EGAM6_ZEEMassTool1 = DerivationFramework__EGInvariantMassTool( name = "EGAM6_ZEEMassTool1", @@ -76,11 +78,10 @@ print EGAM6_ZEEMassTool1 # OS, mee>60 GeV #==================================================================== -# switch to likelihood selectors only as soon as they're commissioned (and used in trigger) if RecomputeElectronSelectors: - requirement = '(Electrons.DFCommonElectronsIsEMLoose || Electrons.DFCommonElectronsLHLoose || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 19.5*GeV' + requirement = '(Electrons.DFCommonElectronsLHLoose || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 19.5*GeV' else: - requirement = '(Electrons.Loose || Electrons.DFCommonElectronsLHLoose || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 19.5*GeV' + requirement = '(Electrons.LHLoose || Electrons.LHMedium) && Electrons.pt > 19.5*GeV' EGAM6_ZEEMassTool2 = DerivationFramework__EGInvariantMassTool( name = "EGAM6_ZEEMassTool2", Object1Requirements = requirement, Object2Requirements = requirement, @@ -107,9 +108,9 @@ print EGAM6_ZEEMassTool2 # switch to likelihood selectors only as soon as they're commissioned (and used in trigger) if RecomputeElectronSelectors : - requirement_tag = '(Electrons.DFCommonElectronsIsEMLoose || Electrons.DFCommonElectronsLHLoose || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 24.5*GeV' + requirement_tag = '(Electrons.DFCommonElectronsLHLoose || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 24.5*GeV' else : - requirement_tag = '(Electrons.Loose || Electrons.DFCommonElectronsLHLoose || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 24.5*GeV' + requirement_tag = '(Electrons.LHLoose || Electrons.LHMedium) && Electrons.pt > 24.5*GeV' # central electrons: collection = Electrons, pt>14.5 GeV requirement_probe = 'Electrons.pt > 14.5*GeV' @@ -137,9 +138,9 @@ print EGAM6_ZEEMassTool3 # switch to likelihood selectors only as soon as they're commissioned (and used in trigger) if RecomputeElectronSelectors: - requirement_tag = '(Electrons.DFCommonElectronsIsEMLoose || Electrons.DFCommonElectronsLHLoose || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 24.5*GeV' + requirement_tag = '(Electrons.DFCommonElectronsLHLoose || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 24.5*GeV' else: - requirement_tag = '(Electrons.Loose || Electrons.DFCommonElectronsLHLoose || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 24.5*GeV' + requirement_tag = '(Electrons.LHLoose || Electrons.LHMedium) && Electrons.pt > 24.5*GeV' requirement_probe = 'DFCommonPhotons_et > 14.5*GeV' EGAM6_ZEGMassTool = DerivationFramework__EGInvariantMassTool( name = "EGAM6_ZEGMassTool", Object1Requirements = requirement_tag, @@ -162,10 +163,17 @@ print EGAM6_ZEGMassTool #expression = '( ( count(Photons.pt > 10*GeV) > 0 ) || ( count(Electrons.pt > 10*GeV) > 0 ) )' expression = 'count(EGAM6_DiElectronMass > 60.0*GeV)>=1 || count(EGAM6_DiElectronMass2 > 60.0*GeV)>=1 || count(EGAM6_DiElectronMass3 > 60.0*GeV)>=1 || count (EGAM6_ElectronPhotonMass > 60.0*GeV)>=1' from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__xAODStringSkimmingTool -EGAM6SkimmingTool = DerivationFramework__xAODStringSkimmingTool( name = "EGAM6SkimmingTool", +EGAM6_SkimmingTool = DerivationFramework__xAODStringSkimmingTool( name = "EGAM6_SkimmingTool", expression = expression) -ToolSvc += EGAM6SkimmingTool -print "EGAM6 skimming tool:", EGAM6SkimmingTool +ToolSvc += EGAM6_SkimmingTool +print "EGAM6 skimming tool:", EGAM6_SkimmingTool + + + +#==================================================================== +# DECORATION TOOLS +#==================================================================== + #==================================================================== # Gain and cluster energies per layer decoration tool @@ -190,116 +198,186 @@ EGAM6_MaxCellDecoratorTool = DerivationFramework__MaxCellDecorator( name ToolSvc += EGAM6_MaxCellDecoratorTool -#================ -# THINNING -#================ +#==================================================================== +# SET UP THINNING +#==================================================================== + +from DerivationFrameworkCore.ThinningHelper import ThinningHelper +EGAM6ThinningHelper = ThinningHelper( "EGAM6ThinningHelper" ) +EGAM6ThinningHelper.TriggerChains = '(^(?!.*_[0-9]*(mu|j|xe|tau|ht|xs|te))(?!HLT_[eg].*_[0-9]*[eg][0-9].*)(?!HLT_eb.*)(?!.*larpeb.*)(?!HLT_.*_AFP_.*)(HLT_[eg].*))|HLT_e.*_Zee.*' +EGAM6ThinningHelper.AppendToStream( EGAM6Stream, ExtraContainersTrigger ) + thinningTools=[] -# Tracks associated with Jets -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__JetTrackParticleThinning -EGAM6JetLCTPThinningTool = DerivationFramework__JetTrackParticleThinning( name = "EGAM6JetLCTPThinningTool", - StreamName = streamName, - JetKey = "AntiKt4EMTopoJets", - InDetTrackParticlesKey = "InDetTrackParticles", - ApplyAnd = True) -ToolSvc += EGAM6JetLCTPThinningTool -print EGAM6JetLCTPThinningTool -#thinningTools.append(EGAM6JetLCTPThinningTool) - -# Tracks associated with Muons -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__MuonTrackParticleThinning -EGAM6MuonTPThinningTool = DerivationFramework__MuonTrackParticleThinning( name = "EGAM6MuonTPThinningTool", - StreamName = streamName, - MuonKey = "Muons", - InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM6MuonTPThinningTool -print EGAM6MuonTPThinningTool -#thinningTools.append(EGAM6MuonTPThinningTool) - -# Tracks associated with Electrons -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning -EGAM6ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM6ElectronTPThinningTool", - StreamName = streamName, - SGKey = "Electrons", +if jobproperties.egammaDFFlags.doEGammaDAODTrackThinning: + + TrackThinningKeepElectronTracks = True + TrackThinningKeepPhotonTracks = True + TrackThinningKeepAllElectronTracks = True + TrackThinningKeepJetTracks = False + TrackThinningKeepMuonTracks = False + TrackThinningKeepTauTracks = False + TrackThinningKeepPVTracks = True + + # Tracks associated with Electrons + if (TrackThinningKeepElectronTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM6ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM6ElectronTPThinningTool", + ThinningService = EGAM6ThinningHelper.ThinningSvc(), + SGKey = "Electrons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Electrons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + ToolSvc += EGAM6ElectronTPThinningTool + print EGAM6ElectronTPThinningTool + thinningTools.append(EGAM6ElectronTPThinningTool) + + # Tracks associated with Electrons (all tracks, large cone, for track isolation studies of the selected electrons) + if (TrackThinningKeepAllElectronTracks) : + EGAM6ElectronTPThinningTool2 = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM6ElectronTPThinningTool2", + ThinningService = EGAM6ThinningHelper.ThinningSvc(), + SGKey = "Electrons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Electrons.pt > 4*GeV", + BestMatchOnly = False, + ConeSize = 0.6, + ApplyAnd = False) + + ToolSvc += EGAM6ElectronTPThinningTool2 + print EGAM6ElectronTPThinningTool2 + thinningTools.append(EGAM6ElectronTPThinningTool2) + + # Tracks associated with Photons + if (TrackThinningKeepPhotonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM6PhotonTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM6PhotonTPThinningTool", + ThinningService = EGAM6ThinningHelper.ThinningSvc(), + SGKey = "Photons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Photons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + ToolSvc += EGAM6PhotonTPThinningTool + print EGAM6PhotonTPThinningTool + thinningTools.append(EGAM6PhotonTPThinningTool) + + # Tracks associated with Jets + if (TrackThinningKeepJetTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__JetTrackParticleThinning + EGAM6JetTPThinningTool = DerivationFramework__JetTrackParticleThinning( name = "EGAM6JetTPThinningTool", + ThinningService = EGAM6ThinningHelper.ThinningSvc(), + JetKey = "AntiKt4EMTopoJets", InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM6ElectronTPThinningTool -print EGAM6ElectronTPThinningTool -#thinningTools.append(EGAM6ElectronTPThinningTool) - -# Tracks associated with Photons -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning -EGAM6PhotonTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM6PhotonTPThinningTool", - StreamName = streamName, - SGKey = "Photons", - InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM6PhotonTPThinningTool -print EGAM6PhotonTPThinningTool -#thinningTools.append(EGAM6PhotonTPThinningTool) - -# Tracks associated with Taus -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TauTrackParticleThinning -EGAM6TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( name = "EGAM6TauTPThinningTool", - StreamName = streamName, - TauKey = "TauJets", - ConeSize = 0.6, - InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM6TauTPThinningTool -print EGAM6TauTPThinningTool -#thinningTools.append(EGAM6TauTPThinningTool) - -# Tracks from primary vertex -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning -EGAM6TPThinningTool = DerivationFramework__TrackParticleThinning( name = "EGAM6TPThinningTool", - StreamName = streamName, - SelectionString = "abs( DFCommonInDetTrackZ0AtPV * sin(InDetTrackParticles.theta)) < 3.0", - InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM6TPThinningTool -print EGAM6TPThinningTool -#thinningTools.append(EGAM6TPThinningTool) - + ToolSvc += EGAM6JetTPThinningTool + print EGAM6JetTPThinningTool + thinningTools.append(EGAM6JetTPThinningTool) + + + # Tracks associated with Muons + if (TrackThinningKeepMuonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__MuonTrackParticleThinning + EGAM6MuonTPThinningTool = DerivationFramework__MuonTrackParticleThinning( name = "EGAM6MuonTPThinningTool", + ThinningService = EGAM6ThinningHelper.ThinningSvc(), + MuonKey = "Muons", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM6MuonTPThinningTool + print EGAM6MuonTPThinningTool + thinningTools.append(EGAM6MuonTPThinningTool) + + + # Tracks associated with Taus + if (TrackThinningKeepTauTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TauTrackParticleThinning + EGAM6TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( name = "EGAM6TauTPThinningTool", + ThinningService = EGAM6ThinningHelper.ThinningSvc(), + TauKey = "TauJets", + ConeSize = 0.6, + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM6TauTPThinningTool + print EGAM6TauTPThinningTool + thinningTools.append(EGAM6TauTPThinningTool) + + # Tracks from primary vertex + if (TrackThinningKeepPVTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning + EGAM6TPThinningTool = DerivationFramework__TrackParticleThinning( name = "EGAM6TPThinningTool", + ThinningService = EGAM6ThinningHelper.ThinningSvc(), + SelectionString = "InDetTrackParticles.DFCommonTightPrimary && abs( DFCommonInDetTrackZ0AtPV * sin(InDetTrackParticles.theta)) < 3.0*mm", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM6TPThinningTool + print EGAM6TPThinningTool + thinningTools.append(EGAM6TPThinningTool) # Truth thinning -truth_cond_WZH = "((abs(TruthParticles.pdgId) >= 23) && (abs(TruthParticles.pdgId) <= 25))" # W, Z and Higgs -truth_cond_lep = "((abs(TruthParticles.pdgId) >= 11) && (abs(TruthParticles.pdgId) <= 16))" # Leptons -truth_cond_top = "((abs(TruthParticles.pdgId) == 6))" # Top quark -truth_cond_gam = "((abs(TruthParticles.pdgId) == 22) && (TruthParticles.pt > 1*GeV))" # Photon -truth_cond_finalState = '(TruthParticles.status == 1 && TruthParticles.barcode < 200000)' # stable particles -truth_expression = '(' + truth_cond_WZH + ' || ' + truth_cond_lep +' || '+truth_cond_top +' || '+truth_cond_gam + ') || (' + truth_cond_finalState+')' - -from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__GenericTruthThinning -EGAM6TruthThinningTool = DerivationFramework__GenericTruthThinning(name = "EGAM6TruthThinningTool", - StreamName = streamName, - ParticleSelectionString = truth_expression, - PreserveDescendants = False, - PreserveGeneratorDescendants = True, - PreserveAncestors = True) - -from AthenaCommon.GlobalFlags import globalflags -print "EGAM6 globalflags.DataSource(): ", globalflags.DataSource() if globalflags.DataSource()=='geant4': + truth_cond_WZH = "((abs(TruthParticles.pdgId) >= 23) && (abs(TruthParticles.pdgId) <= 25))" # W, Z and Higgs + truth_cond_lep = "((abs(TruthParticles.pdgId) >= 11) && (abs(TruthParticles.pdgId) <= 16))" # Leptons + truth_cond_top = "((abs(TruthParticles.pdgId) == 6))" # Top quark + truth_cond_gam = "((abs(TruthParticles.pdgId) == 22) && (TruthParticles.pt > 1*GeV))" # Photon + truth_cond_finalState = '(TruthParticles.status == 1 && TruthParticles.barcode < 200000)' # stable particles + truth_expression = '(' + truth_cond_WZH + ' || ' + truth_cond_lep +' || '+truth_cond_top +' || '+truth_cond_gam + ') || (' + truth_cond_finalState+')' + + from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__GenericTruthThinning + EGAM6TruthThinningTool = DerivationFramework__GenericTruthThinning(name = "EGAM6TruthThinningTool", + ThinningService = "EGAM6ThinningSvc", + ParticleSelectionString = truth_expression, + PreserveDescendants = False, + PreserveGeneratorDescendants = True, + PreserveAncestors = True) + + ToolSvc += EGAM6TruthThinningTool thinningTools.append(EGAM6TruthThinningTool) + print "EGAM6 thinningTools: ", thinningTools +#======================================= +# CREATE PRIVATE SEQUENCE +#======================================= +egam6Seq = CfgMgr.AthSequencer("EGAM6Sequence") +DerivationFrameworkJob += egam6Seq + + #======================================= # CREATE THE DERIVATION KERNEL ALGORITHM #======================================= from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel -DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel("EGAM6Kernel", +egam6Seq += CfgMgr.DerivationFramework__DerivationKernel("EGAM6Kernel", AugmentationTools = [EGAM6_ZEEMassTool1, EGAM6_ZEEMassTool2, EGAM6_ZEEMassTool3, EGAM6_ZEGMassTool, EGAM6_GainDecoratorTool, EGAM6_MaxCellDecoratorTool] + EGAM6_ClusterEnergyPerLayerDecorators, - SkimmingTools = [EGAM6SkimmingTool], + SkimmingTools = [EGAM6_SkimmingTool], ThinningTools = thinningTools ) -#======================================================================== +#==================================================================== +# RESTORE JET COLLECTIONS REMOVED BETWEEN r20 AND r21 +#==================================================================== +from DerivationFrameworkJetEtMiss.ExtendedJetCommon import replaceAODReducedJets +reducedJetList = ["AntiKt4TruthJets"] +replaceAODReducedJets(reducedJetList,egam6Seq,"EGAM6") + + +#==================================================================== +# SET UP STREAM SELECTION +#==================================================================== +# Only events that pass the filters listed below are written out. +# Name must match that of the kernel above +# AcceptAlgs = logical OR of filters +# RequireAlgs = logical AND of filters +EGAM6Stream.AcceptAlgs(["EGAM6Kernel"]) #==================================================================== -# CONTENT LIST +# SET UP SLIMMING #==================================================================== from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper EGAM6SlimmingHelper = SlimmingHelper("EGAM6SlimmingHelper") @@ -311,7 +389,8 @@ EGAM6SlimmingHelper.SmartCollections = [ "TauJets", "MET_Reference_AntiKt4EMTopo", "AntiKt4EMTopoJets", - "BTagging_AntiKt4EMTopo", + "AntiKt4EMTopoJets_BTagging201810", + "BTagging_AntiKt4EMTopo_201810", "InDetTrackParticles", "PrimaryVertices" ] @@ -320,7 +399,6 @@ EGAM6SlimmingHelper.SmartCollections = [ EGAM6SlimmingHelper.IncludeEGammaTriggerContent = True # read list of extra content from EGAM1 file (output of EGAM6 and EGAM1 is the same) -from DerivationFrameworkEGamma.EGAM1ExtraContent import * EGAM6SlimmingHelper.ExtraVariables = ExtraContentAll EGAM6SlimmingHelper.AllVariables = ExtraContainersElectrons EGAM6SlimmingHelper.AllVariables += ExtraContainersTrigger @@ -343,5 +421,9 @@ EGAM6SlimmingHelper.AppendContentToStream(EGAM6Stream) #addMETOutputs(EGAM6Stream) # Add Derived Egamma CellContainer -from DerivationFrameworkEGamma.EGammaCellCommon import CellCommonThinning -CellCommonThinning(EGAM6Stream) +# from DerivationFrameworkEGamma.EGammaCellCommon import CellCommonThinning +# CellCommonThinning(EGAM6Stream) + +#Add full CellContainer +EGAM6Stream.AddItem("CaloCellContainer#AODCellContainer") +EGAM6Stream.AddItem("CaloClusterCellLinkContainer#egammaClusters_links") diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM7.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM7.py index 9be82d1328520d96e411481c2995275ffb1a2b5f..efa45d4b2d841ca0096a8bbe284df38cfb3b5fd2 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM7.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM7.py @@ -1,4 +1,3 @@ - #******************************************************************** # EGAM7.py - keep events passing or of electron triggers, to select # fake electron candidates @@ -12,10 +11,27 @@ from DerivationFrameworkMuons.MuonsCommon import * from DerivationFrameworkJetEtMiss.JetCommon import * from DerivationFrameworkJetEtMiss.METCommon import * from DerivationFrameworkEGamma.EGammaCommon import * +from DerivationFrameworkEGamma.EGAM7ExtraContent import * + +# read common DFEGamma settings from egammaDFFlags +from DerivationFrameworkEGamma.egammaDFFlags import jobproperties +jobproperties.egammaDFFlags.print_JobProperties("full") + +# check if we run on data or MC (DataSource = geant4) +from AthenaCommon.GlobalFlags import globalflags +print "EGAM7 globalflags.DataSource(): ", globalflags.DataSource() + + +#==================================================================== +# SET UP STREAM (to be done early in the game to set up thinning Svc +#==================================================================== +streamName = derivationFlags.WriteDAOD_EGAM7Stream.StreamName +fileName = buildFileName( derivationFlags.WriteDAOD_EGAM7Stream ) +EGAM7Stream = MSMgr.NewPoolRootStream( streamName, fileName ) #==================================================================== -# SKIMMING TOOLS +# SET UP SKIMMING #==================================================================== # SELECTION FOR BACKGROUND ESTIMATES @@ -108,15 +124,30 @@ triggers += ['HLT_e120_lhvloose' ] triggers += ['HLT_e120_lhloose' ] triggers += ['HLT_e120_loose' ] triggers += ['HLT_e120_vloose' ] +triggers += ['HLT_e140_etcut' ] +triggers += ['HLT_e160_etcut' ] +triggers += ['HLT_e180_etcut' ] +triggers += ['HLT_e200_etcut' ] +triggers += ['HLT_e250_etcut' ] +triggers += ['HLT_e300_etcut' ] +triggers += ['HLT_g250_etcut' ] +triggers += ['HLT_g300_etcut' ] expression = '(' + ' || '.join(triggers) + ') && '+objectSelection print expression from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__xAODStringSkimmingTool -EGAM7SkimmingTool = DerivationFramework__xAODStringSkimmingTool( name = "EGAM7SkimmingTool", +EGAM7_SkimmingTool = DerivationFramework__xAODStringSkimmingTool( name = "EGAM7_SkimmingTool", expression = expression) -ToolSvc += EGAM7SkimmingTool -print "EGAM7 skimming tool:", EGAM7SkimmingTool +ToolSvc += EGAM7_SkimmingTool +print "EGAM7 skimming tool:", EGAM7_SkimmingTool + + + +#==================================================================== +# SET UP AUGMENTATIONS +#==================================================================== + #==================================================================== # Gain and cluster energies per layer decoration tool @@ -129,7 +160,7 @@ cluster_sizes = (3,5), (5,7), (7,7), (7,11) EGAM7_ClusterEnergyPerLayerDecorators = [getClusterEnergyPerLayerDecorator(neta, nphi)() for neta, nphi in cluster_sizes] -#==================================================================== +#==================================================================== # Max Cell sum decoration tool #==================================================================== @@ -141,56 +172,172 @@ EGAM7_MaxCellDecoratorTool = DerivationFramework__MaxCellDecorator( name ToolSvc += EGAM7_MaxCellDecoratorTool -#================ -# THINNING -#================ -thinningTools=[] - +#==================================================================== +# SET UP THINNING +#==================================================================== +from DerivationFrameworkCore.ThinningHelper import ThinningHelper +EGAM7ThinningHelper = ThinningHelper( "EGAM7ThinningHelper" ) +EGAM7ThinningHelper.TriggerChains = '(^(?!.*_[0-9]*(mu|j|xe|tau|ht|xs|te))(?!HLT_[eg].*_[0-9]*[eg][0-9].*)(?!HLT_eb.*)(?!.*larpeb.*)(?!HLT_.*_AFP_.*)(HLT_[eg].*))|HLT_e.*_Zee.*' +if globalflags.DataSource()!='geant4': + ExtraContainersTrigger += ExtraContainersTriggerDataOnly +EGAM7ThinningHelper.AppendToStream( EGAM7Stream, ExtraContainersTrigger ) +thinningTools=[] +# Track thinning +if jobproperties.egammaDFFlags.doEGammaDAODTrackThinning: + + TrackThinningKeepElectronTracks = True + TrackThinningKeepPhotonTracks = True + TrackThinningKeepJetTracks = False + TrackThinningKeepMuonTracks = False + TrackThinningKeepTauTracks = False + TrackThinningKeepPVTracks = False + + # Tracks associated with Jets + if (TrackThinningKeepJetTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__JetTrackParticleThinning + EGAM7JetTPThinningTool = DerivationFramework__JetTrackParticleThinning( name = "EGAM7JetTPThinningTool", + ThinningService = EGAM7ThinningHelper.ThinningSvc(), + JetKey = "AntiKt4EMTopoJets", + InDetTrackParticlesKey = "InDetTrackParticles", + ApplyAnd = True) + ToolSvc += EGAM7JetTPThinningTool + print EGAM7JetTPThinningTool + thinningTools.append(EGAM7JetTPThinningTool) + + # Tracks associated with Muons + if (TrackThinningKeepMuonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__MuonTrackParticleThinning + EGAM7MuonTPThinningTool = DerivationFramework__MuonTrackParticleThinning( name = "EGAM7MuonTPThinningTool", + ThinningService = EGAM7ThinningHelper.ThinningSvc(), + MuonKey = "Muons", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM7MuonTPThinningTool + print EGAM7MuonTPThinningTool + thinningTools.append(EGAM7MuonTPThinningTool) + + # Tracks associated with Electrons + if (TrackThinningKeepElectronTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM7ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM7ElectronTPThinningTool", + ThinningService = EGAM7ThinningHelper.ThinningSvc(), + SGKey = "Electrons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Electrons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + ToolSvc += EGAM7ElectronTPThinningTool + print EGAM7ElectronTPThinningTool + thinningTools.append(EGAM7ElectronTPThinningTool) + + # Tracks associated with Photons + if (TrackThinningKeepPhotonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM7PhotonTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM7PhotonTPThinningTool", + ThinningService = EGAM7ThinningHelper.ThinningSvc(), + SGKey = "Photons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Photons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + + ToolSvc += EGAM7PhotonTPThinningTool + print EGAM7PhotonTPThinningTool + thinningTools.append(EGAM7PhotonTPThinningTool) + + # Tracks associated with Taus + if (TrackThinningKeepTauTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TauTrackParticleThinning + EGAM7TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( name = "EGAM7TauTPThinningTool", + ThinningService = EGAM7ThinningHelper.ThinningSvc(), + TauKey = "TauJets", + ConeSize = 0.6, + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM7TauTPThinningTool + print EGAM7TauTPThinningTool + thinningTools.append(EGAM7TauTPThinningTool) + + # Tracks from primary vertex + if (TrackThinningKeepPVTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning + EGAM7TPThinningTool = DerivationFramework__TrackParticleThinning( name = "EGAM7TPThinningTool", + ThinningService = EGAM7ThinningHelper.ThinningSvc(), + SelectionString = "InDetTrackParticles.DFCommonTightPrimary && abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta) < 3.0*mm", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM7TPThinningTool + print EGAM7TPThinningTool + thinningTools.append(EGAM7TPThinningTool) # Truth thinning -truth_cond_WZH = "((abs(TruthParticles.pdgId) >= 23) && (abs(TruthParticles.pdgId) <= 25))" # W, Z and Higgs -truth_cond_lep = "((abs(TruthParticles.pdgId) >= 11) && (abs(TruthParticles.pdgId) <= 16))" # Leptons -truth_cond_top = "((abs(TruthParticles.pdgId) == 6))" # Top quark -truth_cond_gam = "((abs(TruthParticles.pdgId) == 22) && (TruthParticles.pt > 1*GeV))" # Photon -truth_cond_finalState = '(TruthParticles.status == 1 && TruthParticles.barcode < 200000)' # stable particles -truth_expression = '(' + truth_cond_WZH + ' || ' + truth_cond_lep +' || '+truth_cond_top +' || '+truth_cond_gam + ') || (' + truth_cond_finalState+')' - -from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__GenericTruthThinning -EGAM7TruthThinningTool = DerivationFramework__GenericTruthThinning(name = "EGAM7TruthThinningTool", - StreamName = streamName, - ParticleSelectionString = truth_expression, - PreserveDescendants = False, - PreserveGeneratorDescendants = True, - PreserveAncestors = True) - -from AthenaCommon.GlobalFlags import globalflags -print "EGAM7 globalflags.DataSource(): ", globalflags.DataSource() if globalflags.DataSource()=='geant4': + truth_cond_WZH = "((abs(TruthParticles.pdgId) >= 23) && (abs(TruthParticles.pdgId) <= 25))" # W, Z and Higgs + truth_cond_lep = "((abs(TruthParticles.pdgId) >= 11) && (abs(TruthParticles.pdgId) <= 16))" # Leptons + truth_cond_top = "((abs(TruthParticles.pdgId) == 6))" # Top quark + truth_cond_gam = "((abs(TruthParticles.pdgId) == 22) && (TruthParticles.pt > 1*GeV))" # Photon + truth_cond_finalState = '(TruthParticles.status == 1 && TruthParticles.barcode < 200000)' # stable particles + truth_expression = '(' + truth_cond_WZH + ' || ' + truth_cond_lep +' || '+truth_cond_top +' || '+truth_cond_gam + ') || (' + truth_cond_finalState+')' + + from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__GenericTruthThinning + EGAM7TruthThinningTool = DerivationFramework__GenericTruthThinning(name = "EGAM7TruthThinningTool", + ThinningService = EGAM7ThinningHelper.ThinningSvc(), + ParticleSelectionString = truth_expression, + PreserveDescendants = False, + PreserveGeneratorDescendants = True, + PreserveAncestors = True) + ToolSvc += EGAM7TruthThinningTool thinningTools.append(EGAM7TruthThinningTool) + print "EGAM7 thinningTools: ", thinningTools +#======================================= +# CREATE PRIVATE SEQUENCE +#======================================= +egam7Seq = CfgMgr.AthSequencer("EGAM7Sequence") +DerivationFrameworkJob += egam7Seq + + #======================================= # CREATE THE DERIVATION KERNEL ALGORITHM #======================================= from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel -DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel("EGAM7Kernel", - AugmentationTools = [EGAM7_GainDecoratorTool, EGAM7_MaxCellDecoratorTool] + EGAM7_ClusterEnergyPerLayerDecorators, - SkimmingTools = [EGAM7SkimmingTool], - ThinningTools = thinningTools - ) +egam7Seq += CfgMgr.DerivationFramework__DerivationKernel("EGAM7Kernel", + AugmentationTools = [EGAM7_GainDecoratorTool, EGAM7_MaxCellDecoratorTool] + EGAM7_ClusterEnergyPerLayerDecorators, + SkimmingTools = [EGAM7_SkimmingTool], + ThinningTools = thinningTools + ) + +#==================================================================== +# RESTORE JET COLLECTIONS REMOVED BETWEEN r20 AND r21 +#==================================================================== +# od syntax +# addStandardJets("AntiKt", 0.4, "PV0Track", 2000, mods="track_ungroomed", algseq=egam7Seq, outputGroup="EGAM7") +# new syntax +from DerivationFrameworkJetEtMiss.ExtendedJetCommon import replaceAODReducedJets +reducedJetList = ["AntiKt4PV0TrackJets", "AntiKt4TruthJets"] +replaceAODReducedJets(reducedJetList,egam7Seq,"EGAM7") + + +#============ Create Derivation EGAM7 cell collection ================== + +# Keep only calo cells associated with the egammaClusters collection +from DerivationFrameworkCalo.CaloCellDFGetter import CaloCellDFGetter +theCaloCellDFGetter = CaloCellDFGetter(inputClusterKeys=["egammaClusters"], + outputCellKey="DFEGAMCellContainer") +#======================================================================== + #==================================================================== -# SET UP STREAM +# SET UP STREAM SELECTION #==================================================================== -streamName = derivationFlags.WriteDAOD_EGAM7Stream.StreamName -fileName = buildFileName( derivationFlags.WriteDAOD_EGAM7Stream ) -EGAM7Stream = MSMgr.NewPoolRootStream( streamName, fileName ) # Only events that pass the filters listed below are written out. # Name must match that of the kernel above # AcceptAlgs = logical OR of filters @@ -198,29 +345,12 @@ EGAM7Stream = MSMgr.NewPoolRootStream( streamName, fileName ) EGAM7Stream.AcceptAlgs(["EGAM7Kernel"]) -#Special lines for thinning -# Thinning service name must match the one passed to the thinning tools -augStream = MSMgr.GetStream( streamName ) -evtStream = augStream.GetEventStream() - -#============ Thin cells for EGAM7 ================== - -# Keep only calo cells associated with the egammaClusters collection -from DerivationFrameworkCalo.CaloCellDFGetter import thinCaloCellsForDF -thinCaloCellsForDF (inputClusterKeys=["egammaClusters"], - streamName = EGAM7Stream.Name, - outputCellKey = "DFEGAMCellContainer") - -#======================================================================== - - #==================================================================== -# CONTENT LIST +# SET UP SLIMMING #==================================================================== from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper EGAM7SlimmingHelper = SlimmingHelper("EGAM7SlimmingHelper") -from DerivationFrameworkEGamma.EGAM7ExtraContent import * EGAM7SlimmingHelper.SmartCollections = [ "Electrons", "Photons", @@ -228,7 +358,8 @@ EGAM7SlimmingHelper.SmartCollections = [ "TauJets", "MET_Reference_AntiKt4EMTopo", "AntiKt4EMTopoJets", - "BTagging_AntiKt4EMTopo", + "AntiKt4EMTopoJets_BTagging201810", + "BTagging_AntiKt4EMTopo_201810", "InDetTrackParticles", "PrimaryVertices" ] @@ -240,18 +371,22 @@ EGAM7SlimmingHelper.IncludeEGammaTriggerContent = True EGAM7SlimmingHelper.ExtraVariables = ExtraContentAll EGAM7SlimmingHelper.AllVariables = ExtraContainersElectrons EGAM7SlimmingHelper.AllVariables += ExtraContainersTrigger -#if globalflags.DataSource()!='geant4': -# EGAM7SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly if globalflags.DataSource()=='geant4': EGAM7SlimmingHelper.ExtraVariables += ExtraContentAllTruth EGAM7SlimmingHelper.AllVariables += ExtraContainersTruth +else: + EGAM7SlimmingHelper.ExtraVariables += ExtraContainersTriggerDataOnly for tool in EGAM7_ClusterEnergyPerLayerDecorators: EGAM7SlimmingHelper.ExtraVariables.extend( getClusterEnergyPerLayerDecorations( tool ) ) +# Add detailed shower shape variables +from DerivationFrameworkEGamma.ElectronsCPDetailedContent import * +EGAM7SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent +EGAM7SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent +from DerivationFrameworkEGamma.PhotonsCPDetailedContent import * +EGAM7SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent + # This line must come after we have finished configuring EGAM7SlimmingHelper EGAM7SlimmingHelper.AppendContentToStream(EGAM7Stream) - -# Add AODCellContainer (thinned) -EGAM7Stream.AddItem("CaloClusterCellLinkContainer#egammaClusters_links") diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM8.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM8.py index 796e6c66127c23bce5474e1baceeb026fd151306..c62b7913e9562c04527a6d593e83b2290cba0267 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM8.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM8.py @@ -10,48 +10,46 @@ from DerivationFrameworkMuons.MuonsCommon import * from DerivationFrameworkJetEtMiss.JetCommon import * from DerivationFrameworkJetEtMiss.METCommon import * from DerivationFrameworkEGamma.EGammaCommon import * +from DerivationFrameworkEGamma.EGAM8ExtraContent import * + +# read common DFEGamma settings from egammaDFFlags +from DerivationFrameworkEGamma.egammaDFFlags import jobproperties +jobproperties.egammaDFFlags.print_JobProperties("full") +# this could also go in egammaDFFlags RecomputeElectronSelectors = True #RecomputeElectronSelectors = False +# check if we run on data or MC (DataSource = geant4) +from AthenaCommon.GlobalFlags import globalflags +print "EGAM8 globalflags.DataSource(): ", globalflags.DataSource() + #==================================================================== -# SET UP STREAM +# SET UP STREAM (to be done early in the game to set up thinning Svc #==================================================================== streamName = derivationFlags.WriteDAOD_EGAM8Stream.StreamName fileName = buildFileName( derivationFlags.WriteDAOD_EGAM8Stream ) EGAM8Stream = MSMgr.NewPoolRootStream( streamName, fileName ) -# Only events that pass the filters listed below are written out. -# Name must match that of the kernel above -# AcceptAlgs = logical OR of filters -# RequireAlgs = logical AND of filters -EGAM8Stream.AcceptAlgs(["EGAM8Kernel"]) -#Special lines for thinning -# Thinning service name must match the one passed to the thinning tools -augStream = MSMgr.GetStream( streamName ) -evtStream = augStream.GetEventStream() - #==================================================================== -# SKIMMING TOOLS +# SET UP SKIMMING #==================================================================== # SELECTION FOR T&P #==================================================================== # Z->ee selection based on single e trigger, for reco (central) and ID SF(central+fwd) -# 1 tight e, central, pT>25 GeV +# 1 medium e, central, pT>25 GeV # 1 forward e, pT>20 GeV # OS+SS, mee>50 GeV #==================================================================== -# switch to likelihood selectors only as soon as they're commissioned (and used in trigger) if RecomputeElectronSelectors : -# use medium for early data upon electron group request - requirement_tag = '(Electrons.DFCommonElectronsIsEMMedium || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 24.5*GeV' + requirement_tag = '(Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 24.5*GeV' else : - requirement_tag = '(Electrons.Medium || Electrons.DFCommonElectronsLHMedium) && Electrons.pt > 24.5*GeV' + requirement_tag = '(Electrons.LHMedium) && Electrons.pt > 24.5*GeV' requirement_probe = 'ForwardElectrons.pt > 19.5*GeV' from DerivationFrameworkEGamma.DerivationFrameworkEGammaConf import DerivationFramework__EGInvariantMassTool EGAM8_ZEEMassTool = DerivationFramework__EGInvariantMassTool( name = "EGAM8_ZEEMassTool", @@ -96,10 +94,17 @@ print EGAM8_ZMuEMassTool # Skimming criteria expression = 'count(EGAM8_DiElectronMass > 50.0*GeV)>=1 || count(EGAM8_MuonElectronMass > 50.0*GeV)>=1' from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__xAODStringSkimmingTool -EGAM8SkimmingTool = DerivationFramework__xAODStringSkimmingTool( name = "EGAM8SkimmingTool", +EGAM8_SkimmingTool = DerivationFramework__xAODStringSkimmingTool( name = "EGAM8_SkimmingTool", expression = expression) -ToolSvc += EGAM8SkimmingTool -print "EGAM8 skimming tool:", EGAM8SkimmingTool +ToolSvc += EGAM8_SkimmingTool +print "EGAM8 skimming tool:", EGAM8_SkimmingTool + + + +#==================================================================== +# SET UP AUGMENTATIONS +#==================================================================== + #==================================================================== # Gain and cluster energies per layer decoration tool @@ -124,122 +129,177 @@ EGAM8_MaxCellDecoratorTool = DerivationFramework__MaxCellDecorator( name ToolSvc += EGAM8_MaxCellDecoratorTool -#================ -# THINNING -#================ +#==================================================================== +# SET UP THINNING +#==================================================================== + +from DerivationFrameworkCore.ThinningHelper import ThinningHelper +EGAM8ThinningHelper = ThinningHelper( "EGAM8ThinningHelper" ) +EGAM8ThinningHelper.TriggerChains = '(^(?!.*_[0-9]*(mu|j|xe|tau|ht|xs|te))(?!HLT_[eg].*_[0-9]*[eg][0-9].*)(?!HLT_eb.*)(?!.*larpeb.*)(?!HLT_.*_AFP_.*)(HLT_[eg].*))|HLT_e.*_Zee.*' +if globalflags.DataSource()!='geant4': + ExtraContainersTrigger += ExtraContainersTriggerDataOnly +EGAM8ThinningHelper.AppendToStream( EGAM8Stream, ExtraContainersTrigger ) + thinningTools=[] -# Tracks associated with Jets -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__JetTrackParticleThinning -EGAM8JetLCTPThinningTool = DerivationFramework__JetTrackParticleThinning( name = "EGAM8JetLCTPThinningTool", - StreamName = streamName, - JetKey = "AntiKt4EMTopoJets", - InDetTrackParticlesKey = "InDetTrackParticles", - ApplyAnd = True) -ToolSvc += EGAM8JetLCTPThinningTool -print EGAM8JetLCTPThinningTool -#thinningTools.append(EGAM8JetLCTPThinningTool) - -# Tracks associated with Muons -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__MuonTrackParticleThinning -EGAM8MuonTPThinningTool = DerivationFramework__MuonTrackParticleThinning( name = "EGAM8MuonTPThinningTool", - StreamName = streamName, - MuonKey = "Muons", - InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM8MuonTPThinningTool -print EGAM8MuonTPThinningTool -#thinningTools.append(EGAM8MuonTPThinningTool) - -# Tracks associated with Electrons -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning -EGAM8ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM8ElectronTPThinningTool", - StreamName = streamName, - SGKey = "Electrons", - InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM8ElectronTPThinningTool -print EGAM8ElectronTPThinningTool -#thinningTools.append(EGAM8ElectronTPThinningTool) - -# Tracks associated with Photons -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning -EGAM8PhotonTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM8PhotonTPThinningTool", - StreamName = streamName, - SGKey = "Photons", - InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM8PhotonTPThinningTool -print EGAM8PhotonTPThinningTool -#thinningTools.append(EGAM8PhotonTPThinningTool) - -# Tracks associated with Taus -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TauTrackParticleThinning -EGAM8TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( name = "EGAM8TauTPThinningTool", - StreamName = streamName, - TauKey = "TauJets", - ConeSize = 0.6, - InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM8TauTPThinningTool -print EGAM8TauTPThinningTool -#thinningTools.append(EGAM8TauTPThinningTool) - -# Tracks from primary vertex -from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning -EGAM8TPThinningTool = DerivationFramework__TrackParticleThinning( name = "EGAM8TPThinningTool", - StreamName = streamName, - SelectionString = "abs( DFCommonInDetTrackZ0AtPV * sin(InDetTrackParticles.theta)) < 3.0", - InDetTrackParticlesKey = "InDetTrackParticles") -ToolSvc += EGAM8TPThinningTool -print EGAM8TPThinningTool -#thinningTools.append(EGAM8TPThinningTool) +# Track thinning +if jobproperties.egammaDFFlags.doEGammaDAODTrackThinning: + + TrackThinningKeepElectronTracks = True + TrackThinningKeepPhotonTracks = True + TrackThinningKeepJetTracks = False + TrackThinningKeepMuonTracks = True + TrackThinningKeepTauTracks = False + TrackThinningKeepPVTracks = False + + # Tracks associated with Jets + if (TrackThinningKeepJetTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__JetTrackParticleThinning + EGAM8JetTPThinningTool = DerivationFramework__JetTrackParticleThinning( name = "EGAM8JetTPThinningTool", + ThinningService = EGAM8ThinningHelper.ThinningSvc(), + JetKey = "AntiKt4EMTopoJets", + InDetTrackParticlesKey = "InDetTrackParticles", + ApplyAnd = True) + ToolSvc += EGAM8JetTPThinningTool + print EGAM8JetTPThinningTool + thinningTools.append(EGAM8JetTPThinningTool) + + # Tracks associated with Muons + if (TrackThinningKeepMuonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__MuonTrackParticleThinning + EGAM8MuonTPThinningTool = DerivationFramework__MuonTrackParticleThinning( name = "EGAM8MuonTPThinningTool", + ThinningService = EGAM8ThinningHelper.ThinningSvc(), + MuonKey = "Muons", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM8MuonTPThinningTool + print EGAM8MuonTPThinningTool + thinningTools.append(EGAM8MuonTPThinningTool) + + # Tracks associated with Electrons + if (TrackThinningKeepElectronTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM8ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM8ElectronTPThinningTool", + ThinningService = EGAM8ThinningHelper.ThinningSvc(), + SGKey = "Electrons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Electrons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + ToolSvc += EGAM8ElectronTPThinningTool + print EGAM8ElectronTPThinningTool + thinningTools.append(EGAM8ElectronTPThinningTool) + + # Tracks associated with Photons + if (TrackThinningKeepPhotonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM8PhotonTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM8PhotonTPThinningTool", + ThinningService = EGAM8ThinningHelper.ThinningSvc(), + SGKey = "Photons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Photons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + + ToolSvc += EGAM8PhotonTPThinningTool + print EGAM8PhotonTPThinningTool + thinningTools.append(EGAM8PhotonTPThinningTool) + + # Tracks associated with Taus + if (TrackThinningKeepTauTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TauTrackParticleThinning + EGAM8TauTPThinningTool = DerivationFramework__TauTrackParticleThinning( name = "EGAM8TauTPThinningTool", + ThinningService = EGAM8ThinningHelper.ThinningSvc(), + TauKey = "TauJets", + ConeSize = 0.6, + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM8TauTPThinningTool + print EGAM8TauTPThinningTool + thinningTools.append(EGAM8TauTPThinningTool) + + # Tracks from primary vertex + if (TrackThinningKeepPVTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning + EGAM8TPThinningTool = DerivationFramework__TrackParticleThinning( name = "EGAM8TPThinningTool", + ThinningService = EGAM8ThinningHelper.ThinningSvc(), + SelectionString = "InDetTrackParticles.DFCommonTightPrimary && abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta) < 3.0*mm", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM8TPThinningTool + print EGAM8TPThinningTool + thinningTools.append(EGAM8TPThinningTool) # Truth thinning -truth_cond_WZH = "((abs(TruthParticles.pdgId) >= 23) && (abs(TruthParticles.pdgId) <= 25))" # W, Z and Higgs -truth_cond_lep = "((abs(TruthParticles.pdgId) >= 11) && (abs(TruthParticles.pdgId) <= 16))" # Leptons -truth_cond_top = "((abs(TruthParticles.pdgId) == 6))" # Top quark -truth_cond_gam = "((abs(TruthParticles.pdgId) == 22) && (TruthParticles.pt > 1*GeV))" # Photon -truth_cond_finalState = '(TruthParticles.status == 1 && TruthParticles.barcode < 200000)' # stable particles -truth_expression = '(' + truth_cond_WZH + ' || ' + truth_cond_lep +' || '+truth_cond_top +' || '+truth_cond_gam + ') || (' + truth_cond_finalState+')' - -from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__GenericTruthThinning -EGAM8TruthThinningTool = DerivationFramework__GenericTruthThinning(name = "EGAM8TruthThinningTool", - StreamName = streamName, - ParticleSelectionString = truth_expression, - PreserveDescendants = False, - PreserveGeneratorDescendants = True, - PreserveAncestors = True) - -from AthenaCommon.GlobalFlags import globalflags -print "EGAM8 globalflags.DataSource(): ", globalflags.DataSource() if globalflags.DataSource()=='geant4': + truth_cond_WZH = "((abs(TruthParticles.pdgId) >= 23) && (abs(TruthParticles.pdgId) <= 25))" # W, Z and Higgs + truth_cond_lep = "((abs(TruthParticles.pdgId) >= 11) && (abs(TruthParticles.pdgId) <= 16))" # Leptons + truth_cond_top = "((abs(TruthParticles.pdgId) == 6))" # Top quark + truth_cond_gam = "((abs(TruthParticles.pdgId) == 22) && (TruthParticles.pt > 1*GeV))" # Photon + truth_cond_finalState = '(TruthParticles.status == 1 && TruthParticles.barcode < 200000)' # stable particles + truth_expression = '(' + truth_cond_WZH + ' || ' + truth_cond_lep +' || '+truth_cond_top +' || '+truth_cond_gam + ') || (' + truth_cond_finalState+')' + + from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__GenericTruthThinning + EGAM8TruthThinningTool = DerivationFramework__GenericTruthThinning(name = "EGAM8TruthThinningTool", + ThinningService = "EGAM8ThinningSvc", + ParticleSelectionString = truth_expression, + PreserveDescendants = False, + PreserveGeneratorDescendants = True, + PreserveAncestors = True) + + ToolSvc += EGAM8TruthThinningTool thinningTools.append(EGAM8TruthThinningTool) + print "EGAM8 thinningTools: ", thinningTools #======================================= -# CREATE THE DERIVATION KERNEL ALGORITHM +# CREATE PRIVATE SEQUENCE #======================================= +egam8Seq = CfgMgr.AthSequencer("EGAM8Sequence") +DerivationFrameworkJob += egam8Seq + + +#======================================= +# CREATE THE DERIVATION KERNEL ALGORITHM +#======================================= from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel -DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel("EGAM8Kernel", - AugmentationTools = [EGAM8_ZEEMassTool, EGAM8_ZMuEMassTool, EGAM8_GainDecoratorTool, EGAM8_MaxCellDecoratorTool] + EGAM8_ClusterEnergyPerLayerDecorators, - SkimmingTools = [EGAM8SkimmingTool], - ThinningTools = thinningTools - ) +egam8Seq += CfgMgr.DerivationFramework__DerivationKernel("EGAM8Kernel", + AugmentationTools = [EGAM8_ZEEMassTool, EGAM8_ZMuEMassTool, EGAM8_GainDecoratorTool, EGAM8_MaxCellDecoratorTool] + EGAM8_ClusterEnergyPerLayerDecorators, + SkimmingTools = [EGAM8_SkimmingTool], + ThinningTools = thinningTools + ) +#==================================================================== +# RESTORE JET COLLECTIONS REMOVED BETWEEN r20 AND r21 +#==================================================================== +from DerivationFrameworkJetEtMiss.ExtendedJetCommon import replaceAODReducedJets +reducedJetList = ["AntiKt4TruthJets"] +replaceAODReducedJets(reducedJetList,egam8Seq,"EGAM8") -#======================================================================== + +#==================================================================== +# SET UP STREAM SELECTION +#==================================================================== +# Only events that pass the filters listed below are written out. +# Name must match that of the kernel above +# AcceptAlgs = logical OR of filters +# RequireAlgs = logical AND of filters +EGAM8Stream.AcceptAlgs(["EGAM8Kernel"]) #==================================================================== -# CONTENT LIST +# SET UP SLIMMING #==================================================================== from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper EGAM8SlimmingHelper = SlimmingHelper("EGAM8SlimmingHelper") -from DerivationFrameworkEGamma.EGAM8ExtraContent import * EGAM8SlimmingHelper.SmartCollections = [ "Electrons", "Photons", @@ -247,7 +307,8 @@ EGAM8SlimmingHelper.SmartCollections = [ "TauJets", "MET_Reference_AntiKt4EMTopo", "AntiKt4EMTopoJets", - "BTagging_AntiKt4EMTopo", + "AntiKt4EMTopoJets_BTagging201810", + "BTagging_AntiKt4EMTopo_201810", "InDetTrackParticles", "PrimaryVertices" ] @@ -261,23 +322,22 @@ EGAM8SlimmingHelper.IncludeMuonTriggerContent = True EGAM8SlimmingHelper.ExtraVariables = ExtraContentAll EGAM8SlimmingHelper.AllVariables = ExtraContainersElectrons EGAM8SlimmingHelper.AllVariables += ExtraContainersTrigger -if globalflags.DataSource()!='geant4': - EGAM8SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly if globalflags.DataSource()=='geant4': EGAM8SlimmingHelper.ExtraVariables += ExtraContentAllTruth EGAM8SlimmingHelper.AllVariables += ExtraContainersTruth +else: + EGAM8SlimmingHelper.ExtraVariables += ExtraContainersTriggerDataOnly for tool in EGAM8_ClusterEnergyPerLayerDecorators: EGAM8SlimmingHelper.ExtraVariables.extend( getClusterEnergyPerLayerDecorations( tool ) ) +# Add detailed shower shape variables +from DerivationFrameworkEGamma.ElectronsCPDetailedContent import * +EGAM8SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent +EGAM8SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent +from DerivationFrameworkEGamma.PhotonsCPDetailedContent import * +EGAM8SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent + # This line must come after we have finished configuring EGAM8SlimmingHelper EGAM8SlimmingHelper.AppendContentToStream(EGAM8Stream) - -# Add MET_RefFinalFix -# JRC: COMMENTED TEMPORARILY -#addMETOutputs(EGAM8Stream) - -# Add Derived Egamma CellContainer -from DerivationFrameworkEGamma.EGammaCellCommon import CellCommonThinning -CellCommonThinning(EGAM8Stream) diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM9.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM9.py index 6f69bc95f4eaa0812577688e7155424754a4046a..a13d27fba4cf9ba315b046a4d5e48d72551922dd 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM9.py +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/share/EGAM9.py @@ -1,7 +1,6 @@ #******************************************************************** # EGAM9.py - keep events passing or of photon triggers used for # boostrap efficiency measurement of photon triggers -# fake electron candidates # reductionConf flag EGAM9 in Reco_tf.py # author: fernando.monticelli@cern.ch #******************************************************************** @@ -12,10 +11,27 @@ from DerivationFrameworkMuons.MuonsCommon import * from DerivationFrameworkJetEtMiss.JetCommon import * from DerivationFrameworkJetEtMiss.METCommon import * from DerivationFrameworkEGamma.EGammaCommon import * +from DerivationFrameworkEGamma.EGAM9ExtraContent import * + +# read common DFEGamma settings from egammaDFFlags +from DerivationFrameworkEGamma.egammaDFFlags import jobproperties +jobproperties.egammaDFFlags.print_JobProperties("full") + +# check if we run on data or MC +from AthenaCommon.GlobalFlags import globalflags +print "EGAM9 globalflags.DataSource(): ", globalflags.DataSource() + + +#==================================================================== +# SET UP STREAM (to be done early in the game to set up thinning Svc +#==================================================================== +streamName = derivationFlags.WriteDAOD_EGAM9Stream.StreamName +fileName = buildFileName( derivationFlags.WriteDAOD_EGAM9Stream ) +EGAM9Stream = MSMgr.NewPoolRootStream( streamName, fileName ) #==================================================================== -# SKIMMING TOOLS +# SET UP SKIMMING #==================================================================== # SELECTION FOR BACKGROUND ESTIMATES @@ -34,35 +50,59 @@ objectSelection = '( (' + photon_selection + ') || ('+ electron_selection +' ) ) triggers =[] -# HLT_noalg_ triggers for 2016 run +# HLT_noalg_ triggers triggers += ['HLT_noalg_L1EM15VH'] +triggers += ['HLT_noalg_L1EM12'] +triggers += ['HLT_noalg_L1EM15'] +triggers += ['HLT_noalg_L1EM18VH'] +triggers += ['HLT_noalg_L1EM20VH'] +triggers += ['HLT_noalg_L1EM10'] +triggers += ['HLT_noalg_L1EM10VH'] +triggers += ['HLT_noalg_L1EM13VH'] +triggers += ['HLT_noalg_L1EM20VHI'] +triggers += ['HLT_noalg_L1EM22VHI'] +triggers += ['HLT_noalg_L1EM8VH'] # pt_cut triggers triggers += ['HLT_g20_etcut_L1EM12'] -# Passed through triggers -triggers += ['HLT_g10_loose' ] -triggers += ['HLT_g20_loose_L1EM12' ] - -# additional low pt HLT loose triggers -triggers += ['HLT_g20_loose' ] - -# additional BT for high pt HLT loose triggers -triggers += ['HLT_g60_loose' ] +# Passed through triggers for bootstrapping +triggers += ['HLT_g10_loose'] +triggers += ['HLT_g15_loose_L1EM7'] +triggers += ['HLT_g20_loose_L1EM12'] +triggers += ['HLT_g20_loose'] +triggers += ['HLT_g25_loose_L1EM15'] +triggers += ['HLT_g60_loose'] +triggers += ['HLT_g100_loose'] +triggers += ['HLT_g120_loose'] +triggers += ['HLT_g160_loose'] +triggers += ['HLT_g160_loose_L1EM24VHIM'] +triggers += ['HLT_g180_loose'] +triggers += ['HLT_g180_loose_L1EM24VHIM'] +triggers += ['HLT_g35_loose_L1EM15'] +triggers += ['HLT_g40_loose_L1EM15'] +triggers += ['HLT_g45_loose_L1EM15'] +triggers += ['HLT_g50_loose_L1EM15'] +triggers += ['HLT_g70_loose'] +triggers += ['HLT_g80_loose'] +triggers += ['HLT_g140_loose'] +triggers += ['HLT_g200_loose'] -# higher-pT triggers, to bootstrap g140_loose and g140_tight triggers -triggers += ['HLT_g100_loose' ] -triggers += ['HLT_g120_loose' ] expression = '(' + ' || '.join(triggers) + ') && '+objectSelection print expression from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__xAODStringSkimmingTool -EGAM9SkimmingTool = DerivationFramework__xAODStringSkimmingTool( name = "EGAM9SkimmingTool", +EGAM9_SkimmingTool = DerivationFramework__xAODStringSkimmingTool( name = "EGAM9_SkimmingTool", expression = expression) -ToolSvc += EGAM9SkimmingTool -print "EGAM9 skimming tool:", EGAM9SkimmingTool +ToolSvc += EGAM9_SkimmingTool +print "EGAM9 skimming tool:", EGAM9_SkimmingTool + + +#==================================================================== +# SET UP AUGMENTATIONS +#==================================================================== #==================================================================== @@ -76,7 +116,6 @@ cluster_sizes = (3,5), (5,7), (7,7), (7,11) EGAM9_ClusterEnergyPerLayerDecorators = [getClusterEnergyPerLayerDecorator(neta, nphi)() for neta, nphi in cluster_sizes] - #==================================================================== # Max Cell sum decoration tool #==================================================================== @@ -89,84 +128,150 @@ EGAM9_MaxCellDecoratorTool = DerivationFramework__MaxCellDecorator( name ToolSvc += EGAM9_MaxCellDecoratorTool -#================ -# THINNING -#================ -thinningTools=[] +#==================================================================== +# SET UP THINNING +#==================================================================== +from DerivationFrameworkCore.ThinningHelper import ThinningHelper +EGAM9ThinningHelper = ThinningHelper( "EGAM9ThinningHelper" ) +EGAM9ThinningHelper.TriggerChains = '(^(?!.*_[0-9]*(mu|j|xe|tau|ht|xs|te))(?!HLT_[eg].*_[0-9]*[eg][0-9].*)(?!HLT_eb.*)(?!.*larpeb.*)(?!HLT_.*_AFP_.*)(HLT_[eg].*))' +if globalflags.DataSource()!='geant4': + ExtraContainersTrigger += ExtraContainersTriggerDataOnly +EGAM9ThinningHelper.AppendToStream( EGAM9Stream, ExtraContainersTrigger ) +thinningTools=[] # Truth thinning -truth_cond_WZH = "((abs(TruthParticles.pdgId) >= 23) && (abs(TruthParticles.pdgId) <= 25))" # W, Z and Higgs -truth_cond_lep = "((abs(TruthParticles.pdgId) >= 11) && (abs(TruthParticles.pdgId) <= 16))" # Leptons -truth_cond_top = "((abs(TruthParticles.pdgId) == 6))" # Top quark -truth_cond_gam = "((abs(TruthParticles.pdgId) == 22) && (TruthParticles.pt > 1*GeV))" # Photon -truth_cond_finalState = '(TruthParticles.status == 1 && TruthParticles.barcode < 200000)' # stable particles -truth_expression = '(' + truth_cond_WZH + ' || ' + truth_cond_lep +' || '+truth_cond_top +' || '+truth_cond_gam + ') || (' + truth_cond_finalState+')' - -from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__GenericTruthThinning -EGAM9TruthThinningTool = DerivationFramework__GenericTruthThinning(name = "EGAM9TruthThinningTool", - StreamName = streamName, - ParticleSelectionString = truth_expression, - PreserveDescendants = False, - PreserveGeneratorDescendants = True, - PreserveAncestors = True) - -from AthenaCommon.GlobalFlags import globalflags -print "EGAM9 globalflags.DataSource(): ", globalflags.DataSource() if globalflags.DataSource()=='geant4': + truth_cond_WZH = "((abs(TruthParticles.pdgId) >= 23) && (abs(TruthParticles.pdgId) <= 25))" # W, Z and Higgs + truth_cond_lep = "((abs(TruthParticles.pdgId) >= 11) && (abs(TruthParticles.pdgId) <= 16))" # Leptons + truth_cond_top = "((abs(TruthParticles.pdgId) == 6))" # Top quark + truth_cond_gam = "((abs(TruthParticles.pdgId) == 22) && (TruthParticles.pt > 1*GeV))" # Photon + truth_cond_finalState = '(TruthParticles.status == 1 && TruthParticles.barcode < 200000)' # stable particles + truth_expression = '(' + truth_cond_WZH + ' || ' + truth_cond_lep +' || '+truth_cond_top +' || '+truth_cond_gam + ') || (' + truth_cond_finalState+')' + + from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__GenericTruthThinning + EGAM9TruthThinningTool = DerivationFramework__GenericTruthThinning(name = "EGAM9TruthThinningTool", + ThinningService = EGAM9ThinningHelper.ThinningSvc(), + ParticleSelectionString = truth_expression, + PreserveDescendants = False, + PreserveGeneratorDescendants = True, + PreserveAncestors = True) + + ToolSvc += EGAM9TruthThinningTool thinningTools.append(EGAM9TruthThinningTool) + + +# Track thinning +if jobproperties.egammaDFFlags.doEGammaDAODTrackThinning: + + TrackThinningKeepElectronTracks = False + TrackThinningKeepPhotonTracks = True + TrackThinningKeepPVTracks = False + + # tracks associated with Electrons + if (TrackThinningKeepElectronTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM9ElectronTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM9ElectronTPThinningTool", + ThinningService = EGAM9ThinningHelper.ThinningSvc(), + SGKey = "Electrons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Electrons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + ToolSvc += EGAM9ElectronTPThinningTool + print EGAM9ElectronTPThinningTool + thinningTools.append(EGAM9ElectronTPThinningTool) + + # tracks associated with Photons + if (TrackThinningKeepPhotonTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EgammaTrackParticleThinning + EGAM9PhotonTPThinningTool = DerivationFramework__EgammaTrackParticleThinning( name = "EGAM9PhotonTPThinningTool", + ThinningService = EGAM9ThinningHelper.ThinningSvc(), + SGKey = "Photons", + GSFTrackParticlesKey = "GSFTrackParticles", + InDetTrackParticlesKey = "InDetTrackParticles", + SelectionString = "Photons.pt > 0*GeV", + BestMatchOnly = True, + ConeSize = 0.3, + ApplyAnd = False) + + ToolSvc += EGAM9PhotonTPThinningTool + print EGAM9PhotonTPThinningTool + thinningTools.append(EGAM9PhotonTPThinningTool) + + # Tracks from primary vertex + if (TrackThinningKeepPVTracks) : + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning + EGAM9TPThinningTool = DerivationFramework__TrackParticleThinning( name = "EGAM9TPThinningTool", + ThinningService = EGAM9ThinningHelper.ThinningSvc(), + SelectionString = "InDetTrackParticles.DFCommonTightPrimary && abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta) < 3.0*mm", + InDetTrackParticlesKey = "InDetTrackParticles") + ToolSvc += EGAM9TPThinningTool + print EGAM9TPThinningTool + thinningTools.append(EGAM9TPThinningTool) + print "EGAM9 thinningTools: ", thinningTools +#======================================= +# CREATE PRIVATE SEQUENCE +#======================================= +egam9Seq = CfgMgr.AthSequencer("EGAM9Sequence") +DerivationFrameworkJob += egam9Seq + + + #======================================= # CREATE THE DERIVATION KERNEL ALGORITHM #======================================= from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__DerivationKernel -DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel("EGAM9Kernel", - AugmentationTools = [EGAM9_GainDecoratorTool, EGAM9_MaxCellDecoratorTool] + EGAM9_ClusterEnergyPerLayerDecorators, - SkimmingTools = [EGAM9SkimmingTool], - ThinningTools = thinningTools - ) +egam9Seq += CfgMgr.DerivationFramework__DerivationKernel("EGAM9Kernel", + AugmentationTools = [EGAM9_GainDecoratorTool, EGAM9_MaxCellDecoratorTool] + EGAM9_ClusterEnergyPerLayerDecorators, + SkimmingTools = [EGAM9_SkimmingTool], + ThinningTools = thinningTools + ) + #==================================================================== -# SET UP STREAM +# RESTORE JET COLLECTIONS REMOVED BETWEEN r20 AND r21 #==================================================================== -streamName = derivationFlags.WriteDAOD_EGAM9Stream.StreamName -fileName = buildFileName( derivationFlags.WriteDAOD_EGAM9Stream ) -EGAM9Stream = MSMgr.NewPoolRootStream( streamName, fileName ) -# Only events that pass the filters listed below are written out. -# Name must match that of the kernel above -# AcceptAlgs = logical OR of filters -# RequireAlgs = logical AND of filters -EGAM9Stream.AcceptAlgs(["EGAM9Kernel"]) +from DerivationFrameworkJetEtMiss.ExtendedJetCommon import replaceAODReducedJets +reducedJetList = ["AntiKt4TruthJets"] +replaceAODReducedJets(reducedJetList,egam9Seq,"EGAM9") -#Special lines for thinning -# Thinning service name must match the one passed to the thinning tools -augStream = MSMgr.GetStream( streamName ) -evtStream = augStream.GetEventStream() -#============ Thin cells for EGAM9 ================== +#============ Create Derivation EGAM9 cell collection ================== # Keep only calo cells associated with the egammaClusters collection -from DerivationFrameworkCalo.CaloCellDFGetter import thinCaloCellsForDF -thinCaloCellsForDF (inputClusterKeys=["egammaClusters"], - streamName = EGAM9Stream.Name, - outputCellKey = "DFEGAMCellContainer") +from DerivationFrameworkCalo.CaloCellDFGetter import CaloCellDFGetter +theCaloCellDFGetter = CaloCellDFGetter(inputClusterKeys=["egammaClusters"], + outputCellKey="DFEGAMCellContainer") #======================================================================== #==================================================================== -# CONTENT LIST +# SET UP STREAM SELECTION +#==================================================================== +# Only events that pass the filters listed below are written out. +# Name must match that of the kernel above +# AcceptAlgs = logical OR of filters +# RequireAlgs = logical AND of filters +EGAM9Stream.AcceptAlgs(["EGAM9Kernel"]) + + +#==================================================================== +# SET UP SLIMMING #==================================================================== from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper -from DerivationFrameworkEGamma.EGAM9ExtraContent import * # Keep only electrons and photons EGAM9SlimmingHelper = SlimmingHelper("EGAM9SlimmingHelper") @@ -185,18 +290,22 @@ EGAM9SlimmingHelper.ExtraVariables = ExtraContentAll EGAM9SlimmingHelper.AllVariables = ExtraContainersElectrons EGAM9SlimmingHelper.AllVariables += ExtraContainersPhotons EGAM9SlimmingHelper.AllVariables += ExtraContainersTrigger -if globalflags.DataSource()!='geant4': - EGAM9SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly if globalflags.DataSource()=='geant4': EGAM9SlimmingHelper.ExtraVariables += ExtraContentAllTruth EGAM9SlimmingHelper.AllVariables += ExtraContainersTruth +else: + EGAM9SlimmingHelper.ExtraVariables += ExtraContainersTriggerDataOnly for tool in EGAM9_ClusterEnergyPerLayerDecorators: EGAM9SlimmingHelper.ExtraVariables.extend( getClusterEnergyPerLayerDecorations( tool ) ) +# Add detailed shower shape variables +from DerivationFrameworkEGamma.ElectronsCPDetailedContent import * +EGAM9SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent +EGAM9SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent +from DerivationFrameworkEGamma.PhotonsCPDetailedContent import * +EGAM9SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent + # This line must come after we have finished configuring EGAM9SlimmingHelper EGAM9SlimmingHelper.AppendContentToStream(EGAM9Stream) - -# Add AODCellContainer (thinned) -EGAM9Stream.AddItem("CaloClusterCellLinkContainer#egammaClusters_links") diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/BkgElectronClassification.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/BkgElectronClassification.cxx index 53179354a5a8fae1904ba48a0fa90ea397938de6..dfe0c1eaf3f17710a0daaf48f521905fbee42172 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/BkgElectronClassification.cxx +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/BkgElectronClassification.cxx @@ -66,45 +66,12 @@ namespace DerivationFramework { if(tPL.isAvailable(*el) && tPL(*el).isValid() ){ tPdgID(*el)=(*tPL(*el))->pdgId(); } - // - //Additional info for electron coming from photons or another electron, - //not produced by the std egamma reconstruction - // - //use the Classifier for the bkg Electron - //Add Extra Decoration from Classifier in case of BkgElectron (Electron coming for a photon) - static SG::AuxElement::Decorator<int> bkgTT("bkgTruthType") ; - static SG::AuxElement::Decorator<int> bkgTO("bkgTruthOrigin") ; - static SG::AuxElement::Decorator<ElementLink<xAOD::TruthParticleContainer> > bkgTPL ("bkgTruthParticleLink"); - static SG::AuxElement::Decorator<int> bkgMotherPdgID("bkgMotherPdgId") ; - bkgTT(*el)= 0; - bkgTO(*el)= 0; - bkgTPL(*el)=ElementLink<xAOD::TruthParticleContainer>(); - bkgMotherPdgID(*el)=0; - - if(tT.isAvailable(*el) && tO.isAvailable(*el) && - tPL.isAvailable(*el) && tPL(*el).isValid() && - tT(*el)==MCTruthPartClassifier::BkgElectron){ - -#ifdef MCTRUTHCLASSIFIER_CONST - IMCTruthClassifier::Info info; - auto res = m_mcTruthClassifier->checkOrigOfBkgElec(*tPL(*el), &info); - const xAOD::TruthParticle* truthParticle= info.bkgElecMother; -#else - auto res = m_mcTruthClassifier->checkOrigOfBkgElec(*tPL(*el)); - const xAOD::TruthParticle* truthParticle= m_mcTruthClassifier->getBkgElecMother(); -#endif - bkgTT(*el)= res.first; - bkgTO(*el)= res.second; - if(truthParticle){ - ElementLink<xAOD::TruthParticleContainer> link(truthParticle, *truthContainer); - bkgTPL(*el)=link; - bkgMotherPdgID(*el)=truthParticle->pdgId(); - } - } - // - //use the Helpers for electron from electron or photon + + //Use the Helpers for electron from electron or photon //Add Extra Decoration from Egamma helpers in case of BkgElectron (Electron coming for a photon) - //Go back to the last electron/photon mother and classify this one + //Go back to the first/last electron/photon Generator mother and classify this one + + //First the one entering the Geant, the first we meet on the way back static SG::AuxElement::Decorator<int> firstEgMotherTT("firstEgMotherTruthType") ; static SG::AuxElement::Decorator<int> firstEgMotherTO("firstEgMotherTruthOrigin") ; static SG::AuxElement::Decorator<ElementLink<xAOD::TruthParticleContainer> > firstEgMotherTPL ("firstEgMotherTruthParticleLink"); @@ -113,18 +80,35 @@ namespace DerivationFramework { firstEgMotherTO(*el)= 0; firstEgMotherTPL(*el)=ElementLink<xAOD::TruthParticleContainer>(); firstEgMotherPdgID(*el)=0; - // - const xAOD::TruthParticle* eltruth = xAOD::EgammaHelpers::getBkgElectronMother(el,m_barcodecut); - if(eltruth){ - auto res = m_mcTruthClassifier->particleTruthClassifier(eltruth); + const xAOD::TruthParticle* firstElTruth = xAOD::EgammaHelpers::getBkgElectronMother(el,m_barcodecut); + if( firstElTruth ){ + auto res = m_mcTruthClassifier->particleTruthClassifier(firstElTruth); firstEgMotherTT(*el)= res.first; firstEgMotherTO(*el)= res.second; - firstEgMotherPdgID(*el)=eltruth->pdgId(); - ElementLink<xAOD::TruthParticleContainer> link(eltruth, *truthContainer); + firstEgMotherPdgID(*el)=firstElTruth->pdgId(); + ElementLink<xAOD::TruthParticleContainer> link( firstElTruth , *truthContainer); firstEgMotherTPL(*el)=link; } - // - // + + //The last electron / photon we meet on the way back towards the Generator vertex + static SG::AuxElement::Decorator<int> lastEgMotherTT("lastEgMotherTruthType") ; + static SG::AuxElement::Decorator<int> lastEgMotherTO("lastEgMotherTruthOrigin") ; + static SG::AuxElement::Decorator<ElementLink<xAOD::TruthParticleContainer> > lastEgMotherTPL ("lastEgMotherTruthParticleLink"); + static SG::AuxElement::Decorator<int> lastEgMotherPdgID("lastEgMotherPdgId") ; + lastEgMotherTT(*el)= 0; + lastEgMotherTO(*el)= 0; + lastEgMotherTPL(*el)=ElementLink<xAOD::TruthParticleContainer>();; + lastEgMotherPdgID(*el)=0; + const xAOD::TruthParticle* lastElTruth = xAOD::EgammaHelpers::getBkgElectronMother(el); + if( lastElTruth ){ + auto res = m_mcTruthClassifier->particleTruthClassifier(lastElTruth); + lastEgMotherTT(*el)= res.first; + lastEgMotherTO(*el)= res.second; + lastEgMotherPdgID(*el)=lastElTruth->pdgId(); + ElementLink<xAOD::TruthParticleContainer> link( lastElTruth , *truthContainer); + lastEgMotherTPL(*el)=link; + } + } return StatusCode::SUCCESS; } diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGCrackVetoCleaningTool.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGCrackVetoCleaningTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..09f839cbfd8bcc9fdbb756a92fb2808d5816cb41 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGCrackVetoCleaningTool.cxx @@ -0,0 +1,95 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// EGCrackVetoCleaningTool.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// + +#include "DerivationFrameworkEGamma/EGCrackVetoCleaningTool.h" +#include "xAODEgamma/EgammaContainer.h" +#include "xAODEgamma/EgammaxAODHelpers.h" + +namespace DerivationFramework { + + EGCrackVetoCleaningTool::EGCrackVetoCleaningTool(const std::string& t, + const std::string& n, + const IInterface* p) : + AthAlgTool(t,n,p), + m_sgName(""), + m_containerName("") + { + declareInterface<DerivationFramework::IAugmentationTool>(this); + declareProperty("StoreGateEntryName", m_sgName); + declareProperty("ContainerName", m_containerName); + } + + StatusCode EGCrackVetoCleaningTool::initialize() + { + if (m_sgName=="") { + ATH_MSG_ERROR("No SG name provided for the output of EGCrackVetoCleaningTool!"); + return StatusCode::FAILURE; + } + if (m_containerName!="Photons" && m_containerName!="Electrons" && m_containerName!="ForwardElectrons") { + ATH_MSG_ERROR("Wrong container provided!"); + return StatusCode::FAILURE; + } + return StatusCode::SUCCESS; + } + + StatusCode EGCrackVetoCleaningTool::finalize() + { + return StatusCode::SUCCESS; + } + + StatusCode EGCrackVetoCleaningTool::addBranches() const + { + // retrieve container + const xAOD::EgammaContainer* particles = evtStore()->retrieve< const xAOD::EgammaContainer >( m_containerName ); + if( ! particles ) { + ATH_MSG_ERROR ("Couldn't retrieve IParticles with key: " << m_containerName ); + return StatusCode::FAILURE; + } + + // Decorator + SG::AuxElement::Decorator< char > decoratorPass(m_sgName); + + // In principle could use meta-data to do the loop only if mc16a/data15+16 + + // Write mask for each element and record to SG for subsequent selection + for (xAOD::EgammaContainer::const_iterator pItr = particles->begin(); pItr!=particles->end(); ++pItr) { + + xAOD::Type::ObjectType type = (*pItr)->type(); + if (type!=xAOD::Type::Electron && type!=xAOD::Type::Photon) { + ATH_MSG_ERROR ("addBranches(): Wrong particle type (not electron nor photon) being passed to EGCrackVetoCleaningTool"); + return StatusCode::FAILURE; + } + if (type==xAOD::Type::Electron && m_containerName!="Electrons") { + ATH_MSG_ERROR ("addBranches(): Wrong particle type being passed to EGCrackVetoCleaningTool"); + return StatusCode::FAILURE; + } + if (type==xAOD::Type::Photon && m_containerName!="Photons") { + ATH_MSG_ERROR ("addBranches(): Wrong particle type being passed to EGCrackVetoCleaningTool"); + return StatusCode::FAILURE; + } + + const xAOD::Egamma* pCopy = *pItr; + + const xAOD::CaloCluster *clu = pCopy->caloCluster(); + bool maybeBug = clu->hasSampling(CaloSampling::EMB2) && clu->hasSampling(CaloSampling::EME2); + const std::vector<const xAOD::CaloCluster*> assocC = xAOD::EgammaHelpers::getAssociatedTopoClusters(clu); + double dRsatMax = -1.; + if (assocC.size() > 1) { + for (auto sclu : assocC) { + double dR = clu->p4().DeltaR(sclu->p4()); + if (dR > dRsatMax) + dRsatMax = dR; + } + } + decoratorPass(*pCopy) = !(maybeBug && assocC.size() > 1 && dRsatMax > 0.16); // (or dPhi > 0.15 better ?) + } + + return StatusCode::SUCCESS; + } +} diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGElectronAmbiguityTool.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGElectronAmbiguityTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2846a1174ec893cbe369cd141d77274bd120130e --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGElectronAmbiguityTool.cxx @@ -0,0 +1,410 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// EGElectronAmbiguityTool.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// +// + +#include "DerivationFrameworkEGamma/EGElectronAmbiguityTool.h" + +#include "xAODTruth/xAODTruthHelpers.h" +#include "xAODEgamma/ElectronxAODHelpers.h" + +#include "xAODEgamma/ElectronContainer.h" +#include "xAODTracking/VertexContainer.h" +#include "xAODTracking/TrackParticleContainer.h" +#include "xAODTruth/TruthParticle.h" +#include "xAODTruth/TruthVertex.h" +#include "AthContainers/ConstDataVector.h" + +#include "TMath.h" + +namespace { + SG::AuxElement::Decorator< float > drv("DFCommonSimpleConvRadius"); + SG::AuxElement::Decorator< float > dphiv("DFCommonSimpleConvPhi"); + SG::AuxElement::Decorator< float > dmee("DFCommonSimpleMee"); + SG::AuxElement::Decorator< float > dmeeVtx("DFCommonSimpleMeeAtVtx"); + SG::AuxElement::Decorator< float > dsep("DFCommonSimpleSeparation"); + SG::AuxElement::Decorator< int > dambi("DFCommonAddAmbiguity"); + + SG::AuxElement::Decorator< float > dtrv("DFCommonProdTrueRadius"); + SG::AuxElement::Decorator< float > dtpv("DFCommonProdTruePhi"); + SG::AuxElement::Decorator< float > dtzv("DFCommonProdTrueZ"); +} //> end anonymous namespace + +namespace DerivationFramework { + + EGElectronAmbiguityTool::EGElectronAmbiguityTool(const std::string& t, + const std::string& n, + const IInterface* p) : + AthAlgTool(t,n,p) + { + declareInterface<DerivationFramework::IAugmentationTool>(this); + declareProperty("ContainerName", m_containerName = "Electrons"); + declareProperty("VtxContainerName", m_VtxContainerName = "PrimaryVertices"); + declareProperty("tpContainerName", m_tpContainerName = "InDetTrackParticles"); + + declareProperty("isMC", m_isMC); + + declareProperty("pTCut", m_elepTCut = 9e3, "minimum pT for an electron to be studied"); + declareProperty("idCut", m_idCut = "DFCommonElectronsLHLoose", "minimal quality for an electron to be studied"); + + declareProperty("nSiCut", m_nSiCut = 7, "minimum number of Si hits in the other track"); + declareProperty("dzsinTCut", m_dzCut = 0.5, "max dz sinTheta between ele and other tracks"); + declareProperty("SeparationCut", m_sepCut = 1., "first separation cut"); + declareProperty("DCTCut", m_dctCut = 0.02, "second separation cut"); + + declareProperty("radiusCut", m_rvECCut = 20, "minimum radius to be classified as external conversion"); + declareProperty("meeAtVtxCut", m_meeAtVtxECCut = 100, "maximal mass at vertex to be classified as external conversion"); + declareProperty("meeCut", m_meeICCut = 100, "maximal mass at primary vertex to be classified as gamma*"); + + } + + StatusCode EGElectronAmbiguityTool::addBranches() const + { + + static SG::AuxElement::ConstAccessor<char> aidCut(m_idCut); + + // retrieve primary vertex + const xAOD::Vertex *pvtx(nullptr); + const xAOD::VertexContainer *vtxC(nullptr); + if (evtStore()->retrieve(vtxC,m_VtxContainerName).isFailure()) { + ATH_MSG_ERROR( "Failed to retrieve vertex container. Exiting." ); + return StatusCode::FAILURE; + } + for (auto vertex: *vtxC) { + if (vertex->vertexType() == xAOD::VxType::VertexType::PriVtx) { + pvtx = vertex; + break; + } + } + + + // retrieve electron container + const xAOD::ElectronContainer* eleC = evtStore()->retrieve< const xAOD::ElectronContainer >( m_containerName ); + + if( ! eleC ) { + ATH_MSG_ERROR ("Couldn't retrieve Electron container with key: " << m_containerName ); + return StatusCode::FAILURE; + } + if (!pvtx) { + ATH_MSG_DEBUG("No primary vertex found. Setting default values."); + for (const xAOD::Electron* iele : *eleC) { + drv(*iele) = -1; + dphiv(*iele) = -1; + dmee(*iele) = -1; + dmeeVtx(*iele) = -1; + dsep(*iele) = -1; + dambi(*iele) = -1; + dtrv(*iele) = -1; + dtpv(*iele) = -1; + dtzv(*iele) = -1; + } + return StatusCode::SUCCESS; + } + ATH_MSG_DEBUG("Pvx z = " << pvtx->z() << ", number of electrons " << eleC->size()); + + // Make a container of selected tracks : with Si hits, close to electron track + const xAOD::TrackParticleContainer* idtpC(nullptr); + if (evtStore()->retrieve(idtpC,"InDetTrackParticles").isFailure()) { + ATH_MSG_ERROR("No InDetTrackParticles container found"); + return StatusCode::FAILURE; + } + std::set<const xAOD::TrackParticle*> alreadyStored; + std::set<const xAOD::TrackParticle*> eleIDtpStored, eleGSFtpStored; + auto closeByTracks = std::make_unique<ConstDataVector<xAOD::TrackParticleContainer>>(SG::VIEW_ELEMENTS); + + for (auto ele : *eleC) { + + dambi(*ele) = -1; + + // Electron preselection + if (ele->pt() < m_elepTCut || !(m_idCut.size() && aidCut.isAvailable(*ele) && aidCut(*ele))) + continue; + + // Just for debug + const xAOD::TrackParticle *eleGSFtp = ele->trackParticle(); + if (eleGSFtpStored.find(eleGSFtp) == eleGSFtpStored.end()) + eleGSFtpStored.insert(eleGSFtp); + + const xAOD::TrackParticle *eleIDtp = xAOD::EgammaHelpers::getOriginalTrackParticle(ele); + if (eleIDtpStored.find(eleIDtp) == eleIDtpStored.end()) + eleIDtpStored.insert(eleIDtp); + + // The loop on track + for (auto tp : *idtpC) { + + // Keep the electron track (I build a container to run vertexing on it...) + if (tp == eleIDtp) { + closeByTracks->push_back(tp); + alreadyStored.insert(tp); + continue; + } + + // potential candidate to store if not already there + if (alreadyStored.find(tp) != alreadyStored.end()) + continue; + + //// Keep only opposite charge + //if (tp->charge() * ele->charge() > 0) + // continue; + + // Close-by + double dR = eleIDtp->p4().DeltaR(tp->p4()); + double dz = fabs(eleIDtp->z0()-tp->z0())*sin(eleIDtp->theta()); + if (!(dR < 0.3 && dz < m_dzCut)) + continue; + + // With minimum number of Si hits + if (xAOD::EgammaHelpers::numberOfSiHits(tp) < m_nSiCut) + continue; + + alreadyStored.insert(tp); + + closeByTracks->push_back(tp); + } + } + + if (closeByTracks->size() == 0) + return StatusCode::SUCCESS; + + // Record the objects into the event store + if (evtStore()->record ( closeByTracks.release(), "closeByTrackParticles").isFailure()) { + ATH_MSG_ERROR("Could not record the skimmed track particle container"); + return StatusCode::FAILURE; + } + + // + const xAOD::TrackParticleContainer* idSeltpC(nullptr); + if (msgLvl(MSG::DEBUG)) { + if (evtStore()->retrieve(idSeltpC,"closeByTrackParticles").isFailure()) { + ATH_MSG_ERROR("No closeByTrackParticles container found"); + return StatusCode::FAILURE; + } + const xAOD::TrackParticleContainer* tpC(nullptr); + if (evtStore()->retrieve(tpC,"GSFTrackParticles").isFailure()) { + ATH_MSG_ERROR("No TrackParticleInputContainer found"); + return StatusCode::FAILURE; + } + + ATH_MSG_DEBUG("Number of input tracks " << idtpC->size() << " , number of selected close-by tracks " << idSeltpC->size() << " , number of GSF tracks " << tpC->size()); + for (auto trk : eleIDtpStored) + ATH_MSG_DEBUG("ele ID trk " << trk << " pt = " << trk->pt()*1e-3 << " eta = " << trk->eta() << " phi = " << trk->phi() << " nSi = " << xAOD::EgammaHelpers::numberOfSiHits(trk)); + for (auto trk : eleGSFtpStored) + ATH_MSG_DEBUG("ele GSF trk " << trk << " pt = " << trk->pt()*1e-3 << " eta = " << trk->eta() << " phi = " << trk->phi() << " nSi = " << xAOD::EgammaHelpers::numberOfSiHits(trk)); + for (auto trk : *idSeltpC) + ATH_MSG_DEBUG("closeby trk " << trk << " pt = " << trk->pt()*1e-3 << " eta = " << trk->eta() << " phi = " << trk->phi() << " nSi = " << xAOD::EgammaHelpers::numberOfSiHits(trk)); + } + + for (auto ele : *eleC) { + + // Electron preselection + if (ele->pt() < m_elepTCut || !(m_idCut.size() && aidCut.isAvailable(*ele) && aidCut(*ele))) + continue; + + // Henri's circles + if (decorateSimple(ele,pvtx).isFailure()) { + ATH_MSG_ERROR("Cannot decorate the electron with the simple info"); + return StatusCode::FAILURE; + } + + } // loop on electrons to decorate + + return StatusCode::SUCCESS; + } +} + +StatusCode DerivationFramework::EGElectronAmbiguityTool::decorateSimple(const xAOD::Electron *ele, const xAOD::Vertex *pvtx) const { + + + // This is the GSF electron track + const xAOD::TrackParticle *eleGSFtrkP = ele->trackParticle(); + + // And the ID one + const xAOD::TrackParticle *eleIDtrkP = xAOD::EgammaHelpers::getOriginalTrackParticle(ele); + + // For the time being, use the ID one, to be consistent when we only find a good ID to make a conversion and no GSF + bool useGSF = false; // hardcoded because it seems we will not use true. Kept for the time being, as not 100% sure + const xAOD::TrackParticle *eletrkP = useGSF ? eleGSFtrkP : eleIDtrkP; + + ATH_MSG_DEBUG("Electron pt = " << ele->pt()*1e-3 << " eta = " << ele->eta() << " phi = " << ele->phi() << " GSF trk ptr = " << eleGSFtrkP << " ID trk ptr " << eleIDtrkP); + + if (m_isMC) { + const xAOD::TruthParticle *truthEl = xAOD::TruthHelpers::getTruthParticle(*ele); + double tpvr = -1, tpvp = 9e9, tpvz = 9e9; + if (truthEl && fabs(truthEl->pdgId()) == 11 && truthEl->prodVtx() != nullptr) { + tpvr = truthEl->prodVtx()->perp(); + tpvp = truthEl->prodVtx()->phi(); + tpvz = truthEl->prodVtx()->z(); + } + dtrv(*ele) = tpvr; + dtpv(*ele) = tpvp; + dtzv(*ele) = tpvz; + } + + // Find the closest track particle with opposite charge and a minimum nb of Si hits + const xAOD::TrackParticleContainer *tpC(nullptr); + if (evtStore()->retrieve(tpC,"closeByTrackParticles").isFailure()) { + ATH_MSG_ERROR ("Failed to retrieve track particle container. Exiting." ); + return StatusCode::FAILURE; + } + const xAOD::TrackParticle *otrkP(nullptr); + double detaMin = 9e9; + for (auto tp : *tpC) { + // Keep only opposite charge + if (tp->charge() * eletrkP->charge() > 0) + continue; + + // Close-by + double dR = eletrkP->p4().DeltaR(tp->p4()); + double dz = fabs(eletrkP->z0()-tp->z0())*sin(eletrkP->theta()); + if (!(dR < 0.3 && dz < m_dzCut)) + continue; + + double deta = fabs(eletrkP->eta() - tp->eta()); + if (deta < detaMin) { + otrkP = tp; + detaMin = deta; + } + } + + double rv = -9e9; + double pv = -9e9; + double mee = -1.; + double meeAtVtx = -1.; + double sep = -9e9; + bool goodConv = false; + + if (otrkP) { + + // To be consistent with the other, use the ID track. + TLorentzVector ep4; ep4.SetPtEtaPhiM(eletrkP->pt(),eletrkP->eta(),eletrkP->phi(),0.511); + + // Maybe could see if a GSF tp exists for this ID tp and use it if yes ? + TLorentzVector op4; op4.SetPtEtaPhiM(otrkP->pt(),otrkP->eta(),otrkP->phi(),0.511); + + // Simple masses + mee = (ep4+op4).M(); + op4.SetPhi(eletrkP->phi()); + meeAtVtx = (ep4+op4).M(); + + // And the conversion point + std::vector<double> helix1, helix2; + helix1.resize(5); + helix2.resize(5); + helix(eletrkP,pvtx,helix1); + helix(otrkP,pvtx,helix2); + + double beta(0.); + if (helix1[4] < helix2[4]) + beta = TMath::PiOver2()-helix1[4]; + else + beta = TMath::PiOver2()-helix2[4]; + + double phi1(helix1[4] + beta); + if (phi1 > TMath::TwoPi()) phi1 -= TMath::TwoPi(); + if (phi1 < 0.) phi1 += TMath::TwoPi(); + + double phi2(helix2[4] + beta); + if (phi2 > TMath::TwoPi()) phi2 -= TMath::TwoPi(); + if (phi2 < 0.) phi2 += TMath::TwoPi(); + + /// HelixToCircle Main Track Electron + double r1 = 1/(2.*fabs(helix1[1])); + + double charge1(1.); + if (helix1[1]<0.) charge1 = -1.; + double rcenter1(helix1[3]/charge1 + r1); + double phicenter1(phi1 + TMath::PiOver2()*charge1); + + double x1 = rcenter1*cos(phicenter1); + double y1 = rcenter1*sin(phicenter1); + + /// HelixToCircle Other Electron Conv Track + double r2 = 1/(2.*fabs(helix2[1])); + + double charge2(1.); + if(helix2[1]<0.) charge2 = -1.; + double rcenter2(helix2[3]/charge2 + r2); + double phicenter2(phi2 + TMath::PiOver2()*charge2); + + double x2 = rcenter2*cos(phicenter2); + double y2 = rcenter2*sin(phicenter2); + ////// + + double dx(x1-x2); + if (dx < 1e-9 && dx > 0.) dx = 1e-9; + if (dx > -1e-9 && dx < 0.) dx = -1e-9; + double slope((y1-y2)/dx); + double b(y1 - slope*x1); + double alpha(atan(slope)); + double d(sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))); + //only keeping opposite sign option + double separation = d-r1-r2; + double cpx1, cpx2; + if (x1 > x2) { + cpx1 = x1-r1*cos(alpha); + cpx2 = x2+r2*cos(alpha); + } else { + cpx1 = x1+r1*cos(alpha); + cpx2 = x2 - r2*cos(alpha); + } + + double temp1 = (cpx1+cpx2)/2; + double temp2 = slope*temp1+b; + double convX = cos(beta)*temp1 + sin(beta)*temp2; + double convY = -sin(beta)*temp1+ cos(beta)*temp2; + + double dct(helix1[0]-helix2[0]); + + /////// + if (fabs(separation) < m_sepCut && fabs(dct) < m_dctCut){ + goodConv = true; + sep = separation; + pv = TMath::ATan2(convY,convX); + rv = sqrt(convX*convX + convY*convY); + if (convX*cos(eletrkP->phi()) + convY*sin(eletrkP->phi()) < 0) rv *= -1.; + } + } else { + dambi(*ele) = -1; + } + drv(*ele) = rv; + dphiv(*ele) = pv; + dmee(*ele) = mee; + dmeeVtx(*ele) = meeAtVtx; + dsep(*ele) = sep; + if (goodConv && rv > m_rvECCut && meeAtVtx < m_meeAtVtxECCut) + dambi(*ele) = 2; + else if (otrkP) { + if (mee < m_meeICCut) + dambi(*ele) = 1; + else + dambi(*ele) = 0; + } + return StatusCode::SUCCESS; +} + +void DerivationFramework::EGElectronAmbiguityTool::helix(const xAOD::TrackParticle *trkP, const xAOD::Vertex *pvtx, std::vector<double>&he) const { + + static const double PTTOCURVATURE = -0.301; + + he[0] = 1./tan(trkP->theta()); + he[1] = PTTOCURVATURE*trkP->charge()/trkP->pt(); + + if (trkP->phi0() > 0.) + he[4] = trkP->phi0(); + else + he[4] = TMath::TwoPi() + trkP->phi0(); + + double c1 = cos(trkP->phi0()); + double s1 = sin(trkP->phi0()); + he[3] = trkP->d0() + c1*pvtx->y() - s1*pvtx->x(); + + c1 *= he[0]; + s1 *= he[0]; + he[2] = trkP->z0() - c1*pvtx->x() - s1*pvtx->y() + pvtx->z(); +} + diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGElectronLikelihoodToolWrapper.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGElectronLikelihoodToolWrapper.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c591bcba6c5b23a294b45474a30e773102c0f937 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGElectronLikelihoodToolWrapper.cxx @@ -0,0 +1,158 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// EGElectronLikelihoodToolWrapper.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Author: Giovanni Marchiori (giovanni.marchiori@cern.ch) + +#include "DerivationFrameworkEGamma/EGElectronLikelihoodToolWrapper.h" +#include "xAODBase/IParticleContainer.h" +#include "xAODEgamma/EgammaContainer.h" +#include "xAODEgamma/Photon.h" +#include "xAODEgamma/Electron.h" +#include "PATCore/AcceptData.h" +#include "PATCore/AcceptInfo.h" + + +namespace DerivationFramework { + + EGElectronLikelihoodToolWrapper::EGElectronLikelihoodToolWrapper(const std::string& t, + const std::string& n, + const IInterface* p) : + AthAlgTool(t,n,p), + m_cut(""), + m_sgName(""), + m_containerName(""), + m_storeTResult(false) + { + declareInterface<DerivationFramework::IAugmentationTool>(this); + declareProperty("EGammaElectronLikelihoodTool", m_tool); + declareProperty("EGammaFudgeMCTool", m_fudgeMCTool); + declareProperty("CutType", m_cut); + declareProperty("StoreGateEntryName", m_sgName); + declareProperty("ContainerName", m_containerName); + declareProperty("StoreTResult", m_storeTResult); + } + + StatusCode EGElectronLikelihoodToolWrapper::initialize() + { + if (m_sgName.empty()) { + ATH_MSG_ERROR("No SG name provided for the output of EGElectronLikelihoodToolWrapper!"); + return StatusCode::FAILURE; + } + if (m_containerName!="Photons" && m_containerName!="Electrons") { + ATH_MSG_ERROR("Wrong container provided!"); + return StatusCode::FAILURE; + } + CHECK(m_tool.retrieve()); + if (!(m_fudgeMCTool.name().empty())) CHECK(m_fudgeMCTool.retrieve()); + return StatusCode::SUCCESS; + } + + StatusCode EGElectronLikelihoodToolWrapper::finalize() + { + return StatusCode::SUCCESS; + } + + StatusCode EGElectronLikelihoodToolWrapper::addBranches() const + { + // retrieve container + const xAOD::IParticleContainer* particles = evtStore()->retrieve< const xAOD::IParticleContainer >( m_containerName ); + if( ! particles ) { + ATH_MSG_ERROR ("Couldn't retrieve IParticles with key: " << m_containerName ); + return StatusCode::FAILURE; + } + + // Decorator + SG::AuxElement::Decorator< char > decoratorPass(m_sgName); + SG::AuxElement::Decorator< unsigned int > decoratorIsEM(m_sgName + "IsEMValue"); + + // Write mask for each element and record to SG for subsequent selection + for (xAOD::IParticleContainer::const_iterator pItr = particles->begin(); pItr!=particles->end(); ++pItr) { + + xAOD::Type::ObjectType type = (*pItr)->type(); + if (type!=xAOD::Type::Electron && type!=xAOD::Type::Photon) { + ATH_MSG_ERROR ("addBranches(): Wrong particle type (not electron nor photon) being passed to EGElectronLikelihoodToolWrapper"); + return StatusCode::FAILURE; + } + if (type==xAOD::Type::Electron && m_containerName!="Electrons") { + ATH_MSG_ERROR ("addBranches(): Wrong particle type being passed to EGElectronLikelihoodToolWrapper"); + return StatusCode::FAILURE; + } + if (type==xAOD::Type::Photon && m_containerName!="Photons") { + ATH_MSG_ERROR ("addBranches(): Wrong particle type being passed to EGElectronLikelihoodToolWrapper"); + return StatusCode::FAILURE; + } + + const xAOD::IParticle* pCopy = *pItr; + + // this should be computed based on some property of the tool or the existence of the ElectronPhotonShowerShapeFudgeTool + bool applyFF = (!m_fudgeMCTool.empty()); + if (applyFF) { + // apply the shower shape corrections + CP::CorrectionCode correctionCode = CP::CorrectionCode::Ok; + if (type==xAOD::Type::Electron) { + const xAOD::Electron* eg = static_cast<const xAOD::Electron*>(*pItr); + xAOD::Electron* el = nullptr; + correctionCode = m_fudgeMCTool->correctedCopy(*eg, el); + pCopy = el; + } + else { + const xAOD::Photon* eg = static_cast<const xAOD::Photon*>(*pItr); + xAOD::Photon* ph = nullptr; + correctionCode = m_fudgeMCTool->correctedCopy(*eg, ph); + pCopy = ph; + } + if (correctionCode==CP::CorrectionCode::Ok) + ; + else if (correctionCode==CP::CorrectionCode::Error) + Error("addBranches()","Error applying fudge factors to current photon"); + else if (correctionCode==CP::CorrectionCode::OutOfValidityRange) + Warning("addBranches()","Current object has no valid fudge factors due to out-of-range"); + else + Warning("addBranches()",Form("Unknown correction code %d from ElectronPhotonShowerShapeFudgeTool",(int) correctionCode)); + } + + // compute the output of the selector + asg::AcceptData theAccept(m_tool->accept(pCopy)); + unsigned int isEM = (unsigned int) theAccept.getCutResultInvertedBitSet().to_ulong(); // this should work for both the cut-based and the LH selectors + double result(0.); // initialise explicitly to avoid compilation warning. It will be overridden in the following block (result is used only if m_storeTResult is true) + + // Lukas Heinrich: interface in master not yet available. + // if (m_storeTResult) { + // result = double(m_tool->calculate(pCopy)); + // } + + // decorate the original object + if(m_cut.empty()){ + bool pass_selection = (bool) theAccept; + if(pass_selection) decoratorPass(**pItr) = 1; + else decoratorPass(**pItr) = 0; + decoratorIsEM(**pItr) = isEM; + if (m_storeTResult) { + SG::AuxElement::Decorator< double > decoratorResult(m_sgName + "Result"); + decoratorResult(**pItr) = result; + } + } + else{ + if (theAccept.getCutResult(m_cut)) { + decoratorPass(**pItr) = 1; + } else { + decoratorPass(**pItr) = 0; + } + decoratorIsEM(**pItr) = isEM; + if (m_storeTResult) { + SG::AuxElement::Decorator< double > decoratorResult(m_sgName + "Result"); + decoratorResult(**pItr) = result; + } + } + + // delete the particle copy + if (applyFF) delete pCopy; + } + + return StatusCode::SUCCESS; + } +} diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGPhotonCleaningWrapper.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGPhotonCleaningWrapper.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f21810ad10594057fad9d33bb209f0331a158021 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGPhotonCleaningWrapper.cxx @@ -0,0 +1,106 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +/////////////////////////////////////////////////////////////////// +// EGPhotonCleaningWrapper.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// +// Author: Giovanni Marchiori (giovanni.marchiori@cern.ch) +// + +#include "DerivationFrameworkEGamma/EGPhotonCleaningWrapper.h" +#include "xAODEgamma/PhotonContainer.h" +#include "xAODEgamma/Photon.h" +#include <EgammaAnalysisHelpers/PhotonHelpers.h> + +namespace DerivationFramework { + + EGPhotonCleaningWrapper::EGPhotonCleaningWrapper(const std::string& t, + const std::string& n, + const IInterface* p) : + AthAlgTool(t,n,p), + m_sgName("DFCommonPhotonsCleaning"), + m_containerName("Photons") + { + declareInterface<DerivationFramework::IAugmentationTool>(this); + declareProperty("EGammaFudgeMCTool", m_fudgeMCTool); + declareProperty("StoreGateEntryName", m_sgName); + declareProperty("ContainerName", m_containerName); + } + + StatusCode EGPhotonCleaningWrapper::initialize() + { + if (m_sgName=="") { + ATH_MSG_ERROR("No SG name provided for the output of EGPhotonCleaningWrapper"); + return StatusCode::FAILURE; + } + if (m_fudgeMCTool.name()!="") CHECK(m_fudgeMCTool.retrieve()); + return StatusCode::SUCCESS; + } + + StatusCode EGPhotonCleaningWrapper::finalize() + { + return StatusCode::SUCCESS; + } + + StatusCode EGPhotonCleaningWrapper::addBranches() const + { + // retrieve container + const xAOD::PhotonContainer* photons = evtStore()->retrieve< const xAOD::PhotonContainer >( m_containerName ); + if( ! photons ) { + ATH_MSG_ERROR ("Couldn't retrieve photons with key: " << m_containerName ); + return StatusCode::FAILURE; + } + + // Decorator + SG::AuxElement::Decorator< char > decoratorPass(m_sgName); + SG::AuxElement::Decorator< char > decoratorPassDelayed(m_sgName+"NoTime"); + + // Write mask for each element and record to SG for subsequent selection + for (xAOD::PhotonContainer::const_iterator phItr = photons->begin(); phItr!=photons->end(); ++phItr) { + + bool passSelection = false; + bool passSelectionDelayed = false; + + bool applyFF = (!m_fudgeMCTool.empty()); + + if (!applyFF) { + passSelection = PhotonHelpers::passOQquality(*phItr); + passSelectionDelayed = PhotonHelpers::passOQqualityDelayed(*phItr); + } + else { + // apply the shower shape corrections + CP::CorrectionCode correctionCode = CP::CorrectionCode::Ok; + xAOD::Photon* ph = 0; + correctionCode = m_fudgeMCTool->correctedCopy(**phItr, ph); + if (correctionCode==CP::CorrectionCode::Ok) { + passSelection = PhotonHelpers::passOQquality(ph); + passSelectionDelayed = PhotonHelpers::passOQqualityDelayed(ph); + } + else if (correctionCode==CP::CorrectionCode::Error) { + Error("addBranches()","Error applying fudge factors to current photon"); + } + else if (correctionCode==CP::CorrectionCode::OutOfValidityRange) { + Warning("addBranches()","Current photon has no valid fudge factors due to out-of-range"); + } + else { + Warning("addBranches()",Form("Unknown correction code %d from ElectronPhotonShowerShapeFudgeTool",(int) correctionCode)); + } + delete ph; + } + + // decorate the original object + if (passSelection) + decoratorPass(**phItr) = 1; + else + decoratorPass(**phItr) = 0; + + if (passSelectionDelayed) + decoratorPassDelayed(**phItr) = 1; + else + decoratorPassDelayed(**phItr) = 0; + } + + return StatusCode::SUCCESS; + } +} diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGSelectionToolWrapper.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGSelectionToolWrapper.cxx index 1fda708116608a574fc7486b4e2cb587b50f0536..5b3715b1dc9ae42e3bd6b09eb13063c66d61f7c4 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGSelectionToolWrapper.cxx +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGSelectionToolWrapper.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -36,10 +36,10 @@ namespace DerivationFramework { StatusCode EGSelectionToolWrapper::initialize() { if (m_sgName=="") { - ATH_MSG_ERROR("No SG name provided for the output of invariant mass tool!"); + ATH_MSG_ERROR("No SG name provided for the output of EGSelectionToolWrapper!"); return StatusCode::FAILURE; } - if (m_containerName!="Photons" && m_containerName!="Electrons") { + if (m_containerName!="Photons" && m_containerName!="Electrons" && m_containerName!="ForwardElectrons") { ATH_MSG_ERROR("Wrong container provided!"); return StatusCode::FAILURE; } @@ -65,7 +65,7 @@ namespace DerivationFramework { // Decorator SG::AuxElement::Decorator< char > decoratorPass(m_sgName); SG::AuxElement::Decorator< unsigned int > decoratorIsEM(m_sgName + "IsEMValue"); - + // Write mask for each element and record to SG for subsequent selection for (xAOD::IParticleContainer::const_iterator pItr = particles->begin(); pItr!=particles->end(); ++pItr) { @@ -74,7 +74,7 @@ namespace DerivationFramework { ATH_MSG_ERROR ("addBranches(): Wrong particle type (not electron nor photon) being passed to EGSelectionToolWrapper"); return StatusCode::FAILURE; } - if (type==xAOD::Type::Electron && m_containerName!="Electrons") { + if (type==xAOD::Type::Electron && (m_containerName!="Electrons" && m_containerName!="ForwardElectrons")) { ATH_MSG_ERROR ("addBranches(): Wrong particle type being passed to EGSelectionToolWrapper"); return StatusCode::FAILURE; } @@ -114,9 +114,9 @@ namespace DerivationFramework { // compute the output of the selector asg::AcceptData theAccept(m_tool->accept(pCopy)); - // this one should be done only for IsEM selectors.. - unsigned int isEM = theAccept.getCutResultInverted(); - + //unsigned int isEM = m_tool->IsemValue(); // this one should be done only for IsEM selectors.. + unsigned int isEM = (unsigned int) theAccept.getCutResultInvertedBitSet().to_ulong(); // this should work for both the cut-based and the LH selectors + // decorate the original object if(m_cut==""){ bool pass_selection = (bool) theAccept; diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGammaPassSelectionWrapper.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGammaPassSelectionWrapper.cxx deleted file mode 100644 index c9072e5eec7f4acd927f8af906d207a86306cbd1..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/EGammaPassSelectionWrapper.cxx +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// EGammaPassSelectionWrapper.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 "DerivationFrameworkEGamma/EGammaPassSelectionWrapper.h" -#include "xAODEgamma/EgammaContainer.h" -#include <vector> -#include <string> - -// Constructor -DerivationFramework::EGammaPassSelectionWrapper::EGammaPassSelectionWrapper( const std::string& t, - const std::string& n, - const IInterface* p ) : - AthAlgTool(t,n,p), - m_collName("Electrons"), - m_sgPrefix("") -{ - declareInterface<DerivationFramework::IAugmentationTool>(this); - declareProperty("SelectionVariables",m_qualFlags); - declareProperty("CollectionName", m_collName); - declareProperty("SGPrefix", m_sgPrefix); -} - -// Destructor -DerivationFramework::EGammaPassSelectionWrapper::~EGammaPassSelectionWrapper() { -} - -// Athena initialize and finalize -StatusCode DerivationFramework::EGammaPassSelectionWrapper::initialize() -{ - if (m_qualFlags.size()==0) { - ATH_MSG_ERROR("No selection variables for the egamma passSelection wrapper tool!"); - return StatusCode::FAILURE; - } - ATH_MSG_VERBOSE("initialize() ..."); - return StatusCode::SUCCESS; -} -StatusCode DerivationFramework::EGammaPassSelectionWrapper::finalize() -{ - ATH_MSG_VERBOSE("finalize() ..."); - return StatusCode::SUCCESS; -} - -// Augmentation -StatusCode DerivationFramework::EGammaPassSelectionWrapper::addBranches() const -{ - - // Retrieve data - const xAOD::EgammaContainer* egammas = evtStore()->retrieve< const xAOD::EgammaContainer >( m_collName ); - if( ! egammas ) { - ATH_MSG_ERROR("Couldn't retrieve e-gamma container with key: " << m_collName); - return StatusCode::FAILURE; - } - - // Make vectors for the cut results - std::vector<std::vector<int>* > allSelectionResults; - for (std::vector<std::string>::const_iterator strItr = m_qualFlags.begin(); strItr!=m_qualFlags.end(); ++strItr) { - std::vector<int> *passEgamma = new std::vector<int>(); - allSelectionResults.push_back(passEgamma); - } - // Loop over egammas, set decisions - for (xAOD::EgammaContainer::const_iterator eIt = egammas->begin(); eIt!=egammas->end(); ++eIt) { - unsigned int itr(0); - for (std::vector<std::string>::const_iterator strItr = m_qualFlags.begin(); strItr!=m_qualFlags.end(); ++strItr, ++itr) { - bool val(0); - if ( (*eIt)->passSelection(val,*strItr) ) { - if (val) {allSelectionResults[itr]->push_back(1);} - else {allSelectionResults[itr]->push_back(0);} - } else { - ATH_MSG_WARNING("Evident problem with quality flag " << *strItr << " so setting to false!"); - allSelectionResults[itr]->push_back(0); - } - } - } - - // Write decision to SG for access by downstream algs - unsigned int itr(0); - for (std::vector<std::string>::const_iterator strItr = m_qualFlags.begin(); strItr!=m_qualFlags.end(); ++strItr, ++itr) { - std::string sgKey(""); - if (m_sgPrefix=="") { - sgKey = *strItr; - } else { - sgKey = m_sgPrefix+*strItr; - } - if (evtStore()->contains<std::vector<int> >(sgKey)) { - ATH_MSG_ERROR("Tool is attempting to write a StoreGate key " << sgKey << " which already exists. Please use a different key"); - return StatusCode::FAILURE; - } - CHECK(evtStore()->record(allSelectionResults[itr],sgKey)); - } - return StatusCode::SUCCESS; -} - diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/TruthCaloShowerDecorator.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/TruthCaloShowerDecorator.cxx new file mode 100644 index 0000000000000000000000000000000000000000..419f9fbd59d4da511a05e4c2e1f8d53b091bb8e9 --- /dev/null +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/TruthCaloShowerDecorator.cxx @@ -0,0 +1,87 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "DerivationFrameworkEGamma/TruthCaloShowerDecorator.h" +#include "xAODEgamma/ElectronContainer.h" +#include "xAODEgamma/Electron.h" +#include "xAODEgamma/EgammaTruthxAODHelpers.h" +#include "xAODTruth/TruthParticle.h" +#include "xAODTruth/TruthParticleContainer.h" +#include "CaloCalibHitRec/CalibHitToCaloCellTool.h" + +namespace DerivationFramework { + + TruthCaloShowerDecorator::TruthCaloShowerDecorator(const std::string& t,const std::string& n, const IInterface* p) : + AthAlgTool(t,n,p) + { + declareInterface<DerivationFramework::IAugmentationTool>(this); + declareProperty("TruthParticleContainerName", m_truthParticleContainerName ="egammaTruthParticles", "Name of the truth particle container"); + declareProperty("SingleParticleBarcode", m_singleParticleBarcode=10001, "Barcode of single particle"); + declareProperty("CalibHitToCaloCellTool",m_calibhitToCaloCellTool); + //declareProperty("TruthClusterContainerNames", m_truthClusterContainerNames, "Name of input containers for truth clusters"); + } + + StatusCode TruthCaloShowerDecorator::initialize() + { + ATH_MSG_DEBUG("Initializing " << name() << "..."); + + if(m_calibhitToCaloCellTool.retrieve().isFailure()) { + ATH_MSG_FATAL("Failed to retrieve tool " << m_calibhitToCaloCellTool); + return StatusCode::FAILURE; + } + ATH_MSG_INFO("Retrieved tool " << m_calibhitToCaloCellTool); + + return StatusCode::SUCCESS; + } + + StatusCode TruthCaloShowerDecorator::finalize() + { + return StatusCode::SUCCESS; + } + + StatusCode TruthCaloShowerDecorator::addBranches() const + { + const xAOD::TruthParticleContainer* truthPartContainer(0); + CHECK ( evtStore()->retrieve(truthPartContainer, m_truthParticleContainerName) ); + + // create truth clusters + ATH_MSG_DEBUG("Creating truth clusters"); + int singleElectronBarcode = 10001; + if (!m_calibhitToCaloCellTool->processCalibHitsFromParticle(singleElectronBarcode).isSuccess()) { + ATH_MSG_FATAL("Tool " << m_calibhitToCaloCellTool << " failed."); + return StatusCode::FAILURE; + } + + ATH_MSG_DEBUG("Retrieving truth clusters"); + const xAOD::CaloClusterContainer * truthClusterContainerEtot=0; + const xAOD::CaloClusterContainer * truthClusterContainerEvis=0; + const xAOD::CaloClusterContainer * truthClusterContainerEem=0; + + truthClusterContainerEtot = evtStore()->retrieve<const xAOD::CaloClusterContainer>("TruthLArClustersEtot"); + truthClusterContainerEvis = evtStore()->retrieve<const xAOD::CaloClusterContainer>("TruthLArClustersEvis"); + truthClusterContainerEem = evtStore()->retrieve<const xAOD::CaloClusterContainer>("TruthLArClustersEem"); + if (!truthClusterContainerEtot || !truthClusterContainerEvis || !truthClusterContainerEem) { + ATH_MSG_ERROR("Failed to retrieve truth cluster container"); + return StatusCode::FAILURE; + } + + SG::AuxElement::Decorator< ElementLink<xAOD::CaloClusterContainer> > linkDecoratorClusterEtot("truthLArClusterEtotLink"); + SG::AuxElement::Decorator< ElementLink<xAOD::CaloClusterContainer> > linkDecoratorClusterEvis("truthLArClusterEvisLink"); + SG::AuxElement::Decorator< ElementLink<xAOD::CaloClusterContainer> > linkDecoratorClusterEem("truthLArClusterEemLink"); + + ElementLink<xAOD::CaloClusterContainer> truthClusterEtot(*truthClusterContainerEtot,0); + ElementLink<xAOD::CaloClusterContainer> truthClusterEvis(*truthClusterContainerEvis,0); + ElementLink<xAOD::CaloClusterContainer> truthClusterEem(*truthClusterContainerEem,0); + + ATH_MSG_DEBUG("Decorating truth parts with truth cluster energy"); + for (const auto truthPart: *truthPartContainer) { + if (!truthPart) continue; + if (truthPart->barcode() != m_singleParticleBarcode) continue; + linkDecoratorClusterEtot(*truthPart) = truthClusterEtot; + linkDecoratorClusterEvis(*truthPart) = truthClusterEvis; + linkDecoratorClusterEem(*truthPart) = truthClusterEem; + } + return StatusCode::SUCCESS; + } +} diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/components/DerivationFrameworkEGamma_entries.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/components/DerivationFrameworkEGamma_entries.cxx index 3c27b0642e86f2731433410e6ac478eb4965194e..492129dd3ceb4eae0b85e322080338acc4772585 100644 --- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/components/DerivationFrameworkEGamma_entries.cxx +++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkEGamma/src/components/DerivationFrameworkEGamma_entries.cxx @@ -1,18 +1,24 @@ #include "DerivationFrameworkEGamma/PhotonsDirectionTool.h" -#include "DerivationFrameworkEGamma/EGammaPassSelectionWrapper.h" #include "DerivationFrameworkEGamma/EGInvariantMassTool.h" #include "DerivationFrameworkEGamma/EGTransverseMassTool.h" #include "DerivationFrameworkEGamma/EGSelectionToolWrapper.h" +#include "DerivationFrameworkEGamma/EGElectronLikelihoodToolWrapper.h" +#include "DerivationFrameworkEGamma/EGPhotonCleaningWrapper.h" +#include "DerivationFrameworkEGamma/EGCrackVetoCleaningTool.h" #include "DerivationFrameworkEGamma/BkgElectronClassification.h" - +#include "DerivationFrameworkEGamma/TruthCaloShowerDecorator.h" +#include "DerivationFrameworkEGamma/EGElectronAmbiguityTool.h" using namespace DerivationFramework; DECLARE_COMPONENT( PhotonsDirectionTool ) -DECLARE_COMPONENT( EGammaPassSelectionWrapper ) DECLARE_COMPONENT( EGInvariantMassTool ) DECLARE_COMPONENT( EGTransverseMassTool ) DECLARE_COMPONENT( EGSelectionToolWrapper ) +DECLARE_COMPONENT( EGElectronLikelihoodToolWrapper ) +DECLARE_COMPONENT( EGPhotonCleaningWrapper ) +DECLARE_COMPONENT( EGCrackVetoCleaningTool ) DECLARE_COMPONENT( BkgElectronClassification ) +DECLARE_COMPONENT( TruthCaloShowerDecorator ) +DECLARE_COMPONENT( EGElectronAmbiguityTool ) -