diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CMakeLists.txt b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CMakeLists.txt deleted file mode 100644 index 53271a76703bd9ec092aeb677a39396776a50bd4..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CMakeLists.txt +++ /dev/null @@ -1,173 +0,0 @@ -# $Id: CMakeLists.txt 782717 2016-11-07 12:21:17Z krasznaa $ - -# The name of the package: -atlas_subdir( CPAnalysisExamples ) - -# Extra dependencies, based on the build environment: -set( extra_deps ) -set( extra_libs ) -if( XAOD_STANDALONE ) - set( extra_deps Control/xAODRootAccess PhysicsAnalysis/D3PDTools/EventLoop - PRIVATE ) - set( extra_libs xAODRootAccess EventLoop ) -else() - set( extra_deps Control/AthenaBaseComps Control/AthAnalysisBaseComps - PRIVATE PhysicsAnalysis/POOLRootAccess GaudiKernel ) - set( extra_libs AthAnalysisBaseCompsLib ) -endif() - -# The dependencies of the package: -atlas_depends_on_subdirs( - PUBLIC - Control/AthToolSupport/AsgTools - Event/xAOD/xAODMuon - Event/xAOD/xAODJet - Event/xAOD/xAODBTagging - Event/xAOD/xAODCore - Event/xAOD/xAODEgamma - Event/xAOD/xAODMissingET - Event/xAOD/xAODPrimitives - Event/xAOD/xAODTau - Event/xAOD/xAODTracking - Event/xAOD/xAODTruth - Event/xAOD/xAODEventInfo - PhysicsAnalysis/AnalysisCommon/AssociationUtils - PhysicsAnalysis/AnalysisCommon/IsolationSelection - PhysicsAnalysis/AnalysisCommon/PATCore - PhysicsAnalysis/AnalysisCommon/PATInterfaces - PhysicsAnalysis/AnalysisCommon/PileupReweighting - PhysicsAnalysis/Interfaces/AsgAnalysisInterfaces - PhysicsAnalysis/ElectronPhotonID/ElectronEfficiencyCorrection - PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection - PhysicsAnalysis/ElectronPhotonID/IsolationCorrections - PhysicsAnalysis/JetMissingEtID/JetSelectorTools - PhysicsAnalysis/JetTagging/JetTagPerformanceCalibration/xAODBTaggingEfficiency - PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections - PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonMomentumCorrections - PhysicsAnalysis/MuonID/MuonSelectorTools - PhysicsAnalysis/TauID/TauAnalysisTools - Reconstruction/Jet/JetUncertainties - Reconstruction/Jet/JetCalibTools - Reconstruction/Jet/JetInterface - Reconstruction/MET/METInterface - Reconstruction/MET/METUtilities - Trigger/TrigAnalysis/TrigDecisionTool - Trigger/TrigAnalysis/TriggerMatchingTool - ${extra_deps} - Event/xAOD/xAODBase - Event/xAOD/xAODMetaData ) - -# External(s) used by the package: -find_package( ROOT COMPONENTS Core Hist RIO MathCore ) -find_package( Boost ) - -# Libraries in the package: -if( XAOD_STANDALONE ) - atlas_add_root_dictionary( CPAnalysisExamplesLib - CPAnalysisExamplesLibCintSource - ROOT_HEADERS CPAnalysisExamples/xExample.h Root/LinkDef.h - EXTERNAL_PACKAGES ROOT ) -endif() - -atlas_add_library( CPAnalysisExamplesLib - CPAnalysisExamples/*.h Root/*.cxx ${CPAnalysisExamplesLibCintSource} - PUBLIC_HEADERS CPAnalysisExamples - INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} AsgTools - xAODMuon xAODJet xAODBTagging xAODCore xAODEgamma xAODMissingET - xAODPrimitives xAODTau xAODTracking xAODTruth xAODEventInfo - AssociationUtilsLib IsolationSelectionLib PATCoreLib PATInterfaces - PileupReweightingLib ElectronEfficiencyCorrectionLib - ElectronPhotonFourMomentumCorrectionLib IsolationCorrectionsLib - JetSelectorToolsLib xAODBTaggingEfficiencyLib MuonEfficiencyCorrectionsLib - MuonMomentumCorrectionsLib MuonSelectorToolsLib TauAnalysisToolsLib - JetUncertaintiesLib JetCalibToolsLib JetInterface - METInterface METUtilitiesLib TrigDecisionToolLib - TriggerMatchingToolLib ${extra_libs} - PRIVATE_LINK_LIBRARIES xAODBase xAODMetaData ) - -if( NOT XAOD_STANDALONE ) - atlas_add_component( CPAnalysisExamples - src/*.h src/*.cxx src/components/*.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} AthAnalysisBaseCompsLib - ElectronPhotonFourMomentumCorrectionLib xAODEgamma xAODCore xAODBase - AsgTools xAODTracking xAODMuon AthenaBaseComps AsgTools GaudiKernel - AthAnalysisBaseCompsLib CPAnalysisExamplesLib ) -endif() - -atlas_add_dictionary( CPAnalysisExamplesDict - CPAnalysisExamples/CPAnalysisExamplesDict.h - CPAnalysisExamples/selection.xml - LINK_LIBRARIES CPAnalysisExamplesLib ) - -# Executable(s) in the package: -if( XAOD_STANDALONE ) - atlas_add_executable( CPSystematicExample - util/CPSystematicExample.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} xAODRootAccess - xAODEventInfo xAODJet xAODCore PATInterfaces CPAnalysisExamplesLib ) - - atlas_add_executable( CPToolTester - util/CPToolTester.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} xAODRootAccess xAODEventInfo xAODMuon - PATInterfaces CPAnalysisExamplesLib ) - - atlas_add_executable( runExample - util/runExample.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} xAODRootAccess SampleHandler EventLoop - CPAnalysisExamplesLib ) - - atlas_add_executable( run_ut_accessDataAndCpTools - util/run_ut_accessDataAndCpTools.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} xAODRootAccess xAODEventInfo xAODJet - xAODCore xAODEgamma xAODMuon xAODTau CPAnalysisExamplesLib ) - - atlas_add_executable( run_ut_accessDataAndCpTools_v20 - util/run_ut_accessDataAndCpTools_v20.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} xAODRootAccess xAODEventInfo xAODJet - xAODCore xAODEgamma xAODMuon xAODTau CPAnalysisExamplesLib ) -else() - atlas_add_executable( checkxAODTrigger - util/checkxAODTrigger.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} AthAnalysisBaseCompsLib POOLRootAccess - GaudiKernel AsgTools TrigDecisionToolLib ) -endif() - -# Test(s) in the package: -if( XAOD_STANDALONE ) - atlas_add_test( ut_accessData - SOURCES test/ut_accessData.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} xAODRootAccess xAODJet - CPAnalysisExamplesLib ) - - atlas_add_test( ut_accessDataAndCPTools_8TeV - SCRIPT test/ut_accessDataAndCPTools_8TeV.sh ) - atlas_add_test( ut_accessDataAndCPTools_13TeV - SCRIPT test/ut_accessDataAndCPTools_13TeV.sh ) -else() - atlas_add_test( ut_ath_EgammaCalibrationAndSmearingTool_test - SOURCES test/ut_ath_EgammaCalibrationAndSmearingTool_test.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} AthAnalysisBaseCompsLib POOLRootAccess - GaudiKernel AsgTools xAODEgamma xAODCore - ElectronPhotonFourMomentumCorrectionLib ) - - atlas_add_test( ut_ath_checkTrigger_test - SOURCES test/ut_ath_checkTrigger_test.cxx - INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - PROPERTIES TIMEOUT 300 - LINK_LIBRARIES ${ROOT_LIBRARIES} AthAnalysisBaseCompsLib POOLRootAccess - GaudiKernel AsgTools TrigDecisionToolLib ) -endif() - -# Install files from the package: -atlas_install_joboptions( share/*.py ) -atlas_install_data( data/* ) diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/CPAnalysisExamplesDict.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/CPAnalysisExamplesDict.h deleted file mode 100644 index 1cd78547e3f9d185b2721a7050375966b6735391..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/CPAnalysisExamplesDict.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -#ifndef CPANALYSISEXAMPLES_CPANALYSISEXAMPLESDICT_H -#define CPANALYSISEXAMPLES_CPANALYSISEXAMPLESDICT_H - -#include "CPAnalysisExamples/MetadataToolExample.h" - -#endif diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IJetCalibrationTool.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IJetCalibrationTool.h deleted file mode 100644 index 8db7e067d5850c5eb8c542e5b64ca9c0e4532a9b..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IJetCalibrationTool.h +++ /dev/null @@ -1,45 +0,0 @@ -// Dear emacs, this is -*- c++ -*- - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// This is a copy from -// $Id: IMuonSmearingTool.h 299883 2014-03-28 17:34:16Z krasznaa $ - -#ifndef CPANALYSISEXAMPLES_IJETCALIBRATIONTOOL_H -#define CPANALYSISEXAMPLES_IJETCALIBRATIONTOOL_H - -// Framework include(s): -#include "AsgTools/IAsgTool.h" - -// EDM include(s): -#include "xAODJet/Jet.h" - -// Local include(s): -#include "PATInterfaces/CorrectionCode.h" - -namespace CP { - - /// Simple interface for calibrating jets - /// - /// Following the design principles outlined in the TF3 recommendations. - /// - /// - class IJetCalibrationTool : public virtual asg::IAsgTool { - - /// Declare the interface that the class provides - ASG_TOOL_INTERFACE( CP::IJetCalibrationTool ) - - public: - /// Apply the correction on a modifyable object - virtual CorrectionCode applyCorrection( xAOD::Jet& mu ) = 0; - /// Create a corrected copy from a constant jet - virtual CorrectionCode correctedCopy( const xAOD::Jet& input, - xAOD::Jet*& output ) = 0; - - }; // class IJetCalibrationTool - -} // namespace CP - -#endif // CPANALYSISEXAMPLES_IJETCALIBRATIONTOOL_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IMetadataToolExample.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IMetadataToolExample.h deleted file mode 100644 index dbff9e794d5a71feb56a08d130e3b5ceba35ac93..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IMetadataToolExample.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef CPANALYSISEXAMPLES_IMETADATATOOLEXAMPLE_H -#define CPANALYSISEXAMPLES_IMETADATATOOLEXAMPLE_H 1 - -#include "AsgTools/IAsgTool.h" - -namespace CP { - -class IMetadataToolExample : public virtual asg::IAsgTool { - public: - ASG_TOOL_INTERFACE( IMetadataToolExample ) //declares the interface to athena - - //this is just a dummy interface - //technically not necessary - -}; - -} - -#endif //> !CPANALYSISEXAMPLES_IMETADATATOOLEXAMPLE_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IMuonEfficiencyToolExample.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IMuonEfficiencyToolExample.h deleted file mode 100644 index 7267073c464087a72633a3ba37d3ae18455ca355..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IMuonEfficiencyToolExample.h +++ /dev/null @@ -1,54 +0,0 @@ -// Dear emacs, this is -*- c++ -*- - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: IMuonEfficiencyToolExample.h 299754 2014-03-28 15:37:02Z krasznaa $ -#ifndef CPANALYSISEXAMPLES_IMUONEFFICIENCYTOOL_H -#define CPANALYSISEXAMPLES_IMUONEFFICIENCYTOOL_H - -// Framework include(s): -#include "AsgTools/IAsgTool.h" - -// EDM include(s): -#include "xAODMuon/Muon.h" - -// Local include(s): -#include "PATInterfaces/CorrectionCode.h" - -namespace CP { - - /// Simple interface for calculating "a muon efficiency" - /// - /// Meant to try to implement the TF3 recommendations in a realistic - /// test case. - /// - /// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> - /// - /// $Revision: 299754 $ - /// $Date: 2014-03-28 16:37:02 +0100 (Fri, 28 Mar 2014) $ - /// - class IMuonEfficiencyToolExample : public virtual asg::IAsgTool { - - /// Declare the interface that the class provides - ASG_TOOL_INTERFACE( CP::IMuonEfficiencyToolExample ) - - public: - /// Get the "muon efficiency" as a return value - virtual CorrectionCode getEfficiency( const xAOD::Muon& mu, - float& eff ) = 0; - /// Decorate the muon with its efficiency - virtual CorrectionCode applyEfficiency( xAOD::Muon& mu ) = 0; - - /// Get the "muon scale factor" as a return value - virtual CorrectionCode getScaleFactor( const xAOD::Muon& mu, - float& sf ) = 0; - /// Decorate the muon with its scale factor - virtual CorrectionCode applyScaleFactor( xAOD::Muon& mu ) = 0; - - }; // class IMuonEfficiencyToolExample - -} // namespace CP - -#endif // CPANALYSISEXAMPLES_IMUONEFFICIENCYTOOL_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IMuonSelectionToolExample.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IMuonSelectionToolExample.h deleted file mode 100644 index d871e47941d2f1868a8ff3deb02636931ac3c661..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IMuonSelectionToolExample.h +++ /dev/null @@ -1,43 +0,0 @@ -// Dear emacs, this is -*- c++ -*- - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: IMuonSelectionTool.h 299883 2014-03-28 17:34:16Z krasznaa $ -#ifndef CPANALYSISEXAMPLES_IMUONSELECTIONTOOL_H -#define CPANALYSISEXAMPLES_IMUONSELECTIONTOOL_H - -// Framework include(s): -#include "AsgTools/IAsgTool.h" -#include "PATCore/TAccept.h" - -// EDM include(s): -#include "xAODMuon/Muon.h" - -namespace CP { - - /// Interface for (a) muon selector tool(s) - /// - /// This is an example of how to define object selection in - /// a tool. - /// - /// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> - /// - /// $Revision: 299883 $ - /// $Date: 2014-03-28 18:34:16 +0100 (Fri, 28 Mar 2014) $ - /// - class IMuonSelectionToolExample : public virtual asg::IAsgTool { - - /// Declare the interface that the class provides - ASG_TOOL_INTERFACE( CP::IMuonSelectionToolExample ) - - public: - /// Decide whether the muon in question is a "good muon" or not - virtual const Root::TAccept& accept( const xAOD::Muon& mu ) const = 0; - - }; // class IMuonSelectionToolExample - -} // namespace CP - -#endif // CPANALYSISEXAMPLES_IMUONSELECTIONTOOL_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IMuonSmearingToolExample.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IMuonSmearingToolExample.h deleted file mode 100644 index b99ba44f889891f1c38140a67429cbd2af3248b5..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/IMuonSmearingToolExample.h +++ /dev/null @@ -1,47 +0,0 @@ -// Dear emacs, this is -*- c++ -*- - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: IMuonSmearingToolExample.h 299883 2014-03-28 17:34:16Z krasznaa $ -#ifndef CPANALYSISEXAMPLES_IMUONSMEARINGTOOL_H -#define CPANALYSISEXAMPLES_IMUONSMEARINGTOOL_H - -// Framework include(s): -#include "AsgTools/IAsgTool.h" - -// EDM include(s): -#include "xAODMuon/Muon.h" - -// Local include(s): -#include "PATInterfaces/CorrectionCode.h" - -namespace CP { - - /// Simple interface for calibrating/correcting muons - /// - /// Following the design principles outlined in the TF3 recommendations. - /// - /// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> - /// - /// $Revision: 299883 $ - /// $Date: 2014-03-28 18:34:16 +0100 (Fri, 28 Mar 2014) $ - /// - class IMuonSmearingToolExample : public virtual asg::IAsgTool { - - /// Declare the interface that the class provides - ASG_TOOL_INTERFACE( CP::IMuonSmearingToolExample ) - - public: - /// Apply the correction on a modifyable object - virtual CorrectionCode applyCorrection( xAOD::Muon& mu ) = 0; - /// Create a corrected copy from a constant muon - virtual CorrectionCode correctedCopy( const xAOD::Muon& input, - xAOD::Muon*& output ) = 0; - - }; // class IMuonSmearingToolExample - -} // namespace CP - -#endif // CPANALYSISEXAMPLES_IMUONSMEARINGTOOL_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/JetCalibrationToolExample.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/JetCalibrationToolExample.h deleted file mode 100644 index 5223cc609d129ded0f50f20ba7e464498578f968..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/JetCalibrationToolExample.h +++ /dev/null @@ -1,113 +0,0 @@ -// Dear emacs, this is -*- c++ -*- - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: JetCalibrationToolExample3.h 299883 2014-03-28 17:34:16Z krasznaa $ -#ifndef CPANALYSISEXAMPLES_JETCALIBRATIONTOOLEXAMPLE_H -#define CPANALYSISEXAMPLES_JETCALIBRATIONTOOLEXAMPLE_H - -// Rationale: temporary suppression of -// unused-local-typedef warning in Boost header -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-local-typedefs" -#include "boost/tuple/tuple.hpp" -#pragma GCC diagnostic pop - -// Framework include(s): -#include "AsgTools/AsgTool.h" - -// Local include(s): -#include "CPAnalysisExamples/IJetCalibrationTool.h" -#include "PATInterfaces/ISystematicsTool.h" -#include "PATInterfaces/CorrectionTool.h" -#include "xAODJet/JetContainer.h" - -#include <boost/unordered_map.hpp> - -namespace CP { - - /// A simple implementation of the jet calibration tool interface - /// - /// This tries to be a simple, but meaningful example of how correction - /// tools should be implemented for Run 2. - /// - /// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> - /// @author Iacopo Vivarelli <iacopo.vivarelli@cern.ch> - /// - /// $Revision: 299883 $ - /// $Date: 2014-03-28 18:34:16 +0100 (Fri, 28 Mar 2014) $ - /// - class JetCalibrationToolExample : public virtual IJetCalibrationTool, - public virtual ISystematicsTool, - public virtual CP::CorrectionTool< xAOD::JetContainer >, - public asg::AsgTool - { - /// Create a proper constructor for Athena - ASG_TOOL_CLASS2( JetCalibrationToolExample, CP::IJetCalibrationTool, CP::ISystematicsTool ) - - public: - /// Create a constructor for standalone usage - JetCalibrationToolExample( const std::string& name ); - - /// @name Function(s) implementing the asg::IAsgTool interface - /// @{ - - /// Function initialising the tool - virtual StatusCode initialize(); - - /// @} - - /// @name Function(s) implementing the IJetCalibrationTool interface - /// @{ - - /// Apply the correction on a modifyable object - virtual CorrectionCode applyCorrection( xAOD::Jet& object ); - /// Create a corrected copy from a constant jet - virtual CorrectionCode correctedCopy( const xAOD::Jet& input, - xAOD::Jet*& output ); - - /// @} - - /// returns: whether this tool is affected by the given systematis - virtual bool - isAffectedBySystematic( const SystematicVariation& systematic ) const; - - /// returns: the list of all systematics this tool can be affected by - virtual SystematicSet - affectingSystematics() const; - - /// returns: the list of all systematics this tool recommends to use - virtual SystematicSet - recommendedSystematics() const; - - /// effects: configure this tool for the given list of systematic - /// variations. any requested systematics that are not - /// affecting this tool will be silently ignored (unless they - /// cause other errors). - /// failures: systematic unknown - /// failures: requesting multiple variations on the same - /// systematic (e.g. up & down) - /// failures: requesting an unsupported variation on an otherwise - /// supported systematic (e.g. a 2 sigma variation and the tool - /// only supports 1 sigma variations) - /// failures: unsupported combination of supported systematic - /// failures: other tool specific errors - /// - virtual SystematicCode applySystematicVariation - ( const SystematicSet& systConfig ); - - private: - struct Calib - { - float m_calibrationFactor; - }; - boost::unordered_map<SystematicSet, Calib> m_calib; - Calib* m_currentCalib; - - }; // class JetCalibrationToolExample - -} // namespace CP - -#endif // CPANALYSISEXAMPLES_JETCALIBRATIONTOOLEXAMPLE1_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MetadataToolExample.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MetadataToolExample.h deleted file mode 100644 index cf55913fd82655bd16ccf5d976f8981d42160d8a..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MetadataToolExample.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef CPANALYSISEXAMPLES_METADATATOOLEXAMPLE_H -#define CPANALYSISEXAMPLES_METADATATOOLEXAMPLE_H 1 - -/// -///This is an example of a tool that configures -///itself using in-file metadata -///If your tool will behave differently depending on metadata (like AFII vs full sum) -///Then you should write your tool like this -/// - - - -#include "AsgTools/AsgMetadataTool.h" - -#include "CPAnalysisExamples/IMetadataToolExample.h" - -namespace CP { - -class MetadataToolExample: public asg::AsgMetadataTool, public virtual IMetadataToolExample { - public: - //constructor for athena can be created using special macro - //Note: if you add a second interface to your tool, you must use: ASG_TOOL_CLASS2( ToolName, Interface1, Interface2) - ASG_TOOL_CLASS( MetadataToolExample , IMetadataToolExample ) - //add another constructor for non-athena use cases - MetadataToolExample( const std::string& name ); - - /// Initialize is required by AsgTool base class - virtual StatusCode initialize() override; - - /// This method is called at the start of each input file - virtual StatusCode beginInputFile() override; - - /// This method called at end of each input file - virtual StatusCode endInputFile() override; - - /// This method is called at beginning of each event - virtual StatusCode beginEvent() override; - - - virtual void print() const override; - - private: - bool m_isConfigured = false; - bool m_isMC = false; - bool m_isFastSim = false; -}; - -} - -#endif //> !CPANALYSISEXAMPLES_METADATATOOLEXAMPLE_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MuonEfficiencyToolExample.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MuonEfficiencyToolExample.h deleted file mode 100644 index b011b073e8f648c08f73241e650306fc774efe35..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MuonEfficiencyToolExample.h +++ /dev/null @@ -1,72 +0,0 @@ -// Dear emacs, this is -*- c++ -*- - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: MuonEfficiencyToolExample.h 299750 2014-03-28 12:39:15Z krasznaa $ -#ifndef CPANALYSISEXAMPLES_MUONEFFICIENCYTOOL_H -#define CPANALYSISEXAMPLES_MUONEFFICIENCYTOOL_H - -// Framework include(s): -#include "AsgTools/AsgTool.h" - -// Local include(s): -#include "CPAnalysisExamples/IMuonEfficiencyToolExample.h" - -namespace CP { - - /// Implementation for the "muon efficiency" provider tool - /// - /// Meant to try to implement the TF3 recommendations in a realistic - /// test case. - /// - /// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> - /// - /// $Revision: 299750 $ - /// $Date: 2014-03-28 13:39:15 +0100 (Fri, 28 Mar 2014) $ - /// - class MuonEfficiencyToolExample : public virtual IMuonEfficiencyToolExample, - public asg::AsgTool { - - /// Create a proper constructor for Athena - ASG_TOOL_CLASS( MuonEfficiencyToolExample, CP::IMuonEfficiencyToolExample ) - - public: - /// Create a constructor for standalone usage - MuonEfficiencyToolExample( const std::string& name ); - - /// @name Function(s) implementing the asg::IAsgTool interface - /// @{ - - /// Function initialising the tool - virtual StatusCode initialize(); - - /// @} - - /// @name Function(s) implementing the IMuonEfficiencyToolExample interface - /// @{ - - /// Get the "muon efficiency" as a return value - virtual CorrectionCode getEfficiency( const xAOD::Muon& mu, - float& eff ); - /// Decorate the muon with its efficiency - virtual CorrectionCode applyEfficiency( xAOD::Muon& mu ); - - /// Get the "muon scale factor" as a return value - virtual CorrectionCode getScaleFactor( const xAOD::Muon& mu, - float& sf ); - /// Decorate the muon with its scale factor - virtual CorrectionCode applyScaleFactor( xAOD::Muon& mu ); - - /// @} - - private: - /// Some dummy property - double m_dummyProperty; - - }; // class MuonEfficiencyToolExample - -} // namespace CP - -#endif // CPANALYSISEXAMPLES_MUONEFFICIENCYTOOL_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MuonSelectionToolExample.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MuonSelectionToolExample.h deleted file mode 100644 index fc51d98574cd31cc760118af6296cb238b5f14c4..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MuonSelectionToolExample.h +++ /dev/null @@ -1,82 +0,0 @@ -// Dear emacs, this is -*- c++ -*- - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: MuonSelectionTool.h 299883 2014-03-28 17:34:16Z krasznaa $ -#ifndef CPANALYSISEXAMPLES_MUONSELECTIONTOOL_H -#define CPANALYSISEXAMPLES_MUONSELECTIONTOOL_H - -// Framework include(s): -#include "AsgTools/AsgTool.h" -#include "PATCore/IAsgSelectionTool.h" - -// Local include(s): -#include "CPAnalysisExamples/IMuonSelectionToolExample.h" - -namespace CP { - - /// Implementation of the muon selector tool - /// - /// Example implementation of how an object selector tool should - /// look according to the TF3 recommendations. - /// - /// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> - /// - /// $Revision: 299883 $ - /// $Date: 2014-03-28 18:34:16 +0100 (Fri, 28 Mar 2014) $ - /// - class MuonSelectionToolExample : public virtual IAsgSelectionTool, - public virtual IMuonSelectionToolExample, - public asg::AsgTool { - - /// Create a proper constructor for Athena - ASG_TOOL_CLASS2( MuonSelectionToolExample, IAsgSelectionTool, - CP::IMuonSelectionToolExample ) - - public: - /// Constructor for standalone usage - MuonSelectionToolExample( const std::string& name ); - - /// @name Function(s) implementing the asg::IAsgTool interface - /// @{ - - /// Function initialising the tool - virtual StatusCode initialize(); - - /// @} - - /// @name Function(s) implementing the IAsgSelectionTool interface - /// @{ - - /// Get an object describing the "selection steps" of the tool - virtual const Root::TAccept& getTAccept() const; - - /// Get the decision using a generic IParticle pointer - virtual const Root::TAccept& accept( const xAOD::IParticle* p ) const; - - /// @} - - /// @name Function(s) implementing the IMuonSelectorTool interface - /// @{ - - /// Get the decision for a specific Muon object - virtual const Root::TAccept& accept( const xAOD::Muon& mu ) const; - - /// @} - - private: - /// Maximum pseudorapidity for the selected muons - double m_maxEta; - /// Author for the selected e-mails - int m_author; - - /// Object used to store the last decision - mutable Root::TAccept m_accept; - - }; // class MuonSelectionToolExample - -} // namespace CP - -#endif // CPANALYSISEXAMPLES_MUONSELECTIONTOOL_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MuonSmearingToolExample.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MuonSmearingToolExample.h deleted file mode 100644 index 4b8d138d8a8e08192be068f1e7c6cc8f128cefaa..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MuonSmearingToolExample.h +++ /dev/null @@ -1,88 +0,0 @@ -// Dear emacs, this is -*- c++ -*- - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: MuonSmearingToolExample.h 300810 2014-06-06 12:28:18Z krasznaa $ -#ifndef CPANALYSISEXAMPLES_MUONSMEARINGTOOL_H -#define CPANALYSISEXAMPLES_MUONSMEARINGTOOL_H - -// Rationale: temporary suppression of -// unused-local-typedef warning in Boost header -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-local-typedefs" -#include "boost/tuple/tuple.hpp" -#pragma GCC diagnostic pop - -// Framework include(s): -#include "AsgTools/AsgTool.h" -#include "PATInterfaces/SystematicsTool.h" -#include "PATInterfaces/CorrectionTool.h" - -// EDM include(s): -#include "xAODMuon/MuonContainer.h" - -// Local include(s): -#include "CPAnalysisExamples/IMuonSmearingToolExample.h" - -namespace CP { - - class SystematicSet; - - /// A simple implementation of the muon correction tool interface - /// - /// This tries to be a simple, but meaningful example of how correction - /// tools should be implemented for Run 2. - /// - /// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> - /// - /// $Revision: 300810 $ - /// $Date: 2014-06-06 14:28:18 +0200 (Fri, 06 Jun 2014) $ - /// - class MuonSmearingToolExample : public virtual IMuonSmearingToolExample, - public virtual CP::SystematicsTool, - public virtual CP::CorrectionTool< xAOD::MuonContainer >, - public asg::AsgTool { - - /// Create a proper constructor for Athena - ASG_TOOL_CLASS2( MuonSmearingToolExample, CP::ISystematicsTool, - CP::IMuonSmearingToolExample ) - - public: - /// Create a constructor for standalone usage - MuonSmearingToolExample( const std::string& name ); - - /// @name Function(s) implementing the asg::IAsgTool interface - /// @{ - - /// Function initialising the tool - virtual StatusCode initialize(); - - /// @} - - /// @name Functions implementing the CP::IMuonSmearingToolExample interface - /// @{ - - /// Apply the correction on a modifyable object - virtual CorrectionCode applyCorrection( xAOD::Muon& mu ); - - /// Create a corrected copy from a constant muon - virtual CorrectionCode correctedCopy( const xAOD::Muon& input, - xAOD::Muon*& output ) { - return CP::CorrectionTool< xAOD::MuonContainer >:: - correctedCopy( input, output ); - } - - /// @} - - protected: - /// Function receiving the systematic variations that should be applied - virtual SystematicCode sysApplySystematicVariation - ( const SystematicSet & systConfig ); - - }; // class MuonSmearingToolExample - -} // namespace CP - -#endif // CPANALYSISEXAMPLES_MUONSMEARINGTOOL_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MyToolProvider.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MyToolProvider.h deleted file mode 100644 index 9da35f14ef2a1aba7a11da8b430b04decbe20dc2..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/MyToolProvider.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - - -#ifndef CPANALYSISEXAMPLES_MYTOOLPROVIDER -#define CPANALYSISEXAMPLES_MYTOOLPROVIDER - -#include "AsgTools/AsgTool.h" -#include "AsgTools/IAsgTool.h" -#include "AsgTools/AsgMessaging.h" -///////////////////////// -*- C++ -*- ///////////////////////////// - -// Tool interfaces - -#include "AsgTools/ToolHandle.h" - -#include "JetCalibTools/JetCalibrationTool.h" -#include "JetSelectorTools/JetCleaningTool.h" -#include "JetUncertainties/JetUncertaintiesTool.h" -#include "MuonAnalysisInterfaces/MuonCalibrationAndSmearingTool.h" -#include "MuonEfficiencyCorrections/MuonEfficiencyScaleFactors.h" -#include "MuonSelectorTools/MuonSelectionTool.h" -#include "ElectronPhotonFourMomentumCorrection/EgammaCalibrationAndSmearingTool.h" -#include "ElectronEfficiencyCorrection/AsgElectronEfficiencyCorrectionTool.h" -#include "TauAnalysisTools/TauSelectionTool.h" -#include "TauAnalysisTools/TauEfficiencyCorrectionsTool.h" -#include "TauAnalysisTools/TauSmearingTool.h" -#include "xAODBTaggingEfficiency/BTaggingEfficiencyTool.h" -#include "METUtilities/METRebuilder.h" - -// Simple class used to initialize CP tools for usage in more than one ROOT examples - - -class MyToolProvider : public asg::AsgMessaging -{ - public: - - // class methods - - MyToolProvider(const std::string& name); - ~MyToolProvider(); - - StatusCode initialize(bool isData = false, bool isAtlfast = true); - - // Jet tools - - JetCalibrationTool * jetCalibTool; - JetUncertaintiesTool * jetUncertaintiesTool; - JetCleaningTool * jetCleaningTool; - - // muon tools - - CP::MuonCalibrationAndSmearingTool *muonCalibrationAndSmearingTool; - CP::MuonEfficiencyScaleFactors *muonEfficiencySFTool; - CP::MuonSelectionTool *muonSelectionTool; - - // electron tools - - AsgElectronEfficiencyCorrectionTool *elecEfficiencySFTool; - CP::EgammaCalibrationAndSmearingTool *egammaCalibTool; - - // tau tools - - TauAnalysisTools::TauSelectionTool *tauSelTool; - TauAnalysisTools::TauSmearingTool *tauSmearingTool; - TauAnalysisTools::TauEfficiencyCorrectionsTool *tauEffTool; - - // b-tagging tools - - BTaggingEfficiencyTool *btagTool; - - // MET tools - - met::METRebuilder *metRebuilder; - -}; - -#endif // ifndef CPANALYSISEXAMPLES_MYTOOLPROVIDER diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/ToolExamplesAlg.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/ToolExamplesAlg.h deleted file mode 100644 index 899f6fd21418365a701295ad57b43ff5022b3cd1..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/ToolExamplesAlg.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef CPANALYSISEXAMPLES_TOOLEXAMPLESALG_H -#define CPANALYSISEXAMPLES_TOOLEXAMPLESALG_H 1 - -#include "AthAnalysisBaseComps/AthAnalysisAlgorithm.h" - -///General -#include "AsgAnalysisInterfaces/IGoodRunsListSelectionTool.h" -#include "PileupReweighting/PileupReweightingTool.h" -#include "TrigDecisionTool/TrigDecisionTool.h" -#include "TriggerMatchingTool/IMatchingTool.h" -#include "AssociationUtils/IOverlapRemovalTool.h" - -///Electrons -#include "ElectronPhotonFourMomentumCorrection/IEgammaCalibrationAndSmearingTool.h" -#include "IsolationCorrections/IIsolationCorrectionTool.h" -#include "PATCore/IAsgSelectionTool.h" - -#include "IsolationSelection/IIsolationSelectionTool.h" -#include "IsolationSelection/IIsolationCloseByCorrectionTool.h" - -#include "ElectronEfficiencyCorrection/IAsgElectronEfficiencyCorrectionTool.h" - -///Muons -#include "MuonAnalysisInterfaces/IMuonCalibrationAndSmearingTool.h" -#include "MuonAnalysisInterfaces/IMuonSelectionTool.h" - -#include "MuonAnalysisInterfaces/IMuonEfficiencyScaleFactors.h" - - -///Jets -#include "JetCalibTools/IJetCalibrationTool.h" -#include "JetInterface/IJetUpdateJvt.h" -#include "JetInterface/IJetSelector.h" - - - - - - -class ToolExamplesAlg: public ::AthAnalysisAlgorithm { - public: - ToolExamplesAlg( const std::string& name, ISvcLocator* pSvcLocator ); - virtual ~ToolExamplesAlg(); - - virtual StatusCode initialize(); - virtual StatusCode firstExecute(); - virtual StatusCode execute(); - virtual StatusCode finalize(); - - virtual StatusCode beginInputFile(); - - private: - - ///General - ToolHandle<IGoodRunsListSelectionTool> m_grl; - ToolHandle<CP::IPileupReweightingTool> m_prw; - ToolHandle<Trig::TrigDecisionTool> m_tdt; - ToolHandle<Trig::IMatchingTool> m_tmt; - ToolHandle<ORUtils::IOverlapRemovalTool> m_or; - - ///Electrons - ToolHandle<CP::IEgammaCalibrationAndSmearingTool> m_elCalib; - ToolHandle<CP::IIsolationCorrectionTool> m_elIsoCalib; - ToolHandle<IAsgSelectionTool> m_elSelection; - ToolHandle<CP::IIsolationSelectionTool> m_elIsoSelection; - ToolHandle<CP::IIsolationCloseByCorrectionTool> m_elCorrectedIsoSelection; - - ToolHandleArray<IAsgElectronEfficiencyCorrectionTool> m_elSFTools; - - ///Muons - ToolHandle<CP::IMuonCalibrationAndSmearingTool> m_muCalib; - ToolHandle<CP::IMuonSelectionTool> m_muSelectionTool; - ToolHandle<CP::IIsolationSelectionTool> m_muIsoSelection; - - ToolHandleArray<CP::IMuonEfficiencyScaleFactors> m_muSFTools; - - ///Jets - ToolHandle<IJetCalibrationTool> m_jetCalib; - ToolHandle<IJetSelector> m_jetCleaning; - - -}; - -#endif //> !CPANALYSISEXAMPLES_TOOLEXAMPLESALG_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/errorcheck.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/errorcheck.h deleted file mode 100644 index 10c149fb55bf0c2ece18203e632747841a85628f..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/errorcheck.h +++ /dev/null @@ -1,21 +0,0 @@ -// Dear emacs, this is -*- c++ -*- - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: errorcheck.h 299732 2014-03-27 17:41:34Z krasznaa $ -#ifndef CPANALYSISEXAMPLES_ERRORCHECK_H -#define CPANALYSISEXAMPLES_ERRORCHECK_H - -#define CHECK( ARG ) \ - do { \ - const bool result = ARG; \ - if( ! result ) { \ - ::Error( APP_NAME, "Failed to execute: \"%s\"", \ - #ARG ); \ - return 1; \ - } \ - } while( false ) - -#endif // CPANALYSISEXAMPLES_ERRORCHECK_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/selection.xml b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/selection.xml deleted file mode 100644 index 45d47495cf70522dc5128663234595a4e4758d58..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/selection.xml +++ /dev/null @@ -1,5 +0,0 @@ - -<lcgdict> - <class name="MetadataToolExample" /> - <class name="IMetadataToolExample" /> -</lcgdict> diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/xAthExample.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/xAthExample.h deleted file mode 100644 index 0455ffcde59869a7a367bc472ce499117e7d868c..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/xAthExample.h +++ /dev/null @@ -1,55 +0,0 @@ -///////////////////////// -*- C++ -*- ///////////////////////////// - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// xAthExample.h: -// xExample is a package to test the xAOD and CP tools by histogramming -// variables for each type of object. Some plots are specific to ttbar. -// Author: Will Buttinger - conversion of code from Frank Paige <paige@bnl.gov> -// Thanks: David Adams, Joe Taenzer, Iacopo Vivarelli -/////////////////////////////////////////////////////////////////// - -#ifndef XEXAMPLE_XATHEXAMPLE_H -#define XEXAMPLE_XATHEXAMPLE_H - - -#ifndef ROOTCORE - -#include "AthenaBaseComps/AthAlgorithm.h" - -// Root includes -#include <TH1.h> -#include <TH2.h> - - -class xAthExample : public AthAlgorithm -{ -public: - - std::map<std::string,TH1*> m_TH1; - std::map<std::string,TH2*> m_TH2; - std::string ptStr[17]; - float ptLim[17]; - - int m_eventCounter; - int m_warnCounter; - int m_warnLimit; - - long m_startTime; - - // this is a standard constructor - xAthExample(const std::string& name, ISvcLocator* pSvcLocator); - - // these are the functions inherited from Algorithm - virtual StatusCode initialize (); - virtual StatusCode execute (); - virtual StatusCode finalize (); - -}; - -#endif //ROOTCORE - -#endif //XEXAMPLE_XATHEXAMPLE_H - diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/xExample.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/xExample.h deleted file mode 100644 index 5b6c8c70fb4a468c08dc5bed03c302d9e68cf4b9..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/xExample.h +++ /dev/null @@ -1,88 +0,0 @@ -///////////////////////// -*- C++ -*- ///////////////////////////// - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// xExample.h: -// xExample is a package to test the xAOD and CP tools by histogramming -// variables for each type of object. Some plots are specific to ttbar. -// Author: Frank Paige <paige@bnl.gov> -// Thanks: David Adams, Joe Taenzer, Iacopo Vivarelli -/////////////////////////////////////////////////////////////////// - -#ifndef XEXAMPLE_XEXAMPLE_H -#define XEXAMPLE_XEXAMPLE_H - - -#ifdef ROOTCORE -#include <EventLoop/Algorithm.h> - -// Infrastructure include(s): -#include "xAODRootAccess/Init.h" -#include "xAODRootAccess/TEvent.h" - -// Root includes -#include <TH1.h> -#include <TH2.h> -#endif // ROOTCORE - -// STL includes -#include <string> -#include <vector> -#include <map> -#include <fstream> - - -class xExample : public EL::Algorithm -{ - // put your configuration variables here as public variables. - // that way they can be set directly from CINT and python. -public: - // float cutValue; - - - - // variables that don't get filled at submission time should be - // protected from being send from the submission node to the worker - // node (done by the //!) -public: - // Tree *myTree; //! - // TH1 *myHist; //! - - xAOD::TEvent *m_event; //! - - // Variables should be protected from CINT using //! - // Using map(string,TH*) simplifies booking multiple histograms - - std::map<std::string,TH1*> m_TH1; //! - std::map<std::string,TH2*> m_TH2; //! - std::string ptStr[17]; //! - float ptLim[17]; //! - - int m_eventCounter; //! - int m_warnCounter; //! - int m_warnLimit; //! - - long m_startTime; //! - - // this is a standard constructor - xExample (); - - // these are the functions inherited from Algorithm - virtual EL::StatusCode setupJob (EL::Job& job); - virtual EL::StatusCode fileExecute (); - virtual EL::StatusCode histInitialize (); - virtual EL::StatusCode changeInput (bool firstFile); - virtual EL::StatusCode initialize (); - virtual EL::StatusCode execute (); - virtual EL::StatusCode postExecute (); - virtual EL::StatusCode finalize (); - virtual EL::StatusCode histFinalize (); - - // this is needed to distribute the algorithm to the workers - ClassDef(xExample, 1); -}; - -#endif //XEXAMPLE_XEXAMPLE_H - diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/xExampleEDM.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/xExampleEDM.h deleted file mode 100644 index 723b65e0190773f29b430845cd204c115eaaa236..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/xExampleEDM.h +++ /dev/null @@ -1,140 +0,0 @@ -///////////////////////// -*- C++ -*- ///////////////////////////// - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// xExampleEDM.h: -// This file has EDM includes, EDM collections and CP tools for xExample. -// Keep all this in a separate header file to avoid CINT conflicts: -// https://twiki.cern.ch/twiki/bin/view/AtlasComputing/SoftwareTutorialxAODAnalysisInROOT -// Author: Frank Paige <paige@bnl.gov> -/////////////////////////////////////////////////////////////////// - -#ifndef XEXAMPLE_XEXAMPLEEDM_H -#define XEXAMPLE_XEXAMPLEEDM_H - -// Rationale: temporary suppression of -// unused-local-typedef warning in Boost header -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-local-typedefs" -#include "boost/tuple/tuple.hpp" -#pragma GCC diagnostic pop - -// EDM includes: -#include "xAODEventInfo/EventInfo.h" -#include "xAODMuon/MuonContainer.h" -#include "xAODMuon/MuonAuxContainer.h" -#include "xAODTruth/TruthParticleContainer.h" -#include "xAODTruth/TruthVertexContainer.h" -#include "xAODPrimitives/IsolationType.h" -#include "xAODJet/JetContainer.h" -#include "xAODJet/JetAuxContainer.h" -#include "xAODJet/JetAttributes.h" -#include "xAODJet/JetTypes.h" -#include "xAODBTagging/BTagging.h" -#include "xAODEgamma/ElectronContainer.h" -#include "xAODEgamma/ElectronAuxContainer.h" -#include "xAODMissingET/MissingETContainer.h" -#include "xAODMissingET/MissingETAuxContainer.h" -#include "xAODTracking/TrackParticleContainer.h" -#include "xAODTracking/VertexContainer.h" -#include "xAODTracking/TrackingPrimitives.h" -#include "xAODTau/TauJetContainer.h" -#include "xAODTau/TauJetAuxContainer.h" - -#include "xAODCore/ShallowCopy.h" - -// CP tool includes -#ifdef ROOTCORE - -#include "JetCalibTools/JetCalibrationTool.h" -#include "JetSelectorTools/JetCleaningTool.h" -#include "METUtilities/METRebuilder.h" - -#else -//in athena, we include the interfaces, NOT the concrete classes -#include "JetCalibTools/IJetCalibrationTool.h" //interface for JetCalibrationTool -#include "JetInterface/IJetSelector.h" // JetCleaningTool -#include "METInterface/IMETRebuilder.h" //METRebuilder - -#endif - -#ifdef ROOTCORE -# include "xAODRootAccess/Init.h" -# include "xAODRootAccess/TEvent.h" -#endif // ROOTCORE - - -// EDM containers -const xAOD::MuonContainer* m_muons; -const xAOD::ElectronContainer* m_electrons; -const xAOD::TauJetContainer* m_tauJets; -const xAOD::JetContainer* m_akt4Jets; -const xAOD::JetContainer* m_akt4TruthJets; -const xAOD::JetContainer* m_aktem4Jets; -const xAOD::MissingETContainer* m_metFinals; -const xAOD::MissingETContainer* m_metTruths; - -// xAOD supports deep (complete) and shallow copies. -// Choose deep copies for selected e/mu/tau. Current selection just uses -// "tight" flags; eventually might apply CP tools. -// Create container and aux container in initialize() and link them. -// Clear container at end of execute(). - -xAOD::MuonContainer* m_newMuons; -xAOD::MuonAuxContainer* m_newMuonsAux; - -xAOD::ElectronContainer* m_newElectrons; -xAOD::ElectronAuxContainer* m_newElectronsAux; - -xAOD::TauJetContainer* m_newTauJets; -xAOD::TauJetAuxContainer* m_newTauJetsAux; - -// Shallow-copy containers for AntiKt4LCTopo selected, recalibrated jets. -// Jet container made in initialize() as view container. Holds selected -// jets but does not own them. -// Pair holds two containers made by shallowCopyContainer as shallow copies -// of all original jets. Must be deleted for each event. -xAOD::JetContainer* m_akt4ViewJets; -std::pair< xAOD::JetContainer*, xAOD::ShallowAuxContainer* > m_akt4CopyJets; - -// Deep-copy containers for AntiKt4LCTopo jets. -// These are initialized and connected in initialize() -xAOD::JetContainer* m_aktem4NewJets; -xAOD::JetAuxContainer* m_aktem4NewJetsAux; - -// Bad jet flag -float m_badJetPtMax; - -// Containers for rebuilt MET -// These get initialized by METRebuilder -const xAOD::MissingETContainer* m_metCalibs; -const xAOD::MissingETAuxContainer* m_metCalibsAux; -// Needed for METRebuilder constituent map -SG::AuxElement::Accessor< ElementLink<xAOD::IParticleContainer> > m_objLinkAcc("originalObjectLink"); - -#ifdef ROOTCORE - -// Transient object store. Needed for the CP tools. - -xAOD::TStore* m_store; - -// Pointers to CP tools set up in initialize() -JetCleaningTool* m_jetCleaningTool; -JetCalibrationTool* m_akt4LCTopoCalibrationTool; -JetCalibrationTool* m_akt4EMTopoCalibrationTool; -met::METRebuilder* m_metRebuilder; - -#else -#include "GaudiKernel/ToolHandle.h" - -//ToolHandles to CP tools, set up in job options -ToolHandle<IJetSelector> m_jetCleaningTool; -ToolHandle<IJetCalibrationTool> m_akt4LCTopoCalibrationTool; -ToolHandle<IJetCalibrationTool> m_akt4EMTopoCalibrationTool; -ToolHandle<IMETRebuilder> m_metRebuilder; - -#endif - -#endif //XEXAMPLE_XEXAMPLEEDM_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/xExampleUtils.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/xExampleUtils.h deleted file mode 100644 index 015754a0af3a84359fa47bbacd1818ea4b908cab..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/CPAnalysisExamples/xExampleUtils.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef XEXAMPLE_XEXAMPLEUTIL_H -#define XEXAMPLE_XEXAMPLEUTIL_H - -// TruthParticle utilities for xExample -// Use forward references for xAOD classes - -#include <vector> - -namespace xAOD{ - class TruthParticle_v1; - typedef TruthParticle_v1 TruthParticle; - class TruthVertex_v1; - typedef TruthVertex_v1 TruthVertex; -} - -// Long-lived B hadron (5x1,5xx2) -bool isBHadron(const xAOD::TruthParticle* p); - -// Implement HepMC isGenStable -bool isGenStable(const xAOD::TruthParticle* p); - -// Emulate HepMC descendant iterator -// Multiple particles can give same descendant (string/cluster) -// Remove Geant descendants -int getDescendants(const xAOD::TruthParticle* p, - std::vector< const xAOD::TruthParticle* >& dscd ); - - -#endif //XEXAMPLE_XEXAMPLEUTIL_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/README b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/README deleted file mode 100644 index 7a164ffde9fae8ce5396adda2bf0614846244620..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/README +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************** - -This package provides a number of Athena and ROOT based analysis examples, plus some example tools to show how a dual-use combined performance tool should be implemented. - -In util, several pieces of ROOT stearing codes can be found. - -- util/CPSystematicExample.cxx shows how to loop on systematic uncertainties in the systematic registry and output one single TFile with one TTree per systematic uncertainty - -- util/CPTooltester.cxx shows a simple example of muon selection with the invokation of a muon performance tools - -- runExample.cxx shows a more complete analysis example. It makes use of the xExample and xExampleUtils classes also part of this package. - -In Root one can find three examples of muon CP dual-use tools, and one example of a jet calibration tool implementing also systematic uncertainties. Note: all tools are meant to be examples only, and they should NOT be used in a real analysis. - -In src one find a simple example of an Athena algorithm making use of some of the example tools. The corresponding jobOptions can be found in share. - -Other files in the Root and test directory are used for nightly validation of the analysis release - -Finally, the scripts and python directories host simple CINT and pyROOT macros that show how to easily browse xAOD files. - -**********************************************/ diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/JetCalibrationToolExample.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/JetCalibrationToolExample.cxx deleted file mode 100644 index 3cb580e4327fa82461eaf7cc7ec30de24ff5a17a..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/JetCalibrationToolExample.cxx +++ /dev/null @@ -1,175 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// ROOT include(s): -#include <TRandom.h> - -// EDM include(s): -#include "xAODEventInfo/EventInfo.h" - -// Local include(s): - -#include "CPAnalysisExamples/JetCalibrationToolExample.h" - -#include "PATInterfaces/CorrectionTool.h" -#include "PATInterfaces/SystematicCode.h" -#include "PATInterfaces/SystematicRegistry.h" -#include "PATInterfaces/SystematicVariation.h" - -namespace CP { - - JetCalibrationToolExample::JetCalibrationToolExample( const std::string& name ) - : asg::AsgTool( name ), - m_currentCalib (0){ - - } - - StatusCode JetCalibrationToolExample::initialize() { - - // Greet the user: - ATH_MSG_INFO( "Initialising..." ); - - // set up for default running without systematics - applySystematicVariation (SystematicSet ()).ignore(); - - // Add the affecting systematics to the global registry - SystematicRegistry& registry = SystematicRegistry::getInstance(); - if (registry.registerSystematics(*this) != SystematicCode::Ok) - return StatusCode::FAILURE; - - // Return gracefully: - return StatusCode::SUCCESS; - } - - CorrectionCode JetCalibrationToolExample::applyCorrection( xAOD::Jet& jet ) { - - // Retrieve the event information: - const xAOD::EventInfo* ei = 0; - if( evtStore()->retrieve( ei, "EventInfo" ).isFailure() ) { - ATH_MSG_WARNING( "No EventInfo object could be retrieved" ); - ATH_MSG_WARNING( "Random number generation not configured correctly" ); - } - - if (!ei) { - ATH_MSG_ERROR( "Cannot retrieve the EventInfo" ); - return CorrectionCode::Error; - } - - // In real life, the jet correction factors will depend on pileup related - // quantities, on jet moments and jet kinematics. The correction factors - // will be possibly retrieved from some root file to be decided at - // configuration stage. Due to the lack of real jet tools at the time of - // code writing, we just mock an example. Here simply assuming a linear - // correction with mu, just to illustrate the mechanics. - // WARNING! This is NOT a jet/EtMiss recommendation! - - // Access mu - - const float mu = ei->averageInteractionsPerCrossing(); - - // compute a simple correction factor depending on mu. Subtract 200 MeV per unit mu - - float correctionOffset = 200*mu; - - // Redefine the jet 4vector by scaling both pt and mass - - float newJetPt = jet.pt() - correctionOffset; - if (newJetPt < 5000) newJetPt = 5000; - - xAOD::JetFourMom_t newp4(m_currentCalib->m_calibrationFactor*(newJetPt), - jet.eta(), jet.phi(), - m_currentCalib->m_calibrationFactor*jet.m()); - - // Set the jet 4vector: - jet.setJetP4( newp4); - - ATH_MSG_DEBUG("correction applied"); - - // Return gracefully: - return CorrectionCode::Ok; - } - - CorrectionCode JetCalibrationToolExample::correctedCopy( const xAOD::Jet& input, - xAOD::Jet*& output ) { - - // A sanity check: - if( output ) { - ATH_MSG_WARNING( "Non-null pointer received. " - "There's a possible memory leak!" ); - } - - ATH_MSG_DEBUG("making the copy"); - - return CP::CorrectionTool< xAOD::JetContainer >:: correctedCopy( input,output ); - } - - bool JetCalibrationToolExample:: - isAffectedBySystematic( const SystematicVariation& systematic ) const - { - SystematicSet sys = affectingSystematics(); - return sys.find (systematic) != sys.end (); - } - - SystematicSet JetCalibrationToolExample:: - affectingSystematics() const - { - SystematicSet result; - // the first systematic is a continuous one - result.insert (SystematicVariation ("JETNP1", SystematicVariation::CONTINUOUS)); - // for the second systematic we only support two points: - result.insert (SystematicVariation ("JETNP2", 1)); - result.insert (SystematicVariation ("JETNP2", -1)); - return result; - } - - SystematicSet JetCalibrationToolExample :: - recommendedSystematics() const - { - /// rationale: In the simple case that we recommend that all our - /// affecting systematics be used we can do this. if we - /// recommend to use only a subset, we have to create that - /// separately. - return affectingSystematics(); - } - - SystematicCode JetCalibrationToolExample :: - applySystematicVariation ( const SystematicSet& systConfig ) { - - // first check if we already know this systematic configuration - boost::unordered_map<SystematicSet,Calib>::iterator calibIter - = m_calib.find (systConfig); - if (calibIter != m_calib.end()) - { - m_currentCalib = &calibIter->second; - return SystematicCode::Ok; - } - - // this is a systematic configuration that we haven't seen yet, - // let's create a configuration for it. - - Calib calib; - calib.m_calibrationFactor = 1; - - // the first systematic is a simple continuous systematic, where 1 - // sigma corresponds to a 5% effect on the calibration factor - calib.m_calibrationFactor *= 1 + 0.05 * systConfig.getParameterByBaseName ("JETNP1"); - - // for the second parameter we know that it is a +3% variation at - // +1 sigma and a -7% variation at -1 sigma. anything else is an - // unsupported systematic - SystematicVariation syst = systConfig.getSystematicByBaseName ("JETNP2"); - if (syst == SystematicVariation ("JETNP2", 1)) - calib.m_calibrationFactor *= 1.03; - else if (syst == SystematicVariation ("JETNP2", -1)) - calib.m_calibrationFactor *= 0.93; - else if (!syst.empty()) - return SystematicCode::Unsupported; - - // store this calibration for future use, and make it current - m_currentCalib - = &m_calib.insert (std::make_pair (systConfig, calib)).first->second; - return SystematicCode::Ok; - } - -} // namespace CP diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/LinkDef.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/LinkDef.h deleted file mode 100644 index 1bd7da734493ab60050790421871c7eab7c7953a..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/LinkDef.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include <CPAnalysisExamples/xExample.h> - -#ifdef __CINT__ - -#pragma link off all globals; -#pragma link off all classes; -#pragma link off all functions; -#pragma link C++ nestedclass; - -#endif - -#ifdef __CINT__ -#pragma link C++ class xExample+; -#endif diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MetadataToolExample.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MetadataToolExample.cxx deleted file mode 100644 index b404079f2f18a5069ed3e8da3e332c5cc7df28b4..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MetadataToolExample.cxx +++ /dev/null @@ -1,115 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// CPAnalysisExamples includes -#include "CPAnalysisExamples/MetadataToolExample.h" - -#include "xAODEventInfo/EventInfo.h" - -#include "xAODMetaData/FileMetaData.h" - -#ifndef ROOTCORE -#include "AthAnalysisBaseComps/AthAnalysisHelper.h" -#endif - -#include <boost/algorithm/string.hpp> - -namespace CP { - - -MetadataToolExample::MetadataToolExample( const std::string& name ) : asg::AsgMetadataTool( name ){ - - //cannot determine fast/fullsim in EventLoop yet, so declare it as a property - //the user will need to set this - //In athena, this will be determined from the input file automatically - declareProperty("FastSim", m_isFastSim = false, "This will be set automatically for you if using athena"); - - -} - - -StatusCode MetadataToolExample::initialize() { - ATH_MSG_INFO ("Initializing " << name() << "..."); - - //Don't do anything in the initialize step - //just flag that we still need configuring - m_isConfigured = false; - - return StatusCode::SUCCESS; -} - -StatusCode MetadataToolExample::beginInputFile() { - //when this method fires, you cannot yet use the information from evtStore - //instead you must use information from inputMetaStore() - - //currently only athena (POOL) can provide useful metadata - //xAOD-format metdata will be coming soon -#ifndef ROOTCORE - //Determine MC/Data - std::string dataType(""); - CHECK( AthAnalysisHelper::retrieveMetadata( "/TagInfo", "project_name" , dataType, inputMetaStore() ) ); - m_isMC = (dataType == "IS_SIMULATION"); - - //Determine Fast/FullSim - if(m_isMC) { - std::string simType(""); - CHECK( AthAnalysisHelper::retrieveMetadata( "/Simulation/Parameters", "SimulationFlavour" , simType, inputMetaStore() ) ); - boost::to_upper(simType); - m_isFastSim = (simType.find("ATLFASTII")!=std::string::npos); - } - - m_isConfigured=true; -#endif - - //here's how things will work dual use, when file metadata is available in files - if(!m_isConfigured && inputMetaStore()->contains<xAOD::FileMetaData>("FileMetaData")) { - const xAOD::FileMetaData* fmd = 0; - ATH_CHECK( inputMetaStore()->retrieve( fmd, "FileMetaData" ) ); - - std::string simType(""); - bool result = fmd->value( xAOD::FileMetaData::simFlavour , simType ); - if(!result) { //no simFlavour metadata, so must be Data - m_isMC = false; - } else { - m_isMC = true; - boost::to_upper(simType); - m_isFastSim = (simType.find("ATLFASTII")!=std::string::npos); - } - } - - return StatusCode::SUCCESS; -} - -StatusCode MetadataToolExample::endInputFile() { - m_isConfigured = false; - return StatusCode::SUCCESS; -} - -StatusCode MetadataToolExample::beginEvent() { - if(m_isConfigured) return StatusCode::SUCCESS; - - //determine MC/Data from evtInfo ... this will work for both athena and eventloop - const xAOD::EventInfo* evtInfo = 0; - ATH_CHECK( evtStore()->retrieve( evtInfo, "EventInfo" ) ); - m_isMC = evtInfo->eventType(xAOD::EventInfo::IS_SIMULATION); - - m_isConfigured=true; - - return StatusCode::SUCCESS; -} - - -void MetadataToolExample::print() const { - - if(!m_isConfigured) { //check if we still need to configure - const_cast<MetadataToolExample*>(this)->beginInputFile().ignore(); - const_cast<MetadataToolExample*>(this)->beginEvent().ignore(); - } - - ATH_MSG_INFO("IsMC = " << m_isMC << " isFastSim = " << m_isFastSim); - -} - - -} diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MuonEfficiencyToolExample.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MuonEfficiencyToolExample.cxx deleted file mode 100644 index e7b200ac7af83dd3bdc9a94f158dc76eac83590a..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MuonEfficiencyToolExample.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: MuonEfficiencyToolExample.cxx 299754 2014-03-28 15:37:02Z krasznaa $ - -// Local include(s): -#include "CPAnalysisExamples/MuonEfficiencyToolExample.h" - -namespace CP { - - MuonEfficiencyToolExample::MuonEfficiencyToolExample( const std::string& name ) - : asg::AsgTool( name ) { - - declareProperty( "DummyProperty", m_dummyProperty = 10 ); - } - - StatusCode MuonEfficiencyToolExample::initialize() { - - // Greet the user: - ATH_MSG_INFO( "Initialising... " ); - ATH_MSG_DEBUG( "Dummy property = " << m_dummyProperty ); - - // Return gracefully: - return StatusCode::SUCCESS; - } - - CorrectionCode MuonEfficiencyToolExample::getEfficiency( const xAOD::Muon& mu, - float& eff ) { - - // Check if we have an efficiency for this muon: - if( std::abs( mu.eta() ) > 2.4 ) { - return CorrectionCode::OutOfValidityRange; - } - - // If yes, then: - eff = 0.9; - return CorrectionCode::Ok; - } - - CorrectionCode MuonEfficiencyToolExample::applyEfficiency( xAOD::Muon& mu ) { - - // Get the efficiency: - float eff = 0.0; - if( getEfficiency( mu, eff ) == CorrectionCode::Error ) { - return CorrectionCode::Error; - } - - // Decorate the muon: - mu.auxdata< float >( "MuonEfficiency" ) = eff; - return CorrectionCode::Ok; - } - - CorrectionCode MuonEfficiencyToolExample::getScaleFactor( const xAOD::Muon& mu, - float& sf ) { - - // Check if we have a scale factor for this muon: - if( std::abs( mu.eta() ) > 2.4 ) { - return CorrectionCode::OutOfValidityRange; - } - - // If yes, then: - sf = 1.05; - return CorrectionCode::Ok; - } - - CorrectionCode MuonEfficiencyToolExample::applyScaleFactor( xAOD::Muon& mu ) { - - // Get the efficiency: - float sf = 0.0; - if( getScaleFactor( mu, sf ) == CorrectionCode::Error ) { - return CorrectionCode::Error; - } - - // Decorate the muon: - mu.auxdata< float >( "MuonScaleFactor" ) = sf; - return CorrectionCode::Ok; - } - -} // namespace CP diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MuonSelectionToolExample.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MuonSelectionToolExample.cxx deleted file mode 100644 index 10f5222dbf4564a963ca7d0aebd4121219840296..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MuonSelectionToolExample.cxx +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: MuonSelectionTool.cxx 299883 2014-03-28 17:34:16Z krasznaa $ - -// Local include(s): -#include "CPAnalysisExamples/MuonSelectionToolExample.h" - -namespace CP { - - MuonSelectionToolExample::MuonSelectionToolExample( const std::string& name ) - : asg::AsgTool( name ), - m_accept( "MuonSelection" ) { - - declareProperty( "MaxEta", m_maxEta = 2.5 ); - declareProperty( "Author", m_author = xAOD::Muon::MuidCo ); - } - - StatusCode MuonSelectionToolExample::initialize() { - - // Greet the user: - ATH_MSG_INFO( "Initialising..." ); - ATH_MSG_DEBUG( "Maximum eta: " << m_maxEta ); - ATH_MSG_DEBUG( "Selected author: " << m_author ); - - // Set up the TAccept object: - m_accept.addCut( "Eta", - "Selection of muons according to their pseudorapidity" ); - m_accept.addCut( "Author", - "Selection of muons according to their author" ); - - // Return gracefully: - return StatusCode::SUCCESS; - } - - const Root::TAccept& MuonSelectionToolExample::getTAccept() const { - - return m_accept; - } - - const Root::TAccept& - MuonSelectionToolExample::accept( const xAOD::IParticle* p ) const { - - // Reset the result: - m_accept.clear(); - - // Check if this is a muon: - if( p->type() != xAOD::Type::Muon ) { - ATH_MSG_ERROR( "accept(...) Function received a non-muon" ); - return m_accept; - } - - // Cast it to a muon: - const xAOD::Muon* mu = dynamic_cast< const xAOD::Muon* >( p ); - if( ! mu ) { - ATH_MSG_FATAL( "accept(...) Failed to cast particle to muon" ); - return m_accept; - } - - // Let the specific function do the work: - return accept( *mu ); - } - - const Root::TAccept& MuonSelectionToolExample::accept( const xAOD::Muon& mu ) const { - - // Reset the result: - m_accept.clear(); - - // Do the eta cut: - ATH_MSG_VERBOSE( "Muon eta: " << mu.eta() ); - if( std::abs( mu.eta() ) > m_maxEta ) { - return m_accept; - } - m_accept.setCutResult( "Eta", true ); - - // Do the author cut: - ATH_MSG_VERBOSE( "Muon author: " << mu.author() ); - if( mu.author() != m_author ) { - return m_accept; - } - m_accept.setCutResult( "Author", true ); - - // Return the result: - return m_accept; - } - -} // namespace CP diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MuonSmearingToolExample.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MuonSmearingToolExample.cxx deleted file mode 100644 index 88306e6001289d262c16ec67f73cc64e8959f2f9..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MuonSmearingToolExample.cxx +++ /dev/null @@ -1,118 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: MuonSmearingToolExample.cxx 300810 2014-06-06 12:28:18Z krasznaa $ - -// ROOT include(s): -#include <TRandom.h> - -// EDM include(s): -#include "xAODEventInfo/EventInfo.h" - -// Local include(s): -#include "CPAnalysisExamples/MuonSmearingToolExample.h" - -#include "PATInterfaces/SystematicSet.h" -#include "PATInterfaces/SystematicRegistry.h" - -namespace CP { - - MuonSmearingToolExample::MuonSmearingToolExample( const std::string& name ) - : asg::AsgTool( name ) { - - // Teach the base class what systematic variations are supported - // by this tool: - m_affectingSystematics = { - SystematicVariation( "mu_id", 1 ), - SystematicVariation( "mu_id", -1 ), - SystematicVariation( "mu_ms", 1 ), - SystematicVariation( "mu_ms", -1 ), - SystematicVariation( "mu_cb", 1 ), - SystematicVariation( "mu_cb", -1 ) - }; - // Set all systematics as recommended - m_recommendedSystematics = m_affectingSystematics; - - } - - StatusCode MuonSmearingToolExample::initialize() { - - // Greet the user: - ATH_MSG_INFO( "Initialising..." ); - - // Register systematics with the registry - SystematicRegistry& registry = SystematicRegistry::getInstance(); - if( registry.registerSystematics(*this) != SystematicCode::Ok ) - return StatusCode::FAILURE; - - // Set default for running without systematics - applySystematicVariation( SystematicSet() ).ignore(); - - // Return gracefully: - return StatusCode::SUCCESS; - } - - CorrectionCode MuonSmearingToolExample::applyCorrection( xAOD::Muon& mu ) { - - // Retrieve the event information: - const xAOD::EventInfo* ei = 0; - if( evtStore()->retrieve( ei, "EventInfo" ).isFailure() ) { - ATH_MSG_WARNING( "No EventInfo object could be retrieved" ); - ATH_MSG_WARNING( "Random number generation not configured correctly" ); - } - - // Get the run and event numbers: - const uint32_t runNumber = ei ? ei->runNumber() : 0; - const unsigned long long eventNumber = ei ? ei->eventNumber() : 0; - - // Construct a seed for the random number generator: - const UInt_t seed = 1000 * runNumber + eventNumber; - gRandom->SetSeed( seed ); - - // Decide about the parameters of the Gaus function based on the currently - // active systematics settings: - ::Double_t mean = 1.0; - ::Double_t sigma = 0.1; - if( appliedSystematics().find( SystematicVariation( "mu_id", 1 ) ) != - appliedSystematics().end() ) { - mean = 1.1; - } else if( appliedSystematics().find( SystematicVariation( "mu_id", -1 ) ) != - appliedSystematics().end() ) { - mean = 0.9; - } else if( appliedSystematics().find( SystematicVariation( "mu_ms", 1 ) ) != - appliedSystematics().end() ) { - sigma = 0.2; - } else if( appliedSystematics().find( SystematicVariation( "mu_ms", -1 ) ) != - appliedSystematics().end() ) { - sigma = 0.05; - } else if( appliedSystematics().find( SystematicVariation( "mu_cb", 1 ) ) != - appliedSystematics().end() ) { - mean = 1.1; - sigma = 0.2; - } else if( appliedSystematics().find( SystematicVariation( "mu_cb", -1 ) ) != - appliedSystematics().end() ) { - mean = 0.9; - sigma = 0.05; - } - - // Smear the pT of the muon: - mu.setP4( mu.pt() * gRandom->Gaus( mean, sigma ), mu.eta(), mu.phi() ); - - // Return gracefully: - return CorrectionCode::Ok; - } - - SystematicCode MuonSmearingToolExample::sysApplySystematicVariation - ( const SystematicSet& systConfig ) { - - // Only a single systematic can be applied at a time: - if( systConfig.size() > 1 ) { - return SystematicCode::Unsupported; - } - - // Otherwise let's assume that things are correct: - return SystematicCode::Ok; - } - -} // namespace CP diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MyToolProvider.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MyToolProvider.cxx deleted file mode 100644 index 96124cf8c35034058cef9d571d1f4b7197573632..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/MyToolProvider.cxx +++ /dev/null @@ -1,198 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CPAnalysisExamples/MyToolProvider.h" - -MyToolProvider::MyToolProvider(const std::string& name): - AsgMessaging(name), - jetCalibTool(0), - jetUncertaintiesTool(0), - jetCleaningTool(0), - muonCalibrationAndSmearingTool(0), - muonEfficiencySFTool(0), - muonSelectionTool(0), - elecEfficiencySFTool(0), - egammaCalibTool(0), - tauSelTool(0), - tauSmearingTool(0), - tauEffTool(0), - btagTool(0), - metRebuilder(0) -{} - -MyToolProvider::~MyToolProvider() -{ - if (jetCalibTool) delete jetCalibTool; - if (jetUncertaintiesTool) delete jetUncertaintiesTool; - if (jetCleaningTool) delete jetCleaningTool; - if (muonCalibrationAndSmearingTool) delete muonCalibrationAndSmearingTool; - if (muonEfficiencySFTool) delete muonEfficiencySFTool; - if (muonSelectionTool) delete muonSelectionTool; - if (elecEfficiencySFTool) delete elecEfficiencySFTool; - if (egammaCalibTool) delete egammaCalibTool; - if (tauSelTool) delete tauSelTool; - if (tauSmearingTool) delete tauSmearingTool; - if (tauEffTool) delete tauEffTool; - if (btagTool) delete btagTool; - if (metRebuilder) delete metRebuilder; -} - -StatusCode MyToolProvider::initialize(bool isData, bool isAtlfast) -{ - - std::string maindir = ""; - char *tmparea=getenv("ROOTCOREBIN"); - - if (tmparea != NULL) { - maindir = tmparea; - maindir = maindir + "/data/"; - } - else { - std::cout << "ROOTCOREBIN is not set." << std::endl; - return StatusCode::FAILURE; - } - - - // Jet calibration tool - std::string JES_config_file = "JES_Prerecommendation2015_Feb2015.config"; - if(isData) { - jetCalibTool = new JetCalibrationTool("JetCalibToolMine"); - jetCalibTool->setProperty("JetCollection","AntiKt4LCTopo"); - jetCalibTool->setProperty("ConfigFile",JES_config_file); - jetCalibTool->setProperty("CalibSequence","EtaJES_Insitu"); - jetCalibTool->setProperty("IsData",isData); - } else { - jetCalibTool = new JetCalibrationTool("JetCalibToolMine"); - jetCalibTool->setProperty("JetCollection","AntiKt4LCTopo"); - jetCalibTool->setProperty("ConfigFile",JES_config_file); - jetCalibTool->setProperty("CalibSequence","JetArea_Residual_EtaJES"); - jetCalibTool->setProperty("IsData",isData); - } - ATH_CHECK( jetCalibTool->initialize() ); - - /////////////////////////////////////////////////////////////////////////////////////////// - // Initialise jet uncertainty tool - - jetUncertaintiesTool = new JetUncertaintiesTool("JetUncertaintiesTool"); - ATH_CHECK( jetUncertaintiesTool->setProperty("JetDefinition","AntiKt4LCTopo") ); - ATH_CHECK( jetUncertaintiesTool->setProperty("MCType","MC12a") ); - ATH_CHECK( jetUncertaintiesTool->setProperty("ConfigFile","JES_2012/Moriond2013/InsituJES2012_14NP.config") ); - ATH_CHECK( jetUncertaintiesTool->initialize() ); - CP::SystematicSet defaultSet; - CP::SystematicCode ret = jetUncertaintiesTool->applySystematicVariation(defaultSet); - if (ret != CP::SystematicCode::Ok){ - ATH_MSG_ERROR("Cannot configure JetUncertaintiesTool for default systematic setting."); - } - - /////////////////////////////////////////////////////////////////////////////////////////// - // Initialise jet cleaning tools - - jetCleaningTool = new JetCleaningTool("JetCleaningTool"); - ATH_CHECK( jetCleaningTool->setProperty("CutLevel", "LooseBad") ); - ATH_CHECK( jetCleaningTool->initialize() ); - - /////////////////////////////////////////////////////////////////////////////////////////// - // Initialise muon calibration tool - - muonCalibrationAndSmearingTool = new CP::MuonCalibrationAndSmearingTool("MuonCalibrationAndSmearingTool"); - // MuonCalibrationAndSmearingTool->msg().setLevel( MSG::DEBUG); - ATH_CHECK( muonCalibrationAndSmearingTool->initialize() ); - - /////////////////////////////////////////////////////////////////////////////////////////// - // Initialise muon efficiency tool - - muonEfficiencySFTool = new CP::MuonEfficiencyScaleFactors("MuonEfficiencyScaleFactors"); - ATH_CHECK( muonEfficiencySFTool->setProperty("WorkingPoint","Medium") ); - // ATH_CHECK( muonEfficiencySFTool->setProperty("DataPeriod","2012") ); - ATH_CHECK( muonEfficiencySFTool->initialize() ); - - /////////////////////////////////////////////////////////////////////////////////////////// - // Initialise muon selection tool - - muonSelectionTool = new CP::MuonSelectionTool("MuonSelectionTool"); - // muonSelectionTool->msg().setLevel( MSG::VERBOSE ); - ATH_CHECK( muonSelectionTool->setProperty( "MaxEta", 2.4 ) ); - ATH_CHECK( muonSelectionTool->initialize() ); - - /////////////////////////////////////////////////////////////////////////////////////////// - // Initialise electron efficiency tool - - elecEfficiencySFTool = new AsgElectronEfficiencyCorrectionTool("AsgElectronEfficiencyCorrectionTool"); - std::vector< std::string > corrFileNameList; - corrFileNameList.push_back(maindir+"ElectronEfficiencyCorrection/efficiencySF.offline.RecoTrk.2012.8TeV.rel17p2.GEO20.v08.root"); - corrFileNameList.push_back(maindir+"ElectronEfficiencyCorrection/efficiencySF.offline.Tight.2012.8TeV.rel17p2.v07.root"); - corrFileNameList.push_back(maindir+"ElectronEfficiencyCorrection/efficiencySF.e24vhi_medium1_e60_medium1.Tight.2012.8TeV.rel17p2.v07.root"); - ATH_CHECK( elecEfficiencySFTool->setProperty("CorrectionFileNameList",corrFileNameList) ); - if (isData==0) { - PATCore::ParticleDataType::DataType data_type; - if(isAtlfast) data_type = PATCore::ParticleDataType::Fast; - else data_type = PATCore::ParticleDataType::Full; - ATH_MSG_DEBUG( "Setting data type to " << data_type); - ATH_CHECK (elecEfficiencySFTool->setProperty("ForceDataType",(int) data_type) ); - } - ATH_CHECK( elecEfficiencySFTool->initialize() ); - - /////////////////////////////////////////////////////////////////////////////////////////// - // Initialise egamma calibration tool - - egammaCalibTool = new CP::EgammaCalibrationAndSmearingTool("EgammaCalibrationAndSmearingTool"); - egammaCalibTool->setProperty("ESModel", "es2012c"); - ATH_MSG_DEBUG( "Initialising EgcalibTool " ); - ATH_CHECK( egammaCalibTool->initialize() ); - - /////////////////////////////////////////////////////////////////////////////////////////// - // Initialise tau selection tool - - tauSelTool = new TauAnalysisTools::TauSelectionTool("TauSelectionTool"); - tauSelTool->msg().setLevel( MSG::INFO ); - // deprecated - //tauSelTool->setRecommendedProperties(); - ATH_CHECK( tauSelTool->setProperty("SelectionCuts", (int) TauAnalysisTools::SelectionCuts(TauAnalysisTools::CutPt | TauAnalysisTools::CutAbsEta | TauAnalysisTools::CutAbsCharge | TauAnalysisTools::CutNTrack)) ); - ATH_CHECK( tauSelTool->initialize() ); - - /////////////////////////////////////////////////////////////////////////////////////////// - // Initialise tau smearing tool - - tauSmearingTool = new TauAnalysisTools::TauSmearingTool("TauSmearingTool"); - tauSmearingTool->msg().setLevel( MSG::INFO ); - ATH_CHECK( tauSmearingTool->initialize() ); - - /////////////////////////////////////////////////////////////////////////////////////////// - // Initialise tau efficiency tool - - tauEffTool = new TauAnalysisTools::TauEfficiencyCorrectionsTool("TauEffTool"); - tauEffTool->msg().setLevel( MSG::INFO ); - ATH_CHECK( tauEffTool->initialize() ); - - /////////////////////////////////////////////////////////////////////////////////////////// - // Initialise B-tag scale factor tool - - btagTool = new BTaggingEfficiencyTool("BTagTest"); - ATH_CHECK( btagTool->setProperty("TaggerName", "MV2c20") ); - ATH_CHECK( btagTool->setProperty("OperatingPoint", "-0_0436") ); - ATH_CHECK( btagTool->setProperty("JetAuthor", "AntiKt4EMTopoJets") ); - ATH_CHECK( btagTool->setProperty("ScaleFactorFileName","13TeV/2015-PreRecomm-13TeV-MC12-CDI_August3-v1.root") ); - // btagTool->setProperty("JetAuthor", "AntiKt4TopoEMJVF0_5"); - // btagTool->setProperty("ScaleFactorFileName", "../../../MCMC/2014-Winter-8TeV-MC12-CDI-build880.root"); - // btagTool->setProperty("ScaleFactorFileName", "/mnt/lustre/epp_scratch/atlas/ks429/xAODDev/2.0.6/testCDI.root"); - ATH_CHECK( btagTool->initialize() ); - - /////////////////////////////////////////////////////////////////////////////////////////// - // Initialise MET tool - - metRebuilder = new met::METRebuilder("METRebuilderTool"); - // the below is used for a closure test - // MET in xAODs has uncalibrated jets with a cut at 0 GeV - // metRebuilder->setProperty("CalibJetPtCut",0.); - // metRebuilder->msg().setLevel( MSG::VERBOSE); - if( metRebuilder->initialize().isFailure()){ - ATH_MSG_ERROR( "Cannot intialize METRebuilder" ); - ATH_MSG_ERROR( "Exiting... " ); - return StatusCode::FAILURE; - } else { - ATH_MSG_DEBUG( "METRebuilder initialized... " ); - } - - return StatusCode::SUCCESS; -} diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/xExample.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/xExample.cxx deleted file mode 100644 index f350b713098a468a53457da8e89820edb7ee7f27..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/xExample.cxx +++ /dev/null @@ -1,1557 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifdef ROOTCORE - -///////////////////////// -*- C++ -*- ///////////////////////////// -// xExample.cxx: -// xExample is a package to test the xAOD and CP tools by histogramming -// variables for each type of object. Some plots are specific to ttbar. -// Author: Frank Paige <paige@bnl.gov> -// Thanks: David Adams, Joe Taenzer, Iacopo Vivarelli -/////////////////////////////////////////////////////////////////// - -#include <CPAnalysisExamples/xExample.h> -#include <CPAnalysisExamples/xExampleEDM.h> -#include <CPAnalysisExamples/xExampleUtils.h> - -#include <EventLoop/Job.h> -#include <EventLoop/StatusCode.h> -#include <EventLoop/Worker.h> - -// Infrastructure include(s): -#ifdef ROOTCORE -# include "xAODRootAccess/Init.h" -# include "xAODRootAccess/TEvent.h" -#endif // ROOTCORE - -// Root includes: -#include "TH1F.h" -#include "TH2F.h" -#include "TF1.h" - -// STL includes -#include <string> -#include <vector> -#include <map> -#include <fstream> -#include <ctime> - -// this is needed to distribute the algorithm to the workers -ClassImp(xExample) - -/*********************************************************** - -The code below makes shows an example of an analysis using -shallow copies ad deep copies of objects and containers. - -A shallow copy of an object shares the auxiliary store with the original object. -Only quantities that differ with respect to the original object are stored separately. - -A deep copy of an object copies the entire auxiliary store to a separate memory location. - -Please be aware that making a deep copy of an object is an -expensive operation (in terms of used resources). It should be done -only if really necessary - -************************************************************/ - - -////////////////////////// -// xExample class functions -////////////////////////// - -xExample :: xExample (){ - // Here you put any code for the base initialization of variables, - // e.g. initialize all pointers to 0. Note that you should only put - // the most basic initialization here, since this method will be - // called on both the submission and the worker node. Most of your - // initialization code will go into histInitialize() and - // initialize(). -} - - - -EL::StatusCode xExample :: setupJob (EL::Job& job){ - - // Here you put code that sets up the job on the submission object - // so that it is ready to work with your algorithm, e.g. you can - // request the D3PDReader service or add output files. Any code you - // put here could instead also go into the submission script. The - // sole advantage of putting it here is that it gets automatically - // activated/deactivated when you add/remove the algorithm from your - // job, which may or may not be of value to you. - - // From SoftwareTutorialxAODAnalysisInROOT - job.useXAOD(); - xAOD::Init( "xExample" ).ignore(); // call before opening first file - - return EL::StatusCode::SUCCESS; -} - - - -EL::StatusCode xExample :: histInitialize (){ - - // Here you do everything that needs to be done at the very - // beginning on each worker node, e.g. create histograms and output - // trees. This method gets called before any input files are - // connected. - - // Use of map<string,TH*> facilitates booking many histograms; each - // needs only a single statement. Histograms appear in output file - // in alphabetical order, not booking order. - - // pt bins - float xxLim[17] = {9.9999, - 20.00, 30.00, 40.00, 60.00, 80.00, 120.0, - 160.0, 240.0, 320.0, 480.0, 640.0, 960.0, - 1280., 1920., 2560., - 10000.1}; - - std::string xxStr[17] = {"0000", - "0020","0030","0040","0060","0080","0120", - "0160","0240","0320","0480","0640","0960", - "1280","1920","2560", - "0000"}; - - for(unsigned int i=0; i<17; ++i){ - ptLim[i] = xxLim[i]; - ptStr[i] = xxStr[i]; - } - - // Primary vertex - - m_TH1["intactual"] = new TH1F("intactual","intactual",50,0.,50.); - m_TH1["intaverage"] = new TH1F("intaverage","intaverage",50,0.,50.); - m_TH1["intdiff"] = new TH1F("intdiff","intdiff",100,-50.,50.); - - m_TH1["privtxidx"] = new TH1F("privtxidx","privtxidx",50,0.,50.); - m_TH1["privtxz0"] = new TH1F("privtxz0","privtxz0",100,-200.,200.); - m_TH1["privtxn2"] = new TH1F("privtxn2","privtxn2",50,0.,50.); - m_TH1["privtxn5"] = new TH1F("privtxn5","privtxn5",50,0.,50.); - m_TH1["privtxntrk"] = new TH1F("privtxntrk","privtxntrk",100,0.,200.); - - // Muons - - m_TH1["mupt"] = new TH1F("mupt", "mupt", 100, 0., 500. ); - m_TH1["mueta"] = new TH1F("mueta", "mueta", 60, -3., 3. ); - m_TH1["muphi"] = new TH1F("muphi", "muphi", 100, -1., 1.); - m_TH1["mutype"] = new TH1F("mutype","mutype",5,0.,5.); - m_TH1["muquality"] = new TH1F("muquality","muquality",5,0.,5.); - m_TH1["mugoodpt"] = new TH1F("mugoodpt", "mugoodpt", 100, 0., 500. ); - m_TH1["mugoodeta"] = new TH1F("mugoodeta", "mugoodeta", 60, -3., 3. ); - m_TH1["muidrat"] = new TH1F("muidrat","muidrat",100,0.,2.); - m_TH1["muptc30"] = new TH1F("muptc30","muptc30",100,0.,20.); - - // Electrons - - m_TH1["elpt"] = new TH1F("elpt","elpt",100, 0., 500.); - m_TH1["eleta"] = new TH1F("eleta","eleta", 60, -3., 3.); - m_TH1["elphi"] = new TH1F("elphi","elphi", 100, -1., 1.); - m_TH1["elauthor"] = new TH1F("elauthor","elauthor",16,0,16.); - m_TH1["elntrk"] = new TH1F("elntrk","elntrk",20,0,20.); - m_TH1["eleoverp"] = new TH1F("eleoverp","eleoverp",100,0,5.); - m_TH1["eletc30"] = new TH1F("eletc30","eletc30",100,0.,20.); - m_TH1["elgood"] = new TH1F("elgood","elgood",2,0.,2.); - m_TH1["elgoodpt"] = new TH1F("elgoodpt","elgoodpt",100, 0., 500.); - m_TH1["elgoodeta"] = new TH1F("elgoodeta","elgoodeta", 60, -3., 3.); - m_TH1["eldrtrue"] = new TH1F("eldrtrue","eldrtrue",100,0.,1.); - m_TH1["elptrat"] = new TH1F("elptrat","elptrat",100,0.,2.); - - // AntiKt4LCTopo jets - - static const float ptjmax = 2000.; - static const float ptjlomax = 200.; - - m_TH1["akt4pt"] = new TH1F("akt4pt","akt4pt",100,0.,ptjmax); - m_TH1["akt4ptlo"] = new TH1F("akt4ptlo","akt4ptlo",100,0.,ptjlomax); - m_TH1["akt4eta"] = new TH1F("akt4eta","akt4eta",60,-3.,3.); - m_TH1["akt4phi"] = new TH1F("akt4phi","akt4phi",100,-1.,1.); - m_TH1["akt4rlep"] = new TH1F("akt4rlep","akt4rlep",100,0.,2.); - m_TH1["akt4calibrlep"] = new TH1F("akt4calibrlep","akt4calibrlep",100,0.,2.); - m_TH1["akt4ptbad"] = new TH1F("akt4ptbad","akt4ptbad",100,0.,ptjmax); - m_TH1["akt4etabad"] = new TH1F("akt4etabad","akt4etabad",60,-3.,3.); - m_TH2["akt4drelvpt"] = new TH2F("akt4drelvpt","akt4drelvpt",50,0.,200., - 50,0.,2.); - - for(unsigned int ib=1; ib<16; ++ib){ - std::string str = "akt4calib" + ptStr[ib]; - m_TH1[str.c_str()] = new TH1F(str.c_str(),str.c_str(),100,0.,2.); - } - - m_TH1["akt4jvf"] = new TH1F("akt4jvf","akt4jvf",110,-1.,1.19999); - m_TH1["akt4jvfx"] = new TH1F("akt4jvfx","akt4jvfx",110,-1.,1.19999); - m_TH1["akt4jvftot"] = new TH1F("akt4jvftot","akt4jvftot",110,0.,1.09999); - for(unsigned int ib=1; ib<16; ++ib){ - std::string str = "akt4jvf" + ptStr[ib]; - m_TH1[str.c_str()] = new TH1F(str.c_str(),str.c_str(),110,-1.,1.19999); - } - - m_TH1["akt4trueid"] = new TH1F("akt4trueid","akt4trueid",18,-2.,16.); - m_TH1["akt4ptb"] = new TH1F("akt4ptb","akt4ptb",100,0.,ptjmax); - m_TH1["akt4etab"] = new TH1F("akt4etab","akt4etab",60,-3.,3.); - m_TH1["akt4mv1"] = new TH1F("akt4mv1","akt4mv1",100,0.,2.); - m_TH1["akt4sv1b"] = new TH1F("akt4sv1b","akt4sv1b",100,0.,1.); - m_TH1["akt4sv1u"] = new TH1F("akt4sv1u","akt4sv1u",100,0.,1.); - m_TH2["akt4sv1uvb"] = new TH2F("akt4sv1uvb","akt4sv1uvb",80,0.,0.4,50,0.,1.); - - m_TH1["akt4ntrk"] = new TH1F("akt4ntrk","akt4ntrk",50,0.,50.); - m_TH1["akt4rtrk"] = new TH1F("akt4rtrk","akt4rtrk",100,0.,1.); - m_TH1["akt4nsitrk"] = new TH1F("akt4nsitrk","akt4nsitrk",20,0.,20.); - m_TH1["akt4z0trk"] = new TH1F("akt4z0trk","akt4z0trk",100,-200.,200.); - m_TH1["akt4dz0trk"] = new TH1F("akt4dz0trk","akt4dz0trk",200,-5.,5.); - m_TH2["akt4z0vz0"] = new TH2F("akt4z0vz0","akt4z0vz0",25,-50.,50.,25,-50.,50.); - - for(unsigned int ib=1; ib<16; ++ib){ - std::string str = "akt4rtrk" + ptStr[ib]; - m_TH1[str.c_str()] = new TH1F(str.c_str(),str.c_str(),100,0.,2.); - } - - m_TH1["akt4drtrue"] = new TH1F("akt4drtrue","akt4drtrue",100,0.,2.0); - m_TH1["akt4drtruecalib"] = new TH1F("akt4drtruecalib","akt4drtruecalib",100,0.,2.0); - for(unsigned int ib=1; ib<16; ++ib){ - std::string str = "akt4jes" + ptStr[ib]; - m_TH1[str.c_str()] = new TH1F(str.c_str(),str.c_str(),100,0.,2.); - std::string str2 = "akt4jescalib" + ptStr[ib]; - m_TH1[str2.c_str()] = new TH1F(str2.c_str(),str2.c_str(),100,0.,2.); - } - m_TH2["akt4jesvpt"] = new TH2F("akt4jesvpt","akt4jesvpt",50,0.,500,50,0.,2.); - - // AntiKt4Truth jets - - m_TH1["aktT4pt"] = new TH1F("aktT4pt","aktT4pt",100,0.,ptjmax); - m_TH1["aktT4ptlo"] = new TH1F("aktT4ptlo","aktT4ptlo",100,0.,ptjlomax); - m_TH1["aktT4eta"] = new TH1F("aktT4eta","aktT4eta",60,-3.,3.); - m_TH1["aktT4phi"] = new TH1F("aktT4phi","aktT4phi",100,-1.,1.); - - // AntiKt4EMTopo jets - - m_TH1["aktem4n100"] = new TH1F("aktem4n100","aktem4n100",20,0.,20.); - m_TH1["aktem4ncalib100"] = new TH1F("aktem4ncalib100","aktem4ncalib100",20,0.,20.); - - // TauJets - - m_TH1["taupt"] = new TH1F("taupt", "taupt", 100, 0., 500. ); - m_TH1["taueta"] = new TH1F("taueta", "taueta", 60, -3., 3. ); - m_TH1["tauphi"] = new TH1F("tauphi", "tauphi", 100, -1., 1.); - m_TH1["tauid"] = new TH1F("tauid","tauid",5,0.,5.); - m_TH1["taubdt"] = new TH1F("taubdt","taubdt",100,0.,1.); - m_TH2["taudrelvpt"] = new TH2F("taudrelvpt","taudrelvpt",50,0.,200., - 50,0.,2.); - m_TH1["tautruept"] = new TH1F("tautruept","tautruept",100,0.,500.); - m_TH1["tautrueeta"] = new TH1F("tautrueeta","tautrueeta",60,-3.,3.); - m_TH1["taugoodpt"] = new TH1F("taugoodpt", "taugoodpt", 100, 0., 500. ); - m_TH1["taugoodeta"] = new TH1F("taugoodeta", "taugoodeta", 60, -3., 3. ); - m_TH1["taugoodbdt"] = new TH1F("taugoodbdt","taugoodbdt",100,0.,1.); - m_TH1["tauntrk"] = new TH1F("tauntrk","tauntrk",10,0.,10.); - m_TH1["tauptrtrk"] = new TH1F("tauptrtrk","tauptrtrk",120,0.,1.2); - m_TH1["taudrtrue"] = new TH1F("taudrtrue","taudrtrue",100,0.,1.); - m_TH1["tauptrat"] = new TH1F("tauptrat","tauptrat",100,0.,2.); - - // Met - - m_TH1["metet"] = new TH1F("metet","metet",100,0.,1000.); - m_TH1["metetlo"] = new TH1F("metetlo","metetlo",100,0.,200.); - m_TH1["metsum"] = new TH1F("metsum","metsum",100,0.,2000.); - m_TH1["mettrueet"] = new TH1F("mettrueet","mettrueet",100,0.,1000.); - m_TH1["mettrueetlo"] = new TH1F("mettrueetlo","mettrueetlo",100,0.,200.); - m_TH1["mettruesum"] = new TH1F("mettruesum","mettruesum",100,0.,1000.); - m_TH1["metcalibet"] = new TH1F("metcalibet","metcalibet",100,0.,1000.); - m_TH1["metcalibetlo"] = new TH1F("metcalibetlo","metcalibetlo",100,0.,100.); - m_TH1["metcalibsum"] = new TH1F("metcalibsum","metcalibsum",100,0.,2000.); - - // Truth particles - - m_TH1["tppt"] = new TH1F("tppt","tppt",100,0.,500.); - m_TH1["tpptlo"] = new TH1F("tpptlo","tpptlo",100,0.,2.); - m_TH1["tpeta"] = new TH1F("tpeta","tpeta",70,-7.,7.); - m_TH1["tpnum"] = new TH1F("tpnum","tpnum",100,0.,1000.); - m_TH1["tpsum"] = new TH1F("tpsum","tpsum",100,-100.,100.); - m_TH1["tpsumlo"] = new TH1F("tpsumlo","tpsumlo",100,-1.,1.); - m_TH1["tpbpt"] = new TH1F("tpbpt","tpbpt",100,0.,500.); - m_TH1["tpbeta"] = new TH1F("tpbeta","tpbeta",100,-5.,5.); - m_TH1["tpwkid"] = new TH1F("tpwkid","tpwkid",50,-25.,25.); - - // Interactions from Geant - m_TH1["tpvxr"] = new TH1F("tpvxr","tpvxr",100,0.,500.); - m_TH1["tpvxeta"] = new TH1F("tpvxeta","tpvxeta",60,-3.,3.); - m_TH1["tpvxidin"] = new TH1F("tpvxidin","tpvxidin",100,0.,100.); - - - ////////////////////////////////////// - // Add histograms to job and set Sumw2 - ////////////////////////////////////// - - std::map<std::string,TH1*>::iterator h1Itr = m_TH1.begin(); - std::map<std::string,TH1*>::iterator h1ItrE = m_TH1.end(); - for(; h1Itr != h1ItrE; ++h1Itr){ - TH1* h1 = (*h1Itr).second; - h1->Sumw2(); - wk()->addOutput(h1); - } - - std::map<std::string,TH2*>::iterator h2Itr = m_TH2.begin(); - std::map<std::string,TH2*>::iterator h2ItrE = m_TH2.end(); - for(; h2Itr != h2ItrE; ++h2Itr){ - TH2* h2 = (*h2Itr).second; - h2->Sumw2(); - wk()->addOutput(h2); - } - - return EL::StatusCode::SUCCESS; -} - - - -EL::StatusCode xExample :: fileExecute (){ - // Here you do everything that needs to be done exactly once for every - // single file, e.g. collect a list of all lumi-blocks processed - return EL::StatusCode::SUCCESS; -} - - - -EL::StatusCode xExample :: changeInput (bool /*firstFile*/) -{ - // Here you do everything you need to do when we change input files, - // e.g. resetting branch addresses on trees. If you are using - // D3PDReader or a similar service this method is not needed. - return EL::StatusCode::SUCCESS; -} - - - -EL::StatusCode xExample :: initialize (){ - - // Here you do everything that you need to do after the first input - // file has been connected and before the first event is processed, - // e.g. create additional histograms based on which variables are - // available in the input files. You can also create all of your - // histograms and trees in here, but be aware that this method - // doesn't get called if no events are processed. So any objects - // you create here won't be available in the output if you have no - // input events. - - // Wanted to restructure this more like real analysis: - // (1) Get objects and apply CP tools for each - // (2) Remove overlaps - // (3) Make plots - // But many tools missing, and intermediate plots useful. Have moved - // collections to xExampleEDM.h to facilitate this later. - - - // From SoftwareTutorialxAODAnalysisInROOT - m_event = wk()->xaodEvent(); - // print long long int - Info("initialize()", "Number of events = %lli", m_event->getEntries() ); - - // Create a transient object store. Needed for METRebuilder. - // Like m_event but does not assume new objects are written to file - m_store = new xAOD::TStore(); - - m_eventCounter = 0; - m_warnCounter = 0; - m_warnLimit = 100; - - // Configuration from SoftwareTutorialxAODAnalysisInROOT - m_jetCleaningTool = new JetCleaningTool("JetCleaning"); - m_jetCleaningTool->msg().setLevel( MSG::DEBUG ); - m_jetCleaningTool->setProperty( "CutLevel", "MediumBad"); - m_jetCleaningTool->initialize(); - - // Configuration from Joe Taenzer sample code but isData=false - // Path is relative to xaodExample/run directory - // No Insitu with !isData - - const xAOD::EventInfo* eventInfo = 0; - if( !m_event->retrieve( eventInfo, "EventInfo").isSuccess() ){ - Error("initialize()", "Failed to retrieve EventInfo. Exiting." ); - return EL::StatusCode::FAILURE; - } - bool isMC = false; - if( eventInfo->eventType(xAOD::EventInfo::IS_SIMULATION) ) isMC = true; - bool isData = !isMC; - - std::string JES_config_file = "JES_Full2012dataset_Preliminary_MC14.config"; - if(isData) { - m_akt4LCTopoCalibrationTool = new JetCalibrationTool("JetCalibToolMine4LC"); - m_akt4LCTopoCalibrationTool->setProperty("JetCollection","AntiKt4LCTopo"); - m_akt4LCTopoCalibrationTool->setProperty("ConfigFile",JES_config_file); - m_akt4LCTopoCalibrationTool->setProperty("CalibSequence","EtaJES_Insitu"); - m_akt4LCTopoCalibrationTool->setProperty("IsData",isData); - - m_akt4EMTopoCalibrationTool = new JetCalibrationTool("JetCalibToolMine4EM"); - m_akt4EMTopoCalibrationTool->setProperty("JetCollection","AntiKt4EMTopo"); - m_akt4EMTopoCalibrationTool->setProperty("ConfigFile",JES_config_file); - m_akt4EMTopoCalibrationTool->setProperty("CalibSequence","EtaJES_Insitu"); - m_akt4EMTopoCalibrationTool->setProperty("IsData",isData); - }else{ - m_akt4LCTopoCalibrationTool = new JetCalibrationTool("JetCalibToolMine4LC"); - m_akt4LCTopoCalibrationTool->setProperty("JetCollection","AntiKt4LCTopo"); - m_akt4LCTopoCalibrationTool->setProperty("ConfigFile",JES_config_file); - m_akt4LCTopoCalibrationTool->setProperty("CalibSequence","EtaJES"); - m_akt4LCTopoCalibrationTool->setProperty("IsData",isData); - - m_akt4EMTopoCalibrationTool = new JetCalibrationTool("JetCalibToolMine4EM"); - m_akt4EMTopoCalibrationTool->setProperty("JetCollection","AntiKt4EMTopo"); - m_akt4EMTopoCalibrationTool->setProperty("ConfigFile",JES_config_file); - m_akt4EMTopoCalibrationTool->setProperty("CalibSequence","EtaJES"); - m_akt4EMTopoCalibrationTool->setProperty("IsData",isData); - } - - m_akt4LCTopoCalibrationTool->initializeTool("xExampleLC"); - m_akt4EMTopoCalibrationTool->initializeTool("xExampleEM"); - - // Initialize METRebuilder from Reconstruction/MET/METUtilities - // "AntiKt4LCCalibJets" is key used to save m_akt4CopyJets.first - // Keep default inputs otherwise -- see - // https://svnweb.cern.ch/trac/atlasoff/browser/Reconstruction/MET/METUtilities/trunk/Root/METRebuilder.cxx - - m_metRebuilder = new met::METRebuilder("METRebuilderTool"); - m_metRebuilder->setProperty("JetColl", "AntiKt4LCCalibJets"); - m_metRebuilder->setProperty("OutputContainer", "MET_CalibFinal"); - m_metRebuilder->setProperty("OutputTotal", "Final"); - m_metRebuilder->setProperty( "SoftTermType", "TrackSoftTerm"); - m_metRebuilder->msg().setLevel( MSG::INFO); - - if( !m_metRebuilder->initialize() ){ - Error("initialize()", "Failed to initialize METRebuilder. Exiting." ); - return EL::StatusCode::FAILURE; - } - - // Initialize new object containers - // Will clear them after each execute() - - // Deep copy for Muons - m_newMuons = new xAOD::MuonContainer(); - m_newMuonsAux = new xAOD::MuonAuxContainer(); - m_newMuons->setStore(m_newMuonsAux); - - // Deep copy for Electrons - m_newElectrons = new xAOD::ElectronContainer(); - m_newElectronsAux = new xAOD::ElectronAuxContainer(); - m_newElectrons->setStore(m_newElectronsAux); - - // Deep copy for TauJets - m_newTauJets = new xAOD::TauJetContainer(); - m_newTauJetsAux = new xAOD::TauJetAuxContainer(); - m_newTauJets->setStore(m_newTauJetsAux); - - // Shallow copy used for AntiKt4LCTopo jets. - // m_akt4CopyJets in xExampleEDM.h includes all jets. - // View container provides access to selected jets - m_akt4ViewJets = new xAOD::JetContainer(SG::VIEW_ELEMENTS); - - // Deep copy used for AntiKt4EMTopo jets - m_aktem4NewJets = new xAOD::JetContainer(); - m_aktem4NewJetsAux = new xAOD::JetAuxContainer(); - m_aktem4NewJets->setStore(m_aktem4NewJetsAux); - - // Do NOT initialize containers for rebuilt MET - // This is done in METRebuilder - - return EL::StatusCode::SUCCESS; -} - - - -EL::StatusCode xExample :: execute (){ - - // Here you do everything that needs to be done on every single - // events, e.g. read input variables, apply cuts, and fill - // histograms and trees. This is where most of your actual analysis - // code will go. - - // Want to run on both full and derived xAOD with various contents. - // Hence test containers with contains() and skip if missing rather - // than exiting as in tutorials. - - if(m_eventCounter==0) m_startTime = time(NULL); //time in seconds - - if( (m_eventCounter % 100) ==0 ){ - Info("execute()", "Event number = %i", m_eventCounter ); - } - m_eventCounter++; - - - //////////// - // EventInfo - //////////// - - const xAOD::EventInfo* eventInfo = 0; - if( !m_event->retrieve( eventInfo, "EventInfo").isSuccess() ){ - Error("execute()", "Failed to retrieve EventInfo collection. Exiting." ); - return EL::StatusCode::FAILURE; - } - - bool isMC = false; - if( eventInfo->eventType(xAOD::EventInfo::IS_SIMULATION) ) isMC = true; - - // Get relative event weights, necessary for JZxW jets, etc. - // Overall weight is sigma*efficiency/Nevent, where sigma and filter - // efficiency are gotten from AMI - - float wt = 1; - const std::vector< float > weights = eventInfo->mcEventWeights(); - if( weights.size() > 0 ) wt = weights[0]; - - - // Pileup - m_TH1["intactual"]->Fill(eventInfo->actualInteractionsPerCrossing(), wt); - m_TH1["intaverage"]->Fill(eventInfo->averageInteractionsPerCrossing(), wt); - m_TH1["intdiff"]->Fill(eventInfo->actualInteractionsPerCrossing() - - eventInfo->averageInteractionsPerCrossing(), wt); - - - /////////////////// - // Primary vertices - /////////////////// - - // Get primary vertices. First vertex has \max \sum p_T^2? - // Should cache \sum pt^2 -- xAOD::Vertex only has multiplicity - - const xAOD::VertexContainer* pVertices = 0; - if( !m_event->retrieve(pVertices,"PrimaryVertices") ){ - Error("execute()", "Failed to retrieve PrimaryVertices. Exiting." ); - return EL::StatusCode::FAILURE; - } - - // Assume first vertex is correct one - const xAOD::Vertex* pVertex = 0; - if( pVertices->size() > 0 ){ - pVertex = (*pVertices)[0]; - } else { - Error("execute()", "Failed to find primary vertex. Exiting" ); - return EL::StatusCode::FAILURE; - } - - // Check \sum pt^2 for vertices. Will be incorrect if tracks have been - // thinned, so do not replace primary vertex choice. - // Need to check validity of *all* ElementLinks. Otherwise code may die - // when run on derived xAOD samples. - - // Note nv2 and nv5 will be *wrong* if tracks are thinned. - - int iVertex = -1; - float pt2PV = 0; - int nv2 = 0; - int nv5 = 0; - - xAOD::VertexContainer::const_iterator vtxItr = pVertices->begin(); - xAOD::VertexContainer::const_iterator vtxItrE = pVertices->end(); - - int ivtx = -1; - for(; vtxItr!=vtxItrE; ++vtxItr){ - ++ivtx; - int ntrkv = (*vtxItr)->nTrackParticles(); - if( ntrkv == 0 ) continue; - if( ntrkv > 1 ) ++nv2; - if( ntrkv > 4 ) ++nv5; - // Find primary vertex - FIXME. - const std::vector< ElementLink<xAOD::TrackParticleContainer> > vxTracks = - (*vtxItr)->trackParticleLinks(); - float ptsum = 0; - for(unsigned int it=0; it<vxTracks.size(); ++it){ - if( (vxTracks[it]).isValid() ){ - // Dereference an ElementLink to get a pointer to the object - const xAOD::TrackParticle* trkit = *(vxTracks[it]); - if( trkit ) ptsum += trkit->p4().Perp2(); - } - } - if( ptsum > pt2PV ){ - pt2PV = ptsum; - iVertex = ivtx; - } - } - - float z0PV = pVertex->z(); - int ntrkVertex = pVertex->nTrackParticles(); - - // Fill histograms - m_TH1["privtxntrk"]->Fill(ntrkVertex, wt); - m_TH1["privtxidx"]->Fill(std::min(iVertex,49), wt); - m_TH1["privtxz0"]->Fill(z0PV, wt); - m_TH1["privtxn2"]->Fill(nv2, wt); - m_TH1["privtxn5"]->Fill(nv5, wt); - - - ////////////////// - // Truth particles - ////////////////// - - // Truth information in xAOD has linked TruthParticle and TruthVertex - // containers. Particles have parent and decay vertices. - // Must follow sequence of decays to find all descendants. - - const xAOD::TruthParticleContainer* truths = 0; - - // Following mainly relevant to ttbar events - std::vector< const xAOD::TruthParticle* > bHadrons; - std::vector< TLorentzVector > wLeptons; - std::vector< TLorentzVector > wElectrons; - std::vector< TLorentzVector > wMuons; - std::vector< TLorentzVector > wTauJets; - std::vector< const xAOD::TruthParticle* > wkids; - - if( isMC ) { - double eTruth = 0; - int nTruth = 0; - - // Note TruthParticle, NOT TruthParticles - // Need contains() test to avoid warning message for each event. - if( m_event->contains<xAOD::TruthParticleContainer>("TruthParticle") ){ - if( !m_event->retrieve( truths, "TruthParticle" ) ){ - Error("execute()", "Failed to retrieve TruthParticle. Exiting." ); - return EL::StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - Warning("execute()", "Did not find TruthParticle."); - } - ++m_warnCounter; - } - - // MC samples may not contain truth - if( truths ){ - xAOD::TruthParticleContainer::const_iterator tpItr = truths->begin(); - xAOD::TruthParticleContainer::const_iterator tpItrE = truths->end(); - - // Stable particles - // Not for PowhegPythia ttbar! - // Powheg has detached W's with status==3 children and no - // stable descendants. Remove status!=1 and no decayVtx(). - - for( ; tpItr != tpItrE; ++tpItr ) { - - // (*tpItr)->m() gives ZERO - FIXME. - - // Generator stable particles have status==1 && barcode<100000 - // Other status==1 particles are from pileup or Geant - - bool isGS = (*tpItr)->status()==1 && (*tpItr)->barcode()<100000; - - if( isGS ){ - m_TH1["tppt"]->Fill( (*tpItr)->pt()/1000., wt); - m_TH1["tpptlo"]->Fill( (*tpItr)->pt()/1000., wt); - if( (*tpItr)->pt() > 0 ) m_TH1["tpeta"]->Fill( (*tpItr)->eta(), wt); - ++nTruth; - eTruth += (*tpItr)->e(); - } //end isGS - - // Stable particles with decay vertex give Geant secondaries - // Plot vertex location and particle type to see what is being kept - - if( isGS && (*tpItr)->hasDecayVtx() ){ - const xAOD::TruthVertex* dvtx = (*tpItr)->decayVtx(); - if( dvtx ){ - m_TH1["tpvxr"]->Fill( dvtx->perp(), wt); - if( dvtx->perp() > 0 ) m_TH1["tpvxeta"]->Fill( dvtx->eta(), wt); - int idabs = std::abs( (*tpItr)->pdgId() ); - // Plot all hadrons as id=99 - m_TH1["tpvxidin"]->Fill( std::min(idabs,99) ); - } - } - - // B hadrons - plot and save TruthParticle* - if( isBHadron(*tpItr) ){ - m_TH1["tpbpt"]->Fill( (*tpItr)->pt()/1000., wt); - m_TH1["tpbeta"]->Fill( (*tpItr)->eta() , wt); - bHadrons.push_back(*tpItr); - } - - // W leptonic decays - e/mu/tau among first generation children - // Generator specific: used mainly with PowhegPythia6 ttbar sample - // Remove possible virtual W in B decays - - if( abs((*tpItr)->pdgId()) == 24 && (*tpItr)->p4().M() > 5000 ){ - bool badW = false; - bool hadW = true; - const xAOD::TruthVertex* dvtx = 0; - if( (*tpItr)->hasDecayVtx() ) (*tpItr)->decayVtx(); - - // Has valid vertex - if( dvtx ){ - const std::vector< ElementLink<xAOD::TruthParticleContainer> >& - outPart = dvtx->outgoingParticleLinks(); - int lepIda = 0; - for(unsigned int k=0; k<outPart.size(); ++k){ - if( ! (outPart[k]).isValid() ) continue; - const xAOD::TruthParticle* kid = *(outPart[k]); - if( ! kid ) continue; - int kidId = kid->pdgId(); - int kidIda = std::abs(kidId); - - // Remove self-decays, W -> W - if( kidId == (*tpItr)->pdgId() ) badW = true; - // PowhegPythia6 has W's with no real descendants - if( kid->status() != 1 && !(kid->decayVtx()) ) badW = true; - if( !badW ) m_TH1["tpwkid"]->Fill( kid->pdgId() , wt); - - // Find leptonic W decays - if( kidIda==11 || kidIda==13 || kidIda==15 ){ - hadW = false; - lepIda = std::abs(kidId); - wLeptons.push_back( kid->p4() ); - } - } - - // Sum non-neutrino stable descendants, including leptons, - // photons, and hadrons from taus. - // getDescendants replaces HepMC descendants iterator - - if( !hadW && !badW ){ - getDescendants( (*tpItr), wkids ); - TLorentzVector pwvis; - bool nuemu = false; - for(unsigned int kk=0; kk<wkids.size(); ++kk){ - const xAOD::TruthParticle* kid = wkids[kk]; - int ida = std::abs( kid->pdgId() ); - if( ida==12 || ida==14 ) nuemu = true; - if( kid->status()==1 && kid->barcode()<100000 && - ida!=12 && ida!=14 && ida!=16 ){ - pwvis += kid->p4(); - } - } - - if( lepIda==11 ) wElectrons.push_back( pwvis ); - if( lepIda==13 ) wMuons.push_back( pwvis ); - if( lepIda==15 && !nuemu ) wTauJets.push_back( pwvis ); - } - } - }//end id==24 - }//end tpItr - - // Total multiplicity and energy (Ecm hard coded) - // Expect eTruth = Ecm, but not true for PowhegPythia6 ttbar sample - float Ecm = 8000.; - m_TH1["tpnum"]->Fill(nTruth, wt); - m_TH1["tpsum"]->Fill(eTruth/1000. - Ecm, wt); - m_TH1["tpsumlo"]->Fill(eTruth/1000. - Ecm, wt); - - }//end truths - }//end isMC - - - //////// - // Muons - //////// - - // Get the Muons from the event: - m_muons = 0; - if( m_event->contains<xAOD::MuonContainer>("Muons") ){ - if( !m_event->retrieve(m_muons, "Muons") ){ - Error("execute()", "Failed to retrieve Muons. Exiting."); - return EL::StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - Warning("execute()", "Did not find Muons."); - } - ++m_warnCounter; - } - - if( m_muons ){ - xAOD::MuonContainer::const_iterator muItr = m_muons->begin(); - xAOD::MuonContainer::const_iterator muItrE = m_muons->end(); - - for( ; muItr != muItrE; ++muItr ) { - m_TH1["mupt"]->Fill( (*muItr)->pt()/1000., wt); - m_TH1["mueta"]->Fill( (*muItr)->eta() , wt); - m_TH1["muphi"]->Fill( (*muItr)->phi()/M_PI , wt); - - int mutype = (*muItr)->muonType(); - m_TH1["mutype"]->Fill(mutype, wt); - int muquality = (*muItr)->quality(); - m_TH1["muquality"]->Fill(muquality, wt); - if( mutype!=xAOD::Muon::Combined || muquality!=xAOD::Muon::Tight) continue; - - // Do not have Muon CP tools yet, so just copy' - // Would be done internally by CP correctedCopy() method. - xAOD::Muon* tmpmu = new xAOD::Muon(); - tmpmu->makePrivateStore(**muItr); - m_newMuons->push_back(tmpmu); - }//end muItr - - // Make remaining plots from m_newMuons - - muItr = m_newMuons->begin(); - muItrE = m_newMuons->end(); - - for(; muItr!=muItrE; ++muItr){ - const xAOD::Muon* amuon = (*muItr); - if( amuon->pt() < 20000 ) continue; - - // Kinematics - m_TH1["mugoodpt"]->Fill( amuon->pt()/1000., wt); - m_TH1["mugoodeta"]->Fill( amuon->eta() , wt); - - // Isolation variables are track ptcone20,ptcone30,ptcone40 and - // calorimeter etcone20,etcone30,etcone40. Do just one: - float ptc30 = -666.; - amuon->isolation(ptc30, xAOD::Iso::ptcone30); - m_TH1["muptc30"]->Fill(ptc30/1000., wt); - - // Dereference an ElementLink to get a pointer to the object - // Compare pt of inner detector track and muon - const ElementLink< xAOD::TrackParticleContainer >& idlink = - amuon->inDetTrackParticleLink(); - if( idlink.isValid() ) { - const xAOD::TrackParticle* idtrack = *idlink; - if( idtrack ) { - m_TH1["muidrat"]->Fill( idtrack->pt()/amuon->pt() , wt); - } - } - }//end muItr - }//end m_muons - - - //////////// - // Electrons - //////////// - - m_electrons = 0; - if( m_event->contains<xAOD::ElectronContainer>("ElectronCollection") ){ - if( !m_event->retrieve(m_electrons, "ElectronCollection") ){ - Error("execute()", "Failed to retrieve ElectronCollection. Exiting."); - return EL::StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - Warning("execute()", "Did not find ElectronCollection."); - } - ++m_warnCounter; - } - - if( m_electrons ){ - // Electron inherits from Egamma, which contains most stuff - // isolation for Muon but isolationValue for Electron - // Iso for Muon but EgammaParameters for Electron - - xAOD::ElectronContainer::const_iterator eItr = m_electrons->begin(); - xAOD::ElectronContainer::const_iterator eItrE = m_electrons->end(); - - for(; eItr != eItrE; ++eItr){ - TLorentzVector pel = (*eItr)->p4(); - m_TH1["elpt"]->Fill( (*eItr)->pt()/1000., wt); - m_TH1["eleta"]->Fill( (*eItr)->eta() , wt); - m_TH1["elphi"]->Fill( (*eItr)->phi()/M_PI , wt); - m_TH1["elauthor"]->Fill( (*eItr)->author() , wt); - - // Select good electrons - no CP tools yet - bool egood = false; - if( (*eItr)->auxdata<char>("Tight") ) egood = true; - m_TH1["elgood"]->Fill(egood, wt); - if( !egood ) continue; - - // Do not have Electron CP tools yet, so just copy. - // Would be done internally by CP correctedCopy() method. - xAOD::Electron* tmpel = new xAOD::Electron(); - tmpel->makePrivateStore(**eItr); - m_newElectrons->push_back(tmpel); - } - - // Make remaining plots from m_newElectrons - - eItr = m_newElectrons->begin(); - eItrE = m_newElectrons->end(); - - for(; eItr!=eItrE; ++eItr){ - const xAOD::Electron* anelectron = (*eItr); - if( anelectron->pt() < 20000 ) continue; - TLorentzVector pel = anelectron->p4(); - - m_TH1["elgoodpt"]->Fill( anelectron->pt()/1000., wt); - m_TH1["elgoodeta"]->Fill( anelectron->eta() , wt); - - m_TH1["elntrk"]->Fill( anelectron->nTrackParticles() , wt); - float pttrk = 0; - if( anelectron->nTrackParticles() > 0 ){ - pttrk = fabs( anelectron->trackParticle(0)->pt() ); - } - if( pttrk>0 ) pttrk = anelectron->pt()/pttrk; - m_TH1["eleoverp"]->Fill( pttrk , wt); - - // Same isolation variables as for muon but different syntax: - // isolation for Muon but isolationValue for Electron - // Iso for Muon but EgammaParameters for Electron - - float etc30 = -666.; - anelectron->isolationValue(etc30, xAOD::Iso::etcone30); - m_TH1["eletc30"]->Fill(etc30, wt); - - // Match to truth electrons from W - // Truth 4-vector is sum of e + gammas from W descendants - float rtrue = 0.999; - float pttrue = -1; - for(unsigned int kk=0; kk<wElectrons.size(); ++kk){ - float drkk = pel.DeltaR( wElectrons[kk] ); - if( drkk < rtrue ) { - rtrue = drkk; - pttrue = wElectrons[kk].Perp(); - } - } - m_TH1["eldrtrue"]->Fill(rtrue,wt); - if( rtrue < 0.1 ) m_TH1["elptrat"]->Fill(anelectron->pt()/pttrue, wt); - - } //end for eItr - }//end m_electrons - - - ////////// - // TauJets - ////////// - - // Get the TauJets from the event: - m_tauJets = 0; - if( m_event->contains<xAOD::TauJetContainer>("TauRecContainer") ){ - if( !m_event->retrieve(m_tauJets, "TauRecContainer") ){ - Error("execute()", "Failed to retrieve TauRecContainer. Exiting."); - return EL::StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - Warning("execute()", "Did not find TauRecContainer."); - } - ++m_warnCounter; - } - - if( m_tauJets ){ - xAOD::TauJetContainer::const_iterator tauItr = m_tauJets->begin(); - xAOD::TauJetContainer::const_iterator tauItrE = m_tauJets->end(); - - for( ; tauItr != tauItrE; ++tauItr ) { - TLorentzVector ptau = (*tauItr)->p4(); - m_TH1["taupt"]->Fill( (*tauItr)->pt()/1000., wt); - if( (*tauItr)->pt() < 20000 ) continue; - m_TH1["taueta"]->Fill( (*tauItr)->eta() , wt); - m_TH1["tauphi"]->Fill( (*tauItr)->phi()/M_PI , wt); - - // TauID flags - bool tauLoose = - (*tauItr)->isTau( xAOD::TauJetParameters::JetBDTSigLoose ); - bool tauMedium = - (*tauItr)->isTau( xAOD::TauJetParameters::JetBDTSigMedium ); - bool tauTight = - (*tauItr)->isTau( xAOD::TauJetParameters::JetBDTSigTight ); - if( tauLoose ) m_TH1["tauid"]->Fill(1, wt); - if( tauMedium ) m_TH1["tauid"]->Fill(2, wt); - if( tauTight ) m_TH1["tauid"]->Fill(3, wt); - float bdt = (*tauItr)->discriminant( xAOD::TauJetParameters::BDTJetScore ); - m_TH1["taubdt"]->Fill( bdt ); - if( !tauTight ) continue; - - // Remove tight Electron overlaps, DeltaR < 0.2 - float rtaue = 1.999; - for(unsigned int ie=0; ie<m_newElectrons->size(); ++ie){ - const xAOD::Electron* elie = (*m_newElectrons)[ie]; - float dr = ptau.DeltaR(elie->p4()); - if( dr < rtaue ) rtaue = dr; - } - m_TH2["taudrelvpt"]->Fill(ptau.Perp()/1000.,rtaue,wt); - if( rtaue < 0.2 ) continue; - - // Do not have TauJet CP tools yet, so just copy. - // Would be done internally by CP correctedCopy() method. - xAOD::TauJet* tmptau = new xAOD::TauJet(); - tmptau->makePrivateStore(**tauItr); - m_newTauJets->push_back(tmptau); - - }//end for tauItr - - // Make remaining plots from m_newTauJets - - tauItr = m_newTauJets->begin(); - tauItrE = m_newTauJets->end(); - - for(; tauItr!=tauItrE; ++tauItr){ - if( (*tauItr)->pt() < 40000 ) continue; - TLorentzVector ptau = (*tauItr)->p4(); - - m_TH1["taugoodpt"]->Fill( (*tauItr)->pt()/1000., wt); - m_TH1["taugoodeta"]->Fill( (*tauItr)->eta() , wt); - float bdt = (*tauItr)->discriminant( xAOD::TauJetParameters::BDTJetScore ); - m_TH1["taugoodbdt"]->Fill( bdt ); - - // Exercise tracks - // tau->nTracks() gives segfault. FIXME. - // Still true in _r5591_r5625 - /*********** - m_TH1["taugoodntrk"]->Fill( (*tauItr)->nTracks() ); - std::vector< ElementLink<xAOD::TrackParticleContainer> > tautrks = - (*tauItr)->trackLinks(); - for(unsigned int it=0; it<tautrks.size(); ++it){ - if( !(tautrks[it]).isValid() ) continue; - const xAOD::TrackParticle* trk = *(tautrks[it]); - if( trk ) m_TH1["taugoodptrtrk"]->Fill( trk->pt()/(*tauItr)->pt(), wt); - } - ***********/ - - // Match to W -> hadtau nu - float rtrue = 0.999; - float pttrue = -1; - for(unsigned int kk=0; kk<wTauJets.size(); ++kk){ - if( wTauJets[kk].Perp()<=0 ) continue; - float drkk = ptau.DeltaR( wTauJets[kk] ); - if( drkk < rtrue ) { - rtrue = drkk; - pttrue = wTauJets[kk].Perp(); - } - } - - // Match to truth W -> tau nu, !tau -> e,mu - // Sum all isGenStable decay products other than neutrinos - m_TH1["taudrtrue"]->Fill(rtrue, wt); - if( rtrue<0.1 ) m_TH1["tauptrat"]->Fill( (*tauItr)->pt()/pttrue ); - - }//end for tauItr - - for(unsigned int i=0; i<wTauJets.size(); ++i){ - m_TH1["tautruept"]->Fill( wTauJets[i].Perp()/1000. ); - if( wTauJets[i].Perp()<= 0 ) continue; - m_TH1["tautrueeta"]->Fill( wTauJets[i].PseudoRapidity() ); - } - }//end m_tauJets - - - //////////////////// - // AntiKt4Truth Jets - //////////////////// - - m_akt4TruthJets = 0; - if( isMC ){ - if( m_event->contains<xAOD::JetContainer>("AntiKt4TruthJets") ){ - if( !m_event->retrieve(m_akt4TruthJets, "AntiKt4TruthJets") ){ - Error("execute()", "Failed to retrieve AntiKt4TruthJets. Exiting."); - return EL::StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - Warning("execute()", "Did not find AntiKt4TruthJets."); - } - ++m_warnCounter; - } - - if( m_akt4TruthJets ){ - xAOD::JetContainer::const_iterator aktT4Itr = m_akt4TruthJets->begin(); - xAOD::JetContainer::const_iterator aktT4ItrE = m_akt4TruthJets->end(); - - for(; aktT4Itr != aktT4ItrE; ++aktT4Itr){ - TLorentzVector pjet = (*aktT4Itr)->p4(); - - // Remove leptonic W decays from jets - float rlep = 1.999; - for(unsigned int kk=0; kk<wLeptons.size(); ++kk){ - float drkk = pjet.DeltaR( wLeptons[kk] ); - rlep = TMath::Min(rlep,drkk); - } - if( rlep < 0.4 ) continue; - - // Kinematics - float ptj = (*aktT4Itr)->pt()/1000.; - m_TH1["aktT4pt"]->Fill(ptj, wt); - m_TH1["aktT4ptlo"]->Fill(ptj, wt); - m_TH1["aktT4eta"]->Fill((*aktT4Itr)->eta(), wt); - m_TH1["aktT4phi"]->Fill((*aktT4Itr)->phi()/M_PI, wt); - } - }//end m_akt4TruthJets - }//end isMC - - - //////////////////////////////// - // AntiKt4LCTopo Jets and B jets - //////////////////////////////// - - if( m_event->contains<xAOD::JetContainer>("AntiKt4LCTopoJets") ){ - if( !m_event->retrieve(m_akt4Jets, "AntiKt4LCTopoJets") ){ - Error("execute()", "Failed to retrieve AntiKt4LCTopoJets. Exiting."); - return EL::StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - Warning("execute()", "Did not find AntiKt4LCTopoJets."); - } - ++m_warnCounter; - } - - // Reconstructed jets - // Set up shallow copy using variables in xExampleEDM.h - - m_badJetPtMax = 0; - - if( m_akt4Jets ){ - m_akt4CopyJets = xAOD::shallowCopyContainer( *m_akt4Jets ); - xAOD::JetContainer::iterator akt4Itr = (m_akt4CopyJets.first)->begin(); - xAOD::JetContainer::iterator akt4ItrE = (m_akt4CopyJets.first)->end(); - - for(; akt4Itr != akt4ItrE; ++akt4Itr){ - bool isGood = true; - TLorentzVector pjet = (*akt4Itr)->p4(); - xAOD::JetFourMom_t p4aod = (*akt4Itr)->jetP4(); - float ptj = (*akt4Itr)->pt()/1000.; - - // Apply cleaning tool - if( !m_jetCleaningTool->accept(**akt4Itr) ){ - m_TH1["akt4ptbad"]->Fill(ptj, wt); - m_TH1["akt4etabad"]->Fill((*akt4Itr)->eta(), wt); - isGood = false; - // Appropriate scale for bad jet? - m_badJetPtMax = std::max(m_badJetPtMax, ptj); - } - - // Apply JetCalibration tool. - // Calibration already applied in valid1 samples; applying it again - // makes JES worse. Should apply to old scale. FIXME. - // JetArea pileup subtraction applied in mc14 samples, so omit it - // in xExample::initialize(). - // jetP4(), setJetP4() use JetFourMom_t, which is a Math::LorentzVector, - // not a TLorentzVector. - - // Shallow copy - if( !m_akt4LCTopoCalibrationTool->applyCalibration(**akt4Itr) ){ - Error("execute()","Cannot apply shallow-copy calibration."); - continue; - } - (*akt4Itr)->setJetP4("xaodscale",p4aod); - - // Link to original jets needed for METRebuilder. See setObjLink in - // https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/METUtilities - // Must do this for EVERY jet - const ElementLink< xAOD::IParticleContainer > link(*m_akt4Jets,(*akt4Itr)->index()); - m_objLinkAcc(**akt4Itr) = link; - - // Calibration factors - for(unsigned int ib=1; ib<16; ++ib){ - if( ptj>ptLim[ib] && ptj<ptLim[ib+1] ){ - std::string str = "akt4calib" + ptStr[ib]; - float calib = (*akt4Itr)->pt()/p4aod.pt(); - m_TH1[str.c_str()]->Fill(calib, wt); - } - } - - // Remove electron overlaps after calibration - // Just omit jet from view container - float rjete = 1.999; - for(unsigned int ie=0; ie<m_newElectrons->size(); ++ie){ - const xAOD::Electron* elie = (*m_newElectrons)[ie]; - float dr = pjet.DeltaR(elie->p4()); - if( dr < rjete ) rjete = dr; - } - m_TH2["akt4drelvpt"]->Fill(pjet.Perp()/1000., rjete, wt); - - // Save jet if not removed by cleaning and does not match electron - if( rjete > 0.2 && isGood ) m_akt4ViewJets->push_back((*akt4Itr)); - - } //end for akt4Itr - - // Save calibrated jets in TStore for METRebuilder in m_store - // Hence do NOT delete them at end - - if( !m_store->record(m_akt4CopyJets.first, "AntiKt4LCCalibJets") || - !m_store->record(m_akt4CopyJets.second, "AntiKt4LCCalibJetsAux.") ){ - Error("execute()", "Failed to record AntiKt4LCCalibJets. Exiting."); - return EL::StatusCode::FAILURE; - } - - - // Make calibration plots with recalibrated jets - - xAOD::JetContainer::const_iterator akt4Itr2=(m_akt4ViewJets)->begin(); - xAOD::JetContainer::const_iterator akt4Itr2E=(m_akt4ViewJets)->end(); - - for(; akt4Itr2!=akt4Itr2E; ++akt4Itr2){ - const xAOD::Jet* ajet = (*akt4Itr2); - TLorentzVector pjet = ajet->p4(); - xAOD::JetFourMom_t p4aod = ajet->jetP4("xaodscale"); - - // Match calibrated to truth jets - // Bin in pttrue, so do before pt cut - if( m_akt4TruthJets ){ - float drtrue = 666.; - int itrue = -666; - for(unsigned int it=0; it<m_akt4TruthJets->size(); ++it){ - const xAOD::Jet* jit = (*m_akt4TruthJets)[it]; - float drit = pjet.DeltaR(jit->p4()); - if( drit < drtrue ){ - drtrue = drit; - itrue = it; - } - } - if( itrue > -1 ){ - m_TH1["akt4drtruecalib"]->Fill(drtrue, wt); - float ptjT = ((*m_akt4TruthJets)[itrue])->pt(); - float jescalib = ajet->pt()/ptjT; - float jesaod = p4aod.pt()/ptjT; - ptjT = ptjT/1000.; - if( drtrue < 0.1 ){ - m_TH2["akt4jesvpt"]->Fill(ptjT,jesaod, wt); - for(unsigned int ib=1; ib<16; ++ib){ - if(ptjT>ptLim[ib] && ptjT<ptLim[ib+1]){ - std::string str = "akt4jescalib" + ptStr[ib]; - m_TH1[str.c_str()]->Fill(jescalib, wt); - std::string str2 = "akt4jes" + ptStr[ib]; - m_TH1[str2.c_str()]->Fill(jesaod, wt); - } - } - } - } - }//end m_akt4TruthJets - } //end akt4Itr2 - - - // valid1 samples are produced with calibration; applying it again - // made JES worse. Hence akt4Itr3 with various options. - // Default is for MC14 - - // Make remaining plots with original jets - //xAOD::JetContainer::const_iterator akt4Itr3 = m_akt4Jets->begin(); - //xAOD::JetContainer::const_iterator akt4Itr3E = m_akt4Jets->end(); - - // Make remaining plots with recalibrated jets - xAOD::JetContainer::const_iterator akt4Itr3=(m_akt4ViewJets)->begin(); - xAOD::JetContainer::const_iterator akt4Itr3E=(m_akt4ViewJets)->end(); - - for(; akt4Itr3!=akt4Itr3E; ++akt4Itr3){ - const xAOD::Jet* ajet = (*akt4Itr3); - TLorentzVector pjet = ajet->p4(); - - // Remove leptonic W decays from jets - float rlep = 1.999; - for(unsigned int kk=0; kk<wLeptons.size(); ++kk){ - float drkk = pjet.DeltaR( wLeptons[kk] ); - rlep = std::min(rlep,drkk); - } - m_TH1["akt4rlep"]->Fill(rlep, wt); - if( rlep < 0.4 ) continue; - - // Kinematics - float ptj = (*akt4Itr3)->pt()/1000.; - m_TH1["akt4pt"]->Fill((*akt4Itr3)->pt()/1000., wt); - m_TH1["akt4ptlo"]->Fill((*akt4Itr3)->pt()/1000., wt); - m_TH1["akt4eta"]->Fill((*akt4Itr3)->eta(), wt); - m_TH1["akt4phi"]->Fill((*akt4Itr3)->phi()/M_PI, wt); - - // Apply jet cuts for remaining plots - if( (*akt4Itr3)->pt()<20000. || fabs((*akt4Itr3)->eta())>2.5 ) continue; - - // Jet moment keys listed in xAODJet/JetAttributes.h - - // Plot JVF for all jets - std::vector<float> jvfvec = - (*akt4Itr3)->getAttribute< std::vector<float> >(xAOD::JetAttribute::JVF); - - float jvf0 = -666; - if( (int)jvfvec.size() > iVertex ){ - jvf0 = jvfvec[iVertex]; - } else { - Warning("execute()", "Invalid JVF index %i %lu",iVertex,jvfvec.size()); - } - - // Plot primary vertex JVF inclusive and binned in ptj - m_TH1["akt4jvf"]->Fill(jvf0, wt); - for(unsigned int ib=1; ib<16; ++ib){ - if( ptj>ptLim[ib] && ptj<ptLim[ib+1] ){ - std::string str = "akt4jvf" + ptStr[ib]; - m_TH1[str.c_str()]->Fill(jvf0, wt); - } - } - - float jvfmax = -666; - float jvfsum = 0; - //Dummy vertex at end? - for(unsigned int ii=0; ii<jvfvec.size(); ++ii){ - jvfsum += jvfvec[ii]; - if( jvfvec[ii] > jvfmax ) jvfmax = jvfvec[ii]; - } - - // Last primary vertex is dummy - m_TH1["akt4jvftot"]->Fill(jvfsum, wt); - for(unsigned int ii=0; ii<jvfvec.size()-1; ++ii ){ - if( (int)ii != iVertex ) m_TH1["akt4jvfx"]->Fill(jvfvec[ii] , wt); - } - - // Truth flavor - int trueid = (*akt4Itr3)->getAttribute<int>("TruthLabelID"); - m_TH1["akt4trueid"]->Fill(trueid, wt); - if( trueid == 5 ){ - m_TH1["akt4ptb"]->Fill((*akt4Itr3)->pt()/1000., wt); - m_TH1["akt4etab"]->Fill((*akt4Itr3)->eta(), wt); - } - - // Flavor tagging - // "Probabilities" for SV1 and IP3D make no sense - FIXME. - // MV1 is always zero - FIXME. - const xAOD::BTagging* btag =(*akt4Itr3)->btagging(); - double mv1 = btag->MV1_discriminant(); - m_TH1["akt4mv1"]->Fill(mv1, wt); - m_TH1["akt4sv1b"]->Fill(btag->SV1_pb(), wt); - m_TH1["akt4sv1u"]->Fill(btag->SV1_pu(), wt); - m_TH2["akt4sv1uvb"]->Fill(btag->SV1_pb(),btag->SV1_pu(), wt); - - // Associated tracks - // Use only tracks with at least 1pixel/6SCT hits - // With pileup need Delta z0 cut - // Does not work with thinned tracks - FIXME. - - std::vector<const xAOD::IParticle*> jtracks; - jtracks = (*akt4Itr3)->getAssociatedObjects<xAOD::IParticle>( xAOD::JetAttribute::GhostTrack ); - int ntracks = 0; - TLorentzVector psum(0,0,0,0); - for(unsigned int jj=0; jj<jtracks.size(); ++jj){ - const xAOD::TrackParticle* trkjj = dynamic_cast<const xAOD::TrackParticle*>(jtracks[jj]); - if( trkjj->pt() < 1000 ) continue; - uint8_t npix = 0; - uint8_t nsct = 0; - if( !trkjj->summaryValue(npix,xAOD::numberOfPixelHits)) continue; - if( !trkjj->summaryValue(nsct,xAOD::numberOfSCTHits)) continue; - m_TH1["akt4nsitrk"]->Fill(npix+nsct, wt); - if( npix<1 || nsct<6 ) continue; - // z for track and primary vertex in different frames - float dz0 = trkjj->z0()+trkjj->vz() - z0PV; - m_TH1["akt4dz0trk"]->Fill( dz0, wt); - if( std::abs( dz0*sin(trkjj->theta())) > 1.5 ) continue; - ++ntracks; - TLorentzVector ptrk = trkjj->p4(); - psum += ptrk; - m_TH1["akt4rtrk"]->Fill( pjet.DeltaR(ptrk) , wt); - } - - // Protect against occasional track pt >> 1TeV - double rat = psum.Pt() / (*akt4Itr3)->pt(); - rat = std::min(rat,3.0); - for(unsigned int ib=1; ib<16; ++ib){ - if( ptj>ptLim[ib] && ptj<ptLim[ib+1] ){ - std::string str = "akt4rtrk" + ptStr[ib]; - m_TH1[str.c_str()]->Fill(rat, wt); - } - } - m_TH1["akt4ntrk"]->Fill(ntracks , wt); - - } //end for akt4Itr3 - }//end m_akt4Jets - - - ///////////////////// - // AntiKt4EMTopo Jets - ///////////////////// - - m_aktem4Jets = 0; - if( m_event->contains<xAOD::JetContainer>("AntiKt4EMTopoJets") ){ - if( !m_event->retrieve(m_aktem4Jets, "AntiKt4EMTopoJets") ){ - Error("execute()", "Failed to retrieve AntiKt4EMTopoJets. Exiting."); - return EL::StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - Warning("execute()", "Did not find AntiKt4EMTopoJets."); - } - ++m_warnCounter; - } - - if( m_aktem4Jets ){ - xAOD::JetContainer::const_iterator aktem4Itr = m_aktem4Jets->begin(); - xAOD::JetContainer::const_iterator aktem4ItrE = m_aktem4Jets->end(); - - // This is a simple example utilizing a deep copy for jets to count - // uncalibrated and calibrated jets with pt > 100GeV. - // NOT an efficient way to make this trivial plot. - - int njet100 = 0; - for(; aktem4Itr != aktem4ItrE; ++aktem4Itr){ - TLorentzVector pjet = (*aktem4Itr)->p4(); - xAOD::JetFourMom_t p4aod = (*aktem4Itr)->jetP4(); - if( (*aktem4Itr)->pt() > 100000 ) ++njet100; - - // Make the deep copy. MUST initialize pointer to 0. - xAOD::Jet* calibJet = 0; - m_akt4EMTopoCalibrationTool->calibratedCopy(**aktem4Itr, calibJet); - calibJet->setJetP4("xaodscale",p4aod); - - // ALWAYS give ownership to a DataVector, which can delete properly. - // "delete calibJet" does NOT work. - m_aktem4NewJets->push_back(calibJet); - - // Delete unwanted jet. STL methods for removing items from vectors - // are overloaded to work properly. - if( calibJet->pt() < 100000 ) m_aktem4NewJets->pop_back(); - } - - m_TH1["aktem4n100"]->Fill(njet100, wt); - m_TH1["aktem4ncalib100"]->Fill(m_aktem4NewJets->size(), wt); - }//end m_aktem4Jets - - - ///////////// - // Missing ET - ///////////// - - // First just plot (uncalibrated) MET from xAOD - - const xAOD::MissingETContainer* METFinals = 0; - if( m_event->contains<xAOD::MissingETContainer>("MET_RefFinal") ){ - if( !m_event->retrieve(METFinals, "MET_RefFinal") ){ - Error("execute()", "Failed to retrieve MET_RefFinal. Exiting."); - return EL::StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - Warning("execute()", "Did not find MET_RefFinal."); - } - ++m_warnCounter; - } - - const xAOD::MissingETContainer* METTruths = 0; - if( m_event->contains<xAOD::MissingETContainer>("MET_Truth") ){ - if( !m_event->retrieve(METTruths, "MET_Truth") ){ - Error("execute()", "Failed to retrieve MET_Truth. Exiting."); - return EL::StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - Warning("execute()", "Did not find MET_Truth."); - } - ++m_warnCounter; - } - - // Each MissingETContainer has multiple versions labeled by strings - // See METReaderAlg.cxx. Examples include - // (*METFinals)["Final"] (*METTruths)["NonInt"] - // (*METFinals)["RefEle"] (*METTruths)["Int"] - // (*METFinals)["RefGamma"] (*METTruths)["IntOut"] - // (*METFinals)["RefTau"] (*METTruths)["IntMuons"] - // (*METFinals)["RefJet"] - // (*METFinals)["Muons"] - // (*METFinals)["SoftClus"] - // (*METFinals)["SoftClus"] - - const xAOD::MissingET* metRefFinal = 0; - if( METFinals ) metRefFinal = (*METFinals)["Final"]; - const xAOD::MissingET* metTruth = 0; - if( METTruths ) metTruth = (*METTruths)["NonInt"]; - - if( metRefFinal ){ - m_TH1["metet"]->Fill( metRefFinal->met()/1000., wt); - m_TH1["metetlo"]->Fill( metRefFinal->met()/1000., wt); - m_TH1["metsum"]->Fill( metRefFinal->sumet()/1000., wt); - } - - if( metTruth ){ - m_TH1["mettrueet"]->Fill(metTruth->met()/1000., wt); - m_TH1["mettrueetlo"]->Fill(metTruth->met()/1000., wt); - m_TH1["mettruesum"]->Fill(metTruth->sumet()/1000., wt); - } - - // Recalculate MET with calibrated jets - // Remaining inputs are default - see initialize() - - if( !m_metRebuilder->execute() ){ - Error("execute()", "Failed to execute METRebuilder. Exiting."); - return EL::StatusCode::FAILURE; - } - - // Retrieve new MET - name set in initialize(). - - m_metCalibs = 0; - if( !m_store->retrieve(m_metCalibs, "MET_CalibFinal") ){ - Error("execute()", "Failed to retrieve MET_CalibFinal. Exiting."); - return EL::StatusCode::FAILURE; - } - const xAOD::MissingET* metCalibFinal = 0; - if( m_metCalibs ) metCalibFinal = (*m_metCalibs)["Final"]; - - // Histogram new MET - if( metCalibFinal ){ - m_TH1["metcalibet"]->Fill( metCalibFinal->met()/1000., wt); - m_TH1["metcalibetlo"]->Fill( metCalibFinal->met()/1000., wt); - m_TH1["metcalibsum"]->Fill( metCalibFinal->sumet()/1000., wt); - } - - - //////////////////////// - // Clear copy containers - //////////////////////// - - // Deep copies. Clearing containers deletes contents including AuxStore. - m_newMuons->clear(); - m_newElectrons->clear(); - m_newTauJets->clear(); - - // For AntiKt4LCTopo shallow copy - // Clearing view container does not delete contents - // m_akt4CopyJets saved in TStore so NOT deleted. - m_akt4ViewJets->clear(); - - // For AntiKt4EMTopo deep copy - // Clearing container deletes contents - m_aktem4NewJets->clear(); - - // Clear transient store - m_store->clear(); - - - // Close with a message: - if( ((m_eventCounter-1) % 100) == 0 ){ - Info( "execute()", - "===>>> done processing event #%i, " - "run #%i %i events processed so far <<<===", - static_cast< int >( eventInfo->eventNumber() ), - static_cast< int >( eventInfo->runNumber() ), - static_cast< int >( m_eventCounter ) ); - Info("execute()","Processing rate = %f Hz", float(m_eventCounter)/(time(NULL)-m_startTime)); - } - - return EL::StatusCode::SUCCESS; -} - - - -EL::StatusCode xExample :: postExecute (){ - - // Here you do everything that needs to be done after the main event - // processing. This is typically very rare, particularly in user - // code. It is mainly used in implementing the NTupleSvc. - - return EL::StatusCode::SUCCESS; -} - - - -EL::StatusCode xExample :: finalize (){ - - // This method is the mirror image of initialize(), meaning it gets - // called after the last event has been processed on the worker node - // and allows you to finish up any objects you created in - // initialize() before they are written to disk. This is actually - // fairly rare, since this happens separately for each worker node. - // Most of the time you want to do your post-processing on the - // submission node after all your histogram outputs have been - // merged. This is different from histFinalize() in that it only - // gets called on worker nodes that processed input events. - return EL::StatusCode::SUCCESS; -} - - - -EL::StatusCode xExample :: histFinalize (){ - - // This method is the mirror image of histInitialize(), meaning it - // gets called after the last event has been processed on the worker - // node and allows you to finish up any objects you created in - // histInitialize() before they are written to disk. This is - // actually fairly rare, since this happens separately for each - // worker node. Most of the time you want to do your - // post-processing on the submission node after all your histogram - // outputs have been merged. This is different from finalize() in - // that it gets called on all worker nodes regardless of whether - // they processed input events. - - Info( "histFinalize()","Finished processing %i events",m_eventCounter); - Info("histFinalize()","Produced %i retrieve warnings", m_warnCounter); - - - - return EL::StatusCode::SUCCESS; -} - -#endif diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/xExampleUtils.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/xExampleUtils.cxx deleted file mode 100644 index 45b74349bf21dc7af88ba540cba36bddb0687acb..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/Root/xExampleUtils.cxx +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -////////////////////////// -// TruthParticle Utilities -////////////////////////// - -#include "CPAnalysisExamples/xExampleUtils.h" -#include "xAODTruth/TruthParticleContainer.h" -#include "xAODTruth/TruthVertexContainer.h" - -#include <vector> - -// Long-lived B hadron (5x1,5xx2) -bool isBHadron(const xAOD::TruthParticle* p){ - int ida = TMath::Abs( p->pdgId() ); - if( ida > 10000 || ida < 100 ) return false; - if( ida > 1000 ){ - if( ida==5112 || ida==5132 || ida==5232 || ida==5332 ){ - return true; - } else { - return false; - } - } - if( (ida/100)%10==5 && ida%10==1 ) return true; - return false; -} - -// Implement HepMC isGenStable -bool isGenStable(const xAOD::TruthParticle* p){ - if( p->barcode() > 200000 ) return false; - if( p->pdgId() == 21 && p->e() == 0 ) return false; - if( p->status()%1000 == 1 ) return true; - if( p->hasDecayVtx() ){ - const xAOD::TruthVertex* dvtx = p->decayVtx(); - if( dvtx ){ - if( p->status() == 2 && dvtx->barcode() < -200000 ) return true; - } - } - if( p->status()%1000 == 2 && p->status() > 1000 ) return true; - return false; -} - -// Emulate HepMC descendant iterator -// Multiple particles can give same descendant (string/cluster) -// Remove Geant descendants -// MUST check ElementLink validity with isValid() for thinned samples - -int getDescendants(const xAOD::TruthParticle* p, - std::vector< const xAOD::TruthParticle* >& dscd ){ - dscd.clear(); - if( ! (p->hasDecayVtx()) ) return 0; - const xAOD::TruthVertex* dvtx = p->decayVtx(); - if( !dvtx ) return 0; - - const std::vector< ElementLink< xAOD::TruthParticleContainer > >& outPart = - dvtx->outgoingParticleLinks(); - int nkid = outPart.size(); - for(int k=0; k<nkid; ++k){ - if( ! (outPart[k]).isValid() ) continue; - const xAOD::TruthParticle* kid = *(outPart[k]); - dscd.push_back(kid); - } - - int nstart = 0; - int nstop = dscd.size(); - - while( nstop > nstart ){ - for(int i=nstart; i<nstop; ++i){ - const xAOD::TruthParticle* pp = dscd[i]; - if( ! (pp->hasDecayVtx()) ) continue; - const xAOD::TruthVertex* vpp = pp->decayVtx(); - if( !vpp ) continue; - if( vpp->barcode() < -200000 ) continue; - const std::vector< ElementLink< xAOD::TruthParticleContainer > >& - outPart2 = vpp->outgoingParticleLinks(); - unsigned int npp = outPart2.size(); - for(unsigned int k=0; k<npp; ++k){ - if( ! (outPart2[k]).isValid() ) continue; - const xAOD::TruthParticle* kpp = *(outPart2[k]); - if( kpp->barcode() > 200000 ) continue; - bool isIn = false; - for(unsigned int kk=0; kk<dscd.size(); ++kk) if(kpp==dscd[kk]) isIn = true; - if( !isIn ) dscd.push_back(kpp); - } - } - nstart = nstop; - nstop = dscd.size(); - } - - return nstop; -} diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/data/BTagCalibration.env b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/data/BTagCalibration.env deleted file mode 100644 index 07ba4c5cea581a66e3ed0e4d9000c6f92fc3686f..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/data/BTagCalibration.env +++ /dev/null @@ -1,3 +0,0 @@ -# the ROOT file containing the calibration curves -File: $ROOTCOREBIN/data/CPAnalysisExamples/2013-Winter-rel17.2.1.4_MC12.root - diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/python/BrowseXAODfromRoot.py b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/python/BrowseXAODfromRoot.py deleted file mode 100644 index 1bec583038d68f5c5212735c11a6187156e6a553..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/python/BrowseXAODfromRoot.py +++ /dev/null @@ -1,76 +0,0 @@ -#! /usr/bin/evn python - -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - -import ROOT -import os, sys - -if len(sys.argv) < 2: - print "USAGE: " + sys.argv[0] + " [filename]" - sys.exit(-1) - -filename = sys.argv[1] - -# check if the file is there - -if not os.path.isfile(filename): - print "Sorry, no file named " + filename + ", gently exiting..." - sys.exit(-1) - -#Load the RootCore libraries - -ROOT.gROOT.ProcessLine(".x $ROOTCOREDIR/scripts/load_packages.C"); - -# Initialize root to use xAOD - -ROOT.xAOD.Init() - -f = ROOT.TFile.Open(filename,"read"); # Just an example xAOD file - -if not f.IsOpen(): - print "Can't open " + filename + ", exiting" - -# Get a tree from the xAOD file - -thetree = ROOT.xAOD.MakeTransientTree(f); - -# Ready to play with the tree - -C1 = ROOT.TCanvas() -C1.cd(); -#Draw eta of the full jet container - -h_jetEta = ROOT.TH1F("h_jetEta","eta of all jets in the container",100,-5,5) - -thetree.Draw("AntiKt4LCTopoJets.eta() >> h_jetEta"); - -# Now make a loop. Compute and plot the eta separation between the two leading jets -# Also, save the histogram in a file - -outfile = ROOT.TFile("output.root","recreate") - -h_deltaEta = ROOT.TH1F("h_deltaEta","Eta separation between leading jets",10,0,5); - -totalEntries = thetree.GetEntries() - -print ("There are %g events in this tree" % totalEntries) - -for ev in thetree: - - print ("There are %i jets in the jet container" % len(ev.AntiKt4LCTopoJets)) - - # count the number of central jets with pt > 20 GeV - - nj = 0 - - for jet in ev.AntiKt4LCTopoJets: - if jet.pt() > 20000 and ROOT.TMath.Abs(jet.eta()) < 2.5: - nj = nj + 1 - - if nj >= 2: - h_deltaEta.Fill(ev.AntiKt4LCTopoJets[0].eta() - ev.AntiKt4LCTopoJets[1].eta()) - -outfile.cd() -h_jetEta.Write() -h_deltaEta.Write() -outfile.Close() diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/scripts/BrowseXAODfromRoot.C b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/scripts/BrowseXAODfromRoot.C deleted file mode 100644 index 9ca7699bd096eda91e7c5c81d7732d7987e81e47..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/scripts/BrowseXAODfromRoot.C +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -{ - gROOT.Reset(); - - // Load the RootCore libraries - - gROOT.ProcessLine(".x $ROOTCOREDIR/scripts/load_packages.C"); - - // Initialize root to use xAOD - - xAOD::Init(); - - TString filename = "/afs/cern.ch/work/k/krasznaa/public/xAOD/19.0.X_rel_4/mc12_8TeV.105200.McAtNloJimmy_CT10_ttbar_LeptonFilter.AOD.19.0.X_rel_4.pool.root"; - - TFile * f = TFile::Open(filename,"read"); // Just an example xAOD file - - if (!f) std::cerr << "Can't open " << filename << std::endl; - - // Get a tree from the xAOD file - - TTree * thetree = xAOD::MakeTransientTree(f); - - // Ready to play with the tree - - TCanvas C1; - C1.cd(); - - // Draw eta of the full electron container - - thetree.Draw("ElectronCollection.eta()"); - - TCanvas C2; - C2.cd(); - - // Draw the eta of the associated track - - thetree.Draw("ElectronCollection.trackParticle().eta()"); - - TCanvas C3; - - // Plot the number of jet constituents Vs jet pt - - TH2F * constHist = new TH2F("constHist","my favourite plot",100,0,500000,50,0,50); - - thetree.Draw("AntiKt4LCTopoJets.numConstituents():AntiKt4LCTopoJets.pt() >> constHist"); - - constHist->Draw("COLZ"); - -} diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/scripts/run.C b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/scripts/run.C deleted file mode 100644 index 1ae977b2be3e13bdd0c895b70b732254cc63f866..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/scripts/run.C +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -void run(string submitDir="output") { - string origDir = submitDir; - gROOT->ProcessLine(".x $ROOTCOREDIR/scripts/load_packages.C"); - SH::SampleHandler sh; - SH::scanDir (sh, "/afs/cern.ch/user/j/jahreda/work/public/ntuples"); - sh.setMetaString ("nc_tree", "physics"); - sh.print (); - EL::Job job; - job.useD3PDReader(); - job.sampleHandler (sh); - job.options()->setDouble (EL::Job::optCacheSize, 10*1024*1024); - CPAnalysisExample *alg = new CPAnalysisExample; - job.algsAdd (alg); - job.options()->setDouble("elePtCut",15*1000); - job.options()->setDouble("muPtCut",10*1000); - job.options()->setDouble("metPtCut",30*1000); - job.options()->setDouble("jetPtCut",25*1000); - EL::DirectDriver driver; - Long_t *id,*size,*flags,*mt; - Int_t version(0); - while (!gSystem->GetPathInfo(submitDir.c_str(),id,size,flags,mt)) { - version++; - submitDir = string(Form("%s_%d",origDir.c_str(),version)); - } - cerr << "Submitting to " << submitDir << endl; - driver.submit (job, submitDir); -} diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/scripts/xExample_run.C b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/scripts/xExample_run.C deleted file mode 100644 index 1c5f37a6e98626fdb626b25fb76d74a8abef04b2..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/scripts/xExample_run.C +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -void xExample_run(string submitDir="output") { - string origDir = submitDir; - gROOT->ProcessLine(".x $ROOTCOREDIR/scripts/load_packages.C"); - xAOD::Init().ignore(); - SH::SampleHandler sh; - SH::DiskListLocal list ("/afs/cern.ch/atlas/project/PAT/tutorial/cern-oct2014/r5591"); - SH::scanDir (sh,list,"AOD.01494882._113691.pool.root.1" ); - sh.setMetaString ("nc_tree", "CollectionTree"); - sh.print (); - EL::Job job; - job.sampleHandler (sh); - //job.options()->setDouble (EL::Job::optCacheSize, 10*1024*1024); - xExample *alg = new xExample; - job.algsAdd (alg); - EL::DirectDriver driver; - cerr << "Submitting to " << submitDir << endl; - driver.submit (job, submitDir); -} diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/CPAnalysisExamples_jobOptions.py b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/CPAnalysisExamples_jobOptions.py deleted file mode 100644 index 090f6a14049378cc99ad7e51faf8af327fb032fe..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/CPAnalysisExamples_jobOptions.py +++ /dev/null @@ -1,29 +0,0 @@ -# $Id: CPAnalysisExamples_jobOptions.py 300492 2014-04-30 14:39:05Z krasznaa $ - -# Set up the file reading: -FNAME = "/afs/cern.ch/atlas/project/PAT/data/xAOD/19.0.X_rel_4/mc12_8TeV.105200.McAtNloJimmy_CT10_ttbar_LeptonFilter.AOD.19.0.X_rel_4.pool.root" -FNAME = "/afs/cern.ch/user/i/ivivarel/work/DATA/mc14_8TeV.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e1727_s1933_s1911_r5591_tid01494883_00/AOD.01494883._116110.pool.root.1" -#FNAME = "/afs/cern.ch/atlas/project/PAT/data/xAOD/19.0.X_rel_4/mc12_8TeV.147807.PowhegPythia8_AU2CT10_Zmumu.AOD.19.0.X_rel_4.pool.root" -#FNAME = "/afs/cern.ch/atlas/project/PAT/data/xAOD/19.0.X_rel_4/valid1.105200.McAtNloJimmy_CT10_ttbar_LeptonFilter.AOD.19.0.X_rel_4.pool.root" - -import AthenaPoolCnvSvc.ReadAthenaPool -ServiceMgr.EventSelector.InputCollections = [ FNAME ] - -# Access the algorithm sequence: -from AthenaCommon.AlgSequence import AlgSequence -theJob = AlgSequence() - -# Add the test algorithm: -from CPAnalysisExamples.CPAnalysisExamplesConf import CP__ToolTester -alg = CP__ToolTester() -alg.MuonSelectionToolExample.MaxEta = 2.4 -alg.MuonSelectionToolExample.Author = 12 -alg.MuonEfficiencyToolExample.DummyProperty = 5.5 -alg.OutputLevel = DEBUG -theJob += alg - -# Do some additional tweaking: -from AthenaCommon.AppMgr import theApp -theApp.EvtMax = 10 -ServiceMgr.MessageSvc.OutputLevel = INFO -ServiceMgr.MessageSvc.defaultLimit = 1000000 diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/Test__EgammaCalibrationAndSmearingToolJobOptions.py b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/Test__EgammaCalibrationAndSmearingToolJobOptions.py deleted file mode 100644 index 3725545d275d73776aa8b79a97bd5fa4b98a292b..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/Test__EgammaCalibrationAndSmearingToolJobOptions.py +++ /dev/null @@ -1,51 +0,0 @@ -#Skeleton joboption for a simple analysis job - -theApp.EvtMax=1000 #says how many events to run over. Set to -1 for all events - -import AthenaPoolCnvSvc.ReadAthenaPool -svcMgr.EventSelector.InputCollections=[os.environ['ASG_TEST_FILE_MC']] #insert your list of input files here - - - -algseq = CfgMgr.AthSequencer("AthAlgSeq") #gets the main AthSequencer -algseq += CfgMgr.Test__EgammaCalibrationAndSmearingTool() #adds an instance of your alg to it - -svcMgr.ChronoStatSvc.PrintEllapsedTime=True #show the wall clock time -svcMgr.AthenaEventLoopMgr.UseDetailChronoStat=True #show event loop execution time statistics - - -##-------------------------------------------------------------------- -## This section shows up to set up a HistSvc output stream for outputing histograms and trees -## See https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/AthAnalysisBase#How_to_output_trees_and_histogra for more details and examples - -if not hasattr(svcMgr, 'THistSvc'): svcMgr += CfgMgr.THistSvc() #only add the histogram service if not already present (will be the case in this jobo) -svcMgr.THistSvc.Output += ["MYSTREAM DATAFILE='Test_EgammaCalibrationAndSmearingTool.results.root' OPT='RECREATE'"] #add an output root file stream - -##-------------------------------------------------------------------- - - -##-------------------------------------------------------------------- -## The lines below are an example of how to create an output xAOD -## See https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/AthAnalysisBase#How_to_create_an_output_xAOD for more details and examples - -#from OutputStreamAthenaPool.MultipleStreamManager import MSMgr -#xaodStream = MSMgr.NewPoolRootStream( "StreamXAOD", "xAOD.out.root" ) - -##EXAMPLE OF BASIC ADDITION OF EVENT AND METADATA ITEMS -##AddItem and AddMetaDataItem methods accept either string or list of strings -#xaodStream.AddItem( ["xAOD::JetContainer#*","xAOD::JetAuxContainer#*"] ) #Keeps all JetContainers (and their aux stores) -#xaodStream.AddMetaDataItem( ["xAOD::TriggerMenuContainer#*","xAOD::TriggerMenuAuxContainer#*"] ) -#ToolSvc += CfgMgr.xAODMaker__TriggerMenuMetaDataTool("TriggerMenuMetaDataTool") #MetaDataItems needs their corresponding MetaDataTool -#svcMgr.MetaDataSvc.MetaDataTools += [ ToolSvc.TriggerMenuMetaDataTool ] #Add the tool to the MetaDataSvc to ensure it is loaded - -##EXAMPLE OF SLIMMING (keeping parts of the aux store) -#xaodStream.AddItem( ["xAOD::ElectronContainer#Electrons","xAOD::ElectronAuxContainer#ElectronsAux.pt.eta.phi"] ) #example of slimming: only keep pt,eta,phi auxdata of electrons - -##EXAMPLE OF SKIMMING (keeping specific events) -#xaodStream.AddAcceptAlgs( "Test__EgammaCalibrationAndSmearingTool" ) #will only keep events where 'setFilterPassed(false)' has NOT been called in the given algorithm - -##-------------------------------------------------------------------- - - -#include("AthAnalysisBaseComps/SuppressLogging.py") #Optional include to suppress as much athena output as possible. Keep at bottom of joboptions so that it doesn't suppress the logging of the things you have configured above - diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/Test__EgammaCalibrationAndSmearingToolJobOptions_ReadAthenaxAODHybrid.py b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/Test__EgammaCalibrationAndSmearingToolJobOptions_ReadAthenaxAODHybrid.py deleted file mode 100644 index f90c0a92609bd19ad6a89094efaa3ea7d43eb12d..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/Test__EgammaCalibrationAndSmearingToolJobOptions_ReadAthenaxAODHybrid.py +++ /dev/null @@ -1,50 +0,0 @@ -#Skeleton joboption for a simple analysis job - -theApp.EvtMax=-1 #says how many events to run over. Set to -1 for all events - -import AthenaRootComps.ReadAthenaxAODHybrid #read xAOD with TEvent but the metadata with pool -svcMgr.EventSelector.AccessMode = 2 #0 = branch, 1 = class, 2 = athena, -1 = default ... we have to use 2 with the default test file in the releases -svcMgr.EventSelector.InputCollections=[os.environ['ASG_TEST_FILE_MC']] #insert your list of input files here - -algseq = CfgMgr.AthSequencer("AthAlgSeq") #gets the main AthSequencer -algseq += CfgMgr.Test__EgammaCalibrationAndSmearingTool() #adds an instance of your alg to it - -svcMgr.ChronoStatSvc.PrintEllapsedTime=True #show the wall clock time -svcMgr.AthenaEventLoopMgr.UseDetailChronoStat=True #show event loop execution time statistics - - -##-------------------------------------------------------------------- -## This section shows up to set up a HistSvc output stream for outputing histograms and trees -## See https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/AthAnalysisBase#How_to_output_trees_and_histogra for more details and examples - -#if not hasattr(svcMgr, 'THistSvc'): svcMgr += CfgMgr.THistSvc() #only add the histogram service if not already present (will be the case in this jobo) -#svcMgr.THistSvc.Output += ["MYSTREAM DATAFILE='myfile.root' OPT='RECREATE'"] #add an output root file stream - -##-------------------------------------------------------------------- - - -##-------------------------------------------------------------------- -## The lines below are an example of how to create an output xAOD -## See https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/AthAnalysisBase#How_to_create_an_output_xAOD for more details and examples - -#from OutputStreamAthenaPool.MultipleStreamManager import MSMgr -#xaodStream = MSMgr.NewPoolRootStream( "StreamXAOD", "xAOD.out.root" ) - -##EXAMPLE OF BASIC ADDITION OF EVENT AND METADATA ITEMS -##AddItem and AddMetaDataItem methods accept either string or list of strings -#xaodStream.AddItem( ["xAOD::JetContainer#*","xAOD::JetAuxContainer#*"] ) #Keeps all JetContainers (and their aux stores) -#xaodStream.AddMetaDataItem( ["xAOD::TriggerMenuContainer#*","xAOD::TriggerMenuAuxContainer#*"] ) -#ToolSvc += CfgMgr.xAODMaker__TriggerMenuMetaDataTool("TriggerMenuMetaDataTool") #MetaDataItems needs their corresponding MetaDataTool -#svcMgr.MetaDataSvc.MetaDataTools += [ ToolSvc.TriggerMenuMetaDataTool ] #Add the tool to the MetaDataSvc to ensure it is loaded - -##EXAMPLE OF SLIMMING (keeping parts of the aux store) -#xaodStream.AddItem( ["xAOD::ElectronContainer#Electrons","xAOD::ElectronAuxContainer#ElectronsAux.pt.eta.phi"] ) #example of slimming: only keep pt,eta,phi auxdata of electrons - -##EXAMPLE OF SKIMMING (keeping specific events) -#xaodStream.AddAcceptAlgs( "Test__EgammaCalibrationAndSmearingTool" ) #will only keep events where 'setFilterPassed(false)' has NOT been called in the given algorithm - -##-------------------------------------------------------------------- - - -#include("AthAnalysisBaseComps/SuppressLogging.py") #Optional include to suppress as much athena output as possible. Keep at bottom of joboptions so that it doesn't suppress the logging of the things you have configured above - diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/Test__TrackLinkTestJobOptions.py b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/Test__TrackLinkTestJobOptions.py deleted file mode 100644 index cd9fcddb85bf5c9946083500702cf6e590a6898e..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/Test__TrackLinkTestJobOptions.py +++ /dev/null @@ -1,47 +0,0 @@ -#Skeleton joboption for a simple analysis job - -theApp.EvtMax=10 #says how many events to run over. Set to -1 for all events - -import AthenaPoolCnvSvc.ReadAthenaPool #sets up reading of POOL files (e.g. xAODs) -svcMgr.EventSelector.InputCollections=[os.environ['ASG_TEST_FILE_MC']] #insert your list of input files here - -algseq = CfgMgr.AthSequencer("AthAlgSeq") #gets the main AthSequencer -algseq += CfgMgr.Test__TrackLinkTest() #adds an instance of your alg to it - - - -##-------------------------------------------------------------------- -## This section shows up to set up a HistSvc output stream for outputing histograms and trees -## See https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/AthAnalysisBase#How_to_output_trees_and_histogra for more details and examples - -#if not hasattr(svcMgr, 'THistSvc'): svcMgr += CfgMgr.THistSvc() #only add the histogram service if not already present (will be the case in this jobo) -#svcMgr.THistSvc.Output += ["MYSTREAM DATAFILE='myfile.root' OPT='RECREATE'"] #add an output root file stream - -##-------------------------------------------------------------------- - - -##-------------------------------------------------------------------- -## The lines below are an example of how to create an output xAOD -## See https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/AthAnalysisBase#How_to_create_an_output_xAOD for more details and examples - -#from OutputStreamAthenaPool.MultipleStreamManager import MSMgr -#xaodStream = MSMgr.NewPoolRootStream( "StreamXAOD", "xAOD.out.root" ) - -##EXAMPLE OF BASIC ADDITION OF EVENT AND METADATA ITEMS -##AddItem and AddMetaDataItem methods accept either string or list of strings -#xaodStream.AddItem( ["xAOD::JetContainer#*","xAOD::JetAuxContainer#*"] ) #Keeps all JetContainers (and their aux stores) -#xaodStream.AddMetaDataItem( ["xAOD::TriggerMenuContainer#*","xAOD::TriggerMenuAuxContainer#*"] ) -#ToolSvc += CfgMgr.xAODMaker__TriggerMenuMetaDataTool("TriggerMenuMetaDataTool") #MetaDataItems needs their corresponding MetaDataTool -#svcMgr.MetaDataSvc.MetaDataTools += [ ToolSvc.TriggerMenuMetaDataTool ] #Add the tool to the MetaDataSvc to ensure it is loaded - -##EXAMPLE OF SLIMMING (keeping parts of the aux store) -#xaodStream.AddItem( ["xAOD::ElectronContainer#Electrons","xAOD::ElectronAuxContainer#ElectronsAux.pt.eta.phi"] ) #example of slimming: only keep pt,eta,phi auxdata of electrons - -##EXAMPLE OF SKIMMING (keeping specific events) -#xaodStream.AddAcceptAlgs( "Test__TrackLinkTest" ) #will only keep events where 'setFilterPassed(false)' has NOT been called in the given algorithm - -##-------------------------------------------------------------------- - - -include("AthAnalysisBaseComps/SuppressLogging.py") #Optional include to suppress as much athena output as possible. Keep at bottom of joboptions so that it doesn't suppress the logging of the things you have configured above - diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/TooExamplesJobOptions.py b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/TooExamplesJobOptions.py deleted file mode 100644 index f29d07251cddb1e164dda3184a74be5111915d0d..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/TooExamplesJobOptions.py +++ /dev/null @@ -1,241 +0,0 @@ - -#==================================================== -#Imports - EXPERTS ONLY -#------------------------- -import ROOT -from AthenaCommon.AthenaCommonFlags import athenaCommonFlags -import AthenaRootComps.ReadAthenaxAODHybrid #fast xAODReading -#import AthenaPoolCnvSvc.ReadAthenaPool #alternative but more robust POOL reading -from PyUtils import AthFile #file metadata access in joboptions -#==================================================== - - -#==================================================== -#Basic Job Configuration -#------------------------- -algseq = CfgMgr.AthSequencer("AthAlgSeq") #gets the main AthSequencer -algseq += CfgMgr.ToolExamplesAlg("MyAlg") #Add Algorithm to sequence -#==================================================== - - -#==================================================== -#Basic Job Settings -#------------------------- - -athenaCommonFlags.EvtMax = 10 #number of events to process -athenaCommonFlags.FilesInput = [os.environ['ASG_TEST_FILE_MC']] #list of input files - -svcMgr.EventSelector.AccessMode = 2 #0 = branch, 1 = class, 2 = athena -#==================================================== - - - -#==================================================== -#Metadata extraction - EXPERTS ONLY -#------------------------- -#this fills a dictionary with useful metadata about the input file - used in configurations below -#see https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/AthAnalysisBase#How_to_access_file_metadata_at_t -metadata = dict() -af = AthFile.fopen(athenaCommonFlags.FilesInput()[0]) #extra metadata from first input file -metadata['streamName'] = af.fileinfos['stream_names'] -metadata['isMC'] = ('IS_SIMULATION' in af.fileinfos['evt_type']) -metadata['conditionsTag'] = af.fileinfos['conditions_tag'] -metadata['isFastSim'] = metadata['isMC'] and ('ATLFASTII' in af.fileinfos['metadata']['/Simulation/Parameters']['SimulationFlavour'].upper()) -metadata['datasetNumber'] = af.mc_channel_numbers[0] -#==================================================== - - - - - -#==================================================== -#Tool Configurations -#------------------------- - -#Notes: -# Any property listed here is one should ensure is set correctly - - -#----------------------- -## GENERAL -#----------------------- - -#GRL Selection -#Twiki: -ToolSvc += CfgMgr.GoodRunsListSelectionTool("GRLTool") -ToolSvc.GRLTool.GoodRunsListVec=["dev/GoodRunsLists/data15_13TeV/latest/physics_25ns_20.7.xml", #replace with your GRL - "dev/GoodRunsLists/data16_13TeV/latest/physics_25ns_20.7.xml"] - - -#Pileup Reweighting -#Twiki: https://twiki.cern.ch/twiki/bin/view/AtlasProtected/ExtendedPileupReweighting -ToolSvc += CfgMgr.CP__PileupReweightingTool("PileupReweightingTool") -ToolSvc.PileupReweightingTool.ConfigFiles=["dev/PileupReweighting/mc15c_v2_defaults.NotRecommended.prw.root"] #replace with your PRW config files -ToolSvc.PileupReweightingTool.LumiCalcFiles=["dev/GoodRunsLists/data15_13TeV/latest/physics_25ns_20.7.lumicalc.OflLumi-13TeV-005.root", #replace with your lumicalc files - "dev/GoodRunsLists/data16_13TeV/latest/physics_25ns_20.7.lumicalc.OflLumi-13TeV-005.root"] -ToolSvc.PileupReweightingTool.DataScaleFactor=1./1.16 #see twiki -ToolSvc.PileupReweightingTool.DataScaleFactorUP=1. #see twiki -ToolSvc.PileupReweightingTool.DataScaleFactorDOWN=1./1.23 #see twiki - - -#Trigger Decision -#Twiki: -ToolSvc += CfgMgr.Trig__TrigDecisionTool("TrigDecisionTool") - -#Trigger Matching -#Twiki: https://twiki.cern.ch/twiki/bin/view/Atlas/XAODMatchingTool -ToolSvc += CfgMgr.Trig__MatchingTool("TrigMatchingTool") -ToolSvc.TrigMatchingTool.TrigDecisionTool = ToolSvc.TrigDecisionTool - - - -#----------------------- -## ELECTRONS -#----------------------- -#Calibration -#Twiki: -ToolSvc += CfgMgr.CP__EgammaCalibrationAndSmearingTool("EgammaCalibTool") -ToolSvc.EgammaCalibTool.ESModel="es2016PRE" -ToolSvc.EgammaCalibTool.decorrelationModel="1NP_v1" -ToolSvc.EgammaCalibTool.useAFII=metadata['isFastSim'] - -#Isolation Calibration -#Twiki: -ToolSvc += CfgMgr.CP__IsolationCorrectionTool("IsolationCorrectionTool") -ToolSvc.IsolationCorrectionTool.IsMC=metadata['isMC'] -ToolSvc.IsolationCorrectionTool.AFII_corr=ToolSvc.EgammaCalibTool.useAFII - -#Selection -#Twiki: -ToolSvc += CfgMgr.AsgElectronLikelihoodTool("ElectronSelectionTool") -ToolSvc.ElectronSelectionTool.ConfigFile="ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodLooseOfflineConfig2016_CutBL_Smooth.conf" -#loose is "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodLooseOfflineConfig2016_CutBL_Smooth.conf" -#medium is "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodMediumOfflineConfig2016_Smooth.conf" -#vloose is "ElectronPhotonSelectorTools/offline/mc15_20160512/ElectronLikelihoodVeryLooseOfflineConfig2016_Smooth.conf" - -#Isolation Selection -#Twiki: -ToolSvc += CfgMgr.CP__IsolationSelectionTool("ElectronIsolationTool") -ToolSvc.ElectronIsolationTool.ElectronWP = "Loose" #Loose, Tight, FixedCutLoose, FixedCutTight, LooseTrackOnly, TightTrackOnly, Gradient - -#Isolation CloseBy Correction -#Twiki: -ToolSvc += CfgMgr.CP__IsolationCloseByCorrectionTool("ElectronIsolationCloseByCorrectionTool") -ToolSvc.ElectronIsolationCloseByCorrectionTool.IsolationSelectionTool=ToolSvc.ElectronIsolationTool - -#ScaleFactors need the following 'code' -dataTypeCode = 0 #data -if metadata['isMC']: - if metadata['isFastSim']: dataTypeCode=3 #fastsim - else: dataTypeCode = 1 #fullsim - -#Reco ScaleFactor -#Twiki: https://twiki.cern.ch/twiki/bin/view/AtlasProtected/ElectronEfficiencyCorrelationModel -ToolSvc += CfgMgr.AsgElectronEfficiencyCorrectionTool("ElectronRecoSF") -ToolSvc.ElectronRecoSF.ForceDataType=dataTypeCode -ToolSvc.ElectronRecoSF.CorrelationModel="TOTAL" #FULL (~240 systematics), SIMPLIFIED (~25 systematics), TOTAL (1 systematic), COMBMCTOYS (see ElectronEffcieincyCorrelationModel) -#ToolSvc.ElectronRecoSF.NumberOfToys=40 -- set this if using COMBMCTOYS -ToolSvc.ElectronRecoSF.CorrectionFileNameList=["ElectronEfficiencyCorrection/2015_2016/rel20.7/ICHEP_June2016_v3/offline/efficiencySF.offline.RecoTrk.root"] - - -#ID ScaleFactor -#Twiki: https://twiki.cern.ch/twiki/bin/view/AtlasProtected/ElectronEfficiencyCorrelationModel -ToolSvc += CfgMgr.AsgElectronEfficiencyCorrectionTool("ElectronIDSF") -ToolSvc.ElectronIDSF.ForceDataType=dataTypeCode -ToolSvc.ElectronIDSF.CorrelationModel="TOTAL" -ToolSvc.ElectronIDSF.CorrectionFileNameList=["ElectronEfficiencyCorrection/2015_2016/rel20.7/ICHEP_June2016_v3/offline/efficiencySF.offline.LooseAndBLayerLLH_d0z0_v11.root"] -#loose = ["ElectronEfficiencyCorrection/2015_2016/rel20.7/ICHEP_June2016_v3/offline/efficiencySF.offline.LooseAndBLayerLLH_d0z0_v11.root"] -#medium = ?? -#vloose = ?? - - -#Isolation ScaleFactor -#Twiki: https://twiki.cern.ch/twiki/bin/view/AtlasProtected/ElectronEfficiencyCorrelationModel -ToolSvc += CfgMgr.AsgElectronEfficiencyCorrectionTool("ElectronIsolSF") -ToolSvc.ElectronIsolSF.ForceDataType=dataTypeCode -ToolSvc.ElectronIsolSF.CorrelationModel="TOTAL" -ToolSvc.ElectronIsolSF.CorrectionFileNameList=["ElectronEfficiencyCorrection/2015_2016/rel20.7/ICHEP_June2016_v3/isolation/efficiencySF.Isolation.LooseAndBLayerLLH_d0z0_v11_isol" + ToolSvc.ElectronIsolationTool.ElectronWP + ".root"] - - - -#----------------------- -## MUONS -#----------------------- -#Calibration -#Twiki: -ToolSvc += CfgMgr.CP__MuonCalibrationAndSmearingTool("MuonCalibTool") - -#Selection -#Twiki: -ToolSvc += CfgMgr.CP__MuonSelectionTool("MuonSelectionTool") -ToolSvc.MuonSelectionTool.MaxEta = 2.7 -ToolSvc.MuonSelectionTool.MuQuality = 2 #tight = 0, medium = 1, loose = 2 - -#Isolation Selection -#Twiki: -ToolSvc += CfgMgr.CP__IsolationSelectionTool("MuonIsolationTool") -ToolSvc.MuonIsolationTool.MuonWP = "Loose" #Loose, FixedCutLoose, LooseTrackOnly, Gradient - -#Reco ScaleFactor\ -#Twiki: -ToolSvc += CfgMgr.CP__MuonEfficiencyScaleFactors("MuonRecoSF",PileupReweightingTool=ToolSvc.PileupReweightingTool) -if ToolSvc.MuonSelectionTool.MuQuality==0: ToolSvc.MuonRecoSF.WorkingPoint ="Tight" -elif ToolSvc.MuonSelectionTool.MuQuality==1: ToolSvc.MuonRecoSF.WorkingPoint ="Medium" -elif ToolSvc.MuonSelectionTool.MuQuality==2: ToolSvc.MuonRecoSF.WorkingPoint ="Loose" - -#TrackToVertexAssociation (TTVA) ScaleFactor - to be applied if we do the d0 and z0 cuts -#Twiki: -ToolSvc += CfgMgr.CP__MuonEfficiencyScaleFactors("MuonTTVASF",PileupReweightingTool=ToolSvc.PileupReweightingTool) -ToolSvc.MuonTTVASF.WorkingPoint="TTVA" - -#Isolation ScaleFactor -#Twiki: -ToolSvc += CfgMgr.CP__MuonEfficiencyScaleFactors("MuonIsolSF",PileupReweightingTool=ToolSvc.PileupReweightingTool) -ToolSvc.MuonIsolSF.WorkingPoint=ToolSvc.MuonIsolationTool.MuonWP - -#Trigger ScaleFactor -#Twiki: -#??? - -#---------------------- -## JETS -#---------------------- - -#Jet Calibration -#Twiki: https://twiki.cern.ch/twiki/bin/view/AtlasProtected/ApplyJetCalibration2016 -ToolSvc += CfgMgr.JetCalibrationTool("JetCalibTool") -ToolSvc.JetCalibTool.IsData=not metadata['isMC'] -if metadata['isFastSim']: ToolSvc.JetCalibTool.ConfigFile = "JES_MC15Prerecommendation_AFII_June2015.config" -else: ToolSvc.JetCalibTool.ConfigFile="JES_MC15cRecommendation_May2016.config" -ToolSvc.JetCalibTool.CalibSequence="JetArea_Residual_Origin_EtaJES_GSC" -ToolSvc.JetCalibTool.JetCollection="AntiKt4EMTopo" - -#Jet Cleaning -#Twiki: -ToolSvc += CfgMgr.JetCleaningTool("JetCleaningTool") -ToolSvc.JetCleaningTool.CutLevel="LooseBad" -ToolSvc.JetCleaningTool.DoUgly=False - - -#JES Uncertainties -#Twiki: https://twiki.cern.ch/twiki/bin/view/AtlasProtected/JetUncertainties -#??? - -#JER Uncertainties -#Twiki: https://twiki.cern.ch/twiki/bin/view/AtlasProtected/ApplyJetResolutionSmearing -#??? - - -#==================================================== - - -#==================================================== -#EXPERTS ONLY -#------------------------- - -#transfer properties to core components -theApp.EvtMax=athenaCommonFlags.EvtMax() -svcMgr.EventSelector.InputCollections=athenaCommonFlags.FilesInput() - -include("AthAnalysisBaseComps/SuppressLogging.py") #Optional include to suppress as much athena output as possible. Keep at bottom of joboptions so that it doesn't suppress the logging of the things you have configured above -#==================================================== diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/skimmingExampleJobOptions.py b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/skimmingExampleJobOptions.py deleted file mode 100644 index 5f12d60d5e9d6d393323edc6e9b1df18f7fd50fa..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/skimmingExampleJobOptions.py +++ /dev/null @@ -1,44 +0,0 @@ -#Author: Will Buttinger - -#This joboption shows a few examples of how you could define an event selection at the joboption level. -#You can use these techniques in, for example, the skimxAODJobOptions.py - -theApp.EvtMax=10 -import AthenaPoolCnvSvc.ReadAthenaPool -myfile = os.environ.get("ASG_TEST_FILE_MC", "/afs/cern.ch/user/a/asgbase/patspace/xAODs/r6630/mc15_13TeV.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.recon.AOD.e3698_s2608_s2183_r6630_tid05352803_00/AOD.05352803._000242.pool.root.1") -svcMgr.EventSelector.InputCollections = [myfile] -algseq = CfgMgr.AthSequencer("AthAlgSeq") -include("AthAnalysisBaseComps/SuppressLogging.py") #optional to suppress amount of output seen from core services - -#1. Using an existing selector algorithm -#Here we use the PyEvtFilter, which is a python-based selection algorithm - -from GaudiSequencer.PyComps import PyEvtFilter -algseq += PyEvtFilter("MyFilter", evt_list=[(222510,187960),(222510,185506)]) - -#2. Using the expression evaluation code -#Here we will use the CutTool tool, which is effectively an interface to the ExpressionEvaluation code for performing relatively generic selections -#A tool needs to be executed by an algorithm in order to run. We need an algorithm which knows how to execute the CutTool, which implements the ISkimmingTool interface. the DerivationFramework__DerivationKernel is one such algorithm, but there is also the dedicated CutAlg class. We'll use the DerivationKernel here, because it can easily be extended with multiple cut tools. - -ToolSvc += CfgMgr.CutTool("MyCutTool",Cut="EventInfo.eventTypeBitmask==1 && count( (Electrons.pt>20*GeV) && (Electrons.Medium) ) >= 1") -algseq += CfgMgr.DerivationFramework__DerivationKernel("MyKernel",SkimmingTools=[ToolSvc.MyCutTool]) - - -#3. Write your own in-situ python algorithm -# You can write a mini python athena algorithm right in the joboptions, and use that -# Here is an alg that selects events with at least 3 electrons - -import AthenaPython.PyAthena as PyAthena -class MyAlg (PyAthena.Alg): - def execute(self): - self.setFilterPassed(False) #this is the method that algorithms must use to signal if they have 'passed' or not, if they behave as skimmers/filters - print "runNumber = %d , eventNumber = %d\n" % (self.evtStore["EventInfo"].runNumber(),self.evtStore["EventInfo"].eventNumber()) - if( self.evtStore["Electrons"].size()>2 ): self.setFilterPassed(True) - return PyAthena.StatusCode.Success - - -algseq += MyAlg("MyAlg") - - - - diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/skimxAODJobOptions.py b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/skimxAODJobOptions.py deleted file mode 100644 index b11bcfcf6ffbbeba7eb2bc7392bdf5a3c8b09956..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/skimxAODJobOptions.py +++ /dev/null @@ -1,73 +0,0 @@ -#Author: Will Buttinger - -#This is an example of how you could set up a skimming of an xAOD based on Run and Event Numbers -#It is written to work on both the analysis releases and the full athena releases -#Some parts are 'hidden' from the analysis releases, because those features are not yet available there -#If you wish to use this script, please update the relevent parts, which are marked by the SETME comments - - - -theApp.EvtMax=10 #SETME: use -1 to process all input events - -import AthenaPoolCnvSvc.ReadAthenaPool -myfile = os.environ.get("ASG_TEST_FILE_MC", "/afs/cern.ch/user/a/asgbase/patspace/xAODs/r6630/mc15_13TeV.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.recon.AOD.e3698_s2608_s2183_r6630_tid05352803_00/AOD.05352803._000242.pool.root.1") -svcMgr.EventSelector.InputCollections = [myfile] #SETME: put your input files in a list here -algseq = CfgMgr.AthSequencer("AthAlgSeq") - - - -#if we are running in a full athena release we will also set up the calorimeter geometry, to copy the CaloCells -if "AthAnalysisBase" not in os.environ.get("CMTEXTRATAGS",""): - #use the recexconfig AutoConfiguration to set the necessary tags and flags - from AthenaCommon.AthenaCommonFlags import athenaCommonFlags - athenaCommonFlags.FilesInput = svcMgr.EventSelector.InputCollections - from RecExConfig import AutoConfiguration - AutoConfiguration.ConfigureSimulationOrRealData() #this sets AthenaCommon.GlobalFlags.globalflags.DataSource to 'data' or 'geant4' based on input file - AutoConfiguration.ConfigureGeo() - from AthenaCommon.DetFlags import DetFlags - DetFlags.detdescr.all_setOff() - DetFlags.detdescr.Calo_setOn() - #Now load the description, will only load calorimeter, for calocells - include("RecExCond/AllDet_detDescr.py") - - -#use athfile peeking to determine if simulation or data -from PyUtils import AthFile -af = AthFile.fopen(svcMgr.EventSelector.InputCollections[0]) -isMC = 'IS_SIMULATION' in af.fileinfos['evt_type'] - -#also take the stream name from the input file, to ensure the names don't change -streamName = af.fileinfos['stream_names'][0] - -#This is how to configure the PyEvtFilter algorithm, which is designed to 'pick' events -from GaudiSequencer.PyComps import PyEvtFilter -algseq += PyEvtFilter("MyFilter", evt_list=[(222510,187960),(222510,185506)]) #SETME: put the run and event numbers here, as list of (runNum,eventNum) - - -#setup the output stream -from OutputStreamAthenaPool.MultipleStreamManager import MSMgr -xaodStream = MSMgr.NewPoolRootStream( streamName , "xAOD.out.root" ) -xaodStream.Stream.TakeItemsFromInput = True #take all the event payload that analysis releases can read - -#Create the metadata tools for handling the propagation of metadata -ToolSvc += CfgMgr.LumiBlockMetaDataTool("LumiBlockMetaDataTool") #only needed for data -ToolSvc += CfgMgr.xAODMaker__TriggerMenuMetaDataTool( "TriggerMenuMetaDataTool" ) -theApp.CreateSvc += ['CutFlowSvc/CutFlowSvc'] #Not a metadatatool yet :-( -svcMgr.MetaDataSvc.MetaDataTools += [ ToolSvc.TriggerMenuMetaDataTool ] -if not isMC: svcMgr.MetaDataSvc.MetaDataTools += [ ToolSvc.LumiBlockMetaDataTool ] - -#Add Metadata items to the output list. Only the ones that are present will actually get added -xaodStream.AddMetaDataItem(["xAOD::LumiBlockRangeContainer#*","xAOD::LumiBlockRangeAuxContainer#*", - "xAOD::TriggerMenuContainer#*","xAOD::TriggerMenuAuxContainer#*", - "xAOD::CutBookkeeperContainer#*", "xAOD::CutBookkeeperAuxContainer#*"]) - - - -#SETME: uncomment the next line to activate the event skimming. Only events passing the filter will go into the output stream -#xaodStream.AddAcceptAlgs( "MyFilter" ) #SETME: UNCOMMENT THIS LINE FOR THE SKIMMING - - - - - - diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/xAthExample_13TeV_jobOptions.py b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/xAthExample_13TeV_jobOptions.py deleted file mode 100644 index 7be7e5bf729f440d41cc83b9130f950c7480354b..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/xAthExample_13TeV_jobOptions.py +++ /dev/null @@ -1,53 +0,0 @@ - -# Set up the file reading: Reads example 13TeV file -FNAME="/afs/cern.ch/atlas/project/PAT/xAODs/r5787/mc14_13TeV.110401.PowhegPythia_P2012_ttbar_nonallhad.merge.AOD.e2928_s1982_s2008_r5787_r5853_tid01597980_00/AOD.01597980._000098.pool.root.1" - -import AthenaPoolCnvSvc.ReadAthenaPool -ServiceMgr.EventSelector.InputCollections = [ FNAME ] - -# Access the algorithm sequence: -theJob = CfgMgr.AthSequencer("AthAlgSeq") - - -# Add the test algorithm: -theJob += CfgMgr.xAthExample() - -#configure all the tools (all kept by the ToolSvc in this example) -#need to know if isData or not ... do a file peek with athfile: -from PyUtils import AthFile -af = AthFile.fopen(ServiceMgr.EventSelector.InputCollections[0]) -isData = 'IS_SIMULATION' not in af.fileinfos['evt_type'] - - -ToolSvc += CfgMgr.JetCleaningTool("JetCleaning",OutputLevel=DEBUG,CutLevel="MediumBad") - -configFile = "JES_Prerecommendation2015_Feb2015.config" - -if isData: - ToolSvc += CfgMgr.JetCalibrationTool("JetCalibLCTopo",JetCollection="AntiKt4LCTopo", - ConfigFile=configFile, - CalibSequence="JetArea_Residual_EtaJES",IsData=isData) - ToolSvc += CfgMgr.JetCalibrationTool("JetCalibEMTopo",JetCollection="AntiKt4EMTopo", - ConfigFile=configFile, - CalibSequence="JetArea_Residual_EtaJES",IsData=isData) -else: - ToolSvc += CfgMgr.JetCalibrationTool("JetCalibLCTopo",JetCollection="AntiKt4LCTopo", - ConfigFile=configFile, - CalibSequence="JetArea_Residual_EtaJES",IsData=isData) - ToolSvc += CfgMgr.JetCalibrationTool("JetCalibEMTopo",JetCollection="AntiKt4EMTopo", - ConfigFile=configFile, - CalibSequence="JetArea_Residual_EtaJES",IsData=isData) - -ToolSvc += CfgMgr.met__METRebuilder("metRebuilder",JetColl="AntiKt4LCCalibJets", - OutputTotal="Final",SoftTermType="TrackSoftTerm",OutputContainer="MET_CalibFinal") - -#configure the output histsvc file -svcMgr += CfgMgr.THistSvc() -svcMgr.THistSvc.Output += ["MYSTREAM DATAFILE='myfile.root' OPT='RECREATE'"] - - -#other job options -theApp.EvtMax = -1 -ServiceMgr.MessageSvc.OutputLevel = INFO -ServiceMgr.MessageSvc.defaultLimit = 1000000 -svcMgr += CfgMgr.AthenaEventLoopMgr(EventPrintoutInterval=-1) #disables the eventloop printout, the algorithm has its own diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/xAthExample_8TeV_jobOptions.py b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/xAthExample_8TeV_jobOptions.py deleted file mode 100644 index 42d7c0d85553adc9fc2ff739a38a76a3b54a33b3..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/xAthExample_8TeV_jobOptions.py +++ /dev/null @@ -1,55 +0,0 @@ - -# Set up the file reading: reads 8TeV files from a folder -from glob import glob -files=glob("/afs/cern.ch/atlas/project/PAT/xAODs/r5591/mc14_8TeV.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e1727_s1933_s1911_r5591/*") - -import AthenaPoolCnvSvc.ReadAthenaPool -ServiceMgr.EventSelector.InputCollections = files - -# Access the algorithm sequence: -theJob = CfgMgr.AthSequencer("AthAlgSeq") - - -# Add the test algorithm: -theJob += CfgMgr.xAthExample() - -#configure all the tools (all kept by the ToolSvc in this example) -#need to know if isData or not ... do a file peek with athfile: -from PyUtils import AthFile -af = AthFile.fopen(ServiceMgr.EventSelector.InputCollections[0]) -isData = 'IS_SIMULATION' not in af.fileinfos['evt_type'] - - -ToolSvc += CfgMgr.JetCleaningTool("JetCleaning",OutputLevel=DEBUG,CutLevel="MediumBad") - -configFile = "JES_Full2012dataset_Preliminary_MC14.config" - -if isData: - ToolSvc += CfgMgr.JetCalibrationTool("JetCalibLCTopo",JetCollection="AntiKt4LCTopo", - ConfigFile=configFile, - CalibSequence="EtaJES",IsData=isData) - ToolSvc += CfgMgr.JetCalibrationTool("JetCalibEMTopo",JetCollection="AntiKt4EMTopo", - ConfigFile=configFile, - CalibSequence="EtaJES",IsData=isData) -else: - ToolSvc += CfgMgr.JetCalibrationTool("JetCalibLCTopo",JetCollection="AntiKt4LCTopo", - ConfigFile=configFile, - CalibSequence="EtaJES",IsData=isData) - ToolSvc += CfgMgr.JetCalibrationTool("JetCalibEMTopo",JetCollection="AntiKt4EMTopo", - ConfigFile=configFile, - CalibSequence="EtaJES",IsData=isData) - -ToolSvc += CfgMgr.met__METRebuilder("metRebuilder",JetColl="AntiKt4LCCalibJets", - OutputTotal="Final",SoftTermType="TrackSoftTerm",OutputContainer="MET_CalibFinal") - - -#configure the output histsvc file -svcMgr += CfgMgr.THistSvc() -svcMgr.THistSvc.Output += ["MYSTREAM DATAFILE='myfile.root' OPT='RECREATE'"] - - -#other job options -theApp.EvtMax = -1 -ServiceMgr.MessageSvc.OutputLevel = INFO -ServiceMgr.MessageSvc.defaultLimit = 1000000 -svcMgr += CfgMgr.AthenaEventLoopMgr(EventPrintoutInterval=-1) #disables the eventloop printout, the algorithm has its own diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/xAthExample_jobOptions.py b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/xAthExample_jobOptions.py deleted file mode 100644 index aae0fdb09830b3ab89a1fb81f6bd037aa0b94b5f..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/share/xAthExample_jobOptions.py +++ /dev/null @@ -1,56 +0,0 @@ - -# Set up the file reading: -FNAME="/afs/cern.ch/atlas/project/PAT/tutorial/cern-oct2014/r5591/mc14_8TeV.117050.PowhegPythia_P2011C_ttbar.recon.AOD.e1727_s1933_s1911_r5591_tid01494882_00/AOD.01494882._113691.pool.root.1" -#FNAME = - -import AthenaPoolCnvSvc.ReadAthenaPool -ServiceMgr.EventSelector.InputCollections = [ FNAME ] - -# Access the algorithm sequence: -theJob = CfgMgr.AthSequencer("AthAlgSeq") - - -# Add the test algorithm: -theJob += CfgMgr.xAthExample() - -#configure all the tools (all kept by the ToolSvc in this example) -#need to know if isData or not ... do a file peek with athfile: -from PyUtils import AthFile -af = AthFile.fopen(ServiceMgr.EventSelector.InputCollections[0]) -isData = 'IS_SIMULATION' not in af.fileinfos['evt_type'] - - -ToolSvc += CfgMgr.JetCleaningTool("JetCleaning",OutputLevel=DEBUG,CutLevel="MediumBad") - -configFile = "JES_Full2012dataset_Preliminary_MC14.config" - -if isData: - ToolSvc += CfgMgr.JetCalibrationTool("JetCalibLCTopo",JetCollection="AntiKt4LCTopo", - ConfigFile=configFile, - CalibSequence="EtaJES",IsData=isData) - ToolSvc += CfgMgr.JetCalibrationTool("JetCalibEMTopo",JetCollection="AntiKt4TopoEM", - ConfigFile=configFile, - CalibSequence="EtaJES",IsData=isData) -else: - ToolSvc += CfgMgr.JetCalibrationTool("JetCalibLCTopo",JetCollection="AntiKt4LCTopo", - ConfigFile=configFile, - CalibSequence="EtaJES",IsData=isData) - ToolSvc += CfgMgr.JetCalibrationTool("JetCalibEMTopo",JetCollection="AntiKt4TopoEM", - ConfigFile=configFile, - CalibSequence="EtaJES",IsData=isData) - -ToolSvc += CfgMgr.met__METRebuilder("metRebuilder",JetColl="AntiKt4LCCalibJets", - OutputTotal="Final",SoftTermType="TrackSoftTerm",OutputContainer="MET_CalibFinal") - - - -#configure the output histsvc file -svcMgr += CfgMgr.THistSvc() -svcMgr.THistSvc.Output += ["MYSTREAM DATAFILE='myfile.root' OPT='RECREATE'"] - - -#other job options -theApp.EvtMax = -1 -ServiceMgr.MessageSvc.OutputLevel = INFO -ServiceMgr.MessageSvc.defaultLimit = 1000000 -svcMgr += CfgMgr.AthenaEventLoopMgr(EventPrintoutInterval=-1) #disables the eventloop printout, the algorithm has its own diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/Test__EgammaCalibrationAndSmearingTool.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/Test__EgammaCalibrationAndSmearingTool.cxx deleted file mode 100644 index 94a30084101446991287556d49bb81650010d42a..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/Test__EgammaCalibrationAndSmearingTool.cxx +++ /dev/null @@ -1,126 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// CPAnalysisExamples includes -#include "Test__EgammaCalibrationAndSmearingTool.h" - -#include "xAODEgamma/ElectronContainer.h" -#include "xAODCore/ShallowCopy.h" - -#include "xAODCore/tools/ReadStats.h" -#include "xAODCore/tools/IOStats.h" - -#include "xAODBase/IParticleHelpers.h" - -namespace Test { - -EgammaCalibrationAndSmearingTool::EgammaCalibrationAndSmearingTool( const std::string& name, ISvcLocator* pSvcLocator ) : - AthAnalysisAlgorithm( name, pSvcLocator ), - myTool("CP::EgammaCalibrationAndSmearingTool/myTool") { - -} - - -EgammaCalibrationAndSmearingTool::~EgammaCalibrationAndSmearingTool() {} - - -StatusCode EgammaCalibrationAndSmearingTool::initialize() { - ATH_MSG_INFO ("Initializing " << name() << "..."); - // - //This is called once, before the start of the event loop - //Retrieves of tools you have configured in the joboptions go here - // - - CHECK( AthAnalysisHelper::setProperty( myTool, "ESModel", "es2015PRE" ) ); - CHECK( myTool.retrieve() ); - - m_el_pt = new TH1D("el_pt","Electron Calibrated Pt [GeV]",100,0,100); - m_el_pt_new_vs_old = new TH2D("el_pt_new_vs_old","Electron Calibrated Vs Uncalibrated Pt [GeV]",100,0,100,100,0,100); - ServiceHandle<ITHistSvc> histSvc("THistSvc",name()); - CHECK( histSvc->regHist("/MYSTREAM/el_pt_new_vs_old",m_el_pt_new_vs_old) ); - CHECK( histSvc->regHist("/MYSTREAM/el_pt",m_el_pt) ); - - return StatusCode::SUCCESS; -} - -StatusCode EgammaCalibrationAndSmearingTool::finalize() { - ATH_MSG_INFO ("Finalizing " << name() << "..."); - // - //Things that happen once at the end of the event loop go here - // - - //print the smart slimming xAOD statistics - //this will only be useful when running with the 'ReadAthenaxAOD' or 'ReadAthenaxAODHybrid' modes - xAOD::ReadStats& stats = xAOD::IOStats::instance().stats(); - stats.Print("SmartSlimming"); - - - - return StatusCode::SUCCESS; -} - -StatusCode EgammaCalibrationAndSmearingTool::execute() { - ATH_MSG_DEBUG ("Executing " << name() << "..."); - setFilterPassed(false); //optional: start with algorithm not passed - - i++; - - - // - //Your main analysis code goes here - //If you will use this algorithm to perform event skimming, you - //should ensure the setFilterPassed method is called - //If never called, the algorithm is assumed to have 'passed' by default - // - - //get the electrons - const xAOD::ElectronContainer* xaod_els = 0; - if( evtStore()->retrieve( xaod_els , "Electrons" ).isFailure() ) { - ATH_MSG_ERROR("Could not retrieve electrons"); return StatusCode::FAILURE; - } - - //create a shallow copy and calibrate - auto calibratedElectrons = xAOD::shallowCopyContainer( *xaod_els ); - int j=0; - for(auto el : *calibratedElectrons.first) { - myTool->applyCorrection(*el).setChecked(); - m_el_pt_new_vs_old->Fill(xaod_els->at(j++)->pt()/1000.,el->pt()/1000.); //record to histogram - m_el_pt->Fill(el->pt()/1000.); - } - - //for first 10 events we will print out the calibrated and uncalibrated Pt for comparison - if(i<10) { - for(uint j=0;j<xaod_els->size();j++) { - ATH_MSG_INFO("Uncalibrated Pt = " << xaod_els->at(j)->pt() << " , Calibrated Pt = " << calibratedElectrons.first->at(j)->pt()); - } - } - - //cleanup the shallow copy - delete calibratedElectrons.first; - delete calibratedElectrons.second; //the auxstore - - setFilterPassed(true); //if got here, assume that means algorithm passed - return StatusCode::SUCCESS; -} - -StatusCode EgammaCalibrationAndSmearingTool::beginInputFile() { - // - //This method is called at the start of each input file, even if - //the input file contains no events. Accumulate metadata information here - // - - //example of retrieval of CutBookkeepers: (remember you will need to include the necessary header files and use statements in requirements file) - // const xAOD::CutBookkeeperContainer* bks = 0; - // CHECK( inputMetaStore()->retrieve(bks, "CutBookkeepers") ); - - //example of IOVMetaData retrieval (see https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/AthAnalysisBase#How_to_access_file_metadata_in_C) - //float beamEnergy(0); CHECK( retrieveMetadata("/TagInfo","beam_energy",beamEnergy) ); - //std::vector<float> bunchPattern; CHECK( retrieveMetadata("/Digitiation/Parameters","BeamIntensityPattern",bunchPattern) ); - - - - return StatusCode::SUCCESS; -} - -} //> end namespace Test diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/Test__EgammaCalibrationAndSmearingTool.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/Test__EgammaCalibrationAndSmearingTool.h deleted file mode 100644 index 5b8e28bba211f8d29aa44fad6f79fe4d03a59b02..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/Test__EgammaCalibrationAndSmearingTool.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef CPANALYSISEXAMPLES_TEST__EGAMMACALIBRATIONANDSMEARINGTOOL_H -#define CPANALYSISEXAMPLES_TEST__EGAMMACALIBRATIONANDSMEARINGTOOL_H 1 - -#include "AthAnalysisBaseComps/AthAnalysisAlgorithm.h" - -#include "ElectronPhotonFourMomentumCorrection/IEgammaCalibrationAndSmearingTool.h" - -#include "TH2D.h" -#include "TH1D.h" - -namespace Test { - -class EgammaCalibrationAndSmearingTool: public ::AthAnalysisAlgorithm { - public: - EgammaCalibrationAndSmearingTool( const std::string& name, ISvcLocator* pSvcLocator ); - virtual ~EgammaCalibrationAndSmearingTool(); - - virtual StatusCode initialize(); - virtual StatusCode execute(); - virtual StatusCode finalize(); - - virtual StatusCode beginInputFile(); - - private: - int i=0; //count events processed - ToolHandle<CP::IEgammaCalibrationAndSmearingTool> myTool; - - TH2D* m_el_pt_new_vs_old = 0; - TH1D* m_el_pt = 0; -}; -} //> end namespace Test -#endif //> !CPANALYSISEXAMPLES_TEST__EGAMMACALIBRATIONANDSMEARINGTOOL_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/Test__TrackLinkTest.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/Test__TrackLinkTest.cxx deleted file mode 100644 index 813f91bd6406b87a7f52ac23147fa585284c5e07..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/Test__TrackLinkTest.cxx +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// CPAnalysisExamples includes -#include "Test__TrackLinkTest.h" - -#include "xAODEgamma/ElectronContainer.h" -#include "xAODTracking/TrackParticleContainer.h" - -namespace Test { - -TrackLinkTest::TrackLinkTest( const std::string& name, ISvcLocator* pSvcLocator ) : AthAnalysisAlgorithm( name, pSvcLocator ){} - - -TrackLinkTest::~TrackLinkTest() {} - - -StatusCode TrackLinkTest::initialize() { - ATH_MSG_INFO ("Initializing " << name() << "..."); - - return StatusCode::SUCCESS; -} - -StatusCode TrackLinkTest::finalize() { - ATH_MSG_INFO ("Finalizing " << name() << "..."); - - return StatusCode::SUCCESS; -} - -StatusCode TrackLinkTest::execute() { - ATH_MSG_DEBUG ("Executing " << name() << "..."); - setFilterPassed(false); //optional: start with algorithm not passed - - const xAOD::ElectronContainer *inCont(0); - ATH_CHECK( evtStore()->retrieve( inCont, "Electrons" ) ); - - for ( const xAOD::Electron* electron : *inCont){ - // Get the TrackParticle - const xAOD::TrackParticle* trackPart(0); - trackPart = electron->trackParticle(); - if ( !trackPart ) { - ATH_MSG_ERROR("Couldn't get the TrackParticle for this Electron"); - return StatusCode::FAILURE; - } - } - - setFilterPassed(true); //if got here, assume that means algorithm passed - return StatusCode::SUCCESS; -} - -StatusCode TrackLinkTest::beginInputFile() { - - return StatusCode::SUCCESS; -} - -} //> end namespace Test diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/Test__TrackLinkTest.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/Test__TrackLinkTest.h deleted file mode 100644 index 258ef8f57a8a60fe5ca5f40c9c37e7c9344c8f3f..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/Test__TrackLinkTest.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef CPANALYSISEXAMPLES_TEST__TRACKLINKTEST_H -#define CPANALYSISEXAMPLES_TEST__TRACKLINKTEST_H 1 - -#include "AthAnalysisBaseComps/AthAnalysisAlgorithm.h" -#ifdef XAOD_ANALYSIS -#include "AsgTools/AnaToolHandle.h" //use asg::AnaToolHandle instead of regular ToolHandles for full dual-use experience! -#endif - -namespace Test { - -class TrackLinkTest: public ::AthAnalysisAlgorithm { - public: - TrackLinkTest( const std::string& name, ISvcLocator* pSvcLocator ); - virtual ~TrackLinkTest(); - - virtual StatusCode initialize(); - virtual StatusCode execute(); - virtual StatusCode finalize(); - - virtual StatusCode beginInputFile(); - - private: - -}; -} //> end namespace Test -#endif //> !CPANALYSISEXAMPLES_TEST__TRACKLINKTEST_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/ToolExamplesAlg.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/ToolExamplesAlg.cxx deleted file mode 100644 index f04f5000e7dd4a40810c8c0cb8ede465cc990012..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/ToolExamplesAlg.cxx +++ /dev/null @@ -1,144 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -#include "CPAnalysisExamples/ToolExamplesAlg.h" - - -#include "PATInterfaces/SystematicsUtil.h" //for make_systematic_vector - -#include "xAODCore/ShallowCopy.h" //for shallowCopyContainer method - -ToolExamplesAlg::ToolExamplesAlg( const std::string& name, ISvcLocator* pSvcLocator ) : AthAnalysisAlgorithm( name, pSvcLocator ){ - - //declareProperty( "Property", m_nProperty ); //example property declaration - -} - - -ToolExamplesAlg::~ToolExamplesAlg() {} - - -StatusCode ToolExamplesAlg::initialize() { - ATH_MSG_INFO ("Initializing " << name() << "..."); - - //connect the ToolHandles to the tools configured in the joboptions - //could also have done this by declaring the handles as properties above: - // declareProperty("MyTool",handle); - //and in joboptions doing: - //algseq.MyAlg.MyTool = ToolSvc.SomeTool - - - ///General - m_grl.setTypeAndName("GoodRunsListSelectionTool/GRLTool"); - m_prw.setTypeAndName("CP::PileupReweightingTool/PileupReweightingTool"); - m_tdt.setTypeAndName("Trig::TrigDecisionTool/TrigDecisionTool"); - m_tmt.setTypeAndName("Trig::MatchingTool/TrigMatchingTool"); - - ///Electrons - m_elCalib.setTypeAndName("CP::EgammaCalibrationAndSmearingTool/EgammaCalibTool"); - m_elIsoCalib.setTypeAndName("CP::IsolationCorrectionTool/IsolationCorrectionTool"); - m_elSelection.setTypeAndName("AsgElectronLikelihoodTool/ElectronSelectionTool"); - m_elIsoSelection.setTypeAndName("CP__IsolationSelectionTool/ElectronIsolationTool"); - m_elCorrectedIsoSelection.setTypeAndName("CP__IsolationCloseByCorrectionTool/ElectronIsolationCloseByCorrectionTool"); - - //example of using a ToolHandleArray - m_elSFTools.push_back( "AsgElectronEfficiencyCorrectionTool/ElectronRecoSF" ); - m_elSFTools.push_back( "AsgElectronEfficiencyCorrectionTool/ElectronIDSF" ); - m_elSFTools.push_back( "AsgElectronEfficiencyCorrectionTool/ElectronIsolSF" ); - - - //Muons - - - //Jets - - - return StatusCode::SUCCESS; -} - -StatusCode ToolExamplesAlg::firstExecute() { - ATH_MSG_INFO ("FirstExecuting " << name() << "..."); - return StatusCode::SUCCESS; -} - -StatusCode ToolExamplesAlg::finalize() { - ATH_MSG_INFO ("Finalizing " << name() << "..."); - // - //Things that happen once at the end of the event loop go here - // - - - return StatusCode::SUCCESS; -} - -StatusCode ToolExamplesAlg::execute() { - ATH_MSG_DEBUG ("Executing " << name() << "..."); - setFilterPassed(false); //optional: start with algorithm not passed - - const xAOD::EventInfo* ei = 0; CHECK( evtStore()->retrieve( ei , "EventInfo" ) ); - const xAOD::ElectronContainer* els = 0; CHECK( evtStore()->retrieve( els, "Electrons" ) ); - const xAOD::MuonContainer* mus = 0; CHECK( evtStore()->retrieve( mus, "Muons" ) ); - const xAOD::JetContainer* jets = 0; CHECK( evtStore()->retrieve( jets, "AntiKt4EMTopoJets" ) ); - - //GRL Example - //bool passGRL = m_grl->passRunLB(*ei); - - //PRW Example - CHECK( m_prw->apply(*ei) ); - //float pileupWeight = ei->auxdecor<float>("PileupWeight"); - //uint randomRunNumber = ei->auxdecor<uint>("RandomRunNumber"); - - //Trigger Decision Example - //bool passTrigger = m_tdt->isPassed("HLT_e24_lhmedium_L1EM20VH"); - - - //Electron Calibration, Iso Calibration, LH Selection, Iso Selection, Scale Factor Example - - CP::SystematicSet elSysts = m_elCalib->recommendedSystematics(); - elSysts.insert(m_elIsoCalib->recommendedSystematics()); - std::vector<CP::SystematicSet> sysList = CP::make_systematics_vector(elSysts); - - for(auto& syst : sysList ) { - m_elCalib->applySystematicVariation( syst ).setChecked(); - m_elIsoCalib->applySystematicVariation( syst ).setChecked(); - auto calib_els = xAOD::shallowCopyContainer( *els ); - for(auto el : *calib_els.first) { - m_elCalib->applyCorrection(*el).setChecked(); - m_elIsoCalib->applyCorrection(*el).setChecked(); - Root::TAccept acc = m_elSelection->accept(el); //can treat 'acc' as a bool - Root::TAccept isoAcc = m_elIsoSelection->accept(*el); - for(auto tool : m_elSFTools) { - double sf(1.); - tool->getEfficiencyScaleFactor( *el , sf ).setChecked(); //fills sf with scale factor - } - } - const std::string&& systName = (syst.name()=="") ? "Nominal" : syst.name(); - CHECK( evtStore()->record(calib_els.first,"Electrons" + systName ) ); - CHECK( evtStore()->record(calib_els.second,"Electrons" + systName + "Aux.") ); - - //CloseBy-corrected Isolation Selection example - std::vector<const xAOD::IParticle*> all_els; - for(auto el : *calib_els.first) all_els.push_back(el); - - for(auto el : *calib_els.first) { - Root::TAccept acc = m_elCorrectedIsoSelection->acceptCorrected(*el, all_els); - } - - } - - - - - - setFilterPassed(true); //if got here, assume that means algorithm passed - return StatusCode::SUCCESS; -} - -StatusCode ToolExamplesAlg::beginInputFile() { - ATH_MSG_INFO ("beginInputFile..."); - return StatusCode::SUCCESS; -} - - diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/ToolTester.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/ToolTester.cxx deleted file mode 100644 index 1b66116a718286f10a79938dcd8cbd3cf72e7c3f..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/ToolTester.cxx +++ /dev/null @@ -1,122 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: ToolTester.cxx 300458 2014-04-25 09:08:18Z krasznaa $ - -// EDM include(s): -#include "xAODMuon/MuonContainer.h" - -// Local include(s): -#include "ToolTester.h" - -namespace CP { - - ToolTester::ToolTester( const std::string& name, ISvcLocator* svcLoc ) - : AthAlgorithm( name, svcLoc ), - m_selTool( "CP::MuonSelectionToolExample/MuonSelectionToolExample", this ), - m_smearTool( "CP::MuonSmearingToolExample/MuonSmearingToolExample", this ), - m_effTool( "CP::MuonEfficiencyToolExample/MuonEfficiencyToolExample", this ) { - - declareProperty( "SGKey", m_sgKey = "Muons" ); - - declareProperty( "MuonSelectionToolExample", m_selTool ); - declareProperty( "MuonSmearingToolExample", m_smearTool ); - declareProperty( "MuonEfficiencyToolExample", m_effTool ); - } - - StatusCode ToolTester::initialize() { - - // Greet the user: - ATH_MSG_INFO( "Initialising - Package version: " << PACKAGE_VERSION ); - ATH_MSG_DEBUG( "SGKey = " << m_sgKey ); - ATH_MSG_DEBUG( "MuonSelectionTool = " << m_selTool ); - ATH_MSG_DEBUG( "MuonSmearingTool = " << m_smearTool ); - ATH_MSG_DEBUG( "MuonEfficiencyTool = " << m_effTool ); - - // Retrieve the tools: - ATH_CHECK( m_selTool.retrieve() ); - ATH_CHECK( m_smearTool.retrieve() ); - ATH_CHECK( m_effTool.retrieve() ); - - // Return gracefully: - return StatusCode::SUCCESS; - } - - StatusCode ToolTester::execute() { - - // Retrieve the muons: - const xAOD::MuonContainer* muons = 0; - ATH_CHECK( evtStore()->retrieve( muons, m_sgKey ) ); - ATH_MSG_INFO( "Number of muons: " << muons->size() ); - - // Loop over them: - xAOD::MuonContainer::const_iterator mu_itr = muons->begin(); - xAOD::MuonContainer::const_iterator mu_end = muons->end(); - for( ; mu_itr != mu_end; ++mu_itr ) { - - // Select "good" muons: - if( ! m_selTool->accept( **mu_itr ) ) continue; - - // Print some info about the selected muon: - ATH_MSG_INFO( " Selected muon: eta = " << ( *mu_itr )->eta() - << ", phi = " << ( *mu_itr )->phi() - << ", pt = " << ( *mu_itr )->pt() ); - ATH_MSG_INFO( " Primary track: eta = " - << ( *mu_itr )->primaryTrackParticle()->eta() - << ", phi = " - << ( *mu_itr )->primaryTrackParticle()->phi() - << ", pt = " - << ( *mu_itr )->primaryTrackParticle()->pt() ); - const xAOD::TrackParticle* idtrack = - ( *mu_itr )->trackParticle( xAOD::Muon::InnerDetectorTrackParticle ); - if( idtrack ) { - ATH_MSG_INFO( " ID track: eta = " << idtrack->eta() - << ", phi = " << idtrack->phi() - << ", pt = " << idtrack->pt() ); - } - - // Create a calibrared muon: - xAOD::Muon* mu = 0; - if( ! m_smearTool->correctedCopy( **mu_itr, mu ) ) { - ATH_MSG_WARNING( "Failed to smear the muon!" ); - continue; - } - ATH_MSG_INFO( "Calibrated muon: eta = " << mu->eta() - << ", phi = " << mu->phi() - << ", pt = " << mu->pt() ); - - // Use the "simple interface" of the tool(s): - float eff = 0.0, sf = 0.0; - if( ! m_effTool->getEfficiency( *mu, eff ) ) { - ATH_MSG_WARNING( "Couldn't get muon efficiency!" ); - delete mu; - continue; - } - ATH_MSG_INFO( " efficiency = " << eff ); - if( ! m_effTool->getScaleFactor( *mu, sf ) ) { - ATH_MSG_WARNING( "Couldn't get muon scale factor!" ); - delete mu; - continue; - } - ATH_MSG_INFO( " scaleFactor = " << sf ); - - // Call the tool on it in "decrating mode": - if( ! m_effTool->applyEfficiency( *mu ) ) { - ATH_MSG_WARNING( "Couldn't decorate muon!" ); - delete mu; - continue; - } - ATH_MSG_INFO( " efficiency = " - << mu->auxdata< float >( "MuonEfficiency" ) ); - - // Delete the calibrated muon: - delete mu; - - } - - // Return gracefully: - return StatusCode::SUCCESS; - } - -} // namespace CP diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/ToolTester.h b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/ToolTester.h deleted file mode 100644 index 486476fba63050bdccc1fd9258335a7bfb7a11d2..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/ToolTester.h +++ /dev/null @@ -1,58 +0,0 @@ -// Dear emacs, this is -*- c++ -*- - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: ToolTester.h 299890 2014-03-29 08:54:38Z krasznaa $ -#ifndef CPTOOLTESTS_TOOLTESTER_H -#define CPTOOLTESTS_TOOLTESTER_H - -// Gaudi/Athena include(s): -#include "AthenaBaseComps/AthAlgorithm.h" -#include "AsgTools/ToolHandle.h" - -// Local include(s): -#include "CPAnalysisExamples/IMuonSelectionToolExample.h" -#include "CPAnalysisExamples/IMuonSmearingToolExample.h" -#include "CPAnalysisExamples/IMuonEfficiencyToolExample.h" - -namespace CP { - - /// Simple algorithm for using the tools in Athena - /// - /// This is meant to be the "Athena equivalent" of the code put into - /// util/CPToolTester.cxx. - /// - /// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> - /// - /// $Revision: 299890 $ - /// $Date: 2014-03-29 09:54:38 +0100 (Sat, 29 Mar 2014) $ - /// - class ToolTester : public AthAlgorithm { - - public: - /// Regular Algorithm constructor - ToolTester( const std::string& name, ISvcLocator* svcLoc ); - - /// Function initialising the algorithm - virtual StatusCode initialize(); - /// Function executing the algorithm - virtual StatusCode execute(); - - private: - /// StoreGate key for the muon container to investigate - std::string m_sgKey; - - /// Connection to the selection tool - ToolHandle< IMuonSelectionToolExample > m_selTool; - /// Connection to the smearing tool - ToolHandle< IMuonSmearingToolExample > m_smearTool; - /// Connection to the efficiency tool - ToolHandle< IMuonEfficiencyToolExample > m_effTool; - - }; // class ToolTester - -} // namespace CP - -#endif // CPTOOLTESTS_TOOLTESTER_H diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/components/CPAnalysisExamples_entries.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/components/CPAnalysisExamples_entries.cxx deleted file mode 100644 index e3b441200b5d59ae5457e0e2a2088dfcb83b3b6c..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/components/CPAnalysisExamples_entries.cxx +++ /dev/null @@ -1,32 +0,0 @@ -#include "CPAnalysisExamples/MuonEfficiencyToolExample.h" -#include "CPAnalysisExamples/MuonSmearingToolExample.h" -#include "CPAnalysisExamples/MuonSelectionToolExample.h" -#include "CPAnalysisExamples/JetCalibrationToolExample.h" - -#include "../ToolTester.h" - -DECLARE_COMPONENT( CP::MuonEfficiencyToolExample ) -DECLARE_COMPONENT( CP::MuonSmearingToolExample ) -DECLARE_COMPONENT( CP::MuonSelectionToolExample ) -DECLARE_COMPONENT( CP::JetCalibrationToolExample ) - -DECLARE_COMPONENT( CP::ToolTester ) - - -#include "CPAnalysisExamples/xAthExample.h" -DECLARE_COMPONENT( xAthExample ) - - -#include "../Test__TrackLinkTest.h" -DECLARE_COMPONENT( Test::TrackLinkTest ) - -#include "CPAnalysisExamples/ToolExamplesAlg.h" -DECLARE_COMPONENT( ToolExamplesAlg ) - -#include "../Test__EgammaCalibrationAndSmearingTool.h" -DECLARE_COMPONENT( Test::EgammaCalibrationAndSmearingTool ) - - -#include "CPAnalysisExamples/MetadataToolExample.h" -DECLARE_COMPONENT( CP::MetadataToolExample ) - diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/xAthExample.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/xAthExample.cxx deleted file mode 100644 index 7d5682ff231f87eb7416ed2713364682d56a87c9..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/src/xAthExample.cxx +++ /dev/null @@ -1,1345 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// CPAnalysisExamples includes -#include "CPAnalysisExamples/xAthExample.h" - -#include "CPAnalysisExamples/xExampleEDM.h" -#include "CPAnalysisExamples/xExampleUtils.h" - -#include "GaudiKernel/ITHistSvc.h" -#include "GaudiKernel/IJobOptionsSvc.h" -#include "GaudiKernel/AlgTool.h" - -#include <ctime> - -xAthExample::xAthExample( const std::string& name, ISvcLocator* pSvcLocator ) : AthAlgorithm( name, pSvcLocator ) { - -} - - - -StatusCode xAthExample::initialize() { - ATH_MSG_INFO ("Initializing " << name() << "..."); - -///this was me just playing around with stuff .. ignore it -// IMETRebuilder* tmpTool = dynamic_cast<IMETRebuilder*>(AlgTool::Factory::create("met::METRebuilder", "met::METRebuilder", "myTool", this)); -// //tmpTool->setProperty("JetColl","oo"); -// ServiceHandle<IJobOptionsSvc> joSvc("JobOptionsSvc",name()); -// CHECK( joSvc->addPropertyToCatalogue("myTool",StringProperty("JetColl","Blah")) ); -// CHECK( joSvc->setMyProperties( tmpTool->name(), dynamic_cast<IProperty*>(tmpTool) ) ); -/// end of stuff - - // pt bins - float xxLim[17] = {9.9999, - 20.00, 30.00, 40.00, 60.00, 80.00, 120.0, - 160.0, 240.0, 320.0, 480.0, 640.0, 960.0, - 1280., 1920., 2560., - 10000.1}; - - std::string xxStr[17] = {"0000", - "0020","0030","0040","0060","0080","0120", - "0160","0240","0320","0480","0640","0960", - "1280","1920","2560", - "0000"}; - - for(unsigned int i=0; i<17; ++i){ - ptLim[i] = xxLim[i]; - ptStr[i] = xxStr[i]; - } - - // Primary vertex - - m_TH1["intactual"] = new TH1F("intactual","intactual",50,0.,50.); - m_TH1["intaverage"] = new TH1F("intaverage","intaverage",50,0.,50.); - m_TH1["intdiff"] = new TH1F("intdiff","intdiff",100,-50.,50.); - - m_TH1["privtxidx"] = new TH1F("privtxidx","privtxidx",50,0.,50.); - m_TH1["privtxz0"] = new TH1F("privtxz0","privtxz0",100,-200.,200.); - m_TH1["privtxn2"] = new TH1F("privtxn2","privtxn2",50,0.,50.); - m_TH1["privtxn5"] = new TH1F("privtxn5","privtxn5",50,0.,50.); - m_TH1["privtxntrk"] = new TH1F("privtxntrk","privtxntrk",100,0.,200.); - - // Muons - - m_TH1["mupt"] = new TH1F("mupt", "mupt", 100, 0., 500. ); - m_TH1["mueta"] = new TH1F("mueta", "mueta", 60, -3., 3. ); - m_TH1["muphi"] = new TH1F("muphi", "muphi", 100, -1., 1.); - m_TH1["mutype"] = new TH1F("mutype","mutype",5,0.,5.); - m_TH1["muquality"] = new TH1F("muquality","muquality",5,0.,5.); - m_TH1["mugoodpt"] = new TH1F("mugoodpt", "mugoodpt", 100, 0., 500. ); - m_TH1["mugoodeta"] = new TH1F("mugoodeta", "mugoodeta", 60, -3., 3. ); - m_TH1["muidrat"] = new TH1F("muidrat","muidrat",100,0.,2.); - m_TH1["muptc30"] = new TH1F("muptc30","muptc30",100,0.,20.); - - // Electrons - - m_TH1["elpt"] = new TH1F("elpt","elpt",100, 0., 500.); - m_TH1["eleta"] = new TH1F("eleta","eleta", 60, -3., 3.); - m_TH1["elphi"] = new TH1F("elphi","elphi", 100, -1., 1.); - m_TH1["elauthor"] = new TH1F("elauthor","elauthor",16,0,16.); - m_TH1["elntrk"] = new TH1F("elntrk","elntrk",20,0,20.); - m_TH1["eleoverp"] = new TH1F("eleoverp","eleoverp",100,0,5.); - m_TH1["eletc30"] = new TH1F("eletc30","eletc30",100,0.,20.); - m_TH1["elgood"] = new TH1F("elgood","elgood",2,0.,2.); - m_TH1["elgoodpt"] = new TH1F("elgoodpt","elgoodpt",100, 0., 500.); - m_TH1["elgoodeta"] = new TH1F("elgoodeta","elgoodeta", 60, -3., 3.); - m_TH1["eldrtrue"] = new TH1F("eldrtrue","eldrtrue",100,0.,1.); - m_TH1["elptrat"] = new TH1F("elptrat","elptrat",100,0.,2.); - - // AntiKt4LCTopo jets - - static const float ptjmax = 2000.; - static const float ptjlomax = 200.; - - m_TH1["akt4pt"] = new TH1F("akt4pt","akt4pt",100,0.,ptjmax); - m_TH1["akt4ptlo"] = new TH1F("akt4ptlo","akt4ptlo",100,0.,ptjlomax); - m_TH1["akt4eta"] = new TH1F("akt4eta","akt4eta",60,-3.,3.); - m_TH1["akt4phi"] = new TH1F("akt4phi","akt4phi",100,-1.,1.); - m_TH1["akt4rlep"] = new TH1F("akt4rlep","akt4rlep",100,0.,2.); - m_TH1["akt4calibrlep"] = new TH1F("akt4calibrlep","akt4calibrlep",100,0.,2.); - m_TH1["akt4ptbad"] = new TH1F("akt4ptbad","akt4ptbad",100,0.,ptjmax); - m_TH1["akt4etabad"] = new TH1F("akt4etabad","akt4etabad",60,-3.,3.); - m_TH2["akt4drelvpt"] = new TH2F("akt4drelvpt","akt4drelvpt",50,0.,200., - 50,0.,2.); - - for(unsigned int ib=1; ib<16; ++ib){ - std::string str = "akt4calib" + ptStr[ib]; - m_TH1[str.c_str()] = new TH1F(str.c_str(),str.c_str(),100,0.,2.); - } - - m_TH1["akt4jvf"] = new TH1F("akt4jvf","akt4jvf",110,-1.,1.19999); - m_TH1["akt4jvfx"] = new TH1F("akt4jvfx","akt4jvfx",110,-1.,1.19999); - m_TH1["akt4jvftot"] = new TH1F("akt4jvftot","akt4jvftot",110,0.,1.09999); - for(unsigned int ib=1; ib<16; ++ib){ - std::string str = "akt4jvf" + ptStr[ib]; - m_TH1[str.c_str()] = new TH1F(str.c_str(),str.c_str(),110,-1.,1.19999); - } - - m_TH1["akt4trueid"] = new TH1F("akt4trueid","akt4trueid",18,-2.,16.); - m_TH1["akt4ptb"] = new TH1F("akt4ptb","akt4ptb",100,0.,ptjmax); - m_TH1["akt4etab"] = new TH1F("akt4etab","akt4etab",60,-3.,3.); - m_TH1["akt4mv1"] = new TH1F("akt4mv1","akt4mv1",100,0.,2.); - m_TH1["akt4sv1b"] = new TH1F("akt4sv1b","akt4sv1b",100,0.,1.); - m_TH1["akt4sv1u"] = new TH1F("akt4sv1u","akt4sv1u",100,0.,1.); - m_TH2["akt4sv1uvb"] = new TH2F("akt4sv1uvb","akt4sv1uvb",80,0.,0.4,50,0.,1.); - - m_TH1["akt4ntrk"] = new TH1F("akt4ntrk","akt4ntrk",50,0.,50.); - m_TH1["akt4rtrk"] = new TH1F("akt4rtrk","akt4rtrk",100,0.,1.); - m_TH1["akt4nsitrk"] = new TH1F("akt4nsitrk","akt4nsitrk",20,0.,20.); - m_TH1["akt4z0trk"] = new TH1F("akt4z0trk","akt4z0trk",100,-200.,200.); - m_TH1["akt4dz0trk"] = new TH1F("akt4dz0trk","akt4dz0trk",200,-5.,5.); - m_TH2["akt4z0vz0"] = new TH2F("akt4z0vz0","akt4z0vz0",25,-50.,50.,25,-50.,50.); - - for(unsigned int ib=1; ib<16; ++ib){ - std::string str = "akt4rtrk" + ptStr[ib]; - m_TH1[str.c_str()] = new TH1F(str.c_str(),str.c_str(),100,0.,2.); - } - - m_TH1["akt4drtrue"] = new TH1F("akt4drtrue","akt4drtrue",100,0.,2.0); - m_TH1["akt4drtruecalib"] = new TH1F("akt4drtruecalib","akt4drtruecalib",100,0.,2.0); - for(unsigned int ib=1; ib<16; ++ib){ - std::string str = "akt4jes" + ptStr[ib]; - m_TH1[str.c_str()] = new TH1F(str.c_str(),str.c_str(),100,0.,2.); - std::string str2 = "akt4jescalib" + ptStr[ib]; - m_TH1[str2.c_str()] = new TH1F(str2.c_str(),str2.c_str(),100,0.,2.); - } - m_TH2["akt4jesvpt"] = new TH2F("akt4jesvpt","akt4jesvpt",50,0.,500,50,0.,2.); - - // AntiKt4Truth jets - - m_TH1["aktT4pt"] = new TH1F("aktT4pt","aktT4pt",100,0.,ptjmax); - m_TH1["aktT4ptlo"] = new TH1F("aktT4ptlo","aktT4ptlo",100,0.,ptjlomax); - m_TH1["aktT4eta"] = new TH1F("aktT4eta","aktT4eta",60,-3.,3.); - m_TH1["aktT4phi"] = new TH1F("aktT4phi","aktT4phi",100,-1.,1.); - - // AntiKt4EMTopo jets - - m_TH1["aktem4n100"] = new TH1F("aktem4n100","aktem4n100",20,0.,20.); - m_TH1["aktem4ncalib100"] = new TH1F("aktem4ncalib100","aktem4ncalib100",20,0.,20.); - - // TauJets - - m_TH1["taupt"] = new TH1F("taupt", "taupt", 100, 0., 500. ); - m_TH1["taueta"] = new TH1F("taueta", "taueta", 60, -3., 3. ); - m_TH1["tauphi"] = new TH1F("tauphi", "tauphi", 100, -1., 1.); - m_TH1["tauid"] = new TH1F("tauid","tauid",5,0.,5.); - m_TH1["taubdt"] = new TH1F("taubdt","taubdt",100,0.,1.); - m_TH2["taudrelvpt"] = new TH2F("taudrelvpt","taudrelvpt",50,0.,200., - 50,0.,2.); - m_TH1["tautruept"] = new TH1F("tautruept","tautruept",100,0.,500.); - m_TH1["tautrueeta"] = new TH1F("tautrueeta","tautrueeta",60,-3.,3.); - m_TH1["taugoodpt"] = new TH1F("taugoodpt", "taugoodpt", 100, 0., 500. ); - m_TH1["taugoodeta"] = new TH1F("taugoodeta", "taugoodeta", 60, -3., 3. ); - m_TH1["taugoodbdt"] = new TH1F("taugoodbdt","taugoodbdt",100,0.,1.); - m_TH1["tauntrk"] = new TH1F("tauntrk","tauntrk",10,0.,10.); - m_TH1["tauptrtrk"] = new TH1F("tauptrtrk","tauptrtrk",120,0.,1.2); - m_TH1["taudrtrue"] = new TH1F("taudrtrue","taudrtrue",100,0.,1.); - m_TH1["tauptrat"] = new TH1F("tauptrat","tauptrat",100,0.,2.); - - // Met - - m_TH1["metet"] = new TH1F("metet","metet",100,0.,1000.); - m_TH1["metetlo"] = new TH1F("metetlo","metetlo",100,0.,200.); - m_TH1["metsum"] = new TH1F("metsum","metsum",100,0.,2000.); - m_TH1["mettrueet"] = new TH1F("mettrueet","mettrueet",100,0.,1000.); - m_TH1["mettrueetlo"] = new TH1F("mettrueetlo","mettrueetlo",100,0.,200.); - m_TH1["mettruesum"] = new TH1F("mettruesum","mettruesum",100,0.,1000.); - m_TH1["metcalibet"] = new TH1F("metcalibet","metcalibet",100,0.,1000.); - m_TH1["metcalibetlo"] = new TH1F("metcalibetlo","metcalibetlo",100,0.,100.); - m_TH1["metcalibsum"] = new TH1F("metcalibsum","metcalibsum",100,0.,2000.); - - // Truth particles - - m_TH1["tppt"] = new TH1F("tppt","tppt",100,0.,500.); - m_TH1["tpptlo"] = new TH1F("tpptlo","tpptlo",100,0.,2.); - m_TH1["tpeta"] = new TH1F("tpeta","tpeta",70,-7.,7.); - m_TH1["tpnum"] = new TH1F("tpnum","tpnum",100,0.,1000.); - m_TH1["tpsum"] = new TH1F("tpsum","tpsum",100,-100.,100.); - m_TH1["tpsumlo"] = new TH1F("tpsumlo","tpsumlo",100,-1.,1.); - m_TH1["tpbpt"] = new TH1F("tpbpt","tpbpt",100,0.,500.); - m_TH1["tpbeta"] = new TH1F("tpbeta","tpbeta",100,-5.,5.); - m_TH1["tpwkid"] = new TH1F("tpwkid","tpwkid",50,-25.,25.); - - // Interactions from Geant - m_TH1["tpvxr"] = new TH1F("tpvxr","tpvxr",100,0.,500.); - m_TH1["tpvxeta"] = new TH1F("tpvxeta","tpvxeta",60,-3.,3.); - m_TH1["tpvxidin"] = new TH1F("tpvxidin","tpvxidin",100,0.,100.); - - - ////////////////////////////////////// - // Add histograms to job and set Sumw2 - ////////////////////////////////////// - - ServiceHandle<ITHistSvc> histSvc("THistSvc",name()); - - std::map<std::string,TH1*>::iterator h1Itr = m_TH1.begin(); - std::map<std::string,TH1*>::iterator h1ItrE = m_TH1.end(); - for(; h1Itr != h1ItrE; ++h1Itr){ - TH1* h1 = (*h1Itr).second; - h1->Sumw2(); - CHECK( histSvc->regHist(std::string("/MYSTREAM/")+h1->GetName(),h1) ); - } - - std::map<std::string,TH2*>::iterator h2Itr = m_TH2.begin(); - std::map<std::string,TH2*>::iterator h2ItrE = m_TH2.end(); - for(; h2Itr != h2ItrE; ++h2Itr){ - TH2* h2 = (*h2Itr).second; - h2->Sumw2(); - CHECK( histSvc->regHist(std::string("/MYSTREAM/")+h2->GetName(),h2) ); - } - - - - // Wanted to restructure this more like real analysis: - // (1) Get objects and apply CP tools for each - // (2) Remove overlaps - // (3) Make plots - // But many tools missing, and intermediate plots useful. Have moved - // collections to xExampleEDM.h to facilitate this later. - - - m_eventCounter = 0; - m_warnCounter = 0; - m_warnLimit = 100; - - //initialize all the tools (configured in the job options) - m_jetCleaningTool.setTypeAndName("JetCleaningTool/JetCleaning"); - CHECK( m_jetCleaningTool.retrieve() ); - - m_akt4LCTopoCalibrationTool.setTypeAndName("JetCalibrationTool/JetCalibLCTopo"); - CHECK( m_akt4LCTopoCalibrationTool.retrieve() ); - - m_akt4EMTopoCalibrationTool.setTypeAndName("JetCalibrationTool/JetCalibEMTopo"); - CHECK( m_akt4EMTopoCalibrationTool.retrieve() ); - - m_metRebuilder.setTypeAndName("met::METRebuilder/metRebuilder"); - CHECK( m_metRebuilder.retrieve() ); - - - // Initialize new object containers - // Will clear them after each execute() - - // Deep copy for Muons - m_newMuons = new xAOD::MuonContainer(); - m_newMuonsAux = new xAOD::MuonAuxContainer(); - m_newMuons->setStore(m_newMuonsAux); - - // Deep copy for Electrons - m_newElectrons = new xAOD::ElectronContainer(); - m_newElectronsAux = new xAOD::ElectronAuxContainer(); - m_newElectrons->setStore(m_newElectronsAux); - - // Deep copy for TauJets - m_newTauJets = new xAOD::TauJetContainer(); - m_newTauJetsAux = new xAOD::TauJetAuxContainer(); - m_newTauJets->setStore(m_newTauJetsAux); - - // Shallow copy used for AntiKt4LCTopo jets. - // m_akt4CopyJets in xExampleEDM.h includes all jets. - // View container provides access to selected jets - m_akt4ViewJets = new xAOD::JetContainer(SG::VIEW_ELEMENTS); - - // Deep copy used for AntiKt4EMTopo jets - m_aktem4NewJets = new xAOD::JetContainer(); - m_aktem4NewJetsAux = new xAOD::JetAuxContainer(); - m_aktem4NewJets->setStore(m_aktem4NewJetsAux); - - // Do NOT initialize containers for rebuilt MET - // This is done in METRebuilder - - - return StatusCode::SUCCESS; -} - -StatusCode xAthExample::finalize() { - ATH_MSG_INFO ("Finalizing " << name() << "..."); - - ATH_MSG_INFO("Finished processing " << m_eventCounter << " events"); - ATH_MSG_INFO("Produced " << m_warnCounter << " retrieve warnings" ); - - - - return StatusCode::SUCCESS; -} - -StatusCode xAthExample::execute() { - ATH_MSG_DEBUG ("Executing " << name() << "..."); - - if(m_eventCounter==0) m_startTime = time(NULL); //time in seconds - - if( (m_eventCounter % 100) ==0 ){ - Info("execute()", "Event number = %i", m_eventCounter ); - } - m_eventCounter++; - - - //////////// - // EventInfo - //////////// - - const xAOD::EventInfo* eventInfo = 0; - if( !evtStore()->retrieve( eventInfo, "EventInfo").isSuccess() ){ - ATH_MSG_ERROR("Failed to retrieve EventInfo collection. Exiting." ); - return StatusCode::FAILURE; - } - - bool isMC = false; - if( eventInfo->eventType(xAOD::EventInfo::IS_SIMULATION) ) isMC = true; - - // Get relative event weights, necessary for JZxW jets, etc. - // Overall weight is sigma*efficiency/Nevent, where sigma and filter - // efficiency are gotten from AMI - - float wt = 1; - const std::vector< float > weights = eventInfo->mcEventWeights(); - if( weights.size() > 0 ) wt = weights[0]; - - - // Pileup - m_TH1["intactual"]->Fill(eventInfo->actualInteractionsPerCrossing(), wt); - m_TH1["intaverage"]->Fill(eventInfo->averageInteractionsPerCrossing(), wt); - m_TH1["intdiff"]->Fill(eventInfo->actualInteractionsPerCrossing() - - eventInfo->averageInteractionsPerCrossing(), wt); - - - /////////////////// - // Primary vertices - /////////////////// - - // Get primary vertices. First vertex has \max \sum p_T^2? - // Should cache \sum pt^2 -- xAOD::Vertex only has multiplicity - - const xAOD::VertexContainer* pVertices = 0; - if( !evtStore()->retrieve(pVertices,"PrimaryVertices") ){ - ATH_MSG_ERROR("Failed to retrieve PrimaryVertices. Exiting." ); - return StatusCode::FAILURE; - } - - // Assume first vertex is correct one - const xAOD::Vertex* pVertex = 0; - if( pVertices->size() > 0 ){ - pVertex = (*pVertices)[0]; - } else { - ATH_MSG_ERROR("Failed to find primary vertex. Exiting" ); - return StatusCode::FAILURE; - } - - // Check \sum pt^2 for vertices. Will be incorrect if tracks have been - // thinned, so do not replace primary vertex choice. - // Need to check validity of *all* ElementLinks. Otherwise code may die - // when run on derived xAOD samples. - - // Note nv2 and nv5 will be *wrong* if tracks are thinned. - - int iVertex = -1; - float pt2PV = 0; - int nv2 = 0; - int nv5 = 0; - - xAOD::VertexContainer::const_iterator vtxItr = pVertices->begin(); - xAOD::VertexContainer::const_iterator vtxItrE = pVertices->end(); - - int ivtx = -1; - for(; vtxItr!=vtxItrE; ++vtxItr){ - ++ivtx; - int ntrkv = (*vtxItr)->nTrackParticles(); - if( ntrkv == 0 ) continue; - if( ntrkv > 1 ) ++nv2; - if( ntrkv > 4 ) ++nv5; - // Find primary vertex - FIXME. - const std::vector< ElementLink<xAOD::TrackParticleContainer> > vxTracks = - (*vtxItr)->trackParticleLinks(); - float ptsum = 0; - for(unsigned int it=0; it<vxTracks.size(); ++it){ - if( (vxTracks[it]).isValid() ){ - // Dereference an ElementLink to get a pointer to the object - const xAOD::TrackParticle* trkit = *(vxTracks[it]); - if( trkit ) ptsum += trkit->p4().Perp2(); - } - } - if( ptsum > pt2PV ){ - pt2PV = ptsum; - iVertex = ivtx; - } - } - - float z0PV = pVertex->z(); - int ntrkVertex = pVertex->nTrackParticles(); - - // Fill histograms - m_TH1["privtxntrk"]->Fill(ntrkVertex, wt); - m_TH1["privtxidx"]->Fill(std::min(iVertex,49), wt); - m_TH1["privtxz0"]->Fill(z0PV, wt); - m_TH1["privtxn2"]->Fill(nv2, wt); - m_TH1["privtxn5"]->Fill(nv5, wt); - - - ////////////////// - // Truth particles - ////////////////// - - // Truth information in xAOD has linked TruthParticle and TruthVertex - // containers. Particles have parent and decay vertices. - // Must follow sequence of decays to find all descendants. - - const xAOD::TruthParticleContainer* truths = 0; - - // Following mainly relevant to ttbar events - std::vector< const xAOD::TruthParticle* > bHadrons; - std::vector< TLorentzVector > wLeptons; - std::vector< TLorentzVector > wElectrons; - std::vector< TLorentzVector > wMuons; - std::vector< TLorentzVector > wTauJets; - std::vector< const xAOD::TruthParticle* > wkids; - - if( isMC ) { - double eTruth = 0; - int nTruth = 0; - - // Note TruthParticle, NOT TruthParticles - // Need contains() test to avoid warning message for each event. - if( evtStore()->contains<xAOD::TruthParticleContainer>("TruthParticle") ){ - if( !evtStore()->retrieve( truths, "TruthParticle" ) ){ - ATH_MSG_ERROR("Failed to retrieve TruthParticle. Exiting." ); - return StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - ATH_MSG_WARNING("Did not find TruthParticle."); - } - ++m_warnCounter; - } - - // MC samples may not contain truth - if( truths ){ - xAOD::TruthParticleContainer::const_iterator tpItr = truths->begin(); - xAOD::TruthParticleContainer::const_iterator tpItrE = truths->end(); - - // Stable particles - // Not for PowhegPythia ttbar! - // Powheg has detached W's with status==3 children and no - // stable descendants. Remove status!=1 and no decayVtx(). - - for( ; tpItr != tpItrE; ++tpItr ) { - - // (*tpItr)->m() gives ZERO - FIXME. - - // Generator stable particles have status==1 && barcode<100000 - // Other status==1 particles are from pileup or Geant - - bool isGS = (*tpItr)->status()==1 && (*tpItr)->barcode()<100000; - - if( isGS ){ - m_TH1["tppt"]->Fill( (*tpItr)->pt()/1000., wt); - m_TH1["tpptlo"]->Fill( (*tpItr)->pt()/1000., wt); - if( (*tpItr)->pt() > 0 ) m_TH1["tpeta"]->Fill( (*tpItr)->eta(), wt); - ++nTruth; - eTruth += (*tpItr)->e(); - } //end isGS - - // Stable particles with decay vertex give Geant secondaries - // Plot vertex location and particle type to see what is being kept - - if( isGS && (*tpItr)->hasDecayVtx() ){ - const xAOD::TruthVertex* dvtx = (*tpItr)->decayVtx(); - if( dvtx ){ - m_TH1["tpvxr"]->Fill( dvtx->perp(), wt); - if( dvtx->perp() > 0 ) m_TH1["tpvxeta"]->Fill( dvtx->eta(), wt); - int idabs = std::abs( (*tpItr)->pdgId() ); - // Plot all hadrons as id=99 - m_TH1["tpvxidin"]->Fill( std::min(idabs,99) ); - } - } - - // B hadrons - plot and save TruthParticle* - if( isBHadron(*tpItr) ){ - m_TH1["tpbpt"]->Fill( (*tpItr)->pt()/1000., wt); - m_TH1["tpbeta"]->Fill( (*tpItr)->eta() , wt); - bHadrons.push_back(*tpItr); - } - - // W leptonic decays - e/mu/tau among first generation children - // Generator specific: used mainly with PowhegPythia6 ttbar sample - // Remove possible virtual W in B decays - - if( abs((*tpItr)->pdgId()) == 24 && (*tpItr)->p4().M() > 5000 ){ - bool badW = false; - bool hadW = true; - const xAOD::TruthVertex* dvtx = 0; - if( (*tpItr)->hasDecayVtx() ) (*tpItr)->decayVtx(); - - // Has valid vertex - if( dvtx ){ - const std::vector< ElementLink<xAOD::TruthParticleContainer> >& - outPart = dvtx->outgoingParticleLinks(); - int lepIda = 0; - for(unsigned int k=0; k<outPart.size(); ++k){ - if( ! (outPart[k]).isValid() ) continue; - const xAOD::TruthParticle* kid = *(outPart[k]); - if( ! kid ) continue; - int kidId = kid->pdgId(); - int kidIda = std::abs(kidId); - - // Remove self-decays, W -> W - if( kidId == (*tpItr)->pdgId() ) badW = true; - // PowhegPythia6 has W's with no real descendants - if( kid->status() != 1 && !(kid->decayVtx()) ) badW = true; - if( !badW ) m_TH1["tpwkid"]->Fill( kid->pdgId() , wt); - - // Find leptonic W decays - if( kidIda==11 || kidIda==13 || kidIda==15 ){ - hadW = false; - lepIda = std::abs(kidId); - wLeptons.push_back( kid->p4() ); - } - } - - // Sum non-neutrino stable descendants, including leptons, - // photons, and hadrons from taus. - // getDescendants replaces HepMC descendants iterator - - if( !hadW && !badW ){ - getDescendants( (*tpItr), wkids ); - TLorentzVector pwvis; - bool nuemu = false; - for(unsigned int kk=0; kk<wkids.size(); ++kk){ - const xAOD::TruthParticle* kid = wkids[kk]; - int ida = std::abs( kid->pdgId() ); - if( ida==12 || ida==14 ) nuemu = true; - if( kid->status()==1 && kid->barcode()<100000 && - ida!=12 && ida!=14 && ida!=16 ){ - pwvis += kid->p4(); - } - } - - if( lepIda==11 ) wElectrons.push_back( pwvis ); - if( lepIda==13 ) wMuons.push_back( pwvis ); - if( lepIda==15 && !nuemu ) wTauJets.push_back( pwvis ); - } - } - }//end id==24 - }//end tpItr - - // Total multiplicity and energy (Ecm hard coded) - // Expect eTruth = Ecm, but not true for PowhegPythia6 ttbar sample - float Ecm = 8000.; - m_TH1["tpnum"]->Fill(nTruth, wt); - m_TH1["tpsum"]->Fill(eTruth/1000. - Ecm, wt); - m_TH1["tpsumlo"]->Fill(eTruth/1000. - Ecm, wt); - - }//end truths - }//end isMC - - - //////// - // Muons - //////// - - // Get the Muons from the event: - m_muons = 0; - if( evtStore()->contains<xAOD::MuonContainer>("Muons") ){ - if( !evtStore()->retrieve(m_muons, "Muons") ){ - ATH_MSG_ERROR("Failed to retrieve Muons. Exiting."); - return StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - ATH_MSG_WARNING("Did not find Muons."); - } - ++m_warnCounter; - } - - if( m_muons ){ - xAOD::MuonContainer::const_iterator muItr = m_muons->begin(); - xAOD::MuonContainer::const_iterator muItrE = m_muons->end(); - - for( ; muItr != muItrE; ++muItr ) { - m_TH1["mupt"]->Fill( (*muItr)->pt()/1000., wt); - m_TH1["mueta"]->Fill( (*muItr)->eta() , wt); - m_TH1["muphi"]->Fill( (*muItr)->phi()/M_PI , wt); - - int mutype = (*muItr)->muonType(); - m_TH1["mutype"]->Fill(mutype, wt); - int muquality = (*muItr)->quality(); - m_TH1["muquality"]->Fill(muquality, wt); - if( mutype!=xAOD::Muon::Combined || muquality!=xAOD::Muon::Tight) continue; - - // Do not have Muon CP tools yet, so just copy' - // Would be done internally by CP correctedCopy() method. - xAOD::Muon* tmpmu = new xAOD::Muon(); - tmpmu->makePrivateStore(**muItr); - m_newMuons->push_back(tmpmu); - }//end muItr - - // Make remaining plots from m_newMuons - - muItr = m_newMuons->begin(); - muItrE = m_newMuons->end(); - - for(; muItr!=muItrE; ++muItr){ - const xAOD::Muon* amuon = (*muItr); - if( amuon->pt() < 20000 ) continue; - - // Kinematics - m_TH1["mugoodpt"]->Fill( amuon->pt()/1000., wt); - m_TH1["mugoodeta"]->Fill( amuon->eta() , wt); - - // Isolation variables are track ptcone20,ptcone30,ptcone40 and - // calorimeter etcone20,etcone30,etcone40. Do just one: - float ptc30 = -666.; - amuon->isolation(ptc30, xAOD::Iso::ptcone30); - m_TH1["muptc30"]->Fill(ptc30/1000., wt); - - // Dereference an ElementLink to get a pointer to the object - // Compare pt of inner detector track and muon - const ElementLink< xAOD::TrackParticleContainer >& idlink = - amuon->inDetTrackParticleLink(); - if( idlink.isValid() ) { - const xAOD::TrackParticle* idtrack = *idlink; - if( idtrack ) { - m_TH1["muidrat"]->Fill( idtrack->pt()/amuon->pt() , wt); - } - } - }//end muItr - }//end m_muons - - - //////////// - // Electrons - //////////// - - m_electrons = 0; - if( evtStore()->contains<xAOD::ElectronContainer>("ElectronCollection") ){ - if( !evtStore()->retrieve(m_electrons, "ElectronCollection") ){ - ATH_MSG_ERROR("Failed to retrieve ElectronCollection. Exiting."); - return StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - ATH_MSG_WARNING("Did not find ElectronCollection."); - } - ++m_warnCounter; - } - - if( m_electrons ){ - // Electron inherits from Egamma, which contains most stuff - // isolation for Muon but isolationValue for Electron - // Iso for Muon but EgammaParameters for Electron - - xAOD::ElectronContainer::const_iterator eItr = m_electrons->begin(); - xAOD::ElectronContainer::const_iterator eItrE = m_electrons->end(); - - for(; eItr != eItrE; ++eItr){ - TLorentzVector pel = (*eItr)->p4(); - m_TH1["elpt"]->Fill( (*eItr)->pt()/1000., wt); - m_TH1["eleta"]->Fill( (*eItr)->eta() , wt); - m_TH1["elphi"]->Fill( (*eItr)->phi()/M_PI , wt); - m_TH1["elauthor"]->Fill( (*eItr)->author() , wt); - - // Select good electrons - no CP tools yet - bool egood = false; - if( (*eItr)->auxdata<char>("Tight") ) egood = true; - m_TH1["elgood"]->Fill(egood, wt); - if( !egood ) continue; - - // Do not have Electron CP tools yet, so just copy. - // Would be done internally by CP correctedCopy() method. - xAOD::Electron* tmpel = new xAOD::Electron(); - tmpel->makePrivateStore(**eItr); - m_newElectrons->push_back(tmpel); - } - - // Make remaining plots from m_newElectrons - - eItr = m_newElectrons->begin(); - eItrE = m_newElectrons->end(); - - for(; eItr!=eItrE; ++eItr){ - const xAOD::Electron* anelectron = (*eItr); - if( anelectron->pt() < 20000 ) continue; - TLorentzVector pel = anelectron->p4(); - - m_TH1["elgoodpt"]->Fill( anelectron->pt()/1000., wt); - m_TH1["elgoodeta"]->Fill( anelectron->eta() , wt); - - m_TH1["elntrk"]->Fill( anelectron->nTrackParticles() , wt); - float pttrk = 0; - if( anelectron->nTrackParticles() > 0 ){ - pttrk = fabs( anelectron->trackParticle(0)->pt() ); - } - if( pttrk>0 ) pttrk = anelectron->pt()/pttrk; - m_TH1["eleoverp"]->Fill( pttrk , wt); - - // Same isolation variables as for muon but different syntax: - // isolation for Muon but isolationValue for Electron - // Iso for Muon but EgammaParameters for Electron - - float etc30 = -666.; - anelectron->isolationValue(etc30, xAOD::Iso::etcone30); - m_TH1["eletc30"]->Fill(etc30, wt); - - // Match to truth electrons from W - // Truth 4-vector is sum of e + gammas from W descendants - float rtrue = 0.999; - float pttrue = -1; - for(unsigned int kk=0; kk<wElectrons.size(); ++kk){ - float drkk = pel.DeltaR( wElectrons[kk] ); - if( drkk < rtrue ) { - rtrue = drkk; - pttrue = wElectrons[kk].Perp(); - } - } - m_TH1["eldrtrue"]->Fill(rtrue,wt); - if( rtrue < 0.1 ) m_TH1["elptrat"]->Fill(anelectron->pt()/pttrue, wt); - - } //end for eItr - }//end m_electrons - - - ////////// - // TauJets - ////////// - - // Get the TauJets from the event: - m_tauJets = 0; - if( evtStore()->contains<xAOD::TauJetContainer>("TauRecContainer") ){ - if( !evtStore()->retrieve(m_tauJets, "TauRecContainer") ){ - ATH_MSG_ERROR("Failed to retrieve TauRecContainer. Exiting."); - return StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - ATH_MSG_WARNING("Did not find TauRecContainer."); - } - ++m_warnCounter; - } - - if( m_tauJets ){ - xAOD::TauJetContainer::const_iterator tauItr = m_tauJets->begin(); - xAOD::TauJetContainer::const_iterator tauItrE = m_tauJets->end(); - - for( ; tauItr != tauItrE; ++tauItr ) { - TLorentzVector ptau = (*tauItr)->p4(); - m_TH1["taupt"]->Fill( (*tauItr)->pt()/1000., wt); - if( (*tauItr)->pt() < 20000 ) continue; - m_TH1["taueta"]->Fill( (*tauItr)->eta() , wt); - m_TH1["tauphi"]->Fill( (*tauItr)->phi()/M_PI , wt); - - // TauID flags - bool tauLoose = - (*tauItr)->isTau( xAOD::TauJetParameters::JetBDTSigLoose ); - bool tauMedium = - (*tauItr)->isTau( xAOD::TauJetParameters::JetBDTSigMedium ); - bool tauTight = - (*tauItr)->isTau( xAOD::TauJetParameters::JetBDTSigTight ); - if( tauLoose ) m_TH1["tauid"]->Fill(1, wt); - if( tauMedium ) m_TH1["tauid"]->Fill(2, wt); - if( tauTight ) m_TH1["tauid"]->Fill(3, wt); - float bdt = (*tauItr)->discriminant( xAOD::TauJetParameters::BDTJetScore ); - m_TH1["taubdt"]->Fill( bdt ); - if( !tauTight ) continue; - - // Remove tight Electron overlaps, DeltaR < 0.2 - float rtaue = 1.999; - for(unsigned int ie=0; ie<m_newElectrons->size(); ++ie){ - const xAOD::Electron* elie = (*m_newElectrons)[ie]; - float dr = ptau.DeltaR(elie->p4()); - if( dr < rtaue ) rtaue = dr; - } - m_TH2["taudrelvpt"]->Fill(ptau.Perp()/1000.,rtaue,wt); - if( rtaue < 0.2 ) continue; - - // Do not have TauJet CP tools yet, so just copy. - // Would be done internally by CP correctedCopy() method. - xAOD::TauJet* tmptau = new xAOD::TauJet(); - tmptau->makePrivateStore(**tauItr); - m_newTauJets->push_back(tmptau); - - }//end for tauItr - - // Make remaining plots from m_newTauJets - - tauItr = m_newTauJets->begin(); - tauItrE = m_newTauJets->end(); - - for(; tauItr!=tauItrE; ++tauItr){ - if( (*tauItr)->pt() < 40000 ) continue; - TLorentzVector ptau = (*tauItr)->p4(); - - m_TH1["taugoodpt"]->Fill( (*tauItr)->pt()/1000., wt); - m_TH1["taugoodeta"]->Fill( (*tauItr)->eta() , wt); - float bdt = (*tauItr)->discriminant( xAOD::TauJetParameters::BDTJetScore ); - m_TH1["taugoodbdt"]->Fill( bdt ); - - // Exercise tracks - // tau->nTracks() gives segfault. FIXME. - // Still true in _r5591_r5625 - /*********** - m_TH1["taugoodntrk"]->Fill( (*tauItr)->nTracks() ); - std::vector< ElementLink<xAOD::TrackParticleContainer> > tautrks = - (*tauItr)->trackLinks(); - for(unsigned int it=0; it<tautrks.size(); ++it){ - if( !(tautrks[it]).isValid() ) continue; - const xAOD::TrackParticle* trk = *(tautrks[it]); - if( trk ) m_TH1["taugoodptrtrk"]->Fill( trk->pt()/(*tauItr)->pt(), wt); - } - ***********/ - - // Match to W -> hadtau nu - float rtrue = 0.999; - float pttrue = -1; - for(unsigned int kk=0; kk<wTauJets.size(); ++kk){ - if( wTauJets[kk].Perp()<=0 ) continue; - float drkk = ptau.DeltaR( wTauJets[kk] ); - if( drkk < rtrue ) { - rtrue = drkk; - pttrue = wTauJets[kk].Perp(); - } - } - - // Match to truth W -> tau nu, !tau -> e,mu - // Sum all isGenStable decay products other than neutrinos - m_TH1["taudrtrue"]->Fill(rtrue, wt); - if( rtrue<0.1 ) m_TH1["tauptrat"]->Fill( (*tauItr)->pt()/pttrue ); - - }//end for tauItr - - for(unsigned int i=0; i<wTauJets.size(); ++i){ - m_TH1["tautruept"]->Fill( wTauJets[i].Perp()/1000. ); - if( wTauJets[i].Perp()<= 0 ) continue; - m_TH1["tautrueeta"]->Fill( wTauJets[i].PseudoRapidity() ); - } - }//end m_tauJets - - - //////////////////// - // AntiKt4Truth Jets - //////////////////// - - m_akt4TruthJets = 0; - if( isMC ){ - if( evtStore()->contains<xAOD::JetContainer>("AntiKt4TruthJets") ){ - if( !evtStore()->retrieve(m_akt4TruthJets, "AntiKt4TruthJets") ){ - ATH_MSG_ERROR("Failed to retrieve AntiKt4TruthJets. Exiting."); - return StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - ATH_MSG_WARNING("Did not find AntiKt4TruthJets."); - } - ++m_warnCounter; - } - - if( m_akt4TruthJets ){ - xAOD::JetContainer::const_iterator aktT4Itr = m_akt4TruthJets->begin(); - xAOD::JetContainer::const_iterator aktT4ItrE = m_akt4TruthJets->end(); - - for(; aktT4Itr != aktT4ItrE; ++aktT4Itr){ - TLorentzVector pjet = (*aktT4Itr)->p4(); - - // Remove leptonic W decays from jets - float rlep = 1.999; - for(unsigned int kk=0; kk<wLeptons.size(); ++kk){ - float drkk = pjet.DeltaR( wLeptons[kk] ); - rlep = TMath::Min(rlep,drkk); - } - if( rlep < 0.4 ) continue; - - // Kinematics - float ptj = (*aktT4Itr)->pt()/1000.; - m_TH1["aktT4pt"]->Fill(ptj, wt); - m_TH1["aktT4ptlo"]->Fill(ptj, wt); - m_TH1["aktT4eta"]->Fill((*aktT4Itr)->eta(), wt); - m_TH1["aktT4phi"]->Fill((*aktT4Itr)->phi()/M_PI, wt); - } - }//end m_akt4TruthJets - }//end isMC - - - //////////////////////////////// - // AntiKt4LCTopo Jets and B jets - //////////////////////////////// - - if( evtStore()->contains<xAOD::JetContainer>("AntiKt4LCTopoJets") ){ - if( !evtStore()->retrieve(m_akt4Jets, "AntiKt4LCTopoJets") ){ - ATH_MSG_ERROR("Failed to retrieve AntiKt4LCTopoJets. Exiting."); - return StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - ATH_MSG_WARNING("Did not find AntiKt4LCTopoJets."); - } - ++m_warnCounter; - } - - // Reconstructed jets - // Set up shallow copy using variables in xExampleEDM.h - - m_badJetPtMax = 0; - - if( m_akt4Jets ){ - m_akt4CopyJets = xAOD::shallowCopyContainer( *m_akt4Jets ); - xAOD::JetContainer::iterator akt4Itr = (m_akt4CopyJets.first)->begin(); - xAOD::JetContainer::iterator akt4ItrE = (m_akt4CopyJets.first)->end(); - - for(; akt4Itr != akt4ItrE; ++akt4Itr){ - bool isGood = true; - TLorentzVector pjet = (*akt4Itr)->p4(); - xAOD::JetFourMom_t p4aod = (*akt4Itr)->jetP4(); - float ptj = (*akt4Itr)->pt()/1000.; - - // Apply cleaning tool - if( !m_jetCleaningTool->keep(**akt4Itr) ){ - m_TH1["akt4ptbad"]->Fill(ptj, wt); - m_TH1["akt4etabad"]->Fill((*akt4Itr)->eta(), wt); - isGood = false; - // Appropriate scale for bad jet? - m_badJetPtMax = std::max(m_badJetPtMax, ptj); - } - - // Apply JetCalibration tool. - // Calibration already applied in valid1 samples; applying it again - // makes JES worse. Should apply to old scale. FIXME. - // JetArea pileup subtraction applied in mc14 samples, so omit it - // in xExample::initialize(). - // jetP4(), setJetP4() use JetFourMom_t, which is a Math::LorentzVector, - // not a TLorentzVector. - - // Shallow copy - if( !m_akt4LCTopoCalibrationTool->applyCalibration(**akt4Itr) ){ - Error("execute()","Cannot apply shallow-copy calibration."); - continue; - } - (*akt4Itr)->setJetP4("xaodscale",p4aod); - - // Link to original jets needed for METRebuilder. See setObjLink in - // https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/METUtilities - // Must do this for EVERY jet - const ElementLink< xAOD::IParticleContainer > link(*m_akt4Jets,(*akt4Itr)->index()); - m_objLinkAcc(**akt4Itr) = link; - - // Calibration factors - for(unsigned int ib=1; ib<16; ++ib){ - if( ptj>ptLim[ib] && ptj<ptLim[ib+1] ){ - std::string str = "akt4calib" + ptStr[ib]; - float calib = (*akt4Itr)->pt()/p4aod.pt(); - m_TH1[str.c_str()]->Fill(calib, wt); - } - } - - // Remove electron overlaps after calibration - // Just omit jet from view container - float rjete = 1.999; - for(unsigned int ie=0; ie<m_newElectrons->size(); ++ie){ - const xAOD::Electron* elie = (*m_newElectrons)[ie]; - float dr = pjet.DeltaR(elie->p4()); - if( dr < rjete ) rjete = dr; - } - m_TH2["akt4drelvpt"]->Fill(pjet.Perp()/1000., rjete, wt); - - // Save jet if not removed by cleaning and does not match electron - if( rjete > 0.2 && isGood ) m_akt4ViewJets->push_back((*akt4Itr)); - - } //end for akt4Itr - - // Save calibrated jets in TStore for METRebuilder in evtStore() - // Hence do NOT delete them at end - - if( !evtStore()->record(m_akt4CopyJets.first, "AntiKt4LCCalibJets") || - !evtStore()->record(m_akt4CopyJets.second, "AntiKt4LCCalibJetsAux.") ){ - ATH_MSG_ERROR("Failed to record AntiKt4LCCalibJets. Exiting."); - return StatusCode::FAILURE; - } - - - // Make calibration plots with recalibrated jets - - xAOD::JetContainer::const_iterator akt4Itr2=(m_akt4ViewJets)->begin(); - xAOD::JetContainer::const_iterator akt4Itr2E=(m_akt4ViewJets)->end(); - - for(; akt4Itr2!=akt4Itr2E; ++akt4Itr2){ - const xAOD::Jet* ajet = (*akt4Itr2); - TLorentzVector pjet = ajet->p4(); - xAOD::JetFourMom_t p4aod = ajet->jetP4("xaodscale"); - - // Match calibrated to truth jets - // Bin in pttrue, so do before pt cut - if( m_akt4TruthJets ){ - float drtrue = 666.; - int itrue = -666; - for(unsigned int it=0; it<m_akt4TruthJets->size(); ++it){ - const xAOD::Jet* jit = (*m_akt4TruthJets)[it]; - float drit = pjet.DeltaR(jit->p4()); - if( drit < drtrue ){ - drtrue = drit; - itrue = it; - } - } - if( itrue > -1 ){ - m_TH1["akt4drtruecalib"]->Fill(drtrue, wt); - float ptjT = ((*m_akt4TruthJets)[itrue])->pt(); - float jescalib = ajet->pt()/ptjT; - float jesaod = p4aod.pt()/ptjT; - ptjT = ptjT/1000.; - if( drtrue < 0.1 ){ - m_TH2["akt4jesvpt"]->Fill(ptjT,jesaod, wt); - for(unsigned int ib=1; ib<16; ++ib){ - if(ptjT>ptLim[ib] && ptjT<ptLim[ib+1]){ - std::string str = "akt4jescalib" + ptStr[ib]; - m_TH1[str.c_str()]->Fill(jescalib, wt); - std::string str2 = "akt4jes" + ptStr[ib]; - m_TH1[str2.c_str()]->Fill(jesaod, wt); - } - } - } - } - }//end m_akt4TruthJets - } //end akt4Itr2 - - - // valid1 samples are produced with calibration; applying it again - // made JES worse. Hence akt4Itr3 with various options. - // Default is for MC14 - - // Make remaining plots with original jets - //xAOD::JetContainer::const_iterator akt4Itr3 = m_akt4Jets->begin(); - //xAOD::JetContainer::const_iterator akt4Itr3E = m_akt4Jets->end(); - - // Make remaining plots with recalibrated jets - xAOD::JetContainer::const_iterator akt4Itr3=(m_akt4ViewJets)->begin(); - xAOD::JetContainer::const_iterator akt4Itr3E=(m_akt4ViewJets)->end(); - - for(; akt4Itr3!=akt4Itr3E; ++akt4Itr3){ - const xAOD::Jet* ajet = (*akt4Itr3); - TLorentzVector pjet = ajet->p4(); - - // Remove leptonic W decays from jets - float rlep = 1.999; - for(unsigned int kk=0; kk<wLeptons.size(); ++kk){ - float drkk = pjet.DeltaR( wLeptons[kk] ); - rlep = std::min(rlep,drkk); - } - m_TH1["akt4rlep"]->Fill(rlep, wt); - if( rlep < 0.4 ) continue; - - // Kinematics - float ptj = (*akt4Itr3)->pt()/1000.; - m_TH1["akt4pt"]->Fill((*akt4Itr3)->pt()/1000., wt); - m_TH1["akt4ptlo"]->Fill((*akt4Itr3)->pt()/1000., wt); - m_TH1["akt4eta"]->Fill((*akt4Itr3)->eta(), wt); - m_TH1["akt4phi"]->Fill((*akt4Itr3)->phi()/M_PI, wt); - - // Apply jet cuts for remaining plots - if( (*akt4Itr3)->pt()<20000. || fabs((*akt4Itr3)->eta())>2.5 ) continue; - - // Jet moment keys listed in xAODJet/JetAttributes.h - - // Plot JVF for all jets - std::vector<float> jvfvec = - (*akt4Itr3)->getAttribute< std::vector<float> >(xAOD::JetAttribute::JVF); - - float jvf0 = -666; - if( (int)jvfvec.size() > iVertex ){ - jvf0 = jvfvec[iVertex]; - } else { - ATH_MSG_WARNING( "Invalid JVF index " << iVertex << " " << jvfvec.size()); - } - - // Plot primary vertex JVF inclusive and binned in ptj - m_TH1["akt4jvf"]->Fill(jvf0, wt); - for(unsigned int ib=1; ib<16; ++ib){ - if( ptj>ptLim[ib] && ptj<ptLim[ib+1] ){ - std::string str = "akt4jvf" + ptStr[ib]; - m_TH1[str.c_str()]->Fill(jvf0, wt); - } - } - - float jvfmax = -666; - float jvfsum = 0; - //Dummy vertex at end? - for(unsigned int ii=0; ii<jvfvec.size(); ++ii){ - jvfsum += jvfvec[ii]; - if( jvfvec[ii] > jvfmax ) jvfmax = jvfvec[ii]; - } - - // Last primary vertex is dummy - m_TH1["akt4jvftot"]->Fill(jvfsum, wt); - for(unsigned int ii=0; ii<jvfvec.size()-1; ++ii ){ - if( (int)ii != iVertex ) m_TH1["akt4jvfx"]->Fill(jvfvec[ii] , wt); - } - - // Truth flavor - int trueid = (*akt4Itr3)->getAttribute<int>("TruthLabelID"); - m_TH1["akt4trueid"]->Fill(trueid, wt); - if( trueid == 5 ){ - m_TH1["akt4ptb"]->Fill((*akt4Itr3)->pt()/1000., wt); - m_TH1["akt4etab"]->Fill((*akt4Itr3)->eta(), wt); - } - - // Flavor tagging - // "Probabilities" for SV1 and IP3D make no sense - FIXME. - // MV1 is always zero - FIXME. - const xAOD::BTagging* btag =(*akt4Itr3)->btagging(); - double mv1 = btag->MV1_discriminant(); - m_TH1["akt4mv1"]->Fill(mv1, wt); - m_TH1["akt4sv1b"]->Fill(btag->SV1_pb(), wt); - m_TH1["akt4sv1u"]->Fill(btag->SV1_pu(), wt); - m_TH2["akt4sv1uvb"]->Fill(btag->SV1_pb(),btag->SV1_pu(), wt); - - // Associated tracks - // Use only tracks with at least 1pixel/6SCT hits - // With pileup need Delta z0 cut - // Does not work with thinned tracks - FIXME. - - std::vector<const xAOD::IParticle*> jtracks; - jtracks = (*akt4Itr3)->getAssociatedObjects<xAOD::IParticle>( xAOD::JetAttribute::GhostTrack ); - int ntracks = 0; - TLorentzVector psum(0,0,0,0); - for(unsigned int jj=0; jj<jtracks.size(); ++jj){ - const xAOD::TrackParticle* trkjj = dynamic_cast<const xAOD::TrackParticle*>(jtracks[jj]); - if( trkjj->pt() < 1000 ) continue; - uint8_t npix = 0; - uint8_t nsct = 0; - if( !trkjj->summaryValue(npix,xAOD::numberOfPixelHits)) continue; - if( !trkjj->summaryValue(nsct,xAOD::numberOfSCTHits)) continue; - m_TH1["akt4nsitrk"]->Fill(npix+nsct, wt); - if( npix<1 || nsct<6 ) continue; - // z for track and primary vertex in different frames - float dz0 = trkjj->z0()+trkjj->vz() - z0PV; - m_TH1["akt4dz0trk"]->Fill( dz0, wt); - if( std::abs( dz0*sin(trkjj->theta())) > 1.5 ) continue; - ++ntracks; - TLorentzVector ptrk = trkjj->p4(); - psum += ptrk; - m_TH1["akt4rtrk"]->Fill( pjet.DeltaR(ptrk) , wt); - } - - // Protect against occasional track pt >> 1TeV - double rat = psum.Pt() / (*akt4Itr3)->pt(); - rat = std::min(rat,3.0); - for(unsigned int ib=1; ib<16; ++ib){ - if( ptj>ptLim[ib] && ptj<ptLim[ib+1] ){ - std::string str = "akt4rtrk" + ptStr[ib]; - m_TH1[str.c_str()]->Fill(rat, wt); - } - } - m_TH1["akt4ntrk"]->Fill(ntracks , wt); - - } //end for akt4Itr3 - }//end m_akt4Jets - - - ///////////////////// - // AntiKt4EMTopo Jets - ///////////////////// - - m_aktem4Jets = 0; - if( evtStore()->contains<xAOD::JetContainer>("AntiKt4EMTopoJets") ){ - if( !evtStore()->retrieve(m_aktem4Jets, "AntiKt4EMTopoJets") ){ - ATH_MSG_ERROR("Failed to retrieve AntiKt4EMTopoJets. Exiting."); - return StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - ATH_MSG_WARNING("Did not find AntiKt4EMTopoJets."); - } - ++m_warnCounter; - } - - if( m_aktem4Jets ){ - xAOD::JetContainer::const_iterator aktem4Itr = m_aktem4Jets->begin(); - xAOD::JetContainer::const_iterator aktem4ItrE = m_aktem4Jets->end(); - - // This is a simple example utilizing a deep copy for jets to count - // uncalibrated and calibrated jets with pt > 100GeV. - // NOT an efficient way to make this trivial plot. - - int njet100 = 0; - for(; aktem4Itr != aktem4ItrE; ++aktem4Itr){ - TLorentzVector pjet = (*aktem4Itr)->p4(); - xAOD::JetFourMom_t p4aod = (*aktem4Itr)->jetP4(); - if( (*aktem4Itr)->pt() > 100000 ) ++njet100; - - // Make the deep copy. MUST initialize pointer to 0. - xAOD::Jet* calibJet = 0; - m_akt4EMTopoCalibrationTool->calibratedCopy(**aktem4Itr, calibJet); - calibJet->setJetP4("xaodscale",p4aod); - - // ALWAYS give ownership to a DataVector, which can delete properly. - // "delete calibJet" does NOT work. - m_aktem4NewJets->push_back(calibJet); - - // Delete unwanted jet. STL methods for removing items from vectors - // are overloaded to work properly. - if( calibJet->pt() < 100000 ) m_aktem4NewJets->pop_back(); - } - - m_TH1["aktem4n100"]->Fill(njet100, wt); - m_TH1["aktem4ncalib100"]->Fill(m_aktem4NewJets->size(), wt); - }//end m_aktem4Jets - - - ///////////// - // Missing ET - ///////////// - - // First just plot (uncalibrated) MET from xAOD - - const xAOD::MissingETContainer* METFinals = 0; - if( evtStore()->contains<xAOD::MissingETContainer>("MET_RefFinal") ){ - if( !evtStore()->retrieve(METFinals, "MET_RefFinal") ){ - ATH_MSG_ERROR("Failed to retrieve MET_RefFinal. Exiting."); - return StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - ATH_MSG_WARNING("Did not find MET_RefFinal."); - } - ++m_warnCounter; - } - - const xAOD::MissingETContainer* METTruths = 0; - if( evtStore()->contains<xAOD::MissingETContainer>("MET_Truth") ){ - if( !evtStore()->retrieve(METTruths, "MET_Truth") ){ - ATH_MSG_ERROR("Failed to retrieve MET_Truth. Exiting."); - return StatusCode::FAILURE; - } - } else { - if( m_warnCounter < m_warnLimit ){ - ATH_MSG_WARNING("Did not find MET_Truth."); - } - ++m_warnCounter; - } - - // Each MissingETContainer has multiple versions labeled by strings - // See METReaderAlg.cxx. Examples include - // (*METFinals)["Final"] (*METTruths)["NonInt"] - // (*METFinals)["RefEle"] (*METTruths)["Int"] - // (*METFinals)["RefGamma"] (*METTruths)["IntOut"] - // (*METFinals)["RefTau"] (*METTruths)["IntMuons"] - // (*METFinals)["RefJet"] - // (*METFinals)["Muons"] - // (*METFinals)["SoftClus"] - // (*METFinals)["SoftClus"] - - const xAOD::MissingET* metRefFinal = 0; - if( METFinals ) metRefFinal = (*METFinals)["Final"]; - const xAOD::MissingET* metTruth = 0; - if( METTruths ) metTruth = (*METTruths)["NonInt"]; - - if( metRefFinal ){ - m_TH1["metet"]->Fill( metRefFinal->met()/1000., wt); - m_TH1["metetlo"]->Fill( metRefFinal->met()/1000., wt); - m_TH1["metsum"]->Fill( metRefFinal->sumet()/1000., wt); - } - - if( metTruth ){ - m_TH1["mettrueet"]->Fill(metTruth->met()/1000., wt); - m_TH1["mettrueetlo"]->Fill(metTruth->met()/1000., wt); - m_TH1["mettruesum"]->Fill(metTruth->sumet()/1000., wt); - } - - // Recalculate MET with calibrated jets - // Remaining inputs are default - see initialize() - - if( !m_metRebuilder->execute() ){ - ATH_MSG_ERROR("Failed to execute METRebuilder. Exiting."); - return StatusCode::FAILURE; - } - - // Retrieve new MET - name set in initialize(). - - m_metCalibs = 0; - if( !evtStore()->retrieve(m_metCalibs, "MET_CalibFinal") ){ - ATH_MSG_ERROR("Failed to retrieve MET_CalibFinal. Exiting."); - return StatusCode::FAILURE; - } - const xAOD::MissingET* metCalibFinal = 0; - if( m_metCalibs ) metCalibFinal = (*m_metCalibs)["Final"]; - - // Histogram new MET - if( metCalibFinal ){ - m_TH1["metcalibet"]->Fill( metCalibFinal->met()/1000., wt); - m_TH1["metcalibetlo"]->Fill( metCalibFinal->met()/1000., wt); - m_TH1["metcalibsum"]->Fill( metCalibFinal->sumet()/1000., wt); - } - - - //////////////////////// - // Clear copy containers - //////////////////////// - - // Deep copies. Clearing containers deletes contents including AuxStore. - m_newMuons->clear(); - m_newElectrons->clear(); - m_newTauJets->clear(); - - // For AntiKt4LCTopo shallow copy - // Clearing view container does not delete contents - // m_akt4CopyJets saved in TStore so NOT deleted. - m_akt4ViewJets->clear(); - - // For AntiKt4EMTopo deep copy - // Clearing container deletes contents - m_aktem4NewJets->clear(); - - - - // Close with a message: - if( ((m_eventCounter-1) % 100) == 0 ){ - Info( "execute()", - "===>>> done processing event #%i, " - "run #%i %i events processed so far <<<===", - static_cast< int >( eventInfo->eventNumber() ), - static_cast< int >( eventInfo->runNumber() ), - static_cast< int >( m_eventCounter ) ); - Info("execute()","Processing rate = %f Hz", float(m_eventCounter)/(time(NULL)-m_startTime)); - } - - - return StatusCode::SUCCESS; -} - - diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/CPAnalysisExamples.xml b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/CPAnalysisExamples.xml deleted file mode 100644 index 47d18250fba07234e27e62bdc35a8c8a78b644e7..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/CPAnalysisExamples.xml +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0"?> -<atn> - <TEST name="ut_ath_checkTrigger_test" type="script" suite="ASGTests"> - <options_atn>skip_if_libraryMissing.sh CPAnalysisExamples - ut_ath_checkTrigger_test.exe</options_atn> - <timelimit>10</timelimit> - <author> Will Buttinger </author> - <mailto> will@cern.ch </mailto> - <expectations> - <errorMessage> Athena exited abnormally </errorMessage> - <errorMessage>FAILURE (ERROR)</errorMessage> - <returnValue>0</returnValue> - </expectations> - <postscript>skip_if_libraryMissing.sh CPAnalysisExamples rootcomp.py --chi2 --atnMode --output rootcomp_Test_ut_ath_checkTrigger_test.results.root Test_ut_ath_checkTrigger_test.results.root && root2html.py *.root -</postscript> - </TEST> - - <TEST name="Test__EgammaCalibrationAndSmearingTool" type="script" suite="ASGTests"> - <options_atn>skip_if_libraryMissing.sh CPAnalysisExamples athena.py CPAnalysisExamples/Test__EgammaCalibrationAndSmearingToolJobOptions.py</options_atn> - <timelimit>10</timelimit> - <author> Egamma CP Group </author> - <mailto> ruggero.turra@cern.ch </mailto> - <expectations> - <errorMessage> Athena exited abnormally </errorMessage> - <errorMessage>FAILURE (ERROR)</errorMessage> - <returnValue>0</returnValue> - </expectations> - <postscript>skip_if_libraryMissing.sh CPAnalysisExamples rootcomp.py --atnMode --output rootcomp_Test_EgammaCalibrationAndSmearingTool.results.root Test_EgammaCalibrationAndSmearingTool.results.root && root2html.py *.root</postscript> - </TEST> - - <TEST name="Test__TrackLinkTest" type="script" suite="ASGTests"> - <options_atn>skip_if_libraryMissing.sh CPAnalysisExamples athena.py CPAnalysisExamples/Test__TrackLinkTestJobOptions.py</options_atn> - <timelimit>5</timelimit> - <author> Thomas Maier </author> - <mailto> tmaier@cern.ch </mailto> - <expectations> - <errorMessage> Athena exited abnormally </errorMessage> - <errorMessage>FAILURE (ERROR)</errorMessage> - <returnValue>0</returnValue> - </expectations> - </TEST> - - <TEST name="CPAnalysisExamples_makecheck" type="makecheck" suite="ASGTests"> - <package>CPAnalysisExamples</package> - <timelimit>5</timelimit> - <author>Will Buttinger</author> - <mailto> will@cern.ch </mailto> - <expectations> - <errorMessage> Athena exited abnormally </errorMessage> - <errorMessage>differ</errorMessage> - <returnValue>0</returnValue> - </expectations> - </TEST> -</atn> diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/CPAnalysisExamples_TestConfiguration.xml b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/CPAnalysisExamples_TestConfiguration.xml deleted file mode 100755 index 37c8448bea275e0d54724933302f41a5d5c3fa31..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/CPAnalysisExamples_TestConfiguration.xml +++ /dev/null @@ -1,86 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE unifiedTestConfiguration SYSTEM "http://www.hep.ucl.ac.uk/atlas/AtlasTesting/DTD/unifiedTestConfiguration.dtd"> - -<unifiedTestConfiguration> - -<atn> - <TEST name="xAODSkimTest" type="script" suite="ASGTests"> - <options_atn>skip_if_libraryMissing.sh CPAnalysisExamples athena.py CPAnalysisExamples/skimxAODJobOptions.py</options_atn> - <timelimit>10</timelimit> - <author> Will Buttinger </author> - <mailto> will@cern.ch </mailto> - <expectations> - <errorMessage>ERROR </errorMessage> - <returnValue>0</returnValue> - </expectations> - </TEST> - - <TEST name="xAODSkimExamples" type="script" suite="ASGTests"> - <options_atn>skip_if_libraryMissing.sh CPAnalysisExamples athena.py CPAnalysisExamples/skimmingExampleJobOptions.py</options_atn> - <timelimit>5</timelimit> - <author> Will Buttinger </author> - <mailto> will@cern.ch </mailto> - <expectations> - <errorMessage>ERROR </errorMessage> - <returnValue>0</returnValue> - </expectations> - </TEST> - -</atn> - - - - <rtt xmlns="http://www.hep.ucl.ac.uk/atlas/AtlasTesting/rtt"> - - <rttContactPerson>Monica Dobre</rttContactPerson> - <mailto>monica.dobre@cern.ch</mailto> - - <jobList> - <classification> - <displayClass>OfflineValidation</displayClass> - <displayProcess>Reco</displayProcess> - <displayComponent>Athena-Core</displayComponent> - </classification> - - <athena userJobId="AnaTest8TeV"> - <doc> - Test a 8 TeV xAOD file - </doc> - <displayName>AnaTest8TeV</displayName> - <options>xAthExample_8TeV_jobOptions.py</options> - <package>PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples</package> - <group>CPAnaAthTest</group> - <queue>medium</queue> - <testToRemove> - <jobGroupName>RTT:Top</jobGroupName> - <testidentifier>CheckFileRunner0</testidentifier> - </testToRemove> - </athena> - - <athena userJobId="AnaTest13TeV"> - <doc> - Test a 13 TeV xAOD file - </doc> - <displayName>AnaTest13TeV</displayName> - <options>xAthExample_13TeV_jobOptions.py</options> - <package>PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples</package> - <group>CPAnaAthTest</group> - <queue>medium</queue> - <testToRemove> - <jobGroupName>RTT:Top</jobGroupName> - <testidentifier>CheckFileRunner0</testidentifier> - </testToRemove> - </athena> - - - </jobList> - - <jobGroups> - <jobGroup name="CPAnaAthTest" parent="Transform"> - - </jobGroup> - </jobGroups> - - - </rtt> -</unifiedTestConfiguration> diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_accessData.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_accessData.cxx deleted file mode 100644 index b91cdd04ba21b305e453b5fa4741010463fee0fa..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_accessData.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: ut_accessData.cxx 638120 2015-01-07 19:10:02Z sfarrell $ - -// System include(s): - -// ROOT include(s): -#include <TFile.h> - -// Infrastructure include(s): -#ifdef ROOTCORE -# include "xAODRootAccess/Init.h" -# include "xAODRootAccess/TEvent.h" -#endif // ROOTCORE - -// EDM include(s): -#include "xAODJet/JetContainer.h" - -// Local include(s): -#include "CPAnalysisExamples/errorcheck.h" - -int main( int /*argc*/, char* argv[] ) { - - // The application's name: - const char* APP_NAME = argv[ 0 ]; - - //bool m_debug = true; - - // Initialise the application: - CHECK( xAOD::Init( APP_NAME ) ); - - // Open the input file: - const TString fileName = "/afs/cern.ch/atlas/project/PAT/xAODs/r5591/mc14_8TeV.177998.MadGraphPythia_AUET2BCTEQ6L1_ttbargammaPt80_noAllHad_fixed.merge.AOD.e2189_s1933_s1911_r5591_r5625_tid01593004_00/AOD.01593004._000018.pool.root.1"; - - Info( APP_NAME, "Opening file: %s", fileName.Data() ); - TFile * ifile( TFile::Open( fileName, "READ" ) ); - if (!ifile) Error(APP_NAME, "Cannot find file " + fileName); - - // Create a TEvent object: - xAOD::TEvent event( ifile, xAOD::TEvent::kClassAccess ); - CHECK( event.readFrom( ifile ) ); - Info( APP_NAME, "Number of events in the file: %i", - static_cast< int >( event.getEntries() ) ); - - // Decide how many events to run over: - Long64_t entries = event.getEntries(); - - for( Long64_t entry = 0; entry < entries; ++entry ) - { - Info( APP_NAME, "Running on event %i", ((int)entry)); - // Tell the object which entry to look at: - event.getEntry( entry ); - - /***************************************/ - // test jets - - // Get the Jets from the event: - const xAOD::JetContainer* jets = 0; - CHECK( event.retrieve( jets, "AntiKt4LCTopoJets" ) ); - } - - - - // Return gracefully: - return 0; -} diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_accessDataAndCPTools_13TeV.sh b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_accessDataAndCPTools_13TeV.sh deleted file mode 100755 index 87620d8862e6680a3278ff7c596131e2832a21d7..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_accessDataAndCPTools_13TeV.sh +++ /dev/null @@ -1,19 +0,0 @@ -#! /bin/bash - -if [ -z "$ROOTCORE_RELEASE_SERIES" ] -then - echo ROOTCORE_RELEASE_SERIES not set, exiting..... - return 1 -fi - - -if [ $ROOTCORE_RELEASE_SERIES == 23 ] -then - - run_ut_accessDataAndCpTools_v20 $ROOTCORE_TEST_FILE - -else - - echo 'ut test not suitable for release series '$ROOTCORE_RELEASE_SERIES - -fi \ No newline at end of file diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_accessDataAndCPTools_8TeV.sh b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_accessDataAndCPTools_8TeV.sh deleted file mode 100755 index ccbb702224907893449fa2cdc9d5789aa982a62b..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_accessDataAndCPTools_8TeV.sh +++ /dev/null @@ -1,14 +0,0 @@ -#! /bin/bash - -if [ -z "$ROOTCORE_RELEASE_SERIES" ] -then - echo ROOTCORE_RELEASE_SERIES not set, exiting..... - return 1 -fi - -if [ ${ROOTCORE_RELEASE_SERIES} == 21 ] -then - run_ut_accessDataAndCpTools $ROOTCORE_TEST_FILE -else - echo 'ut test not suitable for release series '$ROOTCORE_RELEASE_SERIES -fi \ No newline at end of file diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_ath_EgammaCalibrationAndSmearingTool_test.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_ath_EgammaCalibrationAndSmearingTool_test.cxx deleted file mode 100644 index 324874e15576192624770c660ae342d802834ad0..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_ath_EgammaCalibrationAndSmearingTool_test.cxx +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef ROOTCORE - -///Example standalone executable using POOL to read an xAOD -///Tests the EgammaCalibrationAndSmearingTool -///You can create a skeleton application yourself with: cmt new_analysisapp MyApp -/// -///See src/Test__EgammaCalibrationAndSmearingTool.cxx and share/Test_EgammaCalibrationAndSmearingToolJobOptions.py -///for how to do the equivalent as an athena framework job -/// -///Author: Will Buttinger -/// - -#include "AthAnalysisBaseComps/AthAnalysisHelper.h" //tool creation and configuration -#include "POOLRootAccess/TEvent.h" //event looping -#include "GaudiKernel/ToolHandle.h" //for better working with tools - -#include "AsgTools/MessageCheck.h" //messaging -using namespace asg::msgUserCode; //messaging - -//EDM includes -#include "xAODEgamma/ElectronContainer.h" -#include "xAODCore/ShallowCopy.h" - -//ROOT includes -#include "TString.h" -#include "TSystem.h" - -//specific includes for this test -#include "ElectronPhotonFourMomentumCorrection/IEgammaCalibrationAndSmearingTool.h" -#include "GaudiKernel/IChronoStatSvc.h" - -int main( int argc, char* argv[] ) { - - IAppMgrUI* app = POOL::Init(); //important to do this first! - - // The application's name: - const char* APP_NAME = argv[ 0 ]; - - // Open the input file: - TString fileName = "$ASG_TEST_FILE_MC"; - if( argc < 2 ) { - ANA_MSG_WARNING( "No file name received, using $ASG_TEST_FILE_MC" ); - if (getenv ("ASG_TEST_FILE_MC") == nullptr) - fileName = "/afs/cern.ch/user/a/asgbase/patspace/xAODs/r7725/mc15_13TeV.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.merge.AOD.e3698_s2608_s2183_r7725_r7676/AOD.07915862._000100.pool.root.1"; - } else { - fileName = argv[1]; //use the user provided file - } - ANA_MSG_INFO("Opening file: " << gSystem->ExpandPathName(fileName.Data()) ); - - //create instance of EgammaCalibrationAndSmearingTool - //will request with the interface class: CP::IEgammaCalibrationAndSmearingTool - auto myTool = AthAnalysisHelper::createTool<CP::IEgammaCalibrationAndSmearingTool>("CP::EgammaCalibrationAndSmearingTool/myTool"); - AthAnalysisHelper::setProperty( myTool, "ESModel", "es2015PRE" ); - myTool->initialize(); - - //The preferred way to create and configure the tool is with a ToolHandle: - ToolHandle<CP::IEgammaCalibrationAndSmearingTool> myBetterTool("CP::EgammaCalibrationAndSmearingTool/myTool"); - AthAnalysisHelper::setProperty( myBetterTool, "ESModel", "es2015PRE" ); - myBetterTool.retrieve(); //this will cause the tool to be created and initialized - - //loop over input file with POOL - POOL::TEvent evt; - evt.readFrom( fileName ); - - //example of accessing a service, here we will make the ChronoStatSvc display information - ServiceHandle<IChronoStatSvc> chronoSvc("ChronoStatSvc",APP_NAME); - AthAnalysisHelper::setProperty( chronoSvc , "PrintUserTime", true ); //display CPU time - AthAnalysisHelper::setProperty( chronoSvc , "PrintEllapsedTime", true ); //display wall clock time - - AthAnalysisHelper::setProperty( evt.evtLoop() , "UseDetailChronoStat" , true ); //enable chrono information tracking for our event loop - - int nEntries = 500; //evt.getEntries(); - - for(int i=0;i < nEntries; i++) { - if( evt.getEntry(i) < 0) { ANA_MSG_ERROR("Failed to read event " << i); continue; } - - //get the electrons - const xAOD::ElectronContainer* xaod_els = 0; - if( evt.retrieve( xaod_els , "Electrons" ).isFailure() ) { - ANA_MSG_ERROR("Could not retrieve electrons"); return -1; - } - - //create a shallow copy and calibrate - auto calibratedElectrons = xAOD::shallowCopyContainer( *xaod_els ); - for(auto el : *calibratedElectrons.first) myTool->applyCorrection(*el).setChecked(); - - //for first 10 events we will print out the calibrated and uncalibrated Pt for comparison - if(i<10) { - for(uint j=0;j<xaod_els->size();j++) { - ANA_MSG_INFO("Uncalibrated Pt = " << xaod_els->at(j)->pt() << " , Calibrated Pt = " << calibratedElectrons.first->at(j)->pt()); - } - } - - //cleanup the shallow copy - delete calibratedElectrons.first; - delete calibratedElectrons.second; //the auxstore - - } - - - delete myTool; - - app->finalize(); //trigger finalization of all services and tools created by the Gaudi Application - - return 0; -} - -#endif diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_ath_checkTrigger_test.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_ath_checkTrigger_test.cxx deleted file mode 100644 index 4917ac46b602813946704767b0427afe0de035ca..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/test/ut_ath_checkTrigger_test.cxx +++ /dev/null @@ -1,109 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef ROOTCORE - -///Example standalone executable using POOL to read an xAOD -///Tests the TrigDecisionTool ... shows example usage -///You can create a skeleton application yourself with: cmt new_analysisapp MyApp -/// -///Author: Will Buttinger -/// - -#include "AthAnalysisBaseComps/AthAnalysisHelper.h" //tool creation and configuration -#include "POOLRootAccess/TEvent.h" //event looping -#include "GaudiKernel/ToolHandle.h" //for better working with tools - -#include "AsgTools/MessageCheck.h" //messaging -using namespace asg::msgUserCode; //messaging - -//EDM includes - -//ROOT includes -#include "TString.h" -#include "TSystem.h" -#include "TStopwatch.h" -#include "TH1D.h" -#include "TFile.h" - -//specific includes for this test -#include "TrigDecisionTool/TrigDecisionTool.h" -#include "GaudiKernel/IChronoStatSvc.h" - -int main( int argc, char* argv[] ) { - - IAppMgrUI* app = POOL::Init(); //important to do this first! - - // The application's name: - const char* APP_NAME = argv[ 0 ]; - - // Open the input file: - TString fileName = "$ASG_TEST_FILE_MC"; - std::string trigger; - if( argc < 2 ) { - ANA_MSG_WARNING("Usage: ut_ath_checkTrigger_test.exe <trigger> <file>"); - ANA_MSG_WARNING("Using trigger = L1_2EM15"); - trigger = "L1_2EM15"; - } else { - trigger = argv[1]; - } - POOL::TEvent::EReadMode mode = POOL::TEvent::kPOOLAccess; //POOL is slowest, but it can read everything! - if( argc < 3 ) { - ANA_MSG_WARNING( "No file name received, using $ASG_TEST_FILE_MC" ); - if (getenv ("ASG_TEST_FILE_MC") == nullptr) - fileName = "/afs/cern.ch/user/a/asgbase/patspace/xAODs/r7725/mc15_13TeV.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.merge.AOD.e3698_s2608_s2183_r7725_r7676/AOD.07915862._000100.pool.root.1"; - - } else { - fileName = argv[2]; //use the user provided file - //assume it's a DxAOD, switch to faster mode - mode = POOL::TEvent::kClassAccess; - } - ANA_MSG_INFO("Opening file: " << gSystem->ExpandPathName(fileName.Data()) ); - - //The preferred way to create and configure tools is with a ToolHandle: - //constructor argument is: Type/Name - ToolHandle<Trig::TrigDecisionTool> tdt("Trig::TrigDecisionTool/TrigDecisionTool"); - tdt.retrieve(); //this will cause the tool to be created and initialized - - //loop over input file with xAODRootAccess mode - POOL::TEvent evt(mode); - evt.readFrom( fileName ); - - //example of accessing a service, here we will make the ChronoStatSvc display information - ServiceHandle<IChronoStatSvc> chronoSvc("ChronoStatSvc",APP_NAME); - AAH::setProperty( chronoSvc , "ChronoPrintOutTable", true ); - AAH::setProperty( chronoSvc , "PrintUserTime", true ); //display CPU time - AAH::setProperty( chronoSvc , "PrintEllapsedTime", true ); //display wall clock time - AAH::setProperty( evt.evtLoop() , "UseDetailChronoStat" , true ); //enable chrono information tracking for our event loop - - evt.getEntry(0); //first event here so dont count in timer stats - int passCount(0); - TStopwatch timer; - timer.Start(); - for(int i=0;i < evt.getEntries(); i++) { - if( evt.getEntry(i) < 0) { ANA_MSG_ERROR("Failed to read event " << i); continue; } - if(tdt->isPassed(trigger)) passCount++; - } - timer.Stop(); - - TFile f1("Test_ut_ath_checkTrigger_test.results.root","RECREATE"); - TH1D* h = new TH1D("processingRate","Trigger Processing Rate in Hz",1,0,1); - h->Sumw2(); - h->SetBinContent(1,double(evt.getEntries())/timer.RealTime()); - h->SetBinError(1,10); //allow +/- 10Hz fluctuations - h->Write(); - h = new TH1D("pass_L1_2EM15","Number of events passing L1_2EM15",1,0,1); - h->Sumw2(); - h->SetBinContent(1,passCount);h->SetBinError(1,0.0001); - h->Write(); - f1.Close(); - - app->finalize(); //trigger finalization of all services and tools created by the Gaudi Application - - ANA_MSG_INFO("Number of events passing trigger " << trigger << ": " << passCount); - - return 0; -} - -#endif diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/CPSystematicExample.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/CPSystematicExample.cxx deleted file mode 100644 index af6361331bc7ec9376eba7a9dbbc3defc3a36068..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/CPSystematicExample.cxx +++ /dev/null @@ -1,360 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: CPSystematicExample.cxx 300492 2014-04-30 14:39:05Z krasznaa $ - -// System include(s): -#include <memory> -#include <cstdlib> - -// ROOT include(s): -#include <TFile.h> -#include <TError.h> -#include <TString.h> -#include <TTree.h> - - -// Infrastructure include(s): -#ifdef ROOTCORE -# include "xAODRootAccess/Init.h" -# include "xAODRootAccess/TEvent.h" -#endif // ROOTCORE - -// EDM include(s): -#include "xAODEventInfo/EventInfo.h" -#include "xAODJet/JetContainer.h" -#include "xAODJet/JetAuxContainer.h" -#include "xAODCore/ShallowCopy.h" - -// Local include(s): -#include "CPAnalysisExamples/errorcheck.h" -#include "CPAnalysisExamples/JetCalibrationToolExample.h" - -// Other includes -#include "PATInterfaces/SystematicVariation.h" -#include "PATInterfaces/SystematicRegistry.h" -#include "PATInterfaces/SystematicCode.h" -#include "PATInterfaces/SystematicsUtil.h" -#include "boost/unordered_map.hpp" - -bool ptsorter( const xAOD::IParticle* j1, const xAOD::IParticle* j2 ) { - return ( j1->pt() > j2->pt() ); -} - - -int main( int argc, char* argv[] ) { - - // The application's name: - const char* APP_NAME = argv[ 0 ]; - - bool m_debug = false; - - // Check if we received a file name: - if( argc < 2 ) { - Error( APP_NAME, "No file name received!" ); - Error( APP_NAME, " Usage: %s [xAOD file name]", APP_NAME ); - return 1; - } - - // Initialise the application: - CHECK( xAOD::Init( APP_NAME ) ); - - // Open the input file: - const TString fileName = argv[ 1 ]; - Info( APP_NAME, "Opening file: %s", fileName.Data() ); - TFile * ifile( TFile::Open( fileName, "READ" ) ); - if (!ifile) Error(APP_NAME, "Cannot find file " + fileName); - - // Create a TEvent object: - xAOD::TEvent event( ifile, xAOD::TEvent::kClassAccess ); - CHECK( event.readFrom( ifile ) ); - Info( APP_NAME, "Number of events in the file: %i", - static_cast< int >( event.getEntries() ) ); - - // Create a transient object store. Needed for the tools. - xAOD::TStore store; - - // Decide how many events to run over: - Long64_t entries = event.getEntries(); - if( argc > 2 ) { - const Long64_t e = atoll( argv[ 2 ] ); - if( e < entries ) { - entries = e; - } - } - - // Create the tool(s) to test: - // The tool will take care of registering the systematics - CP::JetCalibrationToolExample jetTool( "JetCalibration" ); - - - - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // IMPORTANT: tools need to be initialized before querying systematics - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - jetTool.msg().setLevel( MSG::INFO ); - CHECK( jetTool.initialize() ); - - - - // In this example, we'll just take all of the recommended - // systematics and loop over them one at a time. A more - // sophisticated example would call another tool to place the - // systematics we evaluate more carefully. this may involve - // writing out the list of systematics to a file, ending this - // program running another tool, and then restarting this program - // with the generated list of systematics. - - // This example only uses the set of recommended systematics. That - // may or may not be the right thing, depending on the tool and - // analysis in question. - - const CP::SystematicRegistry& registry = CP::SystematicRegistry::getInstance(); - const CP::SystematicSet& recommendedSystematics = registry.recommendedSystematics(); - std::vector<CP::SystematicSet> sysList = - CP::make_systematics_vector(recommendedSystematics); - - - // Initialize the output - - // In the output file, we will have one tree per nuisance parameter point. - TFile* outputFile = TFile::Open("output.root", "recreate"); - // SystematicSet caches its hash value, so it's perfect for unordered_map! - boost::unordered_map<CP::SystematicSet, TTree*> sysTreeMap; - - // One output branch for this example - float dijet_mass = 0; - - for (const auto& sys : sysList) - { - std::string treeName = "l_tree_" + sys.name(); - TTree* sysTree = new TTree(treeName.c_str(), "An example tree"); - sysTree->Branch("mass", &dijet_mass, "mass/F"); - sysTreeMap[sys] = sysTree; - } - - // User selection decoration - SG::AuxElement::Accessor<unsigned int> passSelection("passSelection"); - - // Loop over the events: - for( Long64_t entry = 0; entry < entries; ++entry ) - { - if (m_debug) Info( APP_NAME, "Running on event %llu", entry ); - - // Tell the object which entry to look at: - event.getEntry( entry ); - - // Print some event information for fun: - const xAOD::EventInfo* ei = 0; - CHECK( event.retrieve( ei, "EventInfo" ) ); - if (m_debug) { - Info( APP_NAME, - "===>>> start processing event #%i, " - "run #%i %i events processed so far <<<===", - static_cast< int >( ei->eventNumber() ), - static_cast< int >( ei->runNumber() ), - static_cast< int >( entry ) ); - } - - // Get the Jets from the event: - const xAOD::JetContainer* jets = 0; - CHECK( event.retrieve( jets, "AntiKt4LCTopoJets" ) ); - if (m_debug) { - Info( APP_NAME, "Number of jets: %i", - static_cast< int >( jets->size() ) ); - } - - // Debugging: print 4-vector of jets - if (m_debug) Info( APP_NAME, "Printing jet 4-vector"); - - // This can be used in the example of correctedCopy below - xAOD::JetContainer::iterator jetItr; - - dijet_mass = 0; - - // Loop over systematic uncertainties - for (const auto& sys : sysList) - { - - // Tell the jet tool which variation to apply - if (jetTool.applySystematicVariation(sys) != CP::SystematicCode::Ok) { - Error(APP_NAME, "Cannot configure jet tool for systematics"); - } - - - /****************************************************** - While looping over the detector-related systematic uncertainties, you - probably want to create a copy of the final state objects with the - systematic variation applied. There are two supported ways to do so. - One is shown in the commented code section: in this case, the relies on - the correctedCopy method that the CP tools provide. That method creates - a deep copy of the object, that is, the full auxiliary store of the - object is physically copied in memory. This is an expensive operation. - - The second approach - the one that is actually in use - delegates to - the user to make a shallow copy of the object, and operates on the - copied object with the applyCorrection method. The shallow copy of an - object will share the auxiliary store with the original object: usually - a much cheaper operation. Think about a jet: it comes with ~ a hundred - moment (a hundred floats) in teh auxiliary store. While applying the - systematic uncertainties, it is likely that you just want to change the - 4-vector, though - ******************************************************/ - - /************** DEEP COPY EXAMPLE - RELY ON correctedCopy ************ - - // Create a new empy jet container and corresponding auxiliary store - - xAOD::JetContainer l_jetContainer; - xAOD::JetAuxContainer l_jetAuxContainer; - - // Connect the auxiliary store container to the jet container - - l_jetContainer.setStore(&l_jetAuxContainer) ; - - for( jetItr = jets->begin(); jetItr != jets->end(); ++jetItr ) { - - xAOD::Jet * l_jet = 0; - - // Calibrate jets using correctedCopy -- This is a deep copy of the object - - if (!jetTool.correctedCopy(*(*jetItr), l_jet)){ - Error(APP_NAME, "Cannot really apply calibration"); - continue; - } - - // Apply some selection and store the jet in the container - - if (l_jet->pt() > 20000 && std::abs(l_jet->eta()) < 2.5){ - l_jetContainer.push_back(l_jet); - } else { - delete l_jet; // Prevent from a memory leak - } - if (m_debug) Info(APP_NAME, "Stored"); - } // End of loop over jets - - if (l_jetContainer.size() >= 2){ - dijet_mass = - (l_jetContainer.at(0)->p4() + l_jetContainer.at(1)->p4()).M(); - } - - ********************** End of example using correctedCopy ************/ - - /**************** Shallow copy examples *************/ - - // Create a new jet container to be filled with jets that will pass the - // selection NOTE: this has to be created in view mode, as the - // ownership of the objects will have to remain to the shallow copied - // containers - - xAOD::JetContainer l_jetContainer(SG::VIEW_ELEMENTS); - - // Make a shallow copy of the jet container - auto jet_shallowCopy = xAOD::shallowCopyContainer( *jets ); - - if (m_debug) Info(APP_NAME, "Beginning loop on jets"); - - // The any container can be recorder on the TStore object declared above - // Not really necessary in this case, but the store will take care of cleaning up - // the containers when we will be done with that - if( !store.record(jet_shallowCopy.first, "myShallowCopiedJets") || - !store.record(jet_shallowCopy.second, "myShallowCopiedJetsAux.") ){ - Error("execute()", "Failed to record shallow copy containers. Exiting."); - return -1; - } - - // Objects in the store can be retrieved the same way you do for TEvent - - // For example - // const xAOD::JetContainer* myownjets = 0; - // CHECK(m_store->retrieve(myownjets,"myShallowCopiedJets")); - - // Note that this time the loop is on the shallow copy container - for( auto jet : *jet_shallowCopy.first ) { - if (m_debug) { - Info(APP_NAME, "A jet"); - Info(APP_NAME, "Original Jet pt %f, eta %f, phi %f, e %f", - jet->pt(), jet->eta(), jet->phi(), jet->e()); - Info(APP_NAME, "Access em fraction %f", - jet->auxdata< float > ("EMFrac")); - } - - // Calibrate jets - if (!jetTool.applyCorrection(*jet)){ - Error(APP_NAME, "Cannot really apply calibration"); - continue; - } - if (m_debug) { - Info(APP_NAME, "Jet calibrated, about to store it in the container"); - Info(APP_NAME, "calibrated jet pt %f eta %f phi %f e %f", - jet->pt(), jet->eta(), jet->phi(), jet->e()); - Info(APP_NAME,"Access em fraction %f", - jet->auxdata< float > ("EMFrac")); - } - - // Apply some selection - if (jet->pt() > 20000 && std::abs(jet->eta()) < 2.5){ - // decorate the object - passSelection(*jet) = 1; - l_jetContainer.push_back(jet); - } - - if (m_debug) Info(APP_NAME, "Stored"); - } - - // sort the jet container - l_jetContainer.sort( ptsorter ); - - // For debugging purposes: loop again on the container and print some information - for( auto jet : l_jetContainer ) { - if (m_debug) std::cout << jet->pt() << std::endl; - if (m_debug) std::cout << passSelection(*jet) << std::endl; - } - - // Compute the dijet mass - if (l_jetContainer.size() >= 2){ - dijet_mass = - (l_jetContainer.at(0)->p4() + l_jetContainer.at(1)->p4()).M(); - } - - // Write event to good tree - sysTreeMap[sys]->Fill(); - - - if (m_debug) Info(APP_NAME, "About to cleanup the store"); - - // Clean up - l_jetContainer.clear(); - - // The containers created by the shallow copy are owned by you. - // Remember to delete them (not needed if they are recorded to the TStore - //delete jet_shallowCopy.first; - //delete jet_shallowCopy.second; - - store.clear(); - - } - - // Close with a message: - if ((entry + 1) % 100 == 0) { - Info( APP_NAME, - "===>>> done processing event #%i, " - "run #%i %i events processed so far <<<===", - static_cast< int >( ei->eventNumber() ), - static_cast< int >( ei->runNumber() ), - static_cast< int >( entry + 1 ) ); - } - } - - // Write the output trees - for (const auto& sys : sysList) { - sysTreeMap[sys]->Write(); - } - - // Close output file - outputFile->Close(); - - // Return gracefully: - return 0; -} diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/CPToolTester.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/CPToolTester.cxx deleted file mode 100644 index 9cdde840b0502493b0217d72386986ad79580fa0..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/CPToolTester.cxx +++ /dev/null @@ -1,213 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: CPToolTester.cxx 300804 2014-06-04 16:49:29Z krasznaa $ - -// System include(s): -#include <memory> -#include <cstdlib> - -// ROOT include(s): -#include <TFile.h> -#include <TError.h> -#include <TString.h> - -// Infrastructure include(s): -#ifdef ROOTCORE -# include "xAODRootAccess/Init.h" -# include "xAODRootAccess/TEvent.h" -# include "xAODRootAccess/TStore.h" -#endif // ROOTCORE - -// EDM include(s): -#include "xAODEventInfo/EventInfo.h" -#include "xAODMuon/MuonContainer.h" - -// Local include(s): -#include "CPAnalysisExamples/errorcheck.h" -#include "CPAnalysisExamples/MuonEfficiencyToolExample.h" -#include "CPAnalysisExamples/MuonSelectionToolExample.h" -#include "CPAnalysisExamples/MuonSmearingToolExample.h" - -// Other include(s): -#include "PATInterfaces/SystematicSet.h" -#include "PATInterfaces/SystematicRegistry.h" - -int main( int argc, char* argv[] ) { - - // The application's name: - const char* APP_NAME = argv[ 0 ]; - - // Check if we received a file name: - if( argc < 2 ) { - Error( APP_NAME, "No file name received!" ); - Error( APP_NAME, " Usage: %s [xAOD file name]", APP_NAME ); - return 1; - } - - // Initialise the application: - CHECK( xAOD::Init( APP_NAME ) ); - - // Open the input file: - const TString fileName = argv[ 1 ]; - Info( APP_NAME, "Opening file: %s", fileName.Data() ); - std::unique_ptr< TFile > ifile( TFile::Open( fileName, "READ" ) ); - CHECK( ifile.get() ); - - // Create a TEvent object: - xAOD::TEvent event( xAOD::TEvent::kClassAccess ); - CHECK( event.readFrom( ifile.get() ) ); - Info( APP_NAME, "Number of events in the file: %i", - static_cast< int >( event.getEntries() ) ); - - // Create a transient object store. Needed for the tools. - xAOD::TStore store; - - // Decide how many events to run over: - Long64_t entries = event.getEntries(); - if( argc > 2 ) { - const Long64_t e = atoll( argv[ 2 ] ); - if( e < entries ) { - entries = e; - } - } - - // Create the tool(s) to test: - CP::MuonSelectionToolExample selTool( "MuonSelector" ); - CP::MuonSmearingToolExample corrTool( "MuonCorrector" ); - CP::MuonEfficiencyToolExample effTool( "MuonEfficiency" ); - - // Configure and initialise the tool(s): - selTool.msg().setLevel( MSG::DEBUG ); - selTool.setProperty( "MaxEta", 2.4 ); - selTool.setProperty( "Author", 12 ); - selTool.initialize(); - - corrTool.msg().setLevel( MSG::DEBUG ); - corrTool.initialize(); - - effTool.msg().setLevel( MSG::DEBUG ); - effTool.setProperty( "DummyProperty", 5.5 ); - effTool.initialize(); - - // Print the recommended systematics - const CP::SystematicRegistry& reg = CP::SystematicRegistry::getInstance(); - const CP::SystematicSet& recommendedSysts = reg.recommendedSystematics(); - Info( APP_NAME, "Recommended systematics:" ); - for(auto sysItr = recommendedSysts.begin(); - sysItr != recommendedSysts.end(); ++sysItr){ - Info( APP_NAME, " %s", sysItr->name().c_str() ); - } - - // Build a dummy list of systematics (for MuonSmearingTool). - // A proper approach would either use the recommened systematics - // above or query the systematics for each sys tool and build - // the list of NP-points from that. - std::vector<CP::SystematicSet> sysList; - sysList.push_back(CP::SystematicSet()); // nominal - std::vector<std::string> baseVariations = { "mu_id", "mu_ms", "mu_cb" }; - for(auto& s : baseVariations){ - CP::SystematicSet sysSet_p = { CP::SystematicVariation(s, 1) }; - CP::SystematicSet sysSet_n = { CP::SystematicVariation(s, -1) }; - sysList.push_back(sysSet_p); - sysList.push_back(sysSet_n); - } - - // Loop over the events: - for( Long64_t entry = 0; entry < entries; ++entry ) { - - // Tell the object which entry to look at: - event.getEntry( entry ); - - // Print some event information for fun: - const xAOD::EventInfo* ei = 0; - CHECK( event.retrieve( ei, "EventInfo" ) ); - Info( APP_NAME, - "===>>> start processing event #%i, " - "run #%i %i events processed so far <<<===", - static_cast< int >( ei->eventNumber() ), - static_cast< int >( ei->runNumber() ), - static_cast< int >( entry ) ); - - // Get the Muons from the event: - const xAOD::MuonContainer* muons = 0; - CHECK( event.retrieve( muons, "Muons" ) ); - Info( APP_NAME, "Number of muons: %i", - static_cast< int >( muons->size() ) ); - - // Print their properties, using the tools: - xAOD::MuonContainer::const_iterator mu_itr = muons->begin(); - xAOD::MuonContainer::const_iterator mu_end = muons->end(); - for( ; mu_itr != mu_end; ++mu_itr ) { - - // Select "good" muons: - if( ! selTool.accept( **mu_itr ) ) continue; - - // Print some info about the selected muon: - Info( APP_NAME, " Selected muon: eta = %g, phi = %g, pt = %g", - ( *mu_itr )->eta(), ( *mu_itr )->phi(), ( *mu_itr )->pt() ); - Info( APP_NAME, " Primary track: eta = %g, phi = %g, pt = %g", - ( *mu_itr )->primaryTrackParticle()->eta(), - ( *mu_itr )->primaryTrackParticle()->phi(), - ( *mu_itr )->primaryTrackParticle()->pt() ); - const xAOD::TrackParticle* idtrack = - ( *mu_itr )->trackParticle( xAOD::Muon::InnerDetectorTrackParticle ); - if( idtrack ) { - Info( APP_NAME, " ID track: eta = %g, phi = %g, pt = %g", - idtrack->eta(), idtrack->phi(), idtrack->pt() ); - } - - // Loop over systematics to apply. - // NOTE: this is not a good example of how to properly apply systematics, - // because I'm looping over systematics WITHIN the muon loop! - // It's really just a test of the SystematicsTool machinery. - for( auto sysSet : sysList ){ - - Info( APP_NAME, "Now applying systematics: %s", - sysSet.name().c_str() ); - - // Apply the systematics configuration to the smearing tool: - if( corrTool.applySystematicVariation(sysSet) != - CP::SystematicCode::Ok){ - Error( APP_NAME, "Error setting systematic: %s", - sysSet.name().c_str() ); - return 1; - } - - // Create a calibrared muon: - xAOD::Muon* mu = 0; - CHECK( corrTool.correctedCopy( **mu_itr, mu ) ); - Info( APP_NAME, "Calibrated muon: eta = %g, phi = %g, pt = %g", - mu->eta(), mu->phi(), mu->pt() ); - - // Use the "simple interface" of the tool(s): - float eff = 0.0, sf = 0.0; - CHECK( effTool.getEfficiency( *mu, eff ) ); - Info( APP_NAME, " efficiency = %g", eff ); - CHECK( effTool.getScaleFactor( *mu, sf ) ); - Info( APP_NAME, " scaleFactor = %g", sf ); - - // Call the tool on it in "decrating mode": - CHECK( effTool.applyEfficiency( *mu ) ); - Info( APP_NAME, " efficiency = %g", - mu->auxdata< float >( "MuonEfficiency" ) ); - - // Delete the calibrated muon: - delete mu; - - } - } - - // Close with a message: - Info( APP_NAME, - "===>>> done processing event #%i, " - "run #%i %i events processed so far <<<===", - static_cast< int >( ei->eventNumber() ), - static_cast< int >( ei->runNumber() ), - static_cast< int >( entry + 1 ) ); - } - - // Return gracefully: - return 0; -} diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/checkxAODTrigger.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/checkxAODTrigger.cxx deleted file mode 100644 index bd9119b1c3c5282d4aa17700dca766a64b873632..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/checkxAODTrigger.cxx +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef ROOTCORE - -///Example standalone executable using POOL to read an xAOD -///Tests the TrigDecisionTool ... shows example usage -///You can create a skeleton application yourself with: cmt new_analysisapp MyApp -/// -///Author: Will Buttinger -/// - -#include "AthAnalysisBaseComps/AthAnalysisHelper.h" //tool creation and configuration -#include "POOLRootAccess/TEvent.h" //event looping -#include "GaudiKernel/ToolHandle.h" //for better working with tools - -#include "AsgTools/MessageCheck.h" //messaging -using namespace asg::msgUserCode; //messaging - -//EDM includes - -//ROOT includes -#include "TString.h" -#include "TSystem.h" - -//specific includes for this example -#include "TrigDecisionTool/TrigDecisionTool.h" - -int main( int argc, char* argv[] ) { - - IAppMgrUI* app = POOL::Init(); //important to do this first! - - // The application's name: - //const char* APP_NAME = argv[ 0 ]; - - // Open the input file: - TString fileName = "$ASG_TEST_FILE_MC"; - std::string trigger; - if( argc < 3 ) { - ANA_MSG_WARNING("Usage: checkxAODTrigger.exe <trigger> <file>"); - return -1; - } - trigger = argv[1]; - fileName = argv[2]; //use the user provided file - - ANA_MSG_INFO("Opening file: " << gSystem->ExpandPathName(fileName.Data()) ); - - //The preferred way to create and configure tools is with a ToolHandle: - //constructor argument is: Type/Name - ToolHandle<Trig::TrigDecisionTool> tdt("Trig::TrigDecisionTool/TrigDecisionTool"); - tdt.retrieve(); //this will cause the tool to be created and initialized - - //loop over input file with kClassAccess - POOL::TEvent evt(POOL::TEvent::kClassAccess); - evt.readFrom( fileName ); - - int passCount(0); - for(int i=0;i < evt.getEntries(); i++) { - if( evt.getEntry(i) < 0) { ANA_MSG_ERROR("Failed to read event " << i); continue; } - if(tdt->isPassed(trigger)) passCount++; - } - - app->finalize(); //trigger finalization of all services and tools created by the Gaudi Application - - ANA_MSG_INFO("Number of events passing trigger " << trigger << ": " << passCount); - - return 0; -} - -#endif diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/runExample.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/runExample.cxx deleted file mode 100644 index 40096ad201dffaf14ef4e24f4ec1034a8425afbb..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/runExample.cxx +++ /dev/null @@ -1,87 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifdef ROOTCORE - -// Adapted from SoftwareTutorialxAODAnalysisInROOT -// argv[1] = clistFile -// argv[2] = jobName (relative to .) -// argv[3] = proofFlag (none/lite/farm) -// argv[4] = evtMax - -// Stearing code for the xExample code - -#include "CPAnalysisExamples/xExample.h" -#include "xAODRootAccess/Init.h" -#include "SampleHandler/SampleHandler.h" -#include "SampleHandler/ToolsDiscovery.h" -#include "EventLoop/Job.h" -#include "EventLoop/DirectDriver.h" - -#include <TFile.h> -#include <TChain.h> -#include <TSystem.h> - -#include <vector> -#include <fstream> -#include <string> -#include <cstdlib> - -int main( int argc, char* argv[] ) { - - // Check arguments - if( argc < 4 ){ - std::cerr <<"Usage: clistFile jobName proofFlag maxEvt" <<std::endl; - std::cerr <<"proofFlag = none, lite, or farm name" <<std::endl; - std::cerr <<"Use maxEvt = 0 for all events" <<std::endl; - return 1; - } - std::string clistFile = argv[1]; - std::string jobName = argv[2]; - std::string proofFlag = argv[3]; - int evtMax = 0; - evtMax = std::atoi(argv[4]); - - // Set up the job for xAOD access: - xAOD::Init().ignore(); - - // Open the input .clist file and create TChain - Info("runExample", "Opening .clist file: %s", clistFile.c_str() ); - std::ifstream inFile( clistFile.c_str() ); - TChain chain("CollectionTree"); - std::string nextFile; - while( inFile >> nextFile ){ - Info("runExample", "Adding to TChain file: %s", nextFile.c_str() ); - chain.Add( nextFile.c_str() ); - } - - // Create a new sample handler for the TChain - SH::SampleHandler sh; - sh.add( SH::makeFromTChain(jobName.c_str(),chain) ); - sh.setMetaString( "nc_tree", "CollectionTree" ); - - // Create EventLoop job - // Driver writes output in subdirectory jobName - // Atilla: need class mode for electrons - EL::Job job; - job.useXAOD(); - job.options()->setString (EL::Job::optXaodAccessMode, EL::Job::optXaodAccessMode_class); - job.sampleHandler(sh); - - xExample* xt = new xExample; - job.algsAdd( xt ); - if( evtMax > 0 ) job.options()->setDouble(EL::Job::optMaxEvents, evtMax); - - // From https://twiki.cern.ch/twiki/bin/view/AtlasProtected/EventLoop#PROOF_Driver - - if( proofFlag == "none" ){ - std::cout <<"runExample running locally" <<std::endl; - EL::DirectDriver driver; - driver.submit( job, jobName.c_str() ); - } - - return 0; -} - -#endif diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/run_ut_accessDataAndCpTools.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/run_ut_accessDataAndCpTools.cxx deleted file mode 100644 index 8a5ad7699d2f4024ad046f38cd417305b07ff7f1..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/run_ut_accessDataAndCpTools.cxx +++ /dev/null @@ -1,342 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: CPSystematicExample.cxx 300492 2014-04-30 14:39:05Z krasznaa $ - -// System include(s): -#include <memory> -#include <cstdlib> - -// ROOT include(s): -#include <TFile.h> -#include <TError.h> -#include <TString.h> -#include <TTree.h> - - -// Infrastructure include(s): -#ifdef ROOTCORE -# include "xAODRootAccess/Init.h" -# include "xAODRootAccess/TEvent.h" -# include "xAODRootAccess/TStore.h" -#endif // ROOTCORE - -// EDM include(s): -#include "xAODEventInfo/EventInfo.h" -#include "xAODJet/JetContainer.h" -#include "xAODJet/JetAuxContainer.h" -#include "xAODCore/ShallowCopy.h" -#include "xAODEgamma/ElectronContainer.h" -#include "xAODEgamma/ElectronAuxContainer.h" -#include "xAODEgamma/PhotonContainer.h" -#include "xAODEgamma/PhotonAuxContainer.h" -#include "xAODMuon/MuonContainer.h" -#include "xAODMuon/MuonAuxContainer.h" -#include "xAODTau/TauJetContainer.h" -#include "xAODTau/TauJetAuxContainer.h" - -// Local include(s): - -#include "CPAnalysisExamples/errorcheck.h" -#include "CPAnalysisExamples/MyToolProvider.h" - -int main( int /*argc*/, char* argv[] ) { - - // The application's name: - const char* APP_NAME = argv[ 0 ]; - - bool m_debug = false; - - // Initialise the application: - CHECK( xAOD::Init( APP_NAME ) ); - - // Open the input file: - const TString fileName = argv[1]; - - Info( APP_NAME, "Opening file: %s", fileName.Data() ); - TFile * ifile( TFile::Open( fileName, "READ" ) ); - if (!ifile) Error(APP_NAME, "Cannot find file " + fileName); - - // Create a TEvent object: - xAOD::TEvent event( ifile, xAOD::TEvent::kClassAccess ); - CHECK( event.readFrom( ifile ) ); - Info( APP_NAME, "Number of events in the file: %i", - static_cast< int >( event.getEntries() ) ); - - // Create a transient object store. Needed for the tools. - xAOD::TStore store; - - // Create a tool provider and initialise tools - - MyToolProvider toolProvider("toolProvider"); - CHECK(toolProvider.initialize()); - - // Decide how many events to run over: - Long64_t entries = event.getEntries(); - const Long64_t e = 100; - if( e < entries ) { - entries = e; - } - - for( Long64_t entry = 0; entry < entries; ++entry ) - { - if (m_debug) Info( APP_NAME, "Running on event %i", ((int)entry)); - // Tell the object which entry to look at: - event.getEntry( entry ); - - // Print some event information for fun: - const xAOD::EventInfo* ei = 0; - CHECK( event.retrieve( ei, "EventInfo" ) ); - if (m_debug) Info( APP_NAME, - "===>>> start processing event #%i, " - "run #%i %i events processed so far <<<===", - static_cast< int >( ei->eventNumber() ), - static_cast< int >( ei->runNumber() ), - static_cast< int >( entry ) ); - - // Basic test for ability of reading containers: is the pt of any of the objects larger than something? - - bool test_pt = false; - - /***************************************/ - // test jets - - // Get the Jets from the event: - const xAOD::JetContainer* jets = 0; - CHECK( event.retrieve( jets, "AntiKt4LCTopoJets" ) ); - - // Check that the container can be read - - if (m_debug) Info( APP_NAME, "Number of jets: %i", - static_cast< int >( jets->size() ) ); - - // Create shallow copy container - - std::pair< xAOD::JetContainer*, xAOD::ShallowAuxContainer* > jet_shallowCopy = xAOD::shallowCopyContainer( *jets ); - - xAOD::JetContainer::iterator jetItr; - - for( jetItr = (jet_shallowCopy.first)->begin(); jetItr != (jet_shallowCopy.first)->end(); ++jetItr ) { - if (m_debug) Info(APP_NAME, "Original Jet pt %f, eta %f, phi %f, e %f", (*jetItr)->pt(), (*jetItr)->eta(), (*jetItr)->phi(), (*jetItr)->e()); - - // Calibrate jets - - CHECK(toolProvider.jetCalibTool->applyCorrection(**jetItr)); - - // Test JER - - // Get the MC resolution - double mcRes = toolProvider.jerTool->getRelResolutionMC(*jetItr); - // Get the resolution uncertaintu - double uncert = toolProvider.jerTool->getUncertainty(*jetItr); - - if (m_debug) Info( APP_NAME, "mc resolution %f uncertainty %f",mcRes,uncert); - - CHECK(toolProvider.jerSmearingTool->applyCorrection(**jetItr)); - - test_pt = (*jetItr)->pt() > 5000; - if (test_pt) break; - } - - if ((jet_shallowCopy.first)->size() > 0 && !test_pt) { - Error(APP_NAME, "All jets have pt < 5000 MeV. This is weird"); - return -1; - } - - delete jet_shallowCopy.first; - delete jet_shallowCopy.second; - - /******************************************/ - // test electrons - - test_pt = false; - - const xAOD::ElectronContainer* electrons = 0; - CHECK( event.retrieve(electrons, "ElectronCollection") ); - - // Check that the container can be read - - if (m_debug) Info( APP_NAME, "Number of electrons: %i", - static_cast< int >( electrons->size() ) ); - - // Create shallow copy container - - std::pair< xAOD::ElectronContainer*, xAOD::ShallowAuxContainer* > ele_shallowCopy = xAOD::shallowCopyContainer( *electrons ); - - xAOD::ElectronContainer::iterator eleItr; - - for( eleItr = (ele_shallowCopy.first)->begin(); eleItr != (ele_shallowCopy.first)->end(); ++eleItr ) { - if (m_debug) Info(APP_NAME, "Original ele pt %f, eta %f, phi %f, e %f", (*eleItr)->pt(), (*eleItr)->eta(), (*eleItr)->phi(), (*eleItr)->e()); - - // Calibrate electron - - if ((*eleItr)->pt() > 10000){ - CHECK(toolProvider.egammaCalibTool->applyCorrection(**eleItr)); - } - - if ((*eleItr)->pt() > 10000){ - double eleSF = 1.; - CHECK( toolProvider.elecEfficiencySFTool->getEfficiencyScaleFactor(**eleItr, eleSF) ); - if (m_debug) Info(APP_NAME, "ElectronsSF %g", eleSF); - //const Root::TResult &result = toolProvider.elecEfficiencySFTool->calculate(*eleItr); - //if (m_debug) Info(APP_NAME,"ElectronsSF %f",result.getScaleFactor()); - } - - // If any electron has pt > 200 GeV declare test successful - - test_pt = (*eleItr)->pt() > 200; - if (test_pt) break; - - } - - if ((ele_shallowCopy.first)->size() > 0 && !test_pt) { - Error(APP_NAME, "All ele have pt < 200 MeV. This is weird"); - return -1; - } - - delete ele_shallowCopy.first; - delete ele_shallowCopy.second; - - /********************************/ - // test muons - - test_pt = false; - - const xAOD::MuonContainer* muons = 0; - CHECK( event.retrieve(muons, "Muons") ); - - // Check that the container can be read - - if (m_debug) Info( APP_NAME, "Number of muons: %i", - static_cast< int >( muons->size() ) ); - - // Create shallow copy container - - std::pair< xAOD::MuonContainer*, xAOD::ShallowAuxContainer* > muo_shallowCopy = xAOD::shallowCopyContainer( *muons ); - - xAOD::MuonContainer::iterator muoItr; - - for( muoItr = (muo_shallowCopy.first)->begin(); muoItr != (muo_shallowCopy.first)->end(); ++muoItr ) { - if (m_debug) Info(APP_NAME, "Original muon pt %f, eta %f, phi %f, e %f", (*muoItr)->pt(), (*muoItr)->eta(), (*muoItr)->phi(), (*muoItr)->e()); - - CHECK(toolProvider.muonCalibrationAndSmearingTool->applyCorrection(**muoItr)); - - float sf = 0; - - CHECK(toolProvider.muonEfficiencySFTool->getEfficiencyScaleFactor((**muoItr),sf)); - - if (m_debug) Info(APP_NAME, "Muon scale factor %f", sf); - - if (!toolProvider.muonSelectionTool->accept(**muoItr)) - if (m_debug) Info(APP_NAME,"Muon not accepted by selector"); - - test_pt = (*muoItr)->pt() > 200; - if (test_pt) break; - } - - if ((muo_shallowCopy.first)->size() > 0 && !test_pt) { - Error(APP_NAME, "All muons have pt < 200 MeV. This is weird"); - return -1; - } - - delete muo_shallowCopy.first; - delete muo_shallowCopy.second; - - /***********************************/ - // test taus - - test_pt = false; - - const xAOD::TauJetContainer* taus = 0; - CHECK( event.retrieve(taus, "TauRecContainer") ); - - // Check that the container can be read - - if (m_debug) Info( APP_NAME, "Number of taus: %i", - static_cast< int >( taus->size() ) ); - - // Create shallo copy container - - std::pair< xAOD::TauJetContainer*, xAOD::ShallowAuxContainer* > tau_shallowCopy = xAOD::shallowCopyContainer( *taus ); - - xAOD::TauJetContainer::iterator tauItr; - - for( tauItr = (tau_shallowCopy.first)->begin(); tauItr != (tau_shallowCopy.first)->end(); ++tauItr ) { - if (m_debug) Info(APP_NAME, "Original tau pt %f, eta %f, phi %f, e %f", (*tauItr)->pt(), (*tauItr)->eta(), (*tauItr)->phi(), (*tauItr)->e()); - - // Check if tau tools work - - CHECK(toolProvider.tauSmearingTool->applyCorrection(**tauItr)); - if (!toolProvider.tauSelTool->accept(**tauItr)){ - if (m_debug) Info(APP_NAME,"This tau with pt %f is rejected",(*tauItr)->pt()); - // double tau_sf = 0; - // CHECK(toolProvider.tauEffTool->getEfficiencyScaleFactor(**tauItr, tau_sf)); - } - - - test_pt = (*tauItr)->pt() > 200; - if (test_pt) break; - } - - if ((tau_shallowCopy.first)->size() > 0 && !test_pt) { - Error(APP_NAME, "All taus have pt < 200 MeV. This is weird"); - return -1; - } - - delete tau_shallowCopy.first; - delete tau_shallowCopy.second; - - /*****************************/ - // test photons - - test_pt = false; - - const xAOD::PhotonContainer* photons = 0; - CHECK( event.retrieve(photons, "PhotonCollection") ); - - // Check that the container can be read - - if (m_debug) Info( APP_NAME, "Number of photons: %i", - static_cast< int >( photons->size() ) ); - - // Create shallow copy container - - std::pair< xAOD::PhotonContainer*, xAOD::ShallowAuxContainer* > pho_shallowCopy = xAOD::shallowCopyContainer( *photons ); - - xAOD::PhotonContainer::iterator phoItr; - - for( phoItr = (pho_shallowCopy.first)->begin(); phoItr != (pho_shallowCopy.first)->end(); ++phoItr ) { - if (m_debug) Info(APP_NAME, "Original photon pt %f, eta %f, phi %f, e %f", (*phoItr)->pt(), (*phoItr)->eta(), (*phoItr)->phi(), (*phoItr)->e()); - if ((*phoItr)->pt() > 10000){ - CHECK(toolProvider.egammaCalibTool->applyCorrection(**phoItr)); - } - test_pt = (*phoItr)->pt() > 200; - if (test_pt) break; - } - - if ((pho_shallowCopy.first)->size() > 0 && !test_pt) { - Error(APP_NAME, "All photons have pt < 200 MeV. This is weird"); - return -1; - } - - delete pho_shallowCopy.first; - delete pho_shallowCopy.second; - - - - // Close with a message: - if ((entry + 1) % 100 == 0) Info( APP_NAME, - "===>>> done processing event #%i, " - "run #%i %i events processed so far <<<===", - static_cast< int >( ei->eventNumber() ), - static_cast< int >( ei->runNumber() ), - static_cast< int >( entry + 1 ) ); - - } - - - - // Return gracefully: - return 0; -} diff --git a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/run_ut_accessDataAndCpTools_v20.cxx b/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/run_ut_accessDataAndCpTools_v20.cxx deleted file mode 100644 index d382e494d7fe45c801e57298d15924c9d8b0c37d..0000000000000000000000000000000000000000 --- a/PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples/util/run_ut_accessDataAndCpTools_v20.cxx +++ /dev/null @@ -1,340 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: CPSystematicExample.cxx 300492 2014-04-30 14:39:05Z krasznaa $ - -// System include(s): -#include <memory> -#include <cstdlib> - -// ROOT include(s): -#include <TFile.h> -#include <TError.h> -#include <TString.h> -#include <TTree.h> - - -// Infrastructure include(s): -#ifdef ROOTCORE -# include "xAODRootAccess/Init.h" -# include "xAODRootAccess/TEvent.h" -# include "xAODRootAccess/TStore.h" -#endif // ROOTCORE - -// EDM include(s): -#include "xAODEventInfo/EventInfo.h" -#include "xAODJet/JetContainer.h" -#include "xAODJet/JetAuxContainer.h" -#include "xAODCore/ShallowCopy.h" -#include "xAODEgamma/ElectronContainer.h" -#include "xAODEgamma/ElectronAuxContainer.h" -#include "xAODEgamma/PhotonContainer.h" -#include "xAODEgamma/PhotonAuxContainer.h" -#include "xAODMuon/MuonContainer.h" -#include "xAODMuon/MuonAuxContainer.h" -#include "xAODTau/TauJetContainer.h" -#include "xAODTau/TauJetAuxContainer.h" - -// Local include(s): - -#include "CPAnalysisExamples/errorcheck.h" -#include "CPAnalysisExamples/MyToolProvider.h" - -int main( int /*argc*/, char* argv[] ) { - - // The application's name: - const char* APP_NAME = argv[ 0 ]; - - bool m_debug = false; - - // Initialise the application: - CHECK( xAOD::Init( APP_NAME ) ); - - // Open the input file: - const TString fileName = argv[1]; - - Info( APP_NAME, "Opening file: %s", fileName.Data() ); - TFile * ifile( TFile::Open( fileName, "READ" ) ); - if (!ifile) Error(APP_NAME, "Cannot find file " + fileName); - - // Create a TEvent object: - xAOD::TEvent event( ifile, xAOD::TEvent::kClassAccess ); - CHECK( event.readFrom( ifile ) ); - Info( APP_NAME, "Number of events in the file: %i", - static_cast< int >( event.getEntries() ) ); - - // Create a transient object store. Needed for the tools. - xAOD::TStore store; - - // Create a tool provider and initialise tools - - MyToolProvider toolProvider("toolProvider"); - CHECK(toolProvider.initialize()); - - // Decide how many events to run over: - Long64_t entries = event.getEntries(); - const Long64_t e = 100; - if( e < entries ) { - entries = e; - } - - for( Long64_t entry = 0; entry < entries; ++entry ) - { - if (m_debug) Info( APP_NAME, "Running on event %i", ((int)entry)); - // Tell the object which entry to look at: - event.getEntry( entry ); - - // Print some event information for fun: - const xAOD::EventInfo* ei = 0; - CHECK( event.retrieve( ei, "EventInfo" ) ); - if (m_debug) Info( APP_NAME, - "===>>> start processing event #%i, " - "run #%i %i events processed so far <<<===", - static_cast< int >( ei->eventNumber() ), - static_cast< int >( ei->runNumber() ), - static_cast< int >( entry ) ); - - // Basic test for ability of reading containers: is the pt of any of the objects larger than something? - - bool test_pt = false; - - /***************************************/ - // test jets - - // Get the Jets from the event: - const xAOD::JetContainer* jets = 0; - CHECK( event.retrieve( jets, "AntiKt4LCTopoJets" ) ); - - // Check that the container can be read - - if (m_debug) Info( APP_NAME, "Number of jets: %i", - static_cast< int >( jets->size() ) ); - - // Create shallow copy container - - std::pair< xAOD::JetContainer*, xAOD::ShallowAuxContainer* > jet_shallowCopy = xAOD::shallowCopyContainer( *jets ); - - xAOD::JetContainer::iterator jetItr; - - for( jetItr = (jet_shallowCopy.first)->begin(); jetItr != (jet_shallowCopy.first)->end(); ++jetItr ) { - if (m_debug) Info(APP_NAME, "Original Jet pt %f, eta %f, phi %f, e %f", (*jetItr)->pt(), (*jetItr)->eta(), (*jetItr)->phi(), (*jetItr)->e()); - - // Calibrate jets - - CHECK(toolProvider.jetCalibTool->applyCorrection(**jetItr)); - - // Test JER - - // Get the MC resolution - double mcRes = toolProvider.jerTool->getRelResolutionMC(*jetItr); - // Get the resolution uncertaintu - double uncert = toolProvider.jerTool->getUncertainty(*jetItr); - - if (m_debug) Info( APP_NAME, "mc resolution %f uncertainty %f",mcRes,uncert); - - CHECK(toolProvider.jerSmearingTool->applyCorrection(**jetItr)); - - test_pt = (*jetItr)->pt() > 5000; - if (test_pt) break; - } - - if ((jet_shallowCopy.first)->size() > 0 && !test_pt) { - Error(APP_NAME, "All jets have pt < 5000 MeV. This is weird"); - return -1; - } - - delete jet_shallowCopy.first; - delete jet_shallowCopy.second; - - /******************************************/ - // test electrons - - test_pt = false; - - const xAOD::ElectronContainer* electrons = 0; - CHECK( event.retrieve(electrons, "Electrons") ); - - // Check that the container can be read - - if (m_debug) Info( APP_NAME, "Number of electrons: %i", - static_cast< int >( electrons->size() ) ); - - // Create shallow copy container - - std::pair< xAOD::ElectronContainer*, xAOD::ShallowAuxContainer* > ele_shallowCopy = xAOD::shallowCopyContainer( *electrons ); - - xAOD::ElectronContainer::iterator eleItr; - - for( eleItr = (ele_shallowCopy.first)->begin(); eleItr != (ele_shallowCopy.first)->end(); ++eleItr ) { - if (m_debug) Info(APP_NAME, "Original ele pt %f, eta %f, phi %f, e %f", (*eleItr)->pt(), (*eleItr)->eta(), (*eleItr)->phi(), (*eleItr)->e()); - - // Calibrate electron - - if ((*eleItr)->pt() > 10000){ - CHECK(toolProvider.egammaCalibTool->applyCorrection(**eleItr)); - } - - if ((*eleItr)->pt() > 10000){ - double eleSF = 1.; - CHECK( toolProvider.elecEfficiencySFTool->getEfficiencyScaleFactor(**eleItr, eleSF) ); - if (m_debug) Info(APP_NAME, "ElectronsSF %g", eleSF); - //const Root::TResult &result = toolProvider.elecEfficiencySFTool->calculate(*eleItr); - //if (m_debug) Info(APP_NAME,"ElectronsSF %f",result.getScaleFactor()); - } - - // If any electron has pt > 200 GeV declare test successful - - test_pt = (*eleItr)->pt() > 200; - if (test_pt) break; - - } - - if ((ele_shallowCopy.first)->size() > 0 && !test_pt) { - Error(APP_NAME, "All ele have pt < 200 MeV. This is weird"); - return -1; - } - - delete ele_shallowCopy.first; - delete ele_shallowCopy.second; - - /********************************/ - // test muons - - test_pt = false; - - const xAOD::MuonContainer* muons = 0; - CHECK( event.retrieve(muons, "Muons") ); - - // Check that the container can be read - - if (m_debug) Info( APP_NAME, "Number of muons: %i", - static_cast< int >( muons->size() ) ); - - // Create shallow copy container - - std::pair< xAOD::MuonContainer*, xAOD::ShallowAuxContainer* > muo_shallowCopy = xAOD::shallowCopyContainer( *muons ); - - xAOD::MuonContainer::iterator muoItr; - - for( muoItr = (muo_shallowCopy.first)->begin(); muoItr != (muo_shallowCopy.first)->end(); ++muoItr ) { - if (m_debug) Info(APP_NAME, "Original muon pt %f, eta %f, phi %f, e %f", (*muoItr)->pt(), (*muoItr)->eta(), (*muoItr)->phi(), (*muoItr)->e()); - - CHECK(toolProvider.muonCalibrationAndSmearingTool->applyCorrection(**muoItr)); - - float sf = 0; - - CHECK(toolProvider.muonEfficiencySFTool->getEfficiencyScaleFactor((**muoItr),sf)); - - if (m_debug) Info(APP_NAME, "Muon scale factor %f", sf); - - if (!toolProvider.muonSelectionTool->accept(**muoItr)) - if (m_debug) Info(APP_NAME,"Muon not accepted by selector"); - - test_pt = (*muoItr)->pt() > 200; - if (test_pt) break; - } - - if ((muo_shallowCopy.first)->size() > 0 && !test_pt) { - Error(APP_NAME, "All muons have pt < 200 MeV. This is weird"); - return -1; - } - - delete muo_shallowCopy.first; - delete muo_shallowCopy.second; - - /***********************************/ - // test taus - - test_pt = false; - - const xAOD::TauJetContainer* taus = 0; - CHECK( event.retrieve(taus, "TauJets") ); - - // Check that the container can be read - - if (m_debug) Info( APP_NAME, "Number of taus: %i", - static_cast< int >( taus->size() ) ); - - // Create shallo copy container - - std::pair< xAOD::TauJetContainer*, xAOD::ShallowAuxContainer* > tau_shallowCopy = xAOD::shallowCopyContainer( *taus ); - - xAOD::TauJetContainer::iterator tauItr; - - for( tauItr = (tau_shallowCopy.first)->begin(); tauItr != (tau_shallowCopy.first)->end(); ++tauItr ) { - if (m_debug) Info(APP_NAME, "Original tau pt %f, eta %f, phi %f, e %f", (*tauItr)->pt(), (*tauItr)->eta(), (*tauItr)->phi(), (*tauItr)->e()); - - - if (!toolProvider.tauSelTool->accept(**tauItr)){ - if (m_debug) Info(APP_NAME,"This tau with pt %f is rejected",(*tauItr)->pt()); - // double tau_sf = 0; - // CHECK(toolProvider.tauEffTool->getEfficiencyScaleFactor(**tauItr, tau_sf)); - } - - - test_pt = (*tauItr)->pt() > 200; - if (test_pt) break; - } - - if ((tau_shallowCopy.first)->size() > 0 && !test_pt) { - Error(APP_NAME, "All taus have pt < 200 MeV. This is weird"); - return -1; - } - - delete tau_shallowCopy.first; - delete tau_shallowCopy.second; - - /*****************************/ - // test photons - - test_pt = false; - - const xAOD::PhotonContainer* photons = 0; - CHECK( event.retrieve(photons, "Photons") ); - - // Check that the container can be read - - if (m_debug) Info( APP_NAME, "Number of photons: %i", - static_cast< int >( photons->size() ) ); - - // Create shallow copy container - - std::pair< xAOD::PhotonContainer*, xAOD::ShallowAuxContainer* > pho_shallowCopy = xAOD::shallowCopyContainer( *photons ); - - xAOD::PhotonContainer::iterator phoItr; - - for( phoItr = (pho_shallowCopy.first)->begin(); phoItr != (pho_shallowCopy.first)->end(); ++phoItr ) { - if (m_debug) Info(APP_NAME, "Original photon pt %f, eta %f, phi %f, e %f", (*phoItr)->pt(), (*phoItr)->eta(), (*phoItr)->phi(), (*phoItr)->e()); - if ((*phoItr)->pt() > 10000){ - CHECK(toolProvider.egammaCalibTool->applyCorrection(**phoItr)); - } - test_pt = (*phoItr)->pt() > 200; - if (test_pt) break; - } - - if ((pho_shallowCopy.first)->size() > 0 && !test_pt) { - Error(APP_NAME, "All photons have pt < 200 MeV. This is weird"); - return -1; - } - - delete pho_shallowCopy.first; - delete pho_shallowCopy.second; - - - - // Close with a message: - if ((entry + 1) % 100 == 0) Info( APP_NAME, - "===>>> done processing event #%i, " - "run #%i %i events processed so far <<<===", - static_cast< int >( ei->eventNumber() ), - static_cast< int >( ei->runNumber() ), - static_cast< int >( entry + 1 ) ); - - } - - - - // Return gracefully: - return 0; -} diff --git a/Projects/AnalysisBase/package_filters.txt b/Projects/AnalysisBase/package_filters.txt index f77a864771a442e0cf083b96564e06a118007d55..ac7fa92925ab8bf0019905c3494e0861ff243965 100644 --- a/Projects/AnalysisBase/package_filters.txt +++ b/Projects/AnalysisBase/package_filters.txt @@ -67,7 +67,6 @@ + PhysicsAnalysis/Algorithms/.* + PhysicsAnalysis/AnalysisCommon/AssociationUtils + PhysicsAnalysis/AnalysisCommon/AnalysisUtils -#+ PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples + PhysicsAnalysis/AnalysisCommon/CutBookkeeperUtils + PhysicsAnalysis/AnalysisCommon/FsrUtils + PhysicsAnalysis/AnalysisCommon/HDF5Utils diff --git a/Projects/Athena/package_filters.txt b/Projects/Athena/package_filters.txt index 06159fbba011aa5b4849c56c51c626a0bd046d8b..517c53c849e9c059048c27fbdb1255b6e97a45c3 100644 --- a/Projects/Athena/package_filters.txt +++ b/Projects/Athena/package_filters.txt @@ -30,7 +30,6 @@ # Some analysis packages that are not part of Athena - Control/AthLinksSA - PhysicsAnalysis/Algorithms/.* -- PhysicsAnalysis/AnalysisCommon/CPAnalysisExamples - PhysicsAnalysis/AnalysisCommon/PMGTools - PhysicsAnalysis/D3PDTools/EventLoop.* - PhysicsAnalysis/D3PDTools/MultiDraw