diff --git a/Reconstruction/Jet/JetCPInterfaces/JetCPInterfaces/ICPJetCorrectionTool.h b/Reconstruction/Jet/JetCPInterfaces/JetCPInterfaces/ICPJetCorrectionTool.h new file mode 100644 index 0000000000000000000000000000000000000000..9e318e56bbb3a66ce7a40b43401921cbbf6545e3 --- /dev/null +++ b/Reconstruction/Jet/JetCPInterfaces/JetCPInterfaces/ICPJetCorrectionTool.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + * */ + +////////////////////////////////////////////////////////// +/// class ICPJetCorrectionTool +/// +/// Interface class for smearing the jet mass scale and resolution of large-R jets +/// It allows the user to derive the systematic uncertainties associated with the JMS and the JMR +/// +/// For information, see the Twiki: +/// https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/FFJetSmearingTool +/// +////////////////////////////////////////////////////////// + +#ifndef JETCPINTERFACES_ICPJETCORRECTIONTOOL_H +#define JETCPINTERFACES_ICPJETCORRECTIONTOOL_H + +#include "PATInterfaces/CorrectionCode.h" +#include "PATInterfaces/ISystematicsTool.h" + +#include "xAODJet/Jet.h" +#include "xAODJet/JetContainer.h" +#include "xAODEventInfo/EventInfo.h" + +class ICPJetCorrectionTool : virtual public asg::IAsgTool, + virtual public CP::ISystematicsTool +{ + // Interface declaration + ASG_TOOL_INTERFACE(ICPJetCorrectionTool) + + public: + + /// Apply a systematic variation of get a new copy + virtual CP::CorrectionCode applyCorrection(xAOD::Jet& jet_reco) const = 0; + virtual CP::CorrectionCode correctedCopy(const xAOD::Jet& input, xAOD::Jet*& output) const = 0; + virtual CP::CorrectionCode applyContainerCorrection(xAOD::JetContainer& inputs) const = 0; + +}; // class ICPJetCorrectionTool + +#endif /* JETINTERFACE_IJETCPCORRECTIONTOOL_H */ diff --git a/Reconstruction/Jet/JetUncertainties/CMakeLists.txt b/Reconstruction/Jet/JetUncertainties/CMakeLists.txt index 28381461acc05d036887b757015aed4046c7621b..35ee536293f8a0dd53e4a36c99fc3e2ec7ad98e5 100644 --- a/Reconstruction/Jet/JetUncertainties/CMakeLists.txt +++ b/Reconstruction/Jet/JetUncertainties/CMakeLists.txt @@ -13,7 +13,7 @@ atlas_add_library( JetUncertaintiesLib INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} LINK_LIBRARIES ${ROOT_LIBRARIES} AsgMessagingLib AsgTools xAODEventInfo xAODJet PATInterfaces JetCPInterfaces - PRIVATE_LINK_LIBRARIES xAODCore xAODTracking PathResolver ) + PRIVATE_LINK_LIBRARIES xAODCore xAODTracking PathResolver ParticleJetToolsLib ) if( NOT XAOD_STANDALONE ) atlas_add_component( JetUncertainties @@ -37,12 +37,24 @@ if( XAOD_STANDALONE ) util/MakeUncertaintyPlots.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} LINK_LIBRARIES ${ROOT_LIBRARIES} xAODJet xAODEventInfo - xAODRootAccess JetUncertaintiesLib ) + xAODRootAccess JetUncertaintiesLib ParticleJetToolsLib ) atlas_add_executable( JetUncertainties_testTool util/testTool.cxx LINK_LIBRARIES xAODJet xAODEventInfo PATInterfaces xAODRootAccess JetUncertaintiesLib ) + + atlas_add_executable( JetUncertainties_testResolution + util/testResolution.cxx + LINK_LIBRARIES ${ROOT_LIBRARIES} xAODJet xAODEventInfo + xAODRootAccess JetUncertaintiesLib ParticleJetToolsLib ) + + # TODO: cleanup + # atlas_add_executable( FFJetSmearingTool_MyExample + # util/FFJetSmearingTool_MyExample.cxx + # INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + # LINK_LIBRARIES ${ROOT_LIBRARIES} xAODJet xAODEventInfo xAODEventShape + # xAODRootAccess JetUncertaintiesLib ) endif() # Install files from the package: diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/ClosebyUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/ClosebyUncertaintyComponent.h index 012f1e636234369891f8d5e65d3fcd8c0d77c135..cae4ce17d6ab39f8c3551692fc80a39b5f097d75 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/ClosebyUncertaintyComponent.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/ClosebyUncertaintyComponent.h @@ -18,7 +18,6 @@ class ClosebyUncertaintyComponent : public UncertaintyComponent ClosebyUncertaintyComponent(const ClosebyUncertaintyComponent& toCopy); virtual ClosebyUncertaintyComponent* clone() const; virtual ~ClosebyUncertaintyComponent() {} - ClosebyUncertaintyComponent & operator = (const ClosebyUncertaintyComponent &) = delete; protected: diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/CombinedMassUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/CombinedMassUncertaintyComponent.h index 31a94a94ccf747f8df213cc9fb5468c6cc9a92e8..13dcbc94019dc40dddd26d6d3aa440a30d64b06b 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/CombinedMassUncertaintyComponent.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/CombinedMassUncertaintyComponent.h @@ -20,14 +20,13 @@ class CombinedMassUncertaintyComponent : public UncertaintyComponent CombinedMassUncertaintyComponent(const ComponentHelper& component); CombinedMassUncertaintyComponent(const CombinedMassUncertaintyComponent& toCopy); virtual CombinedMassUncertaintyComponent* clone() const; - CombinedMassUncertaintyComponent & operator=(const CombinedMassUncertaintyComponent &) = delete; virtual ~CombinedMassUncertaintyComponent(); - // virtual StatusCode setCaloTerm(UncertaintyGroup* caloComp); virtual StatusCode setTATerm( UncertaintyGroup* TAComp); virtual StatusCode setCaloWeights(const UncertaintyHistogram* caloWeights); virtual StatusCode setTAWeights( const UncertaintyHistogram* TAWeights); virtual StatusCode setCombWeightMassDefs(const CompMassDef::TypeEnum caloMassDef, const CompMassDef::TypeEnum TAMassDef); + virtual StatusCode setCombWeightParam(const CompParametrization::TypeEnum param); virtual StatusCode initialize(TFile* histFile); // Extra information retrieval methods @@ -43,6 +42,7 @@ class CombinedMassUncertaintyComponent : public UncertaintyComponent // Method overrides virtual bool isAlwaysZero() const; + protected: // Uncertainty/validity retrieval helper methods virtual bool getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; @@ -65,8 +65,11 @@ class CombinedMassUncertaintyComponent : public UncertaintyComponent // The two possible scale helpers JetFourMomAccessor m_caloMassScale_weights; JetFourMomAccessor m_TAMassScale_weights; + // The weight parametrization + CompParametrization::TypeEnum m_weightParam; // Helper functions + double readHistoFromParam(const xAOD::JetFourMom_t& jet4vec, const UncertaintyHistogram& histo, const CompParametrization::TypeEnum param, const double massShiftFactor) const; virtual double getWeightFactorCalo(const xAOD::Jet& jet, const double shiftFactor) const; virtual double getWeightFactorTA( const xAOD::Jet& jet, const double shiftFactor) const; StatusCode calculateCombinedMass(const xAOD::Jet& jet, const double shiftFactorCalo, const double shiftFactorTA, double& combMass) const; diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/ConfigHelper.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/ConfigHelper.h index 6796dc875bc9f645515ba443986cb63f8dad89a4..c075f397420c6532a6557a81d5bd208a7e71f162 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/ConfigHelper.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/ConfigHelper.h @@ -1,11 +1,12 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef JETUNCERTAINTIES_CONFIGHELPER_H #define JETUNCERTAINTIES_CONFIGHELPER_H #include "JetUncertainties/UncertaintyEnum.h" +#include "ParticleJetTools/LargeRJetLabelEnum.h" #include "AsgMessaging/AsgMessaging.h" #include "AsgMessaging/StatusCode.h" @@ -32,30 +33,44 @@ class ComponentHelper TString param; TString massDefStr; TString scale; + TString topologyStr; TString interpolStr; TString special; TString uncNameList; TString validName; TString subCompList; - int splitNum{}; - int groupNum{}; + int splitNum; + int groupNum; TString combMassStr; TString caloMassTerm; TString TAMassTerm; TString caloMassDef; TString TAMassDef; + TString truthLabelStr; + TString LargeRJetTruthLabelName; + TString LargeRJetTruthLabelStr; + TString LargeRJetTruthLabelsForSFstr; + TString RegionForSFstr; + TString ResultName; // Derived values to parse from the raw values - CompParametrization::TypeEnum parametrization{}; - CompMassDef::TypeEnum massDef{}; - CompScaleVar::TypeEnum scaleVar{}; - bool isSpecial{}; - PileupComp::TypeEnum pileupType{}; - FlavourComp::TypeEnum flavourType{}; - CombMassComp::TypeEnum combMassType{}; - bool interpolate{}; + CompParametrization::TypeEnum parametrization; + CompMassDef::TypeEnum massDef; + CompScaleVar::TypeEnum scaleVar; + JetTopology::TypeEnum topology; + bool isSpecial; + PileupComp::TypeEnum pileupType; + FlavourComp::TypeEnum flavourType; + CombMassComp::TypeEnum combMassType; + Interpolate::TypeEnum interpolate; std::vector<TString> uncNames; std::vector<TString> subComps; + std::vector<int> truthLabels; + std::vector<TString> LargeRJetTruthLabelStrs; + std::vector<LargeRJetTruthLabel::TypeEnum> LargeRJetTruthLabels; + std::vector<TString> LargeRJetTruthLabelsForSFstrs; + std::vector<CompFlavorLabelVar::TypeEnum> LargeRJetTruthLabelsForSF; + CompTaggerRegionVar::TypeEnum RegionForSF; }; class GroupHelper @@ -71,13 +86,13 @@ class GroupHelper TString cat; TString corr; TString isRed; - int groupNum{}; - int subgroupNum{}; + int groupNum; + int subgroupNum; // Derived values to parse from the raw values - CompCategory::TypeEnum category{}; - CompCorrelation::TypeEnum correlation{}; - bool reducible{}; + CompCategory::TypeEnum category; + CompCorrelation::TypeEnum correlation; + bool reducible; }; class ConfigHelper : asg::AsgMessaging diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/ELogMassEtaUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/ELogMassEtaUncertaintyComponent.h new file mode 100644 index 0000000000000000000000000000000000000000..aa403d362fc01f941851f9bb33f18bbc0ec36f66 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/ELogMassEtaUncertaintyComponent.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef JETUNCERTAINTIES_ELOGMASSETAUNCERTAINTYCOMPONENT_H +#define JETUNCERTAINTIES_ELOGMASSETAUNCERTAINTYCOMPONENT_H + +#include "JetUncertainties/UncertaintyComponent.h" + +namespace jet +{ + +class ELogMassEtaUncertaintyComponent : public UncertaintyComponent +{ + public: + // Constructor/destructor/initialization + ELogMassEtaUncertaintyComponent(const ComponentHelper& component); + ELogMassEtaUncertaintyComponent(const ELogMassEtaUncertaintyComponent& toCopy); + virtual ELogMassEtaUncertaintyComponent* clone() const; + virtual ~ELogMassEtaUncertaintyComponent() {} + + protected: + + // Uncertainty/validity retrieval helper methods + virtual bool getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + virtual double getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + + private: + ELogMassEtaUncertaintyComponent(const std::string& name = ""); + const bool m_absEta; + const CompMassDef::TypeEnum m_massDef; +}; + +} // end jet namespace + +#endif + diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/ELogMassUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/ELogMassUncertaintyComponent.h new file mode 100644 index 0000000000000000000000000000000000000000..4282a3a5dad348bfba9949925aa4d4246d7c7b81 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/ELogMassUncertaintyComponent.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef JETUNCERTAINTIES_ELOGMASSUNCERTAINTYCOMPONENT_H +#define JETUNCERTAINTIES_ELOGMASSUNCERTAINTYCOMPONENT_H + +#include "JetUncertainties/UncertaintyComponent.h" + +namespace jet +{ + +class ELogMassUncertaintyComponent : public UncertaintyComponent +{ + public: + // Constructor/destructor/initialization + ELogMassUncertaintyComponent(const ComponentHelper& component); + ELogMassUncertaintyComponent(const ELogMassUncertaintyComponent& toCopy); + virtual ELogMassUncertaintyComponent* clone() const; + virtual ~ELogMassUncertaintyComponent() {} + + protected: + + // Uncertainty/validity retrieval helper methods + virtual bool getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + virtual double getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + + private: + ELogMassUncertaintyComponent(const std::string& name = ""); + const CompMassDef::TypeEnum m_massDef; +}; + +} // end jet namespace + +#endif + diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/FFJetSmearingTool.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/FFJetSmearingTool.h new file mode 100644 index 0000000000000000000000000000000000000000..642ca83bc9b99b3da7f8d32bb55c90322b843214 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/FFJetSmearingTool.h @@ -0,0 +1,199 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + + +#ifndef FFJETSMEARINGTOOL_FFJETSMEARINGTOOL_H +#define FFJETSMEARINGTOOL_FFJETSMEARINGTOOL_H + + +// Framework includes +#include "AsgTools/AsgTool.h" +#include "AsgTools/ToolHandle.h" +#include "PATInterfaces/CorrectionTool.h" + + +//includes for systematics ATLAS structure +#include "PATInterfaces/SystematicsTool.h"//To set the systematics as it is done in JetJvtEfficiency + +#include "PATInterfaces/SystematicCode.h" +#include "PATInterfaces/SystematicRegistry.h" +#include "PATInterfaces/SystematicVariation.h" + + +//xAOD EDM classes +#include "xAODJet/JetContainer.h" + + +// Other packages includes +#include "JetCPInterfaces/ICPJetCorrectionTool.h" + +// Local includes +#include "JetUncertainties/Helpers.h" +#include "JetUncertainties/JetHelpers.h" + + +// Other includes +#include <TFile.h> +#include <TH2.h> +#include <TH3.h> +#include "TEnv.h" +#include "TMath.h" + +#include <memory> //to use make_unique + +/// Implementation of the Forward Folding (FF) Jet smearing tool interface +/// +/// This tool allows to smear and unsmear the mass of Large R jets using +/// the Forward Folding procedure to evaluate systematic uncertainties. +/// For information, see the Twiki: +/// https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/FFJetSmearingTool +/// +/// If you find any bug, please, contact <alberto.prades.ibanez@cern.ch> +/// + + + +namespace JetTools{ + enum class FFJetAllowedMassDefEnum + { + Calo, ///Calorimeter + TA, ///Track Assisted + Comb, ///Combined + }; + StatusCode stringToEnum(const TString& name, FFJetAllowedMassDefEnum& result) + { + if (name.EqualTo("Calo",TString::kIgnoreCase)){ + result = FFJetAllowedMassDefEnum::Calo; + return StatusCode::SUCCESS; + } + if (name.EqualTo("TA",TString::kIgnoreCase)){ + result = FFJetAllowedMassDefEnum::TA; + return StatusCode::SUCCESS; + } + if (name.EqualTo("Comb",TString::kIgnoreCase)){ + result = FFJetAllowedMassDefEnum::Comb; + return StatusCode::SUCCESS; + } + return StatusCode::FAILURE; + } + TString enumToString(const FFJetAllowedMassDefEnum type) + { + switch (type) + { + case FFJetAllowedMassDefEnum::Calo: return "Calo"; + case FFJetAllowedMassDefEnum::TA: return "TA"; + case FFJetAllowedMassDefEnum::Comb: return "Comb"; + default: return ""; + } + } + +} + +namespace CP { + class FFJetSmearingTool : public asg::AsgTool, virtual public ICPJetCorrectionTool + { + + /// Proper constructor for Athena + ASG_TOOL_CLASS( FFJetSmearingTool, ICPJetCorrectionTool ) + + public: + // Constructor/destructor/init + FFJetSmearingTool(const std::string name); + virtual ~FFJetSmearingTool(); + + virtual StatusCode initialize() override; + + + + //New systematic functions + /// @name Methods implementing the ISystematicsTool interface + /// @{ + + /// Specify whether tool is affected by provided systematic + virtual bool isAffectedBySystematic(const CP::SystematicVariation& systematic) const override; + + /// List of all systematics affecting this tool + virtual CP::SystematicSet affectingSystematics() const override; + + /// List of all systematics recommended for this tool + virtual CP::SystematicSet recommendedSystematics() const override; + + /// Configure tool to apply systematic variation + virtual CP::SystematicCode applySystematicVariation + (const CP::SystematicSet& systematics) override; + + /// @} + + + virtual CP::CorrectionCode applyCorrection(xAOD::Jet& jet_reco) const override;// The user has to use this function to smear it's jet mass + virtual CP::CorrectionCode correctedCopy(const xAOD::Jet& input, xAOD::Jet*& output) const override; + virtual CP::CorrectionCode applyContainerCorrection(xAOD::JetContainer& inputs) const override; + + StatusCode getMatchedTruthJet( xAOD::Jet& jet_reco, xAOD::Jet& jet_truth_matched) const; + + private: + + + StatusCode readFFJetSmearingToolSimplifiedData(TEnv& settings); + + StatusCode getJMSJMR( xAOD::Jet& jet_reco, double jet_mass, JetTools::FFJetAllowedMassDefEnum MassDef_of_syst ,std::string jetTopology, double& JMS_err, double& JMR_err) const; + + StatusCode getJetTopology( xAOD::Jet& jet_reco, std::string& jetTopology) const; + + double Read3DHistogram(const TH3* histo, double x, double y, double z) const; + + + + // Private members + bool m_isInit; + std::string m_release; + std::string m_truth_jetColl; + std::string m_truthlabelaccessor; + float m_EtaRange; + float m_MaxMass; + float m_MaxPt; + std::string m_calibArea; + std::string m_histFileName; + std::string m_MassDef_string; + JetTools::FFJetAllowedMassDefEnum m_MassDef; + std::string m_configFile; + std::string m_path; + std::string m_HistogramsFilePath; + + //Response matrix + std::unique_ptr<TH2D> m_CALO_ResponseMap; + std::unique_ptr<TH2D> m_TA_ResponseMap; + + //Two histograms to extract the Calo and TA weights in the Combined mass of the jet + std::unique_ptr<TH3F> m_caloMassWeight; + std::unique_ptr<TH3F> m_TAMassWeight; + + + //The list of systemaics + CP::SystematicSet m_SysList; + + //Maps that relates the systematic name with some of its caracteristics + std::map<std::string,std::string> m_Syst_HistPath_map; + std::map<std::string,std::string> m_Syst_MassDefAffected_map; + std::map<std::string,std::string> m_Syst_TopologyAffected_map; + std::map<std::string,std::unique_ptr<TH2D>> m_Syst_Hist_map; + std::map<std::string,std::string> m_Syst_Affects_JMSorJMR; + + //The current systematic configuration + struct SysData final + { + std::string SysBaseName {"None"}; + float SysParameter {0}; + }; + std::unordered_map<CP::SystematicSet,SysData> m_sysData; + /// Points to the current systematic configuration + SysData *m_currentSysData{nullptr}; + + static constexpr float m_MeVtoGeV = 1.e-3; + + }; // Class FFJetSmearingTool + +} // namespace CP + +#endif diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/FlavourUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/FlavourUncertaintyComponent.h index 4188fe438c0f9c6bc842c5f90a78f4f178681174..1e8fd940ce4705a56b35d8ef7320d4a651970329 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/FlavourUncertaintyComponent.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/FlavourUncertaintyComponent.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef JETUNCERTAINTIES_FLAVOURUNCERTAINTYCOMPONENT_H @@ -7,8 +7,6 @@ #include "JetUncertainties/UncertaintyComponent.h" -#include <vector> - namespace jet { @@ -19,11 +17,13 @@ class FlavourUncertaintyComponent : public UncertaintyComponent FlavourUncertaintyComponent(const ComponentHelper& component, const TString jetType, const TString analysisRootFileName, - const TString path + const TString defaultAnalysisRootFileName, + const TString path, + const TString calibArea, + const TString analysisHistPattern="" ); FlavourUncertaintyComponent(const FlavourUncertaintyComponent& toCopy); virtual FlavourUncertaintyComponent* clone() const; - FlavourUncertaintyComponent & operator=(const FlavourUncertaintyComponent &) =delete; virtual ~FlavourUncertaintyComponent(); virtual StatusCode initialize(TFile* histFile); @@ -46,9 +46,17 @@ class FlavourUncertaintyComponent : public UncertaintyComponent const FlavourComp::TypeEnum m_flavourType; const TString m_jetType; const TString m_analysisFileName; + const TString m_analysisHistPattern; + const TString m_defAnaFileName; const TString m_path; + const TString m_calibArea; const bool m_absEta; const TString m_secondUncName; + + std::string m_largeRJetTruthLabelName; + + // Large-R flags to only apply to specific jet types (as other jet types handled by topology uncertainties) + std::vector<LargeRJetTruthLabel::TypeEnum> m_largeRJetTruthLabels; UncertaintyHistogram* m_secondUncHist; FlavourRespType m_respType; @@ -64,17 +72,19 @@ class FlavourUncertaintyComponent : public UncertaintyComponent double getFlavourResponseUncertainty(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; double getFlavourCompositionUncertainty(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; double getBJESUncertainty(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + double getGluonFraction(const double pT, const double eta, const int nJets) const; double getGluonFractionError(const double pT, const double eta, const int nJets) const; double getGluonResponseDifference(const double pT, const double eta) const; double getGluonResponseBaseline(const double pT, const double eta) const; double getQuarkResponseBaseline(const double pT, const double eta) const; - + // Private helper indices and functions StatusCode readNjetsHistograms(std::vector<UncertaintyHistogram*>& hists, const std::vector<TString>& histKeys); StatusCode getNjetFromKey(const TString& key, int& nJets) const; StatusCode checkNjetsInput(int& nJets) const; bool isBjet(const xAOD::Jet& jet) const; + void getGluonKeys(TFile* analysisFile, std::vector<TString>& gluonFractionKeys, std::vector<TString>& gluonFractionErrorKeys) const; }; } // end jet namespace diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h index 62aad5b1ac40ec6c1e540f1fff1a838fea3361ee..41900b06d01c5d66a5d1bdb53c8abcec40f05262 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h @@ -15,7 +15,7 @@ #include "TObjArray.h" #include "TFile.h" -#include "AsgMessaging/MsgStreamMacros.h" +// #include "AsgMessaging/MsgStreamMacros.h #include "xAODJet/Jet.h" #include "xAODJet/JetAccessors.h" @@ -84,10 +84,10 @@ namespace utils bool fileExists(const TString& fileName); // Find a valid file path - TString findFilePath(const TString& fileName, const TString& path = ""); + TString findFilePath(const TString& fileName, const TString& path = "", const TString& calibArea = ""); // Open a root file - TFile* readRootFile(const TString& fileName, const TString& path = ""); + TFile* readRootFile(const TString& fileName, const TString& path = "", const TString& calibArea = ""); // Make bins easily std::vector<double> getLogBins(const size_t numBins, const double minVal, const double maxVal); @@ -189,5 +189,3 @@ std::vector<T> utils::vectorize(const TString& str, const TString& sep) } // end jet namespace #endif - - diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/JetHelpers.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/JetHelpers.h new file mode 100644 index 0000000000000000000000000000000000000000..e6cdb0269ecb59c86e60401706a24424c643e3dc --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/JetHelpers.h @@ -0,0 +1,29 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef JETUNCERTAINTIES_JETHELPERS_H +#define JETUNCERTAINTIES_JETHELPERS_H + +#include "TFile.h" + + +class TH1; + +class TAxis; + +namespace JetHelpers +{ + + // JetHelpers to have a const method for interpolation. This will be change in future versions as discussed in https://sft.its.cern.ch/jira/browse/ROOT-9994 + + double Interpolate(const TH1* histo, const double x); + double Interpolate(const TH1* histo, const double x, const double y); + double Interpolate(const TH1* histo, const double x, const double y, const double z); + + double Interpolate2D(const TH1* histo, const double x, const double y, const int xAxis=1, const int yAxis=2, const int otherDimBin=-1); + + +} + +#endif diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/JetUncertaintiesDict.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/JetUncertaintiesDict.h index fbf7972cd82d905b2d14c5efdc77b5371d996e5d..ab6783966b080f26f99e54b19c77f94b5f3eedfd 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/JetUncertaintiesDict.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/JetUncertaintiesDict.h @@ -10,5 +10,6 @@ #endif // __GCCXML__ #include "JetUncertainties/JetUncertaintiesTool.h" +#include "JetUncertainties/FFJetSmearingTool.h" #endif diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/JetUncertaintiesTool.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/JetUncertaintiesTool.h index 8038fe8460baed5783b7785b30cdd03874d375d7..b7c43bc424bc80719284a9b5c3e8f614ad44c9d4 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/JetUncertaintiesTool.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/JetUncertaintiesTool.h @@ -12,6 +12,9 @@ #include <string> #include <vector> #include <unordered_map> +#include <tuple> + +#include "TRandom3.h" namespace jet { @@ -23,11 +26,11 @@ namespace jet class ConfigHelper; class GroupHelper; class ComponentHelper; + class ResolutionHelper; } class TFile; class TH2D; -class TRandom3; namespace xAOD { @@ -35,7 +38,7 @@ namespace xAOD } class JetUncertaintiesTool : virtual public ICPJetUncertaintiesTool, - virtual public asg::AsgTool + public asg::AsgTool { ASG_TOOL_CLASS(JetUncertaintiesTool,ICPJetUncertaintiesTool) @@ -43,7 +46,6 @@ class JetUncertaintiesTool : virtual public ICPJetUncertaintiesTool, // Constructor/destructor JetUncertaintiesTool(const std::string& name = "JetUncertaintiesTool"); JetUncertaintiesTool(const JetUncertaintiesTool& toCopy); - JetUncertaintiesTool & operator=(const JetUncertaintiesTool&) =delete; virtual ~JetUncertaintiesTool(); // Pre-initialization methods @@ -59,14 +61,16 @@ class JetUncertaintiesTool : virtual public ICPJetUncertaintiesTool, // Tool information retrieval methods - virtual std::string getName() const { return m_name; } - virtual std::string getRelease() const { return m_release; } - virtual std::string getJetDef() const { return m_jetDef; } - virtual std::string getMCType() const { return m_mcType; } - virtual std::string getConfigFile() const { return m_configFile; } - virtual std::string getPath() const { return m_path; } - virtual std::string getAnalysisFile() const { return m_analysisFile; } - virtual float getSqrtS() const; + virtual std::string getName() const { return m_name; } + virtual std::string getRelease() const { return m_release; } + virtual std::string getJetDef() const { return m_jetDef; } + virtual std::string getMCType() const { return m_mcType; } + virtual std::string getConfigFile() const { return m_configFile; } + virtual std::string getPath() const { return m_path; } + virtual std::string getAnalysisFile() const { return m_analysisFile; } + virtual std::string getAnalysisHistPattern() const { return m_analysisHistPattern; } + virtual std::string getDefaultAnaFile() const { return m_defAnaFile; } + virtual float getSqrtS() const; // Tool information retrieval methods that require input virtual float getRefMu() const; @@ -94,8 +98,12 @@ class JetUncertaintiesTool : virtual public ICPJetUncertaintiesTool, virtual bool getComponentScalesTau21WTA(const size_t index) const; virtual bool getComponentScalesTau32WTA(const size_t index) const; virtual bool getComponentScalesD2Beta1(const size_t index) const; + virtual bool getComponentScalesC2Beta1(const size_t index) const; virtual bool getComponentScalesQw(const size_t index) const; + virtual bool getComponentScalesTagScaleFactor(const size_t index) const; virtual bool getComponentScalesMultiple(const size_t index) const; + virtual std::set<jet::CompScaleVar::TypeEnum> getComponentScaleVars(const size_t index) const; + virtual jet::JetTopology::TypeEnum getComponentTopology( const size_t index) const; // Retrieve multi-component information virtual std::vector<std::string> getComponentCategories() const; virtual std::vector<size_t> getComponentsInCategory(const std::string& category) const; @@ -121,6 +129,9 @@ class JetUncertaintiesTool : virtual public ICPJetUncertaintiesTool, virtual double getNormalizedCaloMassWeight(const xAOD::Jet& jet) const; virtual double getNormalizedTAMassWeight( const xAOD::Jet& jet) const; + virtual double getNominalResolutionMC(const xAOD::Jet& jet, const jet::CompScaleVar::TypeEnum smearType, const jet::JetTopology::TypeEnum topology = jet::JetTopology::UNKNOWN) const; + virtual double getNominalResolutionData(const xAOD::Jet& jet, const jet::CompScaleVar::TypeEnum smearType, const jet::JetTopology::TypeEnum topology = jet::JetTopology::UNKNOWN) const; + // Inherited methods from CP::IJetUncertaintiesTool to implement // Apply a systematic variation or get a new copy virtual CP::CorrectionCode applyCorrection(xAOD::Jet& jet) const; @@ -172,11 +183,18 @@ class JetUncertaintiesTool : virtual public ICPJetUncertaintiesTool, std::string m_jetDef; std::string m_mcType; std::string m_configFile; + std::string m_calibArea; std::string m_path; std::string m_analysisFile; + std::string m_analysisHistPattern; std::vector<std::string> m_systFilters; + std::string m_name_TagScaleFactor; + std::string m_name_EffSF; + std::string m_name_Efficiency; + // bool m_flavourJetByJet; // Information to read in and store from the config file + std::string m_defAnaFile; float m_refNPV; float m_refMu; jet::UncertaintyHistogram* m_refNPVHist; @@ -199,10 +217,13 @@ class JetUncertaintiesTool : virtual public ICPJetUncertaintiesTool, jet::UncertaintyHistogram* m_TAMassWeight; jet::CompMassDef::TypeEnum m_combMassWeightCaloMassDef; jet::CompMassDef::TypeEnum m_combMassWeightTAMassDef; + jet::CompParametrization::TypeEnum m_combMassParam; // Smearing information long long int m_userSeed; - TRandom3* m_rand; // pointer so it can be changed in a const function (volatile wasn't working) + mutable TRandom3 m_rand; // mutable as this we want to call in a const function (everything else is fixed, the random generator is modifiable) + bool m_isData; + jet::ResolutionHelper* m_resHelper; // Default prefix for each component name const std::string m_namePrefix; @@ -216,7 +237,10 @@ class JetUncertaintiesTool : virtual public ICPJetUncertaintiesTool, jet::UncertaintyComponent* buildUncertaintyComponent(const jet::ComponentHelper& component) const; const xAOD::EventInfo* getDefaultEventInfo() const; StatusCode checkIndexInput(const size_t index) const; - float getMassSmearingFactor(xAOD::Jet& jet, const double shift) const; + double getSmearingFactor(const xAOD::Jet& jet, const jet::CompScaleVar::TypeEnum smearType, const double variation) const; + double getNominalResolution(const xAOD::Jet& jet, const jet::CompScaleVar::TypeEnum smearType, const jet::JetTopology::TypeEnum topology, const bool readMC) const; + double readHistoFromParam(const xAOD::Jet& jet, const jet::UncertaintyHistogram& histo, const jet::CompParametrization::TypeEnum param, const jet::CompMassDef::TypeEnum massDef) const; + double readHistoFromParam(const xAOD::JetFourMom_t& jet4vec, const jet::UncertaintyHistogram& histo, const jet::CompParametrization::TypeEnum param) const; // Helper methods for setting shifted moments StatusCode updateSplittingScale12(xAOD::Jet& jet, const double shift) const; @@ -226,14 +250,21 @@ class JetUncertaintiesTool : virtual public ICPJetUncertaintiesTool, StatusCode updateTau21WTA(xAOD::Jet& jet, const double shift) const; StatusCode updateTau32WTA(xAOD::Jet& jet, const double shift) const; StatusCode updateD2Beta1(xAOD::Jet& jet, const double shift) const; + StatusCode updateC2Beta1(xAOD::Jet& jet, const double shift) const; StatusCode updateQw(xAOD::Jet& jet, const double shift) const; + StatusCode updateTagScaleFactor(xAOD::Jet& jet, const double shift) const; // Helper methods for CP::ISystematicsTool functions bool checkIfRecommendedSystematic(const jet::UncertaintyGroup& systematic) const; virtual CP::SystematicCode addAffectingSystematic(const CP::SystematicVariation& systematic, bool recommended); virtual CP::SystematicCode getFilteredSystematicSet(const CP::SystematicSet& systConfig, CP::SystematicSet& filteredSet); - virtual CP::SystematicCode getUncertaintySet(const CP::SystematicSet& filteredSet, jet::UncertaintySet*& uncSet); + virtual CP::SystematicCode getUncertaintySet(const CP::SystematicSet& filteredSet, jet::UncertaintySet*& uncSet); + + // accessor to taggign efficiency SF + SG::AuxElement::Accessor<float> m_accTagScaleFactor; + SG::AuxElement::Accessor<float> m_accEffSF; + SG::AuxElement::Accessor<float> m_accEfficiency; }; diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/LargeRTopologyUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/LargeRTopologyUncertaintyComponent.h new file mode 100644 index 0000000000000000000000000000000000000000..6870a7b11b3b0609654d6f9d6114fca6625eaeea --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/LargeRTopologyUncertaintyComponent.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARGERTOPOLOGYUNCERTAINTYCOMPONENT_H +#define LARGERTOPOLOGYUNCERTAINTYCOMPONENT_H + +#include "JetUncertainties/UncertaintyComponent.h" +#include "ParticleJetTools/LargeRJetLabelEnum.h" + +namespace jet +{ + +class LargeRTopologyUncertaintyComponent : public UncertaintyComponent +{ + + public: + // Constructor/destructor/initialization + LargeRTopologyUncertaintyComponent(const ComponentHelper& component); + LargeRTopologyUncertaintyComponent(const LargeRTopologyUncertaintyComponent& toCopy); + virtual LargeRTopologyUncertaintyComponent* clone() const; + virtual ~LargeRTopologyUncertaintyComponent() {} + + protected: + // Uncertainty/validity retrieval helper methods + virtual bool getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + virtual double getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + + private: + LargeRTopologyUncertaintyComponent(const std::string& name = ""); + const bool m_absEta; + std::string m_truthLabelName; + std::vector<LargeRJetTruthLabel::TypeEnum> m_truthLabels; +}; + +} // end jet namespace + +#endif + diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PerJetFlavourUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PerJetFlavourUncertaintyComponent.h new file mode 100644 index 0000000000000000000000000000000000000000..aa1f6898f196bd1af533cda6d7c01c16d1f59058 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PerJetFlavourUncertaintyComponent.h @@ -0,0 +1,51 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef JETUNCERTAINTIES_PERJETFLAVOURUNCERTAINTYCOMPONENT_H +#define JETUNCERTAINTIES_PERJETFLAVOURUNCERTAINTYCOMPONENT_H + +#include "JetUncertainties/UncertaintyComponent.h" + +namespace jet +{ + +class PerJetFlavourUncertaintyComponent : public UncertaintyComponent +{ + public: + // Constructor/destructor + PerJetFlavourUncertaintyComponent(const ComponentHelper& component); + PerJetFlavourUncertaintyComponent(const PerJetFlavourUncertaintyComponent& toCopy); + virtual PerJetFlavourUncertaintyComponent* clone() const; + virtual ~PerJetFlavourUncertaintyComponent() {} + virtual StatusCode initialize(TFile* histFile); + + // Extra information retrieval methods + virtual std::vector<int> getRelevantLabels() const { return m_labels; } + + protected: + + // Uncertainty/validity retrieval helper methods + virtual bool getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + virtual double getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + + private: + // Default constructor is forbidden + PerJetFlavourUncertaintyComponent(const std::string& name = ""); + + // Additional private members + const bool m_absEta; + const std::vector<int> m_labels; + + // Wrappers for special flavour histograms + double getFlavourResponseUncertainty(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + bool isSupportedLabel(const int label) const; + bool checkTruthLabel(const xAOD::Jet& jet) const; + +}; + +} // end jet namespace + + +#endif + diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PileupUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PileupUncertaintyComponent.h index b3673ce9cdc7cc99d0a10f2f2338d7e7f7b00dc9..5a4d630f2fffa694650f261bb26e924b5e17d00c 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PileupUncertaintyComponent.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PileupUncertaintyComponent.h @@ -32,7 +32,6 @@ class PileupUncertaintyComponent : public UncertaintyComponent ); PileupUncertaintyComponent(const PileupUncertaintyComponent& toCopy); virtual PileupUncertaintyComponent* clone() const; - PileupUncertaintyComponent & operator =( const PileupUncertaintyComponent &) = delete; virtual ~PileupUncertaintyComponent(); virtual StatusCode initialize(TFile* histFile); diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtAbsMassEtaUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtAbsMassEtaUncertaintyComponent.h new file mode 100644 index 0000000000000000000000000000000000000000..f9409f71ef33be4633fe7122f5e02709117b52e6 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtAbsMassEtaUncertaintyComponent.h @@ -0,0 +1,38 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef JETUNCERTAINTIES_PTABSMASSETAUNCERTAINTYCOMPONENT_H +#define JETUNCERTAINTIES_PTABSMASSETAUNCERTAINTYCOMPONENT_H + +#include "JetUncertainties/UncertaintyComponent.h" + +namespace jet +{ + +class PtAbsMassEtaUncertaintyComponent : public UncertaintyComponent +{ + public: + // Constructor/destructor/initialization + PtAbsMassEtaUncertaintyComponent(const ComponentHelper& component); + PtAbsMassEtaUncertaintyComponent(const PtAbsMassEtaUncertaintyComponent& toCopy); + virtual PtAbsMassEtaUncertaintyComponent* clone() const; + virtual ~PtAbsMassEtaUncertaintyComponent() {} + + protected: + + // Uncertainty/validity retrieval helper methods + virtual bool getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + virtual double getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + + private: + PtAbsMassEtaUncertaintyComponent(const std::string& name = ""); + const bool m_absEta; + const CompMassDef::TypeEnum m_massDef; +}; + +} // end jet namespace + +#endif + + diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtAbsMassUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtAbsMassUncertaintyComponent.h new file mode 100644 index 0000000000000000000000000000000000000000..ee9f968da8fd353dbdfd23b96c25c1ee9f0d8290 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtAbsMassUncertaintyComponent.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef JETUNCERTAINTIES_PTABSMASSUNCERTAINTYCOMPONENT_H +#define JETUNCERTAINTIES_PTABSMASSUNCERTAINTYCOMPONENT_H + +#include "JetUncertainties/UncertaintyComponent.h" + +namespace jet +{ + +class PtAbsMassUncertaintyComponent : public UncertaintyComponent +{ + public: + // Constructor/destructor/initialization + PtAbsMassUncertaintyComponent(const ComponentHelper& component); + PtAbsMassUncertaintyComponent(const PtAbsMassUncertaintyComponent& toCopy); + virtual PtAbsMassUncertaintyComponent* clone() const; + virtual ~PtAbsMassUncertaintyComponent() {} + + protected: + + // Uncertainty/validity retrieval helper methods + virtual bool getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + virtual double getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + + private: + PtAbsMassUncertaintyComponent(const std::string& name = ""); + const CompMassDef::TypeEnum m_massDef; +}; + +} // end jet namespace + +#endif + + diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtEtaUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtEtaUncertaintyComponent.h index 7a8c2de80d43ac9ff0e5a2ca2cd066c6906e70f5..534522d309c8608c0c8b91fef79fd96e7d641443 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtEtaUncertaintyComponent.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtEtaUncertaintyComponent.h @@ -17,7 +17,6 @@ class PtEtaUncertaintyComponent : public UncertaintyComponent PtEtaUncertaintyComponent(const ComponentHelper& component); PtEtaUncertaintyComponent(const PtEtaUncertaintyComponent& toCopy); virtual PtEtaUncertaintyComponent* clone() const; - PtEtaUncertaintyComponent & operator=(const PtEtaUncertaintyComponent &) = delete; virtual ~PtEtaUncertaintyComponent() {} protected: diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtLogPtMassForTagSFUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtLogPtMassForTagSFUncertaintyComponent.h new file mode 100644 index 0000000000000000000000000000000000000000..152a54f9c5c16930e7a8ee9b716b0c1d70b9de5a --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtLogPtMassForTagSFUncertaintyComponent.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef JETUNCERTAINTIES_PTLOGPTMASSFORTAGSFUNCERTAINTYCOMPONENT_H +#define JETUNCERTAINTIES_PTLOGPTMASSFORTAGSFUNCERTAINTYCOMPONENT_H + +#include "JetUncertainties/UncertaintyComponent.h" +#include "ParticleJetTools/LargeRJetLabelEnum.h" + +namespace jet +{ + +class PtLogPtMassForTagSFUncertaintyComponent : public UncertaintyComponent +{ + public: + // Constructor/destructor/initialization + PtLogPtMassForTagSFUncertaintyComponent(const ComponentHelper& component); + PtLogPtMassForTagSFUncertaintyComponent(const PtLogPtMassForTagSFUncertaintyComponent& toCopy); + virtual PtLogPtMassForTagSFUncertaintyComponent* clone() const; + virtual ~PtLogPtMassForTagSFUncertaintyComponent() {} + + protected: + + // Uncertainty/validity retrieval helper methods + virtual bool getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + virtual double getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + + private: + PtLogPtMassForTagSFUncertaintyComponent(const std::string& name = ""); + const CompMassDef::TypeEnum m_massDef; + std::vector<CompFlavorLabelVar::TypeEnum> m_labels; + std::string m_largeRJetTruthLabelName; + const CompTaggerRegionVar::TypeEnum m_region; + const TString m_result_name; +}; + +} // end jet namespace + +#endif + diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtMassEtaUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtMassEtaUncertaintyComponent.h index f598340ddc125ac25ee61304416f7d91a31c0e65..c01194f9ba815f9a9e8d3bdb13a275c9099fe28d 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtMassEtaUncertaintyComponent.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtMassEtaUncertaintyComponent.h @@ -17,7 +17,6 @@ class PtMassEtaUncertaintyComponent : public UncertaintyComponent PtMassEtaUncertaintyComponent(const ComponentHelper& component); PtMassEtaUncertaintyComponent(const PtMassEtaUncertaintyComponent& toCopy); virtual PtMassEtaUncertaintyComponent* clone() const; - PtMassEtaUncertaintyComponent & operator=(const PtMassEtaUncertaintyComponent &) =delete; virtual ~PtMassEtaUncertaintyComponent() {} protected: diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtMassUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtMassUncertaintyComponent.h index cb401703dc372a48866cc3539cab990017bc3838..52eeb431eaf7716f3e17868c42d403c9076c63f3 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtMassUncertaintyComponent.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtMassUncertaintyComponent.h @@ -17,7 +17,6 @@ class PtMassUncertaintyComponent : public UncertaintyComponent PtMassUncertaintyComponent(const ComponentHelper& component); PtMassUncertaintyComponent(const PtMassUncertaintyComponent& toCopy); virtual PtMassUncertaintyComponent* clone() const; - PtMassUncertaintyComponent & operator=(const PtMassUncertaintyComponent &) = delete; virtual ~PtMassUncertaintyComponent() {} protected: diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtUncertaintyComponent.h index c34adb6d5194a5800fe7b442183b75b00fea05c4..c1475f442a5f47dea923a213be26fc66bca68ca5 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtUncertaintyComponent.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PtUncertaintyComponent.h @@ -17,7 +17,6 @@ class PtUncertaintyComponent : public UncertaintyComponent PtUncertaintyComponent(const ComponentHelper& component); PtUncertaintyComponent(const PtUncertaintyComponent& toCopy); virtual PtUncertaintyComponent* clone() const; - PtUncertaintyComponent & operator=(const PtUncertaintyComponent &) = delete; virtual ~PtUncertaintyComponent() {} protected: diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PunchthroughUncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PunchthroughUncertaintyComponent.h index 520bf265452e0615f14fbabf984efe8aa0cd197b..be6bd309734b3f4a3d580c81da98fe09962f923d 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/PunchthroughUncertaintyComponent.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/PunchthroughUncertaintyComponent.h @@ -17,7 +17,6 @@ class PunchthroughUncertaintyComponent : public UncertaintyComponent PunchthroughUncertaintyComponent(const ComponentHelper& component); PunchthroughUncertaintyComponent(const PunchthroughUncertaintyComponent& toCopy); virtual PunchthroughUncertaintyComponent* clone() const; - PunchthroughUncertaintyComponent & operator=(const PunchthroughUncertaintyComponent &) = delete; virtual ~PunchthroughUncertaintyComponent() {} protected: diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/ResolutionHelper.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/ResolutionHelper.h new file mode 100644 index 0000000000000000000000000000000000000000..f4c9190a1bdb07a591c9995fd37d08b74f0d39e3 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/ResolutionHelper.h @@ -0,0 +1,95 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef JETUNCERTAINTIES_RESOLUTIONHELPER_H +#define JETUNCERTAINTIES_RESOLUTIONHELPER_H + +#include "JetUncertainties/UncertaintyEnum.h" +#include "JetUncertainties/UncertaintyHistogram.h" + +#include "AsgMessaging/AsgMessaging.h" + +#include <tuple> + +class TEnv; +class TFile; + +namespace jet +{ + +class ResolutionHelper : public asg::AsgMessaging +{ + public: + ResolutionHelper(const std::string& name, const std::string& jetDef); + ResolutionHelper(const ResolutionHelper& toCopy); + virtual StatusCode initialize(TEnv& settings, TFile* histFile, const TString& MCtype); + virtual ~ResolutionHelper(); + + // Information retrieval + std::tuple<const UncertaintyHistogram*,CompParametrization::TypeEnum,CompMassDef::TypeEnum> getNominalResolution(const CompScaleVar::TypeEnum smearType, const JetTopology::TypeEnum topology, const bool readMC) const; + + bool smearOnlyMC() const { return m_smearOnlyMC; } + bool smearDataAndMC() const { return !m_smearOnlyMC; } + + bool hasRelevantInfo(const CompScaleVar::TypeEnum type, const JetTopology::TypeEnum topology) const; + + private: + std::string m_name; + std::string m_jetDef; + bool m_isInit; + + bool m_smearOnlyMC; + + // Nominal resolution histograms + UncertaintyHistogram* m_ptNomHistData; + CompParametrization::TypeEnum m_ptNomParamData; + CompMassDef::TypeEnum m_ptNomMassDefData; + UncertaintyHistogram* m_ptNomHistMC; + CompParametrization::TypeEnum m_ptNomParamMC; + CompMassDef::TypeEnum m_ptNomMassDefMC; + + UncertaintyHistogram* m_fvNomHistData; + CompParametrization::TypeEnum m_fvNomParamData; + CompMassDef::TypeEnum m_fvNomMassDefData; + UncertaintyHistogram* m_fvNomHistMC; + CompParametrization::TypeEnum m_fvNomParamMC; + CompMassDef::TypeEnum m_fvNomMassDefMC; + + UncertaintyHistogram* m_mQCDNomHistData; + CompParametrization::TypeEnum m_mQCDNomParamData; + CompMassDef::TypeEnum m_mQCDNomMassDefData; + UncertaintyHistogram* m_mQCDNomHistMC; + CompParametrization::TypeEnum m_mQCDNomParamMC; + CompMassDef::TypeEnum m_mQCDNomMassDefMC; + + UncertaintyHistogram* m_mWZNomHistData; + CompParametrization::TypeEnum m_mWZNomParamData; + CompMassDef::TypeEnum m_mWZNomMassDefData; + UncertaintyHistogram* m_mWZNomHistMC; + CompParametrization::TypeEnum m_mWZNomParamMC; + CompMassDef::TypeEnum m_mWZNomMassDefMC; + + UncertaintyHistogram* m_mHbbNomHistData; + CompParametrization::TypeEnum m_mHbbNomParamData; + CompMassDef::TypeEnum m_mHbbNomMassDefData; + UncertaintyHistogram* m_mHbbNomHistMC; + CompParametrization::TypeEnum m_mHbbNomParamMC; + CompMassDef::TypeEnum m_mHbbNomMassDefMC; + + UncertaintyHistogram* m_mTopNomHistData; + CompParametrization::TypeEnum m_mTopNomParamData; + CompMassDef::TypeEnum m_mTopNomMassDefData; + UncertaintyHistogram* m_mTopNomHistMC; + CompParametrization::TypeEnum m_mTopNomParamMC; + CompMassDef::TypeEnum m_mTopNomMassDefMC; + + // Helper methods + StatusCode parseInput(TEnv& settings, TFile* histFile, const TString& key, const TString& defaultValue, UncertaintyHistogram*& hist, CompParametrization::TypeEnum& param, CompMassDef::TypeEnum& massDef,const TString& MCtype); + +}; + +} // end jet namespace + + +#endif diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyComponent.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyComponent.h index d2b63963b4845331ffbd63ef6ba34f81021c2369..d4c388780fed9c5a829be64b261b252d921f9e03 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyComponent.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyComponent.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef JETUNCERTAINTIES_UNCERTAINTYCOMPONENT_H @@ -28,7 +28,6 @@ class UncertaintyComponent : public asg::AsgMessaging UncertaintyComponent(const ComponentHelper& component, const size_t numHist = 1); UncertaintyComponent(const UncertaintyComponent& toCopy); virtual UncertaintyComponent* clone() const = 0; - UncertaintyComponent & operator = (const UncertaintyComponent &) = delete; virtual ~UncertaintyComponent(); virtual StatusCode initialize(TFile* histFile); @@ -36,6 +35,7 @@ class UncertaintyComponent : public asg::AsgMessaging virtual TString getName() const { return m_uncHistName; } virtual TString getValidName() const { return m_validHistName; } virtual CompScaleVar::TypeEnum getScaleVar() const { return m_scaleVar; } + virtual JetTopology::TypeEnum getTopology() const { return m_topology; } // Helpers for special situations virtual bool isAlwaysZero() const; @@ -51,11 +51,12 @@ class UncertaintyComponent : public asg::AsgMessaging const TString m_uncHistName; const TString m_validHistName; const CompScaleVar::TypeEnum m_scaleVar; + const JetTopology::TypeEnum m_topology; const float m_energyScale; - const bool m_interpolate; + const Interpolate::TypeEnum m_interpolate; const int m_splitNumber; - int m_numExpectedHist{}; + int m_numExpectedHist; UncertaintyHistogram* m_uncHist; UncertaintyHistogram* m_validHist; @@ -66,7 +67,9 @@ class UncertaintyComponent : public asg::AsgMessaging // Helper methods virtual bool getValidBool(const double validity) const; virtual double getSplitFactor(const xAOD::Jet& jet) const; + virtual double getAbsMass(const xAOD::Jet& jet, const CompMassDef::TypeEnum massDef) const; virtual double getMassOverPt(const xAOD::Jet& jet, const CompMassDef::TypeEnum massDef) const; + virtual double getMassOverE(const xAOD::Jet& jet, const CompMassDef::TypeEnum massDef) const; private: UncertaintyComponent(const std::string& name = ""); diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyEnum.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyEnum.h index bc81db9993133fad5df9bdb3e69a10ae2d725a88..3433aaa688ec444a38d06b8d228731cc899de9af 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyEnum.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyEnum.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef JETUNCERTAINTIES_UNCERTAINTYENUM_H @@ -47,14 +47,22 @@ namespace CompParametrization Pt, // 1D, (pT) dependence PtEta, // 2D, (pT,eta) dependence PtAbsEta, // 2D, (pT,|eta|) dependence + PtAbsMass, // 2D, (pT,mass) dependence PtMass, // 2D, (pt,m/pT) dependence PtMassEta, // 3D, (pT,m/pT,eta) dependence - PtMassAbsEta // 3D, (pT,m/pT,|eta|) dependence + PtMassAbsEta, // 3D, (pT,m/pT,|eta|) dependence + PtAbsMassEta, // 3D, (pT,mass,eta) dependence + PtAbsMassAbsEta,// 3D, (pT,mass,|eta|) dependence + eLOGmOe, // 2D, (E,log(m/E)) dependence + eLOGmOeEta, // 3D, (E,log(m/E),eta) dependence + eLOGmOeAbsEta, // 3D, (E,log(m/E),|eta|) dependence + PtLOGPtMassForTagSF,// 2D, (pt,log(m/pT)) dependence, only for tagging SF }; TString enumToString(const TypeEnum type); TypeEnum stringToEnum(const TString type); bool isAbsEta(const TypeEnum type); + bool includesMass(const TypeEnum type); } namespace CompMassDef @@ -62,6 +70,7 @@ namespace CompMassDef enum TypeEnum { UNKNOWN=0, // Failure/unset/etc + FourVecMass, // Mass directly from the four-vector CaloMass, // Calorimeter jet mass TAMass, // Track-assisted jet mass = (mTrack/pTtrack) * pTcalo CombMassQCD, // Combined jet mass = mCalo*wCalo + mTA*wTA, QCD weights @@ -80,7 +89,10 @@ namespace CompScaleVar { enum TypeEnum { + // Error state UNKNOWN=0, // Failure/unset/etc + + // Scale uncertainties FourVec, // The full jet 4-vector Pt, // The jet pT Mass, // The jet mass (the default four-vector mass) @@ -90,10 +102,55 @@ namespace CompScaleVar Tau32, // The ratio on n-subjettiness 3/2 Tau21WTA, // The ratio on n-subjettiness 2/1 with WTA axis Tau32WTA, // The ratio on n-subjettiness 3/2 with WTA axis - D2Beta1, // The value of D2^{beta=1} (ECF ratio) + D2Beta1, // The value of D_2^{beta=1} (ECF ratio) + C2Beta1, // The value of C_2^{beta=1} (ECF ratio) Qw, // The value of Qw + TagScaleFactor, // Tagging efficiency SF - MassRes // The jet mass resolution + // Resolution uncertainties + MassRes, // The jet mass resolution, relative + MassResAbs, // The jet mass resolution, absolute + PtRes, // The jet pT resolution, relative + PtResAbs, // The jet pT resolution, absolute + FourVecRes, // The jet energy resolution applied to the full four-vector, relative + FourVecResAbs // The jet energy resolution applied to the full four-vector, absolute + }; + TString enumToString(const TypeEnum type); + TypeEnum stringToEnum(const TString type); + + bool isScaleType(const TypeEnum type); + bool isResolutionType(const TypeEnum type); + bool isAbsResolutionType(const TypeEnum type); + bool isRelResolutionType(const TypeEnum type); +} + +namespace CompFlavorLabelVar +{ + enum TypeEnum // used to identify the jet flavor relevant for this NP + { + UNKNOWN=0, // error state + t_qqb, // full-contained top + t, // inclusive top + V_qq, // W/Z->qq + W_qq, // W->qq + Z_qq, // Z->qq + W_qq_From_t,// t->W->qq + t_other, // inclusive top but not contain t_qqb + q // background jet + }; + TString enumToString(const TypeEnum type); + TypeEnum stringToEnum(const TString type); +} + +namespace CompTaggerRegionVar +{ + enum TypeEnum // used to identify the region relevant for this NP + { + UNKNOWN=0, // error state + passMpassD2_2Var,// passing both mass and D2 cuts + passMfailD2_2Var,// passing mass cut but failing D2 + failMpassD2_2Var,// failing mass cut but passing D2 + failMfailD2_2Var // failing both mass and D2 cuts }; TString enumToString(const TypeEnum type); TypeEnum stringToEnum(const TString type); @@ -120,7 +177,8 @@ namespace FlavourComp UNKNOWN=0, // Failure/unset/etc Response, // Flavour response Composition, // Flavour compositon - bJES // bJES response + bJES, // bJES response + PerJetResponse // Per-jet flavour response }; TString enumToString(const TypeEnum type); TypeEnum stringToEnum(const TString type); @@ -147,7 +205,32 @@ namespace JetTopology QCD, // QCD jet topology WZ, // W/Z jet topology Hbb, // Hbb jet topology - Top // Top jet topology + Top, // Top jet topology + MIXED // Mixed topology (multiple of the above) + }; + TString enumToString(const TypeEnum type); + TypeEnum stringToEnum(const TString type); +} + +namespace ExtendedBool +{ + enum TypeEnum + { + UNSET = -1, + FALSE = 0, + TRUE = 1 + }; +} + +namespace Interpolate +{ + enum TypeEnum + { + UNKNOWN=0, // Failure/unset/etc + None, // No interpolation + Full, // Full interpolation + OnlyX, // Interpolate only in the x-direction (hold y,z fixed) + OnlyY // Interpolate only in the y-direction (hold x,z fixed) }; TString enumToString(const TypeEnum type); TypeEnum stringToEnum(const TString type); diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyGroup.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyGroup.h index aeaa5ea3f869001d19bcb9affe0b44bbf9fb6e3d..af3e66752f13322493bfdeb82b491b1162e274ee 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyGroup.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyGroup.h @@ -31,7 +31,6 @@ class UncertaintyGroup : public asg::AsgMessaging UncertaintyGroup(const GroupHelper& group); UncertaintyGroup(const UncertaintyGroup& toCopy); //virtual UncertaintyGroup* clone() const = 0; - UncertaintyGroup & operator=(const UncertaintyGroup &) = delete; virtual ~UncertaintyGroup(); virtual StatusCode addComponent(UncertaintyComponent* component); virtual StatusCode addSubgroup(UncertaintyGroup* subgroup); @@ -55,6 +54,9 @@ class UncertaintyGroup : public asg::AsgMessaging // Access to information on the constituent components virtual std::set<CompScaleVar::TypeEnum> getScaleVars() const; + // Specialty access methods + virtual JetTopology::TypeEnum getTopology(const CompScaleVar::TypeEnum scaleVar = CompScaleVar::UNKNOWN) const; + // Methods to check for special situations virtual bool isAlwaysZero() const; diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyHistogram.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyHistogram.h index 33afa2969a190a9127f1999c729f03763bb3c720..1ae2006f9dc118a363118c69fac4147d88b770c0 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyHistogram.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintyHistogram.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef JETUNCERTAINTIES_UNCERTAINTYHISTOGRAM_H @@ -8,6 +8,10 @@ #include "AsgMessaging/AsgMessaging.h" #include "AsgMessaging/StatusCode.h" +#include "JetUncertainties/UncertaintyEnum.h" + +#include "JetUncertainties/JetHelpers.h" + #include "TString.h" #include "TH1.h" @@ -21,19 +25,18 @@ class UncertaintyHistogram : public asg::AsgMessaging { public: // Constructor/destructor/initialization - UncertaintyHistogram(const std::string& histName, const bool interpolate); - UncertaintyHistogram(const TString histName, const bool interpolate); - UncertaintyHistogram(const char* histName, const bool interpolate); + UncertaintyHistogram(const std::string& histName, const Interpolate::TypeEnum interpolate); + UncertaintyHistogram(const TString histName, const Interpolate::TypeEnum interpolate); + UncertaintyHistogram(const char* histName, const Interpolate::TypeEnum interpolate); UncertaintyHistogram(const UncertaintyHistogram& toCopy); - UncertaintyHistogram & operator=(const UncertaintyHistogram &) =delete; virtual ~UncertaintyHistogram(); virtual StatusCode initialize(TFile* histFile); // Member retrieval methods - const TString& getName() const { return m_name; } - const TH1* getHisto() const { return m_histo; } - bool getInterp() const { return m_interpolate; } - int getNumDim() const { return m_nDim; } + const TString& getName() const { return m_name; } + const TH1* getHisto() const { return m_histo; } + Interpolate::TypeEnum getInterp() const { return m_interpolate; } + int getNumDim() const { return m_nDim; } // Histogram information access double getValue(const double var1) const; @@ -44,21 +47,20 @@ class UncertaintyHistogram : public asg::AsgMessaging // Private members bool m_isInit; const TString m_name; - const bool m_interpolate; + const Interpolate::TypeEnum m_interpolate; TH1* m_histo; int m_nDim; + // Cache projections in case of 1-D interpolation in a 2-D or 3-D histogram + // For a 3-D histogram, it's [y][z] or [x][z] or [x][y] as appropriate + std::vector< std::vector< std::unique_ptr<TH1> > > m_cachedProj; + StatusCode cacheProjections(); + // Histogram reading helpers double readHisto(const double var1, const double var2=0, const double var3=0) const; + double checkBoundariesByBin(const TAxis* axis, const int numBins, const double valInput) const; double checkBoundaries(const TAxis* axis, const int numBins, const double valInput) const; - // Helper to have a const method for interpolation (why is there not a const version in ROOT???) - double Interpolate(const TH1* histo, const double x) const; - double Interpolate(const TH1* histo, const double x, const double y) const; - double Interpolate(const TH1* histo, const double x, const double y, const double z) const; - Int_t FindBin(const TAxis* axis, const double x) const; - - double Interpolate2D(const TH1* histo, const double x, const double y, const int xAxis=1, const int yAxis=2, const int otherDimBin=-1) const; }; } // end jet namespace diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintySet.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintySet.h index 172cba68143abd096aca1e548be835a2c9e357dc..1897f1799dcd56ebc8fea0cf84bbbbd980fbc0b6 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintySet.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/UncertaintySet.h @@ -44,6 +44,9 @@ class UncertaintySet : virtual public asg::AsgMessaging virtual std::vector< std::pair<CompScaleVar::TypeEnum,bool> > getValiditySet(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; virtual std::vector< std::pair<CompScaleVar::TypeEnum,double> > getUncertaintySet(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; virtual std::vector< std::pair<CompScaleVar::TypeEnum,bool> > getValidUncertaintySet(std::vector< std::pair<CompScaleVar::TypeEnum,double> >& unc, const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const; + + // Specialty methods + JetTopology::TypeEnum getTopology(const CompScaleVar::TypeEnum scaleVar = CompScaleVar::UNKNOWN) const; private: // Private members diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/ValidityHistogram.h b/Reconstruction/Jet/JetUncertainties/JetUncertainties/ValidityHistogram.h index c171c13c22e0a5bb7b25ff50f87a17d04959170b..35ee6bc4a32a1903faae11d55eba97077ecba03d 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/ValidityHistogram.h +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/ValidityHistogram.h @@ -23,7 +23,6 @@ class ValidityHistogram : public UncertaintyHistogram ValidityHistogram(const TString& histName, const CompParametrization::TypeEnum parametrization, const float energyScale, const CompMassDef::TypeEnum massDef); ValidityHistogram(const char* histName, const CompParametrization::TypeEnum parametrization, const float energyScale, const CompMassDef::TypeEnum massDef); ValidityHistogram(const ValidityHistogram& toCopy); - ValidityHistogram & operator=(const ValidityHistogram &) = delete; virtual ~ValidityHistogram(); virtual StatusCode initialize(TFile* histFile); diff --git a/Reconstruction/Jet/JetUncertainties/JetUncertainties/selection.xml b/Reconstruction/Jet/JetUncertainties/JetUncertainties/selection.xml index 6c1aea1f5fa4cdfeaec14ec3404686279a9712cb..f398cd8f9a58898a854d45cfcaff5dc3e4981ac6 100644 --- a/Reconstruction/Jet/JetUncertainties/JetUncertainties/selection.xml +++ b/Reconstruction/Jet/JetUncertainties/JetUncertainties/selection.xml @@ -1,6 +1,6 @@ <lcgdict> <class name="JetUncertaintiesTool" /> - + <class name="FFJetSmearingTool" /> <!-- Suppress the unwanted classes found by ROOT 6. --> <!-- Hopefully we can remove these extra lines at one point... --> <exclusion> diff --git a/Reconstruction/Jet/JetUncertainties/Root/CombinedMassUncertaintyComponent.cxx b/Reconstruction/Jet/JetUncertainties/Root/CombinedMassUncertaintyComponent.cxx index e9c5edfad149244af7327ef407020068ef979e95..b3ff47ffba0472c3ad8a09379b4979822f0ae55a 100644 --- a/Reconstruction/Jet/JetUncertainties/Root/CombinedMassUncertaintyComponent.cxx +++ b/Reconstruction/Jet/JetUncertainties/Root/CombinedMassUncertaintyComponent.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "JetUncertainties/CombinedMassUncertaintyComponent.h" @@ -27,6 +27,7 @@ CombinedMassUncertaintyComponent::CombinedMassUncertaintyComponent(const std::st , m_TAMassWeight(NULL) , m_caloMassScale_weights("") , m_TAMassScale_weights("") + , m_weightParam(CompParametrization::UNKNOWN) { JESUNC_NO_DEFAULT_CONSTRUCTOR; } @@ -41,6 +42,7 @@ CombinedMassUncertaintyComponent::CombinedMassUncertaintyComponent(const Compone , m_TAMassWeight(NULL) , m_caloMassScale_weights("") , m_TAMassScale_weights("") + , m_weightParam(CompParametrization::UNKNOWN) { ATH_MSG_DEBUG("Created CombinedMassUncertaintyComponent named " << getName().Data()); } @@ -55,6 +57,7 @@ CombinedMassUncertaintyComponent::CombinedMassUncertaintyComponent(const Combine , m_TAMassWeight(toCopy.m_TAMassWeight) , m_caloMassScale_weights(toCopy.m_caloMassScale_weights) , m_TAMassScale_weights(toCopy.m_TAMassScale_weights) + , m_weightParam(toCopy.m_weightParam) { ATH_MSG_DEBUG("Creating copy of CombinedMassUncertaintyComponent named " << getName().Data()); if (toCopy.m_caloMassComp) @@ -179,6 +182,18 @@ StatusCode CombinedMassUncertaintyComponent::setCombWeightMassDefs(const CompMas return StatusCode::SUCCESS; } +StatusCode CombinedMassUncertaintyComponent::setCombWeightParam(const CompParametrization::TypeEnum param) +{ + if (m_isInit) + { + ATH_MSG_ERROR("Can only set the weight parametrization before initialization: " << getName().Data()); + return StatusCode::FAILURE; + } + m_weightParam = param; + + return StatusCode::SUCCESS; +} + StatusCode CombinedMassUncertaintyComponent::initialize(TFile* histFile) { // We are completely different here than the normal case @@ -320,8 +335,6 @@ StatusCode CombinedMassUncertaintyComponent::calculateCombinedMass(const xAOD::J else combMass = (caloMassScale.m(jet)*shiftFactorCalo*caloWeight) + (TAMassScale.m(jet)*shiftFactorTA*TAWeight); - //if (fabs(jet.pt()*m_energyScale-700)<1 && fabs(jet.m()*m_energyScale-70)<1) ATH_MSG_INFO(Form("CombMass: %f*%f*%f + %f*%f*%f = %f",caloMassScale(jet).M()*m_energyScale,shiftFactorCalo,caloWeight,TAMassScale(jet).M()*m_energyScale,shiftFactorTA,TAWeight,combMass*m_energyScale)); - return StatusCode::SUCCESS; } @@ -361,8 +374,6 @@ double CombinedMassUncertaintyComponent::getUncertaintyImpl(const xAOD::Jet& jet const double massUncUp = fabs((massUp-massDefault)/massDefault); const double massUncDown = fabs((massDown-massDefault)/massDefault); - //if (fabs(jet.pt()*m_energyScale-700)<1 && fabs(jet.m()*m_energyScale-70)<1) ATH_MSG_INFO(Form("Combined mass: pT = %.0f, m = %.1f, mComb = %.1f, mCaloUnc = %.1f%%, mTAUnc = %.1f%%, m+1s = %.1f (%.1f%%), m-1s = %.1f (%.1f%%)",jet.pt()*m_energyScale,jet.m()*m_energyScale,massDefault*m_energyScale,100*uncCalo,100*uncTA,massUp*m_energyScale,100*massUncUp,massDown*m_energyScale,100*massUncDown)); - return (massUncUp+massUncDown)/2.; } @@ -398,20 +409,66 @@ bool CombinedMassUncertaintyComponent::getValidUncertaintyTA(double& unc, const return !m_TAMassComp ? true : m_TAMassComp->getValidUncertainty(unc,jet,eInfo,CompScaleVar::Mass); } -double CombinedMassUncertaintyComponent::getWeightFactorCalo(const xAOD::Jet& jet, const double shiftFactor) const +double CombinedMassUncertaintyComponent::readHistoFromParam(const xAOD::JetFourMom_t& jet4vec, const UncertaintyHistogram& histo, const CompParametrization::TypeEnum param, const double massShiftFactor) const { - const double resolution = !m_caloMassWeight ? 0 : m_caloMassWeight->getValue(m_caloMassScale_weights(jet).Pt()*m_energyScale, - (m_caloMassScale_weights(jet).M()*shiftFactor)/m_caloMassScale_weights(jet).Pt() - ); + double resolution = 0; + switch (param) + { + case CompParametrization::Pt: + resolution = histo.getValue(jet4vec.Pt()*m_energyScale); + break; + case CompParametrization::PtEta: + resolution = histo.getValue(jet4vec.Pt()*m_energyScale,jet4vec.Eta()); + break; + case CompParametrization::PtAbsMass: + resolution = histo.getValue(jet4vec.Pt()*m_energyScale,jet4vec.M()*m_energyScale*massShiftFactor); + break; + case CompParametrization::PtAbsEta: + resolution = histo.getValue(jet4vec.Pt()*m_energyScale,fabs(jet4vec.Eta())); + break; + case CompParametrization::PtMass: + resolution = histo.getValue(jet4vec.Pt()*m_energyScale,jet4vec.M()*massShiftFactor/jet4vec.Pt()); + break; + case CompParametrization::PtMassEta: + resolution = histo.getValue(jet4vec.Pt()*m_energyScale,jet4vec.M()*massShiftFactor/jet4vec.Pt(),jet4vec.Eta()); + break; + case CompParametrization::PtMassAbsEta: + resolution = histo.getValue(jet4vec.Pt()*m_energyScale,jet4vec.M()*massShiftFactor/jet4vec.Pt(),fabs(jet4vec.Eta())); + break; + case CompParametrization::PtAbsMassEta: + resolution = histo.getValue(jet4vec.Pt()*m_energyScale,jet4vec.M()*m_energyScale*massShiftFactor,jet4vec.Eta()); + break; + case CompParametrization::PtAbsMassAbsEta: + resolution = histo.getValue(jet4vec.Pt()*m_energyScale,jet4vec.M()*m_energyScale*massShiftFactor,fabs(jet4vec.Eta())); + break; + case CompParametrization::eLOGmOe: + resolution = histo.getValue(jet4vec.E()*m_energyScale,log(jet4vec.M()*massShiftFactor/jet4vec.E())); + break; + case CompParametrization::eLOGmOeEta: + resolution = histo.getValue(jet4vec.E()*m_energyScale,log(jet4vec.M()*massShiftFactor/jet4vec.E()),jet4vec.Eta()); + break; + case CompParametrization::eLOGmOeAbsEta: + resolution = histo.getValue(jet4vec.E()*m_energyScale,log(jet4vec.M()*massShiftFactor/jet4vec.E()),fabs(jet4vec.Eta())); + break; + default: + ATH_MSG_ERROR("Failed to read histogram due to unknown parametrization type in " << getName()); + break; + } return resolution == 0 ? 0 : 1./(resolution*resolution); } -double CombinedMassUncertaintyComponent::getWeightFactorTA(const xAOD::Jet& jet, const double shiftFactor) const +double CombinedMassUncertaintyComponent::getWeightFactorCalo(const xAOD::Jet& jet, const double massShiftFactor) const { - const double resolution = !m_TAMassWeight ? 0 : m_TAMassWeight->getValue(m_TAMassScale_weights(jet).Pt()*m_energyScale, - (m_TAMassScale_weights(jet).M()*shiftFactor)/m_TAMassScale_weights(jet).Pt() - ); - return resolution == 0 ? 0 : 1./(resolution*resolution); + if(m_caloMassScale_weights(jet).M() < 0.0) return 0; + if(!m_caloMassWeight) return 0; + return readHistoFromParam(m_caloMassScale_weights(jet),*m_caloMassWeight,m_weightParam,massShiftFactor); +} + +double CombinedMassUncertaintyComponent::getWeightFactorTA(const xAOD::Jet& jet, const double massShiftFactor) const +{ + if(m_TAMassScale_weights(jet).M() < 0.0) return 0; + if(!m_TAMassWeight) return 0; + return readHistoFromParam(m_TAMassScale_weights(jet),*m_TAMassWeight,m_weightParam,massShiftFactor); } diff --git a/Reconstruction/Jet/JetUncertainties/Root/ConfigHelper.cxx b/Reconstruction/Jet/JetUncertainties/Root/ConfigHelper.cxx index 7d74cd00cf3c1d145b15e4a9e5b55ae48246cd0c..af49ef9a288a654c91c5156e9a7e56ea98d184ac 100644 --- a/Reconstruction/Jet/JetUncertainties/Root/ConfigHelper.cxx +++ b/Reconstruction/Jet/JetUncertainties/Root/ConfigHelper.cxx @@ -1,10 +1,11 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "JetUncertainties/ConfigHelper.h" #include "JetUncertainties/Helpers.h" +#include <stdexcept> #include "TEnv.h" @@ -41,6 +42,7 @@ ComponentHelper::ComponentHelper(TEnv& settings, const TString& compPrefix, cons param = settings.GetValue(compPrefix+"Param",""); massDefStr = settings.GetValue(compPrefix+"MassDef",""); scale = settings.GetValue(compPrefix+"Scale","FourVec"); + topologyStr = settings.GetValue(compPrefix+"Topology",""); interpolStr = settings.GetValue(compPrefix+"Interp","true"); special = settings.GetValue(compPrefix+"Special",""); uncNameList = TString(settings.GetValue(compPrefix+"Hists","")).ReplaceAll("MCTYPE",MCtype); @@ -53,20 +55,50 @@ ComponentHelper::ComponentHelper(TEnv& settings, const TString& compPrefix, cons TAMassTerm = settings.GetValue(compPrefix+"TAMassTerm",""); caloMassDef = settings.GetValue(compPrefix+"CaloMassDef",""); TAMassDef = settings.GetValue(compPrefix+"TAMassDef",""); - + truthLabelStr = settings.GetValue(compPrefix+"TruthLabels",""); + LargeRJetTruthLabelName = settings.GetValue(compPrefix+"LargeRJetTruthLabelName","R10TruthLabel_R21Consolidated"); + LargeRJetTruthLabelStr = settings.GetValue(compPrefix+"FatjetTruthLabels",""); + LargeRJetTruthLabelsForSFstr = settings.GetValue(compPrefix+"LargeRJetTruthLabelForSF",""); + RegionForSFstr = settings.GetValue(compPrefix+"RegionForSF",""); + ResultName = settings.GetValue(compPrefix+"ResultName",""); // Get enums where appropriate // Leave interpreting/checking the enums to others parametrization = CompParametrization::stringToEnum(param); massDef = CompMassDef::stringToEnum(massDefStr); scaleVar = CompScaleVar::stringToEnum(scale); + topology = JetTopology::stringToEnum(topologyStr); isSpecial = (!special.CompareTo("true",TString::kIgnoreCase)) || (!special.CompareTo("yes",TString::kIgnoreCase)); pileupType = PileupComp::stringToEnum(name); flavourType = FlavourComp::stringToEnum(name); combMassType = CombMassComp::stringToEnum(combMassStr); - interpolate = utils::getTypeObjFromString<bool>(interpolStr); + interpolate = Interpolate::stringToEnum(interpolStr); uncNames = utils::vectorize<TString>(uncNameList,", "); subComps = utils::vectorize<TString>(subCompList,", "); + truthLabels = utils::vectorize<int>(truthLabelStr,", "); + LargeRJetTruthLabelStrs = utils::vectorize<TString>(LargeRJetTruthLabelStr,","); + for (const TString& aVal : LargeRJetTruthLabelStrs) + { + if (LargeRJetTruthLabel::stringToEnum(aVal) == LargeRJetTruthLabel::UNKNOWN) + { + // Note: throwing an exception here because we can't return StatusCode::FAILURE or similar and this doesn't inherit from a class with such functionality + // This error message should anyways only occur if the CP group provides a bad config file, so this error will only be printed when we are debugging our inputs and before it gets to users + throw std::runtime_error(Form("ERROR: Unable to convert specified LargeRJetTruthLabel to a recognized enum value, please check the configuration file for mistakes: %s",aVal.Data())); + } + else + LargeRJetTruthLabels.push_back(LargeRJetTruthLabel::stringToEnum(aVal)); + } + LargeRJetTruthLabelsForSFstrs = utils::vectorize<TString>(LargeRJetTruthLabelsForSFstr, ","); + for (const TString& aVal : LargeRJetTruthLabelsForSFstrs) + { + if (CompFlavorLabelVar::stringToEnum(aVal) == CompFlavorLabelVar::UNKNOWN) + { + throw std::runtime_error(Form("ERROR: Unable to convert specified LargeRJetTruthLabelForSF to a recognized enum value, please check the configuration file for mistakes: %s",aVal.Data())); + } + else + LargeRJetTruthLabelsForSF.push_back(CompFlavorLabelVar::stringToEnum(aVal)); + } + RegionForSF = CompTaggerRegionVar::stringToEnum(RegionForSFstr); } diff --git a/Reconstruction/Jet/JetUncertainties/Root/ELogMassEtaUncertaintyComponent.cxx b/Reconstruction/Jet/JetUncertainties/Root/ELogMassEtaUncertaintyComponent.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c2464acb0637cfd0cf6dd1002f10ec7c4a77f1e0 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/Root/ELogMassEtaUncertaintyComponent.cxx @@ -0,0 +1,64 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "JetUncertainties/ELogMassEtaUncertaintyComponent.h" +#include "JetUncertainties/Helpers.h" + +namespace jet +{ + +////////////////////////////////////////////////// +// // +// Constructor/destructor/initialization // +// // +////////////////////////////////////////////////// + +ELogMassEtaUncertaintyComponent::ELogMassEtaUncertaintyComponent(const std::string& name) + : UncertaintyComponent(ComponentHelper(name)) + , m_absEta(false) + , m_massDef(CompMassDef::UNKNOWN) +{ + JESUNC_NO_DEFAULT_CONSTRUCTOR; +} + +ELogMassEtaUncertaintyComponent::ELogMassEtaUncertaintyComponent(const ComponentHelper& component) + : UncertaintyComponent(component) + , m_absEta(CompParametrization::isAbsEta(component.parametrization)) + , m_massDef(component.massDef) +{ + ATH_MSG_DEBUG(Form("Creating ELogMassEtaUncertaintyComponent named %s",m_uncHistName.Data())); +} + +ELogMassEtaUncertaintyComponent::ELogMassEtaUncertaintyComponent(const ELogMassEtaUncertaintyComponent& toCopy) + : UncertaintyComponent(toCopy) + , m_absEta(toCopy.m_absEta) + , m_massDef(toCopy.m_massDef) +{ + ATH_MSG_DEBUG(Form("Creating copy of ELogMassEtaUncertaintyComponent named %s",m_uncHistName.Data())); +} + +ELogMassEtaUncertaintyComponent* ELogMassEtaUncertaintyComponent::clone() const +{ + return new ELogMassEtaUncertaintyComponent(*this); +} + + +////////////////////////////////////////////////// +// // +// Validity and uncertainty retrieval // +// // +////////////////////////////////////////////////// + +bool ELogMassEtaUncertaintyComponent::getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo&) const +{ + return !m_validHist ? true : getValidBool(m_validHist->getValue(jet.e()*m_energyScale,log(getMassOverE(jet,m_massDef)),m_absEta ? fabs(jet.eta()) : jet.eta())); +} + +double ELogMassEtaUncertaintyComponent::getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo&) const +{ + return m_uncHist->getValue(jet.pt()*m_energyScale,log(getMassOverE(jet,m_massDef)),m_absEta ? fabs(jet.eta()) : jet.eta()); +} + +} // end jet namespace + diff --git a/Reconstruction/Jet/JetUncertainties/Root/ELogMassUncertaintyComponent.cxx b/Reconstruction/Jet/JetUncertainties/Root/ELogMassUncertaintyComponent.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8908f04b824d83a502d060cc4b54f26ba80d569b --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/Root/ELogMassUncertaintyComponent.cxx @@ -0,0 +1,61 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "JetUncertainties/ELogMassUncertaintyComponent.h" +#include "JetUncertainties/Helpers.h" + +namespace jet +{ + +////////////////////////////////////////////////// +// // +// Constructor/destructor/initialization // +// // +////////////////////////////////////////////////// + +ELogMassUncertaintyComponent::ELogMassUncertaintyComponent(const std::string& name) + : UncertaintyComponent(ComponentHelper(name)) + , m_massDef(CompMassDef::UNKNOWN) +{ + JESUNC_NO_DEFAULT_CONSTRUCTOR; +} + +ELogMassUncertaintyComponent::ELogMassUncertaintyComponent(const ComponentHelper& component) + : UncertaintyComponent(component) + , m_massDef(component.massDef) +{ + ATH_MSG_DEBUG(Form("Creating ELogMassUncertaintyComponent named %s",m_uncHistName.Data())); +} + +ELogMassUncertaintyComponent::ELogMassUncertaintyComponent(const ELogMassUncertaintyComponent& toCopy) + : UncertaintyComponent(toCopy) + , m_massDef(toCopy.m_massDef) +{ + ATH_MSG_DEBUG(Form("Creating copy of ELogMassUncertaintyComponent named %s",m_uncHistName.Data())); +} + +ELogMassUncertaintyComponent* ELogMassUncertaintyComponent::clone() const +{ + return new ELogMassUncertaintyComponent(*this); +} + + +////////////////////////////////////////////////// +// // +// Validity and uncertainty retrieval // +// // +////////////////////////////////////////////////// + +bool ELogMassUncertaintyComponent::getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo&) const +{ + return !m_validHist ? true : getValidBool(m_validHist->getValue(jet.pt()*m_energyScale,log(getMassOverE(jet,m_massDef)))); +} + +double ELogMassUncertaintyComponent::getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo&) const +{ + return m_uncHist->getValue(jet.pt()*m_energyScale,log(getMassOverE(jet,m_massDef))); +} + +} // end jet namespace + diff --git a/Reconstruction/Jet/JetUncertainties/Root/FFJetSmearingTool.cxx b/Reconstruction/Jet/JetUncertainties/Root/FFJetSmearingTool.cxx new file mode 100644 index 0000000000000000000000000000000000000000..413b08641256612d8eaa8f40b487bd0027839fd3 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/Root/FFJetSmearingTool.cxx @@ -0,0 +1,854 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +/* ***********************************************************************************\ + * * + * Name: FFJetSmearingTool * + * Purpose: Perform a jet mass smearing using Forward Folding * + * This tool allow the user to stimate the JMS & JMR systematics uncertainities * + * * +\*************************************************************************************/ + +/// For information, see the Twiki: +/// https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/FFJetSmearingTool +/// +/// If you find any bug, please, contact <alberto.prades.ibanez@cern.ch> + + +// Local includes +#include "JetUncertainties/FFJetSmearingTool.h" + +// Other includes +#include "ParticleJetTools/LargeRJetLabelEnum.h" + +namespace CP { + +// Constructor +FFJetSmearingTool::FFJetSmearingTool(const std::string name) + : asg::AsgTool(name) + , m_isInit(false) + , m_release("") + , m_truth_jetColl("") + , m_EtaRange(0) + , m_calibArea("CalibArea-08") + , m_histFileName("") + { + declareProperty( "MassDef", m_MassDef_string = "" ); + declareProperty( "ConfigFile", m_configFile = "" );//Path to the config file. By default it points to XXX + declareProperty("Path",m_path); +} + +// Destructor +FFJetSmearingTool::~FFJetSmearingTool() +{ } + + + +// Initialize +StatusCode FFJetSmearingTool::initialize() +{ + + // Ensure it hasn't been initialized already + if (m_isInit) + { + ATH_MSG_FATAL(Form("Blocking re-initialization of tool named %s",AsgTool::name().c_str())); //AsgTool::name() calls the name + return StatusCode::FAILURE; + } + + ATH_MSG_INFO(Form("Preparing to initialize the FFJetSmearingTool named %s",AsgTool::name().c_str())); + + if (AsgTool::name()=="") + { + ATH_MSG_FATAL("No name specified. Aborting."); + return StatusCode::FAILURE; + } + if (m_MassDef_string.empty()) + { + ATH_MSG_FATAL("No kind of jet mass specified. Aborting."); + return StatusCode::FAILURE; + } + + // Make sure we have a valid mass definition + ATH_CHECK(JetTools::stringToEnum(m_MassDef_string, m_MassDef)); //If it fails it means that there is No Systematic Uncertainties derived for to the given mass definition. + //The mass definition should be 'Calo', 'TA' or 'Comb'. Show an error and exits. + + //reading the config file as in JetUncertaintiesTool + TEnv settings; + + const TString configFilePath = jet::utils::findFilePath(m_configFile.c_str(),m_path.c_str(),m_calibArea.c_str()); + + if (settings.ReadFile( configFilePath.Data(),kEnvGlobal)) + { + ATH_MSG_ERROR("Cannot read config file: " << configFilePath.Data()); + return StatusCode::FAILURE; + } + // We can read it - start printing + ATH_MSG_INFO("================================================"); + ATH_MSG_INFO(Form(" Initializing the FFJetSmearingTool named %s",AsgTool::name().c_str())); + ATH_MSG_INFO(" Configuration file: " << m_configFile); + ATH_MSG_INFO(" Location: " << configFilePath.Data()); + + + m_release = settings.GetValue("UncertaintyRelease","UNKNOWN"); + ATH_MSG_INFO(" Uncertainty release: " << m_release.c_str()); + + // Check the jet definition + m_truth_jetColl = settings.GetValue("TruthJetColl",""); + if (m_truth_jetColl.empty()) + { + ATH_MSG_ERROR("Cannot find the truth jet collection to use in config"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO(" Truth Jet Collection: " << m_truth_jetColl); + // Check the name of the truth label accessor for BoostjetTaggers + m_truthlabelaccessor = settings.GetValue("TruthLabelAccessor",""); + if (m_truthlabelaccessor.empty()) + { + ATH_MSG_ERROR("Cannot find the TruthLabelAccessor to use in config"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO(" Truth Label Accessor: " << m_truthlabelaccessor); + //eta range of the tool + m_EtaRange = settings.GetValue("EtaRange",0); + if (m_EtaRange == 0) + { + ATH_MSG_ERROR("Cannot find the EtaRange parameter in the config file"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO(" EtaRange : Abs(eta) < " << m_EtaRange); + //mass range of the tool + m_MaxMass = settings.GetValue("MaxMass",0); + if (m_MaxMass == 0) + { + ATH_MSG_ERROR("Cannot find the MaxMass parameter in the config file"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO(" MaxMass : jet_mass < " << m_MaxMass); + //pt range of the tool + m_MaxPt = settings.GetValue("MaxPt",0); + if (m_MaxPt == 0) + { + ATH_MSG_ERROR("Cannot find the MaxPt parameter in the config file"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO(" MaxPt : jet_pt < " << m_MaxPt); + // Get the file to read uncertainties in from + m_histFileName = settings.GetValue("UncertaintyRootFile",""); + m_HistogramsFilePath = jet::utils::findFilePath(m_histFileName.c_str(),m_path.c_str(),m_calibArea.c_str()); + if (m_histFileName.empty()) + { + ATH_MSG_ERROR("Cannot find uncertainty histogram file in the config file"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO(" UncertaintyFile: " << m_histFileName); + ATH_MSG_INFO(" Location: " << m_HistogramsFilePath); + + + + //Read all the histogram files where the jms jmr variations are saved + ATH_CHECK(readFFJetSmearingToolSimplifiedData(settings));//If fail, it shows an Error message and exits + + // Add the affecting systematics to the global registry + CP::SystematicRegistry& registry = CP::SystematicRegistry::getInstance(); + if(registry.registerSystematics(*this) != CP::SystematicCode::Ok){ + ATH_MSG_ERROR("Unable to register systematics!"); + return StatusCode::FAILURE; + } + + m_isInit = true; + + // ANA_CHECK (applySystematicVariation (CP::SystematicSet())); + + return StatusCode::SUCCESS; +} + + + +//----------------------------------------------------------------------------- +// Declare affecting systematics +//----------------------------------------------------------------------------- +bool FFJetSmearingTool::isAffectedBySystematic +(const CP::SystematicVariation& systematic) const +{ + // Using 'find' is sufficient until this tool supports continuous + // // variations, at which point I'll need to use the 'match' method. + CP::SystematicSet sys = affectingSystematics(); + return sys.find(systematic) != sys.end(); +} +//----------------------------------------------------------------------------- + +CP::SystematicSet FFJetSmearingTool::affectingSystematics() const +{ + CP::SystematicSet result; + result.insert(m_SysList); + + return result; +} +//----------------------------------------------------------------------------- +CP::SystematicSet FFJetSmearingTool::recommendedSystematics() const +{ + return m_SysList; +} + +//----------------------------------------------------------------------------- +// Apply systematic configuration +//----------------------------------------------------------------------------- + +CP::SystematicCode FFJetSmearingTool::applySystematicVariation +(const CP::SystematicSet& systematics) +{ + // First check if we already know this systematic configuration. + // Look for it in our sysData map. + auto iter = m_sysData.find (systematics); + + + // If this is a new input set, we need to filter it. + if(iter == m_sysData.end()){ + + // Filter the input systematics with my affecting systematics. + const CP::SystematicSet affectingSysts = affectingSystematics(); + CP::SystematicSet filteredSysts; + if( CP::SystematicSet:: + filterForAffectingSystematics(systematics, affectingSysts, filteredSysts) != + CP::SystematicCode::Ok ) + { + ATH_MSG_ERROR("Received unsupported systematics: " << systematics.name()); + return CP::SystematicCode::Unsupported; + } + + // At this point, we can do some additional checks for consistency + // with the JMS/JMR functionality. For example, if the tool can only handle + // one type of systematic at a time, we return an error if the filtered + // set has more than one item: + if(filteredSysts.size() > 1){ + ATH_MSG_ERROR("No support for more than one JMS/JMR sys at a time: " << + filteredSysts.name()); + return CP::SystematicCode::Unsupported; + } + + + + // Insert the new systematic data onto our map + SysData myData; + + const CP::SystematicVariation& sys = *filteredSysts.begin(); + + myData.SysParameter = sys.parameter(); //Up (+1) and Down (-1) systematic variation + myData.SysBaseName = sys.basename(); //Name of the systematic variation + + iter = m_sysData.emplace (systematics, myData).first; + } + + // Apply the filtered systematics + m_currentSysData = &iter->second; + + return CP::SystematicCode::Ok; +} + + + +//----------------------------------------------------------------------------- +// Read the external file that conatins the JSS recomendations for FatJets +//----------------------------------------------------------------------------- + +StatusCode FFJetSmearingTool::readFFJetSmearingToolSimplifiedData(TEnv& settings){ + + std::unique_ptr<TFile> data_file ( TFile::Open(m_HistogramsFilePath.c_str())); + if(!data_file || data_file->IsZombie()){ + ATH_MSG_FATAL( "Could not open the first input file: " << m_HistogramsFilePath ); + return StatusCode::FAILURE; + } + + + + + TString CaloResponseMap_path = settings.GetValue("CaloResponseMap",""); + + if(CaloResponseMap_path.IsNull()) + { + ATH_MSG_ERROR("Cannot find the CaloResponseMap in the config file"); + return StatusCode::FAILURE; + } + + m_CALO_ResponseMap = std::make_unique<TH2D>(*dynamic_cast<TH2D*>(data_file->Get( CaloResponseMap_path ))); + m_CALO_ResponseMap->SetDirectory(0); + + + if(m_MassDef==JetTools::FFJetAllowedMassDefEnum::Comb || m_MassDef==JetTools::FFJetAllowedMassDefEnum::TA){ + TString TAResponseMap_path = settings.GetValue("TAResponseMap",""); + + if(TAResponseMap_path.IsNull()) + { + ATH_MSG_ERROR("Cannot find the TAResponseMap in the config file"); + return StatusCode::FAILURE; + } + + m_TA_ResponseMap = std::make_unique<TH2D>(*dynamic_cast<TH2D*>(data_file->Get( TAResponseMap_path ))); + m_TA_ResponseMap->SetDirectory(0);//To keep it open when we close the .root file + } + + + + //JMS systematics + for (size_t iComp = 0; iComp < 999; ++iComp) + { + const TString prefix = Form("JMSComponent.%zu.",iComp); + + std::string Syst_Name = settings.GetValue(prefix+"Name",""); + + if( !Syst_Name.empty()){ + m_SysList.insert( CP::SystematicVariation(Syst_Name, 1) ); + m_SysList.insert( CP::SystematicVariation(Syst_Name, -1) ); + + m_Syst_HistPath_map[Syst_Name] = settings.GetValue(prefix+"Hist",""); + m_Syst_MassDefAffected_map[Syst_Name] = settings.GetValue(prefix+"MassDef",""); + m_Syst_TopologyAffected_map[Syst_Name] = settings.GetValue(prefix+"Topology",""); + m_Syst_Affects_JMSorJMR[Syst_Name] = "JMS"; + + m_Syst_Hist_map[Syst_Name] = std::make_unique<TH2D>(*dynamic_cast<TH2D*>(data_file->Get(m_Syst_HistPath_map[Syst_Name].c_str()))); + m_Syst_Hist_map[Syst_Name]->SetDirectory(0); + + } + } + //JMR Systematics + for (size_t iComp = 0; iComp < 999; ++iComp) + { + const TString prefix = Form("JMRComponent.%zu.",iComp); + + std::string Syst_Name = settings.GetValue(prefix+"Name",""); + + + if( !Syst_Name.empty()){ + m_SysList.insert( CP::SystematicVariation(Syst_Name, 1) ); + m_SysList.insert( CP::SystematicVariation(Syst_Name, -1) ); + + m_Syst_HistPath_map[Syst_Name] = settings.GetValue(prefix+"Hist",""); + m_Syst_MassDefAffected_map[Syst_Name] = settings.GetValue(prefix+"MassDef",""); + m_Syst_TopologyAffected_map[Syst_Name] = settings.GetValue(prefix+"Topology",""); + m_Syst_Affects_JMSorJMR[Syst_Name] = "JMR"; + + m_Syst_Hist_map[Syst_Name] = std::make_unique<TH2D>(*dynamic_cast<TH2D*>(data_file->Get(m_Syst_HistPath_map[Syst_Name].c_str()))); + m_Syst_Hist_map[Syst_Name]->SetDirectory(0); + + } + } + + data_file->Close(); + + + //Read the Calo and TA mass weight histograms from the same file that JetUncertainties uses + + + TString Calo_TA_weight_file_name = settings.GetValue("JetUncertainties_UncertaintyRootFile",""); + const TString Calo_TA_weight_file_path = jet::utils::findFilePath(Calo_TA_weight_file_name.Data(),m_path.c_str(),m_calibArea.c_str()); + + if (Calo_TA_weight_file_path.IsNull()) + { + ATH_MSG_ERROR("Cannot find the file with the Calo and TA weights"); + return StatusCode::FAILURE; + } + + TString Calo_weight_hist_name = settings.GetValue("CombMassWeightCaloHist",""); + if (Calo_weight_hist_name.IsNull()) + { + ATH_MSG_ERROR("Cannot find the histogram name that contains the Calo weights in the config file"); + return StatusCode::FAILURE; + } + + TString TA_weight_hist_name = settings.GetValue("CombMassWeightTAHist",""); + if (TA_weight_hist_name.IsNull()) + { + ATH_MSG_ERROR("Cannot find the histogram name that contains the TA weights in the config file"); + return StatusCode::FAILURE; + } + + ATH_MSG_INFO(Form(" Calo weights hist: \"%s\"",Calo_weight_hist_name.Data())); + ATH_MSG_INFO(Form(" TA weights hist: \"%s\"",TA_weight_hist_name.Data())); + ATH_MSG_INFO(Form(" Location: %s",Calo_TA_weight_file_path.Data())); + + + std::unique_ptr<TFile> Calo_TA_weight_file ( TFile::Open(Calo_TA_weight_file_path)); + if(!Calo_TA_weight_file || Calo_TA_weight_file->IsZombie()){ + ATH_MSG_FATAL( "Could not open the first input file: " << Calo_TA_weight_file_path ); + return StatusCode::FAILURE; + } + + m_caloMassWeight = std::make_unique<TH3F>(*dynamic_cast<TH3F*>(Calo_TA_weight_file->Get(Calo_weight_hist_name))); + m_TAMassWeight = std::make_unique<TH3F>(*dynamic_cast<TH3F*>(Calo_TA_weight_file->Get(TA_weight_hist_name))); + + m_caloMassWeight->SetDirectory(0); + m_TAMassWeight->SetDirectory(0);//To keep it open when we close the .root file + + + Calo_TA_weight_file->Close(); + + return StatusCode::SUCCESS; +} + + + + + +//----------------------------------------------------------------------------- +// The function "getMatchedTruthJet" finds the truth jet that match with the given jet_reco and it save it in the given jet_truth_matched jet. +//----------------------------------------------------------------------------- + +StatusCode FFJetSmearingTool::getMatchedTruthJet(xAOD::Jet& jet_reco, xAOD::Jet& jet_truth_matched) const +{ + + // Get the truth jets of the event + const xAOD::JetContainer* jets_truth = nullptr; + + ATH_CHECK(evtStore()->retrieve( jets_truth, m_truth_jetColl));//If fail, it means that we are "Unable to retrieve jetColl Info". It shows an Error message and exits + + double dRmax_truthJet = 0.75;// matching condition + double dRmin=9999; //we will take the closest jet reco-truth + + //Loop over the truth jets in the event to match + const xAOD::Jet* close_jet = nullptr; + for (const auto& jet_truth : *jets_truth) { + float dR_Test = jet_reco.p4().DeltaR(jet_truth->p4()); + if ( dR_Test < dRmax_truthJet){ + if(dR_Test < dRmin){ + close_jet = jet_truth; + dRmin = dR_Test; + } + } + } + if(dRmin > 999){ return StatusCode::FAILURE;} + + jet_truth_matched.setJetP4(close_jet->jetP4()); + return StatusCode::SUCCESS; +} + + +//----------------------------------------------------------------------------- +// The function "getJetTopology" gets the topology of the given jet. "QCD" jets have a extra source of uncertainties called "MODELLINGUNCERTAINTIESQCDJETS". +//----------------------------------------------------------------------------- + +StatusCode FFJetSmearingTool::getJetTopology( xAOD::Jet& jet_reco, std::string& jetTopology) const +{ + + const SG::AuxElement::ConstAccessor<int> accTruthLabel(m_truthlabelaccessor); + if (!accTruthLabel.isAvailable(jet_reco) ) + { + ATH_MSG_ERROR("Unable to retrieve the FatjetTruthLabel from the jet. Please call the BoostedJetTaggers decorateTruthLabel() function before calling this function."); + return StatusCode::FAILURE; + } + + +LargeRJetTruthLabel::TypeEnum jetTruthLabel = LargeRJetTruthLabel::intToEnum(accTruthLabel(jet_reco)); + + if(jetTruthLabel == LargeRJetTruthLabel::tqqb || jetTruthLabel == LargeRJetTruthLabel::other_From_t) + { + jetTopology="Top"; + } + + else if(jetTruthLabel == LargeRJetTruthLabel::Wqq || jetTruthLabel == LargeRJetTruthLabel::Zqq || jetTruthLabel == LargeRJetTruthLabel::Wqq_From_t || jetTruthLabel == LargeRJetTruthLabel::other_From_V) + { + jetTopology="V"; + } + + else if(jetTruthLabel == LargeRJetTruthLabel::qcd) + { + jetTopology="QCD"; + } + + else if(jetTruthLabel == LargeRJetTruthLabel::Hbb || jetTruthLabel == LargeRJetTruthLabel::other_From_H) + { + jetTopology="H"; + } + + else if(jetTruthLabel == LargeRJetTruthLabel::notruth) + { + jetTopology="no_match"; + ATH_MSG_DEBUG("No truth jet match with this reco jet. The jet will not be smeared."); + } + + else jetTopology="QCD"; //We should never arrive here + + ATH_MSG_VERBOSE("The topology of this jet correspond to a " << jetTopology << " large-R jet"); + + return StatusCode::SUCCESS; +} + + + + +//----------------------------------------------------------------------------- +// The function "getJMSJMR" read the JMS and JMR uncertainties associated with the systematic +//----------------------------------------------------------------------------- + +StatusCode FFJetSmearingTool::getJMSJMR( xAOD::Jet& jet_reco, double jet_mass_value, JetTools::FFJetAllowedMassDefEnum MassDef_of_syst, std::string jetTopology, double& JMS_err, double& JMR_err) const{ + + //JMS/JMR systematic variations + JMS_err=0; + JMR_err=0; + + if(m_Syst_MassDefAffected_map.at(m_currentSysData->SysBaseName) == JetTools::enumToString(MassDef_of_syst)){ + ATH_MSG_VERBOSE("This uncertainty affects to the " << JetTools::enumToString(MassDef_of_syst) << " mass"); + } //Only apply the systematic to the proper mass definition + else{return StatusCode::SUCCESS;} + + + + if(m_Syst_TopologyAffected_map.at(m_currentSysData->SysBaseName) != "All" && m_Syst_TopologyAffected_map.at(m_currentSysData->SysBaseName) != jetTopology){ + ATH_MSG_VERBOSE("The systematic do not affects to this jet topology"); + return StatusCode::SUCCESS; + } + + + float jet_mass = jet_mass_value*m_MeVtoGeV;//jet_reco->m()*m_MeVtoGeV; The TA mass can not be extracted this way + float jet_pT = jet_reco.pt()*m_MeVtoGeV; + + + if(m_Syst_Affects_JMSorJMR.at(m_currentSysData->SysBaseName) == "JMS"){ + + JMS_err=m_Syst_Hist_map.at(m_currentSysData->SysBaseName)->GetBinContent(m_Syst_Hist_map.at(m_currentSysData->SysBaseName)->GetXaxis()->FindBin(jet_pT),m_Syst_Hist_map.at(m_currentSysData->SysBaseName)->GetYaxis()->FindBin(jet_mass)) * m_currentSysData->SysParameter; + + JMR_err= 0; + } + + if(m_Syst_Affects_JMSorJMR.at(m_currentSysData->SysBaseName) == "JMR"){ + + JMS_err=0; + JMR_err= m_Syst_Hist_map.at(m_currentSysData->SysBaseName)->GetBinContent(m_Syst_Hist_map.at(m_currentSysData->SysBaseName)->GetXaxis()->FindBin(jet_pT),m_Syst_Hist_map.at(m_currentSysData->SysBaseName)->GetYaxis()->FindBin(jet_mass)) * m_currentSysData->SysParameter; + } + + + + + + ATH_MSG_DEBUG("Systematic applied: " << m_currentSysData->SysBaseName); + + ATH_MSG_VERBOSE("JMS_err: " << JMS_err); + ATH_MSG_VERBOSE("JMR_err: " << JMR_err); + + return StatusCode::SUCCESS; +} + + + +//----------------------------------------------------------------------------- +// Once the tool is initialized. The user can call the function "SmearJetMass" to perform the jet smearing using FF (for the current systematic in his loop) +//----------------------------------------------------------------------------- + +CP::CorrectionCode FFJetSmearingTool::applyCorrection( xAOD::Jet& jet_reco) const{ + + ATH_MSG_VERBOSE("//---------------------------------------------------------------//"); + ATH_MSG_VERBOSE("Reco Jet to Smear: pt = " << jet_reco.pt() << ", mass = " << jet_reco.m() << ", eta = " << jet_reco.eta()); + + if(std::abs(jet_reco.eta()) > m_EtaRange){//JetCalibTools do not properly for jets with |eta|>2 + ATH_MSG_DEBUG("This jet exceeds the eta range that the tool allows (|eta|<" << m_EtaRange << ")"); + return CP::CorrectionCode::OutOfValidityRange; + } + if(jet_reco.m() > m_MaxMass){ + ATH_MSG_DEBUG("This jet exceeds the mass range that the tool allows jet_mass <" << m_MaxMass << " MeV)"); + return CP::CorrectionCode::OutOfValidityRange; + } + if(jet_reco.pt() > m_MaxPt){ + ATH_MSG_DEBUG("This jet exceeds the maximum pt that the tool allows jet_pt <" << m_MaxPt << " MeV)"); + return CP::CorrectionCode::OutOfValidityRange; + } + + //Find matched truth jet + xAOD::Jet jet_truth_matched; + jet_truth_matched.makePrivateStore(); + + if(!(getMatchedTruthJet(jet_reco, jet_truth_matched).isSuccess())){ + ATH_MSG_VERBOSE("No truth jet match with this reco jet. The jet will not be smeared."); + return CP::CorrectionCode::OutOfValidityRange; + } + + ATH_MSG_VERBOSE("Matched truth Jet: pt = " << jet_truth_matched.pt() << ", mass = " << jet_truth_matched.m() << ", eta = " << jet_truth_matched.eta()); + + //Get the jet topology + std::string jetTopology; + + if(!(getJetTopology( jet_reco, jetTopology)).isSuccess()){ + ATH_MSG_ERROR("Imposible to obtain the jetTopology"); + return CP::CorrectionCode::Error; + } + if(jetTopology == "no_match"){ + return CP::CorrectionCode::OutOfValidityRange; + } + + + //The TA mass is saved in an attribute so you can not access to it using ->m(). (if calibrated as Calo mass and not as Combined Mass), The Calo mass is not set as an attribute so you can not access it using ->getAttribute . + + double jet_mass_CALO = 0; + double jet_mass_TA = 0; + double calo_mass_weight=1; // m_comb = Weight*m_Calo + (1-Weight)*m_TA + + float JetTrackAssistedMassCalibrated_from_JetCalibTools; + + if(m_MassDef==JetTools::FFJetAllowedMassDefEnum::Comb){ + + xAOD::JetFourMom_t jet_reco_CALO; + xAOD::JetFourMom_t jet_reco_TA; + xAOD::JetFourMom_t jet_reco_Comb; + + jet_reco.getAttribute<xAOD::JetFourMom_t>("JetJMSScaleMomentumCalo",jet_reco_CALO); + jet_reco.getAttribute<xAOD::JetFourMom_t>("JetJMSScaleMomentumTA",jet_reco_TA); + jet_reco.getAttribute<xAOD::JetFourMom_t>("JetJMSScaleMomentumCombQCD",jet_reco_Comb); + + ATH_MSG_VERBOSE("CALO jet mass " << jet_reco_CALO.mass()); + ATH_MSG_VERBOSE("TA jet mass " << jet_reco_TA.mass() ); + ATH_MSG_VERBOSE("Comb jet mass " << jet_reco_Comb.mass() ); + + jet_mass_CALO = jet_reco_CALO.mass(); + jet_mass_TA = jet_reco_TA.mass(); + + jet_reco.getAttribute<float>("JetTrackAssistedMassCalibrated", JetTrackAssistedMassCalibrated_from_JetCalibTools); + } + if(m_MassDef==JetTools::FFJetAllowedMassDefEnum::Calo){ + jet_mass_CALO = jet_reco.m(); + calo_mass_weight = 1; + } + else if(m_MassDef==JetTools::FFJetAllowedMassDefEnum::TA){ + jet_mass_TA = jet_reco.m(); + calo_mass_weight = 0; + } + + + + + //Obtain the average mass response of the jet. The response will depend in the chosed topology (top,W or QCD) and also in the mass definition (CALO, TA, Combined). By default the map used correspond to QCD jets + + double avg_response_CALO=1; + double avg_response_TA=1; + + if(m_MassDef==JetTools::FFJetAllowedMassDefEnum::Comb || m_MassDef==JetTools::FFJetAllowedMassDefEnum::Calo){ + + if(m_CALO_ResponseMap->GetBinContent(m_CALO_ResponseMap->GetXaxis()->FindBin(jet_reco.pt()*m_MeVtoGeV),m_CALO_ResponseMap->GetYaxis()->FindBin(jet_truth_matched.m()*m_MeVtoGeV)) == 0){//If we look outside the Th2 histogram, we would obtain a 0 so we apply the nominal response (1) + avg_response_CALO=1; + } + else{ + avg_response_CALO = m_CALO_ResponseMap->GetBinContent(m_CALO_ResponseMap->GetXaxis()->FindBin(jet_reco.pt()*m_MeVtoGeV),m_CALO_ResponseMap->GetYaxis()->FindBin(jet_truth_matched.m()*m_MeVtoGeV)); + } + } + + if(m_MassDef==JetTools::FFJetAllowedMassDefEnum::Comb || m_MassDef==JetTools::FFJetAllowedMassDefEnum::TA){ + + if(m_TA_ResponseMap->GetBinContent(m_TA_ResponseMap->GetXaxis()->FindBin(jet_reco.pt()*m_MeVtoGeV),m_TA_ResponseMap->GetYaxis()->FindBin(jet_truth_matched.m()*m_MeVtoGeV))==0){ + + avg_response_TA=1; + } + else{ + avg_response_TA = m_TA_ResponseMap->GetBinContent(m_TA_ResponseMap->GetXaxis()->FindBin(jet_reco.pt()*m_MeVtoGeV),m_TA_ResponseMap->GetYaxis()->FindBin(jet_truth_matched.m()*m_MeVtoGeV)); + } + } + + + //Obtain the jet mass scale (JMS) and the jet mass resolution (JMR) nominal values and variation that correspond to the jet_reco + + double JMS (1), JMS_err(0), JMR(1), JMR_err(0); + double scale; + double resolution; + + double smeared_CALO_mass = jet_mass_CALO; + double smeared_TA_mass = jet_mass_TA; + + bool is_CALO_mass_smeared = false; + bool is_TA_mass_smeared = false; + + if(m_MassDef==JetTools::FFJetAllowedMassDefEnum::Comb || m_MassDef==JetTools::FFJetAllowedMassDefEnum::Calo){ + + if(!(getJMSJMR( jet_reco, jet_mass_CALO, JetTools::FFJetAllowedMassDefEnum::Calo,jetTopology, JMS_err, JMR_err)).isSuccess()){ + return CP::CorrectionCode::Ok; + } + + scale = JMS + JMS_err; + resolution = JMR + JMR_err; + + if(TMath::Abs(scale-1) > 0.0001 || TMath::Abs(resolution-1) > 0.0001){ + is_CALO_mass_smeared = true; + + ATH_MSG_VERBOSE("Forward Folding CALO procedure will use scale=" << scale << ", resolution=" << resolution << " and average respose=" << avg_response_CALO); + + //FF procedure + smeared_CALO_mass = jet_mass_CALO * scale + (jet_mass_CALO - avg_response_CALO*jet_truth_matched.m())*(resolution-scale);//FF formula + } + + } + + if(m_MassDef==JetTools::FFJetAllowedMassDefEnum::Comb || m_MassDef==JetTools::FFJetAllowedMassDefEnum::TA){ + if(!(getJMSJMR( jet_reco, jet_mass_TA, JetTools::FFJetAllowedMassDefEnum::TA,jetTopology, JMS_err, JMR_err))){ + return CP::CorrectionCode::Ok; + } + + scale = JMS + JMS_err; + resolution = JMR + JMR_err; + + if(TMath::Abs(scale-1) > 0.0001 || TMath::Abs(resolution-1) > 0.0001){ + + is_TA_mass_smeared = true; + + ATH_MSG_VERBOSE("Forward Folding TA procedure will use scale=" << scale << ", resolution=" << resolution << " and average respose=" << avg_response_TA); + + //FF procedure + smeared_TA_mass = jet_mass_TA * scale + (jet_mass_TA - avg_response_TA*jet_truth_matched.m())*(resolution-scale);//FF formula + } + + } + + if(is_CALO_mass_smeared==false && is_TA_mass_smeared == false){//We only smear the jet if we have to. If not, avoid doing extra calculations + + ATH_MSG_VERBOSE("This jet is not affected by the systematic. The jet won't be modified"); + ATH_MSG_VERBOSE("//---------------------------------------------------------------//"); + + return CP::CorrectionCode::Ok; + } + + + //Recalculate the weights after the smearing + + if(m_MassDef==JetTools::FFJetAllowedMassDefEnum::Comb && JetTrackAssistedMassCalibrated_from_JetCalibTools != 0 && jet_mass_CALO != 0){ + //we check that JetTrackAssistedMassCalibrated_from_JetCalibTools != 0 instead of jet_mass_TA != 0 becuase + //there is a problem in the conversion between the mass itself and the four-vector representation (due to a + //limitation of floating). This makes the value of jet_mass_TA!=0 in situations where it should be 0. + //In order to work arround it we check JetTrackAssistedMassCalibrated_from_JetCalibTools != 0 insead. + double caloRes; + double TARes; + + xAOD::JetFourMom_t jet_reco_CALO; + xAOD::JetFourMom_t jet_reco_TA; + + jet_reco.getAttribute<xAOD::JetFourMom_t>("JetJMSScaleMomentumCalo",jet_reco_CALO); + jet_reco.getAttribute<xAOD::JetFourMom_t>("JetJMSScaleMomentumTA",jet_reco_TA); + + + xAOD::JetFourMom_t p4_aux; + + //The smearing do not change the pt but it changes the mass (so the energy too) so, itf we want to perform the smearing properly, we have to change + //the Calo and TA foru momenta before looking at the weights map + p4_aux = xAOD::JetFourMom_t(jet_reco_CALO.pt(),jet_reco_CALO.eta(),jet_reco_CALO.phi(),smeared_CALO_mass);//The smearing do not change the pt but it changes the Energy + jet_reco_CALO = p4_aux; + + p4_aux = xAOD::JetFourMom_t(jet_reco_TA.pt(),jet_reco_TA.eta(),jet_reco_TA.phi(),smeared_TA_mass); + jet_reco_TA = p4_aux; + + caloRes=FFJetSmearingTool::Read3DHistogram(m_caloMassWeight.get() ,jet_reco_CALO.e()*m_MeVtoGeV,TMath::Log(jet_reco_CALO.M()/jet_reco_CALO.e()),std::abs(jet_reco_CALO.eta())); + + TARes=FFJetSmearingTool::Read3DHistogram(m_TAMassWeight.get() ,jet_reco_TA.e()*m_MeVtoGeV,TMath::Log(jet_reco_TA.M()/jet_reco_TA.e()),std::abs(jet_reco_TA.eta())); + + //The histograms with the weights that we are reading was deffined with the code "e_LOGmOe_eta" what means that each axis correspond to: + //-X: Jet Energy + //-Y: Log(Jet_Energy/Jet_mass) + //-Z:Eta + //Domain is [200-6000],[-6,0],[0,2] but, the ReadHistogram function put the value of the extream of the histogram to the values outside the domain. + //We have to use a custom "My_Interpolate" because the Z axis has just one bin (and this makes the Root Interpolate function fail) + + double caloFactor; + double TAFactor; + + if (caloRes == 0 ) { caloFactor = 0; TAFactor = 1;} + else if( TARes == 0) { caloFactor = 1; TAFactor = 0;} + else{ + caloFactor = 1./(caloRes*caloRes); + TAFactor = 1./(TARes*TARes); + } + + + calo_mass_weight = caloFactor /(caloFactor + TAFactor); + + ATH_MSG_VERBOSE(" Map Calo weight = " << calo_mass_weight ); + ATH_MSG_VERBOSE(" Map TA weight = " << 1 - calo_mass_weight ); + } + else if( JetTrackAssistedMassCalibrated_from_JetCalibTools == 0){calo_mass_weight = 1;} + else if(jet_mass_CALO == 0){calo_mass_weight = 0;} + + double smeared_mass = calo_mass_weight*smeared_CALO_mass + (1 - calo_mass_weight)*smeared_TA_mass; + + ATH_MSG_VERBOSE("Smeared CALO mass " << smeared_CALO_mass); + ATH_MSG_VERBOSE("Smeared TA mass " << smeared_TA_mass); + + xAOD::JetFourMom_t p4 = jet_reco.jetP4(); + + + p4 = xAOD::JetFourMom_t(jet_reco.pt(),jet_reco.eta(),jet_reco.phi(),smeared_mass); + jet_reco.setJetP4(p4); + + + ATH_MSG_VERBOSE("Smeared Reco Jet: pt = " << jet_reco.pt() << ", mass = " << jet_reco.m() << ", eta = " << jet_reco.eta()); + + + + + ATH_MSG_VERBOSE("//---------------------------------------------------------------//"); + + return CP::CorrectionCode::Ok; +} + +//To apply the correction into a copied jet +CP::CorrectionCode FFJetSmearingTool::correctedCopy(const xAOD::Jet& input, xAOD::Jet*& output) const +{ + + xAOD::Jet* copy = new xAOD::Jet(input); + + // Call the implemented function + if (applyCorrection(*copy) == CP::CorrectionCode::Error) + { + delete copy; + return CP::CorrectionCode::Error; + } + output = copy; + return CP::CorrectionCode::Ok; +} + +//To apply the correction into all the jets inside a jet containter +CP::CorrectionCode FFJetSmearingTool::applyContainerCorrection(xAOD::JetContainer& inputs) const +{ + CP::CorrectionCode result = CP::CorrectionCode::Ok; + + // Loop over the container + for (size_t iJet = 0; iJet < inputs.size(); ++iJet) + { + result = applyCorrection(*inputs.at(iJet)); + if (result == CP::CorrectionCode::Error) + break; + } + return result; +} + + + + + +//Functions from JetUncertainties. We copy them in order to read the map exactly as it is done in JetUncertainties and get EXACTLY the same result + +double FFJetSmearingTool::Read3DHistogram(const TH3* histo, double x, double y, double z) const +{ + + double aux_x = x; + double aux_y = y; + double aux_z = z; + + + // Asymptotic values + //If the value is outside the histogram region, we take the closest value to that one + + double xMax = histo->GetXaxis()->GetBinLowEdge(histo->GetNbinsX()+1); + double xMin = histo->GetXaxis()->GetBinLowEdge(1); + double yMax = histo->GetYaxis()->GetBinLowEdge(histo->GetNbinsY()+1); + double yMin = histo->GetYaxis()->GetBinLowEdge(1); + double zMax = histo->GetZaxis()->GetBinLowEdge(histo->GetNbinsZ()+1); + double zMin = histo->GetZaxis()->GetBinLowEdge(1); + + if(x >= xMax) aux_x = xMax-1e-6 ; //so it fits the up-most x-bin + if(x <= xMin) aux_x = xMin+1e-6 ; //so it fits the low-most x-bin + if ( std::isnan(y)) return 0; // no weight if the input is NaN, can happen for log(X) + if(y >= yMax) aux_y = yMax-1e-6 ; //so it fits the up-most y-bin + if(y <= yMin) aux_y = yMin+1e-6 ; //so it fits the low-most y-bin + if(z >= zMax) aux_z = zMax-1e-6 ; //so it fits the up-most z-bin + if(z <= zMin) aux_z = zMin+1e-6 ; //so it fits the low-most z-bin + + //Use the interpolate function from JetHelpers.cxx + double weight = JetHelpers::Interpolate(histo, aux_x, aux_y, aux_z); + + + return weight; +} + +} // namespace CP diff --git a/Reconstruction/Jet/JetUncertainties/Root/FlavourUncertaintyComponent.cxx b/Reconstruction/Jet/JetUncertainties/Root/FlavourUncertaintyComponent.cxx index af7e98c04f4e082f4fb3f5c4290af097b2e79457..5dfaf108876ea11ef268d0f40b1d0f4ce919d78d 100644 --- a/Reconstruction/Jet/JetUncertainties/Root/FlavourUncertaintyComponent.cxx +++ b/Reconstruction/Jet/JetUncertainties/Root/FlavourUncertaintyComponent.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "JetUncertainties/FlavourUncertaintyComponent.h" @@ -23,8 +23,12 @@ FlavourUncertaintyComponent::FlavourUncertaintyComponent(const std::string& name , m_flavourType(FlavourComp::UNKNOWN) , m_jetType("") , m_analysisFileName("") + , m_analysisHistPattern("") + , m_defAnaFileName("") , m_absEta(false) , m_secondUncName("") + , m_largeRJetTruthLabelName("") + , m_largeRJetTruthLabels() , m_secondUncHist(NULL) , m_respType(FlavourResp_UNKNOWN) , m_secondRespType(FlavourResp_UNKNOWN) @@ -39,15 +43,23 @@ FlavourUncertaintyComponent::FlavourUncertaintyComponent(const std::string& name FlavourUncertaintyComponent::FlavourUncertaintyComponent( const ComponentHelper& component, const TString jetType, const TString analysisRootFileName, - const TString path + const TString defaultAnalysisRootFileName, + const TString path, + const TString calibArea, + const TString analysisHistPattern ) : UncertaintyComponent(component,component.flavourType == FlavourComp::Composition ? 2 : 1) , m_flavourType(component.flavourType) , m_jetType(jetType) , m_analysisFileName(analysisRootFileName) + , m_analysisHistPattern(analysisHistPattern) + , m_defAnaFileName(defaultAnalysisRootFileName) , m_path(path) + , m_calibArea(calibArea) , m_absEta(CompParametrization::isAbsEta(component.parametrization)) , m_secondUncName(component.uncNames.size()>1 ? component.uncNames.at(1) : "") + , m_largeRJetTruthLabelName(component.LargeRJetTruthLabelName) + , m_largeRJetTruthLabels(component.LargeRJetTruthLabels) , m_secondUncHist(NULL) , m_respType(FlavourResp_UNKNOWN) , m_secondRespType(FlavourResp_UNKNOWN) @@ -68,9 +80,14 @@ FlavourUncertaintyComponent::FlavourUncertaintyComponent(const FlavourUncertaint , m_flavourType(toCopy.m_flavourType) , m_jetType(toCopy.m_jetType) , m_analysisFileName(toCopy.m_analysisFileName) + , m_analysisHistPattern(toCopy.m_analysisHistPattern) + , m_defAnaFileName(toCopy.m_defAnaFileName) , m_path(toCopy.m_path) + , m_calibArea(toCopy.m_calibArea) , m_absEta(toCopy.m_absEta) , m_secondUncName(toCopy.m_secondUncName) + , m_largeRJetTruthLabelName(toCopy.m_largeRJetTruthLabelName) + , m_largeRJetTruthLabels(toCopy.m_largeRJetTruthLabels) , m_secondUncHist(NULL) , m_respType(toCopy.m_respType) , m_secondRespType(toCopy.m_secondRespType) @@ -111,6 +128,8 @@ FlavourUncertaintyComponent::~FlavourUncertaintyComponent() m_gluonFractionErrorHists.clear(); } + + StatusCode FlavourUncertaintyComponent::initialize(TFile* histFile) { // Call the base class first @@ -118,10 +137,13 @@ StatusCode FlavourUncertaintyComponent::initialize(TFile* histFile) return StatusCode::FAILURE; // Ensure that the number of histograms matches what is expected for Flavour components - if (m_flavourType == FlavourComp::Response && m_secondUncName != "") + if (m_flavourType == FlavourComp::Response) { - ATH_MSG_ERROR("Expected one histogram for FlavourResponse: " << getName().Data()); - return StatusCode::FAILURE; + if (m_secondUncName != "") + { + ATH_MSG_ERROR("Expected one histogram for FlavourResponse: " << getName().Data()); + return StatusCode::FAILURE; + } } else if (m_flavourType == FlavourComp::Composition && m_secondUncName == "") { @@ -171,7 +193,7 @@ StatusCode FlavourUncertaintyComponent::initialize(TFile* histFile) // Now read the analysis input histograms if this is not a bJES component if (m_flavourType != FlavourComp::bJES) { - TFile* analysisFile = utils::readRootFile(m_analysisFileName,m_path); + TFile* analysisFile = utils::readRootFile(m_analysisFileName,m_path,m_calibArea); if (!analysisFile || analysisFile->IsZombie()) { ATH_MSG_ERROR("Cannot open analysis histogram file: " << m_analysisFileName.Data()); @@ -183,19 +205,8 @@ StatusCode FlavourUncertaintyComponent::initialize(TFile* histFile) // Store all of the key names for now, retrieval will happen later std::vector<TString> gluonFractionKeys; std::vector<TString> gluonFractionErrorKeys; - TList* keys = analysisFile->GetListOfKeys(); - TIter nextkey(keys); - while (TKey* key = dynamic_cast<TKey*>(nextkey())) - { - const TString keyName = key->GetName(); - if (keyName.Contains(m_jetType) && !keyName.Contains("valid")) - { - if (keyName.Contains("gluonFractionError")) - gluonFractionErrorKeys.push_back(keyName); - else if (keyName.Contains("gluonFraction")) - gluonFractionKeys.push_back(keyName); - } - } + getGluonKeys(analysisFile,gluonFractionKeys,gluonFractionErrorKeys); + // Ensure we found histograms... if (!gluonFractionKeys.size() || !gluonFractionErrorKeys.size()) @@ -232,7 +243,7 @@ StatusCode FlavourUncertaintyComponent::initialize(TFile* histFile) else { // Fill the actual vectors now, in proper order - for (int nJets = 0; nJets < nJetsMax; ++nJets) + for (int nJets = 0; nJets <= nJetsMax; ++nJets) { m_gluonFractionHists.push_back(NULL); m_gluonFractionErrorHists.push_back(NULL); @@ -259,17 +270,59 @@ StatusCode FlavourUncertaintyComponent::initialize(TFile* histFile) } } - // Initialize the histograms + // Initialize the non-NULL histograms for (size_t iHist = 0; iHist < m_gluonFractionHists.size(); ++iHist) { - if (m_gluonFractionHists.at(iHist)->initialize(analysisFile).isFailure()) + if (m_gluonFractionHists.at(iHist) && m_gluonFractionHists.at(iHist)->initialize(analysisFile).isFailure()) return StatusCode::FAILURE; - if (m_gluonFractionErrorHists.at(iHist)->initialize(analysisFile).isFailure()) + if (m_gluonFractionErrorHists.at(iHist) && m_gluonFractionErrorHists.at(iHist)->initialize(analysisFile).isFailure()) return StatusCode::FAILURE; } // We're finally done reading that file... analysisFile->Close(); + + + // If nJets treatment is specified, and a default analysis file is specified, use this to fill the zero-bin + // The zero-bin is used whenever a multiplicity that is not explicitly specified is requested + if (m_defAnaFileName != "" && m_gluonFractionHists.size() > 1 && m_gluonFractionHists.at(0) == NULL) + { + // Open the default file + TFile* defAnaFile = utils::readRootFile(m_defAnaFileName,m_path,m_calibArea); + if (!defAnaFile || defAnaFile->IsZombie()) + { + ATH_MSG_ERROR("Cannot open default analysis histogram file: " << m_defAnaFileName.Data()); + return StatusCode::FAILURE; + } + + // Retrieve the gluon fraction(s) and gluon fraction uncertainty(ies) + // May be a single histogram (default) or specified by nJet bins + // Store all of the key names for now, retrieval will happen later + std::vector<TString> gluonFractionDefaultKeys; + std::vector<TString> gluonFractionErrorDefaultKeys; + getGluonKeys(defAnaFile,gluonFractionDefaultKeys,gluonFractionErrorDefaultKeys); + + // Ensure that there is exactly one histogram (not another nJets file, not missing) + if (gluonFractionDefaultKeys.size() != 1 || gluonFractionErrorDefaultKeys.size() != 1) + { + ATH_MSG_ERROR(Form("When using the default file to fill unspecified nJets histograms, exactly one gluon fraction and one gluon fraction uncertainty histogram are required. Instead, we found %zu and %zu respectively in the file %s",gluonFractionDefaultKeys.size(),gluonFractionErrorDefaultKeys.size(),m_defAnaFileName.Data())); + return StatusCode::FAILURE; + } + + // Fill the empty zero-bin histograms + m_gluonFractionHists.at(0) = new UncertaintyHistogram(gluonFractionDefaultKeys.at(0),m_interpolate); + m_gluonFractionErrorHists.at(0) = new UncertaintyHistogram(gluonFractionErrorDefaultKeys.at(0),m_interpolate); + + // Now initialize them + if (m_gluonFractionHists.at(0)->initialize(defAnaFile).isFailure()) + return StatusCode::FAILURE; + if (m_gluonFractionErrorHists.at(0)->initialize(defAnaFile).isFailure()) + return StatusCode::FAILURE; + + // We're done reading that file now too + defAnaFile->Close(); + } + } return StatusCode::SUCCESS; @@ -306,6 +359,42 @@ bool FlavourUncertaintyComponent::getValidityImpl(const xAOD::Jet& jet, const xA double FlavourUncertaintyComponent::getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const { + // First, check if we even want to apply the uncertainty (large-R specific break-out) + // Check if we are supposed to only use given truth labels + static const SG::AuxElement::ConstAccessor<int> accLargeRJetTruthLabel(m_largeRJetTruthLabelName); + if (m_largeRJetTruthLabels.size() != 0) + { + // If we are asking to check truth labels, then retrieve the truth jet label from the jet + if (!accLargeRJetTruthLabel.isAvailable(jet)) + { + // Unable to retrieve truth label, but we were told to look for it, error + ATH_MSG_ERROR("Unable to retrieve LargeRJetTruthLabel: " + m_largeRJetTruthLabelName + " from the jet. Please use JetTruthLabeling before calling this function."); + return JESUNC_ERROR_CODE; + } + // Ok, the label exists, now check what it is + const LargeRJetTruthLabel::TypeEnum largeRJetTruthLabel = LargeRJetTruthLabel::intToEnum(accLargeRJetTruthLabel(jet)); + if (largeRJetTruthLabel == LargeRJetTruthLabel::UNKNOWN) + { + // This is an error - the label exists but it is unrecognized + ATH_MSG_ERROR("UNKNOWN LargeRJetTruthLabel on the jet. Please use JetTruthLabeling before calling this function or check the jet for irregularities."); + return JESUNC_ERROR_CODE; + } + // Not unknown, now check if it is one of the labels we want to apply this uncertainty for + bool relevantLabel = false; + for (const LargeRJetTruthLabel::TypeEnum aLabel : m_largeRJetTruthLabels) + { + if (aLabel == largeRJetTruthLabel) + relevantLabel = true; + } + + // If we don't want to apply an uncertainty to jets with this label, then return 0 here (no uncertainty) + if (!relevantLabel) + return 0; + // Otherwise, continue as usual + } + + + // Now, we do want t o apply the uncertainty, so do it double unc = JESUNC_ERROR_CODE; if (m_flavourType == FlavourComp::Response) unc = getFlavourResponseUncertainty(jet,eInfo); @@ -334,7 +423,7 @@ double FlavourUncertaintyComponent::getFlavourResponseUncertainty(const xAOD::Je // Check if this is a b-jet if (isBjet(jet)) return 0; - + // Get the number of jets int nJets = 0; if (m_gluonFractionHists.size() > 1) @@ -369,7 +458,7 @@ double FlavourUncertaintyComponent::getFlavourCompositionUncertainty(const xAOD: // fg = fraction of gluons // Rq = light quark response // Rg = gluon response - + // Check if this is a b-jet if (isBjet(jet)) return 0; @@ -434,11 +523,13 @@ double FlavourUncertaintyComponent::getBJESUncertainty(const xAOD::Jet& jet, con double FlavourUncertaintyComponent::getGluonFraction(const double pT, const double eta, const int nJets) const { + // nJets value checking is done in checkNjetsInput return m_gluonFractionHists.at(nJets)->getValue(pT,fabs(eta)); } double FlavourUncertaintyComponent::getGluonFractionError(const double pT, const double eta, const int nJets) const { + // nJets value checking is done in checkNjetsInput return m_gluonFractionErrorHists.at(nJets)->getValue(pT,fabs(eta)); } @@ -498,7 +589,7 @@ StatusCode FlavourUncertaintyComponent::readNjetsHistograms(std::vector<Uncertai int nJets = -1; if (getNjetFromKey(histName,nJets).isFailure()) return StatusCode::FAILURE; - if (nJets < 0 || nJets > static_cast<int>(histKeys.size())-1) + if (nJets < 0 || nJets >= static_cast<int>(hists.size())) { ATH_MSG_ERROR(Form("Unexpected gluon fraction nJet %d of index %zu: %s",nJets,iKey,histName.Data())); return StatusCode::FAILURE; @@ -534,21 +625,27 @@ StatusCode FlavourUncertaintyComponent::checkNjetsInput(int& nJets) const { // nJets = 0 is the inclusive composition // nJets = # is the composition for # jets + // nJets < 0 uses default if available + // nJets > MAX uses default if available + // nJets = #, but # is NULL uses default if available // Case of no histograms is checked in initialization, no need to repeat here // Initialization also ensures gluonFractionHists and gluonFractionErrorHists are consistent - // Take overflow from the highest bin - // Note that this means the nJets=0 inclusive composition is used for ALL nJets values if the user did not provide nJets histograms (intended functionality) - if (nJets > 0 && static_cast<size_t>(nJets) >= m_gluonFractionHists.size()) - nJets = m_gluonFractionHists.size() - 1; - - // Watch for missing histograms (users don't need to specify every nJet bin if they don't use them) - if (!m_gluonFractionHists.at(nJets)) + // Check if we need to use the default histogram + if (nJets < 0 || nJets >= static_cast<int>(m_gluonFractionHists.size()) || m_gluonFractionHists.at(nJets) == NULL) { - ATH_MSG_ERROR(Form("nJets of %d is NULL for %s",nJets,getName().Data())); - return StatusCode::FAILURE; + // Check if we can fall back on the default bin (does it exist?) + if (m_gluonFractionHists.at(0) == NULL) + { + ATH_MSG_ERROR("nJets of " << nJets << " is invalid, and default does not exist to fall back on, for " << getName().Data()); + return StatusCode::FAILURE; + } + // Fall back on the default bin + nJets = 0; } + // Otherwise, the specified nJets value is fine and doesn't need to be touched + return StatusCode::SUCCESS; } @@ -562,5 +659,32 @@ bool FlavourUncertaintyComponent::isBjet(const xAOD::Jet& jet) const return m_BjetAccessor(jet) != 0; } + +void FlavourUncertaintyComponent::getGluonKeys(TFile* analysisFile, std::vector<TString>& gluonFractionKeys, std::vector<TString>& gluonFractionErrorKeys) const +{ + TList* keys = analysisFile->GetListOfKeys(); + TIter nextkey(keys); + if (m_analysisHistPattern != "") + { + ATH_MSG_DEBUG("Ignoring histograms which don't contain pattern " << m_analysisHistPattern.Data()); + } + while (TKey* key = dynamic_cast<TKey*>(nextkey())) + { + if (!key) continue; + const TString keyName = key->GetName(); + //Ignoring histograms which doesn't contain user-defined pattern + if (m_analysisHistPattern != "" && !keyName.Contains(m_analysisHistPattern)) continue; + if (keyName.Contains(m_jetType) && !keyName.Contains("valid")) + { + if (keyName.Contains("gluonFractionError")) + gluonFractionErrorKeys.push_back(keyName); + else if (keyName.Contains("gluonFraction")) + gluonFractionKeys.push_back(keyName); + } + } +} + + + } // end jet namespace diff --git a/Reconstruction/Jet/JetUncertainties/Root/Helpers.cxx b/Reconstruction/Jet/JetUncertainties/Root/Helpers.cxx index 2fc91a3a9e4f85f159be47b321e215c5f12a3810..0736f239ec6e6817a93f519282bba25938b1e4ba 100644 --- a/Reconstruction/Jet/JetUncertainties/Root/Helpers.cxx +++ b/Reconstruction/Jet/JetUncertainties/Root/Helpers.cxx @@ -96,22 +96,28 @@ bool fileExists(const TString& fileName) return gSystem->AccessPathName(fileName) == false; } -TString findFilePath(const TString& fileName, const TString& path) +TString findFilePath(const TString& fileName, const TString& path, const TString& calibArea) { TString pathToGet = ""; - // First, try the raw filename plus path (user-specified), then raw filename (local) - if (fileExists(fileName)) - pathToGet = fileName; - else if (fileExists(path+(path.EndsWith("/")?"":"/")+fileName)) + // First, try the raw filename plus path (user-specified), then raw filename (local or full path) + if (path != "" && fileExists(path+(path.EndsWith("/")?"":"/")+fileName)) pathToGet = path+(path.EndsWith("/")?"":"/")+fileName; - - // Next, try PathResolver - if (pathToGet == "") + else if (fileExists(fileName)) + pathToGet = fileName; + + // Next, try PathResolver in a few configurations + // PathResolver #1: versioned CalibArea (most users should be in this case) + if (pathToGet == "" && calibArea != "") + pathToGet = TString(PathResolverFindCalibFile(Form("JetUncertainties/%s/%s",calibArea.Data(),fileName.Data())).c_str()); + // PathResolver #2: unversioned CalibArea (legacy support) + if (pathToGet == "" && calibArea == "") pathToGet = TString(PathResolverFindCalibFile(Form("JetUncertainties/%s",fileName.Data())).c_str()); - + // PathResolver #3: general search in case of files residing in other packages (request from a Higgs group) + if (pathToGet == "") + pathToGet = TString(PathResolverFindCalibFile(fileName.Data()).c_str()); - // Try backup locations now + // Try backup locations now (legacy support) if (pathToGet == "") { // Try ROOTCOREBIN @@ -130,12 +136,12 @@ TString findFilePath(const TString& fileName, const TString& path) return pathToGet; } -TFile* readRootFile(const TString& fileName, const TString& path) +TFile* readRootFile(const TString& fileName, const TString& path, const TString& calibArea) { TFile* rootFile = NULL; - TString pathToGet = findFilePath(fileName,path); - std::cout << "Looking for file " << fileName << " in path " << path << std::endl; + TString pathToGet = findFilePath(fileName,path,calibArea); + //std::cout << "Looking for file " << fileName << " in path " << path << std::endl; if (pathToGet != "") rootFile = new TFile(pathToGet,"READ"); @@ -224,4 +230,3 @@ void scaleHistoAxes(TH1* toScale, const double factorX, const double factorY, co } // End utils namespace } // End jet namespace - diff --git a/Reconstruction/Jet/JetUncertainties/Root/JetHelpers.cxx b/Reconstruction/Jet/JetUncertainties/Root/JetHelpers.cxx new file mode 100644 index 0000000000000000000000000000000000000000..342b0fa014b2de09f9d991c281c67f6cca61f25b --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/Root/JetHelpers.cxx @@ -0,0 +1,316 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + + +#include "JetUncertainties/JetHelpers.h" + +#include "TH1.h" +#include <TMath.h> +#include "TAxis.h" + +//We move all the Histogram reading helpers from "JetUncertainties/UncertaintyHistogram.h" here because we want to use them in the FFJetSmearingTool too + +//Helpers to interpolate + +double JetHelpers::Interpolate(const TH1* histo, const double x) +{ + // Copied from ROOT directly and trivially modified, all credit to ROOT authors of TH1, TH2, and TH3 Interpolate methods + // This is done because I want a const version of interpolation, and none of the methods require modification of the histogram + int xbin = (histo->GetXaxis())->FindBin(x); + double x0,x1,y0,y1; + + if(x<=histo->GetBinCenter(1)) { + return histo->GetBinContent(1); + } else if(x>=histo->GetBinCenter(histo->GetNbinsX())) { + return histo->GetBinContent(histo->GetNbinsX()); + } else { + if(x<=histo->GetBinCenter(xbin)) { + y0 = histo->GetBinContent(xbin-1); + x0 = histo->GetBinCenter(xbin-1); + y1 = histo->GetBinContent(xbin); + x1 = histo->GetBinCenter(xbin); + } else { + y0 = histo->GetBinContent(xbin); + x0 = histo->GetBinCenter(xbin); + y1 = histo->GetBinContent(xbin+1); + x1 = histo->GetBinCenter(xbin+1); + } + return y0 + (x-x0)*((y1-y0)/(x1-x0)); + } +} + + +double JetHelpers::Interpolate(const TH1* histo, const double x, const double y) +{ + // Call the unified method for consistency + return Interpolate2D(histo,x,y); +} + +double JetHelpers::Interpolate2D(const TH1* histo, const double x, const double y, const int xAxis, const int yAxis, const int otherDimBin) +{ + if (xAxis == 0 || xAxis > histo->GetDimension()) + { + histo->Error("Interpolate2D","Invalid x-axis specified"); + return 0; + } + if (yAxis == 0 || yAxis > histo->GetDimension()) + { + histo->Error("Interpolate2D","Invalid y-axis specified"); + return 0; + } + if (xAxis == yAxis) + { + histo->Error("Interpolate2D","Requested x-axis == y-axis, invalid for 2D interpolation"); + return 0; + } + + // Copied from ROOT directly and trivially modified, all credit to ROOT authors of TH1, TH2, and TH3 Interpolate methods + // This is done because I want a const version of interpolation, and none of the methods require modification of the histogram + const TAxis* fXaxis = xAxis == 1 ? histo->GetXaxis() : xAxis == 2 ? histo->GetYaxis() : xAxis == 3 ? histo->GetZaxis() : nullptr; + const TAxis* fYaxis = yAxis == 1 ? histo->GetXaxis() : yAxis == 2 ? histo->GetYaxis() : yAxis == 3 ? histo->GetZaxis() : nullptr; + + if (!fXaxis || !fYaxis) + { + histo->Error("Interpolate2D","Failed to parse axes from inputs"); + return 0; + } + + double f=0; + double x1=0,x2=0,y1=0,y2=0; + double dx,dy; + int bin_x = fXaxis->FindBin(x); + int bin_y = fYaxis->FindBin(y); + if(bin_x<1 || bin_x>fXaxis->GetNbins() || bin_y<1 || bin_y>fYaxis->GetNbins()) { + histo->Error("Interpolate","Cannot interpolate outside histogram domain. (x: %f vs [%f,%f], y: %f vs [%f,%f])",x,fXaxis->GetBinLowEdge(1),fXaxis->GetBinLowEdge(fXaxis->GetNbins()+1),y,fYaxis->GetBinLowEdge(1),fYaxis->GetBinLowEdge(fYaxis->GetNbins()+1)); + return 0; + } + int quadrant = 0; // CCW from UR 1,2,3,4 + // which quadrant of the bin (bin_P) are we in? + dx = fXaxis->GetBinUpEdge(bin_x)-x; + dy = fYaxis->GetBinUpEdge(bin_y)-y; + if (dx<=fXaxis->GetBinWidth(bin_x)/2 && dy<=fYaxis->GetBinWidth(bin_y)/2) + quadrant = 1; // upper right + if (dx>fXaxis->GetBinWidth(bin_x)/2 && dy<=fYaxis->GetBinWidth(bin_y)/2) + quadrant = 2; // upper left + if (dx>fXaxis->GetBinWidth(bin_x)/2 && dy>fYaxis->GetBinWidth(bin_y)/2) + quadrant = 3; // lower left + if (dx<=fXaxis->GetBinWidth(bin_x)/2 && dy>fYaxis->GetBinWidth(bin_y)/2) + quadrant = 4; // lower right + switch(quadrant) { + case 1: + x1 = fXaxis->GetBinCenter(bin_x); + y1 = fYaxis->GetBinCenter(bin_y); + x2 = fXaxis->GetBinCenter(bin_x+1); + y2 = fYaxis->GetBinCenter(bin_y+1); + break; + case 2: + x1 = fXaxis->GetBinCenter(bin_x-1); + y1 = fYaxis->GetBinCenter(bin_y); + x2 = fXaxis->GetBinCenter(bin_x); + y2 = fYaxis->GetBinCenter(bin_y+1); + break; + case 3: + x1 = fXaxis->GetBinCenter(bin_x-1); + y1 = fYaxis->GetBinCenter(bin_y-1); + x2 = fXaxis->GetBinCenter(bin_x); + y2 = fYaxis->GetBinCenter(bin_y); + break; + case 4: + x1 = fXaxis->GetBinCenter(bin_x); + y1 = fYaxis->GetBinCenter(bin_y-1); + x2 = fXaxis->GetBinCenter(bin_x+1); + y2 = fYaxis->GetBinCenter(bin_y); + break; + } + int bin_x1 = fXaxis->FindBin(x1); + if(bin_x1<1) bin_x1=1; + int bin_x2 = fXaxis->FindBin(x2); + if(bin_x2>fXaxis->GetNbins()) bin_x2=fXaxis->GetNbins(); + int bin_y1 = fYaxis->FindBin(y1); + if(bin_y1<1) bin_y1=1; + int bin_y2 = fYaxis->FindBin(y2); + if(bin_y2>fYaxis->GetNbins()) bin_y2=fYaxis->GetNbins(); + + double q11; + double q12; + double q21; + double q22; + if (otherDimBin > 0) + { + // X,Y variable and Z fixed + if (xAxis == 1 && yAxis == 2) + { + q11 = histo->GetBinContent(histo->GetBin(bin_x1,bin_y1,otherDimBin)); + q12 = histo->GetBinContent(histo->GetBin(bin_x1,bin_y2,otherDimBin)); + q21 = histo->GetBinContent(histo->GetBin(bin_x2,bin_y1,otherDimBin)); + q22 = histo->GetBinContent(histo->GetBin(bin_x2,bin_y2,otherDimBin)); + } + // X,Z variable and Y fixed + else if (xAxis == 1 && yAxis == 3) + { + q11 = histo->GetBinContent(histo->GetBin(bin_x1,otherDimBin,bin_y1)); + q12 = histo->GetBinContent(histo->GetBin(bin_x1,otherDimBin,bin_y2)); + q21 = histo->GetBinContent(histo->GetBin(bin_x2,otherDimBin,bin_y1)); + q22 = histo->GetBinContent(histo->GetBin(bin_x2,otherDimBin,bin_y2)); + } + // Y,Z variable and X fixed + else if (xAxis == 2 && yAxis == 3) + { + q11 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_x1,bin_y1)); + q12 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_x1,bin_y2)); + q21 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_x2,bin_y1)); + q22 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_x2,bin_y2)); + } + // Y,X variable and Z fixed + else if (xAxis == 2 && yAxis == 1) + { + q11 = histo->GetBinContent(histo->GetBin(bin_y1,bin_x1,otherDimBin)); + q12 = histo->GetBinContent(histo->GetBin(bin_y1,bin_x2,otherDimBin)); + q21 = histo->GetBinContent(histo->GetBin(bin_y2,bin_x1,otherDimBin)); + q22 = histo->GetBinContent(histo->GetBin(bin_y2,bin_x2,otherDimBin)); + } + // Z,X variable and Y fixed + else if (xAxis == 3 && yAxis == 1) + { + q11 = histo->GetBinContent(histo->GetBin(bin_y1,otherDimBin,bin_x1)); + q12 = histo->GetBinContent(histo->GetBin(bin_y1,otherDimBin,bin_x2)); + q21 = histo->GetBinContent(histo->GetBin(bin_y2,otherDimBin,bin_x1)); + q22 = histo->GetBinContent(histo->GetBin(bin_y2,otherDimBin,bin_x2)); + } + // Z,Y variable and X fixed + else if (xAxis == 3 && yAxis == 2) + { + q11 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_y1,bin_x1)); + q12 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_y1,bin_x2)); + q21 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_y2,bin_x1)); + q22 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_y2,bin_x2)); + } + else + { + histo->Error("Interpolate2D","Unsupported axis combination: (x,y)=(%d,%d) with one bin fixed",xAxis,yAxis); + return 0; + } + } + else + { + // X,Y variable, no Z + if (xAxis == 1 && yAxis == 2) + { + q11 = histo->GetBinContent(histo->GetBin(bin_x1,bin_y1)); + q12 = histo->GetBinContent(histo->GetBin(bin_x1,bin_y2)); + q21 = histo->GetBinContent(histo->GetBin(bin_x2,bin_y1)); + q22 = histo->GetBinContent(histo->GetBin(bin_x2,bin_y2)); + } + // Y,X variable, no Z + else if (xAxis == 2 && yAxis == 1) + { + q11 = histo->GetBinContent(histo->GetBin(bin_y1,bin_x1)); + q12 = histo->GetBinContent(histo->GetBin(bin_y1,bin_x2)); + q21 = histo->GetBinContent(histo->GetBin(bin_y2,bin_x1)); + q22 = histo->GetBinContent(histo->GetBin(bin_y2,bin_x2)); + } + else + { + histo->Error("Interpolate2D","Unsupported axis combination: (x,y)=(%d,%d)",xAxis,yAxis); + return 0; + } + } + + double d = 1.0*(x2-x1)*(y2-y1); + f = 1.0*q11/d*(x2-x)*(y2-y)+1.0*q21/d*(x-x1)*(y2-y)+1.0*q12/d*(x2-x)*(y-y1)+1.0*q22/d*(x-x1)*(y-y1); + return f; +} + +double JetHelpers::Interpolate(const TH1* histo, const double x, const double y, const double z) +{ + // Copied from ROOT directly and trivially modified, all credit to ROOT authors of TH1, TH2, and TH3 Interpolate methods + // This is done because I want a const version of interpolation, and none of the methods require modification of the histogram + const TAxis* fXaxis = histo->GetXaxis(); + const TAxis* fYaxis = histo->GetYaxis(); + const TAxis* fZaxis = histo->GetZaxis(); + + // Find the bin by bin edges + int ubx = fXaxis->FindBin(x); + int uby = fYaxis->FindBin(y); + int ubz = fZaxis->FindBin(z); + + // Check if the value(s) are outside of the bin range(s) + if ( ubx < 1 || ubx > histo->GetNbinsX() || uby < 1 || uby > histo->GetNbinsY() || ubz < 1 || ubz > histo->GetNbinsZ() ) + { + histo->Error("Interpolate","Cannot interpolate outside histogram domain. (x: %f vs [%f,%f], y: %f vs [%f,%f], z: %f vs [%f,%f])",x,fXaxis->GetBinLowEdge(1),fXaxis->GetBinLowEdge(histo->GetNbinsX()+1),y,fYaxis->GetBinLowEdge(1),fYaxis->GetBinLowEdge(histo->GetNbinsY()+1),z,fZaxis->GetBinLowEdge(1),fZaxis->GetBinLowEdge(histo->GetNbinsZ()+1)); + return 0; + } + + // Now switch from bin edges to bin centres + // Note that we want to support edge cases, so it is possible that ub* == ob* + // This functionality is not in original ROOT TH3::Interpolate() + // This functionality is inspired by TH2::Interpolate() + int obx = ubx + 1; + int oby = uby + 1; + int obz = ubz + 1; + + // Calculate distance weights before checking under/overflow bins + // No longer here, see note below + + if (x < fXaxis->GetBinCenter(ubx)) { ubx -= 1; obx -= 1; } + if (ubx < 1) ubx = 1; + if (obx > histo->GetNbinsX()) obx = histo->GetNbinsX(); + + if (y < fYaxis->GetBinCenter(uby)) { uby -= 1; oby -= 1; } + if (uby < 1) uby = 1; + if (oby > histo->GetNbinsY()) oby = histo->GetNbinsY(); + + if (z < fZaxis->GetBinCenter(ubz)) { ubz -= 1; obz -= 1; } + if (ubz < 1) ubz = 1; + if (obz > histo->GetNbinsZ()) obz = histo->GetNbinsZ(); + + // Edge cases were tried with weights set including the under/overflow bins (to follow what TH2::Interpolate() does for boundaries) + // In some cases, it performed quite poorly + // Tests of switching to 2D interpolation with the third dimension fixed appeared to work much better + // Thus, the below is now a switch to bilinear interpolation when bin(s) are equal in trilinear interpolation + if (ubx == obx || uby == oby || ubz == obz) + { + // Bilinear interpolation + if (ubz == obz) + return Interpolate2D(histo,x,y,1,2,ubz); + else if (uby == oby) + return Interpolate2D(histo,x,z,1,3,uby); + else if (ubx == obx) + return Interpolate2D(histo,y,z,2,3,ubx); + + } + + // Moved from the point which says "see note below" to better handle non-uniform bins + // Particularly important for logarithmic bins, which are commonly used in this tool + // Done following studies/suggestion by P-A Delsart + double xw = fXaxis->GetBinCenter(obx) - fXaxis->GetBinCenter(ubx); + double yw = fYaxis->GetBinCenter(oby) - fYaxis->GetBinCenter(uby); + double zw = fZaxis->GetBinCenter(obz) - fZaxis->GetBinCenter(ubz); + + // Not a boundary case, resume normal ROOT::TH3::Interpolate() + double xd = (x - fXaxis->GetBinCenter(ubx)) / xw; + double yd = (y - fYaxis->GetBinCenter(uby)) / yw; + double zd = (z - fZaxis->GetBinCenter(ubz)) / zw; + + + double v[] = { histo->GetBinContent( ubx, uby, ubz ), histo->GetBinContent( ubx, uby, obz ), + histo->GetBinContent( ubx, oby, ubz ), histo->GetBinContent( ubx, oby, obz ), + histo->GetBinContent( obx, uby, ubz ), histo->GetBinContent( obx, uby, obz ), + histo->GetBinContent( obx, oby, ubz ), histo->GetBinContent( obx, oby, obz ) }; + + + double i1 = v[0] * (1 - zd) + v[1] * zd; + double i2 = v[2] * (1 - zd) + v[3] * zd; + double j1 = v[4] * (1 - zd) + v[5] * zd; + double j2 = v[6] * (1 - zd) + v[7] * zd; + + + double w1 = i1 * (1 - yd) + i2 * yd; + double w2 = j1 * (1 - yd) + j2 * yd; + + + double result = w1 * (1 - xd) + w2 * xd; + + return result; +} diff --git a/Reconstruction/Jet/JetUncertainties/Root/JetUncertaintiesTool.cxx b/Reconstruction/Jet/JetUncertainties/Root/JetUncertaintiesTool.cxx index 6f9b9ef3b81387ea5b03aa55ec775069dc588d92..cf76479c404848af1cec035dacfa5683406db89f 100644 --- a/Reconstruction/Jet/JetUncertainties/Root/JetUncertaintiesTool.cxx +++ b/Reconstruction/Jet/JetUncertainties/Root/JetUncertaintiesTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // General package includes @@ -7,6 +7,7 @@ #include "JetUncertainties/Helpers.h" #include "JetUncertainties/UncertaintyEnum.h" #include "JetUncertainties/ConfigHelper.h" +#include "JetUncertainties/ResolutionHelper.h" #include "JetUncertainties/CorrelationMatrix.h" // UncertaintyHistogram types @@ -19,13 +20,20 @@ #include "JetUncertainties/UncertaintySet.h" #include "JetUncertainties/PtUncertaintyComponent.h" #include "JetUncertainties/PtEtaUncertaintyComponent.h" +#include "JetUncertainties/PtLogPtMassForTagSFUncertaintyComponent.h" +#include "JetUncertainties/PtAbsMassUncertaintyComponent.h" #include "JetUncertainties/PtMassUncertaintyComponent.h" +#include "JetUncertainties/PtAbsMassEtaUncertaintyComponent.h" #include "JetUncertainties/PtMassEtaUncertaintyComponent.h" +#include "JetUncertainties/ELogMassUncertaintyComponent.h" +#include "JetUncertainties/ELogMassEtaUncertaintyComponent.h" #include "JetUncertainties/PileupUncertaintyComponent.h" #include "JetUncertainties/FlavourUncertaintyComponent.h" +#include "JetUncertainties/PerJetFlavourUncertaintyComponent.h" #include "JetUncertainties/PunchthroughUncertaintyComponent.h" #include "JetUncertainties/ClosebyUncertaintyComponent.h" #include "JetUncertainties/CombinedMassUncertaintyComponent.h" +#include "JetUncertainties/LargeRTopologyUncertaintyComponent.h" // xAOD includes #include "xAODCore/ShallowCopy.h" @@ -42,7 +50,6 @@ #include "TROOT.h" #include "TEnv.h" #include "TH2D.h" -#include "TRandom3.h" // C++ includes #include <unordered_set> @@ -64,9 +71,12 @@ JetUncertaintiesTool::JetUncertaintiesTool(const std::string& name) , m_jetDef("") , m_mcType("") , m_configFile("") + , m_calibArea("CalibArea-08") , m_path("") , m_analysisFile("") + , m_analysisHistPattern("") , m_systFilters() + , m_defAnaFile("") , m_refNPV(-1) , m_refMu(-1) , m_refNPVHist(NULL) @@ -83,16 +93,25 @@ JetUncertaintiesTool::JetUncertaintiesTool(const std::string& name) , m_TAMassWeight(NULL) , m_combMassWeightCaloMassDef(CompMassDef::UNKNOWN) , m_combMassWeightTAMassDef(CompMassDef::UNKNOWN) + , m_combMassParam(CompParametrization::UNKNOWN) , m_userSeed(0) - , m_rand(new TRandom3()) + , m_rand() + , m_isData(true) + , m_resHelper(NULL) , m_namePrefix("JET_") + , m_accTagScaleFactor("temp_SF") + , m_accEffSF("temp_effSF") + , m_accEfficiency("temp_efficiency") { declareProperty("JetDefinition",m_jetDef); declareProperty("MCType",m_mcType); declareProperty("ConfigFile",m_configFile); + declareProperty("CalibArea",m_calibArea); declareProperty("Path",m_path); declareProperty("AnalysisFile",m_analysisFile); + declareProperty("AnalysisHistPattern",m_analysisHistPattern); declareProperty("VariablesToShift",m_systFilters); + declareProperty("IsData",m_isData); ATH_MSG_DEBUG("Creating JetUncertaintiesTool named "<<m_name); @@ -111,9 +130,12 @@ JetUncertaintiesTool::JetUncertaintiesTool(const JetUncertaintiesTool& toCopy) , m_jetDef(toCopy.m_jetDef) , m_mcType(toCopy.m_mcType) , m_configFile(toCopy.m_configFile) + , m_calibArea(toCopy.m_calibArea) , m_path(toCopy.m_path) , m_analysisFile(toCopy.m_analysisFile) + , m_analysisHistPattern(toCopy.m_analysisHistPattern) , m_systFilters(toCopy.m_systFilters) + , m_defAnaFile(toCopy.m_defAnaFile) , m_refNPV(toCopy.m_refNPV) , m_refMu(toCopy.m_refMu) , m_refNPVHist(toCopy.m_refNPVHist?new UncertaintyHistogram(*toCopy.m_refNPVHist):NULL) @@ -130,9 +152,15 @@ JetUncertaintiesTool::JetUncertaintiesTool(const JetUncertaintiesTool& toCopy) , m_TAMassWeight(NULL) , m_combMassWeightCaloMassDef(CompMassDef::UNKNOWN) , m_combMassWeightTAMassDef(CompMassDef::UNKNOWN) + , m_combMassParam(CompParametrization::UNKNOWN) , m_userSeed(toCopy.m_userSeed) - , m_rand(toCopy.m_rand ? new TRandom3(*toCopy.m_rand) : NULL) + , m_rand(toCopy.m_rand) + , m_isData(toCopy.m_isData) + , m_resHelper(new ResolutionHelper(*toCopy.m_resHelper)) , m_namePrefix(toCopy.m_namePrefix) + , m_accTagScaleFactor(toCopy.m_accTagScaleFactor) + , m_accEffSF(toCopy.m_accEffSF) + , m_accEfficiency(toCopy.m_accEfficiency) { ATH_MSG_DEBUG("Creating copy of JetUncertaintiesTool named "<<m_name); @@ -166,7 +194,7 @@ JetUncertaintiesTool::~JetUncertaintiesTool() JESUNC_SAFE_DELETE(iter->second); m_systSetMap.clear(); - JESUNC_SAFE_DELETE(m_rand); + JESUNC_SAFE_DELETE(m_resHelper); } StatusCode JetUncertaintiesTool::setScaleToMeV() @@ -211,10 +239,10 @@ StatusCode JetUncertaintiesTool::initialize() gROOT->cd(); // Read the config file - const TString configFilePath = jet::utils::findFilePath(m_configFile.c_str(),m_path.c_str()); + const TString configFilePath = jet::utils::findFilePath(m_configFile.c_str(),m_path.c_str(),m_calibArea.c_str()); if (configFilePath == "") { - ATH_MSG_ERROR("Cannot find config file: " << m_configFile << " (path is " << m_path << ")"); + ATH_MSG_ERROR("Cannot find config file: " << m_configFile << " (path is \"" << m_path << "\", CalibArea is \"" << m_calibArea << "\")"); return StatusCode::FAILURE; } @@ -228,9 +256,11 @@ StatusCode JetUncertaintiesTool::initialize() // We can read it - start printing ATH_MSG_INFO(Form("================================================")); ATH_MSG_INFO(Form(" Initializing the JetUncertaintiesTool named %s",m_name.c_str())); - ATH_MSG_INFO(Form(" Path is: %s",m_path.c_str())); - ATH_MSG_INFO(Form(" Configuration read in from:" )); - ATH_MSG_INFO(Form(" %s",configFilePath.Data())); + ATH_MSG_INFO(Form(" Path is: \"%s\"",m_path.c_str())); + ATH_MSG_INFO(Form(" CalibArea is: \"%s\"",m_calibArea.c_str())); + ATH_MSG_INFO(Form(" IsData is: \"%s\"",m_isData ? "true" : "false")); + ATH_MSG_INFO(Form(" Configuration file: \"%s\"",m_configFile.c_str())); + ATH_MSG_INFO(Form(" Location: %s",configFilePath.Data())); // Get the uncertainty release @@ -291,22 +321,61 @@ StatusCode JetUncertaintiesTool::initialize() ATH_MSG_ERROR("Cannot find uncertainty histogram file"); return StatusCode::FAILURE; } - ATH_MSG_INFO(Form(" UncertaintyFile: %s",histFileName.Data())); - - // Get the analysis ROOT file for later use (only if it wasn't specified by user config) - if (m_analysisFile == "") - m_analysisFile = settings.GetValue("AnalysisRootFile",""); - if (m_analysisFile != "") - ATH_MSG_INFO(Form(" AnalysisFile: %s",m_analysisFile.c_str())); - + ATH_MSG_INFO(Form(" UncertaintyFile: \"%s\"",histFileName.Data())); + + // Now find the histogram file + const TString histFilePath = utils::findFilePath(histFileName,m_path.c_str(),m_calibArea.c_str()); + if (histFilePath == "") + { + ATH_MSG_ERROR("Cannot find the path of the uncertainty histogram file"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO(Form(" Location: %s",histFilePath.Data())); + // Now open the histogram file - TFile* histFile = utils::readRootFile(histFileName,m_path.c_str()); + TFile* histFile = new TFile(histFilePath,"READ"); if (!histFile || histFile->IsZombie()) { ATH_MSG_ERROR("Cannot open uncertainty histogram file: " << histFileName.Data()); return StatusCode::FAILURE; } + + // Get the default analysis ROOT file for later use + // Overwrite the analysisFile if it wasn't specified + m_defAnaFile = settings.GetValue("AnalysisRootFile",""); + if (m_analysisFile == "") + m_analysisFile = m_defAnaFile; + if (m_analysisFile != "") + { + ATH_MSG_INFO(Form(" AnalysisFile: \"%s\"",m_analysisFile.c_str())); + // Ensure that we can find the file + const TString analysisFilePath = utils::findFilePath(m_analysisFile.c_str(),m_path.c_str(),m_calibArea.c_str()); + if (analysisFilePath == "") + { + ATH_MSG_ERROR("Cannot find the path of the analysis histogram file"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO(Form(" Location: %s",analysisFilePath.Data())); + } + if (m_defAnaFile != m_analysisFile && m_defAnaFile != "") + { + ATH_MSG_INFO(Form(" DefaultAnalysisFile: \"%s\"",m_defAnaFile.c_str())); + // Ensure that we can find the file + const TString analysisFilePath = utils::findFilePath(m_defAnaFile.c_str(),m_path.c_str(),m_calibArea.c_str()); + if (analysisFilePath == "") + { + ATH_MSG_ERROR("Cannot find the path of the default analysis histogram file"); + return StatusCode::FAILURE; + } + ATH_MSG_INFO(Form(" Location: %s",analysisFilePath.Data())); + // if a histogram pattern was provided, then use it (only if an analysis file is used) + if (m_analysisHistPattern != "") + { + ATH_MSG_INFO(Form(" AnalysisHistPattern: \"%s\"",m_analysisHistPattern.c_str())); + } + } + // Get a file-wide validity histogram if specified TString validHistForFile = settings.GetValue("FileValidHistogram",""); if (validHistForFile != "") @@ -338,17 +407,27 @@ StatusCode JetUncertaintiesTool::initialize() const TString TAMassWeight = TString(settings.GetValue("CombMassWeightTAHist","")); if (caloMassWeight != "" && TAMassWeight != "") { - m_caloMassWeight = new UncertaintyHistogram(caloMassWeight+"_"+m_jetDef.c_str(),true); - m_TAMassWeight = new UncertaintyHistogram(TAMassWeight+"_"+m_jetDef.c_str(),true); + m_caloMassWeight = new UncertaintyHistogram(caloMassWeight+"_"+m_jetDef.c_str(),Interpolate::Full); + m_TAMassWeight = new UncertaintyHistogram(TAMassWeight+"_"+m_jetDef.c_str(),Interpolate::Full); if (m_caloMassWeight->initialize(histFile).isFailure()) return StatusCode::FAILURE; if (m_TAMassWeight->initialize(histFile).isFailure()) return StatusCode::FAILURE; + // Get the weight parametrization, defaulting to pT vs m/pT + const TString combMassParam = TString(settings.GetValue("CombMassWeightParam","PtMass")); + m_combMassParam = CompParametrization::stringToEnum(combMassParam); + if (m_combMassParam == CompParametrization::UNKNOWN) + { + ATH_MSG_ERROR("Unexpected combined mass parametrization: " << combMassParam.Data()); + return StatusCode::FAILURE; + } + ATH_MSG_INFO(" Found and loaded combined mass weight factors"); ATH_MSG_INFO(" WeightCaloHist = " << m_caloMassWeight->getName()); ATH_MSG_INFO(" WeightTAHist = " << m_TAMassWeight->getName()); + ATH_MSG_INFO(" WeightParam = " << CompParametrization::enumToString(m_combMassParam).Data()); // Check for custom mass definitions for the weight factors (not required, defaults exist) const TString caloWeightMassDef = settings.GetValue("CombMassWeightCaloMassDef","Calo"); @@ -375,7 +454,17 @@ StatusCode JetUncertaintiesTool::initialize() return StatusCode::FAILURE; } - + // Get name of accessor to SF value + m_name_TagScaleFactor = TString(settings.GetValue("FileValidSFName","temp_SF")); + m_name_EffSF = TString(settings.GetValue("FileValidEffSFName","temp_effSF")); + m_name_Efficiency = TString(settings.GetValue("FileValidEfficiencyName","temp_efficiency")); + if ( m_name_TagScaleFactor != "temp_SF") { + ATH_MSG_INFO(" accessor of SF is " << m_name_TagScaleFactor); + } + m_accTagScaleFactor = SG::AuxElement::Accessor<float>(m_name_TagScaleFactor); + m_accEffSF = SG::AuxElement::Accessor<float>(m_name_EffSF); + m_accEfficiency = SG::AuxElement::Accessor<float>(m_name_Efficiency); + // Get the NPV/mu reference values // These may not be set - only needed if a pileup component is requested TString refNPV = settings.GetValue("Pileup.NPVRef",""); @@ -393,7 +482,7 @@ StatusCode JetUncertaintiesTool::initialize() m_refNPV = utils::getTypeObjFromString<float>(refNPV); else { - m_refNPVHist = new UncertaintyHistogram(refNPV+"_"+m_jetDef,false); + m_refNPVHist = new UncertaintyHistogram(refNPV+"_"+m_jetDef,Interpolate::None); if (m_refNPVHist->initialize(histFile).isFailure()) return StatusCode::FAILURE; } @@ -402,7 +491,7 @@ StatusCode JetUncertaintiesTool::initialize() m_refMu = utils::getTypeObjFromString<float>(refMu); else { - m_refMuHist = new UncertaintyHistogram(refMu+"_"+m_jetDef,false); + m_refMuHist = new UncertaintyHistogram(refMu+"_"+m_jetDef,Interpolate::None); if (m_refMuHist->initialize(histFile).isFailure()) return StatusCode::FAILURE; } @@ -427,6 +516,12 @@ StatusCode JetUncertaintiesTool::initialize() ATH_MSG_INFO(Form(" VariablesToShift: %s",varString.c_str())); } + // Attempt to read in nominal resolution information + // There may be no such information - this is perfectly normal + m_resHelper = new ResolutionHelper(m_name+"_RH",m_jetDef); + if(m_resHelper->initialize(settings,histFile,m_mcType.c_str()).isFailure()) + return StatusCode::FAILURE; + // Prepare for reading components and groups // Components can be a group by themself (single component groups) if "Group" == 0 // Components can also form simple groups with "SubComp" @@ -577,114 +672,6 @@ StatusCode JetUncertaintiesTool::initialize() } - /* - // Deal with subgroups - // Have to do this carefully to ensure we can have multiple levels of subgroups (groups of groups of groups of ...) - - // First split into complex groups and basic groups (groups which include subgroups and groups which do not include subgroups) - // Also get the full list of subgroup requests to ensure there are no duplicates - std::vector<size_t> complexGroupIndices; - std::vector<size_t> basicGroupIndices; - std::set<int> subgroupsRequested; - for (size_t iGroup = 0; iGroup < m_groups.size(); ++iGroup) - { - const std::vector<int> subgroupNums = m_groups.at(iGroup)->getSubgroupNums(); - if (subgroupNums.size()) - { - for (size_t iSubgroup = 0; iSubgroup < subgroupNums.size(); ++iSubgroup) - { - const int subgroupNum = subgroupNums.at(iSubgroup); - if (subgroupNum == 0) - { - ATH_MSG_ERROR("Requested group number 0 as a subgroup, which is forbidden (0 is a simple group)"); - return StatusCode::FAILURE; - } - else if (subgroupsRequested.count(subgroupNum)) - { - ATH_MSG_ERROR(Form("Requested group number %d as a subgroup of multiple complex groups",subgroupNum)); - return StatusCode::FAILURE; - } - else - subgroupsRequested.insert(subgroupNum); - } - complexGroupIndices.push_back(iGroup); - } - else - basicGroupIndices.push_back(iGroup); - } - - // Match indices to each of the requested subgroups - std::vector< std::pair<int,size_t> > subgroupPairs; - for (size_t iGroup = 0; iGroup < m_groups.size(); ++iGroup) - { - const int groupNum = m_groups.at(iGroup)->getGroupNum(); - if (groupNum == 0) continue; - - for (std::set<int>::const_iterator iter = subgroupsRequested.begin(); iter != subgroupsRequested.end(); ++iter) - { - if ( (*iter) == groupNum ) - { - subgroupPairs.push_back(std::make_pair(groupNum,iGroup)); - break; - } - } - } - - // We now have the map of (group-->index) - // Combine all of the groups as applicable - // Leave all of the groups in the class member vector for now until we have completed the merger - for (size_t iCompGroup = 0; iCompGroup < complexGroupIndices.size(); ++iCompGroup) - { - const size_t compGroupIndex = complexGroupIndices.at(iCompGroup); - const std::vector<int> subgroupNums = m_groups.at(compGroupIndex)->getSubgroupNums(); - for (size_t iSubgroupPair = 0; iSubgroupPair < subgroupPairs.size(); ++iSubgroupPair) - { - for (size_t iSubgroup = 0; iSubgroup < subgroupNums.size(); ++iSubgroup) - { - // Ensure we're not adding a cyclic group - if (m_groups.at(compGroupIndex)->getGroupNum() == subgroupNums.at(iSubgroup)) - { - ATH_MSG_ERROR(Form("Blocking the request to add group number %d as a subgroup of itself",subgroupNums.at(iSubgroup))); - return StatusCode::FAILURE; - } - - // Now add the subgroup to the complex group - if (subgroupNums.at(iSubgroup) == subgroupPairs.at(iSubgroupPair).first) - { - if (m_groups.at(compGroupIndex)->addSubgroup(m_groups.at(subgroupPairs.at(iSubgroupPair).second)).isFailure()) - { - ATH_MSG_ERROR(Form("Failed to add subgroup \"%s\" to complex group \"%s\"",m_groups.at(subgroupPairs.at(iSubgroupPair).second)->getName().Data(),m_groups.at(compGroupIndex)->getName().Data())); - } - break; - } - } - } - } - - // Clean up all of the subgroups, leaving only the outermost complex groups and independent groups in the class member variable - // Faster to do it this way rather than deleting individual entries of the vector - std::vector<UncertaintyGroup*> localGroupVec; - for (size_t iGroup = 0; iGroup < m_groups.size(); ++iGroup) - localGroupVec.push_back(m_groups.at(iGroup)); - m_groups.clear(); - for (size_t iGroup = 0; iGroup < localGroupVec.size(); ++iGroup) - { - // Check if this group should be retained - bool retainGroup = true; - for (size_t iSubgroupPair = 0; iSubgroupPair < subgroupPairs.size(); ++iSubgroupPair) - { - if (subgroupPairs.at(iSubgroupPair).second == iGroup) - { - retainGroup = false; - break; - } - } - // Keep the group if applicable - if (retainGroup) - m_groups.push_back(localGroupVec.at(iGroup)); - } - */ - // Initialize all of the groups (and thus all of the components) // Also ensure that there are no empty groups @@ -712,6 +699,26 @@ StatusCode JetUncertaintiesTool::initialize() return StatusCode::FAILURE; } + // Ensure that we have nominal resolutions for any requested resolution uncertainties + // Do this at initialization, even if it is also checked in execution + // Also ensure that it was specified whether this is data or MC if resolutions are specified + for (size_t iGroup = 0; iGroup < m_groups.size(); ++iGroup) + { + std::set<CompScaleVar::TypeEnum> scaleVars = m_groups.at(iGroup)->getScaleVars(); + for (CompScaleVar::TypeEnum var : scaleVars) + { + if (CompScaleVar::isResolutionType(var)) + { + if (!m_resHelper->hasRelevantInfo(var,m_groups.at(iGroup)->getTopology())) + { + ATH_MSG_ERROR("Config file requests a resolution uncertainty without specifying the corresponding nominal resolution: " << CompScaleVar::enumToString(var).Data()); + return StatusCode::FAILURE; + } + } + } + } + + // Ensure that the filters are sane (they are all associated to at least one group) for (size_t iFilter = 0; iFilter < m_systFilters.size(); ++iFilter) { @@ -966,7 +973,12 @@ UncertaintyComponent* JetUncertaintiesTool::buildUncertaintyComponent(const Comp return NULL; } else if (component.parametrization == CompParametrization::PtEta || component.parametrization == CompParametrization::PtAbsEta) - return new FlavourUncertaintyComponent(component,m_jetDef,m_analysisFile,m_path.c_str()); + { + if (component.flavourType == FlavourComp::PerJetResponse) + return new PerJetFlavourUncertaintyComponent(component); + else + return new FlavourUncertaintyComponent(component,m_jetDef,m_analysisFile.c_str(),m_defAnaFile.c_str(),m_path.c_str(),m_calibArea.c_str(),m_analysisHistPattern.c_str()); + } else { ATH_MSG_ERROR(Form("Unexpected parametrization of %s for component %s",CompParametrization::enumToString(component.parametrization).Data(),component.name.Data())); @@ -1012,18 +1024,10 @@ UncertaintyComponent* JetUncertaintiesTool::buildUncertaintyComponent(const Comp CombinedMassUncertaintyComponent* cmuc = new CombinedMassUncertaintyComponent(combComp); // Set the weights - if (cmuc->setCaloWeights(m_caloMassWeight).isFailure()) { - delete cmuc; - return NULL; - } - if (cmuc->setTAWeights(m_TAMassWeight).isFailure()){ - delete cmuc; - return NULL; - } - if (cmuc->setCombWeightMassDefs(m_combMassWeightCaloMassDef,m_combMassWeightTAMassDef).isFailure()){ - delete cmuc; - return NULL; - } + if (cmuc->setCaloWeights(m_caloMassWeight).isFailure()) return NULL; + if (cmuc->setTAWeights(m_TAMassWeight).isFailure()) return NULL; + if (cmuc->setCombWeightMassDefs(m_combMassWeightCaloMassDef,m_combMassWeightTAMassDef).isFailure()) return NULL; + if (cmuc->setCombWeightParam(m_combMassParam).isFailure()) return NULL; if (component.combMassType == CombMassComp::Calo || component.combMassType == CombMassComp::Both) { // Define the calorimeter group if applicable @@ -1047,8 +1051,6 @@ UncertaintyComponent* JetUncertaintiesTool::buildUncertaintyComponent(const Comp if (caloComps.size() != caloMassDefs.size()) { ATH_MSG_ERROR("Unbalanced number of calo mass terms and calo mass definitions, " << caloComps.size() << " vs " << caloMassDefs.size() << " for combined mass component: " << component.name.Data()); - delete cmuc; - delete caloGroup; return NULL; } @@ -1065,8 +1067,6 @@ UncertaintyComponent* JetUncertaintiesTool::buildUncertaintyComponent(const Comp if (caloCompH.massDef == CompMassDef::UNKNOWN) { ATH_MSG_ERROR("Failed to parse calo mass definition " << iComp << " (" << caloMassDefs.at(iComp).Data() << ") for combined mass component: " << component.name.Data()); - delete cmuc; - delete caloGroup; return NULL; } @@ -1106,8 +1106,6 @@ UncertaintyComponent* JetUncertaintiesTool::buildUncertaintyComponent(const Comp if (TAComps.size() != TAMassDefs.size()) { ATH_MSG_ERROR("Unbalanced number of TA mass terms and TA mass definitions, " << TAComps.size() << " vs " << TAMassDefs.size() << " for combined mass component: " << component.name.Data()); - delete TAGroup; - delete cmuc; return NULL; } @@ -1124,8 +1122,6 @@ UncertaintyComponent* JetUncertaintiesTool::buildUncertaintyComponent(const Comp if (TACompH.massDef == CompMassDef::UNKNOWN) { ATH_MSG_ERROR("Failed to parse TA mass definition " << iComp << " (" << TAMassDefs.at(iComp).Data() << ") for combined mass component: " << component.name.Data()); - delete cmuc; - delete TAGroup; return NULL; } @@ -1148,6 +1144,27 @@ UncertaintyComponent* JetUncertaintiesTool::buildUncertaintyComponent(const Comp // Done, return the component return cmuc; } + // Next check large-R topology + else if (component.name.Contains("Large",TString::kIgnoreCase) && component.name.Contains("Topology",TString::kIgnoreCase)) + { + if (component.parametrization == CompParametrization::PtEta || component.parametrization == CompParametrization::PtAbsEta) + { + if (component.LargeRJetTruthLabels.size() > 0) + { + return new LargeRTopologyUncertaintyComponent(component); + } + else + { + ATH_MSG_ERROR(Form("No LargeRJetTruthLabels specified for Large-R jet topology component %s",component.name.Data())); + return NULL; + } + } + else + { + ATH_MSG_ERROR(Form("Unexpected parametrization of %s for component %s",CompParametrization::enumToString(component.parametrization).Data(),component.name.Data())); + return NULL; + } + } else { ATH_MSG_ERROR("Unexpected special component: " << component.name.Data()); @@ -1165,11 +1182,23 @@ UncertaintyComponent* JetUncertaintiesTool::buildUncertaintyComponent(const Comp case CompParametrization::PtEta: case CompParametrization::PtAbsEta: return new PtEtaUncertaintyComponent(component); + case CompParametrization::PtAbsMass: + return new PtAbsMassUncertaintyComponent(component); case CompParametrization::PtMass: return new PtMassUncertaintyComponent(component); + case CompParametrization::PtLOGPtMassForTagSF: + return new PtLogPtMassForTagSFUncertaintyComponent(component); case CompParametrization::PtMassEta: case CompParametrization::PtMassAbsEta: return new PtMassEtaUncertaintyComponent(component); + case CompParametrization::PtAbsMassEta: + case CompParametrization::PtAbsMassAbsEta: + return new PtAbsMassEtaUncertaintyComponent(component); + case CompParametrization::eLOGmOe: + return new ELogMassUncertaintyComponent(component); + case CompParametrization::eLOGmOeEta: + case CompParametrization::eLOGmOeAbsEta: + return new ELogMassEtaUncertaintyComponent(component); default: ATH_MSG_ERROR("Encountered unexpected parameter type: " << component.param.Data()); return NULL; @@ -1557,16 +1586,36 @@ bool JetUncertaintiesTool::getComponentScalesD2Beta1(const size_t index) const if (checkIndexInput(index).isFailure()) return false; return checkScalesSingleVar(m_groups.at(index)->getScaleVars(),CompScaleVar::D2Beta1); } +bool JetUncertaintiesTool::getComponentScalesC2Beta1(const size_t index) const +{ + if (checkIndexInput(index).isFailure()) return false; + return checkScalesSingleVar(m_groups.at(index)->getScaleVars(),CompScaleVar::C2Beta1); +} bool JetUncertaintiesTool::getComponentScalesQw(const size_t index) const { if (checkIndexInput(index).isFailure()) return false; return checkScalesSingleVar(m_groups.at(index)->getScaleVars(),CompScaleVar::Qw); } +bool JetUncertaintiesTool::getComponentScalesTagScaleFactor(const size_t index) const +{ + if (checkIndexInput(index).isFailure()) return false; + return checkScalesSingleVar(m_groups.at(index)->getScaleVars(),CompScaleVar::TagScaleFactor); +} bool JetUncertaintiesTool::getComponentScalesMultiple(const size_t index) const { if (checkIndexInput(index).isFailure()) return false; return m_groups.at(index)->getScaleVars().size() > 1; } +std::set<CompScaleVar::TypeEnum> JetUncertaintiesTool::getComponentScaleVars(const size_t index) const +{ + if (checkIndexInput(index).isFailure()) return std::set<CompScaleVar::TypeEnum>(); + return m_groups.at(index)->getScaleVars(); +} +JetTopology::TypeEnum JetUncertaintiesTool::getComponentTopology(const size_t index) const +{ + if (checkIndexInput(index).isFailure()) return JetTopology::UNKNOWN; + return m_groups.at(index)->getTopology(); +} bool JetUncertaintiesTool::getValidity(size_t index, const xAOD::Jet& jet) const @@ -1723,6 +1772,113 @@ bool JetUncertaintiesTool::getValidUncertainty(size_t index, double& unc, const } +double JetUncertaintiesTool::getNominalResolutionMC(const xAOD::Jet& jet, const CompScaleVar::TypeEnum smearType, const JetTopology::TypeEnum topology) const +{ + return getNominalResolution(jet,smearType,topology,true); +} + +double JetUncertaintiesTool::getNominalResolutionData(const xAOD::Jet& jet, const CompScaleVar::TypeEnum smearType, const JetTopology::TypeEnum topology) const +{ + return getNominalResolution(jet,smearType,topology,false); +} + +double JetUncertaintiesTool::getNominalResolution(const xAOD::Jet& jet, const CompScaleVar::TypeEnum smearType, const JetTopology::TypeEnum topology, const bool readMC) const +{ + if (!m_isInit) + { + ATH_MSG_FATAL("Tool must be initialized before calling getNominalResolution"); + return JESUNC_ERROR_CODE; + } + if (!m_resHelper) + { + ATH_MSG_ERROR("The ResolutionHelper class was not created"); + return JESUNC_ERROR_CODE; + } + + // Get the nominal histogram, parametrization, and mass def (if relevant) from the helper + std::tuple<const UncertaintyHistogram*,CompParametrization::TypeEnum,CompMassDef::TypeEnum> resolution = m_resHelper->getNominalResolution(smearType,topology,readMC); + + // Check that we retrieved them successfully + if (!std::get<0>(resolution) || std::get<1>(resolution) == CompParametrization::UNKNOWN) + return JESUNC_ERROR_CODE; + if (CompParametrization::includesMass(std::get<1>(resolution)) && std::get<2>(resolution) == CompMassDef::UNKNOWN) + { + // We should never reach this, as it was also checked during initialization + ATH_MSG_ERROR("Parametrization involves mass but mass def is unknown"); + return JESUNC_ERROR_CODE; + } + + // Now read the uncertainty from the histogram + return readHistoFromParam(jet,*std::get<0>(resolution),std::get<1>(resolution),std::get<2>(resolution)); +} + + +double JetUncertaintiesTool::readHistoFromParam(const xAOD::Jet& jet, const UncertaintyHistogram& histo, const CompParametrization::TypeEnum param, const jet::CompMassDef::TypeEnum massDef) const +{ + // Simple case (no mass dependence) + if (!CompParametrization::includesMass(param)) + return readHistoFromParam(jet.jetP4(),histo,param); + + // Complex case (need to check the mass type to use) + // Simple four-vector case + if (massDef == CompMassDef::UNKNOWN || massDef == CompMassDef::FourVecMass) + return readHistoFromParam(jet.jetP4(),histo,param); + // Special scale case + JetFourMomAccessor massScaleAccessor(CompMassDef::getJetScaleString(massDef).Data()); + return readHistoFromParam(massScaleAccessor(jet),histo,param); +} + +double JetUncertaintiesTool::readHistoFromParam(const xAOD::JetFourMom_t& jet4vec, const UncertaintyHistogram& histo, const CompParametrization::TypeEnum param) const +{ + double value = 0; + switch (param) + { + case CompParametrization::Pt: + value = histo.getValue(jet4vec.Pt()*m_energyScale); + break; + case CompParametrization::PtEta: + value = histo.getValue(jet4vec.Pt()*m_energyScale,jet4vec.Eta()); + break; + case CompParametrization::PtAbsEta: + value = histo.getValue(jet4vec.Pt()*m_energyScale,fabs(jet4vec.Eta())); + break; + case CompParametrization::PtAbsMass: + value = histo.getValue(jet4vec.Pt()*m_energyScale,jet4vec.M()*m_energyScale); + break; + case CompParametrization::PtMass: + value = histo.getValue(jet4vec.Pt()*m_energyScale,jet4vec.M()/jet4vec.Pt()); + break; + case CompParametrization::PtLOGPtMassForTagSF: + value = histo.getValue(jet4vec.Pt()*m_energyScale,log(jet4vec.M()/jet4vec.Pt())); + break; + case CompParametrization::PtMassEta: + value = histo.getValue(jet4vec.Pt()*m_energyScale,jet4vec.M()/jet4vec.Pt(),jet4vec.Eta()); + break; + case CompParametrization::PtMassAbsEta: + value = histo.getValue(jet4vec.Pt()*m_energyScale,jet4vec.M()/jet4vec.Pt(),fabs(jet4vec.Eta())); + break; + case CompParametrization::PtAbsMassEta: + value = histo.getValue(jet4vec.Pt()*m_energyScale,jet4vec.M()*m_energyScale,jet4vec.Eta()); + break; + case CompParametrization::PtAbsMassAbsEta: + value = histo.getValue(jet4vec.Pt()*m_energyScale,jet4vec.M()*m_energyScale,fabs(jet4vec.Eta())); + break; + case CompParametrization::eLOGmOe: + value = histo.getValue(jet4vec.E()*m_energyScale,log(jet4vec.M()/jet4vec.E())); + break; + case CompParametrization::eLOGmOeEta: + value = histo.getValue(jet4vec.E()*m_energyScale,log(jet4vec.M()/jet4vec.E()),jet4vec.Eta()); + break; + case CompParametrization::eLOGmOeAbsEta: + value = histo.getValue(jet4vec.E()*m_energyScale,log(jet4vec.M()/jet4vec.E()),fabs(jet4vec.Eta())); + break; + default: + ATH_MSG_ERROR("Failed to read histogram due to unknown parametrization type in " << getName()); + break; + } + return value; +} + double JetUncertaintiesTool::getNormalizedCaloMassWeight(const xAOD::Jet& jet) const { @@ -1731,14 +1887,13 @@ double JetUncertaintiesTool::getNormalizedCaloMassWeight(const xAOD::Jet& jet) c static JetFourMomAccessor caloScale (CompMassDef::getJetScaleString(m_combMassWeightCaloMassDef).Data()); static JetFourMomAccessor TAScale (CompMassDef::getJetScaleString(m_combMassWeightTAMassDef).Data()); - - const double caloRes = m_caloMassWeight->getValue(caloScale.pt(jet)*m_energyScale,caloScale.m(jet)/caloScale.pt(jet) ); - const double TARes = m_TAMassWeight->getValue(TAScale.pt(jet)*m_energyScale,TAScale.m(jet)/TAScale.pt(jet)); + const double caloRes = m_caloMassWeight ? readHistoFromParam(caloScale(jet),*m_caloMassWeight,m_combMassParam) : 0; + const double TARes = m_TAMassWeight ? readHistoFromParam(TAScale(jet),*m_TAMassWeight,m_combMassParam) : 0; if (caloRes == 0 || TARes == 0) return 0; - const double caloFactor = 1./(caloRes*caloRes); - const double TAFactor = 1./(TARes*TARes); + const double caloFactor = (caloRes == 0) ? 0 : 1./(caloRes*caloRes); + const double TAFactor = ( TARes == 0) ? 0 : 1./(TARes*TARes); if (caloFactor + TAFactor == 0) return 0; @@ -1905,9 +2060,9 @@ CP::CorrectionCode JetUncertaintiesTool::applyCorrection(xAOD::Jet& jet, const x } // Check for a global validity histogram - if (m_fileValidHist && !m_fileValidHist->getValidity(jet)) + if (m_fileValidHist && !m_fileValidHist->getValidity(jet)){ return CP::CorrectionCode::OutOfValidityRange; - + } // Scale the jet and/or its moments by the uncertainty/uncertainties // Note that uncertainties may be either positive or negative @@ -1932,16 +2087,57 @@ CP::CorrectionCode JetUncertaintiesTool::applyCorrection(xAOD::Jet& jet, const x if (!allValid) return CP::CorrectionCode::OutOfValidityRange; + // Ensure that we don't mix relative and absolute resolution uncertainties of the same type + // Such situations violate the current code structure + std::vector<CompScaleVar::TypeEnum> scaleVars = m_currentUncSet->getScaleVars(); + bool hasMassRes = false; + bool hasPtRes = false; + bool hasFvRes = false; + for (CompScaleVar::TypeEnum var : scaleVars) + { + if (var == CompScaleVar::MassRes || var == CompScaleVar::MassResAbs) + { + if (hasMassRes) + { + ATH_MSG_ERROR("Varying both absolute and relative mass resolution components simultaneously is not supported"); + return CP::CorrectionCode::Error; + } + else + hasMassRes = true; + } + else if (var == CompScaleVar::PtRes || var == CompScaleVar::PtResAbs) + { + if (hasPtRes) + { + ATH_MSG_ERROR("Varying both absolute and relative pT resolution components simultaneously is not supported"); + return CP::CorrectionCode::Error; + } + else + hasPtRes = true; + } + else if (var == CompScaleVar::FourVecRes || var == CompScaleVar::FourVecResAbs) + { + if (hasFvRes) + { + ATH_MSG_ERROR("Varying both absolute and relative four-vector resolution components simultaneously is not supported"); + return CP::CorrectionCode::Error; + } + else + hasFvRes = true; + } + } + // Handle each case as needed for (size_t iVar = 0; iVar < uncSet.size(); ++iVar) { const CompScaleVar::TypeEnum scaleVar = uncSet.at(iVar).first; //const double unc = uncSet.at(iVar).second; const double shift = 1 + uncSet.at(iVar).second; - + const double smear = uncSet.at(iVar).second; // Careful of const vs non-const objects with accessors // Can unintentionally create something new which didn't exist, as jet is non-const + double smearingFactor = 1; switch (scaleVar) { case CompScaleVar::FourVec: @@ -1981,12 +2177,45 @@ CP::CorrectionCode JetUncertaintiesTool::applyCorrection(xAOD::Jet& jet, const x if (updateD2Beta1(jet,shift).isFailure()) return CP::CorrectionCode::Error; break; + case CompScaleVar::C2Beta1: + if (updateC2Beta1(jet,shift).isFailure()) + return CP::CorrectionCode::Error; + break; case CompScaleVar::Qw: if (updateQw(jet,shift).isFailure()) return CP::CorrectionCode::Error; break; + case CompScaleVar::TagScaleFactor: + if (updateTagScaleFactor(jet,shift).isFailure()) + return CP::CorrectionCode::Error; + break; case CompScaleVar::MassRes: - jet.setJetP4(xAOD::JetFourMom_t(jet.pt(),jet.eta(),jet.phi(),getMassSmearingFactor(jet,shift)*jet.m())); + case CompScaleVar::MassResAbs: + if (m_currentUncSet->getTopology() == JetTopology::UNKNOWN) + { + // The JMR requires that there is a topology specified + // (JMR uncertainties are topology-specific) + ATH_MSG_ERROR("Smearing the mass without specifying the topology is not supported"); + return CP::CorrectionCode::Error; + } + if (m_currentUncSet->getTopology() == JetTopology::MIXED) + { + // We can't handle multi-topology JMR uncertainties + ATH_MSG_ERROR("Smearing the mass using multiple topology definitions is not supported"); + return CP::CorrectionCode::Error; + } + smearingFactor = getSmearingFactor(jet,scaleVar,smear); + jet.setJetP4(xAOD::JetFourMom_t(jet.pt(),jet.eta(),jet.phi(),smearingFactor*jet.m())); + break; + case CompScaleVar::PtRes: + case CompScaleVar::PtResAbs: + smearingFactor = getSmearingFactor(jet,scaleVar,smear); + jet.setJetP4(xAOD::JetFourMom_t(smearingFactor*jet.pt(),jet.eta(),jet.phi(),jet.m())); + break; + case CompScaleVar::FourVecRes: + case CompScaleVar::FourVecResAbs: + smearingFactor = getSmearingFactor(jet,scaleVar,smear); + jet.setJetP4(xAOD::JetFourMom_t(smearingFactor*jet.pt(),jet.eta(),jet.phi(),smearingFactor*jet.m())); break; default: ATH_MSG_ERROR("Asked to scale an UNKNOWN variable for set: " << m_currentUncSet->getName()); @@ -2103,35 +2332,156 @@ const xAOD::EventInfo* JetUncertaintiesTool::getDefaultEventInfo() const -// Courtest of Francesco Spano -float JetUncertaintiesTool::getMassSmearingFactor(xAOD::Jet& jet, const double shift) const -{ - //----input discussion--- - // input should the standard deviation of mass response, sigma(M_smear/M_nominal), recover that deviation - // even if it is the fractional deviation of the mass response, it is fine as long as the mass is calibrated - // sigma(M_smear/M_nominal)/<M_smear/M_nominal>~ sigma(M_smear/M_nominal) as <M_smear/M_nominal> ~ 1 - //---- - // the input shift is the fractional resolution + 1--> recover the nominal fractional resolution - // we should have the resolution of the mass response, but - double frac_sigma_nominal = fabs(shift-1); +double JetUncertaintiesTool::getSmearingFactor(const xAOD::Jet& jet, const CompScaleVar::TypeEnum smearType, const double variation) const +{ + /* + Below follows discussion between B Malaescu, C Young, and S Schramm on 14/08/2018 + + sigma_smear^2 = (sigma_nominal + |n*x + m*y + ...|)^2 - (sigma_nominal)^2 + sigma_smear: width of the Gaussian to smear with + sigma_nominal: the nominal resolution in either (pseudo-)data OR mc (see below) + n: #sigma variation for NP1 + m: #sigma variation for NP2 + x: uncertainty from NP1 + y: uncertainty from NP2 + Note that n,m,x,y all are signed quantities + n,m are + for upward variations and - for downward variations + x,y are + or - to differentiate regions of anticorrelations within a given NP + + The source of sigma_nominal depends on what is being smeared + (nx+my+...) > 0 --> smear MC, so use sigma_nominal^MC + (nx+my+...) < 0 --> smear (pseudo-)data, so use sigma_nominal^data + (nx+my+...) = 0 --> no smearing is required + + In some cases, it is not desireable to smear (pseudo-)data + Result: two correlation smearing options, "full" and "simple" + Full = full correlations preserved, smear both (peudo-)data and MC + Simple = simplified correlations (= loss of correlations), smear only MC + + In "simple" case, we are smearing MC even if we should ideally smear (pseudo-)data + sign(nx+my+...) --> no longer matters, always use sigma_nominal^MC + Furthermore, take the absolute value as we are forcing an upward variation + sigma_smear^2 = (sigma_nom^MC + |n*x + m*y + ...|)^2 - (sigma_nom^MC)^2 + In the case of 1 NP, analysis gets same result if n is positive or negative + Analysis must symmetrize uncertainties themselves to get downward variations + + The above is all for absolute resolution uncertainties + In the case of relative resolution uncertainties, not much changes + n*x --> n*sigma_nominal*x + n: unchanged from before, #sigma variation for NP1 + x: now this is a fractional uncertainty, but it is still the value of NP1 + sigma_nominal: uncertainty measurement varies (sign unaffected by nominal) + In other words, all of the above is directly extended + + This all relies on the fact that absolute and relative resolutions are not mixed + This is enforced by the tool enums, which are one or the other + Asking for both relative and absolute smearing is two separate scale variables + The tool checks for such cases and explicitly blocks them + + There is one exception to the above: a "data-MC difference" smearing + If MC is below data, then we smear MC to match data (nominal smearing) + Occurs if (sigma_nom^MC - sigma_nom^data) < 0, or equivalently (sigma_nom^data - sigma_nom^MC) > 0 + If data is below MC, we don't want to degrade the resolution of data to match MC + Occurs if (sigma_nom^MC - sigma_nom^data) > 0, or equivalently (sigma_nom^data - sigma_nom^MC) < 0 + We also can't anti-smear MC (at least not with Gaussian smearing) + Instead, smear by sigma_smear^2 = (sigma_nom + |Nsigma*[sigma_nom^data - sigma_nom^MC]|)^2 - (sigma_nom)^2 + This uses the second form of the above inequalities to stick with convention + This way, we signify that we are smearing data (uncertainty < 0 if Nsigma > 0) + This should be smearing of data (sigma_nom = sigma_nom^data) + However, in the simple scenario, we still only smear MC + Apply the uncertainty as-is, with sigma_nom = sigma_nom^MC + This is actually "conservative" (in magnitude, not necessarily in correlations) + |Nsigma*(sigma_nom^data - sigma_nom^MC)| is a fixed value independent of choice, call it X + sigma_smear^2 = (sigma_nom + X)^2 - (sigma_nom)^2 + sigma_smear^2 = sigma_nom^2 [ (1 + X/sigma_nom)^2 - 1 ] + Taylor expand: sigma_smear^2 ~ sigma_nom^2 ( 1 + 2*X/sigma_nom - 1 ) + sigma_smear^2 ~ sigma_nom^2 * 2 X / sigma_nom + sigma_smear^2 ~ sigma_nom * 2 X + Therefore, larger sigma_nom --> larger sigma_smear + In this case, we know that sigma_nom^MC > sigma_nom^data (motivation for uncertainty) + As such, sigma_nom = sigma_nom^MC is conservative + This does not need to be handled any different than other uncertainties in the code + However, the inputs will need to be made carefully to do the correct thing + In particular, smear data occurs if sign(unc) < 0 + That is why it is written above as (sigma_nom^data - sigma_nom^MC) < 0 + In other words, the histogram must be created to be <= 0 + It should be <0 when data is below MC, and =0 when data is above MC + This *could* be calculated on-the-fly from the two nominal histograms + This requires substantial code development, as now this one NP is different from all others + In the interest of time and code re-use, instead demand an extra histogram input + + In the end, smear by a Gaussian of mean 1 and width sigma_smear + + ---------- + + Given this, the arguments to the function are: + jet: jet to smear, needed for the kinematic dependence of nominal resolutions + smearType: the resolution type to select the relevant nominal resolutions + variation: the signed value of n*x + m*y + ... (for both relative and absolute) + + Dedicated class member variables used by this function are: + m_isData: needed to control whether or not to smear the jet + m_resHelper: contains lots of global resolution information + - Whether to smear MC and data, or only MC + - Nominal resolution histograms for data + - Nominal resolution histograms for MC + - Parametrizations of nominal resolution histograms + m_rand: the random number generator + m_userSeed: the optional user-specified seed to use for the random generator + + Technical detail on relative uncertainties: + The input value of "variation" is always n*x + m*y + ... + This is trivially correct for absolute uncertainties, but not relative + However, for relative uncertainties, all NPs are with respect to same nominal + As such, it factors out, and we can take variation*sigma_nominal^data + Furthermore, as it factors out, the nominal doesn't matter to determine the sign + This is important as the sign sets whether data or MC is the nominal + */ - // Set the seed; same procedure as in JERSmearingTool::getSmearingFactor(const xAOD::Jet* jet, double sigma) - long long int seed = m_userSeed; - if(seed == 0) seed = 1.e+5*std::abs(jet.phi()); - m_rand->SetSeed(seed); + // Check if we need to do anything at all + if (variation == 0) + return 1; // No smearing if the variation is 0 + else if (m_isData) + { + if (m_resHelper->smearOnlyMC()) + return 1; // No smearing if this is data and we are in the simple scenario + if (variation > 0) + return 1; // No smearing if this is data and the sign says to smear MC + } + else if (variation < 0 && !m_resHelper->smearOnlyMC()) + return 1; // No smearing if this is MC and the sign says to smear data and this is not the simple scenario - // get the Gaussian random number associated to the relative resolution - // 1st way : a la JetRes use a relative standard deviation - // FIXME: for the moment the additional smearing is hardcoded: it will have to change in the future as a kinematic dependent function - double smearingFact1=m_rand->Gaus(1.,0.66*frac_sigma_nominal); + // Figure out which resolution is nominal (MC or data) + const bool nominalIsMC = (m_resHelper->smearOnlyMC() || variation > 0); + + // Get the relevant nominal resolution + const double sigmaNom = getNominalResolution(jet,smearType,m_currentUncSet->getTopology(),nominalIsMC); + + // If this is a relative uncertainty, get the relevant nominal data histogram + // This is used to scale the input relative variation to get the absolute impact + const double relativeFactor = CompScaleVar::isRelResolutionType(smearType) ? sigmaNom : 1; + + // We now have the required information, so let's calculate the smearing factor + // Note that relativeFactor is 1 if this is an absolute uncertainty + const double sigmaSmear = sqrt(pow(sigmaNom + fabs(variation)*relativeFactor,2) - pow(sigmaNom,2)); - // 2nd alternative way : use the relative standard deviation - // const double GaussZeroOne = m_rand->Gaus(0.,1.); - // double smearingFact2=1+0.66*GaussZeroOne*frac_sigma_nominal; - double smearingFact=smearingFact1; + // We have the smearing factor, so prepare to smear + // If the user specified a seed, then use it + // If not, then use the jet's phi times 1*10^5 in MC, 1.23*10^5 in (pseudo-)data + // Difference in seed between allows for easy use of pseudo-data + long long int seed = m_userSeed != 0 ? m_userSeed : (m_isData ? 1.23e+5 : 1.00e+5)*fabs(jet.phi()); + // SetSeed(0) uses the clock, avoid this + if(seed == 0) seed = m_isData ? 34545654 : 45583453; // arbitrary numbers which the seed couldn't otherwise be + m_rand.SetSeed(seed); - return smearingFact; + // Calculate and return the smearing factor + // Force this to be a positive value + // Negative values should be extraordinarily rare, but they do exist + double smearingFactor = -1; + while (smearingFactor < 0) + smearingFactor = m_rand.Gaus(1.,sigmaSmear); + return smearingFactor; } @@ -2478,6 +2828,45 @@ StatusCode JetUncertaintiesTool::updateD2Beta1(xAOD::Jet& jet, const double shif return StatusCode::FAILURE; } +StatusCode JetUncertaintiesTool::updateC2Beta1(xAOD::Jet& jet, const double shift) const +{ + static SG::AuxElement::Accessor<float> accC2("C2"); + static SG::AuxElement::Accessor<float> accECF1("ECF1"); + static SG::AuxElement::Accessor<float> accECF2("ECF2"); + static SG::AuxElement::Accessor<float> accECF3("ECF3"); + const static bool C2wasAvailable = accC2.isAvailable(jet); + const static bool ECFwasAvailable = accECF1.isAvailable(jet) && accECF2.isAvailable(jet) && accECF3.isAvailable(jet); + + const xAOD::Jet& constJet = jet; + if (C2wasAvailable) + { + if (!accC2.isAvailable(jet)) + { + ATH_MSG_ERROR("The C2 moment was previously available but is not available on this jet. This functionality is not supported."); + return StatusCode::FAILURE; + } + const float value = accC2(constJet); + accC2(jet) = shift*value; + return StatusCode::SUCCESS; + } + if (ECFwasAvailable) + { + if (! (accECF1.isAvailable(constJet) && accECF2.isAvailable(constJet) && accECF3.isAvailable(constJet)) ) + { + ATH_MSG_ERROR("The ECF1, ECF2, and ECF3 moments were previously available but are not available on this jet. This functionality is not supported."); + return StatusCode::FAILURE; + } + const float ecf1 = accECF1(constJet); + const float ecf2 = accECF2(constJet); + const float ecf3 = accECF3(constJet); + accC2(jet) = fabs(ecf2) > 1.e-6 ? shift * (ecf3*ecf1/pow(ecf2,2)) : -999; // 999 to match JetSubStructureMomentTools/EnergyCorrelatorRatiosTool + return StatusCode::SUCCESS; + } + + ATH_MSG_ERROR("Neither C2 nor ECF1+ECF2+ECF3 moments are available on the jet, please make sure one of these options is available before calling the tool"); + return StatusCode::FAILURE; +} + StatusCode JetUncertaintiesTool::updateQw(xAOD::Jet& jet, const double shift) const { static SG::AuxElement::Accessor<float> accQw("Qw"); @@ -2494,6 +2883,58 @@ StatusCode JetUncertaintiesTool::updateQw(xAOD::Jet& jet, const double shift) co return StatusCode::FAILURE; } +StatusCode JetUncertaintiesTool::updateTagScaleFactor(xAOD::Jet& jet, const double shift) const +{ + const bool TagScaleFactorwasAvailable = m_accTagScaleFactor.isAvailable(jet); + const xAOD::Jet& constJet = jet; + if (TagScaleFactorwasAvailable) + { + if (!m_accTagScaleFactor.isAvailable(jet)) + { + ATH_MSG_ERROR("TagScaleFactor was previously available but is not available on this jet. This functionality is not supported."); + return StatusCode::FAILURE; + } + const float value = m_accTagScaleFactor(constJet); + if (m_accEffSF.isAvailable(jet)) { + // if efficiency and efficiency SF are available, inefficiency SF will be calculated + const float effSF = m_accEffSF(constJet); + const float efficiency = m_accEfficiency(constJet); + if ( value == effSF ){ + // this jet is "tagged" since SF applied to the event is equal to effSF + if ( shift*value < 0.0 ){ + m_accTagScaleFactor(jet) = 0.0; + } else { + m_accTagScaleFactor(jet) = shift*value; + } + return StatusCode::SUCCESS; + } else { + // this jet is "failed", since SF applied to the event is (1-effSF*efficiency)/(1-efficiency) + // so inefficiency SF will be recalculated for given uncertainty + if ( efficiency < 1.0 ){ + if ( shift*value < 0.0 ){ + m_accTagScaleFactor(jet) = 1.0/(1. - efficiency); + } else { + m_accTagScaleFactor(jet) = (1. - shift*effSF*efficiency) / (1. - efficiency); + } + } + return StatusCode::SUCCESS; + } + } else { + // if efficiency and efficiency SF are NOT available, inefficiency SF will not be calculated + + if ( shift*value < 0.0 ){ + m_accTagScaleFactor(jet) = 0.0; + } else { + m_accTagScaleFactor(jet) = shift*value; + } + return StatusCode::SUCCESS; + } + } + + ATH_MSG_ERROR("TagScaleFactor is not available on the jet, please make sure you called BoostedJetTaggers tag() function before calling this function."); + return StatusCode::FAILURE; +} + diff --git a/Reconstruction/Jet/JetUncertainties/Root/LargeRTopologyUncertaintyComponent.cxx b/Reconstruction/Jet/JetUncertainties/Root/LargeRTopologyUncertaintyComponent.cxx new file mode 100644 index 0000000000000000000000000000000000000000..88dd4ae88ab862f0024e3981a6526b3d436c14a9 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/Root/LargeRTopologyUncertaintyComponent.cxx @@ -0,0 +1,83 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "JetUncertainties/LargeRTopologyUncertaintyComponent.h" +#include "JetUncertainties/Helpers.h" + +namespace jet +{ + +////////////////////////////////////////////////// +// // +// Constructor/destructor/initialization // +// // +////////////////////////////////////////////////// + +LargeRTopologyUncertaintyComponent::LargeRTopologyUncertaintyComponent(const std::string& name) + : UncertaintyComponent(ComponentHelper(name)) + , m_absEta(false) + , m_truthLabelName("") + , m_truthLabels() +{ + JESUNC_NO_DEFAULT_CONSTRUCTOR; +} + +LargeRTopologyUncertaintyComponent::LargeRTopologyUncertaintyComponent(const ComponentHelper& component) + : UncertaintyComponent(component) + , m_absEta(CompParametrization::isAbsEta(component.parametrization)) + , m_truthLabelName(component.LargeRJetTruthLabelName) + , m_truthLabels(component.LargeRJetTruthLabels) +{ + ATH_MSG_DEBUG(Form("Creating LargeRTopologyUncertaintyComponent named %s",m_uncHistName.Data())); +} + +LargeRTopologyUncertaintyComponent::LargeRTopologyUncertaintyComponent(const LargeRTopologyUncertaintyComponent& toCopy) + : UncertaintyComponent(toCopy) + , m_absEta(toCopy.m_absEta) + , m_truthLabelName(toCopy.m_truthLabelName) + , m_truthLabels(toCopy.m_truthLabels) +{ + ATH_MSG_DEBUG(Form("Creating copy of LargeRTopologyUncertaintyComponent named %s",m_uncHistName.Data())); +} + +LargeRTopologyUncertaintyComponent* LargeRTopologyUncertaintyComponent::clone() const +{ + return new LargeRTopologyUncertaintyComponent(*this); +} + + +////////////////////////////////////////////////// +// // +// Validity and uncertainty retrieval // +// // +////////////////////////////////////////////////// + +bool LargeRTopologyUncertaintyComponent::getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo&) const +{ + return !m_validHist ? true : getValidBool(m_validHist->getValue(jet.pt()*m_energyScale,m_absEta ? fabs(jet.eta()) : jet.eta())); +} + +double LargeRTopologyUncertaintyComponent::getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo&) const +{ + // Retrieve the truth jet label from the jet + static const SG::AuxElement::ConstAccessor<int> accTruthLabel(m_truthLabelName); + if (!accTruthLabel.isAvailable(jet) || accTruthLabel(jet) == LargeRJetTruthLabel::UNKNOWN) + { + ATH_MSG_ERROR("Unable to retrieve the LargeRJetTruthLabel: " << m_truthLabelName << " from the jet. Please use JetTruthLabelingTool before calling this function."); + return JESUNC_ERROR_CODE; + } + const LargeRJetTruthLabel::TypeEnum jetTruthLabel = LargeRJetTruthLabel::intToEnum(accTruthLabel(jet)); + + // We now have the truth jet label, check if it matches one of the label(s) assigned to this component + // The uncertainty is only applied to same-labelled jets (zero otherwise) + for (const LargeRJetTruthLabel::TypeEnum aLabel : m_truthLabels) + { + if (aLabel == jetTruthLabel) + return m_uncHist->getValue(jet.pt()*m_energyScale,m_absEta ? fabs(jet.eta()) : jet.eta()); + } + return 0; +} + +} // end jet namespace + diff --git a/Reconstruction/Jet/JetUncertainties/Root/PerJetFlavourUncertaintyComponent.cxx b/Reconstruction/Jet/JetUncertainties/Root/PerJetFlavourUncertaintyComponent.cxx new file mode 100644 index 0000000000000000000000000000000000000000..32e6f04de40544b345e313e8a71f46670a10772f --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/Root/PerJetFlavourUncertaintyComponent.cxx @@ -0,0 +1,144 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#include "JetUncertainties/PerJetFlavourUncertaintyComponent.h" +#include "JetUncertainties/Helpers.h" + +namespace jet +{ + +////////////////////////////////////////////////// +// // +// Constructor/destructor/initialization // +// // +////////////////////////////////////////////////// + +PerJetFlavourUncertaintyComponent::PerJetFlavourUncertaintyComponent(const std::string& name) + : UncertaintyComponent(ComponentHelper(name),0) + , m_absEta(false) + , m_labels() +{ + JESUNC_NO_DEFAULT_CONSTRUCTOR; +} + +PerJetFlavourUncertaintyComponent::PerJetFlavourUncertaintyComponent(const ComponentHelper& component) + : UncertaintyComponent(component,1) + , m_absEta(CompParametrization::isAbsEta(component.parametrization)) + , m_labels(component.truthLabels) +{ + ATH_MSG_DEBUG("Created PerJetFlavourUncertaintyComponent named " << m_uncHistName.Data()); +} + +PerJetFlavourUncertaintyComponent::PerJetFlavourUncertaintyComponent(const PerJetFlavourUncertaintyComponent& toCopy) + : UncertaintyComponent(toCopy) + , m_absEta(toCopy.m_absEta) + , m_labels(toCopy.m_labels) +{ + ATH_MSG_DEBUG("Creating copy of PerJetFlavourUncertaintyComponent named " << m_uncHistName.Data()); +} + +PerJetFlavourUncertaintyComponent* PerJetFlavourUncertaintyComponent::clone() const +{ + return new PerJetFlavourUncertaintyComponent(*this); +} + +StatusCode PerJetFlavourUncertaintyComponent::initialize(TFile* histFile) +{ + // Call the base class first + if (UncertaintyComponent::initialize(histFile).isFailure()) + return StatusCode::FAILURE; + + // Ensure that the labels are sane + if (!m_labels.size()) + { + ATH_MSG_ERROR("Specified a PerJetFlavourUncertaintyComponent without the associated labels to use: " << getName().Data()); + return StatusCode::FAILURE; + } + for (int aLabel : m_labels) + { + if (!isSupportedLabel(aLabel)) + { + ATH_MSG_ERROR("Unsupported label ID of " << aLabel << " in " << getName().Data()); + return StatusCode::FAILURE; + } + } + + // Done checking the configuration + return StatusCode::SUCCESS; +} + + +////////////////////////////////////////////////// +// // +// Validity and uncertainty retrieval // +// // +////////////////////////////////////////////////// + +bool PerJetFlavourUncertaintyComponent::getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo&) const +{ + return !m_validHist ? true : getValidBool(m_validHist->getValue(jet.pt()*m_energyScale,m_absEta ? fabs(jet.eta()) : jet.eta())); +} + +double PerJetFlavourUncertaintyComponent::getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const +{ + return getFlavourResponseUncertainty(jet,eInfo); +} + +double PerJetFlavourUncertaintyComponent::getFlavourResponseUncertainty(const xAOD::Jet& jet, const xAOD::EventInfo&) const +{ + // sigma_x = l_x * dR_x(x response modelling uncertainty) + // sigma_x is the flavour response uncertainty for jet type x + // l_x is the jet flavour label, and is 0 or 1 + // dR_x is the response modelling uncertainty for jets of type x + // dR_x is typically taken as the difference in x response between Pythia and Herwig + + // Check the jet label (is this uncertainty relevant?) + if (!checkTruthLabel(jet)) + return 0; + + // This is a jet of the relevant type + // Now calculate and return the uncertainty + const double pT = jet.pt()*m_energyScale; + const double eta = m_absEta ? fabs(jet.eta()) : jet.eta(); + + // Return the uncertainty + return m_uncHist->getValue(pT,eta); +} + + + +bool PerJetFlavourUncertaintyComponent::isSupportedLabel(const int label) const +{ + switch (abs(label)) + { + case 1: // parton-label, up + case 2: // parton-label, down + case 3: // parton-label, strange + case 4: // parton-label, charm + case 5: // parton-label, bottom + case 21: // parton-label, gluon + return true; + default: + return false; + } +} + +bool PerJetFlavourUncertaintyComponent::checkTruthLabel(const xAOD::Jet& jet) const +{ + static SG::AuxElement::ConstAccessor<int> truthLabelAccessor ("PartonTruthLabelID"); + if (!truthLabelAccessor.isAvailable(jet)) + { + ATH_MSG_ERROR("Unable to find PartonTruthLabelID on the jet"); + return JESUNC_ERROR_CODE; + } + const int truthHighestEparton = abs(truthLabelAccessor(jet)); + + for (const int label : m_labels) + if (label == truthHighestEparton) + return true; + return false; +} + +} // end jet namespace + diff --git a/Reconstruction/Jet/JetUncertainties/Root/PileupUncertaintyComponent.cxx b/Reconstruction/Jet/JetUncertainties/Root/PileupUncertaintyComponent.cxx index b32e4eec438f87f4f92c13a2eecb8eac5b23ebfa..980e8d6c09648b6cdfd60ac67f0a611b64ea863d 100644 --- a/Reconstruction/Jet/JetUncertainties/Root/PileupUncertaintyComponent.cxx +++ b/Reconstruction/Jet/JetUncertainties/Root/PileupUncertaintyComponent.cxx @@ -193,12 +193,12 @@ StatusCode PileupUncertaintyComponent::initialize(TFile* histFile) m_refType = PileupRef_NONE; else if (m_pileupType == PileupComp::PtTerm) { - if (m_uncHistName.Contains("NPV") && m_secondUncName.Contains("Mu")) + if (m_uncHistName.Contains("NPV",TString::kIgnoreCase) && m_secondUncName.Contains("Mu",TString::kIgnoreCase)) { m_refType = PileupRef_NPV; m_secondRefType = PileupRef_MU; } - else if (m_uncHistName.Contains("Mu") && m_secondUncName.Contains("NPV")) + else if (m_uncHistName.Contains("Mu",TString::kIgnoreCase) && m_secondUncName.Contains("NPV",TString::kIgnoreCase)) { m_refType = PileupRef_MU; m_secondRefType = PileupRef_NPV; diff --git a/Reconstruction/Jet/JetUncertainties/Root/PtAbsMassEtaUncertaintyComponent.cxx b/Reconstruction/Jet/JetUncertainties/Root/PtAbsMassEtaUncertaintyComponent.cxx new file mode 100644 index 0000000000000000000000000000000000000000..45a62ee282859d6edab227e563c2a2889ac5ddc1 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/Root/PtAbsMassEtaUncertaintyComponent.cxx @@ -0,0 +1,65 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "JetUncertainties/PtAbsMassEtaUncertaintyComponent.h" +#include "JetUncertainties/Helpers.h" + +namespace jet +{ + +////////////////////////////////////////////////// +// // +// Constructor/destructor/initialization // +// // +////////////////////////////////////////////////// + +PtAbsMassEtaUncertaintyComponent::PtAbsMassEtaUncertaintyComponent(const std::string& name) + : UncertaintyComponent(ComponentHelper(name)) + , m_absEta(false) + , m_massDef(CompMassDef::UNKNOWN) +{ + JESUNC_NO_DEFAULT_CONSTRUCTOR; +} + +PtAbsMassEtaUncertaintyComponent::PtAbsMassEtaUncertaintyComponent(const ComponentHelper& component) + : UncertaintyComponent(component) + , m_absEta(CompParametrization::isAbsEta(component.parametrization)) + , m_massDef(component.massDef) +{ + ATH_MSG_DEBUG(Form("Creating PtAbsMassEtaUncertaintyComponent named %s",m_uncHistName.Data())); +} + +PtAbsMassEtaUncertaintyComponent::PtAbsMassEtaUncertaintyComponent(const PtAbsMassEtaUncertaintyComponent& toCopy) + : UncertaintyComponent(toCopy) + , m_absEta(toCopy.m_absEta) + , m_massDef(toCopy.m_massDef) +{ + ATH_MSG_DEBUG(Form("Creating copy of PtAbsMassEtaUncertaintyComponent named %s",m_uncHistName.Data())); +} + +PtAbsMassEtaUncertaintyComponent* PtAbsMassEtaUncertaintyComponent::clone() const +{ + return new PtAbsMassEtaUncertaintyComponent(*this); +} + + +////////////////////////////////////////////////// +// // +// Validity and uncertainty retrieval // +// // +////////////////////////////////////////////////// + +bool PtAbsMassEtaUncertaintyComponent::getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo&) const +{ + return !m_validHist ? true : getValidBool(m_validHist->getValue(jet.pt()*m_energyScale,getAbsMass(jet,m_massDef)*m_energyScale,m_absEta ? fabs(jet.eta()) : jet.eta())); +} + +double PtAbsMassEtaUncertaintyComponent::getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo&) const +{ + return m_uncHist->getValue(jet.pt()*m_energyScale,getAbsMass(jet,m_massDef)*m_energyScale,m_absEta ? fabs(jet.eta()) : jet.eta()); +} + +} // end jet namespace + + diff --git a/Reconstruction/Jet/JetUncertainties/Root/PtAbsMassUncertaintyComponent.cxx b/Reconstruction/Jet/JetUncertainties/Root/PtAbsMassUncertaintyComponent.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ead08c44790fb3cfb2c3d53b7a16f0a2c9668a72 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/Root/PtAbsMassUncertaintyComponent.cxx @@ -0,0 +1,62 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "JetUncertainties/PtAbsMassUncertaintyComponent.h" +#include "JetUncertainties/Helpers.h" + +namespace jet +{ + +////////////////////////////////////////////////// +// // +// Constructor/destructor/initialization // +// // +////////////////////////////////////////////////// + +PtAbsMassUncertaintyComponent::PtAbsMassUncertaintyComponent(const std::string& name) + : UncertaintyComponent(ComponentHelper(name)) + , m_massDef(CompMassDef::UNKNOWN) +{ + JESUNC_NO_DEFAULT_CONSTRUCTOR; +} + +PtAbsMassUncertaintyComponent::PtAbsMassUncertaintyComponent(const ComponentHelper& component) + : UncertaintyComponent(component) + , m_massDef(component.massDef) +{ + ATH_MSG_DEBUG(Form("Creating PtAbsMassUncertaintyComponent named %s",m_uncHistName.Data())); +} + +PtAbsMassUncertaintyComponent::PtAbsMassUncertaintyComponent(const PtAbsMassUncertaintyComponent& toCopy) + : UncertaintyComponent(toCopy) + , m_massDef(toCopy.m_massDef) +{ + ATH_MSG_DEBUG(Form("Creating copy of PtAbsMassUncertaintyComponent named %s",m_uncHistName.Data())); +} + +PtAbsMassUncertaintyComponent* PtAbsMassUncertaintyComponent::clone() const +{ + return new PtAbsMassUncertaintyComponent(*this); +} + + +////////////////////////////////////////////////// +// // +// Validity and uncertainty retrieval // +// // +////////////////////////////////////////////////// + +bool PtAbsMassUncertaintyComponent::getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo&) const +{ + return !m_validHist ? true : getValidBool(m_validHist->getValue(jet.pt()*m_energyScale,getAbsMass(jet,m_massDef)*m_energyScale)); +} + +double PtAbsMassUncertaintyComponent::getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo&) const +{ + return m_uncHist->getValue(jet.pt()*m_energyScale,getAbsMass(jet,m_massDef)*m_energyScale); +} + +} // end jet namespace + + diff --git a/Reconstruction/Jet/JetUncertainties/Root/PtLogPtMassForTagSFUncertaintyComponent.cxx b/Reconstruction/Jet/JetUncertainties/Root/PtLogPtMassForTagSFUncertaintyComponent.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a48f48cd2707e525ec67bf0f77a929e4df427f1c --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/Root/PtLogPtMassForTagSFUncertaintyComponent.cxx @@ -0,0 +1,132 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +#include "JetUncertainties/PtLogPtMassForTagSFUncertaintyComponent.h" +#include "JetUncertainties/Helpers.h" + +// TODO: enable when BoostedJetTaggers are available +// #include "BoostedJetTaggers/TagResultEnum.h" +namespace jet +{ + +////////////////////////////////////////////////// +// // +// Constructor/destructor/initialization // +// // +////////////////////////////////////////////////// + +PtLogPtMassForTagSFUncertaintyComponent::PtLogPtMassForTagSFUncertaintyComponent(const std::string& name) + : UncertaintyComponent(ComponentHelper(name)) + , m_massDef(CompMassDef::UNKNOWN) + , m_labels() + , m_largeRJetTruthLabelName("") + , m_region() + , m_result_name() +{ + JESUNC_NO_DEFAULT_CONSTRUCTOR; +} + +PtLogPtMassForTagSFUncertaintyComponent::PtLogPtMassForTagSFUncertaintyComponent(const ComponentHelper& component) + : UncertaintyComponent(component) + , m_massDef(component.massDef) + , m_labels(component.LargeRJetTruthLabelsForSF) + , m_largeRJetTruthLabelName(component.LargeRJetTruthLabelName) + , m_region(component.RegionForSF) + , m_result_name(component.ResultName) +{ + ATH_MSG_DEBUG(Form("Creating PtLogPtMassForTagSFUncertaintyComponent named %s",m_uncHistName.Data())); +} + +PtLogPtMassForTagSFUncertaintyComponent::PtLogPtMassForTagSFUncertaintyComponent(const PtLogPtMassForTagSFUncertaintyComponent& toCopy) + : UncertaintyComponent(toCopy) + , m_massDef(toCopy.m_massDef) + , m_labels(toCopy.m_labels) + , m_largeRJetTruthLabelName(toCopy.m_largeRJetTruthLabelName) + , m_region(toCopy.m_region) + , m_result_name(toCopy.m_result_name) +{ + ATH_MSG_DEBUG(Form("Creating copy of PtLogPtMassForTagSFUncertaintyComponent named %s",m_uncHistName.Data())); +} + +PtLogPtMassForTagSFUncertaintyComponent* PtLogPtMassForTagSFUncertaintyComponent::clone() const +{ + return new PtLogPtMassForTagSFUncertaintyComponent(*this); +} + + +////////////////////////////////////////////////// +// // +// Validity and uncertainty retrieval // +// // +////////////////////////////////////////////////// + +bool PtLogPtMassForTagSFUncertaintyComponent::getValidityImpl(const xAOD::Jet& jet, const xAOD::EventInfo&) const +{ + return !m_validHist ? true : getValidBool(m_validHist->getValue(jet.pt()*m_energyScale,log(getMassOverPt(jet,m_massDef)))); +} + +double PtLogPtMassForTagSFUncertaintyComponent::getUncertaintyImpl(const xAOD::Jet& jet, const xAOD::EventInfo&) const +{ + static const SG::AuxElement::Accessor<int> accLabel(m_largeRJetTruthLabelName); + if ( !accLabel.isAvailable(jet) ){ + ATH_MSG_ERROR("LargeRJetTruthLabel: " << m_largeRJetTruthLabelName << " is not decorrated to the jet. Please use JetTruthLabelingTool before calling this function."); + return JESUNC_ERROR_CODE; + } + int jetFlavorLabelInt=accLabel(jet); + LargeRJetTruthLabel::TypeEnum jetFlavorLabel=LargeRJetTruthLabel::intToEnum(jetFlavorLabelInt); + + float mOverPt=jet.m()/jet.pt(); + if ( m_result_name!="" ) { + // currently only TCC 2var tagger uses JESComponent.X.RegionForSF method, which correspont to m_region!="". + + // TODO: enable when BoostedJetTaggers are available + /* + SG::AuxElement::ConstAccessor<int> accResult(m_result_name.Data()); + if ( !accResult.isAvailable(jet) ){ + ATH_MSG_ERROR(m_result_name+" is not decorated to the jet."); + } else { + TagResult::TypeEnum myCutResult=TagResult::intToEnum(accResult(jet)); + if ( m_region==CompTaggerRegionVar::passMpassD2_2Var || + m_region==CompTaggerRegionVar::passMfailD2_2Var || + m_region==CompTaggerRegionVar::failMpassD2_2Var || + m_region==CompTaggerRegionVar::failMfailD2_2Var) { + // TCC 2Var tagger + if ( m_result_name.Contains("SmoothZ") ){ + // to apply W-tagging efficiency SF to Z-tagger, jet mass is shifted by 10GeV + const double WtoZmassShift = 10803; + mOverPt=(jet.m()-WtoZmassShift)/jet.pt(); + } + if ( ! ((myCutResult==TagResult::passMpassD2_2Var && m_region==CompTaggerRegionVar::passMpassD2_2Var) || + (myCutResult==TagResult::passMfailD2_2Var && m_region==CompTaggerRegionVar::passMfailD2_2Var) || + (myCutResult==TagResult::failMpassD2_2Var && m_region==CompTaggerRegionVar::failMpassD2_2Var) || + (myCutResult==TagResult::failMfailD2_2Var && m_region==CompTaggerRegionVar::failMfailD2_2Var)) ){ + return 0.0; + } + } else { + ATH_MSG_ERROR("RegionForSF is specified in the config file, but it is not available for this tagger."); + return 0.0; + } + } + */ + } + + bool isValidLabel=false; + for ( CompFlavorLabelVar::TypeEnum label : m_labels ) { + if ( (label==CompFlavorLabelVar::t_qqb && jetFlavorLabel==LargeRJetTruthLabel::tqqb) || + (label==CompFlavorLabelVar::t && (jetFlavorLabel==LargeRJetTruthLabel::tqqb || jetFlavorLabel==LargeRJetTruthLabel::other_From_t)) || + (label==CompFlavorLabelVar::t_other && (jetFlavorLabel==LargeRJetTruthLabel::Wqq_From_t || jetFlavorLabel==LargeRJetTruthLabel::other_From_t)) || + (label==CompFlavorLabelVar::V_qq && (jetFlavorLabel==LargeRJetTruthLabel::Wqq || jetFlavorLabel==LargeRJetTruthLabel::Zqq || jetFlavorLabel==LargeRJetTruthLabel::Wqq_From_t)) || + (label==CompFlavorLabelVar::W_qq_From_t && jetFlavorLabel==LargeRJetTruthLabel::Wqq_From_t) || + (label==CompFlavorLabelVar::W_qq && jetFlavorLabel==LargeRJetTruthLabel::Wqq) || + (label==CompFlavorLabelVar::Z_qq && jetFlavorLabel==LargeRJetTruthLabel::Zqq) || + (label==CompFlavorLabelVar::q && (jetFlavorLabel==LargeRJetTruthLabel::notruth || jetFlavorLabel==LargeRJetTruthLabel::qcd || jetFlavorLabel==LargeRJetTruthLabel::other_From_V)) ) { + isValidLabel=true; + } + } + if (!isValidLabel) return 0.0;// if the type of uncertainty is not match to the jet truth label, return 0% uncertainty + return m_uncHist->getValue(jet.pt()*m_energyScale,log(mOverPt)); +} + +} // end jet namespace + diff --git a/Reconstruction/Jet/JetUncertainties/Root/ResolutionHelper.cxx b/Reconstruction/Jet/JetUncertainties/Root/ResolutionHelper.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4279024da6d7a3f07634e4fc6ae8287df32e5475 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/Root/ResolutionHelper.cxx @@ -0,0 +1,539 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + + +#include "JetUncertainties/ResolutionHelper.h" +#include "JetUncertainties/Helpers.h" + +#include "TEnv.h" +#include "TFile.h" + +#include <stdexcept> + +namespace jet +{ + +ResolutionHelper::ResolutionHelper(const std::string& name, const std::string& jetDef) + : asg::AsgMessaging(name) + , m_name(name) + , m_jetDef(jetDef) + , m_isInit(false) + , m_smearOnlyMC(false) + , m_ptNomHistData(NULL) + , m_ptNomParamData(CompParametrization::UNKNOWN) + , m_ptNomMassDefData(CompMassDef::UNKNOWN) + , m_ptNomHistMC(NULL) + , m_ptNomParamMC(CompParametrization::UNKNOWN) + , m_ptNomMassDefMC(CompMassDef::UNKNOWN) + , m_fvNomHistData(NULL) + , m_fvNomParamData(CompParametrization::UNKNOWN) + , m_fvNomMassDefData(CompMassDef::UNKNOWN) + , m_fvNomHistMC(NULL) + , m_fvNomParamMC(CompParametrization::UNKNOWN) + , m_fvNomMassDefMC(CompMassDef::UNKNOWN) + , m_mQCDNomHistData(NULL) + , m_mQCDNomParamData(CompParametrization::UNKNOWN) + , m_mQCDNomMassDefData(CompMassDef::UNKNOWN) + , m_mQCDNomHistMC(NULL) + , m_mQCDNomParamMC(CompParametrization::UNKNOWN) + , m_mQCDNomMassDefMC(CompMassDef::UNKNOWN) + , m_mWZNomHistData(NULL) + , m_mWZNomParamData(CompParametrization::UNKNOWN) + , m_mWZNomMassDefData(CompMassDef::UNKNOWN) + , m_mWZNomHistMC(NULL) + , m_mWZNomParamMC(CompParametrization::UNKNOWN) + , m_mWZNomMassDefMC(CompMassDef::UNKNOWN) + , m_mHbbNomHistData(NULL) + , m_mHbbNomParamData(CompParametrization::UNKNOWN) + , m_mHbbNomMassDefData(CompMassDef::UNKNOWN) + , m_mHbbNomHistMC(NULL) + , m_mHbbNomParamMC(CompParametrization::UNKNOWN) + , m_mHbbNomMassDefMC(CompMassDef::UNKNOWN) + , m_mTopNomHistData(NULL) + , m_mTopNomParamData(CompParametrization::UNKNOWN) + , m_mTopNomMassDefData(CompMassDef::UNKNOWN) + , m_mTopNomHistMC(NULL) + , m_mTopNomParamMC(CompParametrization::UNKNOWN) + , m_mTopNomMassDefMC(CompMassDef::UNKNOWN) +{ } + +ResolutionHelper::ResolutionHelper(const ResolutionHelper& toCopy) + : asg::AsgMessaging(toCopy.m_name) + , m_name(toCopy.m_name) + , m_jetDef(toCopy.m_jetDef) + , m_isInit(toCopy.m_isInit) + , m_smearOnlyMC(toCopy.m_smearOnlyMC) + , m_ptNomHistData(!toCopy.m_ptNomHistData ? NULL : new UncertaintyHistogram(*toCopy.m_ptNomHistData)) + , m_ptNomParamData(toCopy.m_ptNomParamData) + , m_ptNomMassDefData(toCopy.m_ptNomMassDefData) + , m_ptNomHistMC(!toCopy.m_ptNomHistMC ? NULL : new UncertaintyHistogram(*toCopy.m_ptNomHistMC)) + , m_ptNomParamMC(toCopy.m_ptNomParamMC) + , m_ptNomMassDefMC(toCopy.m_ptNomMassDefMC) + , m_fvNomHistData(!toCopy.m_fvNomHistData ? NULL : new UncertaintyHistogram(*toCopy.m_fvNomHistData)) + , m_fvNomParamData(toCopy.m_fvNomParamData) + , m_fvNomMassDefData(toCopy.m_fvNomMassDefData) + , m_fvNomHistMC(!toCopy.m_fvNomHistMC ? NULL : new UncertaintyHistogram(*toCopy.m_fvNomHistMC)) + , m_fvNomParamMC(toCopy.m_fvNomParamMC) + , m_fvNomMassDefMC(toCopy.m_fvNomMassDefMC) + , m_mQCDNomHistData(!toCopy.m_mQCDNomHistData ? NULL : new UncertaintyHistogram(*toCopy.m_mQCDNomHistData)) + , m_mQCDNomParamData(toCopy.m_mQCDNomParamData) + , m_mQCDNomMassDefData(toCopy.m_mQCDNomMassDefData) + , m_mQCDNomHistMC(!toCopy.m_mQCDNomHistMC ? NULL : new UncertaintyHistogram(*toCopy.m_mQCDNomHistMC)) + , m_mQCDNomParamMC(toCopy.m_mQCDNomParamMC) + , m_mQCDNomMassDefMC(toCopy.m_mQCDNomMassDefMC) + , m_mWZNomHistData(!toCopy.m_mWZNomHistData ? NULL : new UncertaintyHistogram(*toCopy.m_mWZNomHistData)) + , m_mWZNomParamData(toCopy.m_mWZNomParamData) + , m_mWZNomMassDefData(toCopy.m_mWZNomMassDefData) + , m_mWZNomHistMC(!toCopy.m_mWZNomHistMC ? NULL : new UncertaintyHistogram(*toCopy.m_mWZNomHistMC)) + , m_mWZNomParamMC(toCopy.m_mWZNomParamMC) + , m_mWZNomMassDefMC(toCopy.m_mWZNomMassDefMC) + , m_mHbbNomHistData(!toCopy.m_mHbbNomHistData ? NULL : new UncertaintyHistogram(*toCopy.m_mHbbNomHistData)) + , m_mHbbNomParamData(toCopy.m_mHbbNomParamData) + , m_mHbbNomMassDefData(toCopy.m_mHbbNomMassDefData) + , m_mHbbNomHistMC(!toCopy.m_mHbbNomHistMC ? NULL : new UncertaintyHistogram(*toCopy.m_mHbbNomHistMC)) + , m_mHbbNomParamMC(toCopy.m_mHbbNomParamMC) + , m_mHbbNomMassDefMC(toCopy.m_mHbbNomMassDefMC) + , m_mTopNomHistData(!toCopy.m_mTopNomHistData ? NULL : new UncertaintyHistogram(*toCopy.m_mTopNomHistData)) + , m_mTopNomParamData(toCopy.m_mTopNomParamData) + , m_mTopNomMassDefData(toCopy.m_mTopNomMassDefData) + , m_mTopNomHistMC(!toCopy.m_mTopNomHistMC ? NULL : new UncertaintyHistogram(*toCopy.m_mTopNomHistMC)) + , m_mTopNomParamMC(toCopy.m_mTopNomParamMC) + , m_mTopNomMassDefMC(toCopy.m_mTopNomMassDefMC) +{ } + +ResolutionHelper::~ResolutionHelper() +{ + JESUNC_SAFE_DELETE(m_ptNomHistData); + JESUNC_SAFE_DELETE(m_ptNomHistMC); + JESUNC_SAFE_DELETE(m_fvNomHistData); + JESUNC_SAFE_DELETE(m_fvNomHistMC); + JESUNC_SAFE_DELETE(m_mQCDNomHistData); + JESUNC_SAFE_DELETE(m_mQCDNomHistMC); + JESUNC_SAFE_DELETE(m_mWZNomHistData); + JESUNC_SAFE_DELETE(m_mWZNomHistMC); + JESUNC_SAFE_DELETE(m_mHbbNomHistData); + JESUNC_SAFE_DELETE(m_mHbbNomHistMC); + JESUNC_SAFE_DELETE(m_mTopNomHistData); + JESUNC_SAFE_DELETE(m_mTopNomHistMC); +} + +StatusCode ResolutionHelper::parseInput(TEnv& settings, TFile* histFile, const TString& key, const TString& defaultValue, UncertaintyHistogram*& hist, CompParametrization::TypeEnum& param, CompMassDef::TypeEnum& massDef, const TString& MCtype) +{ + // Get the string + TString value = settings.GetValue(key,defaultValue); + + // Check the trivial case + if (value == "") + return StatusCode::SUCCESS; + + // Ensure it matches the expected format + if (!value.Contains(",")) + { + ATH_MSG_ERROR("Key of " << key.Data() << " has an unexpected value format (missing comma): " << value.Data()); + return StatusCode::FAILURE; + } + + // Split the string + std::vector<TString> splitValue = utils::vectorize<TString>(value,", "); + if (splitValue.size() < 3) + { + ATH_MSG_ERROR("Key of " << key.Data() << " has unexpected value format (less than 3 strings): " << value.Data()); + return StatusCode::FAILURE; + } + else if (splitValue.size() > 4) + { + ATH_MSG_ERROR("Key of " << key.Data() << " has unexpected value format (more than 4 strings): " << value.Data()); + return StatusCode::FAILURE; + } + + // Ensure that the parametrization is valid + param = CompParametrization::stringToEnum(splitValue.at(1)); + if (param == CompParametrization::UNKNOWN) + { + ATH_MSG_ERROR("Key of " << key.Data() << " has unexpected parametrization value: " << splitValue.at(1)); + return StatusCode::FAILURE; + } + + // Ensure that the interpolation type is valid + Interpolate::TypeEnum interp = Interpolate::stringToEnum(splitValue.at(2)); + if (interp == Interpolate::UNKNOWN) + { + ATH_MSG_ERROR("Key of " << key.Data() << " has unexpected interpolation type: " << splitValue.at(2)); + return StatusCode::FAILURE; + } + + // If this is a mass parametrization, ensure that a mass definition was specified + if (CompParametrization::includesMass(param)) + { + if (splitValue.size() != 4) + { + ATH_MSG_ERROR("Key of " << key.Data() << " has unexpected value format (missing mass definition): " << value.Data()); + return StatusCode::FAILURE; + } + massDef = CompMassDef::stringToEnum(splitValue.at(3)); + if (massDef == CompMassDef::UNKNOWN) + { + ATH_MSG_ERROR("Key of " << key.Data() << " has unexpected mass definition: " << splitValue.at(3)); + return StatusCode::FAILURE; + } + } + + // Replace generic MCTYPE string with the user-specified type if applicable + TString histName = splitValue.at(0); + histName.ReplaceAll("MCTYPE",MCtype); + + // Create the histogram + hist = new UncertaintyHistogram(histName+"_"+m_jetDef.c_str(),interp); + + // Initialize the histogram + if (hist->initialize(histFile).isFailure()) + return StatusCode::FAILURE; + + // Print out that we successfully read the input + ATH_MSG_INFO(Form(" %s: \"%s\"",key.Data(),value.Data())); + + return StatusCode::SUCCESS; +} + +StatusCode ResolutionHelper::initialize(TEnv& settings, TFile* histFile, const TString& MCtype) +{ + if (m_isInit) + { + ATH_MSG_ERROR("Blocking double-initialization: " << m_name); + return StatusCode::FAILURE; + } + + // Read nominal resolution information from the configuration file + // In many cases (especially configs before summer 2018), there are no inputs to find + // As such, it is perfectly normal behaviour to read zero inputs from the file + // However, there are some expectations + // There should be no cases of data resolution without MC resolution + // There can be cases of MC resolution without data resolution + // Histograms and their parametrizations must be paired (potentially also with mass) + + // Expected format: + // KeyString: HistName,Parametrization + // KeyString: HistName,Parametrization,MassDef + // Example: + // NominalPtResData: PtResData,PtAbsEta + // Histogram name is PtResData_JETDEF + // Parametrization is pT vs |eta| + // NominalMassResMC: MassResMC,PtMass,Calo + // Histogram name is MassResMC_JETDEF + // Parametrization is pT vs m/pt + // Mass definition is calorimeter (not track-assisted or combined) + + + // Start with nominal pT resolution + if (parseInput(settings,histFile,"NominalPtResData","",m_ptNomHistData,m_ptNomParamData,m_ptNomMassDefData,MCtype).isFailure()) + return StatusCode::FAILURE; + if (parseInput(settings,histFile,"NominalPtResMC","",m_ptNomHistMC,m_ptNomParamMC,m_ptNomMassDefMC,MCtype).isFailure()) + return StatusCode::FAILURE; + if (m_ptNomHistData && !m_ptNomHistMC) + { + ATH_MSG_ERROR("There should never be a nominal data resolution without a nominal MC resolution (pT)"); + return StatusCode::FAILURE; + } + + // Now the nominal four-vector resolution + if (parseInput(settings,histFile,"NominalFourVecResData","",m_fvNomHistData,m_fvNomParamData,m_fvNomMassDefData,MCtype).isFailure()) + return StatusCode::FAILURE; + if (parseInput(settings,histFile,"NominalFourVecResMC","",m_fvNomHistMC,m_fvNomParamMC,m_fvNomMassDefMC,MCtype).isFailure()) + return StatusCode::FAILURE; + if (m_fvNomHistData && !m_fvNomHistMC) + { + ATH_MSG_ERROR("There should never be a nominal data resolution without a nominal MC resolution (four-vector)"); + return StatusCode::FAILURE; + } + + // Now the nominal mass resolution (topology-dependent) + // For simplicity, this is done with separate histograms for each one + // Lots of code duplication, but time is of the essence, and it works + + // QCD topology + if (parseInput(settings,histFile,"NominalMassResDataQCD","",m_mQCDNomHistData,m_mQCDNomParamData,m_mQCDNomMassDefData,MCtype).isFailure()) + return StatusCode::FAILURE; + if (parseInput(settings,histFile,"NominalMassResMCQCD","",m_mQCDNomHistMC,m_mQCDNomParamMC,m_mQCDNomMassDefMC,MCtype).isFailure()) + return StatusCode::FAILURE; + if (m_mQCDNomHistData && !m_mQCDNomHistMC) + { + ATH_MSG_ERROR("There should never be a nominal data resolution without a nominal MC resolution (four-vector)"); + return StatusCode::FAILURE; + } + + // WZ topology + if (parseInput(settings,histFile,"NominalMassResDataWZ","",m_mWZNomHistData,m_mWZNomParamData,m_mWZNomMassDefData,MCtype).isFailure()) + return StatusCode::FAILURE; + if (parseInput(settings,histFile,"NominalMassResMCWZ","",m_mWZNomHistMC,m_mWZNomParamMC,m_mWZNomMassDefMC,MCtype).isFailure()) + return StatusCode::FAILURE; + if (m_mWZNomHistData && !m_mWZNomHistMC) + { + ATH_MSG_ERROR("There should never be a nominal data resolution without a nominal MC resolution (four-vector)"); + return StatusCode::FAILURE; + } + + // Hbb topology + if (parseInput(settings,histFile,"NominalMassResDataHbb","",m_mHbbNomHistData,m_mHbbNomParamData,m_mHbbNomMassDefData,MCtype).isFailure()) + return StatusCode::FAILURE; + if (parseInput(settings,histFile,"NominalMassResMCHbb","",m_mHbbNomHistMC,m_mHbbNomParamMC,m_mHbbNomMassDefMC,MCtype).isFailure()) + return StatusCode::FAILURE; + if (m_mHbbNomHistData && !m_mHbbNomHistMC) + { + ATH_MSG_ERROR("There should never be a nominal data resolution without a nominal MC resolution (four-vector)"); + return StatusCode::FAILURE; + } + + // Top topology + if (parseInput(settings,histFile,"NominalMassResDataTop","",m_mTopNomHistData,m_mTopNomParamData,m_mTopNomMassDefData,MCtype).isFailure()) + return StatusCode::FAILURE; + if (parseInput(settings,histFile,"NominalMassResMCTop","",m_mTopNomHistMC,m_mTopNomParamMC,m_mTopNomMassDefMC,MCtype).isFailure()) + return StatusCode::FAILURE; + if (m_mTopNomHistData && !m_mTopNomHistMC) + { + ATH_MSG_ERROR("There should never be a nominal data resolution without a nominal MC resolution (four-vector)"); + return StatusCode::FAILURE; + } + + // Check if the user has specified if this is full correlations or MC-only + TString smearType = settings.GetValue("ResolutionSmearOnlyMC",""); + if (smearType != "") + { + if (!smearType.CompareTo("true",TString::kIgnoreCase)) + m_smearOnlyMC = true; + else if (!smearType.CompareTo("false",TString::kIgnoreCase)) + m_smearOnlyMC = false; + else + { + ATH_MSG_ERROR("The value of ResolutionSmearOnlyMC doesn't look like the expected boolean: " << smearType.Data()); + return StatusCode::FAILURE; + } + ATH_MSG_INFO(Form(" ResolutionSmearOnlyMC: \"%s\"",m_smearOnlyMC ? "true" : "false")); + } + + // If we are also smearing data, we need the data histograms for any MC histogram + if (!m_smearOnlyMC) + { + if (m_ptNomHistMC && !m_ptNomHistData) + { + ATH_MSG_ERROR("Requested full smearing correlations (both data and MC), but only provided the MC nominal histogram for pT"); + return StatusCode::FAILURE; + } + if (m_fvNomHistMC && !m_fvNomHistMC) + { + ATH_MSG_ERROR("Requested full smearing correlations (both data and MC), but only provided the MC nominal histogram for fourvec"); + return StatusCode::FAILURE; + } + if (m_mQCDNomHistMC && !m_mQCDNomHistData) + { + ATH_MSG_ERROR("Requested full smearing correlations (both data and MC), but only provided the MC nominal histogram for mQCD"); + return StatusCode::FAILURE; + } + if (m_mWZNomHistMC && !m_mWZNomHistData) + { + ATH_MSG_ERROR("Requested full smearing correlations (both data and MC), but only provided the MC nominal histogram for mWZ"); + return StatusCode::FAILURE; + } + if (m_mHbbNomHistMC && !m_mHbbNomHistData) + { + ATH_MSG_ERROR("Requested full smearing correlations (both data and MC), but only provided the MC nominal histogram for mHbb"); + return StatusCode::FAILURE; + } + if (m_mTopNomHistMC && !m_mTopNomHistData) + { + ATH_MSG_ERROR("Requested full smearing correlations (both data and MC), but only provided the MC nominal histogram for mTop"); + return StatusCode::FAILURE; + } + } + + + m_isInit = true; + return StatusCode::SUCCESS; +} + +std::tuple<const UncertaintyHistogram*,CompParametrization::TypeEnum,CompMassDef::TypeEnum> ResolutionHelper::getNominalResolution(const CompScaleVar::TypeEnum smearType, const JetTopology::TypeEnum topology, const bool readMC) const +{ + // First get the resolution histogram and parametrization + const jet::UncertaintyHistogram* resolution = NULL; + CompParametrization::TypeEnum param = CompParametrization::UNKNOWN; + CompMassDef::TypeEnum massDef = CompMassDef::UNKNOWN; + + if (!m_isInit) + { + ATH_MSG_ERROR("Asking for the nominal resolution before initialization"); + return std::tuple<const UncertaintyHistogram*,CompParametrization::TypeEnum,CompMassDef::TypeEnum>(NULL,CompParametrization::UNKNOWN,CompMassDef::UNKNOWN); + } + + + switch (smearType) + { + case CompScaleVar::MassRes: + case CompScaleVar::MassResAbs: + switch (topology) + { + case JetTopology::QCD: + if (readMC) + { + resolution = m_mQCDNomHistMC; + param = m_mQCDNomParamMC; + massDef = m_mQCDNomMassDefMC; + } + else + { + resolution = m_mQCDNomHistData; + param = m_mQCDNomParamData; + massDef = m_mQCDNomMassDefData; + } + break; + + case JetTopology::WZ: + if (readMC) + { + resolution = m_mWZNomHistMC; + param = m_mWZNomParamMC; + massDef = m_mWZNomMassDefMC; + } + else + { + resolution = m_mWZNomHistData; + param = m_mWZNomParamData; + massDef = m_mWZNomMassDefData; + } + break; + + case JetTopology::Hbb: + if (readMC) + { + resolution = m_mHbbNomHistMC; + param = m_mHbbNomParamMC; + massDef = m_mHbbNomMassDefMC; + } + else + { + resolution = m_mHbbNomHistData; + param = m_mHbbNomParamData; + massDef = m_mHbbNomMassDefData; + } + break; + + case JetTopology::Top: + if (readMC) + { + resolution = m_mTopNomHistMC; + param = m_mTopNomParamMC; + massDef = m_mTopNomMassDefMC; + } + else + { + resolution = m_mTopNomHistData; + param = m_mTopNomParamData; + massDef = m_mTopNomMassDefData; + } + break; + + case JetTopology::MIXED: + // We shouldn't read this, as it was checked at a higher level + // Just to be safe, check it and return error code + ATH_MSG_ERROR("Mass resolution depends on a single jet topology, not a mixed topology"); + return std::tuple<const UncertaintyHistogram*,CompParametrization::TypeEnum,CompMassDef::TypeEnum>(NULL,CompParametrization::UNKNOWN,CompMassDef::UNKNOWN); + + default: + // We shouldn't read this, as it was checked at a higher level + // Just to be safe, check it and return error code + ATH_MSG_ERROR("Mass resolution depends on the jet topology, which was not specified"); + return std::tuple<const UncertaintyHistogram*,CompParametrization::TypeEnum,CompMassDef::TypeEnum>(NULL,CompParametrization::UNKNOWN,CompMassDef::UNKNOWN); + } + break; + + case CompScaleVar::PtRes: + case CompScaleVar::PtResAbs: + if (readMC) + { + resolution = m_ptNomHistMC; + param = m_ptNomParamMC; + massDef = m_ptNomMassDefMC; + } + else + { + resolution = m_ptNomHistData; + param = m_ptNomParamData; + massDef = m_ptNomMassDefData; + } + break; + + case CompScaleVar::FourVecRes: + case CompScaleVar::FourVecResAbs: + if (readMC) + { + resolution = m_fvNomHistMC; + param = m_fvNomParamMC; + massDef = m_fvNomMassDefMC; + } + else + { + resolution = m_fvNomHistData; + param = m_fvNomParamData; + massDef = m_fvNomMassDefData; + } + break; + + default: + // This is not a resolution uncertainty component + // We should not get here + // Print an erorr and return error code + ATH_MSG_ERROR("Asked for the smearing factor for a non-resolution component"); + return std::tuple<const UncertaintyHistogram*,CompParametrization::TypeEnum,CompMassDef::TypeEnum>(NULL,CompParametrization::UNKNOWN,CompMassDef::UNKNOWN); + } + return std::tuple<const UncertaintyHistogram*,CompParametrization::TypeEnum,CompMassDef::TypeEnum>(resolution,param,massDef); +} + +bool ResolutionHelper::hasRelevantInfo(const CompScaleVar::TypeEnum type, const JetTopology::TypeEnum topology) const +{ + if (!m_isInit) + { + throw std::runtime_error("Asking for nominal resolution information before initialization"); + return false; + } + + // Check that the nominal MC histograms for the specified type exist + // We have already checked that the parametrizations exist for each histogram + // We have already checked that the data histograms exist for each MC if relevant + switch (type) + { + case CompScaleVar::PtRes: + case CompScaleVar::PtResAbs: + return m_ptNomHistMC != NULL; + + case CompScaleVar::FourVecRes: + case CompScaleVar::FourVecResAbs: + return m_fvNomHistMC != NULL; + + case CompScaleVar::MassRes: + case CompScaleVar::MassResAbs: + switch (topology) + { + case JetTopology::QCD: + return m_mQCDNomHistMC != NULL; + + case JetTopology::WZ: + return m_mWZNomHistMC != NULL; + + case JetTopology::Hbb: + return m_mHbbNomHistMC != NULL; + + case JetTopology::Top: + return m_mTopNomHistMC != NULL; + + default: + throw std::runtime_error(Form("Unexpected topology type, cannot determine if relevant info exists: %s",JetTopology::enumToString(topology).Data())); + return false; + } + + default: + throw std::runtime_error(Form("Unexpected variable type, cannot determine if relevant info exists: %s",CompScaleVar::enumToString(type).Data())); + return false; + } +} + +} // end jet namespace + diff --git a/Reconstruction/Jet/JetUncertainties/Root/UncertaintyComponent.cxx b/Reconstruction/Jet/JetUncertainties/Root/UncertaintyComponent.cxx index 35b17de3d3a26517a4b6533757292dac502b1c05..15fdb8856889f60d5df286b1940e693be5a71736 100644 --- a/Reconstruction/Jet/JetUncertainties/Root/UncertaintyComponent.cxx +++ b/Reconstruction/Jet/JetUncertainties/Root/UncertaintyComponent.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "JetUncertainties/UncertaintyComponent.h" @@ -33,8 +33,9 @@ UncertaintyComponent::UncertaintyComponent(const std::string& name) , m_uncHistName("") , m_validHistName("") , m_scaleVar(CompScaleVar::UNKNOWN) + , m_topology(JetTopology::UNKNOWN) , m_energyScale(1) - , m_interpolate(true) + , m_interpolate(Interpolate::UNKNOWN) , m_splitNumber(0) , m_uncHist(NULL) , m_validHist(NULL) @@ -48,6 +49,7 @@ UncertaintyComponent::UncertaintyComponent(const ComponentHelper& component, con , m_uncHistName(component.uncNames.size()!=0?component.uncNames.at(0):"NONE") , m_validHistName(component.validName) , m_scaleVar(component.scaleVar) + , m_topology(component.topology) , m_energyScale(component.energyScale) , m_interpolate(component.interpolate) , m_splitNumber(component.splitNum) @@ -69,6 +71,7 @@ UncertaintyComponent::UncertaintyComponent(const UncertaintyComponent& toCopy) , m_uncHistName(toCopy.m_uncHistName) , m_validHistName(toCopy.m_validHistName) , m_scaleVar(toCopy.m_scaleVar) + , m_topology(toCopy.m_topology) , m_energyScale(toCopy.m_energyScale) , m_interpolate(toCopy.m_interpolate) , m_splitNumber(toCopy.m_splitNumber) @@ -107,7 +110,7 @@ StatusCode UncertaintyComponent::initialize(TFile* histFile) } if (m_validHistName != "") { - m_validHist = new UncertaintyHistogram(m_validHistName,false); + m_validHist = new UncertaintyHistogram(m_validHistName,Interpolate::None); if (!m_validHist) { ATH_MSG_ERROR("Failed to create validity histogram of name \"" << getValidName().Data() << "\" for component: " << getName().Data()); @@ -304,13 +307,37 @@ bool UncertaintyComponent::getValidBool(const double validity) const return false; } -double UncertaintyComponent::getMassOverPt(const xAOD::Jet& jet, const CompMassDef::TypeEnum massDef) const +double UncertaintyComponent::getAbsMass(const xAOD::Jet& jet, const CompMassDef::TypeEnum massDef) const { - static JetFourMomAccessor scale(CompMassDef::getJetScaleString(massDef).Data()); - static SG::AuxElement::ConstAccessor<float> scaleTAMoment("JetTrackAssistedMassCalibrated"); + bool isSimpleCase = (massDef == CompMassDef::UNKNOWN || massDef == CompMassDef::FourVecMass); + JetFourMomAccessor scale(isSimpleCase ? "" : CompMassDef::getJetScaleString(massDef).Data()); + SG::AuxElement::ConstAccessor<float> scaleTAMoment(isSimpleCase ? "" : "JetTrackAssistedMassCalibrated"); + + if (isSimpleCase) + return jet.m(); + + // Check if the specified scale is available and return it if so + if (scale.isAvailable(jet)) + return scale(jet).M(); + // Fall-back on the TA moment as a float if applicable (TODO: temporary until JetCalibTools updated) + if (massDef == CompMassDef::TAMass && scaleTAMoment.isAvailable(jet)) + return scaleTAMoment(jet); + // Fall-back on the calo mass as the 4-vec if applicable (TODO: temporary until JetCalibTools updated) + if (massDef == CompMassDef::CaloMass) + return jet.m(); - // UNKNOWN is just use the assigned scale - if (massDef == CompMassDef::UNKNOWN) + // Specified scale is not available, error + ATH_MSG_ERROR("Failed to retrieve the " << CompMassDef::enumToString(massDef).Data() << " mass from the jet"); + return JESUNC_ERROR_CODE; +} + +double UncertaintyComponent::getMassOverPt(const xAOD::Jet& jet, const CompMassDef::TypeEnum massDef) const +{ + bool isSimpleCase = (massDef == CompMassDef::UNKNOWN || massDef == CompMassDef::FourVecMass); + JetFourMomAccessor scale(isSimpleCase ? "" : CompMassDef::getJetScaleString(massDef).Data()); + SG::AuxElement::ConstAccessor<float> scaleTAMoment(isSimpleCase ? "" : "JetTrackAssistedMassCalibrated"); + + if (isSimpleCase) return jet.m()/jet.pt(); // Check if the specified scale is available and return it if so @@ -329,5 +356,30 @@ double UncertaintyComponent::getMassOverPt(const xAOD::Jet& jet, const CompMassD } +double UncertaintyComponent::getMassOverE(const xAOD::Jet& jet, const CompMassDef::TypeEnum massDef) const +{ + bool isSimpleCase = (massDef == CompMassDef::UNKNOWN || massDef == CompMassDef::FourVecMass); + JetFourMomAccessor scale(isSimpleCase ? "" : CompMassDef::getJetScaleString(massDef).Data()); + SG::AuxElement::ConstAccessor<float> scaleTAMoment(isSimpleCase ? "" : "JetTrackAssistedMassCalibrated"); + + if (isSimpleCase) + return jet.m()/jet.e(); + + // Check if the specified scale is available and return it if so + if (scale.isAvailable(jet)) + return scale(jet).M()/scale(jet).E(); + // Fall-back on the TA moment as a float if applicable (TODO: temporary until JetCalibTools updated) + if (massDef == CompMassDef::TAMass && scaleTAMoment.isAvailable(jet)) + return scaleTAMoment(jet)/jet.e(); + // Fall-back on the calo mass as the 4-vec if applicable (TODO: temporary until JetCalibTools updated) + if (massDef == CompMassDef::CaloMass) + return jet.m()/jet.e(); + + // Specified scale is not available, error + ATH_MSG_ERROR("Failed to retrieve the " << CompMassDef::enumToString(massDef).Data() << " mass from the jet"); + return JESUNC_ERROR_CODE; + +} + } // end jet namespace diff --git a/Reconstruction/Jet/JetUncertainties/Root/UncertaintyEnum.cxx b/Reconstruction/Jet/JetUncertainties/Root/UncertaintyEnum.cxx index 85255e40670142839cfdb2262ee0ebf35cb5d1e3..44216191e2bfb120200c0f8c801f76bc45467dea 100644 --- a/Reconstruction/Jet/JetUncertainties/Root/UncertaintyEnum.cxx +++ b/Reconstruction/Jet/JetUncertainties/Root/UncertaintyEnum.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ @@ -95,9 +95,16 @@ namespace CompParametrization case Pt: return "Pt"; case PtEta: return "PtEta"; case PtAbsEta: return "PtAbsEta"; + case PtAbsMass: return "PtAbsMass"; case PtMass: return "PtMass"; case PtMassEta: return "PtMassEta"; case PtMassAbsEta: return "PtMassAbsEta"; + case PtAbsMassEta: return "PtAbsMassEta"; + case PtAbsMassAbsEta: return "PtAbsMassAbsEta"; + case eLOGmOe: return "eLOGmOe"; + case eLOGmOeEta: return "eLOGmOeEta"; + case eLOGmOeAbsEta: return "eLOGmOeAbsEta"; + case PtLOGPtMassForTagSF: return "PtLOGPtMassForTagSF"; default: return "UNKNOWN"; } } @@ -110,12 +117,26 @@ namespace CompParametrization return PtEta; if (!type.CompareTo("PtAbsEta",TString::kIgnoreCase)) return PtAbsEta; + if (!type.CompareTo("PtAbsMass",TString::kIgnoreCase)) + return PtAbsMass; if (!type.CompareTo("PtMass",TString::kIgnoreCase)) return PtMass; if (!type.CompareTo("PtMassEta",TString::kIgnoreCase)) return PtMassEta; if (!type.CompareTo("PtMassAbsEta",TString::kIgnoreCase)) return PtMassAbsEta; + if (!type.CompareTo("PtAbsMassEta",TString::kIgnoreCase)) + return PtAbsMassEta; + if (!type.CompareTo("PtAbsMassAbsEta",TString::kIgnoreCase)) + return PtAbsMassAbsEta; + if (!type.CompareTo("eLOGmOe",TString::kIgnoreCase)) + return eLOGmOe; + if (!type.CompareTo("eLOGmOeEta",TString::kIgnoreCase)) + return eLOGmOeEta; + if (!type.CompareTo("eLOGmOeAbsEta",TString::kIgnoreCase)) + return eLOGmOeAbsEta; + if (!type.CompareTo("PtLOGPtMassForTagSF",TString::kIgnoreCase)) + return PtLOGPtMassForTagSF; return UNKNOWN; } @@ -124,11 +145,35 @@ namespace CompParametrization switch(type) { case PtAbsEta: - case PtMassAbsEta: return true; + case PtMassAbsEta: + case PtAbsMassAbsEta: + case eLOGmOeAbsEta: return true; default: return false; } } + + bool includesMass(const TypeEnum type) + { + switch(type) + { + case PtAbsMass: + case PtMass: + case PtLOGPtMassForTagSF: + case PtMassEta: + case PtMassAbsEta: + case PtAbsMassEta: + case PtAbsMassAbsEta: + case eLOGmOe: + case eLOGmOeEta: + case eLOGmOeAbsEta: + return true; + + default: + return false; + } + } + } // end CompParametrization namespace @@ -144,6 +189,7 @@ namespace CompMassDef { switch(type) { + case FourVecMass: return "FourVec"; case CaloMass: return "Calo"; case TAMass: return "TA"; case CombMassQCD: return "CombQCD"; @@ -156,6 +202,8 @@ namespace CompMassDef TypeEnum stringToEnum(const TString type) { + if (!type.CompareTo("FourVec",TString::kIgnoreCase) || !type.CompareTo("FourVector",TString::kIgnoreCase)) + return FourVecMass; if (!type.CompareTo("Calo",TString::kIgnoreCase) || !type.CompareTo("Calorimeter",TString::kIgnoreCase)) return CaloMass; if (!type.CompareTo("TA",TString::kIgnoreCase) || !type.CompareTo("TrackAssisted",TString::kIgnoreCase)) @@ -213,8 +261,15 @@ namespace CompScaleVar case Tau21WTA: return "Tau21WTA"; case Tau32WTA: return "Tau32WTA"; case D2Beta1: return "D2Beta1"; + case C2Beta1: return "C2Beta1"; case Qw: return "Qw"; case MassRes: return "MassRes"; + case MassResAbs: return "MassResAbs"; + case PtRes: return "PtRes"; + case PtResAbs: return "PtResAbs"; + case FourVecRes: return "FourVecRes"; + case FourVecResAbs: return "FourVecResAbs"; + case TagScaleFactor:return "TagScaleFactor"; default: return "UNKNOWN"; } } @@ -241,12 +296,180 @@ namespace CompScaleVar return Tau32WTA; if (!type.CompareTo("D2Beta1",TString::kIgnoreCase)) return D2Beta1; + if (!type.CompareTo("C2Beta1",TString::kIgnoreCase)) + return C2Beta1; if (!type.CompareTo("Qw",TString::kIgnoreCase)) return Qw; if (!type.CompareTo("MassRes",TString::kIgnoreCase)) return MassRes; + if (!type.CompareTo("MassResAbs",TString::kIgnoreCase)) + return MassResAbs; + if (!type.CompareTo("PtRes",TString::kIgnoreCase)) + return PtRes; + if (!type.CompareTo("PtResAbs",TString::kIgnoreCase)) + return PtResAbs; + if (!type.CompareTo("FourVecRes",TString::kIgnoreCase)) + return FourVecRes; + if (!type.CompareTo("FourVecResAbs",TString::kIgnoreCase)) + return FourVecResAbs; + if (!type.CompareTo("TagScaleFactor",TString::kIgnoreCase)) + return TagScaleFactor; return UNKNOWN; } + + bool isScaleType(const TypeEnum type) + { + switch (type) + { + case FourVec: + case Pt: + case Mass: + case D12: + case D23: + case Tau21: + case Tau32: + case Tau21WTA: + case Tau32WTA: + case D2Beta1: + case C2Beta1: + case Qw: + case TagScaleFactor: + return true; + + default: + return false; + } + } + + bool isResolutionType(const TypeEnum type) + { + switch (type) + { + case MassRes: + case MassResAbs: + case PtRes: + case PtResAbs: + case FourVecRes: + case FourVecResAbs: + return true; + + default: + return false; + } + } + + bool isAbsResolutionType(const TypeEnum type) + { + switch (type) + { + case MassResAbs: + case PtResAbs: + case FourVecResAbs: + return true; + + default: + return false; + } + } + + bool isRelResolutionType(const TypeEnum type) + { + switch (type) + { + case MassRes: + case PtRes: + case FourVecRes: + return true; + + default: + return false; + } + } +} + + +////////////////////////////////////////////////// +// // +// Component parametrization type enum methods // +// // +////////////////////////////////////////////////// + +namespace CompFlavorLabelVar +{ + TString enumToString(const TypeEnum type) + { + switch (type) + { + case t_qqb: return "t_qqb"; + case t: return "t"; + case V_qq: return "V_qq"; + case W_qq: return "W_qq"; + case Z_qq: return "Z_qq"; + case W_qq_From_t: return "W_qq_From_t"; + case t_other: return "t_other"; + case q: return "q"; + default: return "UNKNOWN"; + } + } + + TypeEnum stringToEnum(const TString type) + { + if (type=="t_qqb") + return t_qqb; + if (type=="t") + return t; + if (type=="V_qq") + return V_qq; + if (type=="W_qq") + return W_qq; + if (type=="Z_qq") + return Z_qq; + if (type=="W_qq_From_t") + return W_qq_From_t; + if (type=="t_other") + return t_other; + if (type=="q") + return q; + return UNKNOWN; + } +} + + +////////////////////////////////////////////////// +// // +// Component parametrization type enum methods // +// // +////////////////////////////////////////////////// + +namespace CompTaggerRegionVar +{ + TString enumToString(const TypeEnum type) + { + switch (type) + { + case passMpassD2_2Var: return "2Var_passMpassD2"; + case passMfailD2_2Var: return "2Var_passMfailD2"; + case failMpassD2_2Var: return "2Var_failMpassD2"; + case failMfailD2_2Var: return "2Var_failMfailD2"; + default: return "UNKNOWN"; + } + } + + TypeEnum stringToEnum(const TString type) + { + if (type.Contains("2Var",TString::kIgnoreCase)) + { + if (type.Contains("passMpassD2",TString::kIgnoreCase)) + return passMpassD2_2Var; + if (type.Contains("passMfailD2",TString::kIgnoreCase)) + return passMfailD2_2Var; + if (type.Contains("failMpassD2",TString::kIgnoreCase)) + return failMpassD2_2Var; + if (type.Contains("failMfailD2",TString::kIgnoreCase)) + return failMfailD2_2Var; + } + return UNKNOWN; + } } @@ -300,10 +523,11 @@ namespace FlavourComp { switch (type) { - case Response: return "FlavourResponse"; - case Composition: return "FlavourComposition"; - case bJES: return "bJES"; - default: return "UNKNOWN"; + case Response: return "FlavourResponse"; + case Composition: return "FlavourComposition"; + case bJES: return "bJES"; + case PerJetResponse: return "PerJetFlavourResponse"; + default: return "UNKNOWN"; } } @@ -312,7 +536,12 @@ namespace FlavourComp if (type.Contains("Flavour",TString::kIgnoreCase) || type.Contains("Flavor",TString::kIgnoreCase)) { if (type.Contains("Response",TString::kIgnoreCase)) - return Response; + { + if (type.Contains("PerJet",TString::kIgnoreCase)) + return PerJetResponse; + else + return Response; + } if (type.Contains("Composition",TString::kIgnoreCase)) return Composition; } @@ -371,6 +600,7 @@ namespace JetTopology case WZ: return "WZ"; case Hbb: return "Hbb"; case Top: return "Top"; + case MIXED: return "MIXED"; default: return "UNKNOWN"; } } @@ -389,5 +619,40 @@ namespace JetTopology } } + +////////////////////////////////////////////////// +// // +// Histogram interpolation enumeration methods // +// // +////////////////////////////////////////////////// + +namespace Interpolate +{ + TString enumToString(const TypeEnum type) + { + switch(type) + { + case None: return "None"; + case Full: return "Full"; + case OnlyX: return "X"; + case OnlyY: return "Y"; + default: return "UNKNOWN"; + } + } + + TypeEnum stringToEnum(const TString type) + { + if (!type.CompareTo("None",TString::kIgnoreCase) || !type.CompareTo("false",TString::kIgnoreCase)) + return None; + if (!type.CompareTo("Full",TString::kIgnoreCase) || !type.CompareTo("true",TString::kIgnoreCase)) + return Full; + if (!type.CompareTo("OnlyX",TString::kIgnoreCase)) + return OnlyX; + if (!type.CompareTo("OnlyY",TString::kIgnoreCase)) + return OnlyY; + return UNKNOWN; + } +} + } // end jet namespace diff --git a/Reconstruction/Jet/JetUncertainties/Root/UncertaintyGroup.cxx b/Reconstruction/Jet/JetUncertainties/Root/UncertaintyGroup.cxx index d2def874dec57ed0a81975dd7533318152337e83..a6fcf1cfbb1ae9f0897755e80e1c579ede30d16e 100644 --- a/Reconstruction/Jet/JetUncertainties/Root/UncertaintyGroup.cxx +++ b/Reconstruction/Jet/JetUncertainties/Root/UncertaintyGroup.cxx @@ -266,6 +266,60 @@ std::set<CompScaleVar::TypeEnum> UncertaintyGroup::getScaleVars() const } +////////////////////////////////////////////////// +// // +// Specialty methods // +// // +////////////////////////////////////////////////// + +JetTopology::TypeEnum UncertaintyGroup::getTopology(const CompScaleVar::TypeEnum scaleVar) const +{ + // The topology is not normally needed + // Most variables are topology-independent, and thus are listed as "UNKNOWN" + // Mixing topology-agnostic and topology-specific variables is expected + // Mixing topology-specific variables of different topologies is not expected + + // Furthermore, the user can specify either a specific scale variable or not + // If the user doesn't specify (or specifies UNKNOWN, the default), then it checks all + + JetTopology::TypeEnum result = JetTopology::UNKNOWN; + + // First check subgroups + for (const UncertaintyGroup* subgroup : m_subgroups) + { + if (subgroup->getTopology() != JetTopology::UNKNOWN) + { + if (result == JetTopology::UNKNOWN) + result = subgroup->getTopology(); + else if (result != subgroup->getTopology(scaleVar)) + result = JetTopology::MIXED; + } + if (result == JetTopology::MIXED) + return result; // If it's mixed, it won't change any further + } + + // Now check direct components + for (const UncertaintyComponent* component : m_components) + { + // Skip components that don't match our desired scale var (if appropriate) + if (scaleVar != CompScaleVar::UNKNOWN && scaleVar != component->getScaleVar()) + continue; + + if (component->getTopology() != JetTopology::UNKNOWN) + { + if (result == JetTopology::UNKNOWN) + result = component->getTopology(); + else if (result != component->getTopology()) + result = JetTopology::MIXED; + } + if (result == JetTopology::MIXED) + return result; // If it's mixed, it won't change any further + } + + return result; // If we got here, it's not a mixed topology, so return what it is +} + + ////////////////////////////////////////////////// // // // Methods to test for special cases // diff --git a/Reconstruction/Jet/JetUncertainties/Root/UncertaintyHistogram.cxx b/Reconstruction/Jet/JetUncertainties/Root/UncertaintyHistogram.cxx index 672610306cb31b59e8a31daf260cba6c7ddc741c..f09d815a8af1931f4848ed2815274a3b15058f29 100644 --- a/Reconstruction/Jet/JetUncertainties/Root/UncertaintyHistogram.cxx +++ b/Reconstruction/Jet/JetUncertainties/Root/UncertaintyHistogram.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "JetUncertainties/UncertaintyHistogram.h" @@ -9,10 +9,13 @@ #include "TMath.h" #include "TFile.h" #include "TAxis.h" +#include "TH2.h" #include "TH3.h" #include "TH3F.h" #include "TH3D.h" +#include <stdexcept> + namespace jet { @@ -22,24 +25,25 @@ namespace jet // // ////////////////////////////////////////////////// -UncertaintyHistogram::UncertaintyHistogram(const std::string& histName, const bool interpolate) +UncertaintyHistogram::UncertaintyHistogram(const std::string& histName, const Interpolate::TypeEnum interpolate) : asg::AsgMessaging(histName) , m_isInit(false) , m_name(histName.c_str()) , m_interpolate(interpolate) , m_histo(NULL) , m_nDim(0) + , m_cachedProj() { if (histName == "") JESUNC_NO_DEFAULT_CONSTRUCTOR; ATH_MSG_DEBUG(Form("Creating UncertaintyHistogram named %s",getName().Data())); } -UncertaintyHistogram::UncertaintyHistogram(const TString histName, const bool interpolate) +UncertaintyHistogram::UncertaintyHistogram(const TString histName, const Interpolate::TypeEnum interpolate) : UncertaintyHistogram(std::string(histName.Data()),interpolate) { } -UncertaintyHistogram::UncertaintyHistogram(const char* histName, const bool interpolate) +UncertaintyHistogram::UncertaintyHistogram(const char* histName, const Interpolate::TypeEnum interpolate) : UncertaintyHistogram(std::string(histName),interpolate) { } @@ -50,6 +54,7 @@ UncertaintyHistogram::UncertaintyHistogram(const UncertaintyHistogram& toCopy) , m_interpolate(toCopy.m_interpolate) , m_histo(NULL) , m_nDim(toCopy.m_nDim) + , m_cachedProj() { ATH_MSG_DEBUG("Creating copy of UncertaintyHistogram named " << getName().Data()); @@ -57,8 +62,18 @@ UncertaintyHistogram::UncertaintyHistogram(const UncertaintyHistogram& toCopy) { m_histo = dynamic_cast<TH1*>(toCopy.m_histo->Clone()); if (!m_histo) + { ATH_MSG_FATAL("Failed to copy uncertainty histogram for " << getName().Data()); + throw std::runtime_error("Failed to copy histogram in UncertaintyHistogram copy constructor"); + } } + + if (toCopy.m_cachedProj.size()) + if (cacheProjections().isFailure()) + { + ATH_MSG_FATAL("Failed to build the required cache for " << getName().Data()); + throw std::runtime_error("Failed to build projection cache in UncertaintyHistogram copy constructor"); + } } UncertaintyHistogram::~UncertaintyHistogram() @@ -103,6 +118,11 @@ StatusCode UncertaintyHistogram::initialize(TFile* histFile) // Cache dimensionality m_nDim = m_histo->GetDimension(); + // Cache the projections if relevant + if (m_interpolate == Interpolate::OnlyX || m_interpolate == Interpolate::OnlyY) + if (cacheProjections().isFailure()) + return StatusCode::FAILURE; + // Print a summary ATH_MSG_DEBUG(Form("%s: Found histogram",getName().Data())); @@ -173,28 +193,100 @@ double UncertaintyHistogram::readHisto(const double var1, const double var2, con } // Check first dimension boundaries, always applicable - const float valX = checkBoundaries(m_histo->GetXaxis(),m_histo->GetNbinsX(),var1); + const float valX = checkBoundariesByBin(m_histo->GetXaxis(),m_histo->GetNbinsX(),var1); if (m_nDim == 1) { - if (m_interpolate) return Interpolate(m_histo,valX); - else return m_histo->GetBinContent(FindBin(m_histo->GetXaxis(),valX)); + switch (m_interpolate) + { + case Interpolate::Full: + case Interpolate::OnlyX: + return JetHelpers::Interpolate(m_histo,valX); + + case Interpolate::None: + return m_histo->GetBinContent((m_histo->GetXaxis())->FindBin(valX)); + + default: + ATH_MSG_ERROR("Unsupported histogram interpolation type of \"" << Interpolate::enumToString(m_interpolate).Data() << " for 1D histogram named " << m_name.Data()); + return JESUNC_ERROR_CODE; + } } // Check second dimension boundaries, if applicable - const float valY = checkBoundaries(m_histo->GetYaxis(),m_histo->GetNbinsY(),var2); + const float valY = checkBoundariesByBin(m_histo->GetYaxis(),m_histo->GetNbinsY(),var2); if (m_nDim == 2) { - if (m_interpolate) return Interpolate(m_histo,valX,valY); - else return m_histo->GetBinContent(FindBin(m_histo->GetXaxis(),valX),FindBin(m_histo->GetYaxis(),valY)); + // We need a 2D histogram for the projection calls + switch (m_interpolate) + { + case Interpolate::Full: + return JetHelpers::Interpolate(m_histo,valX,valY); + + case Interpolate::OnlyX: + // Interpolate on the x projection for a given Y bin + return JetHelpers::Interpolate(m_cachedProj.at(0).at((m_histo->GetYaxis())->FindBin(valY)).get(),valX); + + case Interpolate::OnlyY: + // Interpolate on the y projection for a given X bin + return JetHelpers::Interpolate(m_cachedProj.at(0).at((m_histo->GetXaxis())->FindBin(valX)).get(),valY); + + case Interpolate::None: + return m_histo->GetBinContent((m_histo->GetXaxis())->FindBin(valX),(m_histo->GetYaxis())->FindBin(valY)); + + default: + ATH_MSG_ERROR("Unsupported histogram interpolation type of \"" << Interpolate::enumToString(m_interpolate).Data() << " for 1D histogram named " << m_name.Data()); + return JESUNC_ERROR_CODE; + } } // Check third dimension boundaries, if applicable - const float valZ = checkBoundaries(m_histo->GetZaxis(),m_histo->GetNbinsZ(),var3); - if (m_interpolate) return Interpolate(m_histo,valX,valY,valZ); - return m_histo->GetBinContent(FindBin(m_histo->GetXaxis(),valX),FindBin(m_histo->GetYaxis(),valY),FindBin(m_histo->GetZaxis(),valZ)); + const float valZ = checkBoundariesByBin(m_histo->GetZaxis(),m_histo->GetNbinsZ(),var3); + + switch (m_interpolate) + { + case Interpolate::Full: + return JetHelpers::Interpolate(m_histo,valX,valY,valZ); + + case Interpolate::OnlyX: + // Interpolate on the x projection for a given y,z bin + return JetHelpers::Interpolate(m_cachedProj.at((m_histo->GetYaxis())->FindBin(valY)).at((m_histo->GetZaxis())->FindBin(valZ)).get(),valX); + + case Interpolate::OnlyY: + // Interpolate on the y projection for a given x,z bin + return JetHelpers::Interpolate(m_cachedProj.at((m_histo->GetXaxis())->FindBin(valX)).at((m_histo->GetZaxis())->FindBin(valZ)).get(),valY); + + case Interpolate::None: + return m_histo->GetBinContent((m_histo->GetXaxis())->FindBin(valX),(m_histo->GetYaxis())->FindBin(valY),(m_histo->GetZaxis())->FindBin(valZ)); + + default: + ATH_MSG_ERROR("Unsupported histogram interpolation type of \"" << Interpolate::enumToString(m_interpolate).Data() << " for 1D histogram named " << m_name.Data()); + return JESUNC_ERROR_CODE; + } } +double UncertaintyHistogram::checkBoundariesByBin(const TAxis* axis, const int numBins, const double valInput) const +{ + double val = valInput; + + // Root histogram binning: + // bin 0 = underflow bin + // bin 1 = first actual bin + // bin N = last actual bin + // bin N+1 = overflow bin + const int binIndex = axis->FindBin(valInput); + if (binIndex < 1) + val = axis->GetBinLowEdge(1); + else if (binIndex > numBins) + { + // Don't use the upper edge as floating point can make it roll into the next bin (which is overflow) + // Instead, use the last bin width to go slightly within the boundary + // An offset of 1.e-4*binWidth is negligible for physics as the values don't change fast, but above floating point precision + val = 1.e-4*axis->GetBinWidth(numBins)+axis->GetBinLowEdge(numBins); + } + + return val; +} + double UncertaintyHistogram::checkBoundaries(const TAxis* axis, const int numBins, const double valInput) const { const static int maxNumWarn = 0; //100 @@ -222,311 +314,152 @@ double UncertaintyHistogram::checkBoundaries(const TAxis* axis, const int numBin return val; } -double UncertaintyHistogram::Interpolate(const TH1* histo, const double x) const +StatusCode UncertaintyHistogram::cacheProjections() { - // Copied from ROOT directly and trivially modified, all credit to ROOT authors of TH1, TH2, and TH3 Interpolate methods - // This is done because I want a const version of interpolation, and none of the methods require modification of the histogram - // Probable reason is that FindBin isn't const, but there should be a const version... - Int_t xbin = FindBin(histo->GetXaxis(),x); - Double_t x0,x1,y0,y1; - - if(x<=histo->GetBinCenter(1)) { - return histo->GetBinContent(1); - } else if(x>=histo->GetBinCenter(histo->GetNbinsX())) { - return histo->GetBinContent(histo->GetNbinsX()); - } else { - if(x<=histo->GetBinCenter(xbin)) { - y0 = histo->GetBinContent(xbin-1); - x0 = histo->GetBinCenter(xbin-1); - y1 = histo->GetBinContent(xbin); - x1 = histo->GetBinCenter(xbin); - } else { - y0 = histo->GetBinContent(xbin); - x0 = histo->GetBinCenter(xbin); - y1 = histo->GetBinContent(xbin+1); - x1 = histo->GetBinCenter(xbin+1); - } - return y0 + (x-x0)*((y1-y0)/(x1-x0)); + // Ensure the histogram exists + if (!m_histo) + { + ATH_MSG_FATAL("Cannot cache histogram as it doesn't exist: " << m_name.Data()); + return StatusCode::FAILURE; } -} - -double UncertaintyHistogram::Interpolate(const TH1* histo, const double x, const double y) const -{ - // Call the unified method for consistency - return Interpolate2D(histo,x,y); -} -double UncertaintyHistogram::Interpolate2D(const TH1* histo, const double x, const double y, const int xAxis, const int yAxis, const int otherDimBin) const -{ - // Copied from ROOT directly and trivially modified, all credit to ROOT authors of TH1, TH2, and TH3 Interpolate methods - // This is done because I want a const version of interpolation, and none of the methods require modification of the histogram - // Probable reason is that FindBin isn't const, but there should be a const version... - const TAxis* fXaxis = xAxis == 1 ? histo->GetXaxis() : xAxis == 2 ? histo->GetYaxis() : xAxis == 3 ? histo->GetZaxis() : NULL; - const TAxis* fYaxis = yAxis == 1 ? histo->GetXaxis() : yAxis == 2 ? histo->GetYaxis() : yAxis == 3 ? histo->GetZaxis() : NULL; - - if (!fXaxis || !fYaxis) + // Ensure the number of dimensions is sane + if (m_histo->GetDimension() < 1 || m_histo->GetDimension() > 3) { - histo->Error("Interpolate2D","Failed to parse axes from inputs"); - return 0; + ATH_MSG_FATAL("Unsupported histogram dimensionality for projection caching: " << m_histo->GetDimension()); + return StatusCode::FAILURE; } - Double_t f=0; - Double_t x1=0,x2=0,y1=0,y2=0; - Double_t dx,dy; - Int_t bin_x = FindBin(fXaxis,x); - Int_t bin_y = FindBin(fYaxis,y); - if(bin_x<1 || bin_x>fXaxis->GetNbins() || bin_y<1 || bin_y>fYaxis->GetNbins()) { - histo->Error("Interpolate","Cannot interpolate outside histogram domain. (x: %f vs [%f,%f], y: %f vs [%f,%f])",x,fXaxis->GetBinLowEdge(1),fXaxis->GetBinLowEdge(fXaxis->GetNbins()+1),y,fYaxis->GetBinLowEdge(1),fYaxis->GetBinLowEdge(fYaxis->GetNbins()+1)); - return 0; + // Ensure the cache doesn't already exist + if (m_cachedProj.size()) + { + ATH_MSG_FATAL("Cannot cache histogram as the cache is non-empty: " << m_name.Data()); + return StatusCode::FAILURE; } - Int_t quadrant = 0; // CCW from UR 1,2,3,4 - // which quadrant of the bin (bin_P) are we in? - dx = fXaxis->GetBinUpEdge(bin_x)-x; - dy = fYaxis->GetBinUpEdge(bin_y)-y; - if (dx<=fXaxis->GetBinWidth(bin_x)/2 && dy<=fYaxis->GetBinWidth(bin_y)/2) - quadrant = 1; // upper right - if (dx>fXaxis->GetBinWidth(bin_x)/2 && dy<=fYaxis->GetBinWidth(bin_y)/2) - quadrant = 2; // upper left - if (dx>fXaxis->GetBinWidth(bin_x)/2 && dy>fYaxis->GetBinWidth(bin_y)/2) - quadrant = 3; // lower left - if (dx<=fXaxis->GetBinWidth(bin_x)/2 && dy>fYaxis->GetBinWidth(bin_y)/2) - quadrant = 4; // lower right - switch(quadrant) { - case 1: - x1 = fXaxis->GetBinCenter(bin_x); - y1 = fYaxis->GetBinCenter(bin_y); - x2 = fXaxis->GetBinCenter(bin_x+1); - y2 = fYaxis->GetBinCenter(bin_y+1); - break; - case 2: - x1 = fXaxis->GetBinCenter(bin_x-1); - y1 = fYaxis->GetBinCenter(bin_y); - x2 = fXaxis->GetBinCenter(bin_x); - y2 = fYaxis->GetBinCenter(bin_y+1); - break; - case 3: - x1 = fXaxis->GetBinCenter(bin_x-1); - y1 = fYaxis->GetBinCenter(bin_y-1); - x2 = fXaxis->GetBinCenter(bin_x); - y2 = fYaxis->GetBinCenter(bin_y); - break; - case 4: - x1 = fXaxis->GetBinCenter(bin_x); - y1 = fYaxis->GetBinCenter(bin_y-1); - x2 = fXaxis->GetBinCenter(bin_x+1); - y2 = fYaxis->GetBinCenter(bin_y); - break; + + // Protect vs Interpolate + switch (m_interpolate) + { + case Interpolate::OnlyX: + // Simple case of 1D + if (m_histo->GetDimension() == 1) + return StatusCode::SUCCESS; + break; + + case Interpolate::OnlyY: + // Failure case of 1D + if (m_histo->GetDimension() == 1) + { + ATH_MSG_FATAL("Cannot project in Y for a 1D histogram: " << m_name.Data()); + return StatusCode::FAILURE; + } + break; + + default: + ATH_MSG_FATAL("The interpolation type is not supported for caching: " << m_name.Data()); + return StatusCode::FAILURE; } - Int_t bin_x1 = FindBin(fXaxis,x1); - if(bin_x1<1) bin_x1=1; - Int_t bin_x2 = FindBin(fXaxis,x2); - if(bin_x2>fXaxis->GetNbins()) bin_x2=fXaxis->GetNbins(); - Int_t bin_y1 = FindBin(fYaxis,y1); - if(bin_y1<1) bin_y1=1; - Int_t bin_y2 = FindBin(fYaxis,y2); - if(bin_y2>fYaxis->GetNbins()) bin_y2=fYaxis->GetNbins(); - - Double_t q11; - Double_t q12; - Double_t q21; - Double_t q22; - if (otherDimBin > 0) + + // If we got here, then the request makes sense + // Start the projections + // Intentionally include underflow and overflow bins + // This keeps the same indexing scheme as root + // Avoids confusion and problems later at cost of a small amount of RAM + if (m_histo->GetDimension() == 2) { - // X,Y variable and Z fixed - if (xAxis == 1 && yAxis == 2) - { - q11 = histo->GetBinContent(histo->GetBin(bin_x1,bin_y1,otherDimBin)); - q12 = histo->GetBinContent(histo->GetBin(bin_x1,bin_y2,otherDimBin)); - q21 = histo->GetBinContent(histo->GetBin(bin_x2,bin_y1,otherDimBin)); - q22 = histo->GetBinContent(histo->GetBin(bin_x2,bin_y2,otherDimBin)); - } - // X,Z variable and Y fixed - else if (xAxis == 1 && yAxis == 3) - { - q11 = histo->GetBinContent(histo->GetBin(bin_x1,otherDimBin,bin_y1)); - q12 = histo->GetBinContent(histo->GetBin(bin_x1,otherDimBin,bin_y2)); - q21 = histo->GetBinContent(histo->GetBin(bin_x2,otherDimBin,bin_y1)); - q22 = histo->GetBinContent(histo->GetBin(bin_x2,otherDimBin,bin_y2)); - } - // Y,Z variable and X fixed - else if (xAxis == 2 && yAxis == 3) - { - q11 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_x1,bin_y1)); - q12 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_x1,bin_y2)); - q21 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_x2,bin_y1)); - q22 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_x2,bin_y2)); - } - // Y,X variable and Z fixed - else if (xAxis == 2 && yAxis == 1) + // Prepare to cache + TH2* localHist = dynamic_cast<TH2*>(m_histo); + m_cachedProj.resize(1); // 2D is a single slice of 3D + if (!localHist) { - q11 = histo->GetBinContent(histo->GetBin(bin_y1,bin_x1,otherDimBin)); - q12 = histo->GetBinContent(histo->GetBin(bin_y1,bin_x2,otherDimBin)); - q21 = histo->GetBinContent(histo->GetBin(bin_y2,bin_x1,otherDimBin)); - q22 = histo->GetBinContent(histo->GetBin(bin_y2,bin_x2,otherDimBin)); + ATH_MSG_FATAL("Failed to convert histogram to a TH2, please check inputs: " << m_name.Data()); + return StatusCode::FAILURE; } - // Z,X variable and Y fixed - else if (xAxis == 3 && yAxis == 1) + + // Create the projections + if (m_interpolate == Interpolate::OnlyX) { - q11 = histo->GetBinContent(histo->GetBin(bin_y1,otherDimBin,bin_x1)); - q12 = histo->GetBinContent(histo->GetBin(bin_y1,otherDimBin,bin_x2)); - q21 = histo->GetBinContent(histo->GetBin(bin_y2,otherDimBin,bin_x1)); - q22 = histo->GetBinContent(histo->GetBin(bin_y2,otherDimBin,bin_x2)); + for (Long64_t binY = 0; binY < localHist->GetNbinsY()+1; ++binY) + { + // Single bin of Y, interpolate across X + m_cachedProj.at(0).emplace_back(localHist->ProjectionX(Form("projx_%lld",binY),binY,binY)); + } } - // Z,Y variable and X fixed - else if (xAxis == 3 && yAxis == 2) + else if (m_interpolate == Interpolate::OnlyY) { - q11 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_y1,bin_x1)); - q12 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_y1,bin_x2)); - q21 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_y2,bin_x1)); - q22 = histo->GetBinContent(histo->GetBin(otherDimBin,bin_y2,bin_x2)); + for (Long64_t binX = 0; binX < localHist->GetNbinsX()+1; ++binX) + { + // Single bin of X, interpolate across Y + m_cachedProj.at(0).emplace_back(localHist->ProjectionY(Form("projy_%lld",binX),binX,binX)); + } } else { - histo->Error("Interpolate2D","Unsupported axis combination: (x,y)=(%d,%d) with one bin fixed",xAxis,yAxis); - return 0; + // We shouldn't make it here due to earlier checks + ATH_MSG_FATAL("Unexpected interpolation type, somehow escaped earlier checks: " << m_name.Data()); + return StatusCode::FAILURE; } } - else + else if (m_histo->GetDimension() == 3) { - // X,Y variable, no Z - if (xAxis == 1 && yAxis == 2) + // Prepare to cache + TH3* localHist = dynamic_cast<TH3*>(m_histo); + if (!localHist) + { + ATH_MSG_FATAL("Failed to convert histogram to a TH3, please check inputs: " << m_name.Data()); + return StatusCode::FAILURE; + } + + // Create the projections + if (m_interpolate == Interpolate::OnlyX) { - q11 = histo->GetBinContent(histo->GetBin(bin_x1,bin_y1)); - q12 = histo->GetBinContent(histo->GetBin(bin_x1,bin_y2)); - q21 = histo->GetBinContent(histo->GetBin(bin_x2,bin_y1)); - q22 = histo->GetBinContent(histo->GetBin(bin_x2,bin_y2)); + m_cachedProj.resize(localHist->GetNbinsY()+1); // 3D is a full double-index scan + for (Long64_t binY = 0; binY < localHist->GetNbinsY()+1; ++binY) + { + for (Long64_t binZ = 0; binZ < localHist->GetNbinsZ()+1; ++binZ) + { + // Single bin of Y-Z, interpolate across X + m_cachedProj.at(binY).emplace_back(localHist->ProjectionX(Form("projx_%lld_%lld",binY,binZ),binY,binY,binZ,binZ)); + } + } } - // Y,X variable, no Z - else if (xAxis == 2 && yAxis == 1) + else if (m_interpolate == Interpolate::OnlyY) { - q11 = histo->GetBinContent(histo->GetBin(bin_y1,bin_x1)); - q12 = histo->GetBinContent(histo->GetBin(bin_y1,bin_x2)); - q21 = histo->GetBinContent(histo->GetBin(bin_y2,bin_x1)); - q22 = histo->GetBinContent(histo->GetBin(bin_y2,bin_x2)); + m_cachedProj.resize(localHist->GetNbinsX()+1); // 3D is a full double-index scan + for (Long64_t binX = 0; binX < localHist->GetNbinsX()+1; ++binX) + { + for (Long64_t binZ = 0; binZ < localHist->GetNbinsZ()+1; ++binZ) + { + // Single bin of X-Z, interpolate across Y + m_cachedProj.at(binX).emplace_back(localHist->ProjectionY(Form("projy_%lld_%lld",binX,binZ),binX,binX,binZ,binZ)); + } + } } else { - histo->Error("Interpolate2D","Unsupported axis combination: (x,y)=(%d,%d)",xAxis,yAxis); - return 0; + // We shouldn't make it here due to earlier checks + ATH_MSG_FATAL("Unexpected interpolation type, somehow escaped earlier checks: " << m_name.Data()); + return StatusCode::FAILURE; } } - - Double_t d = (x2-x1)*(y2-y1); - f = (q11*(x2-x)*(y2-y)+q21*(x-x1)*(y2-y)+q12*(x2-x)*(y-y1)+q22*(x-x1)*(y-y1)) / d; - return f; -} - -double UncertaintyHistogram::Interpolate(const TH1* histo, const double x, const double y, const double z) const -{ - // Copied from ROOT directly and trivially modified, all credit to ROOT authors of TH1, TH2, and TH3 Interpolate methods - // This is done because I want a const version of interpolation, and none of the methods require modification of the histogram - // Probable reason is that FindBin isn't const, but there should be a const version... - const TAxis* fXaxis = histo->GetXaxis(); - const TAxis* fYaxis = histo->GetYaxis(); - const TAxis* fZaxis = histo->GetZaxis(); - - // Find the bin by bin edges - Int_t ubx = FindBin(fXaxis,x); - Int_t uby = FindBin(fYaxis,y); - Int_t ubz = FindBin(fZaxis,z); - - // Check if the value(s) are outside of the bin range(s) - if ( ubx < 1 || ubx > histo->GetNbinsX() || uby < 1 || uby > histo->GetNbinsY() || ubz < 1 || ubz > histo->GetNbinsZ() ) + else { - histo->Error("Interpolate","Cannot interpolate outside histogram domain. (x: %f vs [%f,%f], y: %f vs [%f,%f], z: %f vs [%f,%f])",x,fXaxis->GetBinLowEdge(1),fXaxis->GetBinLowEdge(histo->GetNbinsX()+1),y,fYaxis->GetBinLowEdge(1),fYaxis->GetBinLowEdge(histo->GetNbinsY()+1),z,fZaxis->GetBinLowEdge(1),fZaxis->GetBinLowEdge(histo->GetNbinsZ()+1)); - return 0; + // We shouldn't make it here due to earlier checks + ATH_MSG_FATAL("Unexpected dimensionality: " << m_histo->GetDimension()); + return StatusCode::FAILURE; } - // Now switch from bin edges to bin centres - // Note that we want to support edge cases, so it is possible that ub* == ob* - // This functionality is not in original ROOT TH3::Interpolate() - // This functionality is inspired by TH2::Interpolate() - Int_t obx = ubx + 1; - Int_t oby = uby + 1; - Int_t obz = ubz + 1; - - // Calculate distance weights before checking under/overflow bins - Double_t xw = fXaxis->GetBinCenter(obx) - fXaxis->GetBinCenter(ubx); - Double_t yw = fYaxis->GetBinCenter(oby) - fYaxis->GetBinCenter(uby); - Double_t zw = fZaxis->GetBinCenter(obz) - fZaxis->GetBinCenter(ubz); - - if (x < fXaxis->GetBinCenter(ubx)) { ubx -= 1; obx -= 1; } - if (ubx < 1) ubx = 1; - if (obx > histo->GetNbinsX()) obx = histo->GetNbinsX(); - - if (y < fYaxis->GetBinCenter(uby)) { uby -= 1; oby -= 1; } - if (uby < 1) uby = 1; - if (oby > histo->GetNbinsY()) oby = histo->GetNbinsY(); - - if (z < fZaxis->GetBinCenter(ubz)) { ubz -= 1; obz -= 1; } - if (ubz < 1) ubz = 1; - if (obz > histo->GetNbinsZ()) obz = histo->GetNbinsZ(); - - // Edge cases were tried with weights set including the under/overflow bins (to follow what TH2::Interpolate() does for boundaries) - // In some cases, it performed quite poorly - // Tests of switching to 2D interpolation with the third dimension fixed appeared to work much better - // Thus, the below is now a switch to bilinear interpolation when bin(s) are equal in trilinear interpolation - if (ubx == obx || uby == oby || ubz == obz) + // Ensure that ROOT doesn't try to take posession of any of the projections + for (size_t index = 0; index < m_cachedProj.size(); ++index) { - // Bilinear interpolation - if (ubz == obz) - return Interpolate2D(histo,x,y,1,2,ubz); - else if (uby == oby) - return Interpolate2D(histo,x,z,1,3,uby); - else if (ubx == obx) - return Interpolate2D(histo,y,z,2,3,ubx); - + for (auto& hist : m_cachedProj.at(index)) + { + hist->SetDirectory(nullptr); + } } - - // Not a boundary case, resume normal ROOT::TH3::Interpolate() - Double_t xd = (x - fXaxis->GetBinCenter(ubx)) / xw; - Double_t yd = (y - fYaxis->GetBinCenter(uby)) / yw; - Double_t zd = (z - fZaxis->GetBinCenter(ubz)) / zw; - - - Double_t v[] = { histo->GetBinContent( ubx, uby, ubz ), histo->GetBinContent( ubx, uby, obz ), - histo->GetBinContent( ubx, oby, ubz ), histo->GetBinContent( ubx, oby, obz ), - histo->GetBinContent( obx, uby, ubz ), histo->GetBinContent( obx, uby, obz ), - histo->GetBinContent( obx, oby, ubz ), histo->GetBinContent( obx, oby, obz ) }; - - - Double_t i1 = v[0] * (1 - zd) + v[1] * zd; - Double_t i2 = v[2] * (1 - zd) + v[3] * zd; - Double_t j1 = v[4] * (1 - zd) + v[5] * zd; - Double_t j2 = v[6] * (1 - zd) + v[7] * zd; - - - Double_t w1 = i1 * (1 - yd) + i2 * yd; - Double_t w2 = j1 * (1 - yd) + j2 * yd; - - - Double_t result = w1 * (1 - xd) + w2 * xd; - - return result; -} -Int_t UncertaintyHistogram::FindBin(const TAxis* axis, const double x) const -{ - // Copied from ROOT directly and trivially modified, all credit to ROOT authors of TAxis FindBin method - // This is done because I want a const version of bin finding (no expanding on under/overflow) - const double fXmin = axis->GetXmin(); - const double fXmax = axis->GetXmax(); - const Int_t fNbins = axis->GetNbins(); - const TArrayD* fXbins = axis->GetXbins(); - Int_t bin; - if (x < fXmin) { //*-* underflow - bin = 0; - } else if ( !(x < fXmax)) { //*-* overflow (note the way to catch NaN - bin = fNbins+1; - } else { - if (!fXbins->fN) { //*-* fix bins - bin = 1 + int (fNbins*(x-fXmin)/(fXmax-fXmin) ); - } else { //*-* variable bin sizes - //for (bin =1; x >= fXbins->fArray[bin]; bin++); - bin = 1 + TMath::BinarySearch(fXbins->fN,fXbins->fArray,x); - } - } - return bin; + // All done + return StatusCode::SUCCESS; } } // end jet namespace diff --git a/Reconstruction/Jet/JetUncertainties/Root/UncertaintySet.cxx b/Reconstruction/Jet/JetUncertainties/Root/UncertaintySet.cxx index 71fcdad46e1d42f97c52671675750936c0694eb5..b01dfd437e8a86d85e8aa67bfe425528568974c0 100644 --- a/Reconstruction/Jet/JetUncertainties/Root/UncertaintySet.cxx +++ b/Reconstruction/Jet/JetUncertainties/Root/UncertaintySet.cxx @@ -271,5 +271,41 @@ std::vector< std::pair<CompScaleVar::TypeEnum,bool> > UncertaintySet::getValidUn return validity; } + +////////////////////////////////////////////////// +// // +// Specialty methods // +// // +////////////////////////////////////////////////// + +JetTopology::TypeEnum UncertaintySet::getTopology(const CompScaleVar::TypeEnum scaleVar) const +{ + // The topology is not normally needed + // Most variables are topology-independent, and thus are listed as "UNKNOWN" + // Mixing topology-agnostic and topology-specific variables is expected + // Mixing topology-specific variables of different topologies is not expected + + // Furthermore, the user can specify either a specific scale variable or not + // If the user doesn't specify (or specifies UNKNOWN, the default), then it checks all + + JetTopology::TypeEnum result = JetTopology::UNKNOWN; + + for (const UncertaintyGroup* group : m_groups) + { + if (group->getTopology() != JetTopology::UNKNOWN) + { + if (result == JetTopology::UNKNOWN) + result = group->getTopology(); + else if (result != group->getTopology(scaleVar)) + result = JetTopology::MIXED; + } + if (result == JetTopology::MIXED) + return result; // If it's mixed, it won't change any further + } + + return result; // If we got here, it's not a mixed topology, so return what it is +} + + } // end jet namespace diff --git a/Reconstruction/Jet/JetUncertainties/Root/ValidityHistogram.cxx b/Reconstruction/Jet/JetUncertainties/Root/ValidityHistogram.cxx index 87c96b4c11bb513b6077fc9561fe2196b6bc746c..53f8e9241a69586b2631aaca98eb353f99a0bdb4 100644 --- a/Reconstruction/Jet/JetUncertainties/Root/ValidityHistogram.cxx +++ b/Reconstruction/Jet/JetUncertainties/Root/ValidityHistogram.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "JetUncertainties/ValidityHistogram.h" @@ -32,7 +32,9 @@ class InfoHelper const float m_energyScale; const CompMassDef::TypeEnum m_massDef; + double getAbsMass(const xAOD::Jet& jet) const; double getMassOverPt(const xAOD::Jet& jet) const; + double getMassOverE(const xAOD::Jet& jet) const; }; class InfoHelperPt : public InfoHelper @@ -113,22 +115,85 @@ class InfoHelperPtMassAbsEta : public InfoHelper } }; -double InfoHelper::getMassOverPt(const xAOD::Jet& jet) const +class InfoHelpereLOGmOe : public InfoHelper { - static JetFourMomAccessor scale(CompMassDef::getJetScaleString(m_massDef).Data()); - static SG::AuxElement::ConstAccessor<float> scaleTAMoment("JetTrackAssistedMassCalibrated"); + public: + InfoHelpereLOGmOe(const ValidityHistogram& validHist, const float energyScale, const CompMassDef::TypeEnum massDef) + : InfoHelper(validHist,energyScale,massDef) {} + virtual InfoHelpereLOGmOe* clone() const { return new InfoHelpereLOGmOe(*this); } - // UNKNOWN is just use the assigned scale - if (m_massDef == CompMassDef::UNKNOWN) - return jet.m()/jet.pt(); + virtual bool isValid(const xAOD::Jet& jet) const + { + return m_validHist.getValue(jet.e()*m_energyScale,log(getMassOverE(jet))); + } +}; + +class InfoHelpereLOGmOeEta : public InfoHelper +{ + public: + InfoHelpereLOGmOeEta(const ValidityHistogram& validHist, const float energyScale, const CompMassDef::TypeEnum massDef) + : InfoHelper(validHist,energyScale,massDef) {} + virtual InfoHelpereLOGmOeEta* clone() const { return new InfoHelpereLOGmOeEta(*this); } + + virtual bool isValid(const xAOD::Jet& jet) const + { + return m_validHist.getValue(jet.e()*m_energyScale,log(getMassOverE(jet)),jet.eta()); + } +}; + +class InfoHelpereLOGmOeAbsEta : public InfoHelper +{ + public: + InfoHelpereLOGmOeAbsEta(const ValidityHistogram& validHist, const float energyScale, const CompMassDef::TypeEnum massDef) + : InfoHelper(validHist,energyScale,massDef) {} + virtual InfoHelpereLOGmOeAbsEta* clone() const { return new InfoHelpereLOGmOeAbsEta(*this); } + + virtual bool isValid(const xAOD::Jet& jet) const + { + return m_validHist.getValue(jet.e()*m_energyScale,log(getMassOverE(jet)),fabs(jet.eta())); + } +}; + + +double InfoHelper::getAbsMass(const xAOD::Jet& jet) const +{ + bool isSimpleCase = (m_massDef == CompMassDef::UNKNOWN || m_massDef == CompMassDef::FourVecMass); + JetFourMomAccessor scale(isSimpleCase ? "" : CompMassDef::getJetScaleString(m_massDef).Data()); + SG::AuxElement::ConstAccessor<float> scaleTAMoment(isSimpleCase ? "" : "JetTrackAssistedMassCalibrated"); + + if (isSimpleCase) + return jet.m(); + + // Check if the specified scale is available and return it if so + if (scale.isAvailable(jet)) + return scale(jet).M(); + // Fall-back on the TA moment as a float if applicable + if (m_massDef == CompMassDef::TAMass && scaleTAMoment.isAvailable(jet)) + return scaleTAMoment(jet); + // Fall-back on the calo mass as the 4-vec if applicable (legacy support) + if (m_massDef == CompMassDef::CaloMass) + return jet.m(); + + // Specified scale is not available, error + return JESUNC_ERROR_CODE; +} + +double InfoHelper::getMassOverPt(const xAOD::Jet& jet) const +{ + bool isSimpleCase = (m_massDef == CompMassDef::UNKNOWN || m_massDef == CompMassDef::FourVecMass); + JetFourMomAccessor scale(isSimpleCase ? "" : CompMassDef::getJetScaleString(m_massDef).Data()); + SG::AuxElement::ConstAccessor<float> scaleTAMoment(isSimpleCase ? "" : "JetTrackAssistedMassCalibrated"); + if (isSimpleCase) + return jet.m()/jet.pt(); + // Check if the specified scale is available and return it if so if (scale.isAvailable(jet)) return scale(jet).M()/scale(jet).Pt(); - // Fall-back on the TA moment as a float if applicable (TODO: temporary until JetCalibTools updated) + // Fall-back on the TA moment as a float if applicable if (m_massDef == CompMassDef::TAMass && scaleTAMoment.isAvailable(jet)) return scaleTAMoment(jet)/jet.pt(); - // Fall-back on the calo mass as the 4-vec if applicable (TODO: temporary until JetCalibTools updated) + // Fall-back on the calo mass as the 4-vec if applicable (legacy support) if (m_massDef == CompMassDef::CaloMass) return jet.m()/jet.pt(); @@ -137,6 +202,30 @@ double InfoHelper::getMassOverPt(const xAOD::Jet& jet) const } +double InfoHelper::getMassOverE(const xAOD::Jet& jet) const +{ + bool isSimpleCase = (m_massDef == CompMassDef::UNKNOWN || m_massDef == CompMassDef::FourVecMass); + JetFourMomAccessor scale(isSimpleCase ? "" : CompMassDef::getJetScaleString(m_massDef).Data()); + SG::AuxElement::ConstAccessor<float> scaleTAMoment(isSimpleCase ? "" : "JetTrackAssistedMassCalibrated"); + + if (isSimpleCase) + return jet.m()/jet.e(); + + // Check if the specified scale is available and return it if so + if (scale.isAvailable(jet)) + return scale(jet).M()/scale(jet).E(); + // Fall-back on the TA moment as a float if applicable + if (m_massDef == CompMassDef::TAMass && scaleTAMoment.isAvailable(jet)) + return scaleTAMoment(jet)/jet.e(); + // Fall-back on the calo mass as the 4-vec if applicable (legacy support) + if (m_massDef == CompMassDef::CaloMass) + return jet.m()/jet.e(); + + // Specified scale is not available, error + return JESUNC_ERROR_CODE; + +} + @@ -147,7 +236,7 @@ double InfoHelper::getMassOverPt(const xAOD::Jet& jet) const ////////////////////////////////////////////////// ValidityHistogram::ValidityHistogram(const std::string& histName, const CompParametrization::TypeEnum parametrization, const float energyScale, const CompMassDef::TypeEnum massDef) - : UncertaintyHistogram(histName,false) + : UncertaintyHistogram(histName,Interpolate::None) , m_isInit(false) , m_param(parametrization) , m_energyScale(energyScale) @@ -211,7 +300,10 @@ StatusCode ValidityHistogram::initialize(TFile* histFile) break; case CompParametrization::PtEta: case CompParametrization::PtAbsEta: + case CompParametrization::PtAbsMass: case CompParametrization::PtMass: + case CompParametrization::eLOGmOe: + case CompParametrization::PtLOGPtMassForTagSF: // 2D if (getNumDim() != 2) { @@ -221,6 +313,10 @@ StatusCode ValidityHistogram::initialize(TFile* histFile) break; case CompParametrization::PtMassEta: case CompParametrization::PtMassAbsEta: + case CompParametrization::PtAbsMassEta: + case CompParametrization::PtAbsMassAbsEta: + case CompParametrization::eLOGmOeEta: + case CompParametrization::eLOGmOeAbsEta: // 3D if (getNumDim() != 3) { @@ -254,6 +350,15 @@ StatusCode ValidityHistogram::initialize(TFile* histFile) case CompParametrization::PtMassAbsEta: m_helper = new InfoHelperPtMassAbsEta(*this,m_energyScale,m_massDef); break; + case CompParametrization::eLOGmOe: + m_helper = new InfoHelpereLOGmOe(*this,m_energyScale,m_massDef); + break; + case CompParametrization::eLOGmOeEta: + m_helper = new InfoHelpereLOGmOeEta(*this,m_energyScale,m_massDef); + break; + case CompParametrization::eLOGmOeAbsEta: + m_helper = new InfoHelpereLOGmOeAbsEta(*this,m_energyScale,m_massDef); + break; default: ATH_MSG_ERROR("ValidityHistogram named \"" << getName().Data() << "\" was not prepared to handle the provided parametrization: " << CompParametrization::enumToString(m_param).Data()); return StatusCode::FAILURE; diff --git a/Reconstruction/Jet/JetUncertainties/cmt/Makefile.Standalone b/Reconstruction/Jet/JetUncertainties/cmt/Makefile.Standalone deleted file mode 100644 index a05549e907f99766df08a3b9e028f084245603a2..0000000000000000000000000000000000000000 --- a/Reconstruction/Jet/JetUncertainties/cmt/Makefile.Standalone +++ /dev/null @@ -1,116 +0,0 @@ -# ARCH_LOC_1 := $(wildcard $(shell root-config --prefix)/etc/Makefile.arch) -# ARCH_LOC_2 := $(wildcard $(shell root-config --prefix)/share/root/test/Makefile.arch) -# ARCH_LOC_3 := $(wildcard $(shell root-config --prefix)/share/doc/root/test/Makefile.arch) -# ifneq ($(strip $(ARCH_LOC_1)),) -# $(info Using $(ARCH_LOC_1)) -# include $(ARCH_LOC_1) -# else -# ifneq ($(strip $(ARCH_LOC_2)),) -# $(info Using $(ARCH_LOC_2)) -# include $(ARCH_LOC_2) -# else -# ifneq ($(strip $(ARCH_LOC_3)),) -# $(info Using $(ARCH_LOC_3)) -# include $(ARCH_LOC_3) -# else -# $(error Could not find Makefile.arch! ROOT not set up?) -# endif -# endif -# endif - -ifeq ($(wildcard $(ROOTSYS)/test/Makefile.arch),) - include $(ROOTSYS)/etc/Makefile.arch -else - include $(ROOTSYS)/test/Makefile.arch -endif - -ROOTBIN := $(shell root-config --bindir) -ROOTLIB := $(shell root-config --libdir) -ROOTINC := $(shell root-config --incdir) - -# ------------------------------------------------------------- -# General flags -# ------------------------------------------------------------- -PACKAGE = JetUncertainties -OUTPUTDIR = ../StandAlone - -# These warnings bother me, so I turn them off. -CXXFLAGS += -DJES_STANDALONE - -# add utils subdirectories if needed -INCLUDES += -I.. -I${ROOTINC} - -# Need these to avoid loading dependent libraries when ROOT starts -LINKLIBS = -L${ROOTLIB} -lHist -lMatrix -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic - -# ------------------------------------------------------------- -# ROOT Cint -# ------------------------------------------------------------- -CINT = JetUncertaintiesCint -LDEFFILE = ../Root/LinkDef.h -CINTFILE = $(OUTPUTDIR)/JetUncertaintiesCint.cxx -CINTOBJ = $(patsubst %.cxx,%.o,$(CINTFILE)) - -# ------------------------------------------------------------- -# ProofAna source -# ------------------------------------------------------------- -# add util subdirectories if needed -CXXLIST = ../Root/UJUncertaintyProvider.cxx ../Root/JESUncertaintyProvider.cxx ../Root/MultijetJESUncertaintyProvider.cxx ../Root/JESUtils.cxx $(CINTFILE) -HLIST = ../JetUncertainties/UJUncertaintyProvider.h ../JetUncertainties/JESUncertaintyProvider.h ../JetUncertainties/MultijetJESUncertaintyProvider.h -OLIST = $(patsubst %.cxx,%.o,$(CXXLIST)) -DLIST = $(patsubst %.h,%.d,$(HLIST)) - - -# ------------------------------------------------------------- -# Libraries -# ------------------------------------------------------------- -LIBFILE = $(OUTPUTDIR)/libJetUncertainties.so - -ifeq ($(PLATFORM),macosx) -EXTRALDFLAGS = -install_name $(LIBFILE) -endif - -# get libraries of ROOT -define ldlinksuffixROOT - $(addsuffix $(LDLINKSUFFIX),$(Lib)) $(shell if [ "$(findstring -Ldlink2,$(OPTIONS))" ]; then echo $(addsuffix _pkgid_$(ROOTVER),$(Lib)); fi) -endef - -# ------------------------------------------------------------- -# Compilation -# ------------------------------------------------------------- - -default: shlib - -# Implicit rule to compile all classes -%.o : %.cxx - @echo "Compiling $<" - @$(CXX) -MD $(CXXFLAGS) $(INCLUDES) -c $< -o $*.o - -# Rule to make ROOTCINT output file -$(CINTOBJ) : $(HLIST) $(LDEFFILE) - @echo "Running rootcint" - @$(ROOTBIN)/rootcint -f $(CINTFILE) -c -p $(CXXFLAGS) $(INCLUDES) $(HLIST) $(LDEFFILE) - @echo "Compiling $(CINTFILE)" - @$(CXX) $(CXXFLAGS) $(INCLUDES) -c $(CINTFILE) -o $@ - -rootcint : $(HLIST) $(LDEFFILE) - @echo "Running rootcint" - $(ROOTBIN)/rootcint -f $(CINTFILE) -c -p $(CXXFLAGS) $(INCLUDES) $(HLIST) $(LDEFFILE) - -# Rule to combine objects into a shared library -$(LIBFILE): $(OLIST) - @echo "Linking $(LIBFILE)" - @rm -f $(LIBFILE) - @$(LD) $(CXXFLAGS) $(SOFLAGS) $(LINKLIBS) $(EXTRALDFLAGS) $(OLIST) -o $(LIBFILE) - --include $(DLIST) - -JetUncertaintiesCint: $(CINTOBJ) -shlib: $(LIBFILE) - -clean: - @rm -f ../*/*.o ../*/*.d - - - - diff --git a/Reconstruction/Jet/JetUncertainties/share/UJ_2016/Moriond2017/UJ2016_CaloMass_WithJMR_medium.config b/Reconstruction/Jet/JetUncertainties/share/UJ_2016/Moriond2017/UJ2016_CaloMass_WithJMR_medium.config new file mode 100644 index 0000000000000000000000000000000000000000..2589b40c7f218f9942ad0e33baad6f6907943fa4 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/share/UJ_2016/Moriond2017/UJ2016_CaloMass_WithJMR_medium.config @@ -0,0 +1,400 @@ + +############################################################################## +# +# JetUncertaintiesTool Input Settings for large R jets mass, pT +# and other substructure variables. +# This is the medium correlation assumption variant. +# +# +# January, 2017 +# +# S. Schramm, P-A Delsart, S. Meehan +# +############################################################################## + +UncertaintyRelease: 2016_Moriond2017 +SupportedJetDefs: AntiKt10LCTopoTrimmedPtFrac5SmallR20 +SupportedMCTypes: MC15c +UncertaintyRootFile: UJ_2016/Moriond2017/AntiKt10LCTopoTrimmedPtFrac5SmallR20_20170217_v3_jet1jet2withweights_PROCESSED.root + +FileValidHistogram: ValidRange +FileValidHistParam: PtMassAbsEta +FileValidHistMassDef: Calo + +############################################################################## +# +# Settings for components +# +############################################################################## + + +# Groups + + +JESGroup.1.Name: Rtrk_Baseline_Kin +JESGroup.1.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, Kin scale +JESGroup.1.Group: 1 + + +JESGroup.2.Name: Rtrk_Baseline_Sub +JESGroup.2.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, Sub scale +JESGroup.2.Group: 2 + + +JESGroup.3.Name: Rtrk_Modelling_Kin +JESGroup.3.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, Kin scale +JESGroup.3.Group: 3 + + +JESGroup.4.Name: Rtrk_Modelling_Sub +JESGroup.4.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, Sub scale +JESGroup.4.Group: 4 + + +JESGroup.5.Name: Rtrk_Tracking_Kin +JESGroup.5.Desc: 2016 Rtrk measurement, rel 20.7: Tracking component, Kin scale +JESGroup.5.Group: 5 +JESGroup.5.Corr: Uncorrelated + + +JESGroup.6.Name: Rtrk_Tracking_Sub +JESGroup.6.Desc: 2016 Rtrk measurement, rel 20.7: Tracking component, Sub scale +JESGroup.6.Group: 6 +JESGroup.6.Corr: Uncorrelated + + +JESGroup.7.Name: Rtrk_TotalStat_Kin +JESGroup.7.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, Kin scale +JESGroup.7.Group: 7 + + +JESGroup.8.Name: Rtrk_TotalStat_Sub +JESGroup.8.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, Sub scale +JESGroup.8.Group: 8 + +JESGroup.9.Name: Top_massRes_mass +JESGroup.9.Desc: mass Resolution uncertainty for top topology +JESGroup.9.Type: Other +JESGroup.9.Corr: Uncorrelated +JESGroup.9.Group: 9 + +JESGroup.10.Name: WZ_massRes_mass +JESGroup.10.Desc: mass Resolution uncertainty for W/Z topology +JESGroup.10.Type: Other +JESGroup.10.Corr: Uncorrelated +JESGroup.10.Group: 10 + +JESGroup.11.Name: Hbb_massRes_mass +JESGroup.11.Desc: mass Resolution uncertainty for Higgs to bb topology +JESGroup.11.Type: Other +JESGroup.11.Corr: Uncorrelated +JESGroup.11.Group: 11 + + +# Components + +JESComponent.1.Name: Rtrk_Baseline_mass +JESComponent.1.Param: PtMass +JESComponent.1.MassDef: Calo +JESComponent.1.Scale: mass +JESComponent.1.Group: 1 + +JESComponent.2.Name: Rtrk_Modelling_mass +JESComponent.2.Param: PtMass +JESComponent.2.MassDef: Calo +JESComponent.2.Scale: mass +JESComponent.2.Group: 3 + +JESComponent.3.Name: Rtrk_Tracking1_mass +JESComponent.3.Param: PtMass +JESComponent.3.MassDef: Calo +JESComponent.3.Scale: mass +JESComponent.3.Group: 5 + +JESComponent.4.Name: Rtrk_Tracking2_mass +JESComponent.4.Param: PtMass +JESComponent.4.MassDef: Calo +JESComponent.4.Scale: mass +JESComponent.4.Group: 5 + +JESComponent.5.Name: Rtrk_Tracking3_mass +JESComponent.5.Param: PtMass +JESComponent.5.MassDef: Calo +JESComponent.5.Scale: mass +JESComponent.5.Group: 5 + +JESComponent.6.Name: Rtrk_TotalStat_mass +JESComponent.6.Param: PtMass +JESComponent.6.MassDef: Calo +JESComponent.6.Scale: mass +JESComponent.6.Group: 7 + +JESComponent.7.Name: Rtrk_Baseline_pT +JESComponent.7.Param: PtMass +JESComponent.7.MassDef: Calo +JESComponent.7.Scale: pT +JESComponent.7.Group: 1 + +JESComponent.8.Name: Rtrk_Baseline_Split23 +JESComponent.8.Param: PtMass +JESComponent.8.MassDef: Calo +JESComponent.8.Scale: D23 +JESComponent.8.Group: 1 + +JESComponent.9.Name: Rtrk_Baseline_Split12 +JESComponent.9.Param: PtMass +JESComponent.9.MassDef: Calo +JESComponent.9.Scale: D12 +JESComponent.9.Group: 1 + +JESComponent.10.Name: Rtrk_Baseline_Qw +JESComponent.10.Param: PtMass +JESComponent.10.MassDef: Calo +JESComponent.10.Scale: Qw +JESComponent.10.Group: 1 + +JESComponent.11.Name: Rtrk_Baseline_D2Beta1 +JESComponent.11.Param: PtMass +JESComponent.11.MassDef: Calo +JESComponent.11.Scale: D2Beta1 +JESComponent.11.Group: 2 + +JESComponent.12.Name: Rtrk_Baseline_Tau32WTA +JESComponent.12.Param: PtMass +JESComponent.12.MassDef: Calo +JESComponent.12.Scale: Tau32WTA +JESComponent.12.Group: 2 + +JESComponent.13.Name: Rtrk_Baseline_Tau21WTA +JESComponent.13.Param: PtMass +JESComponent.13.MassDef: Calo +JESComponent.13.Scale: Tau21WTA +JESComponent.13.Group: 2 + +JESComponent.14.Name: Rtrk_Modelling_pT +JESComponent.14.Param: PtMass +JESComponent.14.MassDef: Calo +JESComponent.14.Scale: pT +JESComponent.14.Group: 3 + +JESComponent.15.Name: Rtrk_Modelling_Split23 +JESComponent.15.Param: PtMass +JESComponent.15.MassDef: Calo +JESComponent.15.Scale: D23 +JESComponent.15.Group: 3 + +JESComponent.16.Name: Rtrk_Modelling_Split12 +JESComponent.16.Param: PtMass +JESComponent.16.MassDef: Calo +JESComponent.16.Scale: D12 +JESComponent.16.Group: 3 + +JESComponent.17.Name: Rtrk_Modelling_Qw +JESComponent.17.Param: PtMass +JESComponent.17.MassDef: Calo +JESComponent.17.Scale: Qw +JESComponent.17.Group: 3 + +JESComponent.18.Name: Rtrk_Modelling_D2Beta1 +JESComponent.18.Param: PtMass +JESComponent.18.MassDef: Calo +JESComponent.18.Scale: D2Beta1 +JESComponent.18.Group: 4 + +JESComponent.19.Name: Rtrk_Modelling_Tau32WTA +JESComponent.19.Param: PtMass +JESComponent.19.MassDef: Calo +JESComponent.19.Scale: Tau32WTA +JESComponent.19.Group: 4 + +JESComponent.20.Name: Rtrk_Modelling_Tau21WTA +JESComponent.20.Param: PtMass +JESComponent.20.MassDef: Calo +JESComponent.20.Scale: Tau21WTA +JESComponent.20.Group: 4 + +JESComponent.21.Name: Rtrk_Tracking1_pT +JESComponent.21.Param: PtMass +JESComponent.21.MassDef: Calo +JESComponent.21.Scale: pT +JESComponent.21.Group: 5 + +JESComponent.22.Name: Rtrk_Tracking1_Split23 +JESComponent.22.Param: PtMass +JESComponent.22.MassDef: Calo +JESComponent.22.Scale: D23 +JESComponent.22.Group: 5 + +JESComponent.23.Name: Rtrk_Tracking1_Split12 +JESComponent.23.Param: PtMass +JESComponent.23.MassDef: Calo +JESComponent.23.Scale: D12 +JESComponent.23.Group: 5 + +JESComponent.24.Name: Rtrk_Tracking1_Qw +JESComponent.24.Param: PtMass +JESComponent.24.MassDef: Calo +JESComponent.24.Scale: Qw +JESComponent.24.Group: 5 + +JESComponent.25.Name: Rtrk_Tracking1_D2Beta1 +JESComponent.25.Param: PtMass +JESComponent.25.MassDef: Calo +JESComponent.25.Scale: D2Beta1 +JESComponent.25.Group: 6 + +JESComponent.26.Name: Rtrk_Tracking1_Tau32WTA +JESComponent.26.Param: PtMass +JESComponent.26.MassDef: Calo +JESComponent.26.Scale: Tau32WTA +JESComponent.26.Group: 6 + +JESComponent.27.Name: Rtrk_Tracking1_Tau21WTA +JESComponent.27.Param: PtMass +JESComponent.27.MassDef: Calo +JESComponent.27.Scale: Tau21WTA +JESComponent.27.Group: 6 + +JESComponent.28.Name: Rtrk_Tracking2_pT +JESComponent.28.Param: PtMass +JESComponent.28.MassDef: Calo +JESComponent.28.Scale: pT +JESComponent.28.Group: 5 + +JESComponent.29.Name: Rtrk_Tracking2_Split23 +JESComponent.29.Param: PtMass +JESComponent.29.MassDef: Calo +JESComponent.29.Scale: D23 +JESComponent.29.Group: 5 + +JESComponent.30.Name: Rtrk_Tracking2_Split12 +JESComponent.30.Param: PtMass +JESComponent.30.MassDef: Calo +JESComponent.30.Scale: D12 +JESComponent.30.Group: 5 + +JESComponent.31.Name: Rtrk_Tracking2_Qw +JESComponent.31.Param: PtMass +JESComponent.31.MassDef: Calo +JESComponent.31.Scale: Qw +JESComponent.31.Group: 5 + +JESComponent.32.Name: Rtrk_Tracking2_D2Beta1 +JESComponent.32.Param: PtMass +JESComponent.32.MassDef: Calo +JESComponent.32.Scale: D2Beta1 +JESComponent.32.Group: 6 + +JESComponent.33.Name: Rtrk_Tracking2_Tau32WTA +JESComponent.33.Param: PtMass +JESComponent.33.MassDef: Calo +JESComponent.33.Scale: Tau32WTA +JESComponent.33.Group: 6 + +JESComponent.34.Name: Rtrk_Tracking2_Tau21WTA +JESComponent.34.Param: PtMass +JESComponent.34.MassDef: Calo +JESComponent.34.Scale: Tau21WTA +JESComponent.34.Group: 6 + +JESComponent.35.Name: Rtrk_Tracking3_pT +JESComponent.35.Param: PtMass +JESComponent.35.MassDef: Calo +JESComponent.35.Scale: pT +JESComponent.35.Group: 5 + +JESComponent.36.Name: Rtrk_Tracking3_Split23 +JESComponent.36.Param: PtMass +JESComponent.36.MassDef: Calo +JESComponent.36.Scale: D23 +JESComponent.36.Group: 5 + +JESComponent.37.Name: Rtrk_Tracking3_Split12 +JESComponent.37.Param: PtMass +JESComponent.37.MassDef: Calo +JESComponent.37.Scale: D12 +JESComponent.37.Group: 5 + +JESComponent.38.Name: Rtrk_Tracking3_Qw +JESComponent.38.Param: PtMass +JESComponent.38.MassDef: Calo +JESComponent.38.Scale: Qw +JESComponent.38.Group: 5 + +JESComponent.39.Name: Rtrk_Tracking3_D2Beta1 +JESComponent.39.Param: PtMass +JESComponent.39.MassDef: Calo +JESComponent.39.Scale: D2Beta1 +JESComponent.39.Group: 6 + +JESComponent.40.Name: Rtrk_Tracking3_Tau32WTA +JESComponent.40.Param: PtMass +JESComponent.40.MassDef: Calo +JESComponent.40.Scale: Tau32WTA +JESComponent.40.Group: 6 + +JESComponent.41.Name: Rtrk_Tracking3_Tau21WTA +JESComponent.41.Param: PtMass +JESComponent.41.MassDef: Calo +JESComponent.41.Scale: Tau21WTA +JESComponent.41.Group: 6 + +JESComponent.42.Name: Rtrk_TotalStat_pT +JESComponent.42.Param: PtMass +JESComponent.42.MassDef: Calo +JESComponent.42.Scale: pT +JESComponent.42.Group: 7 + +JESComponent.43.Name: Rtrk_TotalStat_Split23 +JESComponent.43.Param: PtMass +JESComponent.43.MassDef: Calo +JESComponent.43.Scale: D23 +JESComponent.43.Group: 7 + +JESComponent.44.Name: Rtrk_TotalStat_Split12 +JESComponent.44.Param: PtMass +JESComponent.44.MassDef: Calo +JESComponent.44.Scale: D12 +JESComponent.44.Group: 7 + +JESComponent.45.Name: Rtrk_TotalStat_Qw +JESComponent.45.Param: PtMass +JESComponent.45.MassDef: Calo +JESComponent.45.Scale: Qw +JESComponent.45.Group: 7 + +JESComponent.46.Name: Rtrk_TotalStat_D2Beta1 +JESComponent.46.Param: PtMass +JESComponent.46.MassDef: Calo +JESComponent.46.Scale: D2Beta1 +JESComponent.46.Group: 8 + +JESComponent.47.Name: Rtrk_TotalStat_Tau32WTA +JESComponent.47.Param: PtMass +JESComponent.47.MassDef: Calo +JESComponent.47.Scale: Tau32WTA +JESComponent.47.Group: 8 + +JESComponent.48.Name: Rtrk_TotalStat_Tau21WTA +JESComponent.48.Param: PtMass +JESComponent.48.MassDef: Calo +JESComponent.48.Scale: Tau21WTA +JESComponent.48.Group: 8 + +JESComponent.49.Name: Top_massRes_mass +JESComponent.49.Param: PtMass +JESComponent.49.MassDef: Calo +JESComponent.49.Scale: MassRes +JESComponent.49.Group: 9 + +JESComponent.50.Name: WZ_massRes_mass +JESComponent.50.Param: PtMass +JESComponent.50.MassDef: Calo +JESComponent.50.Scale: MassRes +JESComponent.50.Group: 10 + +JESComponent.51.Name: Hbb_massRes_mass +JESComponent.51.Param: PtMass +JESComponent.51.MassDef: Calo +JESComponent.51.Scale: MassRes +JESComponent.51.Group: 11 diff --git a/Reconstruction/Jet/JetUncertainties/share/UJ_2016/Moriond2017/UJ2016_CaloMass_WithJMR_strong.config b/Reconstruction/Jet/JetUncertainties/share/UJ_2016/Moriond2017/UJ2016_CaloMass_WithJMR_strong.config new file mode 100644 index 0000000000000000000000000000000000000000..f95f55d1b7b0055487dfb86a53290ef7e6fb156d --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/share/UJ_2016/Moriond2017/UJ2016_CaloMass_WithJMR_strong.config @@ -0,0 +1,380 @@ + +############################################################################## +# +# JetUncertaintiesTool Input Settings for large R jets mass, pT +# and other substructure variables. +# This is the strong correlation assumption variant. +# +# +# January, 2017 +# +# S. Schramm, P-A Delsart, S. Meehan +# +############################################################################## + +UncertaintyRelease: 2016_Moriond2017 +SupportedJetDefs: AntiKt10LCTopoTrimmedPtFrac5SmallR20 +SupportedMCTypes: MC15c +UncertaintyRootFile: UJ_2016/Moriond2017/AntiKt10LCTopoTrimmedPtFrac5SmallR20_20170217_v3_jet1jet2withweights_PROCESSED.root + +FileValidHistogram: ValidRange +FileValidHistParam: PtMassAbsEta +FileValidHistMassDef: Calo + +############################################################################## +# +# Settings for components +# +############################################################################## + + +# Groups + + +JESGroup.1.Name: Rtrk_Baseline_All +JESGroup.1.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, All scale +JESGroup.1.Group: 1 + + +JESGroup.2.Name: Rtrk_Modelling_All +JESGroup.2.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, All scale +JESGroup.2.Group: 2 + + +JESGroup.3.Name: Rtrk_Tracking_All +JESGroup.3.Desc: 2016 Rtrk measurement, rel 20.7: Tracking component, All scale +JESGroup.3.Group: 3 +JESGroup.3.Corr: Uncorrelated + + +JESGroup.4.Name: Rtrk_TotalStat_All +JESGroup.4.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, All scale +JESGroup.4.Group: 4 + +JESGroup.5.Name: Top_massRes_mass +JESGroup.5.Desc: mass Resolution uncertainty for top topology +JESGroup.5.Type: Other +JESGroup.5.Corr: Uncorrelated +JESGroup.5.Group: 5 + +JESGroup.6.Name: WZ_massRes_mass +JESGroup.6.Desc: mass Resolution uncertainty for W/Z topology +JESGroup.6.Type: Other +JESGroup.6.Corr: Uncorrelated +JESGroup.6.Group: 6 + +JESGroup.7.Name: Hbb_massRes_mass +JESGroup.7.Desc: mass Resolution uncertainty for Higgs to bb topology +JESGroup.7.Type: Other +JESGroup.7.Corr: Uncorrelated +JESGroup.7.Group: 7 + + + +# Components + +JESComponent.1.Name: Rtrk_Baseline_mass +JESComponent.1.Param: PtMass +JESComponent.1.MassDef: Calo +JESComponent.1.Scale: mass +JESComponent.1.Group: 1 + +JESComponent.2.Name: Rtrk_Modelling_mass +JESComponent.2.Param: PtMass +JESComponent.2.MassDef: Calo +JESComponent.2.Scale: mass +JESComponent.2.Group: 2 + +JESComponent.3.Name: Rtrk_Tracking1_mass +JESComponent.3.Param: PtMass +JESComponent.3.MassDef: Calo +JESComponent.3.Scale: mass +JESComponent.3.Group: 3 + +JESComponent.4.Name: Rtrk_Tracking2_mass +JESComponent.4.Param: PtMass +JESComponent.4.MassDef: Calo +JESComponent.4.Scale: mass +JESComponent.4.Group: 3 + +JESComponent.5.Name: Rtrk_Tracking3_mass +JESComponent.5.Param: PtMass +JESComponent.5.MassDef: Calo +JESComponent.5.Scale: mass +JESComponent.5.Group: 3 + +JESComponent.6.Name: Rtrk_TotalStat_mass +JESComponent.6.Param: PtMass +JESComponent.6.MassDef: Calo +JESComponent.6.Scale: mass +JESComponent.6.Group: 4 + +JESComponent.7.Name: Rtrk_Baseline_pT +JESComponent.7.Param: PtMass +JESComponent.7.MassDef: Calo +JESComponent.7.Scale: pT +JESComponent.7.Group: 1 + +JESComponent.8.Name: Rtrk_Baseline_Split23 +JESComponent.8.Param: PtMass +JESComponent.8.MassDef: Calo +JESComponent.8.Scale: D23 +JESComponent.8.Group: 1 + +JESComponent.9.Name: Rtrk_Baseline_Split12 +JESComponent.9.Param: PtMass +JESComponent.9.MassDef: Calo +JESComponent.9.Scale: D12 +JESComponent.9.Group: 1 + +JESComponent.10.Name: Rtrk_Baseline_Qw +JESComponent.10.Param: PtMass +JESComponent.10.MassDef: Calo +JESComponent.10.Scale: Qw +JESComponent.10.Group: 1 + +JESComponent.11.Name: Rtrk_Baseline_D2Beta1 +JESComponent.11.Param: PtMass +JESComponent.11.MassDef: Calo +JESComponent.11.Scale: D2Beta1 +JESComponent.11.Group: 1 + +JESComponent.12.Name: Rtrk_Baseline_Tau32WTA +JESComponent.12.Param: PtMass +JESComponent.12.MassDef: Calo +JESComponent.12.Scale: Tau32WTA +JESComponent.12.Group: 1 + +JESComponent.13.Name: Rtrk_Baseline_Tau21WTA +JESComponent.13.Param: PtMass +JESComponent.13.MassDef: Calo +JESComponent.13.Scale: Tau21WTA +JESComponent.13.Group: 1 + +JESComponent.14.Name: Rtrk_Modelling_pT +JESComponent.14.Param: PtMass +JESComponent.14.MassDef: Calo +JESComponent.14.Scale: pT +JESComponent.14.Group: 2 + +JESComponent.15.Name: Rtrk_Modelling_Split23 +JESComponent.15.Param: PtMass +JESComponent.15.MassDef: Calo +JESComponent.15.Scale: D23 +JESComponent.15.Group: 2 + +JESComponent.16.Name: Rtrk_Modelling_Split12 +JESComponent.16.Param: PtMass +JESComponent.16.MassDef: Calo +JESComponent.16.Scale: D12 +JESComponent.16.Group: 2 + +JESComponent.17.Name: Rtrk_Modelling_Qw +JESComponent.17.Param: PtMass +JESComponent.17.MassDef: Calo +JESComponent.17.Scale: Qw +JESComponent.17.Group: 2 + +JESComponent.18.Name: Rtrk_Modelling_D2Beta1 +JESComponent.18.Param: PtMass +JESComponent.18.MassDef: Calo +JESComponent.18.Scale: D2Beta1 +JESComponent.18.Group: 2 + +JESComponent.19.Name: Rtrk_Modelling_Tau32WTA +JESComponent.19.Param: PtMass +JESComponent.19.MassDef: Calo +JESComponent.19.Scale: Tau32WTA +JESComponent.19.Group: 2 + +JESComponent.20.Name: Rtrk_Modelling_Tau21WTA +JESComponent.20.Param: PtMass +JESComponent.20.MassDef: Calo +JESComponent.20.Scale: Tau21WTA +JESComponent.20.Group: 2 + +JESComponent.21.Name: Rtrk_Tracking1_pT +JESComponent.21.Param: PtMass +JESComponent.21.MassDef: Calo +JESComponent.21.Scale: pT +JESComponent.21.Group: 3 + +JESComponent.22.Name: Rtrk_Tracking1_Split23 +JESComponent.22.Param: PtMass +JESComponent.22.MassDef: Calo +JESComponent.22.Scale: D23 +JESComponent.22.Group: 3 + +JESComponent.23.Name: Rtrk_Tracking1_Split12 +JESComponent.23.Param: PtMass +JESComponent.23.MassDef: Calo +JESComponent.23.Scale: D12 +JESComponent.23.Group: 3 + +JESComponent.24.Name: Rtrk_Tracking1_Qw +JESComponent.24.Param: PtMass +JESComponent.24.MassDef: Calo +JESComponent.24.Scale: Qw +JESComponent.24.Group: 3 + +JESComponent.25.Name: Rtrk_Tracking1_D2Beta1 +JESComponent.25.Param: PtMass +JESComponent.25.MassDef: Calo +JESComponent.25.Scale: D2Beta1 +JESComponent.25.Group: 3 + +JESComponent.26.Name: Rtrk_Tracking1_Tau32WTA +JESComponent.26.Param: PtMass +JESComponent.26.MassDef: Calo +JESComponent.26.Scale: Tau32WTA +JESComponent.26.Group: 3 + +JESComponent.27.Name: Rtrk_Tracking1_Tau21WTA +JESComponent.27.Param: PtMass +JESComponent.27.MassDef: Calo +JESComponent.27.Scale: Tau21WTA +JESComponent.27.Group: 3 + +JESComponent.28.Name: Rtrk_Tracking2_pT +JESComponent.28.Param: PtMass +JESComponent.28.MassDef: Calo +JESComponent.28.Scale: pT +JESComponent.28.Group: 3 + +JESComponent.29.Name: Rtrk_Tracking2_Split23 +JESComponent.29.Param: PtMass +JESComponent.29.MassDef: Calo +JESComponent.29.Scale: D23 +JESComponent.29.Group: 3 + +JESComponent.30.Name: Rtrk_Tracking2_Split12 +JESComponent.30.Param: PtMass +JESComponent.30.MassDef: Calo +JESComponent.30.Scale: D12 +JESComponent.30.Group: 3 + +JESComponent.31.Name: Rtrk_Tracking2_Qw +JESComponent.31.Param: PtMass +JESComponent.31.MassDef: Calo +JESComponent.31.Scale: Qw +JESComponent.31.Group: 3 + +JESComponent.32.Name: Rtrk_Tracking2_D2Beta1 +JESComponent.32.Param: PtMass +JESComponent.32.MassDef: Calo +JESComponent.32.Scale: D2Beta1 +JESComponent.32.Group: 3 + +JESComponent.33.Name: Rtrk_Tracking2_Tau32WTA +JESComponent.33.Param: PtMass +JESComponent.33.MassDef: Calo +JESComponent.33.Scale: Tau32WTA +JESComponent.33.Group: 3 + +JESComponent.34.Name: Rtrk_Tracking2_Tau21WTA +JESComponent.34.Param: PtMass +JESComponent.34.MassDef: Calo +JESComponent.34.Scale: Tau21WTA +JESComponent.34.Group: 3 + +JESComponent.35.Name: Rtrk_Tracking3_pT +JESComponent.35.Param: PtMass +JESComponent.35.MassDef: Calo +JESComponent.35.Scale: pT +JESComponent.35.Group: 3 + +JESComponent.36.Name: Rtrk_Tracking3_Split23 +JESComponent.36.Param: PtMass +JESComponent.36.MassDef: Calo +JESComponent.36.Scale: D23 +JESComponent.36.Group: 3 + +JESComponent.37.Name: Rtrk_Tracking3_Split12 +JESComponent.37.Param: PtMass +JESComponent.37.MassDef: Calo +JESComponent.37.Scale: D12 +JESComponent.37.Group: 3 + +JESComponent.38.Name: Rtrk_Tracking3_Qw +JESComponent.38.Param: PtMass +JESComponent.38.MassDef: Calo +JESComponent.38.Scale: Qw +JESComponent.38.Group: 3 + +JESComponent.39.Name: Rtrk_Tracking3_D2Beta1 +JESComponent.39.Param: PtMass +JESComponent.39.MassDef: Calo +JESComponent.39.Scale: D2Beta1 +JESComponent.39.Group: 3 + +JESComponent.40.Name: Rtrk_Tracking3_Tau32WTA +JESComponent.40.Param: PtMass +JESComponent.40.MassDef: Calo +JESComponent.40.Scale: Tau32WTA +JESComponent.40.Group: 3 + +JESComponent.41.Name: Rtrk_Tracking3_Tau21WTA +JESComponent.41.Param: PtMass +JESComponent.41.MassDef: Calo +JESComponent.41.Scale: Tau21WTA +JESComponent.41.Group: 3 + +JESComponent.42.Name: Rtrk_TotalStat_pT +JESComponent.42.Param: PtMass +JESComponent.42.MassDef: Calo +JESComponent.42.Scale: pT +JESComponent.42.Group: 4 + +JESComponent.43.Name: Rtrk_TotalStat_Split23 +JESComponent.43.Param: PtMass +JESComponent.43.MassDef: Calo +JESComponent.43.Scale: D23 +JESComponent.43.Group: 4 + +JESComponent.44.Name: Rtrk_TotalStat_Split12 +JESComponent.44.Param: PtMass +JESComponent.44.MassDef: Calo +JESComponent.44.Scale: D12 +JESComponent.44.Group: 4 + +JESComponent.45.Name: Rtrk_TotalStat_Qw +JESComponent.45.Param: PtMass +JESComponent.45.MassDef: Calo +JESComponent.45.Scale: Qw +JESComponent.45.Group: 4 + +JESComponent.46.Name: Rtrk_TotalStat_D2Beta1 +JESComponent.46.Param: PtMass +JESComponent.46.MassDef: Calo +JESComponent.46.Scale: D2Beta1 +JESComponent.46.Group: 4 + +JESComponent.47.Name: Rtrk_TotalStat_Tau32WTA +JESComponent.47.Param: PtMass +JESComponent.47.MassDef: Calo +JESComponent.47.Scale: Tau32WTA +JESComponent.47.Group: 4 + +JESComponent.48.Name: Rtrk_TotalStat_Tau21WTA +JESComponent.48.Param: PtMass +JESComponent.48.MassDef: Calo +JESComponent.48.Scale: Tau21WTA +JESComponent.48.Group: 4 + +JESComponent.49.Name: Top_massRes_mass +JESComponent.49.Param: PtMass +JESComponent.49.MassDef: Calo +JESComponent.49.Scale: MassRes +JESComponent.49.Group: 5 + +JESComponent.50.Name: WZ_massRes_mass +JESComponent.50.Param: PtMass +JESComponent.50.MassDef: Calo +JESComponent.50.Scale: MassRes +JESComponent.50.Group: 6 + +JESComponent.51.Name: Hbb_massRes_mass +JESComponent.51.Param: PtMass +JESComponent.51.MassDef: Calo +JESComponent.51.Scale: MassRes +JESComponent.51.Group: 7 diff --git a/Reconstruction/Jet/JetUncertainties/share/UJ_2016/Moriond2017/UJ2016_CaloMass_WithJMR_weak.config b/Reconstruction/Jet/JetUncertainties/share/UJ_2016/Moriond2017/UJ2016_CaloMass_WithJMR_weak.config new file mode 100644 index 0000000000000000000000000000000000000000..43c5f724e3af8c1cc99ff3ec647136009de6837c --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/share/UJ_2016/Moriond2017/UJ2016_CaloMass_WithJMR_weak.config @@ -0,0 +1,527 @@ + +############################################################################## +# +# JetUncertaintiesTool Input Settings for large R jets mass, pT +# and other substructure variables. +# This is the weak correlation assumption variant. +# +# +# January, 2017 +# +# S. Schramm, P-A Delsart, S. Meehan +# +############################################################################## + +UncertaintyRelease: 2016_Moriond2017 +SupportedJetDefs: AntiKt10LCTopoTrimmedPtFrac5SmallR20 +SupportedMCTypes: MC15c +UncertaintyRootFile: UJ_2016/Moriond2017/AntiKt10LCTopoTrimmedPtFrac5SmallR20_20170217_v3_jet1jet2withweights_PROCESSED.root + +FileValidHistogram: ValidRange +FileValidHistParam: PtMassAbsEta +FileValidHistMassDef: Calo + +############################################################################## +# +# Settings for components +# +############################################################################## + + +# Groups + + +JESGroup.1.Name: Rtrk_Baseline_mass +JESGroup.1.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, mass scale +JESGroup.1.Group: 1 + + +JESGroup.2.Name: Rtrk_Modelling_mass +JESGroup.2.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, mass scale +JESGroup.2.Group: 2 + + +JESGroup.3.Name: Rtrk_Tracking_mass +JESGroup.3.Desc: 2016 Rtrk measurement, rel 20.7: Tracking component, mass scale +JESGroup.3.Group: 3 +JESGroup.3.Corr: Uncorrelated + + +JESGroup.4.Name: Rtrk_TotalStat_mass +JESGroup.4.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, mass scale +JESGroup.4.Group: 4 + + +JESGroup.5.Name: Rtrk_Baseline_pT +JESGroup.5.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, pT scale +JESGroup.5.Group: 5 + + +JESGroup.6.Name: Rtrk_Modelling_pT +JESGroup.6.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, pT scale +JESGroup.6.Group: 6 + + +JESGroup.7.Name: Rtrk_Tracking_pT +JESGroup.7.Desc: 2016 Rtrk measurement, rel 20.7: Tracking component, pT scale +JESGroup.7.Group: 7 +JESGroup.7.Corr: Uncorrelated + + +JESGroup.8.Name: Rtrk_TotalStat_pT +JESGroup.8.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, pT scale +JESGroup.8.Group: 8 + + +JESGroup.9.Name: Rtrk_Baseline_Split23 +JESGroup.9.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, Split23 scale +JESGroup.9.Group: 9 + + +JESGroup.10.Name: Rtrk_Modelling_Split23 +JESGroup.10.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, Split23 scale +JESGroup.10.Group: 10 + + +JESGroup.11.Name: Rtrk_Tracking_Split23 +JESGroup.11.Desc: 2016 Rtrk measurement, rel 20.7: Tracking component, Split23 scale +JESGroup.11.Group: 11 +JESGroup.11.Corr: Uncorrelated + + +JESGroup.12.Name: Rtrk_TotalStat_Split23 +JESGroup.12.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, Split23 scale +JESGroup.12.Group: 12 + + +JESGroup.13.Name: Rtrk_Baseline_Split12 +JESGroup.13.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, Split12 scale +JESGroup.13.Group: 13 + + +JESGroup.14.Name: Rtrk_Modelling_Split12 +JESGroup.14.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, Split12 scale +JESGroup.14.Group: 14 + + +JESGroup.15.Name: Rtrk_Tracking_Split12 +JESGroup.15.Desc: 2016 Rtrk measurement, rel 20.7: Tracking component, Split12 scale +JESGroup.15.Group: 15 +JESGroup.15.Corr: Uncorrelated + + +JESGroup.16.Name: Rtrk_TotalStat_Split12 +JESGroup.16.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, Split12 scale +JESGroup.16.Group: 16 + + +JESGroup.17.Name: Rtrk_Baseline_Qw +JESGroup.17.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, Qw scale +JESGroup.17.Group: 17 + + +JESGroup.18.Name: Rtrk_Modelling_Qw +JESGroup.18.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, Qw scale +JESGroup.18.Group: 18 + + +JESGroup.19.Name: Rtrk_Tracking_Qw +JESGroup.19.Desc: 2016 Rtrk measurement, rel 20.7: Tracking component, Qw scale +JESGroup.19.Group: 19 +JESGroup.19.Corr: Uncorrelated + + +JESGroup.20.Name: Rtrk_TotalStat_Qw +JESGroup.20.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, Qw scale +JESGroup.20.Group: 20 + + +JESGroup.21.Name: Rtrk_Baseline_D2Beta1 +JESGroup.21.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, D2Beta1 scale +JESGroup.21.Group: 21 + + +JESGroup.22.Name: Rtrk_Modelling_D2Beta1 +JESGroup.22.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, D2Beta1 scale +JESGroup.22.Group: 22 + + +JESGroup.23.Name: Rtrk_Tracking_D2Beta1 +JESGroup.23.Desc: 2016 Rtrk measurement, rel 20.7: Tracking component, D2Beta1 scale +JESGroup.23.Group: 23 +JESGroup.23.Corr: Uncorrelated + + +JESGroup.24.Name: Rtrk_TotalStat_D2Beta1 +JESGroup.24.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, D2Beta1 scale +JESGroup.24.Group: 24 + + +JESGroup.25.Name: Rtrk_Baseline_Tau32WTA +JESGroup.25.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, Tau32WTA scale +JESGroup.25.Group: 25 + + +JESGroup.26.Name: Rtrk_Modelling_Tau32WTA +JESGroup.26.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, Tau32WTA scale +JESGroup.26.Group: 26 + + +JESGroup.27.Name: Rtrk_Tracking_Tau32WTA +JESGroup.27.Desc: 2016 Rtrk measurement, rel 20.7: Tracking component, Tau32WTA scale +JESGroup.27.Group: 27 +JESGroup.27.Corr: Uncorrelated + + +JESGroup.28.Name: Rtrk_TotalStat_Tau32WTA +JESGroup.28.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, Tau32WTA scale +JESGroup.28.Group: 28 + + +JESGroup.29.Name: Rtrk_Baseline_Tau21WTA +JESGroup.29.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, Tau21WTA scale +JESGroup.29.Group: 29 + + +JESGroup.30.Name: Rtrk_Modelling_Tau21WTA +JESGroup.30.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, Tau21WTA scale +JESGroup.30.Group: 30 + + +JESGroup.31.Name: Rtrk_Tracking_Tau21WTA +JESGroup.31.Desc: 2016 Rtrk measurement, rel 20.7: Tracking component, Tau21WTA scale +JESGroup.31.Group: 31 +JESGroup.31.Corr: Uncorrelated + + +JESGroup.32.Name: Rtrk_TotalStat_Tau21WTA +JESGroup.32.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, Tau21WTA scale +JESGroup.32.Group: 32 + +JESGroup.33.Name: Top_massRes_mass +JESGroup.33.Desc: mass Resolution uncertainty for top topology +JESGroup.33.Type: Other +JESGroup.33.Corr: Uncorrelated +JESGroup.33.Group: 33 + +JESGroup.34.Name: WZ_massRes_mass +JESGroup.34.Desc: mass Resolution uncertainty for W/Z topology +JESGroup.34.Type: Other +JESGroup.34.Corr: Uncorrelated +JESGroup.34.Group: 34 + +JESGroup.35.Name: Hbb_massRes_mass +JESGroup.35.Desc: mass Resolution uncertainty for Higgs to bb topology +JESGroup.35.Type: Other +JESGroup.35.Corr: Uncorrelated +JESGroup.35.Group: 35 + + +# Components + +JESComponent.1.Name: Rtrk_Baseline_mass +JESComponent.1.Param: PtMass +JESComponent.1.MassDef: Calo +JESComponent.1.Scale: mass +JESComponent.1.Group: 1 + +JESComponent.2.Name: Rtrk_Modelling_mass +JESComponent.2.Param: PtMass +JESComponent.2.MassDef: Calo +JESComponent.2.Scale: mass +JESComponent.2.Group: 2 + +JESComponent.3.Name: Rtrk_Tracking1_mass +JESComponent.3.Param: PtMass +JESComponent.3.MassDef: Calo +JESComponent.3.Scale: mass +JESComponent.3.Group: 3 + +JESComponent.4.Name: Rtrk_Tracking2_mass +JESComponent.4.Param: PtMass +JESComponent.4.MassDef: Calo +JESComponent.4.Scale: mass +JESComponent.4.Group: 3 + +JESComponent.5.Name: Rtrk_Tracking3_mass +JESComponent.5.Param: PtMass +JESComponent.5.MassDef: Calo +JESComponent.5.Scale: mass +JESComponent.5.Group: 3 + +JESComponent.6.Name: Rtrk_TotalStat_mass +JESComponent.6.Param: PtMass +JESComponent.6.MassDef: Calo +JESComponent.6.Scale: mass +JESComponent.6.Group: 4 + +JESComponent.7.Name: Rtrk_Baseline_pT +JESComponent.7.Param: PtMass +JESComponent.7.MassDef: Calo +JESComponent.7.Scale: pT +JESComponent.7.Group: 5 + +JESComponent.8.Name: Rtrk_Baseline_Split23 +JESComponent.8.Param: PtMass +JESComponent.8.MassDef: Calo +JESComponent.8.Scale: D23 +JESComponent.8.Group: 9 + +JESComponent.9.Name: Rtrk_Baseline_Split12 +JESComponent.9.Param: PtMass +JESComponent.9.MassDef: Calo +JESComponent.9.Scale: D12 +JESComponent.9.Group: 13 + +JESComponent.10.Name: Rtrk_Baseline_Qw +JESComponent.10.Param: PtMass +JESComponent.10.MassDef: Calo +JESComponent.10.Scale: Qw +JESComponent.10.Group: 17 + +JESComponent.11.Name: Rtrk_Baseline_D2Beta1 +JESComponent.11.Param: PtMass +JESComponent.11.MassDef: Calo +JESComponent.11.Scale: D2Beta1 +JESComponent.11.Group: 21 + +JESComponent.12.Name: Rtrk_Baseline_Tau32WTA +JESComponent.12.Param: PtMass +JESComponent.12.MassDef: Calo +JESComponent.12.Scale: Tau32WTA +JESComponent.12.Group: 25 + +JESComponent.13.Name: Rtrk_Baseline_Tau21WTA +JESComponent.13.Param: PtMass +JESComponent.13.MassDef: Calo +JESComponent.13.Scale: Tau21WTA +JESComponent.13.Group: 29 + +JESComponent.14.Name: Rtrk_Modelling_pT +JESComponent.14.Param: PtMass +JESComponent.14.MassDef: Calo +JESComponent.14.Scale: pT +JESComponent.14.Group: 6 + +JESComponent.15.Name: Rtrk_Modelling_Split23 +JESComponent.15.Param: PtMass +JESComponent.15.MassDef: Calo +JESComponent.15.Scale: D23 +JESComponent.15.Group: 10 + +JESComponent.16.Name: Rtrk_Modelling_Split12 +JESComponent.16.Param: PtMass +JESComponent.16.MassDef: Calo +JESComponent.16.Scale: D12 +JESComponent.16.Group: 14 + +JESComponent.17.Name: Rtrk_Modelling_Qw +JESComponent.17.Param: PtMass +JESComponent.17.MassDef: Calo +JESComponent.17.Scale: Qw +JESComponent.17.Group: 18 + +JESComponent.18.Name: Rtrk_Modelling_D2Beta1 +JESComponent.18.Param: PtMass +JESComponent.18.MassDef: Calo +JESComponent.18.Scale: D2Beta1 +JESComponent.18.Group: 22 + +JESComponent.19.Name: Rtrk_Modelling_Tau32WTA +JESComponent.19.Param: PtMass +JESComponent.19.MassDef: Calo +JESComponent.19.Scale: Tau32WTA +JESComponent.19.Group: 26 + +JESComponent.20.Name: Rtrk_Modelling_Tau21WTA +JESComponent.20.Param: PtMass +JESComponent.20.MassDef: Calo +JESComponent.20.Scale: Tau21WTA +JESComponent.20.Group: 30 + +JESComponent.21.Name: Rtrk_Tracking1_pT +JESComponent.21.Param: PtMass +JESComponent.21.MassDef: Calo +JESComponent.21.Scale: pT +JESComponent.21.Group: 7 + +JESComponent.22.Name: Rtrk_Tracking1_Split23 +JESComponent.22.Param: PtMass +JESComponent.22.MassDef: Calo +JESComponent.22.Scale: D23 +JESComponent.22.Group: 11 + +JESComponent.23.Name: Rtrk_Tracking1_Split12 +JESComponent.23.Param: PtMass +JESComponent.23.MassDef: Calo +JESComponent.23.Scale: D12 +JESComponent.23.Group: 15 + +JESComponent.24.Name: Rtrk_Tracking1_Qw +JESComponent.24.Param: PtMass +JESComponent.24.MassDef: Calo +JESComponent.24.Scale: Qw +JESComponent.24.Group: 19 + +JESComponent.25.Name: Rtrk_Tracking1_D2Beta1 +JESComponent.25.Param: PtMass +JESComponent.25.MassDef: Calo +JESComponent.25.Scale: D2Beta1 +JESComponent.25.Group: 23 + +JESComponent.26.Name: Rtrk_Tracking1_Tau32WTA +JESComponent.26.Param: PtMass +JESComponent.26.MassDef: Calo +JESComponent.26.Scale: Tau32WTA +JESComponent.26.Group: 27 + +JESComponent.27.Name: Rtrk_Tracking1_Tau21WTA +JESComponent.27.Param: PtMass +JESComponent.27.MassDef: Calo +JESComponent.27.Scale: Tau21WTA +JESComponent.27.Group: 31 + +JESComponent.28.Name: Rtrk_Tracking2_pT +JESComponent.28.Param: PtMass +JESComponent.28.MassDef: Calo +JESComponent.28.Scale: pT +JESComponent.28.Group: 7 + +JESComponent.29.Name: Rtrk_Tracking2_Split23 +JESComponent.29.Param: PtMass +JESComponent.29.MassDef: Calo +JESComponent.29.Scale: D23 +JESComponent.29.Group: 11 + +JESComponent.30.Name: Rtrk_Tracking2_Split12 +JESComponent.30.Param: PtMass +JESComponent.30.MassDef: Calo +JESComponent.30.Scale: D12 +JESComponent.30.Group: 15 + +JESComponent.31.Name: Rtrk_Tracking2_Qw +JESComponent.31.Param: PtMass +JESComponent.31.MassDef: Calo +JESComponent.31.Scale: Qw +JESComponent.31.Group: 19 + +JESComponent.32.Name: Rtrk_Tracking2_D2Beta1 +JESComponent.32.Param: PtMass +JESComponent.32.MassDef: Calo +JESComponent.32.Scale: D2Beta1 +JESComponent.32.Group: 23 + +JESComponent.33.Name: Rtrk_Tracking2_Tau32WTA +JESComponent.33.Param: PtMass +JESComponent.33.MassDef: Calo +JESComponent.33.Scale: Tau32WTA +JESComponent.33.Group: 27 + +JESComponent.34.Name: Rtrk_Tracking2_Tau21WTA +JESComponent.34.Param: PtMass +JESComponent.34.MassDef: Calo +JESComponent.34.Scale: Tau21WTA +JESComponent.34.Group: 31 + +JESComponent.35.Name: Rtrk_Tracking3_pT +JESComponent.35.Param: PtMass +JESComponent.35.MassDef: Calo +JESComponent.35.Scale: pT +JESComponent.35.Group: 7 + +JESComponent.36.Name: Rtrk_Tracking3_Split23 +JESComponent.36.Param: PtMass +JESComponent.36.MassDef: Calo +JESComponent.36.Scale: D23 +JESComponent.36.Group: 11 + +JESComponent.37.Name: Rtrk_Tracking3_Split12 +JESComponent.37.Param: PtMass +JESComponent.37.MassDef: Calo +JESComponent.37.Scale: D12 +JESComponent.37.Group: 15 + +JESComponent.38.Name: Rtrk_Tracking3_Qw +JESComponent.38.Param: PtMass +JESComponent.38.MassDef: Calo +JESComponent.38.Scale: Qw +JESComponent.38.Group: 19 + +JESComponent.39.Name: Rtrk_Tracking3_D2Beta1 +JESComponent.39.Param: PtMass +JESComponent.39.MassDef: Calo +JESComponent.39.Scale: D2Beta1 +JESComponent.39.Group: 23 + +JESComponent.40.Name: Rtrk_Tracking3_Tau32WTA +JESComponent.40.Param: PtMass +JESComponent.40.MassDef: Calo +JESComponent.40.Scale: Tau32WTA +JESComponent.40.Group: 27 + +JESComponent.41.Name: Rtrk_Tracking3_Tau21WTA +JESComponent.41.Param: PtMass +JESComponent.41.MassDef: Calo +JESComponent.41.Scale: Tau21WTA +JESComponent.41.Group: 31 + +JESComponent.42.Name: Rtrk_TotalStat_pT +JESComponent.42.Param: PtMass +JESComponent.42.MassDef: Calo +JESComponent.42.Scale: pT +JESComponent.42.Group: 8 + +JESComponent.43.Name: Rtrk_TotalStat_Split23 +JESComponent.43.Param: PtMass +JESComponent.43.MassDef: Calo +JESComponent.43.Scale: D23 +JESComponent.43.Group: 12 + +JESComponent.44.Name: Rtrk_TotalStat_Split12 +JESComponent.44.Param: PtMass +JESComponent.44.MassDef: Calo +JESComponent.44.Scale: D12 +JESComponent.44.Group: 16 + +JESComponent.45.Name: Rtrk_TotalStat_Qw +JESComponent.45.Param: PtMass +JESComponent.45.MassDef: Calo +JESComponent.45.Scale: Qw +JESComponent.45.Group: 20 + +JESComponent.46.Name: Rtrk_TotalStat_D2Beta1 +JESComponent.46.Param: PtMass +JESComponent.46.MassDef: Calo +JESComponent.46.Scale: D2Beta1 +JESComponent.46.Group: 24 + +JESComponent.47.Name: Rtrk_TotalStat_Tau32WTA +JESComponent.47.Param: PtMass +JESComponent.47.MassDef: Calo +JESComponent.47.Scale: Tau32WTA +JESComponent.47.Group: 28 + +JESComponent.48.Name: Rtrk_TotalStat_Tau21WTA +JESComponent.48.Param: PtMass +JESComponent.48.MassDef: Calo +JESComponent.48.Scale: Tau21WTA +JESComponent.48.Group: 32 + +JESComponent.49.Name: Top_massRes_mass +JESComponent.49.Param: PtMass +JESComponent.49.MassDef: Calo +JESComponent.49.Scale: MassRes +JESComponent.49.Group: 33 + +JESComponent.50.Name: WZ_massRes_mass +JESComponent.50.Param: PtMass +JESComponent.50.MassDef: Calo +JESComponent.50.Scale: MassRes +JESComponent.50.Group: 34 + +JESComponent.51.Name: Hbb_massRes_mass +JESComponent.51.Param: PtMass +JESComponent.51.MassDef: Calo +JESComponent.51.Scale: MassRes +JESComponent.51.Group: 35 + diff --git a/Reconstruction/Jet/JetUncertainties/share/UJ_2016/Moriond2017/UJ2016_CaloMass_WithJMR_weak_all.config b/Reconstruction/Jet/JetUncertainties/share/UJ_2016/Moriond2017/UJ2016_CaloMass_WithJMR_weak_all.config new file mode 100644 index 0000000000000000000000000000000000000000..1ec447ba9cd4d195e73b76cc86fc31074f3a67a8 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/share/UJ_2016/Moriond2017/UJ2016_CaloMass_WithJMR_weak_all.config @@ -0,0 +1,622 @@ + +############################################################################## +# +# JetUncertaintiesTool Input Settings for large R jets mass, pT +# and other substructure variables. +# This is the weak_all correlation assumption variant. +# +# +# January, 2017 +# +# S. Schramm, P-A Delsart, S. Meehan +# +############################################################################## + +UncertaintyRelease: 2016_Moriond2017 +SupportedJetDefs: AntiKt10LCTopoTrimmedPtFrac5SmallR20 +SupportedMCTypes: MC15c +UncertaintyRootFile: UJ_2016/Moriond2017/AntiKt10LCTopoTrimmedPtFrac5SmallR20_20170217_v3_jet1jet2withweights_PROCESSED.root + +FileValidHistogram: ValidRange +FileValidHistParam: PtMassAbsEta +FileValidHistMassDef: Calo + +############################################################################## +# +# Settings for components +# +############################################################################## + + +# Groups + + +JESGroup.1.Name: Rtrk_Baseline_mass +JESGroup.1.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, mass scale +JESGroup.1.Group: 1 + + +JESGroup.2.Name: Rtrk_Modelling_mass +JESGroup.2.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, mass scale +JESGroup.2.Group: 2 + + +JESGroup.3.Name: Rtrk_Tracking1_mass +JESGroup.3.Desc: 2016 Rtrk measurement, rel 20.7: Tracking1 component, mass scale +JESGroup.3.Group: 3 +JESGroup.3.Corr: Uncorrelated + + +JESGroup.4.Name: Rtrk_Tracking2_mass +JESGroup.4.Desc: 2016 Rtrk measurement, rel 20.7: Tracking2 component, mass scale +JESGroup.4.Group: 4 +JESGroup.4.Corr: Uncorrelated + + +JESGroup.5.Name: Rtrk_Tracking3_mass +JESGroup.5.Desc: 2016 Rtrk measurement, rel 20.7: Tracking3 component, mass scale +JESGroup.5.Group: 5 +JESGroup.5.Corr: Uncorrelated + + +JESGroup.6.Name: Rtrk_TotalStat_mass +JESGroup.6.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, mass scale +JESGroup.6.Group: 6 + + +JESGroup.7.Name: Rtrk_Baseline_pT +JESGroup.7.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, pT scale +JESGroup.7.Group: 7 + + +JESGroup.8.Name: Rtrk_Modelling_pT +JESGroup.8.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, pT scale +JESGroup.8.Group: 8 + + +JESGroup.9.Name: Rtrk_Tracking1_pT +JESGroup.9.Desc: 2016 Rtrk measurement, rel 20.7: Tracking1 component, pT scale +JESGroup.9.Group: 9 +JESGroup.9.Corr: Uncorrelated + + +JESGroup.10.Name: Rtrk_Tracking2_pT +JESGroup.10.Desc: 2016 Rtrk measurement, rel 20.7: Tracking2 component, pT scale +JESGroup.10.Group: 10 +JESGroup.10.Corr: Uncorrelated + + +JESGroup.11.Name: Rtrk_Tracking3_pT +JESGroup.11.Desc: 2016 Rtrk measurement, rel 20.7: Tracking3 component, pT scale +JESGroup.11.Group: 11 +JESGroup.11.Corr: Uncorrelated + + +JESGroup.12.Name: Rtrk_TotalStat_pT +JESGroup.12.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, pT scale +JESGroup.12.Group: 12 + + +JESGroup.13.Name: Rtrk_Baseline_Split23 +JESGroup.13.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, Split23 scale +JESGroup.13.Group: 13 + + +JESGroup.14.Name: Rtrk_Modelling_Split23 +JESGroup.14.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, Split23 scale +JESGroup.14.Group: 14 + + +JESGroup.15.Name: Rtrk_Tracking1_Split23 +JESGroup.15.Desc: 2016 Rtrk measurement, rel 20.7: Tracking1 component, Split23 scale +JESGroup.15.Group: 15 +JESGroup.15.Corr: Uncorrelated + + +JESGroup.16.Name: Rtrk_Tracking2_Split23 +JESGroup.16.Desc: 2016 Rtrk measurement, rel 20.7: Tracking2 component, Split23 scale +JESGroup.16.Group: 16 +JESGroup.16.Corr: Uncorrelated + + +JESGroup.17.Name: Rtrk_Tracking3_Split23 +JESGroup.17.Desc: 2016 Rtrk measurement, rel 20.7: Tracking3 component, Split23 scale +JESGroup.17.Group: 17 +JESGroup.17.Corr: Uncorrelated + + +JESGroup.18.Name: Rtrk_TotalStat_Split23 +JESGroup.18.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, Split23 scale +JESGroup.18.Group: 18 + + +JESGroup.19.Name: Rtrk_Baseline_Split12 +JESGroup.19.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, Split12 scale +JESGroup.19.Group: 19 + + +JESGroup.20.Name: Rtrk_Modelling_Split12 +JESGroup.20.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, Split12 scale +JESGroup.20.Group: 20 + + +JESGroup.21.Name: Rtrk_Tracking1_Split12 +JESGroup.21.Desc: 2016 Rtrk measurement, rel 20.7: Tracking1 component, Split12 scale +JESGroup.21.Group: 21 +JESGroup.21.Corr: Uncorrelated + + +JESGroup.22.Name: Rtrk_Tracking2_Split12 +JESGroup.22.Desc: 2016 Rtrk measurement, rel 20.7: Tracking2 component, Split12 scale +JESGroup.22.Group: 22 +JESGroup.22.Corr: Uncorrelated + + +JESGroup.23.Name: Rtrk_Tracking3_Split12 +JESGroup.23.Desc: 2016 Rtrk measurement, rel 20.7: Tracking3 component, Split12 scale +JESGroup.23.Group: 23 +JESGroup.23.Corr: Uncorrelated + + +JESGroup.24.Name: Rtrk_TotalStat_Split12 +JESGroup.24.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, Split12 scale +JESGroup.24.Group: 24 + + +JESGroup.25.Name: Rtrk_Baseline_Qw +JESGroup.25.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, Qw scale +JESGroup.25.Group: 25 + + +JESGroup.26.Name: Rtrk_Modelling_Qw +JESGroup.26.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, Qw scale +JESGroup.26.Group: 26 + + +JESGroup.27.Name: Rtrk_Tracking1_Qw +JESGroup.27.Desc: 2016 Rtrk measurement, rel 20.7: Tracking1 component, Qw scale +JESGroup.27.Group: 27 +JESGroup.27.Corr: Uncorrelated + + +JESGroup.28.Name: Rtrk_Tracking2_Qw +JESGroup.28.Desc: 2016 Rtrk measurement, rel 20.7: Tracking2 component, Qw scale +JESGroup.28.Group: 28 +JESGroup.28.Corr: Uncorrelated + + +JESGroup.29.Name: Rtrk_Tracking3_Qw +JESGroup.29.Desc: 2016 Rtrk measurement, rel 20.7: Tracking3 component, Qw scale +JESGroup.29.Group: 29 +JESGroup.29.Corr: Uncorrelated + + +JESGroup.30.Name: Rtrk_TotalStat_Qw +JESGroup.30.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, Qw scale +JESGroup.30.Group: 30 + + +JESGroup.31.Name: Rtrk_Baseline_D2Beta1 +JESGroup.31.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, D2Beta1 scale +JESGroup.31.Group: 31 + + +JESGroup.32.Name: Rtrk_Modelling_D2Beta1 +JESGroup.32.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, D2Beta1 scale +JESGroup.32.Group: 32 + + +JESGroup.33.Name: Rtrk_Tracking1_D2Beta1 +JESGroup.33.Desc: 2016 Rtrk measurement, rel 20.7: Tracking1 component, D2Beta1 scale +JESGroup.33.Group: 33 +JESGroup.33.Corr: Uncorrelated + + +JESGroup.34.Name: Rtrk_Tracking2_D2Beta1 +JESGroup.34.Desc: 2016 Rtrk measurement, rel 20.7: Tracking2 component, D2Beta1 scale +JESGroup.34.Group: 34 +JESGroup.34.Corr: Uncorrelated + + +JESGroup.35.Name: Rtrk_Tracking3_D2Beta1 +JESGroup.35.Desc: 2016 Rtrk measurement, rel 20.7: Tracking3 component, D2Beta1 scale +JESGroup.35.Group: 35 +JESGroup.35.Corr: Uncorrelated + + +JESGroup.36.Name: Rtrk_TotalStat_D2Beta1 +JESGroup.36.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, D2Beta1 scale +JESGroup.36.Group: 36 + + +JESGroup.37.Name: Rtrk_Baseline_Tau32WTA +JESGroup.37.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, Tau32WTA scale +JESGroup.37.Group: 37 + + +JESGroup.38.Name: Rtrk_Modelling_Tau32WTA +JESGroup.38.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, Tau32WTA scale +JESGroup.38.Group: 38 + + +JESGroup.39.Name: Rtrk_Tracking1_Tau32WTA +JESGroup.39.Desc: 2016 Rtrk measurement, rel 20.7: Tracking1 component, Tau32WTA scale +JESGroup.39.Group: 39 +JESGroup.39.Corr: Uncorrelated + + +JESGroup.40.Name: Rtrk_Tracking2_Tau32WTA +JESGroup.40.Desc: 2016 Rtrk measurement, rel 20.7: Tracking2 component, Tau32WTA scale +JESGroup.40.Group: 40 +JESGroup.40.Corr: Uncorrelated + + +JESGroup.41.Name: Rtrk_Tracking3_Tau32WTA +JESGroup.41.Desc: 2016 Rtrk measurement, rel 20.7: Tracking3 component, Tau32WTA scale +JESGroup.41.Group: 41 +JESGroup.41.Corr: Uncorrelated + + +JESGroup.42.Name: Rtrk_TotalStat_Tau32WTA +JESGroup.42.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, Tau32WTA scale +JESGroup.42.Group: 42 + + +JESGroup.43.Name: Rtrk_Baseline_Tau21WTA +JESGroup.43.Desc: 2016 Rtrk measurement, rel 20.7: Baseline component, Tau21WTA scale +JESGroup.43.Group: 43 + + +JESGroup.44.Name: Rtrk_Modelling_Tau21WTA +JESGroup.44.Desc: 2016 Rtrk measurement, rel 20.7: Modelling component, Tau21WTA scale +JESGroup.44.Group: 44 + + +JESGroup.45.Name: Rtrk_Tracking1_Tau21WTA +JESGroup.45.Desc: 2016 Rtrk measurement, rel 20.7: Tracking1 component, Tau21WTA scale +JESGroup.45.Group: 45 +JESGroup.45.Corr: Uncorrelated + + +JESGroup.46.Name: Rtrk_Tracking2_Tau21WTA +JESGroup.46.Desc: 2016 Rtrk measurement, rel 20.7: Tracking2 component, Tau21WTA scale +JESGroup.46.Group: 46 +JESGroup.46.Corr: Uncorrelated + + +JESGroup.47.Name: Rtrk_Tracking3_Tau21WTA +JESGroup.47.Desc: 2016 Rtrk measurement, rel 20.7: Tracking3 component, Tau21WTA scale +JESGroup.47.Group: 47 +JESGroup.47.Corr: Uncorrelated + + +JESGroup.48.Name: Rtrk_TotalStat_Tau21WTA +JESGroup.48.Desc: 2016 Rtrk measurement, rel 20.7: TotalStat component, Tau21WTA scale +JESGroup.48.Group: 48 + +JESGroup.49.Name: Top_massRes_mass +JESGroup.49.Desc: mass Resolution uncertainty for top topology +JESGroup.49.Type: Other +JESGroup.49.Corr: Uncorrelated +JESGroup.49.Group: 49 + +JESGroup.50.Name: WZ_massRes_mass +JESGroup.50.Desc: mass Resolution uncertainty for W/Z topology +JESGroup.50.Type: Other +JESGroup.50.Corr: Uncorrelated +JESGroup.50.Group: 50 + +JESGroup.51.Name: Hbb_massRes_mass +JESGroup.51.Desc: mass Resolution uncertainty for Higgs to bb topology +JESGroup.51.Type: Other +JESGroup.51.Corr: Uncorrelated +JESGroup.51.Group: 51 + + +# Components + +JESComponent.1.Name: Rtrk_Baseline_mass +JESComponent.1.Param: PtMass +JESComponent.1.MassDef: Calo +JESComponent.1.Scale: mass +JESComponent.1.Group: 1 + +JESComponent.2.Name: Rtrk_Modelling_mass +JESComponent.2.Param: PtMass +JESComponent.2.MassDef: Calo +JESComponent.2.Scale: mass +JESComponent.2.Group: 2 + +JESComponent.3.Name: Rtrk_Tracking1_mass +JESComponent.3.Param: PtMass +JESComponent.3.MassDef: Calo +JESComponent.3.Scale: mass +JESComponent.3.Group: 5 + +JESComponent.4.Name: Rtrk_Tracking2_mass +JESComponent.4.Param: PtMass +JESComponent.4.MassDef: Calo +JESComponent.4.Scale: mass +JESComponent.4.Group: 4 + +JESComponent.5.Name: Rtrk_Tracking3_mass +JESComponent.5.Param: PtMass +JESComponent.5.MassDef: Calo +JESComponent.5.Scale: mass +JESComponent.5.Group: 3 + +JESComponent.6.Name: Rtrk_TotalStat_mass +JESComponent.6.Param: PtMass +JESComponent.6.MassDef: Calo +JESComponent.6.Scale: mass +JESComponent.6.Group: 6 + +JESComponent.7.Name: Rtrk_Baseline_pT +JESComponent.7.Param: PtMass +JESComponent.7.MassDef: Calo +JESComponent.7.Scale: pT +JESComponent.7.Group: 7 + +JESComponent.8.Name: Rtrk_Baseline_Split23 +JESComponent.8.Param: PtMass +JESComponent.8.MassDef: Calo +JESComponent.8.Scale: D23 +JESComponent.8.Group: 13 + +JESComponent.9.Name: Rtrk_Baseline_Split12 +JESComponent.9.Param: PtMass +JESComponent.9.MassDef: Calo +JESComponent.9.Scale: D12 +JESComponent.9.Group: 19 + +JESComponent.10.Name: Rtrk_Baseline_Qw +JESComponent.10.Param: PtMass +JESComponent.10.MassDef: Calo +JESComponent.10.Scale: Qw +JESComponent.10.Group: 25 + +JESComponent.11.Name: Rtrk_Baseline_D2Beta1 +JESComponent.11.Param: PtMass +JESComponent.11.MassDef: Calo +JESComponent.11.Scale: D2Beta1 +JESComponent.11.Group: 31 + +JESComponent.12.Name: Rtrk_Baseline_Tau32WTA +JESComponent.12.Param: PtMass +JESComponent.12.MassDef: Calo +JESComponent.12.Scale: Tau32WTA +JESComponent.12.Group: 37 + +JESComponent.13.Name: Rtrk_Baseline_Tau21WTA +JESComponent.13.Param: PtMass +JESComponent.13.MassDef: Calo +JESComponent.13.Scale: Tau21WTA +JESComponent.13.Group: 43 + +JESComponent.14.Name: Rtrk_Modelling_pT +JESComponent.14.Param: PtMass +JESComponent.14.MassDef: Calo +JESComponent.14.Scale: pT +JESComponent.14.Group: 8 + +JESComponent.15.Name: Rtrk_Modelling_Split23 +JESComponent.15.Param: PtMass +JESComponent.15.MassDef: Calo +JESComponent.15.Scale: D23 +JESComponent.15.Group: 14 + +JESComponent.16.Name: Rtrk_Modelling_Split12 +JESComponent.16.Param: PtMass +JESComponent.16.MassDef: Calo +JESComponent.16.Scale: D12 +JESComponent.16.Group: 20 + +JESComponent.17.Name: Rtrk_Modelling_Qw +JESComponent.17.Param: PtMass +JESComponent.17.MassDef: Calo +JESComponent.17.Scale: Qw +JESComponent.17.Group: 26 + +JESComponent.18.Name: Rtrk_Modelling_D2Beta1 +JESComponent.18.Param: PtMass +JESComponent.18.MassDef: Calo +JESComponent.18.Scale: D2Beta1 +JESComponent.18.Group: 32 + +JESComponent.19.Name: Rtrk_Modelling_Tau32WTA +JESComponent.19.Param: PtMass +JESComponent.19.MassDef: Calo +JESComponent.19.Scale: Tau32WTA +JESComponent.19.Group: 38 + +JESComponent.20.Name: Rtrk_Modelling_Tau21WTA +JESComponent.20.Param: PtMass +JESComponent.20.MassDef: Calo +JESComponent.20.Scale: Tau21WTA +JESComponent.20.Group: 44 + +JESComponent.21.Name: Rtrk_Tracking1_pT +JESComponent.21.Param: PtMass +JESComponent.21.MassDef: Calo +JESComponent.21.Scale: pT +JESComponent.21.Group: 9 + +JESComponent.22.Name: Rtrk_Tracking1_Split23 +JESComponent.22.Param: PtMass +JESComponent.22.MassDef: Calo +JESComponent.22.Scale: D23 +JESComponent.22.Group: 15 + +JESComponent.23.Name: Rtrk_Tracking1_Split12 +JESComponent.23.Param: PtMass +JESComponent.23.MassDef: Calo +JESComponent.23.Scale: D12 +JESComponent.23.Group: 21 + +JESComponent.24.Name: Rtrk_Tracking1_Qw +JESComponent.24.Param: PtMass +JESComponent.24.MassDef: Calo +JESComponent.24.Scale: Qw +JESComponent.24.Group: 27 + +JESComponent.25.Name: Rtrk_Tracking1_D2Beta1 +JESComponent.25.Param: PtMass +JESComponent.25.MassDef: Calo +JESComponent.25.Scale: D2Beta1 +JESComponent.25.Group: 33 + +JESComponent.26.Name: Rtrk_Tracking1_Tau32WTA +JESComponent.26.Param: PtMass +JESComponent.26.MassDef: Calo +JESComponent.26.Scale: Tau32WTA +JESComponent.26.Group: 39 + +JESComponent.27.Name: Rtrk_Tracking1_Tau21WTA +JESComponent.27.Param: PtMass +JESComponent.27.MassDef: Calo +JESComponent.27.Scale: Tau21WTA +JESComponent.27.Group: 45 + +JESComponent.28.Name: Rtrk_Tracking2_pT +JESComponent.28.Param: PtMass +JESComponent.28.MassDef: Calo +JESComponent.28.Scale: pT +JESComponent.28.Group: 10 + +JESComponent.29.Name: Rtrk_Tracking2_Split23 +JESComponent.29.Param: PtMass +JESComponent.29.MassDef: Calo +JESComponent.29.Scale: D23 +JESComponent.29.Group: 16 + +JESComponent.30.Name: Rtrk_Tracking2_Split12 +JESComponent.30.Param: PtMass +JESComponent.30.MassDef: Calo +JESComponent.30.Scale: D12 +JESComponent.30.Group: 22 + +JESComponent.31.Name: Rtrk_Tracking2_Qw +JESComponent.31.Param: PtMass +JESComponent.31.MassDef: Calo +JESComponent.31.Scale: Qw +JESComponent.31.Group: 28 + +JESComponent.32.Name: Rtrk_Tracking2_D2Beta1 +JESComponent.32.Param: PtMass +JESComponent.32.MassDef: Calo +JESComponent.32.Scale: D2Beta1 +JESComponent.32.Group: 34 + +JESComponent.33.Name: Rtrk_Tracking2_Tau32WTA +JESComponent.33.Param: PtMass +JESComponent.33.MassDef: Calo +JESComponent.33.Scale: Tau32WTA +JESComponent.33.Group: 40 + +JESComponent.34.Name: Rtrk_Tracking2_Tau21WTA +JESComponent.34.Param: PtMass +JESComponent.34.MassDef: Calo +JESComponent.34.Scale: Tau21WTA +JESComponent.34.Group: 46 + +JESComponent.35.Name: Rtrk_Tracking3_pT +JESComponent.35.Param: PtMass +JESComponent.35.MassDef: Calo +JESComponent.35.Scale: pT +JESComponent.35.Group: 11 + +JESComponent.36.Name: Rtrk_Tracking3_Split23 +JESComponent.36.Param: PtMass +JESComponent.36.MassDef: Calo +JESComponent.36.Scale: D23 +JESComponent.36.Group: 17 + +JESComponent.37.Name: Rtrk_Tracking3_Split12 +JESComponent.37.Param: PtMass +JESComponent.37.MassDef: Calo +JESComponent.37.Scale: D12 +JESComponent.37.Group: 23 + +JESComponent.38.Name: Rtrk_Tracking3_Qw +JESComponent.38.Param: PtMass +JESComponent.38.MassDef: Calo +JESComponent.38.Scale: Qw +JESComponent.38.Group: 29 + +JESComponent.39.Name: Rtrk_Tracking3_D2Beta1 +JESComponent.39.Param: PtMass +JESComponent.39.MassDef: Calo +JESComponent.39.Scale: D2Beta1 +JESComponent.39.Group: 35 + +JESComponent.40.Name: Rtrk_Tracking3_Tau32WTA +JESComponent.40.Param: PtMass +JESComponent.40.MassDef: Calo +JESComponent.40.Scale: Tau32WTA +JESComponent.40.Group: 41 + +JESComponent.41.Name: Rtrk_Tracking3_Tau21WTA +JESComponent.41.Param: PtMass +JESComponent.41.MassDef: Calo +JESComponent.41.Scale: Tau21WTA +JESComponent.41.Group: 47 + +JESComponent.42.Name: Rtrk_TotalStat_pT +JESComponent.42.Param: PtMass +JESComponent.42.MassDef: Calo +JESComponent.42.Scale: pT +JESComponent.42.Group: 12 + +JESComponent.43.Name: Rtrk_TotalStat_Split23 +JESComponent.43.Param: PtMass +JESComponent.43.MassDef: Calo +JESComponent.43.Scale: D23 +JESComponent.43.Group: 18 + +JESComponent.44.Name: Rtrk_TotalStat_Split12 +JESComponent.44.Param: PtMass +JESComponent.44.MassDef: Calo +JESComponent.44.Scale: D12 +JESComponent.44.Group: 24 + +JESComponent.45.Name: Rtrk_TotalStat_Qw +JESComponent.45.Param: PtMass +JESComponent.45.MassDef: Calo +JESComponent.45.Scale: Qw +JESComponent.45.Group: 30 + +JESComponent.46.Name: Rtrk_TotalStat_D2Beta1 +JESComponent.46.Param: PtMass +JESComponent.46.MassDef: Calo +JESComponent.46.Scale: D2Beta1 +JESComponent.46.Group: 36 + +JESComponent.47.Name: Rtrk_TotalStat_Tau32WTA +JESComponent.47.Param: PtMass +JESComponent.47.MassDef: Calo +JESComponent.47.Scale: Tau32WTA +JESComponent.47.Group: 42 + +JESComponent.48.Name: Rtrk_TotalStat_Tau21WTA +JESComponent.48.Param: PtMass +JESComponent.48.MassDef: Calo +JESComponent.48.Scale: Tau21WTA +JESComponent.48.Group: 48 + +JESComponent.49.Name: Top_massRes_mass +JESComponent.49.Param: PtMass +JESComponent.49.MassDef: Calo +JESComponent.49.Scale: MassRes +JESComponent.49.Group: 49 + +JESComponent.50.Name: WZ_massRes_mass +JESComponent.50.Param: PtMass +JESComponent.50.MassDef: Calo +JESComponent.50.Scale: MassRes +JESComponent.50.Group: 50 + +JESComponent.51.Name: Hbb_massRes_mass +JESComponent.51.Param: PtMass +JESComponent.51.MassDef: Calo +JESComponent.51.Scale: MassRes +JESComponent.51.Group: 51 diff --git a/Reconstruction/Jet/JetUncertainties/share/analysisInputs/UnknownFlavourComp.root b/Reconstruction/Jet/JetUncertainties/share/analysisInputs/UnknownFlavourComp.root index c91fef7e8383c820807cac80857166362cb744a2..283a55063f27dcd4730f710faab04d7c177971e3 100644 Binary files a/Reconstruction/Jet/JetUncertainties/share/analysisInputs/UnknownFlavourComp.root and b/Reconstruction/Jet/JetUncertainties/share/analysisInputs/UnknownFlavourComp.root differ diff --git a/Reconstruction/Jet/JetUncertainties/src/components/JetUncertainties_entries.cxx b/Reconstruction/Jet/JetUncertainties/src/components/JetUncertainties_entries.cxx index e7d8e834307cc731624cfe41b64b8393fb08ee02..9869cff5b5a75fd1bdd774c00e3846803e67ed3d 100644 --- a/Reconstruction/Jet/JetUncertainties/src/components/JetUncertainties_entries.cxx +++ b/Reconstruction/Jet/JetUncertainties/src/components/JetUncertainties_entries.cxx @@ -1,4 +1,6 @@ +// Package include(s): #include "JetUncertainties/JetUncertaintiesTool.h" +#include "JetUncertainties/FFJetSmearingTool.h" -DECLARE_COMPONENT( JetUncertaintiesTool ) - +DECLARE_COMPONENT(JetUncertaintiesTool) +DECLARE_COMPONENT(CP::FFJetSmearingTool) diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/CommonScripts/BandUtils.py b/Reconstruction/Jet/JetUncertainties/testingMacros/CommonScripts/BandUtils.py index 2b7f632e1174dec72b0457e5ee404c227482fc86..b0f3815c85c39022c023e762060b6c1eff0d9885 100755 --- a/Reconstruction/Jet/JetUncertainties/testingMacros/CommonScripts/BandUtils.py +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/CommonScripts/BandUtils.py @@ -269,7 +269,9 @@ def makeSingleBandPlot (middleGraph, errorGraphs) : #print "adding ", a sumErrorY += a*a + #print '***REMOVED*** ', sumErrorY sumErrorY = sqrt(sumErrorY) + #print ***REMOVED***, sumErrorY if( iPoint < middleGraph.GetN()): thisBandsGraph.SetPoint(iPoint, dataPointX, 0) diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/CalculateHighPtTerm.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/CalculateHighPtTerm.py new file mode 100755 index 0000000000000000000000000000000000000000..04436ef876ca428425079520b107b82b1d07a132 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/CalculateHighPtTerm.py @@ -0,0 +1,79 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers + +# Following in-situ components need to be combined in quadrature to make the histogram from which to subtract + +from ParseInsituInput import ReadInSituHistograms + +InSituCompDictionary = ReadInSituHistograms("/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Fall2018/AllInSitu/") +SingleParticleFile = TFile("/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Fall2018/HighPt/Release20p7_SingleParticle_FullRange.root") + + +jetDefList = [ + 'AntiKt4Topo_EMJES', + 'AntiKt4PFlow_EMJES', + ] + +outputFile = TFile("Release20p7_HighPtTerm_Fall2018adjusted.root","RECREATE") + +for jetDef in jetDefList : + + print InSituCompDictionary.keys() + inSituHist = InSituCompDictionary[jetDef]['InSituProp_PunchThroughMC'].Clone("InSitu_Quad") + inSituHist.Reset() + inSituHist.SetDirectory(0) + + # Fill inSituHist with sum of squares of components. + for histkey in InSituCompDictionary[jetDef] : + + hist = InSituCompDictionary[jetDef][histkey] + + for bin in range(0, hist.GetNbinsX()+2) : + assert(inSituHist.GetBinLowEdge(bin) == hist.GetBinLowEdge(bin) and inSituHist.GetBinWidth(bin) == hist.GetBinWidth(bin)) + + inSituHist.SetBinContent(bin,inSituHist.GetBinContent(bin)+math.pow(hist.GetBinContent(bin),2)) + + # This is now (total in situ)^2 + + # Fetch single particle hist + spHist = SingleParticleFile.Get("totalHist") + + outputHist = spHist.Clone("adjustedInterpolatedSingleParticleUncertainty") + outputHist.SetDirectory(0) + outputHist.Reset() + + # Loop over in highpT bins and get an interpolated SP value in each; + # calculate difference and fill result + for bin in range(0,spHist.GetNbinsX()+2) : + + pT = spHist.GetXaxis().GetBinCenter(bin) + inSituBin = inSituHist.FindBin(pT) + if inSituBin > inSituHist.GetNbinsX() : inSituBin = inSituHist.GetNbinsX() + inSituVal2 = inSituHist.GetBinContent(inSituBin) + spVal = spHist.Interpolate(pT) + + diff = spVal*spVal - inSituVal2 + + if diff < 0 : + keepSPVal = 0 + else : + keepSPVal = math.sqrt(spVal*spVal - inSituVal2) + + if pT < 2200 : + smoothedSPVal = 0 + elif pT < 2400 : + smoothedSPVal = keepSPVal * ((pT - 2200)/200) + else : + smoothedSPVal = keepSPVal + + outputHist.SetBinContent(bin,smoothedSPVal) + + outputFile.cd() + outputHist.Write("SingleParticle_HighPt_{0}".format(jetDef)) + +outputFile.Close() + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/CalculateHighPtTerm_noMJB.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/CalculateHighPtTerm_noMJB.py new file mode 100755 index 0000000000000000000000000000000000000000..6bee45f36e73a12925c186d11942bd0ecf04ade9 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/CalculateHighPtTerm_noMJB.py @@ -0,0 +1,81 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers + +# Following in-situ components need to be combined in quadrature to make the histogram from which to subtract + +from ParseInsituInput_MJB import ReadInSituHistograms + +InSituCompDictionary = ReadInSituHistograms("/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Moriond2018/forMJBInputs_GammaZJet") +SingleParticleFile = TFile("/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Moriond2018/HighPt2012/AggressiveHighPt_Final2014.root") + +jetDefList = [ 'AntiKt4Topo_EMJES', + 'AntiKt4PFlow_EMJES', + ] + +outputFile = TFile("2012HighPtTerm_2017Moriond2018adjusted.root","RECREATE") + +for jetDef in jetDefList : + + inSituHist = InSituCompDictionary[jetDef]['Zjet_dPhi'].Clone("InSitu_Quad") + inSituHist.Reset() + inSituHist.SetDirectory(0) + + # Fill inSituHist with sum of squares of components. + for histkey in InSituCompDictionary[jetDef] : + + hist = InSituCompDictionary[jetDef][histkey] + + for bin in range(1, hist.GetNbinsX()+1) : + #print "Comparing Zjet_dPhi with",histkey,":",inSituHist.GetBinLowEdge(bin),"==",hist.GetBinLowEdge(bin),"and",inSituHist.GetBinWidth(bin),"==",hist.GetBinWidth(bin) + assert(inSituHist.GetBinLowEdge(bin) == hist.GetBinLowEdge(bin) and inSituHist.GetBinWidth(bin) == hist.GetBinWidth(bin)) + + inSituHist.SetBinContent(bin,inSituHist.GetBinContent(bin)+math.pow(hist.GetBinContent(bin),2)) + + # This is now (total in situ)^2 + + # Fetch single particle hist + # For PFlow, we are using EM hist + spHist = SingleParticleFile.Get("SingleParticle_HighPt_AntiKt4Topo_EMJES") + print "Setting all to",spHist.GetBinContent(spHist.GetNbinsX()) + for bin in range(1,spHist.GetNbinsX()+1) : + spHist.SetBinContent(bin,spHist.GetBinContent(spHist.GetNbinsX())) + + outputHist = spHist.Clone("adjustedInterpolatedSingleParticleUncertainty") + outputHist.SetDirectory(0) + outputHist.Reset() + + # Loop over in highpT bins and get an interpolated SP value in each; + # calculate difference and fill result + for bin in range(0,spHist.GetNbinsX()+2) : + + pT = spHist.GetXaxis().GetBinCenter(bin) + inSituBin = inSituHist.FindBin(pT) + if inSituBin > inSituHist.GetNbinsX() : inSituBin = inSituHist.GetNbinsX() + inSituVal2 = inSituHist.GetBinContent(inSituBin) + spVal = spHist.Interpolate(pT) + + diff = spVal*spVal - inSituVal2 + + if diff < 0 : + keepSPVal = 0 + else : + keepSPVal = math.sqrt(spVal*spVal - inSituVal2) + + if pT < 800 : + smoothedSPVal = 0 + elif pT < 1000 : + smoothedSPVal = keepSPVal * ((pT - 800)/200) + else : + smoothedSPVal = keepSPVal + + outputHist.SetBinContent(bin,smoothedSPVal) + + outputFile.cd() + outputHist.Write("SingleParticle_HighPt_{0}".format(jetDef)) + +outputFile.Close() + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/CopyJERHists.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/CopyJERHists.py new file mode 100755 index 0000000000000000000000000000000000000000..cf5b105d54570f0d43e978bc35f287906009ce25 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/CopyJERHists.py @@ -0,0 +1,27 @@ +from ROOT import * +from array import array +import sys +import os +import glob +import re +import math + +from ParseCurrentFile import ReadCurrentHistograms + +def ReadJERHistograms(fileToRead) : + + print "Beginning readJERHistograms" + + # Now read the histograms + print "Reading JER hists from input..." + # For now, everything except flavour and cross calibration inputs + # are read in from the final 2012 calibration files. + # Input file and jet types + theCurrentHistos = ReadCurrentHistograms(fileToRead) + + for jettype in theCurrentHistos.keys() : + for systname in theCurrentHistos[jettype].keys() : + if not systname.startswith("JER_") : + del theCurrentHistos[jettype][systname] + + return theCurrentHistos \ No newline at end of file diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/CreateNonClosureInput.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/CreateNonClosureInput.py new file mode 100755 index 0000000000000000000000000000000000000000..fd1f385fdceb28b164d5b2ceef505fc181fdeff8 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/CreateNonClosureInput.py @@ -0,0 +1,32 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers + +## Right now we don't support AFII but we still need non-closure histograms for Pythia8. +# Create blank ones and add them. + +SystematicNameDictionary = { + 'RelativeNonClosure_AFII_AntiKt4EMTopo' : 'RelativeNonClosure_AFII', + 'RelativeNonClosure_AFII_AntiKt4EMPFlow' : 'RelativeNonClosure_AFII' + } + +jetDefList = [ 'AntiKt4Topo_EMJES', 'AntiKt4PFlow_EMJES'] + +def CreateNonClosureHistograms(): + + histos = {} + for jetDef in jetDefList : + histos[jetDef] = {} + + # Add a blank nonclosure histo for Pythia8 + # Also add a blank Closeby histo for Pythia8 + etaBins = [min(ProviderHistoHelpers.GetDefaultEtaBins()),0,max(ProviderHistoHelpers.GetDefaultEtaBins())] + histos[jetDef]["RelativeNonClosure_MC16"] = ProviderHistoHelpers.MakeProviderHisto("RelativeNonClosure_MC16",ptBins=[15,1000,2500],etaBins=etaBins) + histos[jetDef]["RelativeNonClosure_MC16"].SetDirectory(0) + histos[jetDef]["CloseBy_Pythia8"] = ProviderHistoHelpers.MakeProviderHisto("CloseBy_MC16",ptBins=[15,1000,2500],etaBins=etaBins) + histos[jetDef]["CloseBy_Pythia8"].SetDirectory(0) + + return histos diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/MakeFileForMJB.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/MakeFileForMJB.py new file mode 100755 index 0000000000000000000000000000000000000000..35468c1fb4a7d83a498af2bf09caee1a99d51c20 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/MakeFileForMJB.py @@ -0,0 +1,144 @@ +from ROOT import * +from array import array +import sys +import os +import glob +import re +import math + +from ParseEtaIntercalInput import ReadEtaIntercalibrationHistograms +from ParseInsituInput_MJB import ReadInSituHistograms +from ParsePileupInput import ReadPileupHistograms +from ParseFlavourInput import ReadFlavourHistograms +from ParsePunchthroughInput import ReadPunchthroughHistograms +from Parse2012Input import Read2012Histograms + +#http://stackoverflow.com/questions/2669059/how-to-sort-alpha-numeric-set-in-python +from itertools import groupby +def natural_sort(s): + return [int(''.join(g)) if k else ''.join(g) for k, g in groupby(s[0], str.isdigit)] + +# Design: This is to make a file entirely from scratch. +# All components are assumed available in new versions. +# If that is not the case borrow parallel script from +# the Moriond 2016 directory (where punchthrough was kept from 2012) + +# Full list of required inputs, distinguished by needing them +# from a different person +# - In situ terms +# - Eta intercalibration +# - Pileup +# - Flavour +# - Punchthrough + + +# NOTES +# For this Moriond release, all MC histograms being kept from 20.1 as no changes observed to MC. +# Thus flavour histograms already validated at an earlier stage. +# Things below were done in pre-recs and are currently being done here: +# - Freeze flavour histograms by hand wherever input histogram falls below 0: extrapolate forward in pT from around 2 TeV centrally and from lower pT as eta increases. +# - FlavorResponse histogram inverted from input file to match Run I convention +freezeFlavourInPt = False +# Punchthrough needs to be checked to ensure axes are where we think they are +# Eta intercalibration currently includes TWO non-closure terms: +# - one with all bins used +# - one with only bins in 2.0 to 2.6 used (consider this an OFC uncertainty) +# Pileup fixed <mu> and <NPV> values are being kept from 2015 at this stage. +# In situ terms: +# - Using OOC from DB for MPF Z+jet results +# - Using small value MC generator uncertainty in Z+jets +# essentially due to how close nominal and alternate +# samples are. Not prioritising rebinned version, since fluctuations +# appear statistical. + +########################################## + +# Check useage and store arguments +if len(sys.argv) < 3: + print "USAGE: Expected the following arguments" + print " 1. Directory path to V+jet calibrations" + print " 2. Eta intercalibration directory path" + print " 3. Pileup directory path" + print " 5. Flavour directory path" + print " 6. Punchthrough directory path" + exit(1) + +outBaselineFile = "JESUncertainty_forMJB.root" +theVPlusJetsDir = sys.argv[1] +etaIntercalDir = sys.argv[2] +pileupDir = sys.argv[3] +flavourDir = sys.argv[4] +punchthroughDir = sys.argv[5] + +# Ensure that all of the directories exist +if not outBaselineFile.endswith(".root"): + print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile + exit(2) +if not os.path.exists(theVPlusJetsDir): + print "V+jets directory does not exist:",theVPlusJetsDir + exit(3) +if not os.path.exists(etaIntercalDir): + print "Eta intercalibration directory does not exist:",etaIntercalDir + exit(4) +if not os.path.exists(pileupDir): + print "Pileup directory does not exist:",pileupDir + exit(5) +if not os.path.exists(flavourDir): + print "Flavour directory does not exist:",flavourDir + exit(6) +if not os.path.exists(punchthroughDir): + print "Punchthrough directory does not exist:",punchthroughDir + exit(7) + + +# Store everything in memory! +currentDir = gDirectory +gROOT.cd() + +# Now read the histograms +print "Reading inputs..." +# For now, everything except flavour and cross calibration inputs +# are read in from the final 2012 calibration files. +theVPlusJetsHistos = ReadInSituHistograms(theVPlusJetsDir) # Check! +etaIntercalHistos = ReadEtaIntercalibrationHistograms(etaIntercalDir) +pileupHistos = ReadPileupHistograms(pileupDir) + +flavourHistos = ReadFlavourHistograms(flavourDir,freezeFlavourInPt) # True flag freezes uncertainty above pT = 2TeV (lower at higher eta) + +punchthroughHistos = ReadPunchthroughHistograms(punchthroughDir) + +# Make one mega-dictionary +print "Merging inputs..." +jetDefs = {"AntiKt4Topo_EMJES" : "AntiKt4EMTopo", "AntiKt4PFlow_EMJES" : "AntiKt4EMPFlow"} +systematics = {} +for aJetDef in jetDefs.keys(): + + systematics[aJetDef] = {} + dictsToUse = [punchthroughHistos, + etaIntercalHistos, + theVPlusJetsHistos, + pileupHistos, + flavourHistos] + + for dictionary in dictsToUse : + print dictionary + print aJetDef + systematics[aJetDef].update(dictionary[aJetDef].items()) + + print systematics[aJetDef] + + +# Loop over the mega-dictionary and write results +print "Writing to output file",outBaselineFile,"..." +baselineFile = TFile(outBaselineFile,"RECREATE") +for aJetDef,aSyst in sorted(systematics.iteritems(),key=natural_sort): + for aSystName,aSystHisto in sorted(aSyst.iteritems(),key=natural_sort): + baselineFile.cd() + aSystHisto.SetTitle(aSystName+"_"+jetDefs[aJetDef]) + aSystHisto.Write(aSystHisto.GetTitle()) + +# Done, close the files, revert directory +baselineFile.Close() +gDirectory = currentDir +print "Done!" + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/MakeNewFileFromOldAndSubstitution.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/MakeNewFileFromOldAndSubstitution.py new file mode 100755 index 0000000000000000000000000000000000000000..8fe0e391ae93c5529bf9ed0c6fcad12bfb4d737c --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/MakeNewFileFromOldAndSubstitution.py @@ -0,0 +1,110 @@ +from ROOT import * +from array import array +import sys +import os +import glob +import re +import math + +from ParseCurrentFile import ReadCurrentHistograms + + +#http://stackoverflow.com/questions/2669059/how-to-sort-alpha-numeric-set-in-python +from itertools import groupby +def natural_sort(s): + return [int(''.join(g)) if k else ''.join(g) for k, g in groupby(s[0], str.isdigit)] + +# Here, set file(s) from which to take replacement histograms and what names to switch +jetreplacements = {"AntiKt4EMTopo":"AntiKt4Topo_EMJES"} +replacements = {} +replacements["/cluster/warehouse/kpachal/JetCalibration/JetUncertainties/JetUncertainties/inputs/PunchThrough/"] = { + "PunchThrough_MC15" : "PunchThrough_MC15", +} + +# Here, specify histograms you want to get rid of altogether +deletions = [] + +# Check useage and store arguments +if len(sys.argv) < 3: + print "USAGE: Expected the following arguments" + print " 1. Root file to use as template" + print " 2. Name of output root file to create" + exit(1) + +inputFile = sys.argv[1] +outBaselineFile = sys.argv[2] + +# Ensure that all of the directories exist +if not outBaselineFile.endswith(".root"): + print "Output ROOT file doesn't appear to be a root file:",outBaselineFile + exit(2) +if not os.path.exists(inputFile): + print "Input file does not exist:",inputFile + exit(3) +for filename in replacements.keys(): + if not os.path.exists(filename) : + print "Replacement input file does not exist:",filename + exit(4) + +# Now read the histograms +print "Reading inputs..." +# For now, everything except flavour and cross calibration inputs +# are read in from the final 2012 calibration files. +# Input file and jet types +theCurrentHistos = ReadCurrentHistograms(inputFile,jetreplacements.keys()) + +import ParseFlavourInput +import ParseNonClosureInput +import ParsePunchthroughInput + +theReplacementHistos = {} +for filename in replacements.keys() : + if "flavor" in filename or "Flavor" in filename or "flavour" in filename or "Flavour" in filename : + thisset = ParseFlavourInput.ReadFlavourHistograms(filename) + elif "AFII_Uncertainty" in filename : + thisset = ParseNonClosureInput.ReadNonClosureHistograms(filename,True) + print "Just retrieved",thisset + elif "PunchThrough" in filename : + thisset = ParsePunchthroughInput.ReadPunchthroughHistograms(filename) + else : + thisset = ReadCurrentHistograms(filename,jetreplacements.keys()) + print thisset + theReplacementHistos.update(thisset) + +# Make one mega-dictionary +print "Merging inputs..." +jetDefs = ["AntiKt4EMTopo"]#,"AntiKt4Topo_LCJES","AntiKt6Topo_EMJES","AntiKt6Topo_LCJES"] +systematics = {} +validities = {} +for aJetDef in jetDefs : + systematics[aJetDef] = dict( + theCurrentHistos[aJetDef].items() + ) + +# Loop over the mega-dictionary and write results +print "Writing to output file",outBaselineFile,"..." +baselineFile = TFile(outBaselineFile,"RECREATE") +for aJetDef,aSyst in sorted(systematics.iteritems(),key=natural_sort): + for aSystName,aSystHisto in sorted(aSyst.iteritems(),key=natural_sort): + baselineFile.cd() + for filename in replacements.keys() : + if aSystName in replacements[filename].keys() : + print "Writing new version of",aSystName + newName = replacements[filename][aSystName] + newHist = theReplacementHistos[jetreplacements[aJetDef]][newName] + newHist.SetDirectory(0) + newHist.SetTitle(aSystName+"_"+aJetDef) + print "Giving it name",newHist.GetTitle() + newHist.Write(newHist.GetTitle()) + elif aSystName in deletions : + print "Deleting histogram",aSystName + continue + else : + print "Keeping original version of",aSystName + aSystHisto.SetTitle(aSystName+"_"+aJetDef) + aSystHisto.Write(aSystHisto.GetTitle()) + +# Done, close the files, revert directory +baselineFile.Close() +print "Done!" + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/Parse2012Input.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/Parse2012Input.py new file mode 100755 index 0000000000000000000000000000000000000000..cecbe33e3b3a2d3e6041245de82aefb24346c2cb --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/Parse2012Input.py @@ -0,0 +1,140 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers + +# Dictionary to translate from Bogan's names to provider names +useJetCollections = {"AntiKt4EMTopo": "AntiKt4Topo_EMJES", "AntiKt4LCTopo": "AntiKt4Topo_LCJES"} + +haveUpdatedVersions = ["FlavorResponse", + "flavorCompGlu", + "flavorCompLight", + "Pileup_OffsetMu", + "Pileup_OffsetNPV", + "Pileup_PtTerm_Mu", + "Pileup_PtTerm_NPV", +# "PunchThrough_AFII", +# "PunchThrough_MC12", + "RelativeNonClosure_AFII", + "RelativeNonClosure_MC12", + "EtaIntercalibration_Modelling", + "EtaIntercalibration_TotalStat",] + +def GetKeyNames(self,dir=""): + self.cd(dir) + return [key.GetName() for key in gDirectory.GetListOfKeys()] +TFile.GetKeyNames = GetKeyNames + +def Read2012Histograms(dirName,scaleEtaInter3Regions=False,scaleEtaInter2Regions=False): + removeInSitu = False + if not dirName.endswith("/"): + dirName = dirName + "/" + + # Just one file here with everything in it. + aSystFile = dirName + "JESUncertainty_2012.root" + systematicFile = TFile(aSystFile,"READ") + + histos = {} + for key in systematicFile.GetKeyNames() : + + # Formatting is all already correct. + + # Only keep things of the jet collections we are using. + jettype = key.split("_")[-1] + if jettype not in useJetCollections.keys() : + continue + elif useJetCollections[jettype] not in histos : + print "Adding extra dict..." + histos[useJetCollections[jettype]] = {} + + # Only keep things for which we do not have a more current version. + systname = key.replace("_"+jettype,"") + if systname in haveUpdatedVersions : + continue + + histo = systematicFile.Get(key) + histo.SetDirectory(0) + + if key.find("EtaIntercalibration_Modelling")!=-1 and (scaleEtaInter3Regions or scaleEtaInter2Regions) : + + print "OH NO!!!" + return + + # Loop over pT bins. + for xbin in range(histo.GetNbinsX()+2) : + # Loop out in eta. + for ybin in range(histo.GetNbinsY()+2) : + run1val = histo.GetBinContent(xbin,ybin) + #print "Bin at pT ",histo.GetXaxis().GetBinCenter(xbin)," and [ylow,y,yhigh] = ", binYLow, histo.GetYaxis().GetBinCenter(ybin), binYHigh + # Store bin contents as we go out: last one is one we want as frozen value. + if abs(histo.GetYaxis().GetBinCenter(ybin)) < 0.8 : + continue + elif 0.8 < abs(histo.GetYaxis().GetBinCenter(ybin)) < 2.5 : + if scaleEtaInter3Regions : + histo.SetBinContent(xbin,ybin,2.0*run1val) + else : + continue + else : + histo.SetBinContent(xbin,ybin,3.0*run1val) + + if (key.find("LAr_")!=-1 or key.find("Zjet_")!=-1 or key.find("Gjet")!=-1) and removeInSitu : + + # Loop over all bins. If outside eta range, set to "no uncertainty" = 0 + for xbin in range(histo.GetNbinsX()+2) : + for ybin in range(histo.GetNbinsY()+2) : + # Set to zero if outside of eta range. + #print 'Eta is', abs(histo.GetYaxis().GetBinCenter(ybin)) + if abs(histo.GetYaxis().GetBinCenter(ybin)) > 0.8 : + histo.SetBinContent(xbin,ybin,0.0) + else : + continue + #print "Leaving bin content." + + if key.find("PunchThrough")!=-1 : + + # Find maximum value on old histogram: we will use this everywhere + maxVal = histo.GetMaximum() + print "For punchthrough, using max val",maxVal + + # Loop over all bins in x, y, z. + for xbin in range(histo.GetNbinsX()+2) : + for ybin in range(histo.GetNbinsY()+2) : + for zbin in range(histo.GetNbinsZ()+2) : + # Permitted regions are only: + # - pT > 50 GeV + # - eta < 2.7 + # - NSegments > 20 + + # x axis is pT. + # y axis is nSegments + # z axis is eta + if histo.GetXaxis().GetBinCenter(xbin) < 50 or \ + histo.GetYaxis().GetBinCenter(ybin) < 20 or \ + histo.GetZaxis().GetBinCenter(zbin) > 2.7 : + histo.SetBinContent(xbin,ybin,zbin,0.0) + + else : + # Set to maximum value + histo.SetBinContent(xbin,ybin,zbin,maxVal) + + if key.find("MC12") : + # New histo + newhist = histo.Clone() + oldname = histo.GetName() + newname = oldname.replace("MC12","MC15") + newhist.SetName(newname) + newkey = systname.replace("MC12","MC15") + newhist.SetDirectory(0) + histos[useJetCollections[jettype]][newkey] = newhist + continue + + histos[useJetCollections[jettype]][systname] = histo + + # Done, return dictionary of histos + return histos + + + + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseCrossCalInput.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseCrossCalInput.py new file mode 100755 index 0000000000000000000000000000000000000000..65a414d179c51ca76148cf57e082e3ed32c02a93 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseCrossCalInput.py @@ -0,0 +1,182 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers + +SystematicNameDictionary = { + 'Xcalib_50nsVs25ns_AntiKt4EMTopo':'Xcalib_50nsVs25ns', + 'Xcalib_5Vs4sample_AntiKt4EMTopo':'Xcalib_5Vs4sample', + 'Xcalib_TopoClustering_AntiKt4EMTopo':'Xcalib_TopoClustering', + 'Xcalib_EarlyData_AntiKt4EMTopo':'Xcalib_EarlyData', + 'Xcalib_NoiseThreshold_AntiKt4EMTopo':'Xcalib_NoiseThreshold', + 'Xcalib_UnderlyingEvent_AntiKt4EMTopo':'Xcalib_UnderlyingEvent' + } + +jetDefDict = { + '' : 'AntiKt4Topo_EMJES', + } + +def ReadCrossCalHistograms(dirName,scaleCrossCalVal=1.0,freezeCrossCalAll=False,freezeCrossCalBarrel=False,freezeCrossCalCentral=False): + if not dirName.endswith("/"): + dirName = dirName + "/" + + # Run over each file (one per jet definition) + histos = {} + files = sorted(glob.glob(dirName+"*.root")) + for aFileName in files: + # Determine the jet definition + jetDef = "" + for aFileDef,aJetDef in jetDefDict.iteritems(): + if aFileDef in aFileName: + jetDef = aJetDef + break + if jetDef == "": + print "Failed to determine jet definition for file:",aFileName + return None + + histos[jetDef] = {} + + # Read in the histograms of interest from the file + inFile = TFile(aFileName,"READ") + + for histName in inFile.GetKeyNames(): + + # Skip validity histograms. + if 'valid' in histName : + continue + + systematicName = SystematicNameDictionary[histName]+"_"+jetDef + histo = inFile.Get(histName) + if histo is None: + print "Failed to get histogram:",systematicName + return None + histo.SetName(systematicName+"_old") + + if freezeCrossCalAll or freezeCrossCalBarrel or freezeCrossCalCentral : + # Loop over pT bins. + for xbin in range(histo.GetNbinsX()+2) : + # Loop out in eta. + freezeval = 0 + for ybin in range(histo.GetNbinsY()+2) : + #print "Bin at pT ",histo.GetXaxis().GetBinCenter(xbin)," and [ylow,y,yhigh] = ", binYLow, histo.GetYaxis().GetBinCenter(ybin), binYHigh + # Store bin contents as we go out: last one is one we want as frozen value. + eta = abs(histo.GetYaxis().GetBinCenter(ybin)) + if eta < 0.8 : + freezeval = histo.GetBinContent(xbin,ybin) + else : + if (eta < 2.5 and freezeCrossCalBarrel) or freezeCrossCalAll : + histo.SetBinContent(xbin,ybin,freezeval*scaleCrossCalVal) + else : + histo.SetBinContent(xbin,ybin,0) + + + # Histo has different range, extend it + histoNew = ProviderHistoHelpers.ExtendPtRangeOfHisto(histo,systematicName) + histoSym = ProviderHistoHelpers.SymmetrizeHistoInEta(histoNew,systematicName) + histoSym.SetDirectory(0) + + # If this is the 50 vs 25 ns histogram, we need to separate it by eta region. + if '50nsVs25ns' in histName : + CentralHist = histo.Clone() + CentralHist.SetName("Central_holder") + ForwardHist = histo.Clone() + ForwardHist.SetName("Forward_holder") + # Loop over pT bins. + for xbin in range(histo.GetNbinsX()+2) : + # Loop out in eta. + freezeval = 0 + for ybin in range(histo.GetNbinsY()+2) : + #print "Bin at pT ",histo.GetXaxis().GetBinCenter(xbin)," and [ylow,y,yhigh] = ", binYLow, histo.GetYaxis().GetBinCenter(ybin), binYHigh + # Store bin contents as we go out: last one is one we want as frozen value. + eta = abs(histo.GetYaxis().GetBinCenter(ybin)) + if eta < 0.8 : + freezeval = histo.GetBinContent(xbin,ybin) + ForwardHist.SetBinContent(xbin,ybin,0.0) + CentralHist.SetBinContent(xbin,ybin,freezeval) + else : + ForwardHist.SetBinContent(xbin,ybin,freezeval) + CentralHist.SetBinContent(xbin,ybin,0.0) + + # Now do symmetrization for these hists and write to file. + NewCentral = ProviderHistoHelpers.ExtendPtRangeOfHisto(CentralHist,systematicName+"holder") + CentralSym = ProviderHistoHelpers.SymmetrizeHistoInEta(NewCentral,SystematicNameDictionary[histName]+"_Central_"+jetDef) + CentralSym.SetDirectory(0) + histos[jetDef][SystematicNameDictionary[histName]+"_Central"] = CentralSym + NewForward = ProviderHistoHelpers.ExtendPtRangeOfHisto(ForwardHist,systematicName+"holder") + ForwardSym = ProviderHistoHelpers.SymmetrizeHistoInEta(NewForward,SystematicNameDictionary[histName]+"_Forward_"+jetDef) + ForwardSym.SetDirectory(0) + histos[jetDef][SystematicNameDictionary[histName]+"_Forward"] = ForwardSym + + # If this is the early data histogram, we need to deactivate it in the central region for 25 ns data. + if 'EarlyData' in histName : + ForwardHist = histo.Clone() + ForwardHist.SetName("EarlyData_Forward_holder") + # Loop over pT bins. + for xbin in range(histo.GetNbinsX()+2) : + # Loop out in eta. + for ybin in range(histo.GetNbinsY()+2) : + #print "Bin at pT ",histo.GetXaxis().GetBinCenter(xbin)," and [ylow,y,yhigh] = ", binYLow, histo.GetYaxis().GetBinCenter(ybin), binYHigh + # Store bin contents as we go out: last one is one we want as frozen value. + eta = abs(histo.GetYaxis().GetBinCenter(ybin)) + if eta < 0.8 : + ForwardHist.SetBinContent(xbin,ybin,0.0) + + # Now do symmetrization and write to file. + NewForward = ProviderHistoHelpers.ExtendPtRangeOfHisto(ForwardHist,systematicName+"holder") + ForwardSym = ProviderHistoHelpers.SymmetrizeHistoInEta(NewForward,SystematicNameDictionary[histName]+"_Forward_"+jetDef) + ForwardSym.SetDirectory(0) + histos[jetDef][SystematicNameDictionary[histName]+"_Forward"] = ForwardSym + histos[jetDef][SystematicNameDictionary[histName]] = histoSym + + else : + histos[jetDef][SystematicNameDictionary[histName]] = histoSym + + # Done reading, close the file + inFile.Close() + + return histos + +def ReadCrossCalValidityHistograms(dirName): + if not dirName.endswith("/"): + dirName = dirName + "/" + + # Run over each file (one per jet definition) + histos = {} + files = sorted(glob.glob(dirName+"*.root")) + for aFileName in files: + # Determine the jet definition + jetDef = "" + for aFileDef,aJetDef in jetDefDict.iteritems(): + if aFileDef in aFileName: + jetDef = aJetDef + break + if jetDef == "": + print "Failed to determine jet definition for file:",aFileName + return None + histos[jetDef] = {} + + # Read in the histograms of interest from the file + inFile = TFile(aFileName,"READ") + for histName in inFile.GetKeyNames(): + if 'valid' not in histName : + continue + dictkey = histName.replace("valid_","") + systematicName = "valid_"+SystematicNameDictionary[dictkey]+"_"+jetDef + histo = inFile.Get(histName) + if histo is None: + print "Failed to get histogram:",systematicName + return None + histo.SetName(systematicName+"_old") + + # Histo has different range, extend it + histoNew = ProviderHistoHelpers.ExtendPtRangeOfHisto(histo,"valid_"+systematicName) + histoSym = ProviderHistoHelpers.SymmetrizeHistoInEta(histoNew,"valid_"+systematicName) + histoSym.SetDirectory(0) + histos[jetDef][SystematicNameDictionary[dictkey]] = histoSym + + # Done reading, close the file + inFile.Close() + + return histos diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseCurrentFile.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseCurrentFile.py new file mode 100755 index 0000000000000000000000000000000000000000..9a4c6c7565ce82b74fb2966547a1c7d6c4f7b22b --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseCurrentFile.py @@ -0,0 +1,49 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers + +def GetKeyNames(self,dir=""): + self.cd(dir) + return [key.GetName() for key in gDirectory.GetListOfKeys()] +TFile.GetKeyNames = GetKeyNames + +def ReadCurrentHistograms(aSystFile,newjetsdict=[]): + + useJetCollections = {"AntiKt4EMTopo" : "AntiKt4Topo_EMJES", + "AntiKt4EMPFlow": "AntiKt4PFlow_EMJES"} + + # Just one file here with everything in it. + systematicFile = TFile(aSystFile,"READ") + + if newjetsdict!=[] : + useJetCollections = newjetsdict + + histos = {} + for key in systematicFile.GetKeyNames() : + + # Only keep things of the jet collections we are using. + foundJetType = False + for type in useJetCollections : + if key.endswith(type) : + jettype = type + foundJetType = True + if not foundJetType : + print "No jet type matches" + continue + jetkey = useJetCollections[jettype] + if jetkey not in histos : + print "Adding extra dict..." + histos[jetkey] = {} + + systname = key.replace("_"+jettype,"") + + histo = systematicFile.Get(key) + histo.SetDirectory(0) + histos[jetkey][systname] = histo + + # Done, return dictionary of histos + return histos + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseEtaIntercalInput.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseEtaIntercalInput.py new file mode 100755 index 0000000000000000000000000000000000000000..3ad24250091350a08f137bc54c94c9411b0b9243 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseEtaIntercalInput.py @@ -0,0 +1,83 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers + +def GetKeyNames(self,dir=""): + self.cd(dir) + return [key.GetName() for key in gDirectory.GetListOfKeys()] +TFile.GetKeyNames = GetKeyNames + +SystematicNames = {'EtaIntercalibration_TotalStat' : 'EtaIntercalibration_TotalStat',\ + 'EtaIntercalibration_TotalSyst' : 'EtaIntercalibration_Modelling',\ + 'E_4TeV' : 'EtaIntercalibration_NonClosure_highE',\ + 'Eta_2p4_to_2p6' : 'EtaIntercalibration_NonClosure_posEta',\ + 'Eta_m2p6_to_m2p4' : 'EtaIntercalibration_NonClosure_negEta' + } + +jetDefDict = { + 'AntiKt4EMTopo' : 'AntiKt4Topo_EMJES', + 'AntiKt4EMPFlow' : 'AntiKt4PFlow_EMJES', + } + +def ReadEtaIntercalibrationHistograms(dirName): + if not dirName.endswith("/"): + dirName = dirName + "/" + + # Run over each file (one per jet definition) + histos = {} + files = sorted(glob.glob(dirName+"*.root")) + for aFileName in files: + # Determine the jet definition + jetDef = "" + for aFileDef,aJetDef in jetDefDict.iteritems(): + if aFileDef in aFileName: + jetDef = aJetDef + break + if jetDef == "": + print "Failed to determine jet definition for file:",aFileName + return None + if jetDef not in histos.keys() : + histos[jetDef] = {} + + # Read in the histograms of interest from the file + inFile = TFile(aFileName,"READ") + contents = inFile.GetKeyNames() + for aName in SystematicNames.keys(): + if not "NonClosure" in SystematicNames[aName] : + if "Topo" in jetDef : + getsystematicName = aName + "_" + jetDef.replace("Topo","") + else : + getsystematicName = aName + "_" + jetDef.replace("4PFlow","4EMPFlow").replace("_EMJES","_PFlowJES") + else : + getsystematicName = aName + + if not getsystematicName in contents : + continue + + histo = inFile.Get(getsystematicName) + + systematicName = SystematicNames[aName] + "_" + jetDef + histo.SetName(systematicName+"_old") + + # Histo has different range, extend it + histoNew = ProviderHistoHelpers.ExtendPtRangeOfHisto(histo,systematicName) + histoNew.SetDirectory(0) + histos[jetDef][SystematicNames[aName]] = histoNew + + # Done reading, close the file + inFile.Close() + + # Since histos came from a whole mix of files, make sure we got them all in the end. + for aName,storeName in SystematicNames.iteritems(): + for aJetDef in histos.keys(): + if not storeName in histos[aJetDef].keys() : + print "Failed to find histogram:", storeName,"for jet definition",aJetDef + + print "About to return eta intercalib histos" + print histos + print "\n" + return histos + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseEtaIntercalInput_detailed.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseEtaIntercalInput_detailed.py new file mode 100755 index 0000000000000000000000000000000000000000..9208b121187549a02c2caa47e51989c8e0abbb2b --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseEtaIntercalInput_detailed.py @@ -0,0 +1,130 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers + +def GetKeyNames(self,dir=""): + self.cd(dir) + return [key.GetName() for key in gDirectory.GetListOfKeys()] +TFile.GetKeyNames = GetKeyNames + +SystematicNames_timeinvariant = { + 'EtaIntercalibration_TotalSyst' : 'EtaIntercalibration_TotalSyst',\ +} + +SystematicNames_timedependent = { + 'E_4TeV' : 'EtaIntercalibration_NonClosure_highE',\ + 'Eta_2p4_to_2p6' : 'EtaIntercalibration_NonClosure_posEta',\ + 'Eta_m2p6_to_m2p4' : 'EtaIntercalibration_NonClosure_negEta' + } + +jetDefDict = { + 'AntiKt4EMTopo' : 'AntiKt4Topo_EMJES', + 'AntiKt4EMPFlow' : 'AntiKt4PFlow_EMJES', + } + +def ReadEtaIntercalibrationDetailedStats(filename, dictionary) : + # Inside detailed stats files, individual components are inside of a directory. + # Make a special name for each and add it to the output dictionary + + openFile = TFile.Open(filename,"READ") + dirName = "StatNuisanceParams" + stat_keys = openFile.GetKeyNames(dirName) + + jet_def = "" + for thing in jetDefDict.keys() : + if thing in filename : + jet_def = thing + + for key in stat_keys : + hist = openFile.Get(dirName+"/"+key) + hist.SetDirectory(0) + + save_name = "EtaIntercalibration_"+key + hist.SetName(save_name+"_"+jet_def) + hist.SetTitle(save_name+"_"+jet_def) + + dictionary[jetDefDict[jet_def]][save_name] = hist + + return dictionary + +def ReadEtaIntercalibrationHistograms(dirName,year=""): + if not dirName.endswith("/"): + dirName = dirName + "/" + + # Run over each file (one per jet definition) + # Collect files and figure out what they are, matching year token specified in run + histos = {} + files = sorted(glob.glob(dirName+"*{0}*.root".format(year))) + for aFileName in files: + # Determine the jet definition + jetDef = "" + for aFileDef,aJetDef in jetDefDict.iteritems(): + if aFileDef in aFileName: + jetDef = aJetDef + break + if jetDef == "": + print "Failed to determine jet definition for file:",aFileName + return None + if jetDef not in histos.keys() : + histos[jetDef] = {} + + # Read in the histograms of interest from the file + inFile = TFile(aFileName,"READ") + contents = inFile.GetKeyNames() + + if year : + SystematicNames = SystematicNames_timedependent + else : + SystematicNames = SystematicNames_timeinvariant + + for aName in SystematicNames.keys(): + if not "NonClosure" in SystematicNames[aName] : + if "Topo" in jetDef : + getsystematicName = aName + "_" + jetDef.replace("Topo","") + else : + getsystematicName = aName + "_" + jetDef.replace("4PFlow","4EMPFlow").replace("_EMJES","_PFlowJES") + else : + getsystematicName = aName + + if not getsystematicName in contents : + continue + + histo = inFile.Get(getsystematicName) + + systematicName = SystematicNames[aName] + "_" + jetDef + histo.SetName(systematicName+"_old") + + # Histo has different range, extend it + histoNew = ProviderHistoHelpers.ExtendPtRangeOfHisto(histo,systematicName) + histoNew.SetDirectory(0) + histos[jetDef][SystematicNames[aName]] = histoNew + + # Done reading, close the file + inFile.Close() + + # Since histos came from a whole mix of files, make sure we got them all in the end. + for aName,storeName in SystematicNames.iteritems(): + for aJetDef in histos.keys(): + if not storeName in histos[aJetDef].keys() : + print "Failed to find histogram:", storeName,"for jet definition",aJetDef + + # Now, if this is year dependent, add stat histograms + if year : + for thisDef in jetDefDict.keys() : + files = sorted(glob.glob(dirName+"*{0}*_statErr_*{1}*.root".format(year,thisDef))) + if len(files) != 1 : + print "Did not find right number of stat term files!" + print files + exit(1) + filename = files[0] + print histos + histos = ReadEtaIntercalibrationDetailedStats(filename, histos) + print histos + + print "Histos out here" + print histos + print "\n" + return histos diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseFlavourInput.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseFlavourInput.py new file mode 100755 index 0000000000000000000000000000000000000000..8326611bd004b82d30979d914b816ada8a8011a9 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseFlavourInput.py @@ -0,0 +1,84 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers + + +def GetKeyNames(self,dir=""): + self.cd(dir) + return [key.GetName() for key in gDirectory.GetListOfKeys()] +TFile.GetKeyNames = GetKeyNames + + +SystematicNames = {'lqResponsePythia' : 'flavorCompLight', + 'gluonResponsePythia' : 'flavorCompGlu', + 'gluonResponseDiff' : 'FlavorResponse' } +jetDefDict = { + 'AntiKt4EMTopo' : 'AntiKt4Topo_EMJES', + 'AntiKt4EMPflow' : 'AntiKt4PFlow_EMJES', + } + +def ReadFlavourHistograms(dirName,freezepT=False): + print "Beginning flavour" + if not dirName.endswith("/") and not dirName.endswith(".root"): + dirName = dirName + "/" + if dirName.endswith("/") : + files = sorted(glob.glob(dirName+"*.root")) + else : + files = [dirName] + + # Run over each file (one per jet definition for LQ/Gluon and one per jet definition for HvP) + histos = {} + for aFileName in files: + # Determine the jet definition + jetDef = "" + for jetDef in jetDefDict.keys() : + print "Beginning jetDef",jetDef + if jetDefDict[jetDef] not in histos: + histos[jetDefDict[jetDef]] = {} + + # Read in the histograms from the file + # Note that we want all the histograms, but with this scheme not everything in the dict is in each file + # So instead loop over all histos in the file + inFile = TFile(aFileName,"READ") + for histName in inFile.GetKeyNames(): + systName = histName.split("_")[0] + if not jetDef in histName : + continue + if not systName in SystematicNames.keys() : + if "bResponse" in systName : + continue + print "Error!!!",systName,"not in",SystematicNames.keys() + continue + systematicName = systName + "_" + jetDefDict[jetDef] + histo = inFile.Get(histName) + if histo is None: + print "Failed to get histogram:",systematicName + return None + + if freezepT : + # Loop over eta bins. + for ybin in range(histo.GetNbinsY()+2) : + # Loop out in pT. + freezeval = 0 + for xbin in range(histo.GetNbinsX()+2) : + inbin = histo.GetBinContent(xbin,ybin) + #print "Bin at pT ",histo.GetXaxis().GetBinCenter(xbin)," and [ylow,y,yhigh] = ", binYLow, histo.GetYaxis().GetBinCenter(ybin), binYHigh + # Store bin contents as we go out: last one is one we want as frozen value. + if inbin > 0 : + freezeval = inbin + else : + histo.SetBinContent(xbin,ybin,freezeval) + + # Already eta symmetric. + #histoSym = ProviderHistoHelpers.SymmetrizeHistoInEta(histo,systematicName) + histo.SetDirectory(0) + histos[jetDefDict[jetDef]][SystematicNames[systName]] = histo + + # Done reading, close the file + inFile.Close() + + print "Done flavour.\n" + return histos diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseHighPtInput.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseHighPtInput.py new file mode 100755 index 0000000000000000000000000000000000000000..b1420dc23358d69ec4ffe1976c7dc66871b35e52 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseHighPtInput.py @@ -0,0 +1,89 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers +import os + +def GetKeyNames(self,dir=""): + self.cd(dir) + return [key.GetName() for key in gDirectory.GetListOfKeys()] +TFile.GetKeyNames = GetKeyNames + +jetDefList = ['AntiKt4Topo_EMJES',"AntiKt4PFlow_EMJES"]#,'AntiKt6Topo_EMJES','AntiKt4Topo_LCJES','AntiKt6Topo_LCJES'] + +def ReadHighPtHistogramsFromOldFile(fileName) : + + histos = {} + for jetDef in jetDefList : + histos[jetDef] = {} + inFile = TFile(fileName,"READ") + uncNames = ["SingleParticle_HighPt"] + jetCollections = {"AntiKt4EMTopo" : "AntiKt4Topo_EMJES", "AntiKt4EMPFlow" : "AntiKt4PFlow_EMJES"} + for name in uncNames : + for jetCollection in jetCollections.keys() : + getJetType = jetCollections[jetCollection] + fetchName = name+"_"+getJetType + hist = inFile.Get(fetchName) + print "retrieved",fetchName + hist.SetDirectory(0) + histos[jetCollections[jetCollection]][name] = hist + + return histos + +def ReadHighPtHistograms(dirName): + + if os.path.isdir(dirName): + fileList = sorted(glob.glob(dirName+"*.root")) + if len(fileList) > 1 : + print "Nope!!!" + return {} + else : + file = TFile(fileList[0],"READ") + else : + file = TFile(dirName,"READ") + + # Run over the file +# emFileList = sorted(glob.glob(dirName+"EM*/*.root")) +# lcFileList = sorted(glob.glob(dirName+"LC*/*.root")) +# if len(emFileList) != 1: +# print "Found a number of EM root files not equal to 1 in dir:",dirName +# return None +# if len(lcFileList) != 1: +# print "Found a number of LC root files not equal to 1 in dir:",dirName +# return None +# emFile = TFile(emFileList[0],"READ") +# lcFile = TFile(lcFileList[0],"READ") + + histos = {} + for aJetDef in jetDefList: + histos[aJetDef] = {} + +# rootFile = None +# if "EMJES" in aJetDef: +# rootFile = emFile +# elif "LCJES" in aJetDef: +# rootFile = lcFile +# else: +# print "Unexpected jet def:",aJetDef +# return None + + rootFile = file + + for histName in rootFile.GetKeyNames(): + if aJetDef not in histName: continue + histo = rootFile.Get(histName) + if histo is None: + print "Failed to get histogram:",histName + return None + histo.SetName(histName+"_1D") + + histos[aJetDef][re.sub("_%s"%(aJetDef),"",histName)] = ProviderHistoHelpers.ConvertPtHistoToProviderHisto(histo,histName) + histos[aJetDef][re.sub("_%s"%(aJetDef),"",histName)].SetDirectory(0) + + lcFile.Close() + emFile.Close() + + return histos + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseInputs.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseInputs.py new file mode 100755 index 0000000000000000000000000000000000000000..6a53224f93c206836b6a705ffcbc4c38c2761579 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseInputs.py @@ -0,0 +1,174 @@ +from ROOT import * +from array import array +import sys +import os +import glob +import re +import math + +from ParseEtaIntercalInput_detailed import ReadEtaIntercalibrationHistograms +from ParseInsituInput import ReadInSituHistograms +from ParsePileupInput import ReadPileupHistograms +from ParseNonClosureInput import ReadNonClosureHistograms +from ParseHighPtInput import ReadHighPtHistograms,ReadHighPtHistogramsFromOldFile +from ParseFlavourInput import ReadFlavourHistograms +from ParsebJESInput import ReadBJESHistograms +from ParsePunchthroughInput import ReadPunchthroughHistograms +from CopyJERHists import ReadJERHistograms + +#http://stackoverflow.com/questions/2669059/how-to-sort-alpha-numeric-set-in-python +from itertools import groupby +def natural_sort(s): + return [int(''.join(g)) if k else ''.join(g) for k, g in groupby(s[0], str.isdigit)] + +# Design: This is to make a file entirely from scratch. +# At present the high pT term has not been updated since 2012, so +# that one will be retrieved from the final 2012 recommendations. +# All else is needed new. + +# Full list of required inputs, distinguished by needing them +# from a different person +# - In situ terms +# - Eta intercalibration +# - Single particle +# - MC non-closure +# - Pileup +# - Flavour +# - B-JES +# - Punchthrough + + +# NOTES +# Need to carefully check all flavour histograms in comparison to 2012 to make sure they look sensible!! +# Things below were done in pre-recs and are currently being done here: +# - Freeze flavour histograms by hand wherever input histogram falls below 0: extrapolate forward in pT from around 2 TeV centrally and from lower pT as eta increases. +# - FlavorResponse histogram inverted from input file to match Run I convention +freezeFlavourInPt = False + +########################################## + +# Check useage and store arguments +if len(sys.argv) < 3: + print "USAGE: Expected the following arguments" + print " 1. InSitu directory path" + print " 2. Eta intercalibration directory path" + print " 3. Path or directory for single-particle: currently 2012 recommendation" + print " 4. MC nonclosure directory path" + print " 5. Pileup directory path" + print " 6. Flavour directory path" + print " 7. bJES directory path" + print " 8. Punchthrough directory path" + exit(1) + +outBaselineFile = "JESUncertainty_AllComponents_{0}.root" +inSituDir = sys.argv[1] +etaIntercalDir = sys.argv[2] +highPtDir = sys.argv[3] +nonclosureDir = sys.argv[4] +pileupDir = sys.argv[5] +flavourDir = sys.argv[6] +bJESDir = sys.argv[7] +punchthroughDir = sys.argv[8] +oldJERFile = sys.argv[9] + +# Ensure that all of the directories exist +if not outBaselineFile.endswith(".root"): + print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile + exit(2) +if not os.path.exists(inSituDir): + print "InSitu directory does not exist:",inSituDir + exit(3) +if not os.path.exists(etaIntercalDir): + print "Eta intercalibration directory does not exist:",etaIntercalDir + exit(4) +if not os.path.exists(highPtDir): + print "HighPt directory does not exist:",highPtDir + exit(5) +if not os.path.exists(nonclosureDir): + print "MC nonclosure directory does not exist:",nonclosureDir + exit(6) +if not os.path.exists(pileupDir): + print "Pileup directory does not exist:",pileupDir + exit(7) +if not os.path.exists(flavourDir): + print "Flavour directory does not exist:",flavourDir + exit(8) +if not os.path.exists(bJESDir): + print "bJES directory does not exist:",bJESDir + exit(9) +if not os.path.exists(punchthroughDir): + print "Punchthrough directory does not exist:",punchthroughDir + exit(10) +if not os.path.exists(oldJERFile) : + print "You need to specify a file to pick up JER from!",oldJERFile + +# Store everything in memory! +currentDir = gDirectory +gROOT.cd() + +# Now read the histograms +print "Reading inputs..." +# For now, the high pT component +# is read in from the final 2012 calibration files. +inSituHistos = ReadInSituHistograms(inSituDir) +etaIntercalHistos_20152016 = ReadEtaIntercalibrationHistograms(etaIntercalDir,"2015_16_") +etaIntercalHistos_2017 = ReadEtaIntercalibrationHistograms(etaIntercalDir,"2017_") +etaIntercalHistos_general = ReadEtaIntercalibrationHistograms(etaIntercalDir,"") +highPtHistos = ReadHighPtHistogramsFromOldFile(highPtDir)#ReadHighPtHistograms(highPtDir) +nonclosureHistos = ReadNonClosureHistograms(nonclosureDir,True) +pileupHistos = ReadPileupHistograms(pileupDir) +flavourHistos = ReadFlavourHistograms(flavourDir,freezeFlavourInPt) # True flag freezes uncertainty above pT = 2TeV (lower at higher eta) +bJESHistos = ReadBJESHistograms(bJESDir) +punchthroughHistos = ReadPunchthroughHistograms(punchthroughDir) +JERHistos = ReadJERHistograms(oldJERFile) + +# Make one mega-dictionary +print "Merging inputs..." +jetDefs = {"AntiKt4Topo_EMJES" : "AntiKt4EMTopo", 'AntiKt4PFlow_EMJES' : 'AntiKt4EMPFlow'} +systematics = {} + +for years in ("2015_16","2017") : + systematics[years] = {} + for aJetDef in jetDefs.keys(): + + etaIntercalHistos_timeDep = etaIntercalHistos_2017 if "2017" in years else etaIntercalHistos_20152016 + + systematics[years][aJetDef] = dict( + inSituHistos[aJetDef].items() + + etaIntercalHistos_timeDep[aJetDef].items() + + etaIntercalHistos_general[aJetDef].items() + + highPtHistos[aJetDef].items() + + nonclosureHistos[aJetDef].items() + + pileupHistos[aJetDef].items() + + flavourHistos[aJetDef].items() + + bJESHistos[aJetDef].items() + + punchthroughHistos[aJetDef].items() + ) + +# Loop over the mega-dictionary and write results +# Want one output file per dataset +for years in ("2015_16","2017") : + outFileName = outBaselineFile.format(years) + print "Writing to output file",outFileName,"..." + baselineFile = TFile(outFileName,"RECREATE") + theseHists = systematics[years] + for aJetDef,aSyst in sorted(theseHists.iteritems(),key=natural_sort): + for aSystName,aSystHisto in sorted(aSyst.iteritems(),key=natural_sort): + baselineFile.cd() + aSystHisto.SetTitle(aSystName+"_"+jetDefs[aJetDef]) + aSystHisto.Write(aSystHisto.GetTitle()) + + # Write JER last cause it's kind of separate + for aJetDef,aSyst in sorted(JERHistos.iteritems(),key=natural_sort): + for aSystName,aSystHisto in sorted(aSyst.iteritems(),key=natural_sort): + aSystHisto.SetTitle(aSystName+"_"+jetDefs[aJetDef]) + aSystHisto.Write(aSystHisto.GetTitle()) + + # Done, close the files, revert directory + baselineFile.Close() + gDirectory = currentDir + +print "Done!" + + + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseInputs_Preliminary.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseInputs_Preliminary.py new file mode 100755 index 0000000000000000000000000000000000000000..6c73f5a169c2762e51221e5ae0a594cb9a4698f8 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseInputs_Preliminary.py @@ -0,0 +1,143 @@ +from ROOT import * +from array import array +import sys +import os +import glob +import re +import math + +from ParseEtaIntercalInput import ReadEtaIntercalibrationHistograms +from ParseInsituInput_MJB import ReadInSituHistograms +from ParsePileupInput import ReadPileupHistograms +from ParseHighPtInput import ReadHighPtHistograms,ReadHighPtHistogramsFromOldFile +from ParseFlavourInput import ReadFlavourHistograms +from ParsebJESInput import ReadBJESHistograms +from ParsePunchthroughInput import ReadPunchthroughHistograms +from CreateNonClosureInput import CreateNonClosureHistograms + +#http://stackoverflow.com/questions/2669059/how-to-sort-alpha-numeric-set-in-python +from itertools import groupby +def natural_sort(s): + return [int(''.join(g)) if k else ''.join(g) for k, g in groupby(s[0], str.isdigit)] + +# Design: This is to make a file entirely from scratch. +# At present the high pT term has not been updated since 2012, so +# that one will be retrieved from the final 2012 recommendations. +# All else is needed new. + +# Full list of required inputs, distinguished by needing them +# from a different person +# - In situ terms +# - Eta intercalibration +# - Single particle +# - MC non-closure +# - Pileup +# - Flavour +# - B-JES +# - Punchthrough + + +# NOTES +# Need to carefully check all flavour histograms in comparison to 2012 to make sure they look sensible!! +# Things below were done in pre-recs and are currently being done here: +# - Freeze flavour histograms by hand wherever input histogram falls below 0: extrapolate forward in pT from around 2 TeV centrally and from lower pT as eta increases. +# - FlavorResponse histogram inverted from input file to match Run I convention +freezeFlavourInPt = False + +########################################## + +# Check useage and store arguments +if len(sys.argv) < 3: + print "USAGE: Expected the following arguments" + print " 1. InSitu directory path" + print " 2. Eta intercalibration directory path" + print " 3. Path or directory for single-particle: currently 2012 recommendation" + print " 5. Pileup directory path" + print " 6. Flavour directory path" + print " 7. bJES directory path" + print " 8. Punchthrough directory path" + exit(1) + +outBaselineFile = "JESUncertainty_AllComponents.root" +inSituDir = sys.argv[1] +etaIntercalDir = sys.argv[2] +highPtDir = sys.argv[3] +pileupDir = sys.argv[4] +flavourDir = sys.argv[5] +bJESDir = sys.argv[6] +punchthroughDir = sys.argv[7] + +# Ensure that all of the directories exist +if not outBaselineFile.endswith(".root"): + print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile + exit(2) +if not os.path.exists(inSituDir): + print "InSitu directory does not exist:",inSituDir + exit(3) +if not os.path.exists(etaIntercalDir): + print "Eta intercalibration directory does not exist:",etaIntercalDir + exit(4) +if not os.path.exists(highPtDir): + print "HighPt directory does not exist:",highPtDir + exit(5) +if not os.path.exists(pileupDir): + print "Pileup directory does not exist:",pileupDir + exit(7) +if not os.path.exists(flavourDir): + print "Flavour directory does not exist:",flavourDir + exit(8) +if not os.path.exists(bJESDir): + print "bJES directory does not exist:",bJESDir + exit(9) +if not os.path.exists(punchthroughDir): + print "Punchthrough directory does not exist:",punchthroughDir + exit(10) + +# Store everything in memory! +currentDir = gDirectory +gROOT.cd() + +# Now read the histograms +print "Reading inputs..." +# For now, the high pT component +# is read in from the final 2012 calibration files. +inSituHistos = ReadInSituHistograms(inSituDir) +etaIntercalHistos = ReadEtaIntercalibrationHistograms(etaIntercalDir) +highPtHistos = ReadHighPtHistogramsFromOldFile(highPtDir)#ReadHighPtHistograms(highPtDir) +pileupHistos = ReadPileupHistograms(pileupDir) +flavourHistos = ReadFlavourHistograms(flavourDir,freezeFlavourInPt) # True flag freezes uncertainty above pT = 2TeV (lower at higher eta) +bJESHistos = ReadBJESHistograms(bJESDir) +punchthroughHistos = ReadPunchthroughHistograms(punchthroughDir) +nonClosureHists = CreateNonClosureHistograms() + +# Make one mega-dictionary +print "Merging inputs..." +jetDefs = {"AntiKt4Topo_EMJES" : "AntiKt4EMTopo", "AntiKt4PFlow_EMJES" : "AntiKt4EMPFlow"} +systematics = {} +for aJetDef in jetDefs.keys(): + + systematics[aJetDef] = dict( + inSituHistos[aJetDef].items() + + etaIntercalHistos[aJetDef].items() + + highPtHistos[aJetDef].items() + + pileupHistos[aJetDef].items() + + flavourHistos[aJetDef].items() + + bJESHistos[aJetDef].items() + + punchthroughHistos[aJetDef].items() + + nonClosureHists[aJetDef].items() + ) + +# Loop over the mega-dictionary and write results +print "Writing to output file",outBaselineFile,"..." +baselineFile = TFile(outBaselineFile,"RECREATE") +for aJetDef,aSyst in sorted(systematics.iteritems(),key=natural_sort): + for aSystName,aSystHisto in sorted(aSyst.iteritems(),key=natural_sort): + baselineFile.cd() + aSystHisto.SetTitle(aSystName+"_"+jetDefs[aJetDef]) + aSystHisto.Write(aSystHisto.GetTitle()) + +# Done, close the files, revert directory +baselineFile.Close() +gDirectory = currentDir +print "Done!" + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseInsituInput.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseInsituInput.py new file mode 100755 index 0000000000000000000000000000000000000000..629c1b5dd5fbafe6a592dd700426491d0e2cd630 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseInsituInput.py @@ -0,0 +1,213 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers + +# Dictinary below last updated to match inputs from Bogdan and Meghan +# sent December 14 2016 + +# Dictionary to translate from Bogan's names to provider names +SystematicNameDictionary = { + 'gammajetdphi' : 'Gjet_dPhi', + 'gammajetgenerator' : 'Gjet_Generator', + 'gammajetjvt' : 'Gjet_Jvt', + 'gammajetshower' : 'Gjet_ShowerTopology', + 'gammajetphscalez' : 'Gjet_GamESZee', + 'gammajetphsmear' : 'Gjet_GamEsmear', + 'gammajetpurity' : 'Gjet_Purity', + 'gammajetstat1' : 'Gjet_Stat1', + 'gammajetstat2' : 'Gjet_Stat2', + 'gammajetstat3' : 'Gjet_Stat3', + 'gammajetstat4' : 'Gjet_Stat4', + 'gammajetstat5' : 'Gjet_Stat5', + 'gammajetstat6' : 'Gjet_Stat6', + 'gammajetstat7' : 'Gjet_Stat7', + 'gammajetstat8' : 'Gjet_Stat8', + 'gammajetstat9' : 'Gjet_Stat9', + 'gammajetstat10' : 'Gjet_Stat10', + 'gammajetstat11' : 'Gjet_Stat11', + 'gammajetstat12' : 'Gjet_Stat12', + 'gammajetstat13' : 'Gjet_Stat13', + 'gammajetstat14' : 'Gjet_Stat14', + 'gammajetstat15' : 'Gjet_Stat15', + 'gammajetstat16' : 'Gjet_Stat16', + 'gammajetsubleadingjet' : 'Gjet_Veto', + 'mjbalpha' : 'MJB_Alpha', + 'mjbbeta' : 'MJB_Beta', + 'mjbfrag' : 'MJB_Fragmentation', # WAS: mjbmodelling + 'mjbjvt' : 'MJB_JVT', + 'mjbptasymm' : 'MJB_Asym', + 'mjbptthreshold' : 'MJB_Threshold', + 'mjbstat1' : 'MJB_Stat1', + 'mjbstat2' : 'MJB_Stat2', + 'mjbstat3' : 'MJB_Stat3', + 'mjbstat4' : 'MJB_Stat4', + 'mjbstat5' : 'MJB_Stat5', + 'mjbstat6' : 'MJB_Stat6', + 'mjbstat7' : 'MJB_Stat7', + 'mjbstat8' : 'MJB_Stat8', + 'mjbstat9' : 'MJB_Stat9', + 'mjbstat10' : 'MJB_Stat10', + 'mjbstat11' : 'MJB_Stat11', + 'mjbstat12' : 'MJB_Stat12', + 'mjbstat13' : 'MJB_Stat13', + 'mjbstat14' : 'MJB_Stat14', + 'mjbstat15' : 'MJB_Stat15', + 'mjbstat16' : 'MJB_Stat16', + 'mjbstat17' : 'MJB_Stat17', + 'mjbstat18' : 'MJB_Stat18', + 'mjbstat19' : 'MJB_Stat19', + 'mjbstat20' : 'MJB_Stat20', + 'mjbstat21' : 'MJB_Stat21', + 'mjbstat22' : 'MJB_Stat22', + 'mjbstat23' : 'MJB_Stat23', + 'mjbstat24' : 'MJB_Stat24', + 'mjbstat25' : 'MJB_Stat25', + 'mjbstat26' : 'MJB_Stat26', + 'mjbstat27' : 'MJB_Stat27', + 'mjbstat28' : 'MJB_Stat28', + 'zjetdphi' : 'Zjet_dPhi', + 'zjetescale' : 'Zjet_ElecESZee', + 'zjetesmear' : 'Zjet_ElecEsmear', + 'zjetgenerator' : 'Zjet_MC', + 'zjetjvt' : 'Zjet_Jvt', + 'zjetmuscale' : 'Zjet_MuScale', + 'zjetmusmearid' : 'Zjet_MuSmearID', + 'zjetmusmearms' : 'Zjet_MuSmearMS', + 'zjetmusagittares' : 'Zjet_MuSagittaRes', + 'zjetmusagittarho' : 'Zjet_MuSagittaRho', + 'zjetelstat1' : 'Zjet_ElecStat1', + 'zjetelstat2' : 'Zjet_ElecStat2', + 'zjetelstat3' : 'Zjet_ElecStat3', + 'zjetelstat4' : 'Zjet_ElecStat4', + 'zjetelstat5' : 'Zjet_ElecStat5', + 'zjetelstat6' : 'Zjet_ElecStat6', + 'zjetelstat7' : 'Zjet_ElecStat7', + 'zjetelstat8' : 'Zjet_ElecStat8', + 'zjetelstat9' : 'Zjet_ElecStat9', + 'zjetelstat10' : 'Zjet_ElecStat10', + 'zjetelstat11' : 'Zjet_ElecStat11', + 'zjetelstat12' : 'Zjet_ElecStat12', + 'zjetelstat13' : 'Zjet_ElecStat13', + 'zjetelstat14' : 'Zjet_ElecStat14', + 'zjetmustat1' : 'Zjet_MuStat1', + 'zjetmustat2' : 'Zjet_MuStat2', + 'zjetmustat3' : 'Zjet_MuStat3', + 'zjetmustat4' : 'Zjet_MuStat4', + 'zjetmustat5' : 'Zjet_MuStat5', + 'zjetmustat6' : 'Zjet_MuStat6', + 'zjetmustat7' : 'Zjet_MuStat7', + 'zjetmustat8' : 'Zjet_MuStat8', + 'zjetmustat9' : 'Zjet_MuStat9', + 'zjetmustat10' : 'Zjet_MuStat10', + 'zjetmustat11' : 'Zjet_MuStat11', + 'zjetmustat12' : 'Zjet_MuStat12', + 'zjetmustat13' : 'Zjet_MuStat13', + 'zjetmustat14' : 'Zjet_MuStat14', + 'zjetsubleadingjet' : 'Zjet_Veto', + 'zjetshower' : 'Zjet_ShowerTopology', + # The following are from the terms which + # were propagated through the MJB calculation + 'etaintercalibrationmodelling' : 'InSituProp_EtaIntercalModelling', + 'etaintercalibrationnonclosurehighe' : 'InSituProp_EtaIntercalNonClosureHighE', + 'etaintercalibrationnonclosureposeta' : 'InSituProp_EtaIntercalNonClosurePosEta', + 'etaintercalibrationnonclosurenegeta' : 'InSituProp_EtaIntercalNonClosureNegEta', + 'etaintercalibrationofcs' : 'InSituProp_EtaIntercalOFCs', + 'etaintercalibrationtotalstat' : 'InSituProp_EtaIntercalStat', + 'flavorcomposition' : 'InSituProp_FlavorComposition', + 'flavorresponse' : 'InSituProp_FlavorResponse', + 'pileupoffsetmu' : 'InSituProp_PileupOffsetMu', + 'pileupoffsetnpv' : 'InSituProp_PileupOffsetNPV', + 'pileupptterm' : 'InSituProp_PileupPtTerm', + 'pileuprhotopology' : 'InSituProp_PileupRhoTopology', + 'punchthroughmc16' : 'InSituProp_PunchThroughMC', + } + +jetDefDict = { + 'EMJES_R4' : 'AntiKt4Topo_EMJES', + 'PFJES_R4' : 'AntiKt4PFlow_EMJES' + } + +def ReadInSituHistograms(dirName): + if not dirName.endswith("/"): + dirName = dirName + "/" + + print dirName + import os + print os.listdir(dirName) + + # Run over each subdirectory (one per jet definition) + histos = {} + subDirs = sorted(glob.glob(dirName+"*/")) + print "Checking subdirs",subDirs + for aSubDirName in subDirs: + # Determine the jet definition + jetDef = "" + for aDirDef,aJetDef in jetDefDict.iteritems(): + if aDirDef in aSubDirName: + jetDef = aJetDef + break + if jetDef == "": + print "Failed to determine jet definition for directory:",aSubDirName + return None + histos[jetDef] = {} + + # Loop over the systematic files in the subdirectory + systFiles = sorted(glob.glob(aSubDirName+"/SystError_*.txt")) + for aSystFile in systFiles: + # Figure out which component this is + aSubDirName = aSubDirName.rstrip("/") + systematicNameHandle = aSystFile.replace(aSubDirName+"/SystError_","") + systematicNameHandle = systematicNameHandle.replace(".txt","") + systematicName = SystematicNameDictionary[systematicNameHandle] + print "Making histogram %s --> %s"%(systematicNameHandle,systematicName) + + # Open the file + systematicFile = open(aSystFile,"r") + + # Read the lines of the file into arrays + lowBinEdges = [] + systValues = [] + for line in systematicFile.readlines(): + line = line.strip("\r\n") + lowEdge = float(line.split()[0]) + systVal = float(line.split()[2].strip()) + + lowBinEdges.append(lowEdge) + systValues.append(systVal) + + # Done reading, close the file + systematicFile.close() + + # Make the last bin go up to 2500 + lowBinEdges.append(2500.) + systValues.append(systValues[-1]) + + # Turn the lists into arrays and build the 1D histogram + lowBinEdgesArray = array('d',lowBinEdges) + systValuesArray = array('d',systValues) + histoName = systematicName+"_"+jetDef + histo1D = TH1D(histoName+"_1D",histoName+"_1D",len(lowBinEdges)-1,lowBinEdgesArray) + + # Fill it from the file values + for iBin in xrange(1,histo1D.GetNbinsX()+1): + histo1D.SetBinContent(iBin,systValues[iBin-1]) + + histos[jetDef][systematicName] = histo1D + + # EM has 10 stat parameters, LC has 11 + # So for EM algorithms, make an empty histo for stat 11 +# if "EM" in jetDef: +# systematicName = SystematicNameDictionary['mjbstat11'] +# histos[jetDef][systematicName] = ProviderHistoHelpers.MakeProviderHisto(systematicName+"_"+jetDef) +# histos[jetDef][systematicName].SetDirectory(0) + + + # Done, return dictionary of histos + return histos + + + + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseInsituInput_MJB.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseInsituInput_MJB.py new file mode 100755 index 0000000000000000000000000000000000000000..3aa4f63003da7cd0e1b2b464a81b8f428ee611d4 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseInsituInput_MJB.py @@ -0,0 +1,170 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers +import os + +# Dictionary to translate from Bogan's names to provider names +SystematicNameDictionary = { + 'gammajetdphi' : 'Gjet_dPhi', + 'gammajetgenerator' : 'Gjet_Generator', + 'gammajetjvt' : 'Gjet_Jvt', + 'gammajetshower' : 'Gjet_ShowerTopology', + 'gammajetphscalez' : 'Gjet_GamESZee', + 'gammajetphsmear' : 'Gjet_GamEsmear', + 'gammajetpurity' : 'Gjet_Purity', + 'gammajetstat1' : 'Gjet_Stat1', + 'gammajetstat2' : 'Gjet_Stat2', + 'gammajetstat3' : 'Gjet_Stat3', + 'gammajetstat4' : 'Gjet_Stat4', + 'gammajetstat5' : 'Gjet_Stat5', + 'gammajetstat6' : 'Gjet_Stat6', + 'gammajetstat7' : 'Gjet_Stat7', + 'gammajetstat8' : 'Gjet_Stat8', + 'gammajetstat9' : 'Gjet_Stat9', + 'gammajetstat10' : 'Gjet_Stat10', + 'gammajetstat11' : 'Gjet_Stat11', + 'gammajetstat12' : 'Gjet_Stat12', + 'gammajetstat13' : 'Gjet_Stat13', + 'gammajetstat14' : 'Gjet_Stat14', + 'gammajetstat15' : 'Gjet_Stat15', + 'gammajetstat16' : 'Gjet_Stat16', + 'gammajetsubleadingjet' : 'Gjet_Veto', + 'zjetdphi' : 'Zjet_dPhi', + 'zjetescale' : 'Zjet_ElecESZee', + 'zjetesmear' : 'Zjet_ElecEsmear', + 'zjetgenerator' : 'Zjet_MC', + 'zjetjvt' : 'Zjet_Jvt', + 'zjetmuscale' : 'Zjet_MuScale', + 'zjetmusmearid' : 'Zjet_MuSmearID', + 'zjetmusmearms' : 'Zjet_MuSmearMS', + 'zjetmusagittares' : 'Zjet_MuSagittaRes', + 'zjetmusagittarho' : 'Zjet_MuSagittaRho', + 'zjetelstat1' : 'Zjet_ElecStat1', + 'zjetelstat2' : 'Zjet_ElecStat2', + 'zjetelstat3' : 'Zjet_ElecStat3', + 'zjetelstat4' : 'Zjet_ElecStat4', + 'zjetelstat5' : 'Zjet_ElecStat5', + 'zjetelstat6' : 'Zjet_ElecStat6', + 'zjetelstat7' : 'Zjet_ElecStat7', + 'zjetelstat8' : 'Zjet_ElecStat8', + 'zjetelstat9' : 'Zjet_ElecStat9', + 'zjetelstat10' : 'Zjet_ElecStat10', + 'zjetelstat11' : 'Zjet_ElecStat11', + 'zjetelstat12' : 'Zjet_ElecStat12', + 'zjetelstat13' : 'Zjet_ElecStat13', + 'zjetelstat14' : 'Zjet_ElecStat14', + 'zjetmustat1' : 'Zjet_MuStat1', + 'zjetmustat2' : 'Zjet_MuStat2', + 'zjetmustat3' : 'Zjet_MuStat3', + 'zjetmustat4' : 'Zjet_MuStat4', + 'zjetmustat5' : 'Zjet_MuStat5', + 'zjetmustat6' : 'Zjet_MuStat6', + 'zjetmustat7' : 'Zjet_MuStat7', + 'zjetmustat8' : 'Zjet_MuStat8', + 'zjetmustat9' : 'Zjet_MuStat9', + 'zjetmustat10' : 'Zjet_MuStat10', + 'zjetmustat11' : 'Zjet_MuStat11', + 'zjetmustat12' : 'Zjet_MuStat12', + 'zjetmustat13' : 'Zjet_MuStat13', + 'zjetmustat14' : 'Zjet_MuStat14', + 'zjetsubleadingjet' : 'Zjet_Veto', + 'zjetshower' : 'Zjet_ShowerTopology', + } + +jetDefDict = { + 'EMJES_R4' : 'AntiKt4Topo_EMJES', + 'LCJES_R4' : 'AntiKt4Topo_LCJES', + 'PFJES_R4' : 'AntiKt4PFlow_EMJES' + } + +def ReadInSituHistograms(dirName): + if not dirName.endswith("/"): + dirName = dirName + "/" + + # Run over each subdirectory (one per jet definition) + histos = {} + subDirs = sorted(glob.glob(dirName+"*")) + subDirs = [i for i in subDirs if os.path.isdir(os.path.join(os.getcwd(), i))] + for aSubDirName in subDirs: + # Determine the jet definition + jetDef = "" + for aDirDef,aJetDef in jetDefDict.iteritems(): + if aDirDef in aSubDirName: + jetDef = aJetDef + break + if jetDef == "": + print "Failed to determine jet definition for directory:",aSubDirName + continue + else : + print "Jet definition is",jetDef + histos[jetDef] = {} + + # Loop over the systematic files in the subdirectory + systFiles = sorted(glob.glob(aSubDirName+"/SystError_*.txt")) + for aSystFile in systFiles: + # If anything else is present, skip it + if not "SystError_" in aSystFile : + continue + + # Figure out which component this is + systematicNameHandle = re.sub(aSubDirName+"/SystError_","",aSystFile) + systematicNameHandle = re.sub(".txt","",systematicNameHandle) + systematicName = SystematicNameDictionary[systematicNameHandle] + print "Making histogram %s --> %s"%(systematicNameHandle,systematicName) + + # Open the file + systematicFile = open(aSystFile,"r") + + # Read the lines of the file into arrays + lowBinEdges = [] + systValues = [] + for line in systematicFile.readlines(): + line = line.strip("\r\n") + lowEdge = float(line.split()[0]) + systVal = float(line.split()[2].strip()) + + lowBinEdges.append(lowEdge) + systValues.append(systVal) + + # Done reading, close the file + systematicFile.close() + + # Make the last bin go up to 2500 + lowBinEdges.append(2500.) + systValues.append(systValues[-1]) + + # Turn the lists into arrays and build the 1D histogram + lowBinEdgesArray = array('d',lowBinEdges) + systValuesArray = array('d',systValues) + histoName = systematicName+"_"+jetDef + histo1D = TH1D(histoName+"_1D",histoName+"_1D",len(lowBinEdges)-1,lowBinEdgesArray) + + # Fill it from the file values + for iBin in xrange(1,histo1D.GetNbinsX()+1): + histo1D.SetBinContent(iBin,systValues[iBin-1]) + + # Convert to a 2D provider-stlye histo -- WHY WOULD WE DO THAT + # STOP DOING THAT IT BREAKS THINGS +# histo = ProviderHistoHelpers.ConvertPtHistoToProviderHisto(histo1D,histoName) +# histo.SetDirectory(0) +# print "Histo is type",type(histo),"whereas input was",histo1D +# histos[jetDef][systematicName] = histo + histos[jetDef][systematicName] = histo1D + + # EM has 10 stat parameters, LC has 11 + # So for EM algorithms, make an empty histo for stat 11 +# if "EM" in jetDef: +# systematicName = SystematicNameDictionary['mjbstat11'] +# histos[jetDef][systematicName] = ProviderHistoHelpers.MakeProviderHisto(systematicName+"_"+jetDef) +# histos[jetDef][systematicName].SetDirectory(0) + + + # Done, return dictionary of histos + return histos + + + + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseNonClosureInput.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseNonClosureInput.py new file mode 100755 index 0000000000000000000000000000000000000000..4095fffc8958dd3a0bda741985f19d07b0d11ef4 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParseNonClosureInput.py @@ -0,0 +1,89 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers + + +SystematicNameDictionary = { + 'RelativeNonClosure_AFII_AntiKt4EMTopo' : 'RelativeNonClosure_AFII', + 'RelativeNonClosure_AFII_AntiKt4EMPFlow' : 'RelativeNonClosure_AFII' + } + +jetDefDict = { + 'EMTopo' : 'AntiKt4Topo_EMJES', + 'EMPFlow' : 'AntiKt4PFlow_EMJES', + } + +def ReadNonClosureHistograms(dirName,freezepT=False): + if dirName.endswith(".root") : + files = [dirName] + + elif not dirName.endswith("/") : + dirName = dirName + "/" + print "Looking in dirName",dirName + import os + os.listdir(dirName) + files = sorted(glob.glob(dirName+"*.root")) + + # Run over each file (one per jet definition) + histos = {} + for aFileName in files: + # Determine the jet definition + jetDef = "" + for aFileDef,aJetDef in jetDefDict.iteritems(): + if aFileDef in aFileName: + jetDef = aJetDef + break + if jetDef == "": + print "Failed to determine jet definition for file:",aFileName + return None + histos[jetDef] = {} + + # Read in the histogram from the file + inFile = TFile(aFileName,"READ") + for aName,aSystName in SystematicNameDictionary.iteritems(): + print aName,aFileDef,aSystName + if not aFileDef in aName : continue + systematicName = aSystName + "_" + jetDef + print systematicName + histo = inFile.Get(aName) + if histo is None: + print "Failed to get histogram:",systematicName + return None + + if freezepT : + # Loop over eta bins. + for ybin in range(histo.GetNbinsY()+2) : + # Loop out in pT. + freezeval = 0 + for xbin in range(histo.GetNbinsX()+2) : + inbin = histo.GetBinContent(xbin,ybin) + #print "Bin at pT ",histo.GetXaxis().GetBinCenter(xbin)," and [ylow,y,yhigh] = ", binYLow, histo.GetYaxis().GetBinCenter(ybin), binYHigh + # Store bin contents as we go out: last one is one we want as frozen value. + if inbin > -0.5 : + freezeval = inbin + else : + histo.SetBinContent(xbin,ybin,freezeval) + + + histoSym = ProviderHistoHelpers.SymmetrizeHistoInEta(histo,systematicName) + histoSym.SetDirectory(0) + histos[jetDef][aSystName] = histoSym + print "Added hist with name",aSystName,"for jetDef",jetDef + + # Also add a blank nonclosure histo for Pythia8 + # Also add a blank Closeby histo for both AFII and Pythia8 + etaBins = [min(ProviderHistoHelpers.GetDefaultEtaBins()),0,max(ProviderHistoHelpers.GetDefaultEtaBins())] + histos[jetDef]["RelativeNonClosure_MC16"] = ProviderHistoHelpers.MakeProviderHisto("RelativeNonClosure_MC16",ptBins=[15,1000,2500],etaBins=etaBins) + histos[jetDef]["RelativeNonClosure_MC16"].SetDirectory(0) + histos[jetDef]["CloseBy_Pythia8"] = ProviderHistoHelpers.MakeProviderHisto("CloseBy_MC16",ptBins=[15,1000,2500],etaBins=etaBins) + histos[jetDef]["CloseBy_Pythia8"].SetDirectory(0) + histos[jetDef]["CloseBy_AFII"] = ProviderHistoHelpers.MakeProviderHisto("CloseBy_AFII",ptBins=[15,1000,2500],etaBins=etaBins) + histos[jetDef]["CloseBy_AFII"].SetDirectory(0) + + # Done reading, close the file + inFile.Close() + + return histos diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParsePileupInput.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParsePileupInput.py new file mode 100755 index 0000000000000000000000000000000000000000..2b60d59088417673f00154e29a475d824691d9b7 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParsePileupInput.py @@ -0,0 +1,59 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers + +# One file from Eric with the offset terms. +# A few extra files: rho topology terms are newly computed from values from +# Jamie and Jacob (by me, see script in input directory) +# and pt terms have been calculated once for 2015 by Steve Alkire. +# pT term inputs for both collections were collated in a single file. + +SystematicNames = ['Pileup_OffsetNPV','Pileup_OffsetMu','Pileup_PtTerm_npv','Pileup_PtTerm_mu','Pileup_RhoTopology'] + +jetDefs = {'AntiKt4EMTopo':'AntiKt4Topo_EMJES','AntiKt4EMPFlow':'AntiKt4PFlow_EMJES'} + +def ReadPileupHistograms(dirName): + if not dirName.endswith("/"): + dirName = dirName + "/" + + # We're just taking it from the old ROOT file... + # Ensure there is just one such file + rootFileList = sorted(glob.glob(dirName+"*.root")) + + histos = {} + + for aJetDef in jetDefs.keys(): + histos[jetDefs[aJetDef]] = {} + + for file in rootFileList : + rootFile = TFile(file,"READ") + + # Loop over the desired systematics + for aSystName in SystematicNames: + systematicName = aSystName + "_" + aJetDef + if systematicName not in rootFile.GetKeyNames() : + continue + histo = rootFile.Get(systematicName) + histo.SetDirectory(0) + + histos[jetDefs[aJetDef]][aSystName] = histo + + # Done reading, close the file + rootFile.Close() + + + # Did we get everything? + for aJetDef in jetDefs.keys(): + print "Beginning jetDef",aJetDef + for aSystName in SystematicNames: + print "Beginning systName",aSystName + if not aSystName in histos[jetDefs[aJetDef]].keys() : + print "Failed to find histogram:",aSystName,"for jet definition",aJetDef + + return histos + + + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParsePunchthroughInput.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParsePunchthroughInput.py new file mode 100755 index 0000000000000000000000000000000000000000..3cd53ae005f52565ea7839847bc75ce9e8c97db0 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParsePunchthroughInput.py @@ -0,0 +1,150 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers + +def GetKeyNames(self,dir=""): + self.cd(dir) + return [key.GetName() for key in gDirectory.GetListOfKeys()] +TFile.GetKeyNames = GetKeyNames + +jetDefDict = { + 'AntiKt4EMTopo' : 'AntiKt4Topo_EMJES', + 'AntiKt4EMPFlow' : 'AntiKt4PFlow_EMJES', + } + +SystematicNameList = ['PunchThrough_MC16','PunchThrough_AFII'] + +def ReadPunchthroughHistograms(dirName): + if not dirName.endswith("/"): + dirName = dirName + "/" + + # Run over the one file + rootFileList = sorted(glob.glob(dirName+"*.root")) + fileDict = {} + if len(rootFileList) != 1: + print "Found a number of root files not equal to 1 in dir:",dirName + print "Assume separate files for", + for i in jetDefDict.keys() : print i, + print + for aJetDef in jetDefDict.keys() : + for file in rootFileList : + if aJetDef in file : + if aJetDef not in fileDict.keys() : + fileDict[aJetDef] = file + else : + print "Oh no! More than one file corresponding to this jet definition:",aJetDef + return None + else : + print "Found only one root file: assume contents can be used for all jet collections." + for aJetDef in jetDefDict.keys() : + fileDict[aJetDef] = rootFileList[0] + + histos = {} + for aJetDef,aJetDefProv in jetDefDict.iteritems(): + rootFile = TFile(fileDict[aJetDef],"READ") + histos[aJetDefProv] = {} + + for histName in rootFile.GetKeyNames(): + if aJetDef not in histName: continue + for aKey in SystematicNameList: + if "_MC" in aKey : + gethistName = aKey+"_"+aJetDef + histo = rootFile.Get(gethistName) + if histo is None: + print "Failed to get histogram:",histName + return None + histo.SetName(aKey+"_"+aJetDefProv) + histo.SetDirectory(0) + + # In Lydia's histogram: + # x axis is pT. + # y axis is eta + # z axis is NSegments + # Last two axes need to get swapped to be compatible with 8TeV!!!! + + # In Christopher's histogram, + # these are back to being as requested. + + pTBinArray = [] + nPTBins = histo.GetXaxis().GetNbins() + for bin in range(1,nPTBins+2) : + binEdge = histo.GetXaxis().GetBinLowEdge(bin) + pTBinArray.append(binEdge) + pTBinArray = array('d',pTBinArray) + + etaBinArray = [] +# if "EM" in aJetDef : +# nEtaBins = histo.GetYaxis().GetNbins() +# for bin in range(1,nEtaBins+2) : +# binEdge = histo.GetYaxis().GetBinLowEdge(bin) +# etaBinArray.append(binEdge) +# else : + nEtaBins = histo.GetZaxis().GetNbins() + for bin in range(1,nEtaBins+2) : + binEdge = histo.GetZaxis().GetBinLowEdge(bin) + etaBinArray.append(binEdge) + etaBinArray = array('d',etaBinArray) + + nSegmentsBinArray = [] +# if "EM" in aJetDef : +# nNSegBins = histo.GetZaxis().GetNbins() +# for bin in range(1,nNSegBins+2) : +# binEdge = histo.GetZaxis().GetBinLowEdge(bin) +# nSegmentsBinArray.append(binEdge) +# else : + nNSegBins = histo.GetYaxis().GetNbins() + for bin in range(1,nNSegBins+2) : + binEdge = histo.GetYaxis().GetBinLowEdge(bin) + nSegmentsBinArray.append(binEdge) + + nSegmentsBinArray = array('d',nSegmentsBinArray) + + outhisto = TH3D(aKey+"_"+aJetDefProv,aKey+"_"+aJetDefProv,nPTBins,pTBinArray,nNSegBins,nSegmentsBinArray,nEtaBins,etaBinArray) + outhisto.SetDirectory(0) + + # Fix histo margins to make sure it only applies the calibration where it should. + # Loop over all bins in x, y, z. + for xbin in range(histo.GetNbinsX()+2) : + for ybin in range(histo.GetNbinsY()+2) : + for zbin in range(histo.GetNbinsZ()+2) : + # Permitted regions are only: + # - pT > 50 GeV + # - eta < 2.7 + # - NSegments > 20 + +# if "EM" in aJetDef : +# if histo.GetXaxis().GetBinCenter(xbin) < 50 or \ +# histo.GetYaxis().GetBinCenter(ybin) > 2.7 or \ +# histo.GetZaxis().GetBinCenter(zbin) < 20 : +# histo.SetBinContent(xbin,ybin,zbin,0.0) +# outhisto.SetBinContent(xbin,zbin,ybin,0.0) +# else : +# outhisto.SetBinContent(xbin,zbin,ybin,histo.GetBinContent(xbin,ybin,zbin)) + +# elif "LC" in aJetDef : + if histo.GetXaxis().GetBinCenter(xbin) < 50 or \ + histo.GetZaxis().GetBinCenter(zbin) > 2.7 or \ + histo.GetYaxis().GetBinCenter(ybin) < 20 : + histo.SetBinContent(xbin,ybin,zbin,0.0) + outhisto.SetBinContent(xbin,ybin,zbin,0.0) + else : + outhisto.SetBinContent(xbin,ybin,zbin,histo.GetBinContent(xbin,ybin,zbin)) + + + histos[aJetDefProv][aKey] = outhisto + + # Add a blank histogram for AFII corresponding to this + else : + outhisto = TH3D(aKey+"_"+aJetDefProv,aKey+"_"+aJetDefProv,2,15.0,4500.0,2,0.0,1000.0,2,-4.5,4.5) + outhisto.SetDirectory(0) + histos[aJetDefProv][aKey] = outhisto + + # Done reading, close the file + rootFile.Close() + print "Done punchthrough.\n" + + return histos + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParsebJESInput.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParsebJESInput.py new file mode 100755 index 0000000000000000000000000000000000000000..43b6856034a7167c0783fcbdc0bc0e86c103cbdb --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ParsebJESInput.py @@ -0,0 +1,71 @@ +from ROOT import * +from array import array +import glob +import re +import math +import ProviderHistoHelpers + +jetDefDict = { + 'AntiKt4EMTopo' : 'AntiKt4Topo_EMJES', +# 'AntiKt6EMTopo' : 'AntiKt6Topo_EMJES', + 'AntiKt4LCTopo' : 'AntiKt4PFlow_EMJES', +# 'AntiKt6LCTopo' : 'AntiKt6Topo_LCJES' + } + +def ReadBJESHistograms(dirName): + if not dirName.endswith("/"): + dirName = dirName + "/" + + # Run over each file (one per jet definition) + # Skip files that don't start with bJES + histos = {} + files = sorted(glob.glob(dirName+"bJES*.root")) + print "Found files",files + + if len(files) > 1 : + print "Not what I expected!" + return None + aFileName = files[0] + + # Read in the histograms of interest from the file + inFile = TFile(aFileName,"READ") + for inFileDef in jetDefDict.keys() : + jetDef = jetDefDict[inFileDef] + if jetDef not in histos.keys() : + histos[jetDef] = {} + fetchName = "bResponseDiff_" + inFileDef + systematicName = "bJES_" + jetDef + histo = inFile.Get(fetchName) + print "Trying to get histo",fetchName + print histo + if histo is None: + print "Failed to get histogram:",systematicName + return None + else : + print "Got histogram",systematicName + histo.SetDirectory(0) + nbinsx = histo.GetNbinsX() + binsx = histo.GetXaxis().GetXbins() + newhisto = TH2D("bJES_extendedEta_{0}".format(jetDef),"bJES_extendedEta_{0}".format(jetDef),nbinsx,binsx.GetArray(),2,-4.4,4.4) + newhisto.SetDirectory(0) + + # This input is symmetric in eta but doesn't extend far enough. + # Should be symmetric in eta: find max value in each row and set everywhere. + # eta bins are y bins: + for ptbin in range(1,histo.GetNbinsX()+1) : + + # Get max val + maxVal = 0.0 + for etabin in range(1,histo.GetNbinsY()) : + thisVal = histo.GetBinContent(ptbin,etabin) + if thisVal > maxVal : maxVal = thisVal + for etabin in range(1,newhisto.GetNbinsY()+1) : + newhisto.SetBinContent(ptbin,etabin,maxVal) + + histos[jetDef]['bJES'] = newhisto + + # Done reading, close the file + inFile.Close() + + return histos + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ProviderHistoHelpers.py b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ProviderHistoHelpers.py new file mode 100755 index 0000000000000000000000000000000000000000..39c8282df22a8257d8543bdfa731ae98b81cb698 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/ProviderHistoHelpers.py @@ -0,0 +1,196 @@ +from ROOT import * +from array import array +import glob +import re +import math + + +def GetDefaultPtBins(numBins=100,lowVal=15.0,highVal=2500.0): + dx = (math.log(highVal)-math.log(lowVal))/numBins + bins = [] + for iBin in range(0,numBins+1): + bins.append(math.exp(math.log(lowVal)+iBin*dx)) + + return bins + +def GetDefaultEtaBins(): + etaValuesAsym = [0,0.15,0.3,0.8,1.0,1.2,1.65,2.1,2.45,2.8,3.0,3.2,3.6,4.5] + etaValuesSym = [] + for aVal in etaValuesAsym: + etaValuesSym.append(aVal) + if math.fabs(aVal) > 1.e-4: # Don't double-count zero + etaValuesSym.append(-aVal) + + return sorted(etaValuesSym) + +def GetCentredBins(values): + if len(values) == 1: + return [values[0]*0.5,values[0]*1.5] + + binList = [] + for iVal in range(0,len(values)-1): + binList.append(values[iVal]+(values[iVal+1]-values[iVal])/2.0) + binList.insert(0,values[0]-(values[1]-values[0])/2.0) + binList.append(values[-1]+(values[-1]-values[-2])/2.0) + + return binList + +def MakeProviderHisto(histoName,ptBins=GetDefaultPtBins(),etaBins=GetDefaultEtaBins()): + return TH2D(histoName,histoName,len(ptBins)-1,array('d',ptBins),len(etaBins)-1,array('d',etaBins)) + + +def ConvertPtHistoToProviderHisto(histo1D,histoName): + histo2D = MakeProviderHisto(histoName,etaBins=[min(GetDefaultEtaBins()),0,max(GetDefaultEtaBins())]) + + oldMinPt = histo1D.GetXaxis().GetBinLowEdge(1) + oldMaxPt = histo1D.GetXaxis().GetBinLowEdge(histo1D.GetNbinsX()+1) + tolerance = 1.0e-4 + for ptBin in range(1,histo2D.GetNbinsX()+1): + pt = histo2D.GetXaxis().GetBinCenter(ptBin) + unc = 0.0 + if pt <= oldMinPt: + unc = histo1D.Interpolate(oldMinPt+tolerance) + elif pt >= oldMaxPt: + unc = histo1D.Interpolate(oldMaxPt+tolerance) + else: + unc = histo1D.Interpolate(pt) + + for etaBin in range(1,histo2D.GetNbinsY()+1): + histo2D.SetBinContent(ptBin,etaBin,unc) + + return histo2D + +def ConvertTGraphToProviderHisto(graph,histoName): + pointsX = [] + pointsY = [] + for iPoint in range(0,graph.GetN()): + px = Double(0) + py = Double(0) + graph.GetPoint(iPoint,px,py) + pointsX.append(px) + pointsY.append(py) + + # Make bins with the points as the centre where possible + bins = GetCentredBins(pointsX) + + # Extend the range to cover [15,2500] if necessary + if bins[0] > 15: + bins.insert(0,15.) + pointsX.inset(0,(bins[0]+bins[1])/2.0) + pointsY.insert(0,pointsY[0]) + + if bins[-1] < 2500: + bins.append(2500.) + pointsX.append((bins[-1]+bins[-2])/2.0) + pointsY.append(pointsY[-1]) + + # Make the histo and fill it + histo = MakeProviderHisto(histoName,ptBins=bins,etaBins=[min(GetDefaultEtaBins()),0,max(GetDefaultEtaBins())]) + for ptBin in range(1,histo.GetNbinsX()+1): + for etaBin in range(1,histo.GetNbinsY()+1): + histo.SetBinContent(ptBin,etaBin,pointsY[ptBin-1]) + + return histo + +def ExtendPtRangeOfHisto(histo,histoName): + # Get the current bins + ptBins = [] + for xBin in range(1,histo.GetNbinsX()+2): + ptBins.append(histo.GetXaxis().GetBinLowEdge(xBin)) + + # Extend only if necessary + if math.fabs(ptBins[-1] - 2500) < 1.e-4: + print "Histo already went to 2500 GeV, doing nothing" + return histo + elif ptBins[-1] > 2500: + print "Histo beyond range, cannot extend" + return None + ptBins.append(2500.) + + # Get eta bins + etaBins = [] + for yBin in range(1,histo.GetNbinsY()+2): + etaBins.append(histo.GetYaxis().GetBinLowEdge(yBin)) + + # Make and fill + newHisto = MakeProviderHisto(histoName,ptBins=ptBins,etaBins=etaBins) + for xBin in range(1,histo.GetNbinsX()+1): + for yBin in range(1,histo.GetNbinsY()+1): + newHisto.SetBinContent(xBin,yBin,histo.GetBinContent(xBin,yBin)) + for yBin in range(1,histo.GetNbinsY()+1): + newHisto.SetBinContent(histo.GetNbinsX()+1,yBin,histo.GetBinContent(histo.GetNbinsX(),yBin)) + + return newHisto + +def SymmetrizeHistoInEta(histo,histoName): + # Get the current eta bins and symmetrize + etaBins = [] + for yBin in range(1,histo.GetNbinsY()+2): + etaVal = histo.GetYaxis().GetBinLowEdge(yBin) + if math.fabs(etaVal) > 1.e-4: + etaBins.append(-etaVal) + etaBins.append(etaVal) + etaBins = sorted(etaBins) + + # Get the current pT bins + ptBins = [] + for xBin in range(1,histo.GetNbinsX()+2): + ptBins.append(histo.GetXaxis().GetBinLowEdge(xBin)) + + # Make and fill + newHisto = MakeProviderHisto(histoName,ptBins=ptBins,etaBins=etaBins) + for xBin in range(1,histo.GetNbinsX()+1): + xVal = histo.GetXaxis().GetBinCenter(xBin) + for yBin in range(1,histo.GetNbinsY()+1): + yVal = histo.GetYaxis().GetBinCenter(yBin) + newHisto.SetBinContent(newHisto.GetXaxis().FindBin(xVal),newHisto.GetYaxis().FindBin(-yVal),histo.GetBinContent(xBin,yBin)) + newHisto.SetBinContent(newHisto.GetXaxis().FindBin(xVal),newHisto.GetYaxis().FindBin(yVal),histo.GetBinContent(xBin,yBin)) + + return newHisto + +def QuadratureSumHisto(histoName,histos): + # If it's one histo, just return it + if len(histos) == 1: + return histos[0] + + # Ensure that the binning is the same + tolerance = 1.e-4 + for aHisto in histos[1:]: + if aHisto.GetNbinsX() != histos[0].GetNbinsX(): + print "Input histograms have different number of x bins - can't do quadrature sum safely" + return None + elif aHisto.GetNbinsY() != histos[0].GetNbinsY(): + print "Input histograms have different number of y bins - can't do quadrature sum safely" + return None + for xBin in range(1,histos[0].GetNbinsX()+2): + edge = None + for aHisto in histos: + if edge is None: + edge = aHisto.GetXaxis().GetBinLowEdge(xBin) + elif math.fabs(edge-aHisto.GetXaxis().GetBinLowEdge(xBin)) > tolerance: + print "Input histograms have different x binning - can't do quadrature sum safely" + return None + for yBin in range(1,histos[0].GetNbinsY()+2): + edge = None + for aHisto in histos: + if edge is None: + edge = aHisto.GetYaxis().GetBinLowEdge(yBin) + elif math.fabs(edge-aHisto.GetYaxis().GetBinLowEdge(yBin)) > tolerance: + print "Input histograms have different y binning - can't do quadrature sum safely" + return None + + # Same binning - good, we can continue + # Clone the first histo for the binning + quadSumHisto = histos[0].Clone() + for xBin in range(1,quadSumHisto.GetNbinsX()+1): + for yBin in range(1,quadSumHisto.GetNbinsY()+1): + quadSum = 0 + for aHisto in histos: + quadSum += pow(aHisto.GetBinContent(xBin,yBin),2) + quadSumHisto.SetBinContent(xBin,yBin,sqrt(quadSum)) + + return quadSumHisto + + + + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/runMakeFile.sh b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/runMakeFile.sh new file mode 100755 index 0000000000000000000000000000000000000000..7803fc7b7ed8edade2739f6b8aee76813d1793cf --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/runMakeFile.sh @@ -0,0 +1,10 @@ +python ParseInputs.py \ +/eos/atlas/atlascerngroupdisk/perf-jets/JESJER/Recommendations/r21/InSituUncertainties \ +/eos/atlas/atlascerngroupdisk/perf-jets/JESJER/Recommendations/r21/EtaInterCalibration \ +/eos/atlas/atlascerngroupdisk/perf-jets/JESJER/Recommendations/r21/SingleParticle/Uncertainties/UsedFall2018/Release20p7_HighPtTerm_Fall2018adjusted.root \ +/eos/atlas/atlascerngroupdisk/perf-jets/JESJER/Recommendations/r21/AFII_Uncertainties/ \ +/eos/atlas/atlascerngroupdisk/perf-jets/JESJER/Recommendations/r21/PileUpUncertainties/UsedFall2018/ \ +/eos/atlas/atlascerngroupdisk/perf-jets/JESJER/Recommendations/r21/FlavorUncertainties/UsedFall2018Recommendations/general/ \ +/eos/atlas/atlascerngroupdisk/perf-jets/JESJER/Recommendations/r21/FlavorUncertainties/UsedFall2018Recommendations/bJES \ +/eos/atlas/atlascerngroupdisk/perf-jets/JESJER/Recommendations/r21/Punchthrough_R21_19Sept2018 \ +/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/CalibArea-05/rel21/Summer2018/R4_AllComponents.root \ No newline at end of file diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/runMakeMJBFile.sh b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/runMakeMJBFile.sh new file mode 100755 index 0000000000000000000000000000000000000000..b4b0f3710b2c5163ee764ef9671dac2fbd47f51b --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/InputScripts/January2018_specialStatTerms/runMakeMJBFile.sh @@ -0,0 +1,6 @@ +python MakeFileForMJB.py \ +/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Fall2018/forMJBInputs_GammaZJet \ +/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Fall2018/EtaIntercalibration \ +/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Fall2018/Pileup \ +/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Fall2018/Flavour \ +/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/inputs/Fall2018/PunchThrough diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/atlasstyle/AtlasLabels.C b/Reconstruction/Jet/JetUncertainties/testingMacros/atlasstyle/AtlasLabels.C index 45417038043bb832d2f0f00faf606cc0e0439626..2de0afca5efd8a0ac764cfc929d600e78986e371 100644 --- a/Reconstruction/Jet/JetUncertainties/testingMacros/atlasstyle/AtlasLabels.C +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/atlasstyle/AtlasLabels.C @@ -54,7 +54,7 @@ void ATLASVersion(char* version,Double_t x,Double_t y,Color_t color) if (version) { char versionString[100]; - snprintf(versionString,99,"Version %s",version); + sprintf(versionString,"Version %s",version); TLatex l; l.SetTextAlign(22); l.SetTextSize(0.04); diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/atlasstyle/AtlasLabels.h b/Reconstruction/Jet/JetUncertainties/testingMacros/atlasstyle/AtlasLabels.h index 8a58fa2113943e3054d60efae25bdc2ad8af8386..9a8f403d26376f6cf78014e5638923d89b180093 100644 --- a/Reconstruction/Jet/JetUncertainties/testingMacros/atlasstyle/AtlasLabels.h +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/atlasstyle/AtlasLabels.h @@ -7,6 +7,7 @@ // // @author M.Sutton // +// Copyright (C) 2010 Atlas Collaboration // // $Id: AtlasLabels.h, v0.0 Thu 25 Mar 2010 10:34:20 CET $ diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/atlasstyle/AtlasStyle.h b/Reconstruction/Jet/JetUncertainties/testingMacros/atlasstyle/AtlasStyle.h index 3735bc5c80b107d784589252fa9b15ee9ec550e6..52eca17ce554c8a93f91dd5404bbf45879d70365 100644 --- a/Reconstruction/Jet/JetUncertainties/testingMacros/atlasstyle/AtlasStyle.h +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/atlasstyle/AtlasStyle.h @@ -10,6 +10,7 @@ // // @author M.Sutton // +// Copyright (C) 2010 Atlas Collaboration // // $Id: AtlasStyle.h, v0.0 Thu 25 Mar 2010 10:34:20 CET $ diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/ChangeHistoRange.py b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/ChangeHistoRange.py new file mode 100644 index 0000000000000000000000000000000000000000..630415e6473c1c784fcf6b0c57eb94804ea8df8b --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/ChangeHistoRange.py @@ -0,0 +1,227 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +import sys +import re +import array +from math import fabs +from ROOT import * + +def GetKeyNames(self,dir=""): + self.cd(dir) + return [key.GetName() for key in gDirectory.GetListOfKeys()] +TFile.GetKeyNames = GetKeyNames + +if len(sys.argv) < 7: + print "Too few arguments. Expected the following:" + print " 1. Input file" + print " 2. Output file" + print " 3. Name of histogram to modify" + print " 4. Axis (x, y, or z)" + print " 5. New lower value, -999 to leave unchanged" + print " 6. New upper value, -999 to leave unchanged" + sys.exit(1) + +# Arguments +inFile = TFile.Open(sys.argv[1],"READ") +outFile = TFile.Open(sys.argv[2],"RECREATE") +histName = sys.argv[3] +axis = sys.argv[4] +lowBound = float(sys.argv[5]) +highBound = float(sys.argv[6]) +changeLow = not (fabs(lowBound+999) < 1.e-4) +changeHigh = not (fabs(highBound+999) < 1.e-4) + +# Sanity checks +if histName not in inFile.GetKeyNames(): + print "The requested histogram is not in the input file:",histName + sys.exit(2) +if axis not in ["x","y","z","X","Y","Z"]: + print "Axis is not x, y, or z:",axis + sys.exit(2) +if (not changeLow) and (not changeHigh): + print "Requesting to change neither the low or high boundary, nothing to do" + sys.exit(2) +if changeLow and changeHigh and lowBound > highBound: + print "Requesting a new lower boundary that is below the upper boundary" + sys.exit(2) + +# Write histograms, changing the one requested +for aHist in inFile.GetKeyNames(): + hist = inFile.Get(aHist) + if aHist != histName: + outFile.cd() + hist.Write(aHist) + else: + # Build the histogram bins + binsX = [] + for xBin in range(1,hist.GetNbinsX()+2): + binsX.append(hist.GetXaxis().GetBinLowEdge(xBin)) + binsY = [] + if hist.GetDimension() > 1: + for yBin in range(1,hist.GetNbinsY()+2): + binsY.append(hist.GetYaxis().GetBinLowEdge(yBin)) + binsZ = [] + if hist.GetDimension() > 2: + for zBin in range(1,hist.GetNbinsZ()+2): + binsZ.append(hist.GetZaxis().GetBinLowEdge(zBin)) + + # Check which one we are changing + refBins = None + if axis == "x" or axis == "X": + refBins = binsX + elif axis == "y" or axis == "Y": + if hist.GetDimension() > 1: + refBins = binsY + else: + print "Requested y axis for a 1D histogram" + sys.exit(3) + elif axis == "z" or axis == "Z": + if hist.GetDimension() > 2: + refBins = binsZ + else: + print "Requested z axis for a 1D or 2D histogram" + sys.exit(3) + else: + print "Couldn't interpret axis request:",axis + sys.exit(3) + + # Modify bins as needed + newBins = [] + if changeLow and lowBound > refBins[-1]: + print "New low bin is above the upper bound of the histogram" + sys.exit(4) + if changeHigh and highBound < refBins[0]: + print "New high bin is below the lower bound of the histogram" + sys.exit(4) + if changeLow: + newBins.append(lowBound) + for aBin in refBins: + if changeLow and fabs(aBin-lowBound) < 1.e-4: + continue # Added before + elif changeLow and aBin < lowBound: + continue + elif changeHigh and fabs(aBin-highBound) < 1.e-4: + continue # Adding after + elif changeHigh and aBin > highBound: + continue + newBins.append(aBin) + if changeHigh: + newBins.append(highBound) + + # Map old bins to new bins + # Very stupid brute force due to time constraints + binPairs = [] + for aBin,aBinI in zip(refBins,range(1,len(refBins)+1)): + for newBin,newBinI in zip(newBins,range(1,len(newBins)+1)): + if fabs(aBin-newBin)<1.e-4: + binPairs.append([aBinI,newBinI]) + if changeLow and binPairs[0][1] != 1: + if newBins[0] < refBins[0]: + binPairs.insert(0,[1,1]) # hold fixed to new bins + else: + binPairs.insert(0,[binPairs[0][0]-1,binPairs[0][1]-1]) + if changeHigh and binPairs[0][-1] != len(binPairs): + if newBins[-1] > refBins[-1]: + binPairs.append([len(refBins),len(newBins)]) # hold fixed to new bins + else: + binPairs.append([binPairs[-1][0]+1,binPairs[-1][1]+1]) + if len(binPairs) != len(newBins): + print "Error: mismatched numbers of bins and bin pairs" + sys.exit(5) + + + # Make the histogram + # Doing this brute-force for now... + newHist = None + if hist.GetDimension() == 1: + if isinstance(hist,TH1F): + newHist = TH1F(histName+"_mod",hist.GetTitle(),len(newBins)-1,array.array('f',newBins)) + elif isinstance(hist,TH1D): + newHist = TH1D(histName+"_mod",hist.GetTitle(),len(newBins)-1,array.array('d',newBins)) + else: + print "Unsupported type of 1D histogram" + sys.exit(5) + elif hist.GetDimension() == 2: + if isinstance(hist,TH2F): + if axis == "x" or axis == "X": + newHist = TH2F(histName+"_mod",hist.GetTitle(),len(newBins)-1,array.array('f',newBins),len(binsY)-1,array.array('f',binsY)) + elif axis == "y" or axis == "Y": + newHist = TH2F(histName+"_mod",hist.GetTitle(),len(binsX)-1,array.array('f',binsX),len(newBins)-1,array.array('f',newBins)) + elif isinstance(hist,TH2D): + if axis == "x" or axis == "X": + newHist = TH2D(histName+"_mod",hist.GetTitle(),len(newBins)-1,array.array('d',newBins),len(binsY)-1,array.array('d',binsY)) + elif axis == "y" or axis == "Y": + newHist = TH2D(histName+"_mod",hist.GetTitle(),len(binsX)-1,array.array('d',binsX),len(newBins)-1,array.array('d',newBins)) + else: + print "Unsupported type of 2D histogram" + sys.exit(5) + elif hist.GetDimension() == 3: + if isinstance(hist,TH3F): + if axis == "x" or axis == "X": + newHist = TH3F(histName+"_mod",hist.GetTitle(),len(newBins)-1,array.array('f',newBins),len(binsY)-1,array.array('f',binsY),len(binsZ)-1,array.array('f',binsZ)) + elif axis == "y" or axis == "Y": + newHist = TH3F(histName+"_mod",hist.GetTitle(),len(binsX)-1,array.array('f',binsX),len(newBins)-1,array.array('f',newBins),len(binsZ)-1,array.array('f',binsZ)) + elif axis == "z" or axis == "Z": + newHist = TH3F(histName+"_mod",hist.GetTitle(),len(binsX)-1,array.array('f',binsX),len(binsY)-1,array.array('f',binsY),len(newBins)-1,array.array('f',newBins)) + elif isinstance(hist,TH3D): + if axis == "x" or axis == "X": + newHist = TH3D(histName+"_mod",hist.GetTitle(),len(newBins)-1,array.array('d',newBins),len(binsY)-1,array.array('d',binsY),len(binsZ)-1,array.array('d',binsZ)) + elif axis == "y" or axis == "Y": + newHist = TH3D(histName+"_mod",hist.GetTitle(),len(binsX)-1,array.array('d',binsX),len(newBins)-1,array.array('d',newBins),len(binsZ)-1,array.array('d',binsZ)) + elif axis == "z" or axis == "Z": + newHist = TH3D(histName+"_mod",hist.GetTitle(),len(binsX)-1,array.array('d',binsX),len(binsY)-1,array.array('d',binsY),len(newBins)-1,array.array('d',newBins)) + else: + print "Unsupported type of 3D histogram" + sys.exit(5) + else: + print "Unsupported histogram dimensionality" + sys.exit(5) + + # Now we have the histogram, let's fill it + # Done this way now as it runs faster (although less compact for humans...) + if hist.GetDimension() == 1: + for oldBin,newBin in binPairs: + newHist.SetBinContent(newBin,hist.GetBinContent(oldBin)) + newHist.SetBinError(newBin,hist.GetBinError(oldBin)) + if hist.GetDimension() == 2: + if axis == "x" or axis == "X": + for oldBin,newBin in binPairs: + for yBin in range(1,hist.GetNbinsY()+1): + newHist.SetBinContent(newBin,yBin,hist.GetBinContent(oldBin,yBin)) + newHist.SetBinError(newBin,yBin,hist.GetBinError(oldBin,yBin)) + else: + for xBin in range(1,hist.GetNbinsX()+1): + for oldBin,newBin in binPairs: + newHist.SetBinContent(xBin,newBin,hist.GetBinContent(xBin,oldBin)) + newHist.SetBinError(xBin,newBin,hist.GetBinError(xBin,oldBin)) + if hist.GetDimension() == 3: + if axis == "x" or axis == "X": + for oldBin,newBin in binPairs: + for yBin in range(1,hist.GetNbinsY()+1): + for zBin in range(1,hist.GetNbinsZ()+1): + newHist.SetBinContent(newBin,yBin,zBin,hist.GetBinContent(oldBin,yBin,zBin)) + newHist.SetBinError(newBin,yBin,zBin,hist.GetBinError(oldBin,yBin,zBin)) + elif axis == "y" or axis == "Y": + for xBin in range(1,hist.GetNbinsX()+1): + for oldBin,newBin in binPairs: + for zBin in range(1,hist.GetNbinsZ()+1): + newHist.SetBinContent(xBin,newBin,zBin,hist.GetBinContent(xBin,oldBin,zBin)) + newHist.SetBinError(xBin,newBin,zBin,hist.GetBinError(xBin,oldBin,zBin)) + else: + for xBin in range(1,hist.GetNbinsX()+1): + for yBin in range(1,hist.GetNbinsY()+1): + for oldBin,newBin in binPairs: + newHist.SetBinContent(xBin,yBin,newBin,hist.GetBinContent(xBin,yBin,oldBin)) + newHist.SetBinError(xBin,yBin,newBin,hist.GetBinError(xBin,yBin,oldBin)) + + # Filled histogram, finally + # Write it out with the old name + outFile.cd() + newHist.Write(histName) + + + +outFile.Close() +inFile.Close() + + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/CombineRootFiles.py b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/CombineRootFiles.py index b53b3ef28d0fd2c7bd20238b9a0d0beeecf417e8..87e7f1aec0d9963066bde20282bee11e8810c329 100644 --- a/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/CombineRootFiles.py +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/CombineRootFiles.py @@ -3,6 +3,8 @@ import sys import re +import math +import os from ROOT import * def GetKeyNames(self,dir=""): self.cd(dir) @@ -28,23 +30,42 @@ for aFileName in inFileNames: print "Input file doesn't appear to be a root file:",aFileName print "Blocking for safety" exit(3) + if not os.path.isfile(aFileName): + print "Input file doesn't exist:",aFileName + print "Blocking for safety" + exit(3) outFile = TFile(outFileName,"RECREATE") -#foundValid=False +# Store the names of the histograms we are adding to enforce uniqueness +uniqueHistos = {} + for aFileName in inFileNames: print "Reading file:",aFileName aFile = TFile(aFileName,"READ") for histName in aFile.GetKeyNames(): - #if histName.startswith("ValidRange"): - # if foundValid: - # continue - # else: - # foundValid = True - hist = aFile.Get(histName) - outFile.cd() - hist.Write(histName) + if histName not in uniqueHistos.keys(): + hist = aFile.Get(histName) + outFile.cd() + hist.Write(histName) + + # Store the histogram and name + hist.SetDirectory(0) + uniqueHistos[histName] = hist + else: + # Check if they are identical histograms + hist = aFile.Get(histName) + hist.Add(uniqueHistos[histName],-1) + areDifferent = ( math.fabs(hist.GetMinimum()) > 1.e-8 or math.fabs(hist.GetMaximum()) > 1.e-8 ) + + if areDifferent: + print "[ERROR] Two non-identical histograms with the same name were provided: %s"%(histName) + print "Aborting..." + exit(1) + else: + print "[SAFE] Skipping non-unique histogram name which is identical to the old one: %s"%(histName) + aFile.Close() diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/CompareRootFiles.py b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/CompareRootFiles.py new file mode 100644 index 0000000000000000000000000000000000000000..da434afb8ba5d99d2b15dd013ef2f366e2dc8213 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/CompareRootFiles.py @@ -0,0 +1,47 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +import sys +import re +from math import fabs +from ROOT import * + +def GetKeyNames(self,dir=""): + self.cd(dir) + return [key.GetName() for key in gDirectory.GetListOfKeys()] +TFile.GetKeyNames = GetKeyNames + + +if len(sys.argv) < 4: + print "Too few arguments. Expected the following:" + print " 1. Input root file 1" + print " 2. Input root file 2" + print " 3. Output plot file (.root)" + exit(1) + +inFile1 = TFile.Open(sys.argv[1],"READ") +inFile2 = TFile.Open(sys.argv[2],"READ") +outFile = TFile.Open(sys.argv[3],"RECREATE") + +# First check for different histograms +for histName in inFile1.GetKeyNames(): + if histName not in inFile2.GetKeyNames(): + print "Histogram in file1 but not file2:",histName +for histName in inFile2.GetKeyNames(): + if histName not in inFile1.GetKeyNames(): + print "Histogram in file2 but not file1:",histName + +# Now compare the same histograms +for histName in inFile1.GetKeyNames(): + if histName in inFile2.GetKeyNames(): + hist1 = inFile1.Get(histName) + hist2 = inFile2.Get(histName) + hist1.Add(hist2,-1) + if fabs(hist1.GetMaximum()) > 1.e-4 or fabs(hist1.GetMinimum()) > 1.e-4: + print "Histogram values differ:",histName + outFile.cd() + hist1.Write(histName) + +outFile.Close() +inFile1.Close() +inFile2.Close() + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/CorrelationMatrixHelpers.py b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/CorrelationMatrixHelpers.py index bbf74c9efd58e5e7d5ce1689f1f5d13c4dd8de07..c668253b64d07512035ad25d158df93d0311de58 100644 --- a/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/CorrelationMatrixHelpers.py +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/CorrelationMatrixHelpers.py @@ -409,23 +409,42 @@ class CorrMat4D: # 4D histogram plotting helpers def DrawLabels(hist,jetDefString,scenarioString,drawATLASLabel,labelName): - if drawATLASLabel: - AtlasStyleMacro.ATLASLabel(0.10,0.845,labelName) - jetDefLabel = "" - - if jetDefString.startswith("AntiKt4"): - jetDefLabel += "anti-k_{t} #it{R} = 0.4, " - elif jetDefString.startswith("AntiKt6"): - jetDefLabel += "anti-k_{t} #it{R} = 0.6, " - - if jetDefString.endswith("LCTopo") or jetDefString.endswith("TopoLC"): - jetDefLabel += "LCW+JES" - elif jetDefString.endswith("EMTopo") or jetDefString.endswith("TopoEM"): - jetDefLabel += "EM+JES" - - scenarioString = "{0}".format(scenarioString) - doDrawText(0.10,0.900,jetDefLabel+" 2016") - doDrawText(0.10,0.955,scenarioString) + if scenarioString != "": + if drawATLASLabel: + AtlasStyleMacro.ATLASLabel(0.10,0.845,labelName) + jetDefLabel = "" + + if jetDefString.startswith("AntiKt4"): + jetDefLabel += "anti-k_{t} #it{R} = 0.4, " + elif jetDefString.startswith("AntiKt6"): + jetDefLabel += "anti-k_{t} #it{R} = 0.6, " + + if jetDefString.endswith("LCTopo") or jetDefString.endswith("TopoLC"): + jetDefLabel += "LCW+JES" + elif jetDefString.endswith("EMTopo") or jetDefString.endswith("TopoEM"): + jetDefLabel += "EM+JES" + + scenarioString = "{0}".format(scenarioString) + doDrawText(0.10,0.900,jetDefLabel+" 2016") + doDrawText(0.10,0.955,scenarioString) + else: + if drawATLASLabel: + AtlasStyleMacro.ATLASLabel(0.09,0.955,labelName) + jetDefLabel = "" + + if jetDefString.startswith("AntiKt4"): + jetDefLabel += "anti-#it{k}_{t} #it{R} = 0.4, " + elif jetDefString.startswith("AntiKt6"): + jetDefLabel += "anti-#it{k}_{t} #it{R} = 0.6, " + + if jetDefString.endswith("LCTopo") or jetDefString.endswith("TopoLC"): + jetDefLabel += "LCW+JES + #it{in situ}" + elif jetDefString.endswith("EMTopo") or jetDefString.endswith("TopoEM"): + jetDefLabel += "EM+JES + #it{in situ}" + + scenarioString = "{0}".format(scenarioString) + doDrawText(0.50,0.955,jetDefLabel) + doDrawText(0.09,0.900,"Data 2015, #sqrt{s} = 13 TeV") def DrawLabelsGuessScenario(histo): jetDefString = histo.jetDef @@ -470,7 +489,12 @@ def DrawLabelsGuessScenario(histo): else: scenarioNum = "Correlation difference, full - %s"%(scenarioLabel) - DrawLabels(histo.hist4D,jetDefString,scenarioLabel,histo.DrawATLASLabel,histo.ATLASLabelName) + DrawLabels(histo.hist4D,jetDefString,"",histo.DrawATLASLabel,histo.ATLASLabelName) + #DrawLabels(histo.hist4D,jetDefString,scenarioLabel,histo.DrawATLASLabel,histo.ATLASLabelName) + + sanitizedLabel= "Uncovered correlation loss" if "Metric 2" in scenarioLabel else (scenarioLabel if "Metric" not in scenarioLabel else re.sub("\)","",re.sub(".*\(","",scenarioLabel))) + histo.hist4D.GetZaxis().SetTitle(sanitizedLabel) + histo.hist4D.GetZaxis().SetTitleOffset(1.8) def saveHists4D(canvas,plotFileName,hist,oneSidedAxis,fixedX,fixedY,fixedStr,scenarioLabel="",drawATLASLabel=True,additionalString = ""): diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/ExtractComponent.py b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/ExtractComponent.py new file mode 100644 index 0000000000000000000000000000000000000000..b013a202c58f5519990d6b4edaec87d767f7d56b --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/ExtractComponent.py @@ -0,0 +1,38 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +import sys +import re +from ROOT import * + +def GetKeyNames(self,dir=""): + self.cd(dir) + return [key.GetName() for key in gDirectory.GetListOfKeys()] +TFile.GetKeyNames = GetKeyNames + + +if len(sys.argv) < 4: + print "Too few arguments. Expected the following:" + print " 1. Input file" + print " 2. Output file" + print " 3+ Name(s) of components to extract" + exit(1) + +inputFile = TFile.Open(sys.argv[1],"READ") +outputFile = TFile.Open(sys.argv[2],"RECREATE") +compNames = sys.argv[3:] + +# Check that the request is possible +for compName in compNames: + if compName not in inputFile.GetKeyNames(): + print "Unable to continue - input file does not contain the requested component:",compName + exit(2) + +# Now do what the user asked +for compName in compNames: + hist = inputFile.Get(compName) + outputFile.cd() + hist.Write(compName) + +outputFile.Close() +inputFile.Close() + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/Make4DCorrelationMatrix.py b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/Make4DCorrelationMatrix.py index d2c9bf142f365852d92b10497c3d99daf0800736..a0441cad092714307b6da5adee8757f8a54e0740 100644 --- a/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/Make4DCorrelationMatrix.py +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/Make4DCorrelationMatrix.py @@ -176,11 +176,11 @@ print "6) still defined as:",fixedPtX,fixedPtY,fixedEtaX,fixedEtaY # Prepare the canvas print "Writing results to file: ",(re.sub(".eps","-*.eps",plotFileName) if plotFileName.endswith(".eps") else (re.sub(".png","-*.png",plotFileName) if plotFileName.endswith(".png") else plotFileName)) -canvas = TCanvas("canvas","4D Correlation Matrix",0,0,2500,2400) -canvas.SetLeftMargin(0.10 if not useRelativeMetric else 0.08) -canvas.SetRightMargin(0.15 if not useRelativeMetric else 0.17) +canvas = TCanvas("canvas","4D Correlation Matrix",0,0,2600,2200) +canvas.SetLeftMargin(0.09 if not useRelativeMetric else 0.08) +canvas.SetRightMargin(0.19 if not useRelativeMetric else 0.17) canvas.SetBottomMargin(0.04) -canvas.SetTopMargin(0.16) +canvas.SetTopMargin(0.12) canvas.SetLogz(useRelativeMetric) canvas.cd() canvas.Draw() diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/SwapComponents.py b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/SwapComponents.py new file mode 100644 index 0000000000000000000000000000000000000000..0e3063f7dec99e7e7bf1154361ea8d3056d51a17 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/SwapComponents.py @@ -0,0 +1,67 @@ +# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + +import sys +import re +from ROOT import * + +def GetKeyNames(self,dir=""): + self.cd(dir) + return [key.GetName() for key in gDirectory.GetListOfKeys()] +TFile.GetKeyNames = GetKeyNames + + +if len(sys.argv) < 4: + print "Too few arguments. Expected the following:" + print " 1. Output file" + print " 2. Primary input file (to be overwritten in parts)" + print " 3. New input file (to use to overwrite parts)" + print " 4. Optional: whether to interpret new histograms (TRUE) as additions or to exit (FALSE)" + sys.exit(1) + +outFile = TFile.Open(sys.argv[1],"RECREATE") +primaryFile = TFile.Open(sys.argv[2],"READ") +updateFile = TFile.Open(sys.argv[3],"READ") +addNew = True if len(sys.argv) > 4 and (sys.argv[4] == "TRUE" or sys.argv[4] == "True" or sys.argv[4] == "true") else False + + +# Figure out which components we want to replace and store the corresponding histograms +updates = {} +for histName in updateFile.GetKeyNames(): + hist = updateFile.Get(histName) + hist.SetDirectory(0) + updates[histName] = hist +updateFile.Close() + +# Check that we can find the components to replace +newHists = [] +for histName in updates.keys(): + if not histName in primaryFile.GetKeyNames(): + if not addNew: + print "Failed to find the original histogram to replace for key =",histName + sys.exit(2) + else: + newHists.append(histName) + +# We found everything we want to replace, so do it +for histName in primaryFile.GetKeyNames(): + hist = None + if histName in updates.keys(): + print "Updating component:",histName + hist = updates[histName] + else: + hist = primaryFile.Get(histName) + outFile.cd() + hist.Write(histName) + +# Add new histograms if requested +if addNew: + for newHist in newHists: + print "Adding new component:",newHist + hist = updates[newHist] + outFile.cd() + hist.Write(newHist) + + +outFile.Close() +primaryFile.Close() + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/SwitchComponentName.py b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/SwitchComponentName.py index 96f625c50524fbc290f4a9bef512b385f30dbe47..721ab8cf5cf9eb7b9b7abf13cf00dcc282251967 100644 --- a/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/SwitchComponentName.py +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/python_scripts/SwitchComponentName.py @@ -28,6 +28,7 @@ for histName in inputFile.GetKeyNames(): if TString(histName).Contains(compName): newHistName = re.sub(compName,newName,histName) print "Renaming component: %s --> %s"%(histName,newHistName) + outputFile.cd() hist.Write(newHistName) continue else: diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/run/runMakeSmearingPlots.sh b/Reconstruction/Jet/JetUncertainties/testingMacros/run/runMakeSmearingPlots.sh new file mode 100644 index 0000000000000000000000000000000000000000..238461bf0e10c5bc36478794b341d83d3fae830f --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/run/runMakeSmearingPlots.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +BOOLT="true" +BOOLF="false" + + +function ResTest \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC16" + CalibArea="" + configFile="JER/R4_GlobalReduction_JER.config" + outFile="JER-smear.pdf" + component="MassResUncWZ,-2" + isData="true" + options="prefix=JET_;path=\"/afs/cern.ch/work/s/sschramm/private/rel21/athena/Reconstruction/Jet/JetUncertainties/share/\";fixedEtaVals=0,0.1,0.45,1.0,1.55,2.15,2.85,3.35,4.0" +} + +function TestRelJMR \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16a" + CalibArea="CalibArea-05" + configFile="rel21/Moriond2018/R10_CaloMass_strong.config" + outFile="JMR-smear.pdf" + component="MassRes_Top,+1" + isData="false" + #options="prefix=JET_;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/CalibArea-05\";fixedEtaVals=0,0.4,1.2,1.8" + options="prefix=JET_;fixedEtaVals=0,0.4,1.2,1.8" +} + + + +# Check arguments +if test $# -lt 1 ; then + echo "USAGE: $0 <scenario to run> (options addition or overwrite)" + exit 1 +fi + +firstArg=$BOOLT +#echo "$BOOLT" +for anArg in $@ ; do + #echo "start loop" + #echo "$firstArg" + #echo "$BOOLT" + #echo "$anArg" + if [ "$firstArg" = "$BOOLT" ] ; then + # Run the specified scenario + #echo "running" + #echo "$1" + $1 + + # Check that it looks semi-reasonable + if [ -z "$outFile" ] ; then + echo "Output file is not specified" + echo "Check that you spelled the desired scenario correctly" + exit 2 + fi + + # Move on to options + firstArg=$BOOLF + continue + elif ! [ -z "$anArg" ] ; then + # Overwrite option(s) if needed + key=`echo $anArg | tr "=" " " | awk '{print $1}'` + val=`echo $anArg | tr "=" " " | awk '{print $2}'` + if [ -z "$key" ] || [ -z "$val" ] || [ "$key" = "$val" ] ; then + echo "Bad option formatting: $anArg" + exit 3 + fi + if [[ "$options" = *$key* ]] ; then + #Overwrite + options=`echo "$options" | sed s/"${key}=[^;]*"/"${key}=${val}"/g` + else + # Extend + options="${options};${key}=${val}" + fi + fi +done + +echo "Running with options: $options" +JetUncertainties_testResolution "$outFile" "$jetDefinition" "$MCtype" "$configFile" "$component" "$isData" "$options" + diff --git a/Reconstruction/Jet/JetUncertainties/testingMacros/run/runMakeUncertaintyPlots.sh b/Reconstruction/Jet/JetUncertainties/testingMacros/run/runMakeUncertaintyPlots.sh new file mode 100644 index 0000000000000000000000000000000000000000..84c20164231ac3a29a29f60b3dea147159d5ea8b --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/testingMacros/run/runMakeUncertaintyPlots.sh @@ -0,0 +1,4002 @@ +#!/bin/bash + +#executable="MakeUncertaintyPlots.exe" +#source="../code/MakeUncertaintyPlots.cxx" +# +#echo "Compiling executable" +#g++ -o $executable $source -Wall $($ROOTSYS/bin/root-config --cflags --glibs) -I $ROOTCOREBIN/include -L $ROOTCOREBIN/lib/* -DXAOD_STANDALONE `toAdd=""; for aLib in $ROOTCOREBIN/lib/x*/*so ; do clean="${aLib##*/}" ; clean="${clean%.so}" ; toAdd="$toAdd -l ${clean/lib/}" ; done ; echo $toAdd` +# +#if test $? -ne 0 ; then +# echo "Failed to compile: $executable" +# exit 1 +#fi +#echo "Successfully compiled code: $executable" + + +BOOLT="true" +BOOLF="false" + + +function Moriond2013 \ +{ + # Moriond 2013 release + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo;AntiKt6EMTopo;AntiKt6LCTopo" + MCtype="MC12a" + configFile="JES_2012/Moriond2013/InsituJES2012_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2013-Nominal.pdf" + compList="Insitu#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup, average 2012 conditions" + options="isDijet=true;isLargeR=false;prefix=JET_" +} + +function Moriond2013_AFII \ +{ + # Moriond 2013 release + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo;AntiKt6EMTopo" + MCtype="AFII" + configFile="JES_2012/Moriond2013/InsituJES2012_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2013-AFII-Nominal.pdf" + compList="Insitu#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;RelativeNonClosure_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup, average 2012 conditions;MC nonclosure, fast simulation" + options="isDijet=true;isLargeR=false;prefix=JET_" +} + +function Moriond2013_Stronger \ +{ + # Moriond 2013 release + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo;AntiKt6EMTopo;AntiKt6LCTopo" + MCtype="MC12a" + configFile="JES_2012/Moriond2013/InsituJES2012_StrongerCorrelations.config" + outFile="JetUncertainties-Moriond2013-Stronger.pdf" + compList="Insitu#,Zjet#,Gjet#,MJB#,Correlated_#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup, average 2012 conditions" + options="isDijet=true;isLargeR=false;prefix=JET_" +} + +function Moriond2013_OnlyLAr \ +{ + # Load default Moriond 2013 release + Moriond2013 + # Override variables + outFile="JetUncertainties-Moriond2013-OnlyLAr.pdf" + compList="Insitu_LAr#;Insitu_LArESmaterial;Insitu_LArESpresampler;Insitu_LArESZee" + compLabels="e/#gamma, total (all components);e/#gamma energy scale, material;e/#gamma energy scale, presampler;e/#gamma energy scale, Zee" +} + +function Moriond2013_OnlyZjet \ +{ + # Load default Moriond 2013 release + Moriond2013 + # Override variables + outFile="JetUncertainties-Moriond2013-OnlyZjet.pdf" + compList="Zjet_#;Zjet_Extrapolation;Zjet_MC;Zjet_JVF;Zjet_KTerm;Zjet_Veto;Zjet_Stat#" + compLabels="Z+jet, total (all components);Z+jet, extrapolation;Z+jet, MC generator;Z+jet, pileup rejection;Z+jet, out-of-cone;Z+jet, radiation suppression;Z+jet, combined statistics (x10)" +} + +function Moriond2013_OnlyGjet \ +{ + # Load default Moriond 2013 release + Moriond2013 + # Override variables + outFile="JetUncertainties-Moriond2013-OnlyGjet.pdf" + compList="Gjet_#;Gjet_dPhi;Gjet_Generator;Gjet_OOC;Gjet_Purity;Gjet_Veto;Gjet_Stat#" + compLabels="#gamma+jet, total (all components);#gamma+jet, extrapolation;#gamma+jet, MC generator;#gamma+jet, out-of-cone;#gamma+jet, photon purity;#gamma+jet, radiation suppression; #gamma+jet, combined statistics (x9)" +} + +function Moriond2013_OnlyMJB \ +{ + # Load default Moriond 2013 release + Moriond2013 + # Override variables + outFile="JetUncertainties-Moriond2013-OnlyMJB.pdf" + compList="MJB_#;MJB_Alpha;MJB_Beta;MJB_Fragmentation;MJB_Asym;MJB_Threshold;MJB_Stat#" + compLabels="MJB, total (all components);MJB, #alpha selection;MJB, #beta selection;MJB, fragmentation;MJB, #it{p}_{T} asymmetry;MJB, #it{p}_{T} threshold;MJB, combined statistics (x10)" +} + +function Moriond2013_OnlyEtaInt \ +{ + # Load default Moriond 2013 release + Moriond2013 + # Override variables + outFile="JetUncertainties-Moriond2013-OnlyEtaInt.pdf" + compList="EtaIntercalibration_#;EtaIntercalibration_Modelling;EtaIntercalibration_StatAndMethod" + compLabels="#eta-intercalibration, total (all components);#eta-intercalibration, modelling;#eta-intercalibration, statistics" +} + +function Moriond2013_OnlyPileup \ +{ + # Load default Moriond 2013 release + Moriond2013 + # Override variables + outFile="JetUncertainties-Moriond2013-OnlyPileup.pdf" + compList="Pileup_#;Pileup_OffsetMu;Pileup_OffsetNPV;Pileup_PtTerm;Pileup_RhoTopology" + compLabels="Pileup, total (all components);Pileup, <#mu> offset;Pileup, NPV offset;Pileup, #it{p}_{T} bias;Pileup, #rho topology" +} + +function Moriond2013_OnlyFlavour \ +{ + # Load default Moriond 2013 release + Moriond2013 + # Override variables + outFile="JetUncertainties-Moriond2013-OnlyFlavour.pdf" + compList="Flavor_#;Flavor_Comp#;Flavor_Resp#" + compLabels="Flavour, total (all components);Flavour composition;Flavour response" +} + + +function LargeR_July2014 \ +{ + # July 2014 large-R jet release + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR30" + MCtype="MC12a" + configFile="UJ_2012/JMS2012_Jul242014_Combined.config" + outFile="JetUncertainties-LargeR-July2014.pdf" + compList="Gjet_#;DoubleRatio#;Topology;Pileup#" + compLabels="#splitline{In-situ gamma+jet}{#scale[0.75]{valid up to 1000 GeV}};#splitline{Track/Calo Data/MC double ratio}{#scale[0.75]{used in the combination from 900 GeV}};MC topology;Pile-up uncertainty (#mu = 20)" + options="isDijet=true;isLargeR=true;prefix=JET_" +} + + +function Final2012_unknown \ +{ + # Final 2012 release, nominal + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo;AntiKt6EMTopo;AntiKt6LCTopo" + MCtype="MC12" + configFile="JES_2012/Final/InsituJES2012_AllNuisanceParameters.config" + outFile="JetUncertainties-Final2012-Unknown-Nominal.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup, average 2012 conditions;Punch-through, average 2012 conditions" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function Final2012_dijet \ +{ + # Final 2012 release, nominal + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo;AntiKt6EMTopo;AntiKt6LCTopo" + MCtype="MC12" + configFile="JES_2012/Final/InsituJES2012_AllNuisanceParameters.config" + outFile="JetUncertainties-Final2012-Dijet-Nominal.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup, average 2012 conditions;Punch-through, average 2012 conditions" + options="isDijet=false;isLargeR=false;prefix=JET_;" +} + +function Final2012_unknown_log \ +{ + # Final 2012 release, nominal + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo;AntiKt6EMTopo;AntiKt6LCTopo" + MCtype="MC12" + configFile="JES_2012/Final/InsituJES2012_AllNuisanceParameters.config" + outFile="JetUncertainties-Final2012-Unknown-log-Nominal.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup, average 2012 conditions;Punch-through, average 2012 conditions" + options="isDijet=false;isLargeR=false;prefix=JET_;doLogY=true" +} + +function Final2012_dijet_log \ +{ + # Final 2012 release, nominal + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo;AntiKt6EMTopo;AntiKt6LCTopo" + MCtype="MC12" + configFile="JES_2012/Final/InsituJES2012_AllNuisanceParameters.config" + outFile="JetUncertainties-Final2012-Dijet-log-Nominal.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup, average 2012 conditions;Punch-through, average 2012 conditions" + options="isDijet=true;isLargeR=false;prefix=JET_;doLogY=true" +} + +function CompareAll2012 \ +{ + + # Load default Prerec 2015 release + Final2012 + # Override variables + outFile="JetUncertainties-CompareAll2012.pdf" + options="isDijet=false;isLargeR=false;prefix=JET_;compareOnly=true;compareConfig1=JES_2012/HCP2012/JESUncertainty2012_Sept2012.config&MC12a&HCP 2012;compareConfig2=JES_2012/Moriond2013/InsituJES2012_AllNuisanceParameters.config&MC12a&Moriond 2013;compareConfig3=JES_2012/Final/InsituJES2012_AllNuisanceParameters.config&MC12&Final 2012" + +} + + +function Final2012_AFII \ +{ + # Final 2012 release, nominal + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo;AntiKt6EMTopo;AntiKt6LCTopo" + MCtype="AFII" + configFile="JES_2012/Final/InsituJES2012_AllNuisanceParameters.config" + outFile="JetUncertainties-Final2012-AFII-Nominal.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;RelativeNonClosure_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup, average 2012 conditions;MC nonclosure, fast simulation" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function Final2012_Stronger \ +{ + # Final 2012 release, stronger correlations + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo;AntiKt6EMTopo;AntiKt6LCTopo" + MCtype="MC12" + configFile="JES_2012/Final/InsituJES2012_StrongerCorrelations.config" + outFile="JetUncertainties-Final2012-Stronger.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#,Correlated_#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup, average 2012 conditions;Punch-through, average 2012 conditions" + options="isDijet=true;isLargeR=false;prefix=JET_" +} + +function Final2012_Weaker \ +{ + # Final 2012 release, weaker correlations + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo;AntiKt6EMTopo;AntiKt6LCTopo" + MCtype="MC12" + configFile="JES_2012/Final/InsituJES2012_WeakerCorrelations.config" + outFile="JetUncertainties-Final2012-Weaker.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup, average 2012 conditions;Punch-through, average 2012 conditions" + options="isDijet=true;isLargeR=false;prefix=JET_" +} + +function Final2012_OnlyLAr \ +{ + # Load default Final 2012 release + Final2012 + # Override variables + outFile="JetUncertainties-Final2012-OnlyLAr.pdf" + compList="LAr_#;LAr_ESmaterial;LAr_ESpresampler;LAr_ESZee;LAr_Esmear" + compLabels="e/#gamma, total (all components);e/#gamma energy scale, material;e/#gamma energy scale, presampler;e/#gamma energy scale, Zee;e/#gamma energy smearing" +} + +function Final2012_OnlyZjet \ +{ + # Load default Final 2012 release + Final2012 + # Override variables + outFile="JetUncertainties-Final2012-OnlyZjet.pdf" + compList="Zjet_#;Zjet_dPhi;Zjet_MC;Zjet_MuScale;Zjet_MuSmearID;Zjet_MuSmearMS;Zjet_JVF;Zjet_KTerm;Zjet_Veto;Zjet_Stat#" + compLabels="Z+jet, total (all components);Z+jet, extrapolation;Z+jet, MC generator;Z+jet, #mu scale;Z+jet, #mu smearing (ID);Z+jet, #mu smearing (MS);Z+jet, pileup rejection;Z+jet, out-of-cone;Z+jet, radiation suppression;Z+jet, combined statistics (x11)" +} + +function Final2012_OnlyGjet \ +{ + # Load default Final 2012 release + Final2012 + # Override variables + outFile="JetUncertainties-Final2012-OnlyGjet.pdf" + compList="Gjet_#;Gjet_dPhi;Gjet_Generator;Gjet_OOC;Gjet_Purity;Gjet_Veto;Gjet_Stat#" + compLabels="#gamma+jet, total (all components);#gamma+jet, extrapolation;#gamma+jet, MC generator;#gamma+jet, out-of-cone;#gamma+jet, photon purity;#gamma+jet, radiation suppression; #gamma+jet, combined statistics (x13)" +} + +function Final2012_OnlyMJB \ +{ + # Load default Final 2012 release + Final2012 + # Override variables + outFile="JetUncertainties-Final2012-OnlyMJB.pdf" + compList="MJB_#;MJB_Alpha;MJB_Beta;MJB_Fragmentation;MJB_Asym;MJB_Threshold;MJB_Stat#" + compLabels="MJB, total (all components);MJB, #alpha selection;MJB, #beta selection;MJB, fragmentation;MJB, #it{p}_{T} asymmetry;MJB, #it{p}_{T} threshold;MJB, combined statistics (x10)" +} + +function Final2012_OnlyEtaInt \ +{ + # Load default Final 2012 release + Final2012 + # Override variables + outFile="JetUncertainties-Final2012-OnlyEtaInt.pdf" + compList="EtaIntercalibration_#;EtaIntercalibration_Modelling;EtaIntercalibration_TotalStat" + compLabels="#eta-intercalibration, total (all components);#eta-intercalibration, modelling;#eta-intercalibration, statistics" +} + +function Final2012_OnlyPileup \ +{ + # Load default Final 2012 release + Final2012_unknown + # Override variables + outFile="JetUncertainties-Final2012-OnlyPileup.pdf" + compList="Pileup_#;Pileup_OffsetMu;Pileup_OffsetNPV;Pileup_PtTerm;Pileup_RhoTopology" + compLabels="Pileup, total (all components);Pileup, <#mu> offset;Pileup, NPV offset;Pileup, #it{p}_{T} bias;Pileup, #rho topology" +} + +function Final2012_OnlyFlavour \ +{ + # Load default Final 2012 release + Final2012 + # Override variables + outFile="JetUncertainties-Final2012-OnlyFlavour.pdf" + compList="Flavor_#;Flavor_Comp#;Flavor_Resp#" + compLabels="Flavour, total (all components);Flavour composition;Flavour response" +} + +# For Dimitris Varouchas Dec 11 2014 +function Final2012_FHttbar \ +{ + jetDefinition="AntiKt4LCTopo" + MCtype="MC12" + configFile="JES_2012/Final/InsituJES2012_23NP_ByCategory.config" + outFile="JetUncertainties-Final2012-FHttbar.pdf" + compList="EffectiveNP_Modelling1;Pileup_RhoTopology;EffectiveNP_Modelling1,Pileup_RhoTopology;Effective#,Pileup#,SingleParticle#,EtaIntercalib#" + compLabels="Modelling1;Pileup, #rho topology;Modelling1 #oplus #rho topology;All except flavour" + options="isDijet=true;isLargeR=false;prefix=JET_" +} + +function Final2012_3NP_Scenario1_Dijet \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC12" + configFile="JES_2012/Final/InsituJES2012_3NP_Scenario1.config" + outFile="JetUncertainties-Final2012-3NP-Scenario1-Dijet.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3" + options="isDijet=true;isLargeR=false;prefix=JET_" +} + +function Final2012_3NP_Scenario1_Unknown \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC12" + configFile="JES_2012/Final/InsituJES2012_3NP_Scenario1.config" + outFile="JetUncertainties-Final2012-3NP-Scenario1-Unknown.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function Final2012_3NP_Scenario1 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC12" + configFile="JES_2012/Final/InsituJES2012_3NP_Scenario1.config" + outFile="JetUncertainties-Final2012-3NP-Scenario1.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function Final2012_3NP_Scenario2 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC12" + configFile="JES_2012/Final/InsituJES2012_3NP_Scenario2.config" + outFile="JetUncertainties-Final2012-3NP-Scenario2.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function Final2012_3NP_Scenario3 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC12" + configFile="JES_2012/Final/InsituJES2012_3NP_Scenario3.config" + outFile="JetUncertainties-Final2012-3NP-Scenario3.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function Final2012_3NP_Scenario4 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC12" + configFile="JES_2012/Final/InsituJES2012_3NP_Scenario4.config" + outFile="JetUncertainties-Final2012-3NP-Scenario4.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function TestConfig \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC12" + configFile="JES_2012/Final/test.config" + outFile="JetUncertainties-SplitTest.pdf" + compList="EtaIntercalibration_#;#_T1F;#_T1C" + compLabels="#eta intercalibration, f_{1}^{#it{p}_{T}} #oplus f_{2}^{#it{p}_{T}};#eta intercalibration, f_{1}^{#it{p}_{T}};#eta intercalibration, f_{2}^{#it{p}_{T}}" + #compList="EtaIntercalibration_#;#_T2F;#_T2C" + #compLabels="#eta intercalibration, f_{1}^{#eta} #oplus f_{2}^{#eta};#eta intercalibration, f_{1}^{#eta};#eta intercalibration, f_{2}^{#eta}" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function TestATLASCMS \ +{ + + jetDefinition="AntiKt4LCTopo" #;AntiKt4LCTopo" + MCtype="MC12" + configFile="JES_2012/Final/CMS/FlavourTestGluon.config" + outFile="ATLAS-CMS-Flavour-Gluon.pdf" + #compList="FlavorResponse;gJES_CMS;bJES;bJES_HadIntModel;bJES_CMS" + #compLabels="ATLAS gluon-jet PYTHIA8-Herwig++;#splitline{CMS#kern[2.5]{g}luon-jet PYTHIA6-Herwig++}{};ATLAS b-jet PYTHIA8-Herwig++;ATLAS b-jet hadronic interaction model;CMS#kern[2.3]{b}-jet hadronic interaction model" + #compList="FlavorResponse;gJES_CMS;bJES;bJES_CMS" + #compLabels="ATLAS gluon-jet PYTHIA8-Herwig++;#splitline{CMS#kern[2.5]{g}luon-jet PYTHIA6-Herwig++}{};ATLAS b-jet PYTHIA8-Herwig++;CMS#kern[2.3]{b}-jet hadronic interaction model" + compList="Flavor_Response;Flavor_CMS" + compLabels="ATLAS gluon-jet uncertainty;CMS #kern[2.1]{ }gluon-jet uncertainty" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=false;DoATLASLabel=true" +} + +function Final2012_Pileup \ +{ + # Final 2012 release, nominal + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo;AntiKt6EMTopo;AntiKt6LCTopo" + MCtype="MC12" + configFile="JES_2012/Final/TestPileup.config" + outFile="JetUncertainties-Final2012-Nominal-Pileup.pdf" + + #compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + #compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup, average 2012 conditions;Punch-through, average 2012 conditions" + #options="isDijet=true;isLargeR=false;prefix=JET_;isEtaDepPileup=true;isPublic=true" + + compList="Pileup_OffsetMu;Pileup_OffsetNPV;Pileup_PtTerm;Pileup_RhoTopology" + compLabels="Pileup #mu;Pileup NPV;Pileup p_{T};Pileup #rho" + options="isDijet=true;isLargeR=false;prefix=JET_;isEtaDepPileup=true;isPublic=false" +} + +function Prerec2015 \ +{ + + # Final 2012 release, nominal + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/Prerec/InsituJES2015_AllNuisanceParameters.config" + outFile="JetUncertainties-Prerec2015-Nominal.pdf" + + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#;Xcalib_#" + compLabels="Absolute #it{in situ} JES (2012);Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup, predicted 2015 conditions;Punch-through, predicted 2015 conditions; 2012 to 2015 extrapolation uncertainty" + +# compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" +# compLabels="Absolute #it{in situ} JES (2012);Relative #it{in situ} JES (scaled 2012);Flav. composition;Flav. response;Pileup, predicted 2015 conditions;Punch-through, predicted 2015 conditions;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_" +} + +# Unknown composition + +function Prerec2015_50ns_Unknown \ +{ + + # Load default Prerec 2015 release + Prerec2015 + # Override variables + configFile="JES_2015/Prerec/PrerecJES2015_AllNuisanceParameters_50ns.config" + outFile="JetUncertainties-Prerec2015-50ns-Unknown-Nominal.pdf" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;bunchSpacing=50" + +} + +function Prerec2015_50ns_AFII_Unknown \ +{ + + # Load default Prerec 2015 release + Prerec2015 + # Override variables + MCtype="AFII" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;Xcalib_#;RelativeNonClosure_#" + compLabels="Absolute #it{in situ} JES (2012);Relative #it{in situ} JES (scaled 2012);Flav. composition;Flav. response;Pileup, predicted 2015 conditions;2012 to 2015 extrapolation uncertainty;MC nonclosure, fast simulation" + configFile="JES_2015/Prerec/PrerecJES2015_AllNuisanceParameters_50ns.config" + outFile="JetUncertainties-Prerec2015-50ns-Unknown-AFII.pdf" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;bunchSpacing=50" + +} + +function Prerec2015_50ns_Unknown_Compare \ +{ + + # Load default Prerec 2015 release + Prerec2015 + # Override variables + configFile="JES_2015/Prerec/PrerecJES2015_AllNuisanceParameters_50ns.config" + outFile="JetUncertainties-Prerec2015-50ns-Unknown-Nominal-CompareTo2012.pdf" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;bunchSpacing=50;doCompare=JES_2012/Final/InsituJES2012_AllNuisanceParameters.config&MC12&Total uncertainty, 2012" + +} + +function Prerec2015_50ns_Unknown_OnlyFlavour \ +{ + + # Load default Prerec 2015 release + Prerec2015_50ns_Unknown + outFile="JetUncertainties-Prerec2015-50ns-Unknown-OnlyFlavour.pdf" + compList="Flavor_#;Flavor_Comp#;Flavor_Resp#" + compLabels="Flavour, total (all components);Flavour composition;Flavour response" + +} + +function Prerec2015_50ns_Unknown_OnlyXcalib \ +{ + + # Load default Prerec 2015 release + Prerec2015_50ns_Unknown + outFile="JetUncertainties-Prerec2015-50ns-Unknown-OnlyXcalib.pdf" + compList="Xcalib_#;Xcalib_1#;Xcalib_2#;Xcalib_3#;Xcalib_4#;Xcalib_5#;Xcalib_6#" + compLabels="2012 to 2015 extrapolation, total;Bunch spacing;Digitization;Topoclustering;Early data term;Noise threshold;Underlying event" + +} + +function Prerec2015_50ns_Unknown_OnlyPileup \ +{ + # Load default Prerec 2015 release + Prerec2015_50ns_Unknown + # Override variables + outFile="JetUncertainties-Prerec2015-50ns-Unknown-OnlyPileup.pdf" + compList="Pileup_#;Pileup_OffsetMu;Pileup_OffsetNPV;Pileup_PtTerm;Pileup_RhoTopology" + compLabels="Pileup, total (all components);Pileup, <#mu> offset;Pileup, NPV offset;Pileup, #it{p}_{T} bias;Pileup, #rho topology" +} + + +function Prerec2015_25ns_Unknown \ +{ + + # Load default Prerec 2015 release + Prerec2015 + # Override variables + configFile="JES_2015/Prerec/PrerecJES2015_AllNuisanceParameters_25ns.config" + outFile="JetUncertainties-Prerec2015-25ns-Unknown-Nominal.pdf" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;bunchSpacing=25" + +} + +function Prerec2015_25ns_AFII_Unknown \ +{ + + # Load default Prerec 2015 release + Prerec2015 + # Override variables + MCtype="AFII" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;Xcalib_#;RelativeNonClosure_#" + compLabels="Absolute #it{in situ} JES (2012);Relative #it{in situ} JES (scaled 2012);Flav. composition;Flav. response;Pileup, predicted 2015 conditions;2012 to 2015 extrapolation uncertainty;MC nonclosure, fast simulation" + configFile="JES_2015/Prerec/PrerecJES2015_AllNuisanceParameters_25ns.config" + outFile="JetUncertainties-Prerec2015-25ns-Unknown-AFII.pdf" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;bunchSpacing=25" + +} + + +function Prerec2015_25ns_Unknown_Compare \ +{ + + # Load default Prerec 2015 release + Prerec2015 + # Override variables + configFile="JES_2015/Prerec/PrerecJES2015_AllNuisanceParameters_25ns.config" + outFile="JetUncertainties-Prerec2015-25ns-Unknown-Nominal-CompareTo2012.pdf" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;bunchSpacing=25;doCompare=JES_2012/Final/InsituJES2012_AllNuisanceParameters.config&MC12&Total uncertainty, 2012" + +} + + + +function Prerec2015_25ns_Unknown_OnlyFlavour \ +{ + + # Load default Prerec 2015 release + Prerec2015_25ns_Unknown + outFile="JetUncertainties-Prerec2015-25ns-Unknown-OnlyFlavour.pdf" + compList="Flavor_#;Flavor_Comp#;Flavor_Resp#" + compLabels="Flavour, total (all components);Flavour composition;Flavour response" + +} + +function Prerec2015_25ns_Unknown_OnlyXcalib \ +{ + + # Load default Prerec 2015 release + Prerec2015_25ns_Unknown + outFile="JetUncertainties-Prerec2015-25ns-Unknown-OnlyXcalib.pdf" + compList="Xcalib_#;Xcalib_1#;Xcalib_2#;Xcalib_3#;Xcalib_4#;Xcalib_5#;Xcalib_6#" + compLabels="2012 to 2015 extrapolation, total;Bunch spacing;Digitization;Topoclustering;Early data term;Noise threshold;Underlying event" + +} + +function Prerec2015_25ns_Unknown_OnlyPileup \ +{ + # Load default Prerec 2015 release + Prerec2015_25ns_Unknown + # Override variables + outFile="JetUncertainties-Prerec2015-25ns-Unknown-OnlyPileup.pdf" + compList="Pileup_#;Pileup_OffsetMu;Pileup_OffsetNPV;Pileup_PtTerm;Pileup_RhoTopology" + compLabels="Pileup, total (all components);Pileup, <#mu> offset;Pileup, NPV offset;Pileup, #it{p}_{T} bias;Pileup, #rho topology" + +} + +# Dijet composition + +function Prerec2015_50ns_Dijet \ +{ + + # Load default Prerec 2015 release + Prerec2015 + # Override variables + configFile="JES_2015/Prerec/PrerecJES2015_AllNuisanceParameters_50ns.config" + outFile="JetUncertainties-Prerec2015-50ns-Dijet-Nominal.pdf" + options="isDijet=true;isGSC=true;isLargeR=false;prefix=JET_" + +} + +function Prerec2015_50ns_Dijet_OnlyFlavour \ +{ + + # Load default Prerec 2015 release + Prerec2015_50ns_Dijet + outFile="JetUncertainties-Prerec2015-50ns-Dijet-OnlyFlavour.pdf" + compList="Flavor_#;Flavor_Comp#;Flavor_Resp#" + compLabels="Flavour, total (all components);Flavour composition;Flavour response" + +} + +function Prerec2015_50ns_Dijet_OnlyXcalib \ +{ + + # Load default Prerec 2015 release + Prerec2015_50ns_Dijet + outFile="JetUncertainties-Prerec2015-50ns-Dijet-OnlyXcalib.pdf" + compList="Xcalib_#;Xcalib_1#;Xcalib_2#;Xcalib_3#;Xcalib_4#;Xcalib_5#;Xcalib_6#" + compLabels="2012 to 2015 extrapolation, total;Bunch spacing;Digitization;Topoclustering;Early data term;Noise threshold;Underlying event" + +} + +function Prerec2015_25ns_Dijet \ +{ + + # Load default Prerec 2015 release + Prerec2015 + # Override variables + configFile="JES_2015/Prerec/PrerecJES2015_AllNuisanceParameters_25ns.config" + outFile="JetUncertainties-Prerec2015-25ns-Dijet-Nominal.pdf" + options="isDijet=true;isGSC=true;isLargeR=false;prefix=JET_" + +} + +function Prerec2015_25ns_Dijet_OnlyFlavour \ +{ + + # Load default Prerec 2015 release + Prerec2015_25ns_Dijet + outFile="JetUncertainties-Prerec2015-25ns-Dijet-OnlyFlavour.pdf" + compList="Flavor_#;Flavor_Comp#;Flavor_Resp#" + compLabels="Flavour, total (all components);Flavour composition;Flavour response" + +} + +function Prerec2015_25ns_Dijet_OnlyXcalib \ +{ + + # Load default Prerec 2015 release + Prerec2015_25ns_Dijet + outFile="JetUncertainties-Prerec2015-25ns-Dijet-OnlyXcalib.pdf" + compList="Xcalib_#;Xcalib_1#;Xcalib_2#;Xcalib_3#;Xcalib_4#;Xcalib_5#;Xcalib_6#" + compLabels="2012 to 2015 extrapolation, total;Bunch spacing;Digitization;Topoclustering;Early data term;Noise threshold;Underlying event" + +} + +####################################### + +function Moriond2016 \ +{ + + # Final 2012 release, nominal + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/Moriond2016/JES2015_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2016-Nominal.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_" +} + +function Moriond2016_CompareToPrerec \ +{ + # Load default Moriond 2016 release + Moriond2016 + # Override variables + options="${options};doCompare=JES_2015/Prerec/PrerecJES2015_AllNuisanceParameters_25ns.config&MC15&Preliminary uncertainty" +} + +function Moriond2016_Public \ +{ + Moriond2016 + outFile="${outFile/Nominal/Nominal-Public}" + options="${options};isPublic=True;ATLASLabel=Internal;Interp=True" + compLabels="${compLabels/Pileup/Pile-up, average 2015 conditions}" + compLabels="${compLabels/Punch-through/Punch-through, average 2015 conditions}" +} + +function Moriond2016_Public_Dijet \ +{ + Moriond2016_Public + outFile="${outFile/Public/Public-dijet}" + options="${options/isDijet=false/isDijet=true}" +} + +function Moriond2016_Public_Compare \ +{ + Moriond2016_Public + outFile="${outFile/Public/Compare-Public}" + options="${options};doCompare=JES_2015/Prerec/PrerecJES2015_AllNuisanceParameters_25ns.config&MC15&Preliminary uncertainty" +} + +function Moriond2016_Public_Dijet_Compare \ +{ + Moriond2016_Public_Dijet + outFile="${outFile/Public/Compare-Public}" + options="${options};doCompare=JES_2015/Prerec/PrerecJES2015_AllNuisanceParameters_25ns.config&MC15&Preliminary uncertainty" +} + +# Unknown composition + +function Moriond2016_Unknown \ +{ + + # Load default Moriond 2016 release + Moriond2016 + # Override variables + outFile="JetUncertainties-Moriond2016-Unknown-Nominal.pdf" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;" + +} + +function Moriond2016_AFII_Unknown \ +{ + + # Load default Prerec 2015 release + Moriond2016 + # Override variables + MCtype="AFII" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;RelativeNonClosure_#" + compLabels="Absolute #it{in situ} JES (2012);Relative #it{in situ} JES (scaled 2012);Flav. composition;Flav. response;Pileup, predicted 2015 conditions;MC nonclosure, fast simulation" + outFile="JetUncertainties-Prerec2015-25ns-Unknown-AFII.pdf" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;bunchSpacing=25" + +} + +# For comparison to result without propagated through uncertainties +function Moriond2016_Unknown_NoMJBProp \ +{ + + # Load default Moriond 2016 release + Moriond2016 + # Override variables + configFile="JES_2015/Moriond2016/JES2015_WithoutPropagatedPars.config" + outFile="JetUncertainties-Moriond2016-Unknown-Nominal-NoMJBPropagatedUncertainties.pdf" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;" + +} + + +####################################### Moriond 2016 Specialty + +function Moriond2016_OnlyEtaInt \ +{ + # Load default Moriond 2016 release + Moriond2016 + # Override variables + outFile="JetUncertainties-Moriond2016-Unknown-OnlyEtaInt.pdf" + compList="EtaIntercalibration_#;EtaIntercalibration_Modelling;EtaIntercalibration_TotalStat;EtaIntercalibration_NonClosure" + compLabels="#eta-intercalibration, total (all components);#eta-intercalibration, modelling;#eta-intercalibration, statistics;#eta-intercalibration, non-closure" +} + +function Moriond2016_OnlyPileup \ +{ + # Load default Prerec 2015 release + Moriond2016 + # Override variables + outFile="JetUncertainties-Moriond2016-Unknown-OnlyPileup.pdf" + compList="Pileup_#;Pileup_OffsetMu;Pileup_OffsetNPV;Pileup_PtTerm;Pileup_RhoTopology" + compLabels="Pileup, total (all components);Pileup, <#mu> offset;Pileup, NPV offset;Pileup, #it{p}_{T} bias;Pileup, #rho topology" + +} + +####################################### Moriond 2016 Reductions + +function Moriond2016_GlobalReductions \ +{ + # Load default Moriond 2016 release + Moriond2016 + # Override variables + configFile="JES_2015/Moriond2016/JES2015_19NP.config" + outFile="JetUncertainties-Moriond2016-Unknown-GlobalReduction.pdf" + compList="EffectiveNP#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;" + +} + +function Moriond2016_CategoryReductions \ +{ + # Load default Moriond 2016 release + Moriond2016 + # Override variables + configFile="JES_2015/Moriond2016/JES2015_25NP_ByCategory.config" + outFile="JetUncertainties-Moriond2016-Unknown-CategoryReduction.pdf" + compList="EffectiveNP#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;" + +} + +####################################### Moriond 2016 Reductions Specialty + +function Moriond2016_GlobalReductions_Alone \ +{ + # Load default Moriond 2016 release + Moriond2016 + # Override variables + configFile="JES_2015/Moriond2016/JES2015_19NP.config" + outFile="JetUncertainties-Moriond2016-Unknown-GlobalReduction-Alone.pdf" + compList="EffectiveNP#,SingleParticle#;EffectiveNP_1;EffectiveNP_2;EffectiveNP_3;EffectiveNP_4;EffectiveNP_5;EffectiveNP_6restTerm;SingleParticle#" + compLabels="In situ total;First global parameter;Second global parameter;Third global parameter;Fourth global parameter;Fifth global parameter;Remainder parameter;High-pT term" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;" + +} + +function Moriond2016_CategoryReductions_Alone \ +{ + # Load default Moriond 2016 release + Moriond2016 + # Override variables + configFile="JES_2015/Moriond2016/JES2015_25NP_ByCategory.config" + outFile="JetUncertainties-Moriond2016-Unknown-CategoryReduction-Alone.pdf" + compList="EffectiveNP#,SingleParticle#;EffectiveNP_Statistical#;EffectiveNP_Modelling#;EffectiveNP_Detector#;EffectiveNP_Mixed#;SingleParticle#" + compLabels="In situ total;Statistical terms;Modelling terms;Detector terms;Mixed terms;High-pT term" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;" + +} + +####################################### + +function ICHEP2016 \ +{ + + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo" + MCtype="MC15" + configFile="JES_2015/ICHEP2016/JES2015_AllNuisanceParameters.config" + outFile="JetUncertainties-ICHEP2016-Nominal.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_" +} + +function ICHEP2016_CompareToMoriond \ +{ + # Load default Ichep 2016 release + ICHEP2016 + # Override variables + outFile="JetUncertainties-ICHEP2016-Nominal-CompareToMoriond.pdf" + options="${options};doCompare=JES_2015/Moriond2016/JES2015_AllNuisanceParameters.config&MC15&Moriond uncertainty" +} + +function ICHEP2016_Public \ +{ + ICHEP2016 + outFile="${outFile/Nominal/Nominal-Public}" + options="${options};isPublic=True;ATLASLabel=Preliminary;Interp=True" + compLabels="${compLabels/Pileup/Pileup, average 2015 conditions}" + compLabels="${compLabels/Punch-through/Punch-through, average 2015 conditions}" +} + +function ICHEP2016_OnlyPileup \ +{ + # Load default Prerec 2015 release + ICHEP2016 + # Override variables + outFile="JetUncertainties-ICHEP2016-Unknown-OnlyPileup.pdf" + compList="Pileup_#;Pileup_OffsetMu;Pileup_OffsetNPV;Pileup_PtTerm;Pileup_RhoTopology" + compLabels="Pileup, total (all components);Pileup, <#mu> offset;Pileup, NPV offset;Pileup, #it{p}_{T} bias;Pileup, #rho topology" + +} + +####################################### + +function PreMoriond2017_forMJB \ +{ + + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017/JESNuisanceParametersForMJB.config" + outFile="JetUncertainties-IntoMJB_PreMoriond2017.pdf" + + compList="Zjet#,Gjet#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#;" + compLabels="Absolute #it{in situ} JES (Z,#gamma+jet);Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;bunchSpacing=25" + +} + +function Moriond2017 \ +{ + + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017/JES2016_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2017-Nominal.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_" + #options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/\";fixedEtaVals=0;fixedPtVals=NONE" +} + +function Moriond2017_Public \ +{ + Moriond2017 + outFile="${outFile/Nominal/Nominal-Public}" + options="${options};isPublic=True;ATLASLabel=Preliminary;Interp=True;fixedPtVals=25,40,60,80,100,120;" + compLabels="${compLabels/Pileup/Pileup, average 2016 conditions}" + compLabels="${compLabels/Punch-through/Punch-through, average 2016 conditions}" +} + +function Moriond2017_Public_Dijet \ +{ + Moriond2017 + outFile="${outFile/Nominal/Nominal-Public-Dijet}" + options="isDijet=true;isGSC=true;isLargeR=false;prefix=JET_;isPublic=True;ATLASLabel=Preliminary;Interp=True;fixedPtVals=25,40,60,80,100,120;" + compLabels="${compLabels/Pileup/Pileup, average 2016 conditions}" + compLabels="${compLabels/Punch-through/Punch-through, average 2016 conditions}" +} + +function Moriond2017_OFCsOnly \ +{ + + # Load default Ichep 2016 release + Moriond2017 + # Override config + outFile="JetUncertainties-Moriond2017-Nominal-OnlyOFCs.pdf" + configFile="JES_2016/Moriond2017/JES2016_AllNuisanceParameters_OFCs.config" + +} + +function Moriond2017_CompareToICHEP \ +{ + # Load default Ichep 2016 release + Moriond2017 + # Override variables + outFile="JetUncertainties-Moriond2017-Nominal-CompareToICHEP2016.pdf" + options="${options};doCompare=JES_2015/ICHEP2016/JES2015_AllNuisanceParameters.config&MC15&ICHEP uncertainty" +} + +function Moriond2017_CompareToICHEP_Dijet \ +{ + # Load default Ichep 2016 release + Moriond2017 + # Override variables + outFile="JetUncertainties-Moriond2017-Nominal-Dijet-CompareToICHEP2016.pdf" + options="isDijet=true;isGSC=true;isLargeR=false;prefix=JET_;doCompare=JES_2015/ICHEP2016/JES2015_AllNuisanceParameters.config&MC15&ICHEP uncertainty" +} + +function Moriond2017_OnlyPileup \ +{ + # Load default Prerec 2015 release + Moriond2017 + # Override variables + outFile="JetUncertainties-Moriond2017-OnlyPileup.pdf" + compList="Pileup_#;Pileup_OffsetMu;Pileup_OffsetNPV;Pileup_PtTerm;Pileup_RhoTopology" + compLabels="Pileup, total (all components);Pileup, <#mu> offset;Pileup, NPV offset;Pileup, #it{p}_{T} bias;Pileup, #rho topology" + +} + +function Moriond2017_OnlyFlavour \ +{ + # Load default Moriond 2013 release + Moriond2017 + # Override variables + outFile="JetUncertainties-Moriond2017-OnlyFlavour.pdf" + compList="Flavor_#;Flavor_Comp#;Flavor_Resp#" + compLabels="Flavour, total (all components);Flavour composition;Flavour response" +} + +function Moriond2017_GlobalReductions \ +{ + # Load default Moriond 2016 release + Moriond2017 + # Override variables + configFile="JES_2016/Moriond2017/JES2016_21NP.config" + outFile="JetUncertainties-Moriond2017-Unknown-GlobalReduction.pdf" + compList="EffectiveNP#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;" + +} + +function Moriond2017_CategoryReductions \ +{ + # Load default Moriond 2016 release + Moriond2017 + # Override variables + configFile="JES_2016/Moriond2017/JES2016_29NP_ByCategory.config" + outFile="JetUncertainties-Moriond2017-Unknown-CategoryReduction.pdf" + compList="EffectiveNP#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;" + +} + +function Moriond2017_SR1 \ +{ + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017/JES2016_SR_Scenario1_forplotting.config" + outFile="JetUncertainties-Moriond2017-3NP-Scenario1_test.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3;EtaIntercalibration_NonClosure" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3;#eta-intercalibration nonclosure" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function Moriond2017_SR1_NP3Only_Dijet \ +{ + # Load default Moriond 2016 release + Moriond2017 + # Override variables + configFile="JES_2016/Moriond2017/JES2016_21NP.config" + outFile="JetUncertainties-Moriond2017-Dijet-NP3Only.pdf" + compList="SingleParticle#;EtaIntercalibration_Modelling;PunchThrough_#" + compLabels="Single particle; #eta-intercalibration modelling;Punch through" + options="isDijet=true;isGSC=true;isLargeR=false;prefix=JET_;" + +} + +function Moriond2017_SR2 \ +{ + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017/JES2016_SR_Scenario2_forplotting.config" + outFile="JetUncertainties-Moriond2017-3NP-Scenario2_test.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3;EtaIntercalibration_NonClosure" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3;#eta-intercalibration nonclosure" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function Moriond2017_SR3 \ +{ + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017/JES2016_SR_Scenario3_forplotting.config" + outFile="JetUncertainties-Moriond2017-3NP-Scenario3_test.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3;EtaIntercalibration_NonClosure" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3;#eta-intercalibration nonclosure" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function Moriond2017_SR4 \ +{ + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017/JES2016_SR_Scenario4_forplotting.config" + outFile="JetUncertainties-Moriond2017-3NP-Scenario4_test.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3;EtaIntercalibration_NonClosure" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3;#eta-intercalibration nonclosure" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function Moriond2017_SpecialRequest_Top \ +{ + Moriond2017 + jetDefinition="AntiKt4EMTopo" + outFile="${outFile/Nominal/Nominal-TTbar}" + options="isReginas=true;isGSC=true;isLargeR=false;prefix=JET_;isPublic=True;ATLASLabel=Preliminary;Interp=True;fixedPtVals=25,40,60,80,100,120;" + compLabels="${compLabels/Pileup/Pileup, average 2016 conditions}" + compLabels="${compLabels/Punch-through/Punch-through, average 2016 conditions}" + +} + + +####################################### + +function Moriond2017_PFlow \ +{ + + jetDefinition="AntiKt4EMPFlow" + MCtype="MC15" + configFile="JES_2016/PFlow2017/JES2016_AllNuisanceParameters.config" + outFile="JetUncertainties-PFlow2017-Nominal.pdf" + compList="LAr#,Zjet#,Gjet#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_" +} + +function Moriond2017_PFlow_Public \ +{ + Moriond2017_PFlow + outFile="${outFile/Nominal/Nominal-Public}" + options="${options};isPublic=True;ATLASLabel=Preliminary;Interp=True;fixedPtVals=25,40,60,80,100,120;" + compLabels="${compLabels/Pileup/Pileup, average 2016 conditions}" + compLabels="${compLabels/Punch-through/Punch-through, average 2016 conditions}" +} + +function Moriond2017_PFlow_Dijet_Public \ +{ + Moriond2017_PFlow + outFile="${outFile/Nominal/Dijet-Public}" + options="isDijet=true;isGSC=true;isLargeR=false;prefix=JET_;isPublic=True;ATLASLabel=Preliminary;Interp=True;fixedPtVals=25,40,60,80,100,120;" + compLabels="${compLabels/Pileup/Pileup, average 2016 conditions}" + compLabels="${compLabels/Punch-through/Punch-through, average 2016 conditions}" +} + +####################################### + + +function ICHEP2016_CompareToMoriond \ +{ + # Load default Ichep 2016 release + ICHEP2016 + # Override variables + outFile="JetUncertainties-ICHEP2016-Nominal-CompareToMoriond.pdf" + options="${options};doCompare=JES_2015/Moriond2016/JES2015_AllNuisanceParameters.config&MC15&Moriond uncertainty" +} + +function ICHEP2016_Public \ +{ + ICHEP2016 + outFile="${outFile/Nominal/Nominal-Public}" + options="${options};isPublic=True;ATLASLabel=Preliminary;Interp=True" + compLabels="${compLabels/Pileup/Pileup, average 2015 conditions}" + compLabels="${compLabels/Punch-through/Punch-through, average 2015 conditions}" +} + +function Moriond2017_OnlyPileup \ +{ + # Load default Moriond 2013 release + Moriond2017 + # Override variables + outFile="JetUncertainties-Moriond2013-OnlyPileup.pdf" + compList="Pileup_#;Pileup_OffsetMu;Pileup_OffsetNPV;Pileup_PtTerm;Pileup_RhoTopology" + compLabels="Pileup, total (all components);Pileup, <#mu> offset;Pileup, NPV offset;Pileup, #it{p}_{T} bias;Pileup, #rho topology" +} + +####################################### +# Special request for Cate +function ICHEP2016_Compare_EtaIntercal \ +{ + ICHEP2016 + outFile="${outFile/Public/Compare-Public}" + compList="EtaIntercalib#" + compLabels="Relative #it{in situ} JES" + options="${options};doCompare=JES_2015/Prerec/PrerecJES2015_AllNuisanceParameters_25ns.config&MC15&Preliminary uncertainty" +} + +####################################### Old stuff + +function Prerec2015_OnlyFlavour \ +{ + # Load default Prerec 2015 release + Prerec2015 + # Override variables + outFile="JetUncertainties-Prerec2015-OnlyFlavour.pdf" + compList="Flavor_#;Flavor_Comp#;Flavor_Resp#" + compLabels="Flavour, total (all components);Flavour composition;Flavour response" +} + +function Prerec2015_OnlyXcalib \ +{ + # Load default Prerec 2015 release + Prerec2015 + # Override variables + outFile="JetUncertainties-Prerec2015-OnlyXcalib.pdf" + compList="Xcalib_#;Xcalib_1#;Xcalib_2#;Xcalib_3#;Xcalib_4#;Xcalib_5#;Xcalib_6#" + compLabels="2012 to 2015 extrapolation, total;Bunch spacing;Digitization;Topoclustering;Early data term;Noise threshold;Underlying event" +} + +function Prerec2015_3NP_Scenario1_25ns \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/Prerec/PrerecJES2015_3NP_Scenario1_25ns.config" + outFile="JetUncertainties-Prerec2015-3NP-Scenario1-25ns.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function Prerec2015_3NP_Scenario2_25ns \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/Prerec/PrerecJES2015_3NP_Scenario2_25ns.config" + outFile="JetUncertainties-Prerec2015-3NP-Scenario2-25ns.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function Prerec2015_3NP_Scenario3_25ns \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/Prerec/PrerecJES2015_3NP_Scenario3_25ns.config" + outFile="JetUncertainties-Prerec2015-3NP-Scenario3-25ns.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function Prerec2015_3NP_Scenario4_25ns \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/Prerec/PrerecJES2015_3NP_Scenario4_25ns.config" + outFile="JetUncertainties-Prerec2015-3NP-Scenario4-25ns.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function Prerec2015_3NP_Scenario1_50ns \ +{ + Prerec2015_3NP_Scenario1_25ns + configFile=${configFile/25/50} + outFile=${outFile/25/50} +} + +function Prerec2015_3NP_Scenario2_50ns \ +{ + Prerec2015_3NP_Scenario2_25ns + configFile=${configFile/25/50} + outFile=${outFile/25/50} +} + +function Prerec2015_3NP_Scenario3_50ns \ +{ + Prerec2015_3NP_Scenario3_25ns + configFile=${configFile/25/50} + outFile=${outFile/25/50} +} + +function Prerec2015_3NP_Scenario4_50ns \ +{ + Prerec2015_3NP_Scenario4_25ns + configFile=${configFile/25/50} + outFile=${outFile/25/50} +} + +####################################### Specialty requirements + +function PreMoriond2016_forMJB \ +{ + + # Load default Prerec 2015 release + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo" + MCtype="MC15" + configFile="JES_2015/Prerec/JESNuisanceParametersForMJB.config" + outFile="JetUncertainties-IntoMJB_PreMoriond2016.pdf" + + compList="LAr#,Zjet#,Gjet#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#;" + compLabels="Absolute #it{in situ} JES (LAr,Z,#gamma+jet);Relative #it{in situ} JES (2015 Prerec);Flav. composition;Flav. response;Pileup, predicted 2015 conditions;Punch-through, predicted 2015 conditions;" + + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;bunchSpacing=25" + +} + +function PreICHEP2016_forMJB \ +{ + + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo" + MCtype="MC15" + configFile="JES_2015/ICHEP2016/JESNuisanceParametersForMJB.config" + outFile="JetUncertainties-IntoMJB_PreIchep2016.pdf" + + compList="LAr#,Zjet#,Gjet#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#;" + compLabels="Absolute #it{in situ} JES (Z,#gamma+jet);Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;bunchSpacing=25" + +} + +################################################ +## Moriond 2017 uncertainty plots +## for the four fitted JES possibilities +## with all of their relevant reductions + +##-------------------------------------------### +## JESFit_0_4 + +function Moriond2017_0_4 \ +{ + + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017_0_4/JES2016_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2017_0_4-Unknown-Nominal.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_" +} + +function Moriond2017_0_4_GlobalReduction \ +{ + # Load default Moriond 2016 release + Moriond2017_0_4 + # Override variables + configFile="JES_2016/Moriond2017_0_4/JES2016_17NP.config" + outFile="JetUncertainties-Moriond2017_0_4-Unknown-GlobalReduction.pdf" + compList="EffectiveNP#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;" +} + +function Moriond2017_0_4_forTests \ +{ + + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017_0_4/JES2016_AllNuisanceParameters_forCorrTests.config" + outFile="JetUncertainties-Moriond2017_0_4-Unknown-Nominal-test.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#;LAr#;Zjet#;Gjet#;MJB#;" + compLabels="Absolute #it{in situ} JES;LAr;Z+jet;Gamma+jet;Multijet balance" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_" +} + +function Moriond2017_0_4_GlobalReduction_forTests \ +{ + # Load default Moriond 2016 release + Moriond2017_0_4_forTests + # Override variables + configFile="JES_2016/Moriond2017_0_4/JES2016_17NP_forCorrTests.config" + outFile="JetUncertainties-Moriond2017_0_4-Unknown-GlobalReduction-test.pdf" + compList="EffectiveNP#;EffectiveNP_1;EffectiveNP_2;EffectiveNP_3;EffectiveNP_4restTerm;" + compLabels="In situ total;First global parameter;Second global parameter;Third global parameter;Fourth global parameter" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;" + +} + + +##-------------------------------------------### +## JESFit_m1_4 +## Selected nominal: directory renamed Moriond2017_fitted + +function Moriond2017_fitted \ +{ + + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017_fitted/JES2016_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2017_fitted-Unknown-Nominal.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_" +} + +function Moriond2017_fitted_GlobalReduction \ +{ + # Load default Moriond 2016 release + Moriond2017_fitted + # Override variables + configFile="JES_2016/Moriond2017_fitted/JES2016_18NP.config" + outFile="JetUncertainties-Moriond2017_fitted-Unknown-GlobalReduction.pdf" + compList="EffectiveNP#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;" +} + +function Moriond2017_fitted_forLaurie \ +{ + + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017_fitted/JES2016_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2017_fitted-Unknown-Nominal-forLaurie.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;fixedPtVals=100,200,300" +} + +##-------------------------------------------### +## JESFit_m2_4 + +function Moriond2017_m2_4 \ +{ + + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017_m2_4/JES2016_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2017_m2_4-Unknown-Nominal.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_" +} + +function Moriond2017_m2_4_GlobalReduction \ +{ + # Load default Moriond 2016 release + Moriond2017_m2_4 + # Override variables + configFile="JES_2016/Moriond2017_m2_4/JES2016_19NP.config" + outFile="JetUncertainties-Moriond2017_m2_4-Unknown-GlobalReduction.pdf" + compList="EffectiveNP#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;" +} + +##-------------------------------------------### +## JESFit_m2_5 + +function Moriond2017_m2_5 \ +{ + + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017_m2_5/JES2016_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2017_m2_5-Unknown-Nominal.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_" +} + +function Moriond2017_m2_5_GlobalReduction \ +{ + # Load default Moriond 2016 release + Moriond2017_m2_5 + # Override variables + configFile="JES_2016/Moriond2017_m2_5/JES2016_20NP.config" + outFile="JetUncertainties-Moriond2017_m2_5-Unknown-GlobalReduction.pdf" + compList="EffectiveNP#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;" +} + +####################################### Random + + +function JER2012 +{ + # Final 2012 JER + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo;AntiKt6EMTopo;AntiKt6LCTopo" + MCtype="MC12" + configFile="JER_2012/InsituJER2012_AllNuisanceParameters.config" + outFile="JER-Final2012.pdf" + compList="JER_NoiseTerm;JER_Dijet_#;JER_Gjet_#;JER_Zjet_#" + compLabels="Noise term;Dijet;#gamma+jet;Z+jet" + options="isJER=true;isDijet=false;isLargeR=false;prefix=JET_" +} + +function JER2015 +{ + # Prerec 2015 JER + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JER_2015/PrerecJER2015_AllNuisanceParameters.config" + outFile="JER-Prerec2015.pdf" + compList="JER_NoiseTerm;JER_Dijet_#;JER_Gjet_#;JER_Zjet_#;Xcalib_#" + compLabels="Noise term;Dijet #it{in situ} measurement;#gamma+jet #it{in situ} measurement;Z+jet #it{in situ} measurement;2012 to 2015 extrapolation" + options="isJER=true;isDijet=false;isLargeR=false;prefix=JET_" +} + +function JER2015_xcal +{ + JER2015 + compList="Xcalib_50nsVs25ns;Xcalib_5Vs4sample;Xcalib_TopoClustering;Xcalib_EarlyData;Xcalib_NoiseThreshold;Xcalib_UnderlyingEvent;Xcalib_PhiModulation" + compLabels="50 vs 25 ns;5 vs 4 samples;Topo-clustering;Early data;Noise threshold;Underlying event;Phi modulation" + outFile="JER-Prerec2015_xCalib.pdf" +} + +function JER_2015_2012_Compare \ +{ + + # Load default prerec JER 2015 + JER2015 + # Override variables + outFile="JER-Prerec2015-CompareTo2012.pdf" + options="isJER=true;isDijet=false;isGSC=false;isLargeR=false;prefix=JET_;doCompare=JER_2012/InsituJER2012_AllNuisanceParameters.config&MC12&Total uncertainty, 2012" + +} + + + +############# 2015 Large-R pre-rec uncertainties ############# + +#compareLargeRPrerec="true" +#fullSplitLargeRPrerec="true" +#splitScales1LargeRPrerec="true" +#splitScales2LargeRPrerec="true" +#noMassWindowLargeRPrerec="true" +#signalLargeRPrerec="true" + +function LargeR_Prerec2015_Hbb \ +{ + # July 2014 large-R jet release + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15" + configFile="UJ_2015/Prerec/Prerec2015_HbbTagging.config" + outFile="JetUncertainties-LargeR-Prerec2015-Hbb-pT.pdf" + compList="Hbb_Run1;Hbb_CrossCalib" + compLabels="Run 1 R_{trk};Cross-calibration" + options="isDijet=false;isLargeR=true;prefix=JET_;scaleVar=pt" +} + +function LargeR_Prerec2015_Hbb_nomerge \ +{ + LargeR_Prerec2015_Hbb + configFile=${configFile/HbbTagging/HbbTagging_NoMerge} + compList="Hbb_Run1;Hbb_50vs25ns;Hbb_LArSampling;Hbb_TopoclusterAlg;Hbb_NoiseThrUp;Hbb_NoiseThrDown;Hbb_Material" + compLabels="Run1;50 vs 25 ns;4 vs 5 LAr samples;Topocluster algorithm;Noise threshold up;Noise threshold down;Material" +} + +function LargeR_Prerec2015_Hbb_splitscales1 \ +{ + LargeR_Prerec2015_Hbb + configFile=${configFile/HbbTagging/HbbTagging_SplitScales1} + compList="Hbb_Run1_pT;Hbb_Run1_mass;Hbb_Run1_D2;Hbb_CrossCalib" + compLabels="Run 1 R_{trk} (pT);Run 1 R_{trk} (mass);Run 1 R_{trk} (D2);Cross-calibration" +} + +function LargeR_Prerec2015_Hbb_splitscales2 \ +{ + LargeR_Prerec2015_Hbb + configFile=${configFile/HbbTagging/HbbTagging_SplitScales2} + compList="Hbb_Run1_pT;Hbb_Run1_mass;Hbb_Run1_D2;Hbb_CrossCalib_pT;Hbb_CrossCalib_mass;Hbb_CrossCalib_D2" + compLabels="Run 1 R_{trk} (pT);Run 1 R_{trk} (mass);Run 1 R_{trk} (D2);Cross-calibration (pT);Cross-calibration (mass);Cross-calibration (D2)" +} + +function LargeR_Prerec2015_Hbb_pT \ +{ + if ! [ -z $fullSplitLargeRPrerec ] ; then + LargeR_Prerec2015_Hbb_nomerge + elif ! [ -z $splitScales1LargeRPrerec ] ; then + LargeR_Prerec2015_Hbb_splitscales1 + elif ! [ -z $splitScales2LargeRPrerec ] ; then + LargeR_Prerec2015_Hbb_splitscales2 + else + LargeR_Prerec2015_Hbb + fi + if ! [ -z $noMassWindowLargeRPrerec ] ; then + configFile=${configFile/HbbTagging/HbbTagging_NoMassWindow} + fi + if ! [ -z $signalLargeRPrerec ] ; then + configFile=${configFile/HbbTagging/HbbTagging_Signal} + fi + if ! [ -z $compareLargeRPrerec ] ; then + options="${options};doCompare=UJ_2015/Prerec/Prerec2015_HbbTagging_PhysicsLists.config&MC15&Total uncertainty, physics lists" + fi +} + +function LargeR_Prerec2015_Hbb_mass \ +{ + if ! [ -z $fullSplitLargeRPrerec ] ; then + LargeR_Prerec2015_Hbb_nomerge + elif ! [ -z $splitScales1LargeRPrerec ] ; then + LargeR_Prerec2015_Hbb_splitscales1 + elif ! [ -z $splitScales2LargeRPrerec ] ; then + LargeR_Prerec2015_Hbb_splitscales2 + else + LargeR_Prerec2015_Hbb + fi + if ! [ -z $noMassWindowLargeRPrerec ] ; then + configFile=${configFile/HbbTagging/HbbTagging_NoMassWindow} + fi + if ! [ -z $signalLargeRPrerec ] ; then + configFile=${configFile/HbbTagging/HbbTagging_Signal} + fi + outFile=${outFile/-pT/-mass} + options=${options/scaleVar=pt/scaleVar=mass} + if ! [ -z $compareLargeRPrerec ] ; then + options="${options};doCompare=UJ_2015/Prerec/Prerec2015_HbbTagging_PhysicsLists.config&MC15&Total uncertainty, physics lists" + fi +} + +function LargeR_Prerec2015_Hbb_D2 \ +{ + if ! [ -z $fullSplitLargeRPrerec ] ; then + LargeR_Prerec2015_Hbb_nomerge + elif ! [ -z $splitScales1LargeRPrerec ] ; then + LargeR_Prerec2015_Hbb_splitscales1 + elif ! [ -z $splitScales2LargeRPrerec ] ; then + LargeR_Prerec2015_Hbb_splitscales2 + else + LargeR_Prerec2015_Hbb + fi + if ! [ -z $noMassWindowLargeRPrerec ] ; then + configFile=${configFile/HbbTagging/HbbTagging_NoMassWindow} + fi + if ! [ -z $signalLargeRPrerec ] ; then + configFile=${configFile/HbbTagging/HbbTagging_Signal} + fi + outFile=${outFile/-pT/-D2} + options=${options/scaleVar=pt/scaleVar=D2Beta1} + if ! [ -z $compareLargeRPrerec ] ; then + options="${options};doCompare=UJ_2015/Prerec/Prerec2015_HbbTagging_PhysicsLists.config&MC15&Total uncertainty, physics lists" + fi +} + +function LargeR_Prerec2015_Top \ +{ + # July 2014 large-R jet release + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15" + configFile="UJ_2015/Prerec/Prerec2015_TopTagging.config" + outFile="JetUncertainties-LargeR-Prerec2015-Top-pT.pdf" + compList="Top_Run1;Top_CrossCalib" + compLabels="Run 1 R_{trk};Cross-calibration" + options="isDijet=false;isLargeR=true;prefix=JET_;scaleVar=pt" +} + +function LargeR_Prerec2015_Top_nomerge \ +{ + LargeR_Prerec2015_Top + configFile=${configFile/TopTagging/TopTagging_NoMerge} + compList="Top_Run1;Top_50vs25ns;Top_TopoclusterAlg;Top_NoiseThrUp;Top_NoiseThrDown;Top_Material" + compLabels="Run1;50 vs 25 ns;Topocluster algorithm;Noise threshold up;Noise threshold down;Material" +} + +function LargeR_Prerec2015_Top_splitscales1 \ +{ + LargeR_Prerec2015_Top + configFile=${configFile/TopTagging/TopTagging_SplitScales1} + compList="Top_Run1_pT;Top_Run1_mass;Top_Run1_Tau32;Top_CrossCalib" + compLabels="Run 1 R_{trk} (pT);Run 1 R_{trk} (mass);Run 1 R_{trk} (Tau32);Cross-calibration" +} + +function LargeR_Prerec2015_Top_splitscales2 \ +{ + LargeR_Prerec2015_Top + configFile=${configFile/TopTagging/TopTagging_SplitScales2} + compList="Top_Run1_pT;Top_Run1_mass;Top_Run1_Tau32;Top_CrossCalib_pT;Top_CrossCalib_mass;Top_CrossCalib_Tau32" + compLabels="Run 1 R_{trk} (pT);Run 1 R_{trk} (mass);Run 1 R_{trk} (Tau32);Cross-calibration (pT);Cross-calibration (mass);Cross-calibration (Tau32)" +} + +function LargeR_Prerec2015_Top_pT \ +{ + if ! [ -z $fullSplitLargeRPrerec ] ; then + LargeR_Prerec2015_Top_nomerge + elif ! [ -z $splitScales1LargeRPrerec ] ; then + LargeR_Prerec2015_Top_splitscales1 + elif ! [ -z $splitScales2LargeRPrerec ] ; then + LargeR_Prerec2015_Top_splitscales2 + else + LargeR_Prerec2015_Top + fi + if ! [ -z $noMassWindowLargeRPrerec ] ; then + configFile=${configFile/TopTagging/TopTagging_NoMassWindow} + fi + if ! [ -z $signalLargeRPrerec ] ; then + configFile=${configFile/TopTagging/TopTagging_Signal} + fi + if ! [ -z $compareLargeRPrerec ] ; then + options="${options};doCompare=UJ_2015/Prerec/Prerec2015_TopTagging_PhysicsLists.config&MC15&Total uncertainty, physics lists" + fi +} + +function LargeR_Prerec2015_Top_mass \ +{ + if ! [ -z $fullSplitLargeRPrerec ] ; then + LargeR_Prerec2015_Top_nomerge + elif ! [ -z $splitScales1LargeRPrerec ] ; then + LargeR_Prerec2015_Top_splitscales1 + elif ! [ -z $splitScales2LargeRPrerec ] ; then + LargeR_Prerec2015_Top_splitscales2 + else + LargeR_Prerec2015_Top + fi + if ! [ -z $noMassWindowLargeRPrerec ] ; then + configFile=${configFile/TopTagging/TopTagging_NoMassWindow} + fi + if ! [ -z $signalLargeRPrerec ] ; then + configFile=${configFile/TopTagging/TopTagging_Signal} + fi + outFile=${outFile/-pT/-mass} + options=${options/scaleVar=pt/scaleVar=mass} + if ! [ -z $compareLargeRPrerec ] ; then + options="${options};doCompare=UJ_2015/Prerec/Prerec2015_TopTagging_PhysicsLists.config&MC15&Total uncertainty, physics lists" + fi +} + +function LargeR_Prerec2015_Top_Tau32 \ +{ + if ! [ -z $fullSplitLargeRPrerec ] ; then + LargeR_Prerec2015_Top_nomerge + elif ! [ -z $splitScales1LargeRPrerec ] ; then + LargeR_Prerec2015_Top_splitscales1 + elif ! [ -z $splitScales2LargeRPrerec ] ; then + LargeR_Prerec2015_Top_splitscales2 + else + LargeR_Prerec2015_Top + fi + if ! [ -z $noMassWindowLargeRPrerec ] ; then + configFile=${configFile/TopTagging/TopTagging_NoMassWindow} + fi + if ! [ -z $signalLargeRPrerec ] ; then + configFile=${configFile/TopTagging/TopTagging_Signal} + fi + outFile=${outFile/-pT/-Tau32} + options=${options/scaleVar=pt/scaleVar=Tau32WTA} + if ! [ -z $compareLargeRPrerec ] ; then + options="${options};doCompare=UJ_2015/Prerec/Prerec2015_TopTagging_PhysicsLists.config&MC15&Total uncertainty, physics lists" + fi +} + +function LargeR_Prerec2015_WZ \ +{ + # July 2014 large-R jet release + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15" + configFile="UJ_2015/Prerec/Prerec2015_WZTagging.config" + outFile="JetUncertainties-LargeR-Prerec2015-WZ-pT.pdf" + compList="WZ_Run1;WZ_CrossCalib" + compLabels="Run 1 R_{trk};Cross-calibration" + options="isDijet=false;isLargeR=true;prefix=JET_;scaleVar=pt" +} + +function LargeR_Prerec2015_WZ_nomerge \ +{ + LargeR_Prerec2015_WZ + configFile=${configFile/WZTagging/WZTagging_NoMerge} + compList="WZ_Run1;WZ_50vs25ns;WZ_LArSampling;WZ_TopoclusterAlg;WZ_NoiseThrUp;WZ_NoiseThrDown;WZ_Material" + compLabels="Run1;50 vs 25 ns;4 vs 5 LAr samples;Topocluster algorithm;Noise threshold up;Noise threshold down;Material" +} + +function LargeR_Prerec2015_WZ_splitscales1 \ +{ + LargeR_Prerec2015_WZ + configFile=${configFile/WZTagging/WZTagging_SplitScales1} + compList="WZ_Run1_pT;WZ_Run1_mass;WZ_Run1_D2;WZ_CrossCalib" + compLabels="Run 1 R_{trk} (pT);Run 1 R_{trk} (mass);Run 1 R_{trk} (D2);Cross-calibration" +} + +function LargeR_Prerec2015_WZ_splitscales2 \ +{ + LargeR_Prerec2015_WZ + configFile=${configFile/WZTagging/WZTagging_SplitScales2} + compList="WZ_Run1_pT;WZ_Run1_mass;WZ_Run1_D2;WZ_CrossCalib_pT;WZ_CrossCalib_mass;WZ_CrossCalib_D2" + compLabels="Run 1 R_{trk} (pT);Run 1 R_{trk} (mass);Run 1 R_{trk} (D2);Cross-calibration (pT);Cross-calibration (mass);Cross-calibration (D2)" +} + +function LargeR_Prerec2015_WZ_pT \ +{ + if ! [ -z $fullSplitLargeRPrerec ] ; then + LargeR_Prerec2015_WZ_nomerge + elif ! [ -z $splitScales1LargeRPrerec ] ; then + LargeR_Prerec2015_WZ_splitscales1 + elif ! [ -z $splitScales2LargeRPrerec ] ; then + LargeR_Prerec2015_WZ_splitscales2 + else + LargeR_Prerec2015_WZ + fi + if ! [ -z $noMassWindowLargeRPrerec ] ; then + configFile=${configFile/WZTagging/WZTagging_NoMassWindow} + fi + if ! [ -z $signalLargeRPrerec ] ; then + configFile=${configFile/WZTagging/WZTagging_Signal} + fi + if ! [ -z $compareLargeRPrerec ] ; then + options="${options};doCompare=UJ_2015/Prerec/Prerec2015_WZTagging_PhysicsLists.config&MC15&Total uncertainty, physics lists" + fi +} + +function LargeR_Prerec2015_WZ_mass \ +{ + if ! [ -z $fullSplitLargeRPrerec ] ; then + LargeR_Prerec2015_WZ_nomerge + elif ! [ -z $splitScales1LargeRPrerec ] ; then + LargeR_Prerec2015_WZ_splitscales1 + elif ! [ -z $splitScales2LargeRPrerec ] ; then + LargeR_Prerec2015_WZ_splitscales2 + else + LargeR_Prerec2015_WZ + fi + if ! [ -z $noMassWindowLargeRPrerec ] ; then + configFile=${configFile/WZTagging/WZTagging_NoMassWindow} + fi + if ! [ -z $signalLargeRPrerec ] ; then + configFile=${configFile/WZTagging/WZTagging_Signal} + fi + outFile=${outFile/-pT/-mass} + options=${options/scaleVar=pt/scaleVar=mass} + if ! [ -z $compareLargeRPrerec ] ; then + options="${options};doCompare=UJ_2015/Prerec/Prerec2015_WZTagging_PhysicsLists.config&MC15&Total uncertainty, physics lists" + fi +} + +function LargeR_Prerec2015_WZ_D2 \ +{ + if ! [ -z $fullSplitLargeRPrerec ] ; then + LargeR_Prerec2015_WZ_nomerge + elif ! [ -z $splitScales1LargeRPrerec ] ; then + LargeR_Prerec2015_WZ_splitscales1 + elif ! [ -z $splitScales2LargeRPrerec ] ; then + LargeR_Prerec2015_WZ_splitscales2 + else + LargeR_Prerec2015_WZ + fi + if ! [ -z $noMassWindowLargeRPrerec ] ; then + configFile=${configFile/WZTagging/WZTagging_NoMassWindow} + fi + if ! [ -z $signalLargeRPrerec ] ; then + configFile=${configFile/WZTagging/WZTagging_Signal} + fi + outFile=${outFile/-pT/-D2} + options=${options/scaleVar=pt/scaleVar=D2Beta1} + if ! [ -z $compareLargeRPrerec ] ; then + options="${options};doCompare=UJ_2015/Prerec/Prerec2015_WZTagging_PhysicsLists.config&MC15&Total uncertainty, physics lists" + fi +} + + + + + +function LargeR_Moriond2016_Rtrk_Public \ +{ + # July 2014 large-R jet release + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15" + configFile="UJ_2015/Moriond2016/UJ2015_WZTagging_medium.config" + outFile="JetUncertainties-Moriond2016-Rtrk-public-mass.pdf" + compList="Rtrk_Baseline;Rtrk_Modelling;Rtrk_Tracking#" + compLabels="R_{trk} baseline (Pythia);R_{trk} modelling (Herwig);R_{trk} tracking" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;isPublic=true;scaleVar=mass" +} +function LargeR_Moriond2016_Rtrk \ +{ + # July 2014 large-R jet release + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15" + configFile="UJ_2015/Moriond2016/UJ2015_WZTagging.config" + outFile="JetUncertainties-Moriond2016-Rtrk-pT.pdf" + compList="Rtrk_Baseline;Rtrk_Modelling;Rtrk_Tracking1;Rtrk_Tracking2;Rtrk_Tracking3" + compLabels="R_{trk} baseline;R_{trk} modelling;R_{trk} tracking 1;R_{trk} tracking 2;R_{trk} tracking 3" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;totalUncName=\"Total Uncertainty, 13 TeV in situ\";scaleVar=pt" +} +function LargeR_Moriond2016_RtrkCombTrack \ +{ + # July 2014 large-R jet release + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15" + configFile="UJ_2015/Moriond2016/UJ2015_WZTagging.config" + outFile="JetUncertainties-Moriond2016-RtrkComb-pT.pdf" + compList="Rtrk_Baseline;Rtrk_Modelling;Rtrk_Tracking#" + compLabels="R_{trk} baseline;R_{trk} modelling;R_{trk} tracking" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;totalUncName=\"Total Uncertainty, 13 TeV in situ\";scaleVar=pt" +} +function LargeR_Moriond2016_Tracking \ +{ + # July 2014 large-R jet release + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15" + configFile="UJ_2015/Moriond2016/UJ2015_TrackingComp.config" + outFile="JetUncertainties-Moriond2016-Tracking-pT.pdf" + compList="Rtrk_Tracking1;Rtrk_Tracking2;Rtrk_Tracking3" + compLabels="R_{trk} tracking 1;R_{trk} tracking 2;R_{trk} tracking 3" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;drawTotal=false;scaleVar=pt" +} +function LargeR_Moriond2016_WZ \ +{ + # July 2014 large-R jet release + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15" + configFile="UJ_2015/Moriond2016/UJ2015_WZTagging.config" + outFile="JetUncertainties-Moriond2016-WZ-pT.pdf" + compList="Rtrk_Baseline;Rtrk_Modelling;Rtrk_Tracking1;Rtrk_Tracking2;Rtrk_Tracking3" + compLabels="R_{trk} baseline;R_{trk} modelling;R_{trk} tracking 1;R_{trk} tracking 2;R_{trk} tracking 3" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;doCompare=UJ_2015/Prerec/Prerec2015_WZTagging.config&MC15&\"Pre-recommendation, W/Z tagged\";totalUncName=\"Total Uncertainty, 13 TeV in situ\";scaleVar=pt" +} +function LargeR_Moriond2016_Top \ +{ + # July 2014 large-R jet release + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15" + configFile="UJ_2015/Moriond2016/UJ2015_TopTagging.config" + outFile="JetUncertainties-Moriond2016-top-pT.pdf" + compList="Rtrk_Baseline;Rtrk_Modelling;Rtrk_Tracking1;Rtrk_Tracking2;Rtrk_Tracking3" + compLabels="R_{trk} baseline;R_{trk} modelling;R_{trk} tracking 1;R_{trk} tracking 2;R_{trk} tracking 3" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;doCompare=UJ_2015/Prerec/Prerec2015_TopTagging.config&MC15&\"Pre-recommendation, top tagged\";totalUncName=\"Total Uncertainty, 13 TeV in situ\";scaleVar=pt" +} +function LargeR_Moriond2016_Hbb \ +{ + # July 2014 large-R jet release + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15" + configFile="UJ_2015/Moriond2016/UJ2015_HbbTagging.config" + outFile="JetUncertainties-Moriond2016-Hbb-pT.pdf" + compList="Rtrk_Baseline;Rtrk_Modelling;Rtrk_Tracking1;Rtrk_Tracking2;Rtrk_Tracking3" + compLabels="R_{trk} baseline;R_{trk} modelling;R_{trk} tracking 1;R_{trk} tracking 2;R_{trk} tracking 3" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;doCompare=UJ_2015/Prerec/Prerec2015_HbbTagging.config&MC15&\"Pre-recommendation, Hbb tagged\";totalUncName=\"Total Uncertainty, 13 TeV in situ\";scaleVar=pt" +} +tagType=WZ +scale=D2Beta1 +NMW="NMW" +corr=strong +function LargeR_Moriond2016_VALIDATE \ +{ + # July 2014 large-R jet release + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15" + if [ -z "$NMW" ] ; then + configFile="UJ_2015/Moriond2016/UJ2015_${tagType}Tagging_${corr}.config" + outFile="JetUncertainties-Moriond2016-${tagType}-$corr-${scale}.pdf" + else + configFile="UJ_2015/Moriond2016/UJ2015_${tagType}Tagging_NoMassWindow_${corr}.config" + outFile="JetUncertainties-Moriond2016-${tagType}-NMW-$corr-${scale}.pdf" + fi + if [[ $corr = weak ]] ; then + compList="Rtrk_Baseline_pT;Rtrk_Baseline_mass;Rtrk_Modelling_pT;Rtrk_Modelling_mass;Rtrk_Tracking_pT;Rtrk_Tracking_mass;${tagType}_Run1_#;${tagType}_Cross#" + compLabels="R_{trk} baseline (pT);R_{trk} baseline (mass);R_{trk} modelling (pT);R_{trk} modelling (mass);R_{trk} tracking (pT);R_trk tracking (mass);Run-1 R_{trk} ($scale$NMW);Cross-calib ($scale$NMW)" + elif [[ $corr = medium ]] ; then + compList="Rtrk_Baseline;Rtrk_Modelling;Rtrk_Tracking;${tagType}_Run1_#;${tagType}_Cross#" + compLabels="R_{trk} baseline (pT+mass);R_{trk} modelling (pT+mass);R_{trk} tracking (pT+mass);Run-1 R_{trk} ($scale$NMW);Cross-calib ($scale$NMW)" + elif [[ $corr = strong ]] ; then + compList="Rtrk_Baseline;Rtrk_ModellingAndTracking;${tagType}_Run1_#;${tagType}_Cross#" + compLabels="R_{trk} baseline (pT+mass);R_{trk} modelling+tracking (pT+mass);Run-1 R_{trk} ($scale$NMW);Cross-calib ($scale$NMW)" + fi + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;doCompare=UJ_2015/Prerec/Prerec2015_HbbTagging.config&MC15&\"Pre-recommendation, $tagType tagged\";totalUncName=\"Total Uncertainty, 13 TeV in situ\";scaleVar=${scale}" +} + + +# Kate going to use for 2015 paper + + +function Moriond2016_SR_Scenario1 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/Moriond2016/JES2015_SR_Scenario1.config" + outFile="JetUncertainties-Moriond2016-SR-Scenario1.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3" #;EtaIntercalibration_NonClosure" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3" #;#eta-intercalibration nonclosure" + #compList="GroupedNP_1;GroupedNP_2;GroupedNP_3;EtaIntercalibration_NonClosure;RelativeNonClosure_#" + #compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3;#eta-intercalibration nonclosure;MC nonclosure (if applicable)" + options="isDijet=false;isLargeR=false;prefix=JET_" +} +function Moriond2016_SR_Scenario2 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/Moriond2016/JES2015_SR_Scenario2.config" + outFile="JetUncertainties-Moriond2016-SR-Scenario2.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3" #;EtaIntercalibration_NonClosure" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3" #;#eta-intercalibration nonclosure" + options="isDijet=false;isLargeR=false;prefix=JET_" +} +function Moriond2016_SR_Scenario3 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/Moriond2016/JES2015_SR_Scenario3.config" + outFile="JetUncertainties-Moriond2016-SR-Scenario3.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3" #;EtaIntercalibration_NonClosure" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3" #;#eta-intercalibration nonclosure" + options="isDijet=false;isLargeR=false;prefix=JET_" +} +function Moriond2016_SR_Scenario4 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/Moriond2016/JES2015_SR_Scenario4.config" + outFile="JetUncertainties-Moriond2016-SR-Scenario4.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3" #;EtaIntercalibration_NonClosure" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3" #;#eta-intercalibration nonclosure" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + + +function TLA2015 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="TLA_2015/JES2015_TLA_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2016-TLA.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;TLA_ScaleFactor" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Trigger Flav. composition;Trigger Flav. response;Trigger Pileup, average 2015 conditions;Trigger data-derived correction" + options="isDijet=false;isLargeR=false;prefix=JET_;doCompare=JES_2015/Moriond2016/JES2015_AllNuisanceParameters.config&MC15&\"Total Uncertainty, Offline\";totalUncName=\"Total Uncertainty, Trigger\";ptBins=U&1000&75&1000;logPt=false;isPublic=true;isTLA=true" +} + +function TLA2015_SR1 \ +{ + TLA2015 + configFile="TLA_2015/JES2015_SR_TLA_Scenario1.config" + outFile="JetUncertainties-Moriond2016-TLA-SR1.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3;EtaIntercalibration_NonClosure;TLA_ScaleFactor" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3;#eta-intercalibration nonclosure;TLA scale factor" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function TLA2015_SR2 \ +{ + TLA2015_SR1 + configFile="${configFile/Scenario1/Scenario2}" + outFile="${outFile/SR1/SR2}" +} + +function TLA2015_SR3 \ +{ + TLA2015_SR1 + configFile="${configFile/Scenario1/Scenario3}" + outFile="${outFile/SR1/SR3}" +} + +function TLA2015_SR4 \ +{ + TLA2015_SR1 + configFile="${configFile/Scenario1/Scenario4}" + outFile="${outFile/SR1/SR4}" +} + +function TLA2015_flavour \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="TLA_2015/JES2015_TLA_AllNuisanceParameters.config;JES_2015/Moriond2016/JES2015_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2016-TLA-flavour-quadsum.pdf" + #outFile="JetUncertainties-Moriond2016-TLA-flavour.pdf" + compList="TOTAL;Flavor_Comp#,Flavor_Resp#@Flavor_Comp#,Flavor_Resp#" + compLabels="Total uncertainty, TLA 2015;Flav. composition #oplus response (no GSC)@Flav. composition #oplus response (with GSC)" + #compList="TOTAL;Flavor_Comp#;Flavor_Resp#@Flavor_Comp#;Flavor_Resp#" + #compLabels="Total uncertainty, TLA 2015;Flav. composition (no GSC);Trigger Flav. response (no GSC)@Flav. composition (with GSC);Flav. response (with GSC)" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=false;ptBins=U&1000&75&1000;logPt=false;isPublic=false;isTLA=true" +} + +########################################### +# Kate: TLA, 2016 dataset + +function TLA2016 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="TLA_2016/TLA_2016/JES2016_TLA_AllNuisanceParameters.config" + outFile="JetUncertainties-TLA2016.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;TLA_ScaleFactor" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Trigger Flav. composition;Trigger Flav. response;Trigger Pileup, average 2016 conditions;Trigger data-derived correction" + options="isDijet=false;isLargeR=false;prefix=JET_;doCompare=JES_2016/Moriond2017/JES2016_AllNuisanceParameters.config&MC15&\"Total Uncertainty, Offline\";totalUncName=\"Total Uncertainty, Trigger\";ptBins=U&1500&55&1500;logPt=false;isPublic=true;isTLA=true" +} + +function TLA2016_SR1 \ +{ + TLA2016 + configFile="TLA_2016/TLA_2016/JES2016_SR_TLA_Scenario1.config" + outFile="JetUncertainties-TLA2016-SR1.pdf" + compList="GroupedNP_1;GroupedNP_2;GroupedNP_3;EtaIntercalibration_NonClosure;TLA_ScaleFactor" + compLabels="Grouped NP 1;Grouped NP 2;Grouped NP 3;#eta-intercalibration nonclosure;TLA scale factor" + options="isDijet=false;isLargeR=false;prefix=JET_" +} + +function TLA2016_SR2 \ +{ + TLA2016_SR1 + configFile="${configFile/Scenario1/Scenario2}" + outFile="${outFile/SR1/SR2}" +} + +function TLA2016_SR3 \ +{ + TLA2016_SR1 + configFile="${configFile/Scenario1/Scenario3}" + outFile="${outFile/SR1/SR3}" +} + +function TLA2016_SR4 \ +{ + TLA2016_SR1 + configFile="${configFile/Scenario1/Scenario4}" + outFile="${outFile/SR1/SR4}" +} + +function TLA2016_flavour \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="TLA_2016/TLA_2016/JES2016_TLA_AllNuisanceParameters.config;JES_2016/Moriond2017/JES2016_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2017-TLA-flavour-quadsum.pdf" + #outFile="JetUncertainties-Moriond2016-TLA-flavour.pdf" + compList="TOTAL;Flavor_Comp#,Flavor_Resp#@Flavor_Comp#,Flavor_Resp#" + compLabels="Total uncertainty, TLA 2016;Flav. composition #oplus response (no GSC)@Flav. composition #oplus response (with GSC)" + #compList="TOTAL;Flavor_Comp#;Flavor_Resp#@Flavor_Comp#;Flavor_Resp#" + #compLabels="Total uncertainty, TLA 2015;Flav. composition (no GSC);Trigger Flav. response (no GSC)@Flav. composition (with GSC);Flav. response (with GSC)" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=false;ptBins=U&1500&85&1500;logPt=false;isPublic=false;isTLA=true" +} + +############# End TLA #################### + + +function testGlobalCompareBase \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC12;MC12;MC15;MC15" + configFile="JES_2012/Final/InsituJES2012_AllNuisanceParameters.config;JES_2012/Final/InsituJES2012_14NP.config;JES_2015/Moriond2016/JES2015_AllNuisanceParameters.config;JES_2015/Moriond2016/JES2015_19NP.config" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=False;axisMin=0;axisMax=0.05;absVal=false" +} + +function testGlobalCompareBaseRed \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC12;MC15" + configFile="JES_2012/Final/InsituJES2012_14NP.config;JES_2015/Moriond2016/JES2015_19NP.config" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=False;axisMin=-0.025;axisMax=0.025;absVal=false" +} + + +function testGlobalCompareNP12012 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC12;MC12" + configFile="JES_2012/Final/InsituJES2012_14NP.config;JES_2012/Final/InsituJES2012_AllNuisanceParameters.config" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=False;axisMin=0;axisMax=0.05" + outFile="JetUncertainties-Final2012-Moriond2016-GlobalReductions-NP1-2012.pdf" + compList="EffectiveNP_1@Zjet_MC,Zjet_Kterm,Gjet_OOC;Zjet_MC;Zjet_Kterm;Gjet_OOC" + compLabels="Global NP1 (2012)@Zjet MC #oplus Zjet K-term #oplus #gammajet OOC (2012);Zjet MC (2012);Zjet K-term (2012);#gammajet OOC (2012)" +} + +function testGlobalCompareNP12015 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15;MC15" + configFile="JES_2015/Moriond2016/JES2015_19NP.config;JES_2015/Moriond2016/JES2015_AllNuisanceParameters.config" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=False;axisMin=0;axisMax=0.05" + outFile="JetUncertainties-Final2012-Moriond2016-GlobalReductions-NP1-2015.pdf" + compList="EffectiveNP_1@Zjet_MC,Zjet_Kterm,Gjet_OOC;Zjet_MC;Zjet_Kterm;Gjet_OOC" + compLabels="Global NP1 (2015)@Zjet MC #oplus Zjet K-term #oplus #gammajet OOC (2015);Zjet MC (2015);Zjet K-term (2015);#gammajet OOC (2015)" +} + +function testGlobalCompareNP1all \ +{ + testGlobalCompareBase + outFile="JetUncertainties-Final2012-Moriond2016-GlobalReductions-NP1all.pdf" + compList="Zjet_MC;Zjet_Kterm;Gjet_OOC@EffectiveNP_1@Zjet_Kterm;Zjet_MC;Gjet_OOC@EffectiveNP_1" + compLabels="Zjet MC (2012);Zjet K-term (2012);#gammajet OOC (2012)@Global NP1 (2012)@Zjet K-term (2015);Zjet MC (2015);#gammajet OOC (2015)@Global NP1 (2015)" +} + +function testGlobalCompareNP1 \ +{ + testGlobalCompareBase + outFile="JetUncertainties-Final2012-Moriond2016-GlobalReductions-NP1.pdf" + compList="Zjet_MC,Zjet_Kterm,Gjet_OOC#@EffectiveNP_1@Zjet_Kterm,Zjet_MC,Gjet_OOC#@EffectiveNP_1" + compLabels="Zjet MC #oplus Zjet K-term #oplus #gammajet OOC (2012)@Global NP1 (2012)@Zjet MC #oplus Zjet K-term #oplus #gammajet OOC (2015)@Global NP1 (2015)" +} + +function testGlobalCompareNP2 \ +{ + testGlobalCompareBaseRed + outFile="JetUncertainties-Final2012-Moriond2016-GlobalReductions-NP2.pdf" + compList="EffectiveNP_2@EffectiveNP_2" + compLabels="Global NP2 (2012)@Global NP2 (2015)" +} + +function testGlobalCompareNP3 \ +{ + testGlobalCompareBaseRed + outFile="JetUncertainties-Final2012-Moriond2016-GlobalReductions-NP3.pdf" + compList="EffectiveNP_3@EffectiveNP_3" + compLabels="Global NP3 (2012)@Global NP3 (2015)" +} + +function testGlobalCompareNP4 \ +{ + testGlobalCompareBaseRed + outFile="JetUncertainties-Final2012-Moriond2016-GlobalReductions-NP4.pdf" + compList="EffectiveNP_4@EffectiveNP_4" + compLabels="Global NP4 (2012)@Global NP4 (2015)" +} + +function testGlobalCompareNP5 \ +{ + testGlobalCompareBaseRed + outFile="JetUncertainties-Final2012-Moriond2016-GlobalReductions-NP5.pdf" + compList="EffectiveNP_5@EffectiveNP_5" + compLabels="Global NP5 (2012)@Global NP5 (2015)" +} + +function testGlobalCompareNP6 \ +{ + testGlobalCompareBaseRed + outFile="JetUncertainties-Final2012-Moriond2016-GlobalReductions-NP6.pdf" + compList="EffectiveNP_6restTerm@EffectiveNP_6restTerm" + compLabels="Global NP6, residual term (2012)@Global NP6, residual term (2015)" +} + +function testGlobalCompareFlavour \ +{ + testGlobalCompareBase + outFile="JetUncertainties-Final2012-Moriond2016-GlobalReductions-flavour.pdf" + compList="Flavor_Composition@Flavor_Response@Flavor_Composition@Flavor_Response" + compLabels="Flavor composition (2012)@Flavor response (2012)@Flavor composition (2015)@Flavor response (2015)" + options=${options/absVal=false/absVal=true} +} + + + +function TAM2016 \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="LRJ_2016/Prerec/TopTagging.config" + outFile="JetUncertainties-TAM-Top-D2.pdf" + #compList="Rtrk_Baseline;Rtrk_Modelling;Rtrk_Tracking1;Rtrk_Tracking2;Rtrk_Tracking3;TAM_Hadronisation#;TAM_Efficiency#;TAM_Fakes#" + #compLabels="Rtrk baseline;Rtrk modelling;Rtrk tracking1;Rtrk tracking2;Rtrk tracking3;TAM had;TAM eff;TAM fakes" + compList="Rtrk_Baseline;Rtrk_Modelling;Rtrk_Tracking1;Rtrk_Tracking2;Rtrk_Tracking3" + compLabels="Rtrk baseline;Rtrk modelling;Rtrk tracking1;Rtrk tracking2;Rtrk tracking3" + #compList="Rtrk_Baseline;TAM_Hadronisation;TAM_Efficiency;TAM_Fakes" + #compLabels="Rtrk baseline (pT);TAM hadronisation;TAM efficiency;TAM fakes" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;doCompare=UJ_2015/Moriond2016/UJ2015_TopTagging_medium.config&MC15&\"Moriond 2016 uncertainty, top tagged\";totalUncName=\"2016 data pre-recommendation\";scaleVar=D2Beta1" + #options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;totalUncName=\"2016 data pre-recommendation\";scaleVar=mass" +} + +function TAM2016Grouped \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="LRJ_2016/Prerec/TopTaggingGrouped.config" + outFile="JetUncertainties-TAM-TopGrouped-mass.pdf" + compList="Baseline_calo;Baseline_TA;Modelling;Tracking1;Tracking2;Tracking3" + compLabels="Baseline (calo);Baseline (TA);Modelling;Tracking 1;Tracking 2;Tracking 3" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;doCompare=UJ_2015/Moriond2016/UJ2015_TopTagging_medium.config&MC15&\"Moriond 2016 uncertainty, top tagged\";totalUncName=\"2016 data pre-recommendation\";scaleVar=CombMass_calo&CombMass_TA&mass" +} + +function TAM2016Grouped2 \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="LRJ_2016/Prerec/TopTaggingGrouped2.config" + outFile="JetUncertainties-TAM-TopGrouped-mass.pdf" + compList="Baseline_Calo;Baseline_TA;Modelling;Tracking1;Tracking2;Tracking3" + compLabels="Baseline (calo);Baseline (TA);Modelling (both);Tracking 1 (both);Tracking 2 (both);Tracking 3 (calo)" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;doCompare=UJ_2015/Moriond2016/UJ2015_TopTagging_medium.config&MC15&\"Moriond 2016 uncertainty, top tagged\";totalUncName=\"2016 data pre-recommendation\";scaleVar=mass" +} + +function CompareLargeR2016ByComp \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15;MC15c;MC15c" + configFile="UJ_2015/Moriond2016/UJ2015_TopTagging.config;LRJ_2016/Prerec/TopTagging_v1.config;LRJ_2016/Prerec/TopTagging.config" + outFile="JetUncertainties-LRJ2016-Comparison-mass.pdf" + compList="Rtrk_Baseline@Rtrk_Baseline@Rtrk_Baseline" + compLabels="Rtrk Baseline (Moriond)@Rtrk Baseline (last week, unsmoothed)@Rtrk Baseline (now, unsmoothed)" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;DrawTotal=false;scaleVar=mass" +} + +function CompareLargeR2016ByComp2 \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c;MC15c" + configFile="LRJ_2016/Prerec/TopTagging_v1.config;LRJ_2016/Prerec/TopTagging.config" + outFile="JetUncertainties-LRJ2016-Comparison2-mass.pdf" + compList="TAM_Fakes_all@TAM_Fakes_all" + compLabels="TAM Fakes (last week, unsmoothed)@TAM Fakes (now, unsmoothed)" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;DrawTotal=false;scaleVar=mass" +} + +function CompareLargeR2016ByCompEta \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c;MC15c;MC15c" + configFile="LRJ_2016/Prerec/TopTagging_central.config;LRJ_2016/Prerec/TopTagging_forward.config;LRJ_2016/Prerec/TopTagging.config" + outFile="JetUncertainties-LRJ2016-ComparisonEta-mass.pdf" + compList="TAM_Fakes_central@TAM_Fakes_forward@TAM_Fakes_all" + compLabels="TAM Fakes (|#eta|<0.4)@TAM Fakes (0.4<|#eta|<2.0)@TAM Fakes (|#eta|<2.0)" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;DrawTotal=false;scaleVar=mass" +} + +function CompareLargeR2016ByTotalEta \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c;MC15c;MC15c" + configFile="LRJ_2016/Prerec/TopTagging_central.config;LRJ_2016/Prerec/TopTagging_forward.config;LRJ_2016/Prerec/TopTagging.config" + outFile="JetUncertainties-LRJ2016-ComparisonEtaTotal-mass.pdf" + compList="TOTAL@TOTAL@TOTAL" + compLabels="Total uncertainty, |#eta|<0.4@Total uncertainty, 0.4<|#eta|<2.0@Total uncertainty, |#eta|<2.0" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;DrawTotal=false;scaleVar=mass" +} + +function CompareLargeR2016ByTotalEtaGrouped \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c;MC15c;MC15c" + configFile="LRJ_2016/Prerec/TopTaggingGrouped2_central.config;LRJ_2016/Prerec/TopTaggingGrouped2_forward.config;LRJ_2016/Prerec/TopTaggingGrouped2.config" + outFile="JetUncertainties-LRJ2016-ComparisonEtaTotal-mComb.pdf" + compList="TOTAL@TOTAL@TOTAL" + compLabels="Total uncertainty, |#eta|<0.4@Total uncertainty, 0.4<|#eta|<2.0@Total uncertainty, |#eta|<2.0" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;DrawTotal=false;scaleVar=mass" +} + + +function LargeR_Final2012_Moriond2016 \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15" + configFile="UJ_2015/Moriond2016/UJ2015_TopTagging_medium.config" + outFile="JetUncertainties-LargeR-Final2012-Moriond2016-mass.pdf" + compList="Rtrk_Baseline;Rtrk_Modelling;Rtrk_Tracking" + compLabels="R_{trk} baseline;R_{trk} modelling;R_{trk} tracking" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;doCompare=UJ_2012/JMS2012_Jul242014_Combined.config&MC12a&\"Final 2012 uncertainty\"&AntiKt10LCTopoTrimmedPtFrac5SmallR30;totalUncName=\"Moriond 2016 uncertainty\";scaleVar=mass" +} + + +function LargeR_ICHEP2016 \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="UJ_2015/ICHEP2016/MultiTagging_all.config" + outFile="JetUncertainties-LargeR-ICHEP2016-SCALEVAR.pdf" + #compList="#Baseline#;#Modelling#;#Tracking#;#TotalStat#" + #compLabels="Baseline;Modelling;Tracking;Total stat." + compList="#Baseline#;#Modelling#;#Tracking1#;#Tracking2#;#Tracking3#;#TotalStat#" + compLabels="Baseline;Modelling;Tracking (efficiency);Tracking (fakes);Tracking (q/p_{T});Total stat." + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;doCompare=UJ_2015/Moriond2016/UJ2015_TOPOLOGY_weak.config&MC15&\"Moriond2016 total uncertainty\";totalUncName=\"ICHEP2016 total uncertainty\";scaleVar=SCALEVAR" +} + +function LargeR_ICHEP2016_pt \ +{ + LargeR_ICHEP2016 + outFile="${outFile/SCALEVAR/pt}" + options="${options/TOPOLOGY/TopTagging}" + options="${options/SCALEVAR/pt}" +} + +function LargeR_ICHEP2016_mass \ +{ + LargeR_ICHEP2016 + outFile="${outFile/SCALEVAR/mass}" + options="${options/TOPOLOGY/TopTagging}" + options="${options/SCALEVAR/mass}" + options="${options};massDef=calo" +} + +function LargeR_ICHEP2016_mTA \ +{ + LargeR_ICHEP2016 + configFile="${configFile/MultiTagging/MultiTagging_TAMass}" + outFile="${outFile/SCALEVAR/mTA}" + options="${options/TOPOLOGY/TopTagging}" + options="${options/SCALEVAR/mass}" + options="${options};massDef=TA" +} + +function LargeR_ICHEP2016_mComb \ +{ + LargeR_ICHEP2016 + configFile="${configFile/MultiTagging/MultiTagging_CombMass}" + outFile="${outFile/SCALEVAR/mComb}" + options="${options/TOPOLOGY/TopTagging}" + options="${options/SCALEVAR/mass}" + options="${options};massDef=comb" +} + +function LargeR_ICHEP2016_tau32 \ +{ + LargeR_ICHEP2016 + outFile="${outFile/SCALEVAR/tau32}" + options="${options/TOPOLOGY/TopTagging}" + options="${options/SCALEVAR/Tau32WTA}" +} + +function LargeR_ICHEP2016_D2 \ +{ + LargeR_ICHEP2016 + outFile="${outFile/SCALEVAR/D2}" + options="${options/TOPOLOGY/WZTagging}" + options="${options/SCALEVAR/D2Beta1}" +} + +function LargeR_ICHEP2016_allmass \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="UJ_2015/ICHEP2016/AllMass.config" + outFile="JetUncertainties-LargeR-ICHEP2016-allmass.pdf" + compList="Calo_Baseline;TAM_Baseline;Calo_Modelling;TAM_Modelling;Calo_Tracking1;TAM_Tracking1;Calo_Tracking2;TAM_Tracking2;Calo_Tracking3" + compLabels="Baseline (calo);Baseline (TA);Modelling (calo);Modelling (TA);Tracking eff. (calo);Tracking eff. (TA);Tracking fakes (calo);Tracking fakes (TA);Tracking q/pT (calo)" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;drawTotal=false;scaleVar=mass;massDef=calo+TA" +} + +function LargeR_ICHEP2016_compareMass \ +{ + local appendConfig="" #"_withcap" + local topology="Multi" #"Top" + + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="UJ_2015/ICHEP2016/${topology}Tagging_CombMass_all${appendConfig}.config;UJ_2015/ICHEP2016/${topology}Tagging_CombMass_all${appendConfig}.config;UJ_2015/ICHEP2016/${topology}Tagging_all.config;UJ_2015/ICHEP2016/${topology}Tagging_TAMass_all.config;UJ_2015/ICHEP2016/${topology}Tagging_CombMass_all${appendConfig}.config" + outFile="JetUncertainties-LargeR-ICHEP2016-masscomp-${topology}${appendConfig}.pdf" + compList="CaloWeight@TAWeight@TOTAL@TOTAL@TOTAL" + compLabels="(Calorimeter weight)/10@(Track-assisted weight)/10@Calorimeter mass@Track-assisted mass@Combined mass" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;drawTotal=false;scaleVar=mass" +} +function LargeR_ICHEP2016_combVsCalo \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="UJ_2015/ICHEP2016/MultiTagging_CombMass_all.config" + outFile="JetUncertainties-LargeR-ICHEP2016-CombMass-CaloMass.pdf" + compList="#Baseline#;#Modelling#;#Tracking1#;#Tracking2#;#Tracking3#;#TotalStat#" + compLabels="Baseline;Modelling;Tracking (efficiency);Tracking (fakes);Tracking (q/p_{T});Total stat." + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;doCompare=UJ_2015/ICHEP2016/MultiTagging_weak.config&MC15c&\"Calorimeter mass total uncertainty\";totalUncName=\"Combined mass total uncertainty\";scaleVar=mass" +} + +function LargeR_ICHEP2016_validation \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + #configFile="UJ_2015/ICHEP2016/WZTagging_CONFIGTYPE.config;UJ_2015/ICHEP2016/HbbTagging_CONFIGTYPE.config;UJ_2015/ICHEP2016/TopTagging_CONFIGTYPE.config;UJ_2015/ICHEP2016/MultiTagging_CONFIGTYPE.config" + #configFile="UJ_2015/ICHEP2016/WZTagging_TAMass_CONFIGTYPE.config;UJ_2015/ICHEP2016/HbbTagging_TAMass_CONFIGTYPE.config;UJ_2015/ICHEP2016/TopTagging_TAMass_CONFIGTYPE.config;UJ_2015/ICHEP2016/MultiTagging_TAMass_CONFIGTYPE.config" + configFile="UJ_2015/ICHEP2016/WZTagging_CombMass_CONFIGTYPE.config;UJ_2015/ICHEP2016/HbbTagging_CombMass_CONFIGTYPE.config;UJ_2015/ICHEP2016/TopTagging_CombMass_CONFIGTYPE.config;UJ_2015/ICHEP2016/MultiTagging_CombMass_CONFIGTYPE.config" + outFile="JetUncertainties-LargeR-ICHEP2016-validation-CONFIGTYPE-SCALEVAR.pdf" + compLabels="Baseline (WZ);Modelling (WZ);Tracking (WZ);Stat (WZ)@Baseline (Hbb);Modelling (Hbb);Tracking (Hbb);Stat (Hbb)@Baseline (Top);Modelling (Top);Tracking (Top);Stat (Top)@Baseline (MT);Modelling (MT);Tracking (MT);Stat (MT)" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;drawTotal=false;scaleVar=SCALEVAR" +} + +function LargeR_ICHEP2016_validation_weak \ +{ + LargeR_ICHEP2016_validation + configFile="${configFile//CONFIGTYPE/weak}" + outFile="${outFile//CONFIGTYPE/weak}" + if [[ $configFile = *_TAMass_* ]] ; then + compListBase="Rtrk_Baseline_pT,TAM_Baseline_mass,Rtrk_Baseline_D2;Rtrk_Modelling_pT,TAM_Modelling_mass,Rtrk_Modelling_D2;Rtrk_Tracking_pT,TAM_Tracking_mass,Rtrk_Tracking_D2;Rtrk_TotalStat_pt,TAM_TotalStat_mass,Rtrk_TotalStat_D2" + elif [[ $configFile = *_CombMass_* ]] ; then + compListBase="Rtrk_Baseline_pT,Comb_Baseline_mass,Rtrk_Baseline_D2;Rtrk_Modelling_pT,Comb_Modelling_mass,Rtrk_Modelling_D2;Rtrk_Tracking_pT,Comb_Tracking_mass,Rtrk_Tracking_D2;Rtrk_TotalStat_pt,Comb_TotalStat_mass,Rtrk_TotalStat_D2" + else + compListBase="Rtrk_Baseline_pT,Rtrk_Baseline_mass,Rtrk_Baseline_D2;Rtrk_Modelling_pT,Rtrk_Modelling_mass,Rtrk_Modelling_D2;Rtrk_Tracking_pT,Rtrk_Tracking_mass,Rtrk_Tracking_D2;Rtrk_TotalStat_pT,Rtrk_TotalStat_mass,Rtrk_TotalStat_D2" + fi + compList="$compListBase@$compListBase@${compListBase//D2/Tau32}" + if [[ $configFile = *_TAMass_* ]] ; then + compList="${compList}@Rtrk_Baseline_pT,TAM_Baseline_mass,Rtrk_Baseline_D2,Rtrk_Baseline_Tau32;Rtrk_Modelling_pT,TAM_Modelling_mass,Rtrk_Modelling_D2,Rtrk_Modelling_Tau32;Rtrk_Tracking_pT,TAM_Tracking_mass,Rtrk_Tracking_D2,Rtrk_Tracking_Tau32;Rtrk_TotalStat_pT,TAM_TotalStat_mass,Rtrk_TotalStat_D2,Rtrk_TotalStat_Tau32" + elif [[ $configFile = *_CombMass_* ]] ; then + compList="${compList}@Rtrk_Baseline_pT,Comb_Baseline_mass,Rtrk_Baseline_D2,Rtrk_Baseline_Tau32;Rtrk_Modelling_pT,Comb_Modelling_mass,Rtrk_Modelling_D2,Rtrk_Modelling_Tau32;Rtrk_Tracking_pT,Comb_Tracking_mass,Rtrk_Tracking_D2,Rtrk_Tracking_Tau32;Rtrk_TotalStat_pT,Comb_TotalStat_mass,Rtrk_TotalStat_D2,Rtrk_TotalStat_Tau32" + else + compList="${compList}@Rtrk_Baseline_pT,Rtrk_Baseline_mass,Rtrk_Baseline_D2,Rtrk_Baseline_Tau32;Rtrk_Modelling_pT,Rtrk_Modelling_mass,Rtrk_Modelling_D2,Rtrk_Modelling_Tau32;Rtrk_Tracking_pT,Rtrk_Tracking_mass,Rtrk_Tracking_D2,Rtrk_Tracking_Tau32;Rtrk_TotalStat_pT,Rtrk_TotalStat_mass,Rtrk_TotalStat_D2,Rtrk_TotalStat_Tau32" + fi +} + +function LargeR_ICHEP2016_validation_weak_pt \ +{ + LargeR_ICHEP2016_validation_weak + outFile="${outFile/SCALEVAR/pt}" + options="${options/SCALEVAR/pt}" +} + +function LargeR_ICHEP2016_validation_weak_mass \ +{ + LargeR_ICHEP2016_validation_weak + outFile="${outFile/SCALEVAR/mass}" + options="${options/SCALEVAR/mass}" +} + +function LargeR_ICHEP2016_validation_weak_sub \ +{ + LargeR_ICHEP2016_validation_weak + outFile="${outFile/SCALEVAR/sub}" + options="${options/SCALEVAR/D2Beta1&Tau32WTA}" +} + +function LargeR_ICHEP2016_validation_weak_D2 \ +{ + LargeR_ICHEP2016_validation_weak + outFile="${outFile/SCALEVAR/D2}" + options="${options/SCALEVAR/D2Beta1}" +} + +function LargeR_ICHEP2016_validation_weak_tau32 \ +{ + LargeR_ICHEP2016_validation_weak + outFile="${outFile/SCALEVAR/tau32}" + options="${options/SCALEVAR/Tau32WTA}" +} + +function LargeR_ICHEP2016_validation_medium \ +{ + LargeR_ICHEP2016_validation + configFile="${configFile//CONFIGTYPE/medium}" + outFile="${outFile//CONFIGTYPE/medium}" + if [[ $configFile = *_TAMass_* ]] ; then + compListBase="TAM_Baseline_Kin,Rtrk_Baseline_D2;TAM_Modelling_Kin,Rtrk_Modelling_D2;TAM_Tracking_Kin,Rtrk_Tracking_D2;TAM_TotalStat_Kin,Rtrk_TotalStat_D2" + elif [[ $configFile = *_CombMass_* ]] ; then + compListBase="Comb_Baseline_Kin,Rtrk_Baseline_D2;Comb_Modelling_Kin,Rtrk_Modelling_D2;Comb_Tracking_Kin,Rtrk_Tracking_D2;Comb_TotalStat_Kin,Rtrk_TotalStat_D2" + else + compListBase="Rtrk_Baseline_Kin,Rtrk_Baseline_D2;Rtrk_Modelling_Kin,Rtrk_Modelling_D2;Rtrk_Tracking_Kin,Rtrk_Tracking_D2;Rtrk_TotalStat_Kin,Rtrk_TotalStat_D2" + fi + compList="$compListBase@$compListBase@${compListBase//D2/Tau32}" + if [[ $configFile = *_TAMass_* ]] ; then + compList="${compList}@TAM_Baseline_Kin,Rtrk_Baseline_Sub;TAM_Modelling_Kin,Rtrk_Modelling_Sub;TAM_Tracking_Kin,Rtrk_Tracking_Sub;TAM_TotalStat_Kin,Rtrk_TotalStat_Sub" + elif [[ $configFile = *_CombMass_* ]] ; then + compList="${compList}@Comb_Baseline_Kin,Rtrk_Baseline_Sub;Comb_Modelling_Kin,Rtrk_Modelling_Sub;Comb_Tracking_Kin,Rtrk_Tracking_Sub;Comb_TotalStat_Kin,Rtrk_TotalStat_Sub" + else + compList="${compList}@Rtrk_Baseline_Kin,Rtrk_Baseline_Sub;Rtrk_Modelling_Kin,Rtrk_Modelling_Sub;Rtrk_Tracking_Kin,Rtrk_Tracking_Sub;Rtrk_TotalStat_Kin,Rtrk_TotalStat_Sub" + fi +} + +function LargeR_ICHEP2016_validation_medium_pt \ +{ + LargeR_ICHEP2016_validation_medium + outFile="${outFile/SCALEVAR/pt}" + options="${options/SCALEVAR/pt}" +} + +function LargeR_ICHEP2016_validation_medium_mass \ +{ + LargeR_ICHEP2016_validation_medium + outFile="${outFile/SCALEVAR/mass}" + options="${options/SCALEVAR/mass}" +} + +function LargeR_ICHEP2016_validation_medium_sub \ +{ + LargeR_ICHEP2016_validation_medium + outFile="${outFile/SCALEVAR/sub}" + options="${options/SCALEVAR/D2Beta1&Tau32WTA}" +} + +function LargeR_ICHEP2016_validation_medium_D2 \ +{ + LargeR_ICHEP2016_validation_medium + outFile="${outFile/SCALEVAR/D2}" + options="${options/SCALEVAR/D2Beta1}" +} + +function LargeR_ICHEP2016_validation_medium_tau32 \ +{ + LargeR_ICHEP2016_validation_medium + outFile="${outFile/SCALEVAR/tau32}" + options="${options/SCALEVAR/Tau32WTA}" +} + +function LargeR_ICHEP2016_validation_strong \ +{ + LargeR_ICHEP2016_validation + configFile="${configFile//CONFIGTYPE/strong}" + outFile="${outFile//CONFIGTYPE/strong}" + if [[ $configFile = *_TAMass_* ]] ; then + compListBase="TAM_Baseline_All;TAM_Modelling_All;TAM_Tracking_All;TAM_TotalStat_All" + elif [[ $configFile = *_CombMass_* ]] ; then + compListBase="Comb_Baseline_All;Comb_Modelling_All;Comb_Tracking_All;Comb_TotalStat_All" + else + compListBase="Rtrk_Baseline_All;Rtrk_Modelling_All;Rtrk_Tracking_All;Rtrk_TotalStat_All" + fi + compList="$compListBase@$compListBase@$compListBase@$compListBase" +} + +function LargeR_ICHEP2016_validation_strong_pt \ +{ + LargeR_ICHEP2016_validation_strong + outFile="${outFile/SCALEVAR/pt}" + options="${options/SCALEVAR/pt}" +} + +function LargeR_ICHEP2016_validation_strong_mass \ +{ + LargeR_ICHEP2016_validation_strong + outFile="${outFile/SCALEVAR/mass}" + options="${options/SCALEVAR/mass}" +} + +function LargeR_ICHEP2016_validation_strong_sub \ +{ + LargeR_ICHEP2016_validation_strong + outFile="${outFile/SCALEVAR/sub}" + options="${options/SCALEVAR/D2Beta1&Tau32WTA}" +} + +function LargeR_ICHEP2016_validation_strong_D2 \ +{ + LargeR_ICHEP2016_validation_strong + outFile="${outFile/SCALEVAR/D2}" + options="${options/SCALEVAR/D2Beta1}" +} + +function LargeR_ICHEP2016_validation_strong_tau32 \ +{ + LargeR_ICHEP2016_validation_strong + outFile="${outFile/SCALEVAR/tau32}" + options="${options/SCALEVAR/Tau32WTA}" +} + + +function LargeR_ICHEP2016_mCalo \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="UJ_2015/ICHEP2016/MultiTagging_all.config" + outFile="JetUncertainties-LargeR-ICHEP2016-public-mCalo.pdf" + compList="#Baseline#;#Modelling#;#Tracking1#;#Tracking2#;#Tracking3#;#TotalStat#" + compLabels="Baseline;Modelling;Tracking (TIDE);Tracking (fakes);Tracking (q/p_{T});Statistical" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;totalUncName=\"Total m_{calo} uncertainty\";scaleVar=mass;isPublic=true;axisMax=0.30" +} +function LargeR_ICHEP2016_mTA \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="UJ_2015/ICHEP2016/MultiTagging_TAMass_all.config" + outFile="JetUncertainties-LargeR-ICHEP2016-public-mTA.pdf" + compList="#Baseline#;#Modelling#;#Tracking1#;#Tracking2#;#Tracking3#;#TotalStat#" + compLabels="Baseline;Modelling;Tracking (TIDE);Tracking (fakes);Tracking (q/p_{T});Statistical" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;doCompare=UJ_2015/ICHEP2016/MultiTagging_weak.config&MC15c&\"Total m_{calo} uncertainty\";totalUncName=\"Total m_{TA} uncertainty\";scaleVar=mass;isPublic=true;axisMax=0.30" +} +function LargeR_ICHEP2016_pT \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="UJ_2015/ICHEP2016/MultiTagging_all.config" + outFile="JetUncertainties-LargeR-ICHEP2016-public-pT.png" + compList="#Baseline#;#Modelling#;#Tracking1#,#Tracking2#,#Tracking3#;#TotalStat#" + compLabels="R_{trk} baseline (Pythia 8);R_{trk} modelling (Herwig++);R_{trk} tracking;Statistical" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;totalUncName=\"Total uncertainty\";scaleVar=pT;isPublic=true;axisMax=0.30" +} +function LargeR_ICHEP2016_D2 \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="UJ_2015/ICHEP2016/MultiTagging_all.config" + outFile="JetUncertainties-LargeR-ICHEP2016-public-D2.png" + compList="#Baseline#;#Modelling#;#Tracking1#,#Tracking2#,#Tracking3#;#TotalStat#" + compLabels="R_{trk} baseline (Pythia 8);R_{trk} modelling (Herwig++);R_{trk} tracking;Statistical" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;totalUncName=\"Total uncertainty\";scaleVar=D2Beta1;isPublic=true;axisMax=0.30" +} +function LargeR_ICHEP2016_Tau32 \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="UJ_2015/ICHEP2016/MultiTagging_all.config" + outFile="JetUncertainties-LargeR-ICHEP2016-public-Tau32.png" + compList="#Baseline#;#Modelling#;#Tracking1#,#Tracking2#,#Tracking3#;#TotalStat#" + compLabels="R_{trk} baseline (Pythia 8);R_{trk} modelling (Herwig++);R_{trk} tracking;Statistical" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;totalUncName=\"Total uncertainty\";scaleVar=Tau32WTA;isPublic=true;axisMax=0.30" +} + + + + +SRNum=1 +function ICHEP2016_validation_SR \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/ICHEP2016/JES2015_SR_ScenarioAll.config;JES_2015/ICHEP2016/JES2015_SR_Scenario${SRNum}.config" + outFile="JetUncertainties-ICHEP2016-SRval-${SRNum}.pdf" + compList="GroupedNP_SR${SRNum}_1;GroupedNP_SR${SRNum}_2;GroupedNP_SR${SRNum}_3@GroupedNP_1;GroupedNP_2;GroupedNP_3" + compLabels="SRAll Grouped NP 1;SRAll Grouped NP 2;SRAll Grouped NP 3@SR${SRNum} Grouped NP 1;SR${SRNum} Grouped NP 2;SR${SRNum} Grouped NP 3" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=false" +} +function ICHEP2016_SRall \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/ICHEP2016/JES2015_SR_ScenarioAll.config" + outFile="JetUncertainties-ICHEP2016-SRAll.pdf" + compList="EtaIntercalibration_NonClosure;RelativeNonClosure_MC15;GroupedNP_SR1_1;GroupedNP_SR1_2;GroupedNP_SR1_3;GroupedNP_SR2_1;GroupedNP_SR2_2;GroupedNP_SR2_3;GroupedNP_SR3_1;GroupedNP_SR3_2;GroupedNP_SR3_3;GroupedNP_SR4_1;GroupedNP_SR4_2;GroupedNP_SR4_3" + compLabels="EtaIntercalibration_NonClosure;RelativeNonClosure_MC15;GroupedNP_SR1_1;GroupedNP_SR1_2;GroupedNP_SR1_3;GroupedNP_SR2_1;GroupedNP_SR2_2;GroupedNP_SR2_3;GroupedNP_SR3_1;GroupedNP_SR3_2;GroupedNP_SR3_3;GroupedNP_SR4_1;GroupedNP_SR4_2;GroupedNP_SR4_3" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=false" +} +function ICHEP2016_SR1_NP1 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/ICHEP2016/JES2015_SR_ScenarioAll.config;JES_2015/ICHEP2016/JES2015_19NP.config" + outFile="JetUncertainties-ICHEP2016-SR1-NP1.pdf" + compList="GroupedNP_SR1_1@EffectiveNP_1;Pileup_OffsetMu;Pileup_OffsetNPV;Pileup_PtTerm;Pileup_RhoTopology;Flavor_Composition;Flavor_Response" + compLabels="GroupedNP_SR1_1@EffectiveNP_1;Pileup_OffsetMu;Pileup_OffsetNPV;Pileup_PtTerm;Pileup_RhoTopology;Flavor_Composition;Flavor_Response" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=false" +} +function ICHEP2016_SR1_NP2 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/ICHEP2016/JES2015_SR_ScenarioAll.config;JES_2015/ICHEP2016/JES2015_19NP.config" + outFile="JetUncertainties-ICHEP2016-SR1-NP2.pdf" + compList="GroupedNP_SR1_2@EffectiveNP_2;EffectiveNP_3;EffectiveNP_4;EffectiveNP_5;EffectiveNP_6restTerm;EtaIntercalibration_TotalStat" + compLabels="GroupedNP_SR1_2@EffectiveNP_2;EffectiveNP_3;EffectiveNP_4;EffectiveNP_5;EffectiveNP_6restTerm;EtaIntercalibration_TotalStat" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=false" +} +function ICHEP2016_SR1_NP3 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/ICHEP2016/JES2015_SR_ScenarioAll.config;JES_2015/ICHEP2016/JES2015_19NP.config" + outFile="JetUncertainties-ICHEP2016-SR1-NP3.pdf" + compList="GroupedNP_SR1_3@EtaIntercalibration_Modelling;SingleParticle_HighPt" + compLabels="GroupedNP_SR1_3@EtaIntercalibration_Modelling;SingleParticle_HighPt" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=false" +} + + + + + +function LargeR_Moriond2016_Run1 \ +{ + # July 2014 large-R jet release + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15" + configFile="UJ_2015/Moriond2016/UJ2015_WZTagging.config" + outFile="JetUncertainties-Moriond2016-Run1-pT.pdf" + compList="Rtrk_Baseline;Rtrk_Modelling;Rtrk_Tracking1;Rtrk_Tracking2;Rtrk_Tracking3" + compLabels="R_{trk} baseline;R_{trk} modelling;R_{trk} tracking 1;R_{trk} tracking 2;R_{trk} tracking 3" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;totalUncName=\"Total Uncertainty, Moriond2016\";scaleVar=pT;doCompare=UJ_2015/Prerec/Prerec2015_OnlyRun1.config&MC15&\"Total R_{trk} uncertainty, 2012\"" +} + + +function ICHEP2016_AllEtaInt \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2015/ICHEP2016/JES2015_AllNuisanceParameters.config;JES_2015/ICHEP2016/JES2015_AllNuisanceParameters_AllEtaIntStat.config" + outFile="JetUncertainties-ICHEP2016-AllEtaIntStat.pdf" + compList="EtaIntercalibration_TotalStat@EtaIntercalibration_Stat#;EtaIntercalibration_TotalStat#" + compLabels="TotalStat term (all combined)@246 split stat NPs;TotalStat propagated through MJB" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=false;axisMax=0.02" +} + + +function YearCompare_GlobalReduction \ +{ + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo;AntiKt4EMTopo;AntiKt4LCTopo;AntiKt4EMTopo" + MCtype="MC11c;MC11c;MC12;MC12;MC15" + configFile="JES_2011/Final/InsituJES2011_12NP.config;JES_2011/Final/InsituJES2011_12NP.config;JES_2012/Final/InsituJES2012_14NP.config;JES_2012/Final/InsituJES2012_14NP.config;JES_2015/ICHEP2016/JES2015_19NP.config" + outFile="JetUncertainties-YearCompare-${COMPNAME}.pdf" + compList="$COMPNAME@$COMPNAME@$COMPNAME@$COMPNAME@$COMPNAME" + compLabels="$COMPNAME (EM4, 2011)@$COMPNAME (LC4, 2011)@$COMPNAME (EM4, 2012)@$COMPNAME (LC4, 2012)@$COMPNAME (EM4, 2016)" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=false;fixedPtVals=100;fixedEtaVals=0;axisMax=0.04" +} + +function ReclusteredUsingLargeR_validation \ +{ + var="pT" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + #configFile="UJ_2015/ICHEP2016/ReclusteredJets_strong.config" + configFile="UJ_2015/ICHEP2016/ReclusteredJets_onlymass.config" + outFile="JetUncertainties-LargeR-RC-ICHEP2016-${var}.pdf" + compList="#Baseline#;#Modelling#;#Tracking#;#TotalStat#" + compLabels="Baseline;Modelling;Tracking;Statistical" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;scaleVar=${var};isPublic=false;axisMax=0.30" +} + +function Moriond2017_LargeR \ +{ + var="pT" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="UJ_2016/Moriond2017/UJ2016_CombinedMass_weak_all.config" + outFile="JetUncertainties-LargeR-Moriond2017-${var}.pdf" + compList="#Baseline#;#Modelling#;#Tracking#;#TotalStat#" + compLabels="Baseline;Modelling;Tracking;Statistical" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;scaleVar=${var};isPublic=false;axisMax=0.30;VariablesToShift=Tau32WTA,D2Beta1,Split12" +} + +function LargeR_Moriond2017_compareMass \ +{ + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="UJ_2016/Moriond2017/UJ2016_CombinedMass_weak.config;UJ_2016/Moriond2017/UJ2016_CombinedMass_weak.config;UJ_2016/Moriond2017/UJ2016_CaloMass_weak.config;UJ_2016/Moriond2017/UJ2016_TrackAssistedMass_weak.config;UJ_2016/Moriond2017/UJ2016_CombinedMass_weak.config" + outFile="JetUncertainties-LargeR-Moriond2017-masscomp.pdf" + compList="CaloWeight@TAWeight@TOTAL@TOTAL@TOTAL" + compLabels="(Calorimeter weight)/10@(Track-assisted weight)/10@Calorimeter mass@Track-assisted mass@Combined mass" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;drawTotal=false;scaleVar=mass" + #options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;drawTotal=false;scaleVar=mass;xAxisRange=20&1000" +} + +function SmallRMass_Extrap \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017/JES2016_AllNuisanceParameters_JMSExtrap.config" + outFile="JetUncertainties-SmallRMass-Extrap.pdf" + compList="Rtrk_Baseline#;Rtrk_Modelling#;Rtrk_Tracking#;Rtrk_TotalStat#" + compLabels="Basline;Modelling;Tracking;Statistical" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;scaleVar=mass;totalUncName=\"Total uncertainty, extrapolated\";ptBins=L&2000&20&3000;xAxisRange=20&3000" +} + +function SmallRMass_Frozen \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017/JES2016_AllNuisanceParameters_JMSFrozen.config" + outFile="JetUncertainties-SmallRMass-Frozen.pdf" + compList="Rtrk_Baseline#;Rtrk_Modelling#;Rtrk_Tracking#;Rtrk_TotalStat#" + compLabels="Basline;Modelling;Tracking;Statistical" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;scaleVar=mass;totalUncName=\"Total uncertainty, frozen\";ptBins=L&2000&20&3000;xAxisRange=20&3000" +} + +function ValidateSmallRMassConfig \ +{ + scale="pT" + #scale="FourVec" + #scale="mass" + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017/JES2016_AllNuisanceParameters.config;JES_2016/Moriond2017/JES2016_AllNuisanceParameters_JMSExtrap.config" + outFile="JetUncertainties-SmallRMass-Validation-${scale}.pdf" + compList="TOTAL@TOTAL" + compLabels="Config without JMS@Config with JMS" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;drawTotal=false;scaleVar=${scale};axisMax=0.05;ptBins=L&2000&20&3000;xAxisRange=20&3000" +} + +function ValidateSmallRMassConfigs \ +{ + #scale="pT" + scale="mass" + JMSTYPE="JMSExtrap" + #JMSTYPE="JMSFrozen" + + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017/JES2016_AllNuisanceParameters_${JMSTYPE}.config;JES_2016/Moriond2017/JES2016_29NP_ByCategory_${JMSTYPE}.config;JES_2016/Moriond2017/JES2016_21NP_${JMSTYPE}.config;JES_2016/Moriond2017/JES2016_SR_Scenario1_${JMSTYPE}.config;JES_2016/Moriond2017/JES2016_SR_Scenario2_${JMSTYPE}.config;JES_2016/Moriond2017/JES2016_SR_Scenario3_${JMSTYPE}.config;JES_2016/Moriond2017/JES2016_SR_Scenario4_${JMSTYPE}.config" + outFile="JetUncertainties-SmallRMass-ValidationSet-${scale}-${JMSTYPE}.pdf" + compList="TOTAL@TOTAL@TOTAL@TOTAL@TOTAL@TOTAL@TOTAL" + compLabels="All NP@Category@Global@SR1@SR2@SR3@SR4" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;drawTotal=false;scaleVar=${scale};axisMax=0.1;ptBins=L&2000&20&3000;xAxisRange=20&3000" +} + +function LargeRstatBug \ +{ + scale="pT" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="UJ_2016/Moriond2017/UJ2016_CombinedMass_weak_all.config;UJ_2016/Moriond2017/ShowBadStatUnc.config" + outFile="JetUncertainties-LargeR-StatBug-${scale}.pdf" + compList="#TotalStat#;TOTAL@#TotalStat#;TOTAL" + compLabels="Statistical term (fixed);Total uncertainty (fixed)@Statistical term (buggy);Total uncertainty (buggy)" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;drawTotal=false;scaleVar=${scale}" +} + +function EtaIntModComp \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC11b;MC12" + configFile="JES_2011/Final/InsituJES2011_AllNuisanceParameters.config;JES_2012/Final/InsituJES2012_AllNuisanceParameters.config" + outFile="JetUncertainties-EtaIntModComp.pdf" + compList="EtaIntercalibration_Mod#;TOTAL@EtaIntercalibration_Mod#;TOTAL" + compLabels="2011 #eta-intercal modelling;2011 total@2012 #eta-intercal modelling;2012 total" + options="isDijet=false;isLargeR=false;prefix=JET_;drawTotal=false" +} + +function LargeR_Moriond2017_ICHEP2016 \ +{ + #scale="pT" + scale="mass" + #scale="D2Beta1" + #scale="Tau32WTA" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC15c" + configFile="UJ_2016/Moriond2017/UJ2016_CombinedMass_weak_all.config" + outFile="JetUncertainties-Moriond2017-ICHEP2016-${scale}.pdf" + compList="#Baseline#;#Modelling#;#Tracking#;#TotalStat#" + compLabels="Baseline;Modelling;Tracking;Total stat." + #options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;scaleVar=${scale};totalUncName=\"Total uncertainty\"" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;scaleVar=${scale};totalUncName=\"Total uncertainty\";doCompare=UJ_2015/ICHEP2016/MultiTagging_all.config&MC15c&\"ICHEP2016\"" +} + +function Moriond2017_OnlyFlavourSplit \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017/JES2016_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2017-Flavour-dijet.pdf" + compList="Flavor_Response_orig;Flavor_Response_prop;Flavor_Composition_orig;Flavor_Composition_prop" + compLabels="Flavour Response;MJB-propagated Flavour Response;Flavour Composition;MJB-propagated Flavour Composition" + options="isDijet=true;prefix=JET_" +} + + + +function Moriond2018_LargeR \ +{ + var="pT" + massDef="CombMass" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16a" + configFile="rel21/Moriond2018/R10_${massDef}_all.config" + outFile="JetUncertainties-LargeR-Moriond2018-${var}.pdf" + compList="#Baseline#;#Modelling#;#Tracking#;#TotalStat#" + compLabels="Baseline;Modelling;Tracking;Statistical" + totalUnc="Total uncertainty" + if [[ $var = "mass" ]] ; then + if [[ $massDef = "CombMass" ]] ; then + totalUnc="$totalUnc, m_{comb}" + elif [[ $massDef = "TAMass" ]] ; then + totalUnc="$totalUnc, m_{TA}" + elif [[ $massDef = "CaloMass" ]] ; then + totalUnc="$totalUnc, m_{calo}" + else + totalUnc="$totalUnc, mass" + fi + else + totalUnc="$totalUnc, $var" + fi + + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;scaleVar=${var};isPublic=false;axisMax=0.30;totalUncName=\"$totalUnc\"" +} + +function Moriond2018_LargeR_Validation \ +{ + var="pT" + massDef="CombMass" + scenario="strong" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16a" + configFile="rel21/Moriond2018/R10_${massDef}_all.config;rel21/Moriond2018/R10_${massDef}_${scenario}.config" + outFile="JetUncertainties-LargeR-Moriond2018-${scenario}-${massDef}-${var}.pdf" + compList="#Baseline#;#Modelling#;#Tracking#;#TotalStat#@#Baseline#;#Modelling#;#Tracking#;#TotalStat#" + compLabels="Baseline (all);Modelling (all);Tracking (all);Statistical (all)@Baseline ($scenario);Modelling ($scenario);Tracking ($scenario);Statistical ($scenario)" + options="isDijet=false;isLargeR=true;prefix=JET_;specifyTagger=false;scaleVar=${var};isPublic=false;axisMax=0.30" +} + +function Moriond2018 \ +{ + + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + configFile="rel21/Moriond2018/R4_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2018-Nominal.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_" +} + +function Moriond2018_EMvsPF \ +{ + + jetDefinition="AntiKt4EMPFlow" + MCtype="MC16" + configFile="rel21/Moriond2018/R4_AllNuisanceParameters.config" + outFile="JetUncertainties-Moriond2018-Nominal-Compare.pdf" + compList="LAr#,Zjet#,Gjet#,MJB#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;doCompare=rel21/Moriond2018/R4_AllNuisanceParameters.config&MC16&Total uncertainty, EMTopo&AntiKt4EMTopo;totalUncName=\"Total uncertainty, EMPFlow\"" +} + +####################################### +## Fall 2018 functions + +function PreFall2018_forMJB \ +{ + + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + configFile="JetUncertainties/rel21/Fall2018/R4_JESNuisanceParametersForMJB.config" + outFile="Fall2018/JetUncertainties-IntoMJB_Fall2018.pdf" + compList="Zjet#,Gjet#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#;" + compLabels="Absolute #it{in situ} JES (Z,#gamma+jet);Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;bunchSpacing=25;fixedPtVals=25,40,60,80,100,120;path=/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/share/" + +} + +function PreFall2018_forMJB_comparePFlowEMTopo \ +{ + + # Load default Fall 2018 release + PreFall2018_forMJB + # Override variables + jetDefinition="AntiKt4EMTopo" + outFile="Fall2018/JetUncertainties-Fall2018-intoMJB-ComparePFlowEMTopo.pdf" + options="${options};doCompare=JetUncertainties/rel21/Fall2018/R4_JESNuisanceParametersForMJB.config&MC16&PFlow uncertainty&AntiKt4EMPFlow" + +} + +function Fall2018 \ +{ + + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + configFile="rel21/Fall2018/R4_AllNuisanceParameters_AllJERNP.config" + outFile="Fall2018/JetUncertainties-Fall2018-AllComponents-unknownComp.pdf" + compList="LAr#,Zjet#,Gjet#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;path=/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/share/" +} + +function Fall2018_Dijet \ +{ + + Fall2018 + outFile="Fall2018/JetUncertainties-Fall2018-AllComponents-dijetComp.pdf" + options="isDijet=true;isGSC=true;isLargeR=false;prefix=JET_;path=/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/share/" +} + +function Fall2018_GlobalReduction \ +{ + # Load default Moriond 2018 release + Fall2018 + # Override variables + configFile="rel21/Fall2018/R4_GlobalReduction_FullJER.config" + outFile="Fall2018/JetUncertainties-Fall2018-Unknown-GlobalReduction.pdf" + compList="EffectiveNP#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + +} + +function Fall2018_CategoryReduction \ +{ + # Load default Moriond 2018 release + Fall2018 + # Override variables + configFile="rel21/Fall2018/R4_CategoryReduction.config" + outFile="Fall2018/JetUncertainties-Fall2018-Unknown-CategoryReduction.pdf" + compList="EffectiveNP#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + +} + + +####################################### +## Fall 2018 special + +function Fall2018_fullStat_20152016 \ +{ + + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + configFile="rel21/Fall2018_fullStatUncertanties/R4_AllNuisanceParameters_2015_16_AllJERNP.config" + outFile="Fall2018_fullStatUncertanties/JetUncertainties-Fall2018-AllStatTerms-2016-2016-unknownComp.pdf" + compList="Zjet#,Gjet#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;path=/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/share/" +} + +function Fall2018_fullStat_2017 \ +{ + + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + configFile="rel21/Fall2018_fullStatUncertanties/R4_AllNuisanceParameters_2017_AllJERNP.config" + outFile="Fall2018_fullStatUncertanties/JetUncertainties-Fall2018-AllStatTerms-2017-unknownComp.pdf" + compList="Zjet#,Gjet#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;path=/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/share/" +} + +function Fall2018_fullStat_20152016_testNoJER \ +{ + + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + configFile="rel21/Fall2018_fullStatUncertanties/R4_AllNuisanceParameters_2015_16_NoJER.config" + outFile="Fall2018_fullStatUncertanties/JetUncertainties-Fall2018-AllStatTerms-2016-2016-unknownComp-noJER.pdf" + compList="Zjet#,Gjet#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;path=/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/share/" +} + +function Fall2018_fullStat_2017_testNoJER \ +{ + + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + configFile="rel21/Fall2018_fullStatUncertanties/R4_AllNuisanceParameters_2017_NoJER.config" + outFile="Fall2018_fullStatUncertanties/JetUncertainties-Fall2018-AllStatTerms-2017-unknownComp-noJER.pdf" + compList="Zjet#,Gjet#,SingleParticle#;EtaIntercalib#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Pileup;Punch-through;" + options="isDijet=false;isGSC=true;isLargeR=false;prefix=JET_;path=/afs/cern.ch/work/k/kpachal/JetUncertainties/JetUncertainties/athena/Reconstruction/Jet/JetUncertainties/share/" +} + +####################################### +# Older + +function testRel21AFII \ +{ + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="AFII" + configFile="rel21/Moriond2018/R4_AllNuisanceParameters.config" + outFile="JetUncertainties-rel21-R4-${MCtype}-RhoTop.pdf" + compList="RelativeNonClosure#;Pileup_RhoTopology" + compLabels="RelativeNonClosure_${MCtype};Pileup_RhoTopology" + options="isDijet=false;prefix=JET_" +} + +function Rel20p7_EffNP1 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017/JES2016_AllNuisanceParameters.config;JES_2016/Moriond2017/JES2016_21NP.config" + outFile="JetUncertainties-rel20p7-EffNP1.pdf" + compList="Zjet_MC,Zjet_Veto,LAr_Jvt@EffectiveNP_1" + compLabels="Zjet (MC+Veto) + LAr JVT@EffectiveNP_1" + options="isDijet=false;prefix=JET_;fixedEtaVals=0;fixedPtVals=40;drawTotal=false" +} + +function Rel20p7_EffNP2 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + configFile="JES_2016/Moriond2017/JES2016_AllNuisanceParameters.config;JES_2016/Moriond2017/JES2016_21NP.config" + outFile="JetUncertainties-rel20p7-EffNP2.pdf" + compList="LAr_ESZee,Gjet_Generator,INV__Gjet_Purity@EffectiveNP_2" + compLabels="#gamma+jet (Generator-Purity) + LAr ES(Zee)@EffectiveNP_2" + options="isDijet=false;prefix=JET_;fixedEtaVals=0;fixedPtVals=40;drawTotal=false" +} + +function Rel21_EffNP1 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC16" + CalibArea="CalibArea-02" + configFile="rel21/Moriond2018/R4_AllNuisanceParameters.config;rel21/Moriond2018/R4_GlobalReduction.config" + outFile="JetUncertainties-rel21-EffNP1.pdf" + compList="Zjet_MC,Zjet_Veto,Zjet_JVT@EffectiveNP_1" + compLabels="Zjet MC+JVT+Veto@EffectiveNP_1" + options="isDijet=false;prefix=JET_;fixedEtaVals=0;fixedPtVals=40;drawTotal=false" +} + +function Rel21_EffNP2 \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC16" + CalibArea="CalibArea-02" + configFile="rel21/Moriond2018/R4_AllNuisanceParameters.config;rel21/Moriond2018/R4_GlobalReduction.config" + outFile="JetUncertainties-rel21-EffNP2.pdf" + compList="Gjet_GamESZee,Gjet_Generator,INV__Gjet_Purity@EffectiveNP_2" + compLabels="#gamma+jet ES(Zee)+Generator-Purity@EffectiveNP_2" + options="isDijet=false;prefix=JET_;fixedEtaVals=0;fixedPtVals=40;drawTotal=false" +} + +function testDefaultNjets \ +{ + njet=0 + + jetDefinition="AntiKt4EMTopo" + MCtype="MC16" + CalibArea="CalibArea-03" + configFile="rel21/Moriond2018/R4_AllNuisanceParameters.config" + outFile="JetUncertainties-Njets-${njet}.pdf" + compList="Flavor_Response;Flavor_Composition" + compLabels="Flavor_Response;Flavor_Composition" + options="prefix=JET_;fixedEtaVals=0;fixedPtVals=40;NjetFlavour=${njet};Composition=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/Inputs/ANALYSISTO-370.root" +} + +function testPerJetFlavour \ +{ + label=21 + + jetDefinition="AntiKt4EMTopo" + MCtype="MC16" + CalibArea="CalibArea-03" + configFile="rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour.config" + outFile="JetUncertainties-TruthLabel-${label}.pdf" + compList="FlavorResponse_PerJet#;Flavor_Composition" + compLabels="FlavorResponse_PerJet ${label};Flavor_Composition" + options="prefix=JET_;fixedEtaVals=0;fixedPtVals=40;TruthLabel=${label};path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/" +} + +function CompareFlavourBinning \ +{ + label=21 + + jetDefinition="AntiKt4EMTopo" + MCtype="MC16" + CalibArea="CalibArea-04" + #configFile="rel21/Moriond2018/R4_AllNuisanceParameters.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_OneBin.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_CoarseBinning.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_FineBinning.config" + configFile="rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_OneBin.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_CoarseBinning.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_FineBinning.config" + outFile="JetUncertainties-TruthLabel-CompareBinning-${label}.pdf" + compList="FlavorResponse_PerJet#;Flavor_Composition@FlavorResponse_PerJet#;Flavor_Composition@FlavorResponse_PerJet#;Flavor_Composition" + compLabels="Response ${label} OneBin;Composition OneBin@Response ${label} CoarseBin;Composition CoarseBin@Response ${label} FineBin;Composition FineBin" + options="prefix=JET_;fixedEtaVals=0,1,2.5;fixedPtVals=20,40,60,80,100;TruthLabel=${label};path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/;drawTotal=False" +} + +function CompareFlavourBinningComp \ +{ + label=1 + + jetDefinition="AntiKt4EMTopo" + MCtype="MC16" + CalibArea="CalibArea-04" + configFile="rel21/Moriond2018/R4_AllNuisanceParameters.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_OneBin.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_CoarseBinning.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_FineBinning.config" + #configFile="rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_OneBin.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_CoarseBinning.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_FineBinning.config" + outFile="JetUncertainties-TruthLabel-CompareBinning-Composition-${label}.pdf" + compList="Flavor_Composition@Flavor_Composition@Flavor_Composition@Flavor_Composition" + compLabels="Current (50% gluon fraction uncertainty)@Composition OneBin@Composition CoarseBin@Composition FineBin" + options="prefix=JET_;fixedEtaVals=0,1,2.5,4.5;fixedPtVals=20,40,60,80,100;TruthLabel=${label};path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/;drawTotal=False" +} + +function CompareFlavourBinningResp \ +{ + label=11 + + jetDefinition="AntiKt4EMTopo" + MCtype="MC16" + CalibArea="CalibArea-04" + configFile="rel21/Moriond2018/R4_AllNuisanceParameters.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_OneBin.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_CoarseBinning.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_FineBinning.config" + #configFile="rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_OneBin.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_CoarseBinning.config;rel21/Moriond2018/R4_AllNuisanceParameters_PerJetFlavour_FineBinning.config" + outFile="JetUncertainties-TruthLabel-CompareBinning-Response-${label}.pdf" + compList="Flavor_Response@FlavorResponse_PerJet#@FlavorResponse_PerJet#@FlavorResponse_PerJet#" + compLabels="Current (50% gluon = PDG 21)@Response to PDG ${label} OneBin@Response to PDG ${label} CoarseBin@Response to PDG ${label} FineBin" + options="prefix=JET_;fixedEtaVals=0,1,2.5,4.5;fixedPtVals=20,40,60,80,100,200;TruthLabel=${label};path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/;drawTotal=False" +} + +function DumpHistos \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + CalibArea="" + configFile="JES_2016/Moriond2017/JES2016_21NP.config" + outFile="test.pdf" + compList="EffectiveNP_1;EffectiveNP_2;EffectiveNP_3;EffectiveNP_4;EffectiveNP_5;EffectiveNP_6;EffectiveNP_7;EffectiveNP_8restTerm;Flavor_Composition;Flavor_Response;Pileup_RhoTopology" + compLabels="EffectiveNP_1;EffectiveNP_2;EffectiveNP_3;EffectiveNP_4;EffectiveNP_5;EffectiveNP_6;EffectiveNP_7;EffectiveNP_8restTerm;Flavor_Composition_UNKNOWN;Flavor_Response_UNKNOWN;Pileup_RhoTopology" + options="prefix=JET_;isDijet=false;fixedEtaVals=0;fixedPtVals=NONE;drawTotal=False;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/\";dumpFile=test.root" + #compList="Flavor_Composition;Flavor_Response" + #compLabels="Flavor_Composition_DIJET;Flavor_Response_DIJET" + #options="prefix=JET_;isDijet=true;fixedEtaVals=0;fixedPtVals=NONE;drawTotal=False;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/\";dumpFile=test.root" + #compList="BJES_Response" + #compLabels="BJES_Response" + #options="prefix=JET_;isDijet=false;fixedEtaVals=0;fixedPtVals=NONE;drawTotal=False;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/\";dumpFile=test.root" +} + +function HLInputs \ +{ + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + CalibArea="" + configFile="HL/HL-Run2.config" + outFile="test.pdf" + compList="EffectiveNP_#;Flavor_Comp#;FlavorResp#;Pileup#" + compLabels="Absolute #it{in situ} JES;Flav. composition;Flav. response;Pileup" + options="prefix=JET_;fixedEtaVals=0;fixedPtVals=NONE;path=\"/afs/cern.ch/work/s/sschramm/private/rel21/athena/Reconstruction/Jet/JetUncertainties/share/\"" +} + +function HLCompare \ +{ + composition="DIJET" + + jetDefinition="AntiKt4EMTopo" + MCtype="MC15" + CalibArea="" + configFile="HL2018/HL-Optimistic-${composition}.config" + #outFile="HL-compare-Run2-Optimistic-UNKNOWN.pdf" + outFile="HL-compare-Baseline-Optimistic-${composition}.pdf" + compList="EffectiveNP_#;Flavor_Comp#;FlavorResp#;Pileup#" + #compLabels="Absolute #it{in situ} JES;Flav. composition, unknown composition;Flav. response, unknown composition;Pileup" + compLabels="Absolute #it{in situ} JES;Flav. composition, inclusive jets;Flav. response, inclusive jets;Pileup" + #options="prefix=JET_;isDijet=false;fixedEtaVals=0;fixedPtVals=NONE;path=\"/afs/cern.ch/work/s/sschramm/private/rel21/athena/Reconstruction/Jet/JetUncertainties/share/\";doCompare=JES_2016/Moriond2017/JES2016_21NP.config&MC15&Run 2 uncertainty;totalUncName=\"HL-LHC uncertainty, optimistic\"" + #options="prefix=JET_;isDijet=true;fixedEtaVals=0;fixedPtVals=NONE;path=\"/afs/cern.ch/work/s/sschramm/private/rel21/athena/Reconstruction/Jet/JetUncertainties/share/\";doCompare=HL/HL-Baseline.config&MC15&HL-LHC uncertainty, baseline;totalUncName=\"HL-LHC uncertainty, optimistic\"" + options="prefix=JET_;isDijet=true;fixedEtaVals=0;fixedPtVals=NONE;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/\";doCompare=HL2018/HL-Baseline-${composition}.config&MC15&HL-LHC uncertainty, baseline;totalUncName=\"HL-LHC uncertainty, optimistic\"" +} + +function JERTest \ +{ + scaleVar="MassRes" + topology="Top" + jetDefinition="AntiKt4EMTopo" + MCtype="MC16" + CalibArea="" + configFile="JER/R4_GlobalReduction_JER.config" + outFile="JER-test.pdf" + compList="PtResUnc;FourVecResUnc;MassResUncQCD;MassResUncWZ;MassResUncHbb;MassResUncTop;NOMINALRESMC;NOMINALRESDATA" + compLabels="pT resolution;four-vector resolution;mass resolution, QCD;mass resolution, WZ;mass resolution, Hbb;mass resolution, top;nominal MC resolution;nominal data resolution" + options="prefix=JET_;fixedEtaVals=0,2;fixedPtVals=NONE;path=\"/afs/cern.ch/work/s/sschramm/private/rel21/athena/Reconstruction/Jet/JetUncertainties/share/\";scaleVar=${scaleVar};topology=${topology}" +} + +function JER_August_2018_Compare \ +{ + scaleVar="FourVecResAbs" + jetdef="EMTopo" + jetDefinition="AntiKt4${jetdef};AntiKt4${jetdef};AntiKt4${jetdef}" + MCtype="MC16" + CalibArea="" + configFile="rel21/Summer2018/R4_GlobalReduction_SimpleJER.config;rel21/Summer2018/R4_GlobalReduction_FullJER.config;rel21/Summer2018/R4_AllNuisanceParameters_AllJERNP.config" + outFile="JER-August2018-Compare-${jetdef}.pdf" + compList="JER#@JER#@JER#" + compLabels="Total JER uncertainty, ${jetdef}, 7NP@Total JER uncertainty, ${jetdef}, 12NP@Total JER uncertainty, ${jetdef}, All NP" + options="prefix=JET_;fixedEtaVals=0;fixedPtVals=25;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/CalibArea-05/\";drawTotal=false;scaleVar=${scaleVar};IsData=false" +} + +function JER_August_2018_Nominal \ +{ + scaleVar="FourVecResAbs" + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + CalibArea="" + configFile="rel21/Summer2018/R4_GlobalReduction_SimpleJER.config;rel21/Summer2018/R4_GlobalReduction_SimpleJER.config" + outFile="JER-August2018-Nominal.pdf" + compList="NOMINALRESMC;NOMINALRESDATA@NOMINALRESMC;NOMINALRESDATA" + compLabels="Nominal MC JER, EMTopo;Nominal data JER, EMTopo@Nominal MC JER, EMPFlow;Nominal data JER,EMPFlow" + options="prefix=JET_;fixedEtaVals=0;fixedPtVals=25;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/CalibArea-05/\";drawTotal=false;scaleVar=${scaleVar};IsData=false;axisMax=0.4" +} + +function JER_August2018 \ +{ + scaleVar="FourVecResAbs" + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + CalibArea="" + configFile="rel21/Summer2018/R4_AllNuisanceParameters_AllJERNP.config" + outFile="JER-Summer2018-Recommendations.pdf" + compList="JER_DataVsMC;JER_N_#;JER_dijet_c#,JER_dijet_j#,JER_dijet_m#,JER_dijet_p#;JER_dijet_stat#" + compLabels="Nominal data vs MC difference;Noise term, random cones method;Dijet #it{in situ} JER (systematics);Dijet #it{in situ} JER (statistics)" + options="prefix=JET_;fixedEtaVals=0.202;fixedPtVals=40;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/CalibArea-05/\";scaleVar=${scaleVar};IsData=false;axisMax=0.05" +} + + +function JER_Fall_2018_Compare \ +{ + scaleVar="FourVecResAbs" + jetdef="EMTopo" + jetDefinition="AntiKt4${jetdef};AntiKt4${jetdef};AntiKt4${jetdef}" + MCtype="MC16" + CalibArea="" + configFile="rel21/Fall2018/R4_GlobalReduction_SimpleJER.config;rel21/Fall2018/R4_GlobalReduction_FullJER.config;rel21/Fall2018/R4_AllNuisanceParameters_AllJERNP.config" + outFile="JER-Fall2018-${MCtype}-Compare-${jetdef}.pdf" + compList="JER#@JER#@JER#" + compLabels="Total JER uncertainty, ${jetdef}, 7NP@Total JER uncertainty, ${jetdef}, 12NP@Total JER uncertainty, ${jetdef}, All NP" + options="prefix=JET_;fixedEtaVals=0;fixedPtVals=25;drawTotal=false;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/CalibArea-07/\"" +} + +function JER_Fall_2018_Nominal \ +{ + scaleVar="FourVecResAbs" + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + CalibArea="" + configFile="rel21/Fall2018/R4_GlobalReduction_SimpleJER.config;rel21/Fall2018/R4_GlobalReduction_SimpleJER.config" + outFile="JER-Fall2018-${MCtype}-Nominal.pdf" + compList="NOMINALRESMC;NOMINALRESDATA@NOMINALRESMC;NOMINALRESDATA" + compLabels="Nominal MC JER, EMTopo;Nominal data JER, EMTopo@Nominal MC JER, EMPFlow;Nominal data JER,EMPFlow" + options="prefix=JET_;fixedEtaVals=0;fixedPtVals=25;drawTotal=false;scaleVar=${scaleVar};IsData=false;axisMax=0.4;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/CalibArea-07/\"" +} + +function JER_Fall2018 \ +{ + scaleVar="FourVecResAbs" + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + CalibArea="" + configFile="rel21/Fall2018/R4_AllNuisanceParameters_AllJERNP.config" + outFile="JER-Fall2018-${MCtype}-Recommendations.pdf" + compList="JER_DataVsMC_#;JER_N_#;JER_dijet_c#,JER_dijet_j#,JER_dijet_m#,JER_dijet_p#;JER_dijet_stat#" + compLabels="Nominal data vs MC difference;Noise term, random cones method;Dijet #it{in situ} JER (systematics);Dijet #it{in situ} JER (statistics)" + options="prefix=JET_;fixedEtaVals=0.202;fixedPtVals=40,60;scaleVar=${scaleVar};IsData=false;axisMax=0.05;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/CalibArea-07/\"" +} + +function JER_Fall2018_TotalCompare \ +{ + scaleVar="FourVecResAbs" + jetDefinition="AntiKt4EMTopo" + MCtype="MC16" + CalibArea="" + configFile="rel21/Fall2018/R4_AllNuisanceParameters_AllJERNP.config" + outFile="JER-Fall2018-${MCtype}-Recommendations-CompareJetDef.pdf" + compList="" + compLabels="" + options="prefix=JET_;fixedEtaVals=0.202;fixedPtVals=40,60;scaleVar=${scaleVar};IsData=false;axisMax=0.05;" + options="${options};doCompare=rel21/Summer2019/R4_AllNuisanceParameters_AllJERNP.config&MC16&PFlow+JES total uncertainty&AntiKt4EMPFlow;totalUncName=EMTopo+JES total uncertainty" +} + +function JER_Fall_2018_CompareAllEtaInt \ +{ + scaleVar="FourVecResAbs" + jetdef="EMTopo" + jetDefinition="AntiKt4${jetdef};AntiKt4${jetdef};AntiKt4${jetdef}" + MCtype="MC16" + CalibArea="" + configFile="rel21/Fall2018/R4_GlobalReduction_SimpleJER.config;rel21/Fall2018_fullStatUncertanties/R4_AllNuisanceParameters_2015_16_AllJERNP.config;rel21/Fall2018_fullStatUncertanties/R4_AllNuisanceParameters_2017_AllJERNP.config" + outFile="JER-Fall2018-${MCtype}-CompareEtaInt-${jetdef}.pdf" + compList="JER#@JER#@JER#" + compLabels="Total JER uncertainty, ${jetdef}, normal@Total JER uncertainty, ${jetdef}, AllEtaInt 15+16@Total JER uncertainty, ${jetdef}, AllEtaInt 17" + options="prefix=JET_;fixedEtaVals=0;fixedPtVals=25;drawTotal=false;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/CalibArea-07/\"" +} + +function LargeR_Spring_2019 \ +{ + topology="qcd" + topoStr="UNKNOWN" + flavStr="" + if [[ $topology = "qcd" ]] ; then + topoStr="QCD jets (#equiv 0)" + flavStr=", QCD jets (unknown comp.)" + elif [[ $topology = "Wqq" ]] ; then + topoStr="W/Z bosons" + flavStr=", propagated from R=0.4 jets" + elif [[ $topology = "tqqb" ]] ; then + topoStr="top quarks" + flavStr=", propagated from R=0.4 jets" + fi + + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + configFile="rel21/Spring2019/R10_AllNuisanceParameters.config" + outFile="JetUncertainties-Spring2019-AllComponents-${topology}.pdf" + #configFile="rel21/Spring2019/R10_GlobalReduction.config" + #outFile="JetUncertainties-Spring2019-GR-${topology}.pdf" + compList="InSituProp#,LAr_#,Zjet#,Gjet#,MJB#,Effective#;EtaInt#;Flavor_Comp#;Flavor_Resp#;LargeR_Topo#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition${flavStr};Flav. response${flavStr};Large-R topology dependence, $topoStr" + options="isDijet=false;isLargeR=false;prefix=JET_;path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/;xAxisRange=175&3000;FatjetTruthLabel=${topology}" + options="${options};fixedPtVals=200,500,1000,2500;fixedEtaVals=0,0.5,1.5,2.499;axisMax=0.05;etaBins=U&1000&-2.5&2.5;fixedMoverPtVals=0.2" + #options="${options};fixedPtVals=NONE;fixedEtaVals=0;axisMax=0.05;etaBins=U&1000&-2.5&2.5;fixedMoverPtVals=0.2" + options="${options};FillLabelShift=-350&-385" +} + +function LargeR_Spring_2019_CompareRtrk \ +{ + topology="qcd" + + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + configFile="rel21/Spring2019/R10_AllNuisanceParameters.config" + outFile="JetUncertainties-Spring2019-CompareRtrk.pdf" + compList="InSituProp#,LAr_#,Zjet#,Gjet#,MJB#,Effective#;EtaInt#;Flavor_Comp#;Flavor_Resp#;LargeR_Topo#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Large-R topology" + options="isDijet=false;isLargeR=true;prefix=JET_;path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/;xAxisRange=200&3000;FatjetTruthLabel=${topology}" + options="${options};fixedPtVals=200,500,1000,2500;fixedEtaVals=0,0.5,1.5,2.499;axisMax=0.20;etaBins=U&1000&-2.5&2.5" + #options="${options};fixedPtVals=200,500,1000,2500;fixedEtaVals=0,0.5,1.5,2.499;axisMax=0.20;etaBins=U&1000&-2.5&2.5;fixedMoverPtVals=0.2" + options="${options};doCompare=rel21/Moriond2018/R10_CombMass_all_FV.config&MC16a&Total uncertainty, Moriond 2018;scaleVar=FourVec" + options="${options};totalUncName=\"Total uncertainty (QCD jets, unknown comp.)\"" #;FillLabelShift=10&10" +} + +function LargeR_Spring_2019_topology \ +{ + topology="qcd" + + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + configFile="rel21/Spring2019/R10_AllNuisanceParameters_QCD.config;rel21/Spring2019/R10_AllNuisanceParameters_V.config;rel21/Spring2019/R10_AllNuisanceParameters_top.config" + outFile="JetUncertainties-Spring2019-TopologyCompare.eps" + compList="TOTAL@TOTAL@TOTAL" + compLabels="Total uncertainty, QCD jets (unknown comp.)@Total uncertainty, W/Z bosons@Total uncertainty, top quarks" + options="isDijet=false;isLargeR=false;prefix=JET_;path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/;xAxisRange=175&3000;FatjetTruthLabel=${topology}" + options="${options};fixedPtVals=200,500,1000,2500;fixedEtaVals=0,0.5,1.5,2.499;axisMax=0.05;etaBins=U&1000&-2.5&2.5;drawTotal=false" + #options="${options};fixedPtVals=NONE;fixedEtaVals=0;axisMax=0.05;etaBins=U&1000&-2.5&2.5;drawTotal=false" +} + +function LargeR_Spring2019_test \ +{ + topology="qcd" + scale="FourVec" + config="AllNuisanceParameters" + + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + configFile="rel21/Spring2019/R10_${config}.config" + outFile="JetUncertainties-Spring2019-${config}-${scale}-${topology}.pdf" + #configFile="rel21/Spring2019/R10_GlobalReduction.config" + #outFile="JetUncertainties-Spring2019-GR-${topology}.pdf" + compList="InSituProp#,LAr_#,Zjet#,Gjet#,MJB#,Effective#;EtaInt#;Flavor_Comp#;Flavor_Resp#;LargeR_Topo#;CombMass_#;MassRes_Top_comb;MassRes_WZ_comb;MassRes_Hbb_comb" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition;Flav. response;Large-R topology;JMS total;JMR (top);JMR (W/Z);JMR (Hbb)" + options="isDijet=false;isLargeR=false;prefix=JET_;path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/;xAxisRange=170&3000;FatjetTruthLabel=${topology}" + options="${options};fixedPtVals=200,500,1000,2500;fixedEtaVals=0,0.5,1.5,2.499;etaBins=U&1000&-2.5&2.5;fixedMoverPtVals=0.1;scaleVar=${scale}" + if [[ $scale = "FourVec" ]] ; then + options="${options};axisMax=0.05" + elif [[ $scale = "Mass" ]] ; then + options="${options};axisMax=0.3" + elif [[ $scale = "MassRes" ]] ; then + options="${options};axisMax=0.5" + else + options="${options};axisMax=0.5" + fi +} + +function LargeR_TCC_SF \ +{ + TagType="W" + topology="qcd" + tagResult=1 + + # From BoostedJetTaggers, for tagResult + #if ( type==1 ){ + # return passMpassD2_2Var; + #}else if ( type==2 ){ + # return passMfailD2_2Var; + #}else if ( type==3 ){ + # return failMpassD2_2Var; + #}else if ( type==4 ){ + # return failMfailD2_2Var; + #} + + + jetDefinition="AntiKt10TrackCaloClusterTrimmedPtFrac5SmallR20" + MCtype="MC16" + configFile="rel21/Summer2019/R10_SF_TCC_2VarSmooth_${TagType}Tag.config" + outFile="JetUncertainties-Summer2019-SF-TCC-2VarSmooth-${TagType}Tag-${topology}Jet-Result${tagResult}.pdf" + + compList="Rtrk_#;BGSF_Dijet#;BGSF_Gammajet#;SigSF_ttbar#;SigSF_V_qq_Modelling_highPt" + compLabels="Propagated R_{trk} p_{T} uncertainties;Background SF uncertainty (dijet);Background SF uncertainty (#gamma+jet);Signal SF uncertainty (ttbar);Signal SF uncertainty (extrap)" + + #options="prefix=JET_;path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/" + options="prefix=JET_;CalibArea=CalibArea-08" + options="${options};fixedPtVals=NONE;fixedEtaVals=NONE;fixedMassVals=30,45,50,80,90,175,300" + options="${options};etaBins=U&1000&-2.5&2.5;xAxisRange=170&3000;axisMax=0.5" + options="${options};FillLabelShift=-350&-385" + options="${options};scaleVar=TagScaleFactor;TagSFName=Smooth${TagType}Contained2VarMaxSig_SF;FatjetTruthLabel=${topology};TagAcceptName=Smooth${TagType}Contained2VarMaxSig_accept;TagAcceptResult=${tagResult}" +} + +function LargeR_TCC_Scale \ +{ + doFixedMass="true" + scaleVar="mass" + + jetDefinition="AntiKt10TrackCaloClusterTrimmedPtFrac5SmallR20" + MCtype="MC16" + configFile="rel21/Summer2019/R10_Scale_TCC_all.config" + if ! [[ -z $doFixedMass ]] ; then + outFile="JetUncertainties-Summer2019-Scale-TCC-${scaleVar}-FixedM.pdf" + else + outFile="JetUncertainties-Summer2019-Scale-TCC-${scaleVar}-FixedMpT.pdf" + fi + + compList="Rtrk_Baseline#;Rtrk_Tracking#;Rtrk_TotalStat#;Rtrk_Modelling#;Rtrk_Closure#" + compLabels="Baseline;Tracking;Statistical;Modelling;Closure" + + options="prefix=JET_;path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/" + if ! [[ -z $doFixedMass ]] ; then + options="${options};fixedPtVals=NONE;fixedEtaVals=NONE;fixedMassVals=30,50,80,90,175,300" + else + options="${options};fixedPtVals=NONE;fixedEtaVals=NONE;fixedMoverPtVals=0.05,0.1,0.2,0.3,0.5" + fi + options="${options};etaBins=U&1000&-2.5&2.5;xAxisRange=170&3000;axisMax=0.3" + options="${options};FillLabelShift=-350&-385" + options="${options};scaleVar=${scaleVar}" +} + +function LargeR_TCC_Both \ +{ + TagType="Z" + topology="qcd" + tagResult=1 + + scaleVar="pT" + #scaleVar="mass" + #scaleVar="TagScaleFactor" + + # From BoostedJetTaggers, for tagResult + #if ( type==1 ){ + # return passMpassD2_2Var; + #}else if ( type==2 ){ + # return passMfailD2_2Var; + #}else if ( type==3 ){ + # return failMpassD2_2Var; + #}else if ( type==4 ){ + # return failMfailD2_2Var; + #} + + + jetDefinition="AntiKt10TrackCaloClusterTrimmedPtFrac5SmallR20" + MCtype="MC16" + configFile="rel21/Summer2019/R10_SF_TCC_2VarSmooth_${TagType}Tag.config;rel21/Summer2019/R10_Scale_TCC_all.config" + outFile="JetUncertainties-Summer2019-Both-TCC-2VarSmooth-${TagType}Tag-${topology}Jet-Result${tagResult}-${scaleVar}.pdf" + + compList="Rtrk_#_pT;Rtrk_#_mass;BGSF#;SigSF#" + compLabels="Rtrk p_{T} (original + propagated);Rtrk mass (original + propagated);Background SF (dijet + #gamma+jet);Signal SF (ttbar + extrap)" + + options="prefix=JET_;path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/;ignoreNoMatch=true;drawTotal=false" + options="${options};fixedPtVals=NONE;fixedEtaVals=NONE;fixedMassVals=30,50,80,90,175,300" + if [[ $scaleVar = TagScaleFactor ]] ; then + options="${options};etaBins=U&1000&-2.5&2.5;xAxisRange=170&3000;axisMax=0.5" + else + options="${options};etaBins=U&1000&-2.5&2.5;xAxisRange=170&3000;axisMax=0.3" + fi + options="${options};FillLabelShift=-350&-385" + options="${options};scaleVar=${scaleVar};TagSFName=Smooth${TagType}Contained2VarMaxSig_SF;FatjetTruthLabel=${topology};TagAcceptName=Smooth${TagType}Contained2VarMaxSig_accept;TagAcceptResult=${tagResult}" + +} + + +function LargeR_LC_SF_top \ +{ + TagType="Top" + topology="tqqb" + + # From BoostedJetTaggers, for topology + # case tqqb: return 1; + # case Wqq: return 2; + # case Zqq: return 3; + # case Wqq_From_t: return 4; + # case other_From_t: return 5; + # case other_From_V: return 6; + # case notruth: return 7; + # case qcd: return 8; + + + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + configFile="rel21/Summer2019/R10_SF_LC_DNNContained80_${TagType}Tag.config" + outFile="JetUncertainties-Summer2019-SF-LC-DNNContained80-${TagType}Tag-${topology}Jet.pdf" + + compList="Rtrk_#;BGSF_Dijet#;BGSF_Gammajet#;SigSF_ttbar#;SigSF_ttbar_Modelling_highPt" + compLabels="Propagated R_{trk} p_{T} uncertainties;Background SF uncertainty (dijet);Background SF uncertainty (#gamma+jet);Signal SF uncertainty (ttbar);Signal SF uncertainty (extrap)" + + options="prefix=JET_;path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/" + options="${options};fixedPtVals=NONE;fixedEtaVals=NONE;fixedMassVals=30,45,50,80,90,175,300;fixedMoverPtVals=0.05,0.1,0.2,0.3,0.5" + options="${options};etaBins=U&1000&-2.5&2.5;xAxisRange=170&3000;axisMax=0.5" + options="${options};FillLabelShift=-350&-385" + options="${options};scaleVar=TagScaleFactor;TagSFName=DNNTaggerTopQuarkContained80_SF;FatjetTruthLabel=${topology}" +} + +function EtaInt2018 \ +{ + doDijet="false" + + if [[ $doDijet = "true" ]] ; then + comp="dijet" + isdijet="true" + else + comp="unknown" + isdijet="false" + fi + + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + configFile="rel21/Summer2019/R4_AllNuisanceParameters_AllJERNP.config" + outFile="JetUncertainties-Summer2019-EtaInt2018-AllComponents-${comp}Comp.pdf" + compList="LAr#,Zjet#,Gjet#,SingleParticle#;EtaIntercalibration_Modelling,EtaIntercalibration_TotalStat,EtaIntercalibration_NonClosure_highE,EtaIntercalibration_NonClosure_negEta,EtaIntercalibration_NonClosure_posEta;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#;EtaIntercalibration_NonClosure_2018data" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition (${comp});Flav. response (${comp});Pileup;Punch-through;New 2018 component" + options="isDijet=${isdijet};isGSC=true;isLargeR=false;prefix=JET_;" + #options="${options};path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/" + options="${options};fixedEtaVals=NONE;fixedPtVals=20,40,60,100,150,200,300,500,700,1000,1500" + #options="${options};fixedEtaVals=1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0;fixedPtVals=NONE" +} + +function EtaInt2018_Compare \ +{ + doDijet="false" + + if [[ $doDijet = "true" ]] ; then + comp="dijet" + isdijet="true" + else + comp="unknown" + isdijet="false" + fi + + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + configFile="rel21/Fall2018/R4_AllNuisanceParameters_AllJERNP.config" + outFile="JetUncertainties-Summer2019-EtaInt2018-Compare-${comp}Comp.pdf" + compList="LAr#,Zjet#,Gjet#,SingleParticle#;EtaInter#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition (${comp});Flav. response (${comp});Pileup;Punch-through" + options="isDijet=${isdijet};isGSC=true;isLargeR=false;prefix=JET_;" + #options="${options};path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/" + options="${options};fixedEtaVals=NONE;fixedPtVals=20,40,60,100,150,200,300,500,700,1000,1500" + options="${options};doCompare=rel21/Summer2019/R4_AllNuisanceParameters_AllJERNP.config&MC16&Total uncertainty, including 2018 eta-intercal;scaleVar=FourVec" +} + +function EtaInt2018_LR \ +{ + topology="qcd" + + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + configFile="rel21/Summer2019/R10_AllNuisanceParameters.config" + outFile="JetUncertainties-Summer2019-EtaInt2018-AllComponents-LR.pdf" + compList="InSituProp#,LAr_#,Zjet#,Gjet#,MJB#,Effective#;EtaIntercalibration_Modelling,EtaIntercalibration_R10_TotalStat,EtaIntercalibration_NonClosure_highE,EtaIntercalibration_NonClosure_negEta,EtaIntercalibration_NonClosure_posEta;Flavor_Comp#;Flavor_Resp#;LargeR_Topo#;EtaIntercalibration_NonClosure_2018data" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition (${topology});Flav. response (${topology});Lage-R topology (${topology});New 2018 component" + options="isLargeR=false;prefix=JET_;FatjetTruthLabel=${topology}" + #options="${options};path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/" + options="${options};fixedEtaVals=NONE;fixedPtVals=175,200,300,500,700,1000,1500;etaBins=U&1000&-2.5&2.5;FillLabelShift=-0.7&-0.525" +} + +function EtaInt2018_LR_Compare \ +{ + topology="qcd" + + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + configFile="rel21/Spring2019/R10_AllNuisanceParameters.config" + outFile="JetUncertainties-Summer2019-EtaInt2018-Compare-LR.pdf" + compList="InSituProp#,LAr_#,Zjet#,Gjet#,MJB#,Effective#;EtaIntercal#;Flavor_Comp#;Flavor_Resp#;LargeR_Topo#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition (${topology});Flav. response (${topology});Lage-R topology (${topology})" + options="isLargeR=false;prefix=JET_;FatjetTruthLabel=${topology}" + #options="${options};path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/" + options="${options};fixedEtaVals=NONE;fixedPtVals=175,200,300,500,700,1000,1500;etaBins=U&1000&-2.5&2.5;FillLabelShift=-0.7&-0.525" + options="${options};doCompare=rel21/Summer2019/R10_AllNuisanceParameters.config&MC16&Total uncertainty, including 2018 eta-intercal;scaleVar=FourVec" +} + + +function EtaInt2018_FullStat16_Compare \ +{ + doDijet="false" + + if [[ $doDijet = "true" ]] ; then + comp="dijet" + isdijet="true" + else + comp="unknown" + isdijet="false" + fi + + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + configFile="rel21/Fall2018_fullStatUncertanties/R4_AllNuisanceParameters_2015_16_AllJERNP.config" + outFile="JetUncertainties-Summer2019-EtaInt2018-FullStat16-Compare-${comp}Comp.pdf" + compList="LAr#,Zjet#,Gjet#,SingleParticle#;EtaInter#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition (${comp});Flav. response (${comp});Pileup;Punch-through" + options="isDijet=${isdijet};isGSC=true;isLargeR=false;prefix=JET_;" + #options="${options};path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/" + options="${options};fixedEtaVals=NONE;fixedPtVals=20,40,60,100,150,200,300,500,700,1000,1500" + options="${options};doCompare=rel21/Summer2019_fullStatUncertainties/R4_AllNuisanceParameters_2015_16_AllJERNP.config&MC16&Total uncertainty, including 2018 eta-intercal;scaleVar=FourVec" +} + +function EtaInt2018_FullStat17_Compare \ +{ + doDijet="false" + + if [[ $doDijet = "true" ]] ; then + comp="dijet" + isdijet="true" + else + comp="unknown" + isdijet="false" + fi + + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + configFile="rel21/Fall2018_fullStatUncertanties/R4_AllNuisanceParameters_2017_AllJERNP.config" + outFile="JetUncertainties-Summer2019-EtaInt2018-FullStat17-Compare-${comp}Comp.pdf" + compList="LAr#,Zjet#,Gjet#,SingleParticle#;EtaInter#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition (${comp});Flav. response (${comp});Pileup;Punch-through" + options="isDijet=${isdijet};isGSC=true;isLargeR=false;prefix=JET_;" + #options="${options};path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/" + options="${options};fixedEtaVals=NONE;fixedPtVals=20,40,60,100,150,200,300,500,700,1000,1500" + options="${options};doCompare=rel21/Summer2019_fullStatUncertainties/R4_AllNuisanceParameters_2017_AllJERNP.config&MC16&Total uncertainty, including 2018 eta-intercal;scaleVar=FourVec" +} + + +function EtaInt2018_FullStat18_Compare \ +{ + doDijet="false" + + if [[ $doDijet = "true" ]] ; then + comp="dijet" + isdijet="true" + else + comp="unknown" + isdijet="false" + fi + + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + configFile="rel21/Fall2018_fullStatUncertanties/R4_AllNuisanceParameters_2017_AllJERNP.config" + outFile="JetUncertainties-Summer2019-EtaInt2018-FullStat18-Compare-${comp}Comp.pdf" + compList="LAr#,Zjet#,Gjet#,SingleParticle#;EtaInter#;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition (${comp});Flav. response (${comp});Pileup;Punch-through" + options="isDijet=${isdijet};isGSC=true;isLargeR=false;prefix=JET_;" + #options="${options};path=/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/testing/" + options="${options};fixedEtaVals=NONE;fixedPtVals=20,40,60,100,150,200,300,500,700,1000,1500" + options="${options};doCompare=rel21/Summer2019_fullStatUncertainties/R4_AllNuisanceParameters_2018_AllJERNP.config&MC16&Total uncertainty, including 2018 eta-intercal;scaleVar=FourVec" +} + +function TestSummer2019 \ +{ + jetDefinition="AntiKt4EMTopo;AntiKt4EMPFlow" + MCtype="MC16" + configFile="rel21/Summer2019/R4_CategoryReduction_SimpleJER.config" + outFile="JetUncertainties-Summer2019-CategoryJES-SimpleJER.pdf" + compList="Effective#,SingleParticle#;EtaIntercalibration_Modelling,EtaIntercalibration_TotalStat,EtaIntercalibration_NonClosure_highE,EtaIntercalibration_NonClosure_negEta,EtaIntercalibration_NonClosure_posEta;Flavor_Comp#;Flavor_Resp#;Pileup#;PunchThrough_#;EtaIntercalibration_NonClosure_2018data" + compLabels="Absolute #it{in situ} JES;Relative #it{in situ} JES;Flav. composition (${comp});Flav. response (${comp});Pileup;Punch-through;New 2018 component" + options="isDijet=true;isGSC=true;isLargeR=false;prefix=JET_;" +} + +function JES_2011 \ +{ + jetDefinition="AntiKt4EMTopo;AntiKt4LCTopo" + MCtype="MC11c" + CalibArea="" + configFile="JES_2011/Final/InsituJES2011_12NP.config" + outFile="JES-Final2011.pdf" + compList="EffectiveNP_1;EffectiveNP_2;EffectiveNP_3;EffectiveNP_4;EffectiveNP_5;EffectiveNP_6#;EtaIntercalibration_TotalStat;EtaIntercalibration_Modelling;SingleParticle_HighPt;RelativeNonClosure#" + compLabels="JetScaleEff1;JetScaleEff2;JetScaleEff3;JetScaleEff4;JetScaleEff5;JetScaleEff6;JetScaleEta1;JetScaleEta2;JetScaleHighPt;JetScaleMC (${MCtype})" + options="prefix=JET_;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/SVNBACKUP/JetUncertainties/trunk/share/\"" +} + + + +function JER_Fall2020_R10_xcheck_JES \ +{ + # Perfect agreement, this test is successful + scaleVar="FourVecResAbs" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + CalibArea="" + configFile="R10_AllNuisanceParameters_AllJERNP_TEST.config" + outFile="JER-Fall2020-${MCtype}-Tests-JES.pdf" + compList="JER_dijet_jes#;JER_xcheck_JES" + compLabels="Direct sum of JES terms;xcheck JES term" + options="prefix=JET_;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/LargeRConsolidated/JERtests/\";drawTotal=false" + options="${options};fixedEtaVals=NONE;fixedPtVals=150,200,300,500,1000,2000;xAxisRange=-2.5&2.5;axisMax=0.2" +} + +function JER_Fall2020_R10_xcheck_NC \ +{ + # Perfect agreement, this test is successful + scaleVar="FourVecResAbs" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + CalibArea="" + configFile="R10_AllNuisanceParameters_AllJERNP_TEST.config" + outFile="JER-Fall2020-${MCtype}-Tests-NC.pdf" + compList="JER_dijet_closure#;JER_xcheck_NC" + compLabels="Direct sum of nonclosure terms;xcheck NC term" + options="prefix=JET_;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/LargeRConsolidated/JERtests/\";drawTotal=false" + options="${options};fixedEtaVals=NONE;fixedPtVals=150,200,300,500,1000,2000;xAxisRange=-2.5&2.5;axisMax=0.2" +} + +function JER_Fall2020_R10_xcheck_MC \ +{ + # Perfect agreement, this test is successful + scaleVar="FourVecResAbs" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + CalibArea="" + configFile="R10_AllNuisanceParameters_AllJERNP_TEST.config" + outFile="JER-Fall2020-${MCtype}-Tests-MC.pdf" + compList="JER_dijet_mcgenerator_R10;JER_xcheck_MC" + compLabels="Direct sum of MC terms;xcheck MC term" + options="prefix=JET_;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/LargeRConsolidated/JERtests/\";drawTotal=false" + options="${options};fixedEtaVals=NONE;fixedPtVals=150,200,300,500,1000,2000;xAxisRange=-2.5&2.5;axisMax=0.2" +} + +function JER_Fall2020_R10_xcheck_DT \ +{ + # Perfect agreement, this test is successful + scaleVar="FourVecResAbs" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + CalibArea="" + configFile="R10_AllNuisanceParameters_AllJERNP_TEST.config" + outFile="JER-Fall2020-${MCtype}-Tests-DT.pdf" + compList="JER_dijet_selection_R10;JER_xcheck_DT" + compLabels="Direct sum of DT terms;xcheck DT term" + options="prefix=JET_;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/LargeRConsolidated/JERtests/\";drawTotal=false" + options="${options};fixedEtaVals=NONE;fixedPtVals=150,200,300,500,1000,2000;xAxisRange=-2.5&2.5;axisMax=0.2" +} + +function JER_Fall2020_R10_xcheck_Total \ +{ + # Perfect agreement, this test is successful + scaleVar="FourVecResAbs" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + CalibArea="" + configFile="R10_AllNuisanceParameters_AllJERNP_TEST.config" + outFile="JER-Fall2020-${MCtype}-Tests-Total.pdf" + compList="JER_dijet_c#,JER_dijet_sel#,JER_dijet_jes#,JER_dijet_mc#;JER_xcheck_Total" + compLabels="Direct sum of all dijet terms;xcheck total term" + options="prefix=JET_;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/LargeRConsolidated/JERtests/\";drawTotal=false" + options="${options};fixedEtaVals=NONE;fixedPtVals=150,200,300,500,1000,2000;xAxisRange=-2.5&2.5;axisMax=0.2" +} + +function JER_Fall2020_R10_fixPt \ +{ + scaleVar="FourVecResAbs" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + CalibArea="" + configFile="rel21/Fall2020/R10_AllNuisanceParameters_AllJERNP_AllJMSNP.config" + outFile="JER-Fall2020-${jetDefinition}-${MCtype}-fixedPt.pdf" + compList="JER_DataVsMC_R10#;JER_dijet_R10_closure;JER_dijet_R10_selection;JER_dijet_R10_mcgen#;JER_dijet_R10_jes#;JER_dijet_R10_stat" + compLabels="Nominal data vs MC difference;Dijet #it{in situ} JER, closure;Dijet #it{in situ} JER, selection;Dijet #it{in situ} JER, MC generator;Dijet #it{in situ} JER, propagated JES;Dijet #it{in situ} JER, statistics" + options="prefix=JET_;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/LargeRConsolidated/Recommendation/\";FillLabelShift=-0.7&-0.525" + options="${options};fixedEtaVals=NONE;fixedPtVals=150.,200.,300.,500.,1000.,2000.;xAxisRange=-2.5&2.5;axisMax=0.04" + options="${options};doCompare=rel21/Summer2019/R10_AllNuisanceParameters_FlatJER.config&MC16&Total uncertainty, previous;totalUncName=\"Total uncertainty, consolidated\"" +} + +function JER_Fall2020_R10_fixEta \ +{ + scaleVar="FourVecResAbs" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + CalibArea="" + configFile="rel21/Fall2020/R10_AllNuisanceParameters_AllJERNP_AllJMSNP.config" + outFile="JER-Fall2020-${jetDefinition}-${MCtype}-fixedEta.pdf" + compList="JER_DataVsMC_R10#;JER_dijet_R10_closure;JER_dijet_R10_selection;JER_dijet_R10_mcgen#;JER_dijet_R10_jes#;JER_dijet_R10_stat" + compLabels="Nominal data vs MC difference;Dijet #it{in situ} JER, closure;Dijet #it{in situ} JER, selection;Dijet #it{in situ} JER, MC generator;Dijet #it{in situ} JER, propagated JES;Dijet #it{in situ} JER, statistics" + options="prefix=JET_;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/LargeRConsolidated/Recommendation/\";FillLabelShift=-305&-340" + options="${options};fixedEtaVals=0,0.201,0.701,1.01,1.31,1.61,2.01;fixedPtVals=NONE;xAxisRange=150&3000;axisMax=0.04" + options="${options};doCompare=rel21/Summer2019/R10_AllNuisanceParameters_FlatJER.config&MC16&Total uncertainty, previous;totalUncName=\"Total uncertainty, consolidated\"" +} + +function JER_Fall2020_R10_fixEta_onlyJES_proposal \ +{ + scaleVar="FourVecResAbs" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + CalibArea="" + configFile="rel21/Fall2020/R10_AllNuisanceParameters_AllJERNP_AllJMSNP.config" + outFile="JER-Fall2020-${jetDefinition}-${MCtype}-fixedEta-onlyJES-proposal.pdf" + compList="JER_dijet_R10_jes#;JER_dijet_R10_jesEffNP1;JER_dijet_R10_jesEffNP3;JER_dijet_R10_jesEffNP4;JER_dijet_R10_jesEtaIntMod;JER_dijet_R10_jesFlavComp;JER_dijet_R10_jesFlavResp;JER_dijet_R10_jesEffNP2,JER_dijet_R10_jesEffNP5,JER_dijet_R10_jesEffNP6,JER_dijet_R10_jesEtaIntStat,JER_dijet_R10_jesHighPt" + compLabels="Merger of all 11x JES NPs;Effective NP 1;Effective NP 3;Effective NP 4;Eta intercalibration, modelling;Flavour composition;Flavour response;Remaining 5x NPs merged" + options="prefix=JET_;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/LargeRConsolidated/Recommendation/\";FillLabelShift=-305&-340" + options="${options};fixedEtaVals=0,0.201,0.701,1.01,1.31,1.61,2.01;fixedPtVals=NONE;xAxisRange=150&3000;axisMax=0.025" + options="${options};totalUncName=\"Total uncertainty, consolidated\";TwoColumnLegend=True" +} + +function JER_Fall2020_R10_fixEta_onlyJES \ +{ + scaleVar="FourVecResAbs" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + CalibArea="" + configFile="rel21/Fall2020/R10_AllNuisanceParameters_AllJERNP_AllJMSNP.config" + outFile="JER-Fall2020-${jetDefinition}-${MCtype}-fixedEta-onlyJES.pdf" + compList="JER_dijet_R10_jes#;JER_dijet_R10_jesEffNP1;JER_dijet_R10_jesEffNP2;JER_dijet_R10_jesEffNP3;JER_dijet_R10_jesEffNP4;JER_dijet_R10_jesEffNP5;JER_dijet_R10_jesEffNP6;JER_dijet_R10_jesEtaIntMod;JER_dijet_R10_jesEtaIntStat;JER_dijet_R10_jesFlavComp;JER_dijet_R10_jesFlavResp;JER_dijet_R10_jesHighPt" + compLabels="Merger of all 11x JES NPs;Effective NP 1;Effective NP 2;Effective NP 3;Effective NP 4;Effective NP 5;Effective NP 6;Eta intercalibration, modelling;Eta intercalibration, statistical;Flavour composition;Flavour response;High pT term" + options="prefix=JET_;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/LargeRConsolidated/Recommendation/\";FillLabelShift=-305&-340" + options="${options};fixedEtaVals=0,0.201,0.701,1.01,1.31,1.61,2.01;fixedPtVals=NONE;xAxisRange=150&3000;axisMax=0.04" + options="${options};doCompare=rel21/Summer2019/R10_AllNuisanceParameters_FlatJER.config&MC16&Total uncertainty, previous;totalUncName=\"Total uncertainty, consolidated\";TwoColumnLegend=True" +} + +function JMS_Fall2020_R10_Calo \ +{ + scaleVar="mass" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + CalibArea="" + configFile="rel21/Fall2020/R10_AllNuisanceParameters_AllJERNP_AllJMSNP-Calo.config" + outFile="JMS-Fall2020-${jetDefinition}-${MCtype}-mCalo.pdf" + compList="FF_Larger#;FF_Matrix#;FF_Parton#;FF_Radiation#;FF_Shape#;FF_SmallRjet#;FF_Stat#;Rtrk_Generator#;Rtrk_Track#;Rtrk_Stat#" + compLabels="FF, LargerSample;FF, MatrixElement;FF, PartonShower;FF, Radiation;FF, Shape;FF, small-R jet;FF, Statistical;Rtrk, Generator;Rtrk, Tracking;Rtrk, Statistical" + options="prefix=JET_;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/LargeRConsolidated/Recommendation/\"" + options="${options};massDef=calo;xAxisRange=150&3000;axisMax=0.1;TwoColumnLegend=True;FillLabelShift=-320&-350;totalUncName=\"Total Uncertainty, mCalo\"" + options="${options};fixedPtVals=NONE;fixedEtaVals=NONE;fixedMassVals=30,50,80,175,275,325,500" +} + +function JMS_Fall2020_R10_TA \ +{ + scaleVar="mass" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + CalibArea="" + configFile="rel21/Fall2020/R10_AllNuisanceParameters_AllJERNP_AllJMSNP-TA.config" + outFile="JMS-Fall2020-${jetDefinition}-${MCtype}-mTA.pdf" + compList="FF_Larger#;FF_Matrix#;FF_Parton#;FF_Radiation#;FF_Shape#;FF_SmallRjet#;FF_Stat#;Rtrk_Generator#;Rtrk_Track#;Rtrk_Stat#" + compLabels="FF, LargerSample;FF, MatrixElement;FF, PartonShower;FF, Radiation;FF, Shape;FF, small-R jet;FF, Statistical;Rtrk, Generator;Rtrk, Tracking;Rtrk, Statistical" + options="prefix=JET_;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/LargeRConsolidated/Recommendation/\"" + options="${options};massDef=calo;xAxisRange=150&3000;axisMax=0.2;TwoColumnLegend=True;FillLabelShift=-320&-350;totalUncName=\"Total Uncertainty, mTA\"" + options="${options};fixedPtVals=NONE;fixedEtaVals=NONE;fixedMassVals=30,50,80,175,275,325,500" +} + +function JMS_Fall2020_R10_comb \ +{ + scaleVar="mass" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + CalibArea="" + configFile="rel21/Fall2020/R10_AllNuisanceParameters_AllJERNP_AllJMSNP.config" + outFile="JMS-Fall2020-${jetDefinition}-${MCtype}-mComb.pdf" + compList="CombMass_FF_Larger#;CombMass_FF_Matrix#;CombMass_FF_Parton#;CombMass_FF_Radiation#;CombMass_FF_Shape#;CombMass_FF_SmallRjet#;CombMass_FF_Stat#;CombMass_Rtrk_Generator#;CombMass_Rtrk_Track#;CombMass_Rtrk_Stat#" + compLabels="FF, LargerSample;FF, MatrixElement;FF, PartonShower;FF, Radiation;FF, Shape;FF, small-R jet;FF, Statistical;Rtrk, Generator;Rtrk, Tracking;Rtrk, Statistical" + options="prefix=JET_;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/LargeRConsolidated/Recommendation/\"" + options="${options};massDef=calo;xAxisRange=150&3000;axisMax=0.2;TwoColumnLegend=True;FillLabelShift=-320&-350;totalUncName=\"Total Uncertainty, mComb\"" + options="${options};fixedPtVals=NONE;fixedEtaVals=NONE;fixedMassVals=30,50,80,175,275,325,500" + options="${options};doCompare=rel21/Summer2019/R10_AllNuisanceParameters_FlatJER.config&MC16&Total uncertainty, previous;totalUncName=\"Total uncertainty, consolidated\"" +} + +function JMS_Fall2020_R10_compare \ +{ + scaleVar="mass" + jetDefinition="AntiKt10LCTopoTrimmedPtFrac5SmallR20" + MCtype="MC16" + CalibArea="" + configFile="rel21/Fall2020/R10_AllNuisanceParameters_AllJERNP_AllJMSNP.config;rel21/Fall2020/R10_AllNuisanceParameters_AllJERNP_AllJMSNP-Calo.config;rel21/Fall2020/R10_AllNuisanceParameters_AllJERNP_AllJMSNP-TA.config" + outFile="JMS-Fall2020-${jetDefinition}-${MCtype}-compare.pdf" + compList="TOTAL@TOTAL@TOTAL" + compLabels="Total Uncertainty, mComb@Total Uncertainty, mCalo@Total Uncertainty, mTA" + #compList="TOTAL;CombMass_FF#;CombMass_Rtrk#@TOTAL;FF_#;Rtrk_#@TOTAL;FF_#;Rtrk_#" + #compLabels="Total uncertainty, mComb;FF, mComb;Rtrk, mComb@Total uncertanty, mCalo;FF, mCalo;Rtrk, mCalo@Total uncertainty, mTA;FF, mTA;Rtrk mTA" + options="prefix=JET_;scaleVar=${scaleVar};IsData=false;path=\"/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/LargeRConsolidated/Recommendation/\"" + options="${options};massDef=calo;xAxisRange=150&3000;axisMax=0.2;drawTotal=False" + options="${options};fixedPtVals=NONE;fixedEtaVals=NONE;fixedMassVals=30,50,80,175,275,325,500" +} + + + + + + + +# Check arguments +if test $# -lt 1 ; then + echo "USAGE: $0 <scenario to run> (options addition or overwrite)" + echo "Scenarios available:" + echo " Moriond2013" + echo " LargeR_July2014" + echo " Final2012" + echo " Final2012_Stronger" + echo " Final2012_Weaker" + exit 1 +fi + +firstArg=$BOOLT +#echo "$BOOLT" +for anArg in $@ ; do + #echo "start loop" + #echo "$firstArg" + #echo "$BOOLT" + #echo "$anArg" + if [ "$firstArg" = "$BOOLT" ] ; then + # Run the specified scenario + #echo "running" + #echo "$1" + $1 + + # Check that it looks semi-reasonable + if [ -z "$outFile" ] ; then + echo "Output file is not specified" + echo "Check that you spelled the desired scenario correctly" + exit 2 + fi + + # Move on to options + firstArg=$BOOLF + continue + elif ! [ -z "$anArg" ] ; then + # Overwrite option(s) if needed + key=`echo $anArg | tr "=" " " | awk '{print $1}'` + val=`echo $anArg | tr "=" " " | awk '{print $2}'` + if [ -z "$key" ] || [ -z "$val" ] || [ "$key" = "$val" ] ; then + echo "Bad option formatting: $anArg" + exit 3 + fi + if [[ "$options" = *$key* ]] ; then + #Overwrite + options=`echo "$options" | sed s/"${key}=[^;]*"/"${key}=${val}"/g` + else + # Extend + options="${options};${key}=${val}" + fi + fi +done + +echo "Running with options: $options" +MakeUncertaintyPlots "$outFile" "$jetDefinition" "$MCtype" "$configFile" "$compList" "$compLabels" "$options" + diff --git a/Reconstruction/Jet/JetUncertainties/util/FFJetSmearingTool_MyExample.cxx b/Reconstruction/Jet/JetUncertainties/util/FFJetSmearingTool_MyExample.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3031cb61b335a91d327cf74d197199b6886491d9 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/util/FFJetSmearingTool_MyExample.cxx @@ -0,0 +1,651 @@ +/* + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +*/ + +/* ***********************************************************************************\ + * * + * Name: FFJetSmearingTool_MyExample * + * Purpose: Example code for using the FFJetSmearingTool * + * * +\*************************************************************************************/ + +//In order to simplify the usage of this example we recomend to set up a run directory as shown in: +// https://gitlab.cern.ch/alprades/ffjetsmearingtool/tree/master/FFJetSmearingTool +// If a user want to use the FFJetSmearingTool, he has to calibrate and tagg his jets. +// This will be different for each ntuple and is not easy to generalise so, to make the +// example simple, plese, copy the run directoy. + +//For more information about the tool, please, check TWiki of the tool: https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/FFJetSmearingTool + +// System include(s): +#include <memory> + +#include "AsgTools/ToolHandle.h" +#include "AsgTools/AsgTool.h" + + +// ROOT +#include "TFile.h" +#include "TCanvas.h" + + +//xAOD EDM classes +#include "xAODEventInfo/EventInfo.h" +#include "xAODJet/JetContainer.h" + +#include "xAODEventShape/EventShape.h" +#include "xAODRootAccess/tools/Message.h" +#include "xAODRootAccess/tools/ReturnCheck.h" +#include "xAODCore/tools/IOStats.h" +#include "xAODCore/tools/ReadStats.h" +#include "xAODCore/ShallowCopy.h" + +#include "JetCalibTools/JetCalibrationTool.h" + +//Other includes +#include "TH1F.h" +#include "TTree.h" + + +//truh label +#include "ParticleJetTools/JetTruthLabelingTool.h" + +//My includes +#include "JetUncertainties/FFJetSmearingTool.h" + +// Error checking macro +#define CHECK( ARG ) \ + do { \ + const bool result = ARG; \ + if(!result) { \ + printf("Failed to execute: %s \n", #ARG);\ + return 1; \ + } \ + } while( false ) + + + +// Help message if the --help option is given by the user +void usage() { + printf("Running options:\n"); + printf("YOU HAVE TO ADAPT THE OPTIONS TO FFJETSMEARINGCORRECTION\n"); + printf(" --help : To get the help you're reading\n"); + printf(" --jetColl= : Specify the jet collection (TrimmedLargeR)\n"); + printf(" --MassDef= : Specify the kind of jet mass used (Calo, TA, Comb)\n"); + printf(" --sample= : Specify input xAOD\n"); + printf(" Example: FFJetSmearingTool_MyExample --truth_jetColl=AntiKt10TruthTrimmedPtFrac5SmallR20Jets --reco_jetColl=AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets --MassDef=Comb --sample=DAOD_JETM6.16317590._000003.pool.root.1 --output=file_name.root --ConfigFile=rel21/Spring2020/FFJetSmearingTool_TestOnly_JMR.config --DebugTool=true \n"); +} + + + + + +//--------------- +// Main Function +//--------------- + +int main(int argc, char* argv[]){ + + //Reading user instructions of the example *********************************************************************************************** + + + //--------------------------------------------- + // Declaring input variables with default values + //--------------------------------------------- + std::string sample = ""; + std::string truth_jetColl = ""; + std::string reco_jetColl = ""; + std::string string_kindofmass = ""; + std::string output = ""; + std::string string_configfile_path = ""; + std::string string_debugtool = ""; + //--------------------------- + // Decoding the user settings + //--------------------------- + + for (int i=1; i< argc; i++){ + + std::string opt(argv[i]); std::vector< std::string > v; + + std::istringstream iss(opt); + + std::string item; + char delim = '='; + + while (std::getline(iss, item, delim)){ + v.push_back(item); + } + + if ( opt.find("--help") != std::string::npos ) { + usage(); return 0; + } + + if ( opt.find("--sample=") != std::string::npos ) sample = v[1]; + if ( opt.find("--truth_jetColl=") != std::string::npos ) truth_jetColl = v[1]; + if ( opt.find("--reco_jetColl=") != std::string::npos ) reco_jetColl = v[1]; + if ( opt.find("--MassDef=") != std::string::npos ) string_kindofmass = v[1]; + if ( opt.find("--ConfigFile=") != std::string::npos ) string_configfile_path = v[1]; + if ( opt.find("--DebugTool=") != std::string::npos ) string_debugtool = v[1]; + if ( opt.find("--output=") != std::string::npos ) output = v[1]; + }//End: Loop over input options + + + if(sample==""){ + printf("No input xAOD file specified, exiting\n"); + return 1; + } + if(truth_jetColl==""){ + printf("No truth jet collection specified, exiting\n"); + return 1; + } + if(reco_jetColl==""){ + printf("No truth jet collection specified, exiting\n"); + return 1; + } + if(string_kindofmass==""){ + printf("No kind of jet mass specified, exiting\n"); + return 1; + } + if(string_configfile_path==""){ + printf("No ConfigFile specified, exiting\n"); + return 1; + } + if(string_debugtool==""){ + printf("No debugtool specified, exiting\n"); + return 1; + } + if(output==""){ + printf("output not specified, exiting\n"); + return 1; + } + printf("%s %s %s %s %s \n", sample.c_str(), truth_jetColl.c_str(), reco_jetColl.c_str(), output.c_str(), string_debugtool.c_str()); + + + TString kindofmass = string_kindofmass; + + bool want_to_debug = false; + + if(string_debugtool == "true"){want_to_debug = true;} + if(string_debugtool == "false"){want_to_debug = false;} + +//************************************************************************************************************************************* + + + //-------------------- + // Opening input file + //-------------------- + + std::unique_ptr< TFile > ifile( TFile::Open( sample.c_str(), "READ" ) ); + + + // Create a TEvent object + xAOD::TEvent event(xAOD::TEvent::kClassAccess); + + CHECK( event.readFrom( ifile.get() ) ); + + + //---------------------------------- + // Initialization of FFJetSmearingTool + //---------------------------------- + + const std::string name_FFJetSmearingTool = "FFJetSmearing_Example"; + // Call the constructor + + CP::FFJetSmearingTool ffjetsmearingtool(name_FFJetSmearingTool.c_str()); + +/* +asg::AsgToolConfig config (("FFJetSmearingTool/" + name_FFJetSmearingTool).c_str()); +// configure `config` object +std::shared_ptr<void> cleanup; +ToolHandle<FFJetSmearingTool> ffjetsmearingtool; + + +//ASSERT_SUCCESS (config.makeTool (fjetsmearingtool, cleanup)); +config.makeTool (ffjetsmearingtool, cleanup); +*/ + + + + + + + (ffjetsmearingtool.setProperty( "MassDef", kindofmass )).ignore(); + + (ffjetsmearingtool.setProperty( "ConfigFile", string_configfile_path )).ignore(); + + // Initialize the tool + if(!(ffjetsmearingtool.initialize().isSuccess())){ + printf("Initialization of FFJetSmearingTool failed, exiting\n"); + return 0; + } + + + //Set output level threshold (1=VERBOSE, 2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL, 7=ALWAYS) + ffjetsmearingtool.setProperty ("OutputLevel", MSG::ERROR); + + if(want_to_debug){ + ffjetsmearingtool.setProperty ("OutputLevel", MSG::VERBOSE); + } +//***************************************************************** TESTINGGGG********************** + // Print the recommended systematics + + const CP::SystematicSet& recommendedSysts = ffjetsmearingtool.recommendedSystematics();//take the systematics of the FFJETSmearing Tool + printf("Recommended systematics: \n"); + for(auto sysItr = recommendedSysts.begin(); + sysItr != recommendedSysts.end(); ++sysItr){ + printf("%s \n", sysItr->name().c_str()); + } + + + std::vector<CP::SystematicSet> sysList; + + + + //--------------------------------------------------------- + //////Initialize the tool to set the truth tagging + + JetTruthLabelingTool m_JetTruthLabelingTool("JetTruthLabelingTool"); + + CHECK(m_JetTruthLabelingTool.setProperty("TruthLabelName", "R10TruthLabel_R21Consolidated")); + CHECK(m_JetTruthLabelingTool.setProperty("UseTRUTH3", false)); // Set this to false only if you have the FULL !TruthParticles container in your input file + CHECK(m_JetTruthLabelingTool.setProperty("TruthParticleContainerName", "TruthParticles")); // Set this if you have the FULL !TruthParticles container but have named it something else + CHECK(m_JetTruthLabelingTool.initialize()); + + + + + + //-------------------- + // Calibrate jets (ir is necessary to extract the Calo and TA from a Combined jet). The user have to calibrate the jets before using the SmearingTool + //-------------------- + const std::string name_JetCalibTools = "JetCalibTool_LC"; + + // Call the constructor + JetCalibrationTool jetCalibrationTool(name_JetCalibTools.c_str()); + + jetCalibrationTool.setProperty("JetCollection", "AntiKt10LCTopoTrimmedPtFrac5SmallR20"); + + if(kindofmass=="Comb"){ // To test like if the user has different jet mass definitions in his analysis + jetCalibrationTool.setProperty("ConfigFile", "JES_MC16recommendation_FatJet_Trimmed_JMS_comb_17Oct2018.config"); + } + if(kindofmass=="Calo"){ + jetCalibrationTool.setProperty("ConfigFile", "JES_MC16recommendation_FatJet_Trimmed_JMS_calo_12Oct2018.config"); + } + if(kindofmass=="TA"){ + jetCalibrationTool.setProperty("ConfigFile", "JES_MC16recommendation_FatJet_Trimmed_JMS_TA_12Oct2018.config"); + } + + + jetCalibrationTool.setProperty("CalibSequence", "EtaJES_JMS"); + jetCalibrationTool.setProperty("IsData", false); + jetCalibrationTool.setProperty("CalibArea", "00-04-82"); + jetCalibrationTool.setProperty("DEVmode", false); + + if(!(jetCalibrationTool.initialize().isSuccess())){ + printf("Initialization of JetCalibTools failed, exiting \n"); + return 0; + } +//-------------------------------------------------------- + + + for (auto sys : recommendedSysts) { sysList.push_back(CP::SystematicSet({sys})); } + + printf("\n=============SYSTEMATICS CHECK NOW \n"); + for (auto sys : sysList) { + // Tell the calibration tool which variation to apply + if (ffjetsmearingtool.applySystematicVariation(sys) != CP::SystematicCode::Ok) { + printf("Error, Cannot configure calibration tool for systematics \n"); + } + + printf("\nWe are using the systematic %s \n", sys.name().c_str()); + + + + +//************************************************************************************** + + static constexpr float MeVtoGeV = 1.e-3; + + //---------------------------------- + // Define histograms + //---------------------------------- + + TH1F* reco_jet_mass_hist=new TH1F("reco_jet_mass_hist","reco_jet_mass_hist", 100, 0, 200); + TH1F* matched_truth_jet_mass_hist=new TH1F("matched_truth_jet_mass_hist","matched_truth_jet_mass_hist", 100, 0, 200); + TH1F* smeared_reco_jet_mass_hist=new TH1F("smeared_reco_jet_mass_hist","smeared_reco_jet_mass_hist", 100, 0, 200); + + reco_jet_mass_hist->Sumw2(); + matched_truth_jet_mass_hist->Sumw2(); + smeared_reco_jet_mass_hist->Sumw2(); + + + + + + + int upperlimit1 = 600; + int upperlimit2 = 1000; + + int numBinsMass = 120; + int numBinsPt = 100; + + //numBinsMass = 12; + //numBinsPt = 10; + + + std::unique_ptr<TH3F> hist_jet_mass_scale_change_3D; + hist_jet_mass_scale_change_3D = std::make_unique<TH3F>("hist_jet_mass_scale_change_3D","hist_jet_mass_scale_change_3D",numBinsPt,0,upperlimit2/*pt*/,numBinsMass,0,upperlimit1/*mass*/,numBinsMass,0,upperlimit1/*mass*/); + + + float lowerlimit3 = -0.5; + float upperlimit3 = 0.5; + int numBinsDiff = 100; + + + std::unique_ptr<TH3F> hist_jet_mass_resolution_change_3D; + hist_jet_mass_resolution_change_3D = std::make_unique<TH3F>("hist_jet_mass_resolution_change_3D","hist_jet_mass_resolution_change_3D",numBinsPt,0,upperlimit2/*pt*/,numBinsMass,0,upperlimit1/*mass*/,numBinsDiff,lowerlimit3,upperlimit3/*mass*/); + + + + //------------------ + // Loop over events + //------------------ + + // Get the number of events + const Long64_t nevents = event.getEntries(); + + // Decide how many events to run over + //if(nevents>10000){nevents = 10000; } + + + + for(Long64_t ievent = 0; ievent < nevents; ++ievent){ + + // Load the event: + if( event.getEntry( ievent ) < 0 ) { + printf("Failed to load entry %lld \n", ievent); + return 1; + } + + + // Show status + if(ievent % 100==0) printf("Event %lld of %lld \n", ievent, nevents); + + //************************************************************// + // Print some event information for fun + if(want_to_debug){ + const xAOD::EventInfo* ei = nullptr; + CHECK( event.retrieve(ei, "EventInfo") ); + + printf("===>>> start processing event #%llu, run #%i, %lld events processed so far <<<=== \n", ei->eventNumber(), ei->runNumber(), ievent); + + + // Get the truth jets from the event + const xAOD::JetContainer* jets_truth = nullptr; + CHECK( event.retrieve(jets_truth, "AntiKt10TruthTrimmedPtFrac5SmallR20Jets") ); + + printf("Number of truth jets: %lu \n", jets_truth->size()); + + //Loop over the truth jets in the event + for(const xAOD::Jet* jet_truth : *jets_truth){ + // Print basic info about this jet + printf("Truth Jet: pt = %f, mass = %f, eta = %f \n", jet_truth->pt()*MeVtoGeV, jet_truth->m()*MeVtoGeV, jet_truth->eta()); + } + + + + // Get the reco jets from the event + const xAOD::JetContainer* jets_reco = nullptr; + CHECK( event.retrieve(jets_reco, reco_jetColl) ); + + printf("Number of reco jets: %lu \n", jets_reco->size()); + + //Loop over the reco jets in the event + for(const xAOD::Jet* jet_reco : *jets_reco){ + + // Print basic info about this jet + printf("Reco Jet: pt = %f, mass = %f, eta = %f \n", jet_reco->pt()*MeVtoGeV, jet_reco->m()*MeVtoGeV, jet_reco->eta()); + } + } + //************************************************************// + + + + xAOD::Jet jet_truth_matched; + jet_truth_matched.makePrivateStore(); + + // Retrieve jet container + const xAOD::JetContainer* jets = nullptr; + CHECK( event.retrieve( jets, reco_jetColl ) ); + + // Shallow copy + auto jets_shallowCopy = xAOD::shallowCopyContainer( *jets ); + + //Give a TruthLabel to the jets. We will need it in the FFSmearingTool to apply the uncertainties of one jet topology or another + m_JetTruthLabelingTool.modify(*(jets_shallowCopy.first)); + + if(want_to_debug) printf("Start the loop over the jets \n"); + + bool lead_jet = true;//to fill the histogram + + // Iterate over the shallow copy + for( xAOD::Jet* jet_reco : *( jets_shallowCopy.first ) ) { + + //Calibrate the jet. This step is necessary to extract the CALO and TA mass inside the tool later (if we are talking about a combined mass jet) + jetCalibrationTool.applyCalibration( *jet_reco ); +//------------------------------------------------------------------------------------------------------------------------------------------// +//Test how the Calo and TA mass are set in the Combined mass. + + xAOD::JetFourMom_t jet_reco_Comb_FourMom; + xAOD::JetFourMom_t jet_reco_CALO_FourMom; + xAOD::JetFourMom_t jet_reco_TA_FourMom; + + jet_reco->getAttribute<xAOD::JetFourMom_t>("JetJMSScaleMomentumCombQCD",jet_reco_Comb_FourMom); + jet_reco->getAttribute<xAOD::JetFourMom_t>("JetJMSScaleMomentumCalo",jet_reco_CALO_FourMom); + jet_reco->getAttribute<xAOD::JetFourMom_t>("JetJMSScaleMomentumTA",jet_reco_TA_FourMom); + + if(want_to_debug && kindofmass == "Comb"){ + printf("Comb jet mass = %f \n", jet_reco_Comb_FourMom.mass()); + printf("Calo jet mass = %f \n", jet_reco_CALO_FourMom.mass()); + printf("TA jet mass = %f \n", jet_reco_TA_FourMom.mass()); + } + + std::unique_ptr<xAOD::Jet> jet_reco_Comb = std::make_unique<xAOD::Jet>(); //You have to initialize the jet object this way. + //If not, oyu will encounter breaks when running + jet_reco_Comb->makePrivateStore(); //And after that we have to give it a private store to avoid a brak when using setJetP4 + jet_reco_Comb->setJetP4(jet_reco_Comb_FourMom); + std::unique_ptr<xAOD::Jet> jet_reco_CALO = std::make_unique<xAOD::Jet>(); + jet_reco_CALO->makePrivateStore(); + jet_reco_CALO->setJetP4(jet_reco_CALO_FourMom); + std::unique_ptr<xAOD::Jet> jet_reco_TA = std::make_unique<xAOD::Jet>(); + jet_reco_TA->makePrivateStore(); + jet_reco_TA->setJetP4(jet_reco_TA_FourMom); + + if(want_to_debug && kindofmass == "Comb"){ + printf("NEW Comb jet mass = %f \n", jet_reco_Comb->m()); + printf("NEW CALO jet mass = %f \n", jet_reco_CALO->m()); + printf("NEW TA jet mass = %f \n", jet_reco_TA->m()); + } + +//------------------------------------------------------------------------------------------------------------------------------------------// + + if(want_to_debug && kindofmass=="Calo"){ printf("CALO jet mass = %f \n", jet_reco->m()); } + if(want_to_debug && kindofmass=="TA"){ printf("TA jet mass = %f \n", jet_reco_TA->m()); } + + if(kindofmass=="TA"){m_JetTruthLabelingTool.modifyJet(*(jet_reco_TA)); };//To tag the TA jet with the jet topology + + + if(!(ffjetsmearingtool.getMatchedTruthJet(*jet_reco, jet_truth_matched).isSuccess())){ continue;} + + if(lead_jet == true){reco_jet_mass_hist->Fill(jet_reco->m()*MeVtoGeV); matched_truth_jet_mass_hist->Fill(jet_truth_matched.m()*MeVtoGeV); } + + if(kindofmass=="TA"){ + + Double_t aux_original_jet_mass = jet_reco->m()*MeVtoGeV; + + ffjetsmearingtool.applyCorrection(*jet_reco_TA); + if(lead_jet == true && aux_original_jet_mass > 0){ + smeared_reco_jet_mass_hist->Fill(jet_reco_TA->m()*MeVtoGeV); lead_jet=false; + + hist_jet_mass_scale_change_3D->Fill(jet_reco->pt()*MeVtoGeV, aux_original_jet_mass, (jet_reco_TA->m()*MeVtoGeV)/*/(aux_original_jet_mass)*/); + } + } + else{ + Double_t aux_original_jet_mass = jet_reco->m()*MeVtoGeV; + + ffjetsmearingtool.applyCorrection(*jet_reco); + + if(lead_jet == true && aux_original_jet_mass > 0){ + smeared_reco_jet_mass_hist->Fill(jet_reco->m()*MeVtoGeV); lead_jet=false; + + hist_jet_mass_scale_change_3D->Fill(jet_reco->pt()*MeVtoGeV, aux_original_jet_mass, (jet_reco->m()*MeVtoGeV)/*/(aux_original_jet_mass)*/); + + hist_jet_mass_resolution_change_3D->Fill(jet_reco->pt()*MeVtoGeV, aux_original_jet_mass, TMath::Abs((jet_reco->m()*MeVtoGeV) - (aux_original_jet_mass))/ aux_original_jet_mass); + + } + } + + if(want_to_debug){ + if(kindofmass=="Comb"){ printf("Comb jet mass after smearing = %f \n", jet_reco->m()); } + if(kindofmass=="Calo"){ printf("CALO jet mass after smearing = %f \n", jet_reco->m()); } + if(kindofmass=="TA"){ printf("TA jet mass after smearing = %f \n", jet_reco_TA->m()); } + } + + //-----------------------------------------------------// + //To test corrected copy function + xAOD::Jet* jet_reco_copy = nullptr; + if( ! ffjetsmearingtool.correctedCopy(*jet_reco, jet_reco_copy) ){//The copy is filled only if the jet passes the conditions to be used inside the Tool + if(want_to_debug){ printf("Failed to fill the corrected copy of the jet \n"); } + } + else{ + if(want_to_debug){ printf("Corrected Copy Comb jet mass after smearing = %f \n", jet_reco_copy->m()); } + } + // Delete the corrected copy: + delete jet_reco_copy; + //-----------------------------------------------------// + + + + } + delete jets_shallowCopy.first; + delete jets_shallowCopy.second; + + }//END: Loop over events + + TString output_path = "output/" + sys.name() + "_" + output ; + + TFile *jetmass_histograms = new TFile(output_path,"recreate"/*"UPDATE"*/); + + + reco_jet_mass_hist->Write(); + matched_truth_jet_mass_hist->Write(); + smeared_reco_jet_mass_hist->Write(); + + + +//------------------------------------------------------------------------------------------------------------// +// 3D plots for testing the JetMassScale and JetMassResolution smearing for each systematic + + TH2F* hist_jet_mass_scale_change_2D = new TH2F("hist_jet_mass_scale_change_2D","hist_jet_mass_scale_change_2D",numBinsPt,0,upperlimit2,numBinsMass,0,upperlimit1); + + for (int i=1; i<=hist_jet_mass_scale_change_3D->GetNbinsX(); i++) + { + for (int j=1; j<= hist_jet_mass_scale_change_3D->GetNbinsY(); j++) + { + TH1F* hold = new TH1F("","",numBinsMass,0,upperlimit1); + for (int k=1; k<= hist_jet_mass_scale_change_3D->GetNbinsZ(); k++) + { + hold->SetBinContent(k,hist_jet_mass_scale_change_3D->GetBinContent(i,j,k)); //A 2D projection of the TH3 + } + hist_jet_mass_scale_change_2D->SetBinContent(i,j,hold->GetMean()/hist_jet_mass_scale_change_3D->GetYaxis()->GetBinCenter(j)); + delete hold; + } + } + + //hist_jet_mass_scale_change_2D->Smooth(1,""); + + TH2F* hist_jet_mass_resolution_change_2D = new TH2F("hist_jet_mass_resolution_change_2D","hist_jet_mass_resolution_change_2D",numBinsPt,0,upperlimit2,numBinsMass,0,upperlimit1); + + for (int i=1; i<=hist_jet_mass_resolution_change_3D->GetNbinsX(); i++) + { + for (int j=1; j<= hist_jet_mass_resolution_change_3D->GetNbinsY(); j++) + { + TH1F* hold = new TH1F("","",numBinsDiff,lowerlimit3,upperlimit3); + for (int k=1; k<= hist_jet_mass_resolution_change_3D->GetNbinsZ(); k++) + { + hold->SetBinContent(k,hist_jet_mass_resolution_change_3D->GetBinContent(i,j,k)); //A 2D projection of the TH3 + } + hist_jet_mass_resolution_change_2D->SetBinContent(i,j,hold->GetMean()/hist_jet_mass_resolution_change_3D->GetYaxis()->GetBinCenter(j)); + delete hold; + } + } + + + + + + TCanvas *c1 = new TCanvas("c1","c1",500,500); + + + hist_jet_mass_scale_change_2D->GetXaxis()->SetTitleOffset(1.5); + hist_jet_mass_scale_change_2D->GetXaxis()->SetNdivisions(5); + hist_jet_mass_scale_change_2D->GetYaxis()->SetTitleOffset(1.5); + hist_jet_mass_scale_change_2D->GetZaxis()->SetTitleOffset(1.5); + hist_jet_mass_scale_change_2D->GetYaxis()->SetTitle("Initial Reco Mass [GeV]"); + hist_jet_mass_scale_change_2D->GetXaxis()->SetTitle("Reco p_{T} [GeV]"); + hist_jet_mass_scale_change_2D->GetZaxis()->SetTitle("Average Mass smearing (Initial_reco_mass/smeared_reco_mass)"); + + hist_jet_mass_scale_change_2D->GetZaxis()->SetRangeUser(0.95,1.05); + + //hist_jet_mass_scale_change_2D->GetXaxis()->SetRangeUser(pt_low_bound,pt_up_bound); + hist_jet_mass_scale_change_2D->Draw("colz"); + + TString output_path_scale_debug = "output/debug_plots/scale_variations/" + sys.name() + "_scaleDebug.pdf" ; + + c1->Print(output_path_scale_debug); + + TCanvas *c2 = new TCanvas("c2","c2",500,500); + + hist_jet_mass_resolution_change_2D->GetXaxis()->SetTitleOffset(1.5); + hist_jet_mass_resolution_change_2D->GetXaxis()->SetNdivisions(5); + hist_jet_mass_resolution_change_2D->GetYaxis()->SetTitleOffset(1.5); + hist_jet_mass_resolution_change_2D->GetZaxis()->SetTitleOffset(1.5); + hist_jet_mass_resolution_change_2D->GetYaxis()->SetTitle("Initial Reco Mass [GeV]"); + hist_jet_mass_resolution_change_2D->GetXaxis()->SetTitle("Reco p_{T} [GeV]"); + hist_jet_mass_resolution_change_2D->GetZaxis()->SetTitle("Average Mass smearing (Initial_reco_mass/smeared_reco_mass)"); + + hist_jet_mass_resolution_change_2D->GetZaxis()->SetRangeUser(-0.1,0.1); + + hist_jet_mass_resolution_change_2D->Draw("colz"); + + TString output_path_resolution_debug = "output/debug_plots/resolution_variations/" + sys.name() + "_resolutionDebug.pdf" ; + + c2->Print(output_path_resolution_debug); + + delete hist_jet_mass_scale_change_2D; + + delete hist_jet_mass_resolution_change_2D; + + delete c1; + delete c2; +//------------------------------------------------------------------------------------------------------------// + + + + + + + jetmass_histograms->Close(); + + delete jetmass_histograms; + + + delete reco_jet_mass_hist; + delete matched_truth_jet_mass_hist; + delete smeared_reco_jet_mass_hist; + + + }//Close the systematics loop + + return 0; +} diff --git a/Reconstruction/Jet/JetUncertainties/util/MakeCorrelationMatrixPlots.cxx b/Reconstruction/Jet/JetUncertainties/util/MakeCorrelationMatrixPlots.cxx index 82c593fa00dd65190ec8e64c0ec6cbdf618b8518..75878fdc6ff1d4bf6e1d93cf6d895b726f5b9b65 100644 --- a/Reconstruction/Jet/JetUncertainties/util/MakeCorrelationMatrixPlots.cxx +++ b/Reconstruction/Jet/JetUncertainties/util/MakeCorrelationMatrixPlots.cxx @@ -14,7 +14,6 @@ #include "TFile.h" #include <vector> -#include <limits> const double fixedRangeDiff = 0; const bool addExtremumInfo = true; @@ -55,7 +54,7 @@ void DrawLabels(const TH2D* histo, const double fixedValue1, const double fixedV } // Add the ATLAS label - ATLASLabel(0.13,minRepStyle?0.825:0.955,"Internal",kBlack); + ATLASLabel(0.13,minRepStyle?0.825:0.955,"",kBlack); // Determine the configuration type (data year, correlation scenario, reduction if applicable) const TString config1 = uncTool->getConfigFile(); @@ -100,9 +99,9 @@ void DrawLabels(const TH2D* histo, const double fixedValue1, const double fixedV } else { - tex->DrawLatex(0.13,0.955,Form("anti-k_{t} #it{R} = %s, %s+JES",jetDef.Contains("AntiKt4") ? "0.4" : jetDef.Contains("AntiKt6") ? "0.6" : "UNKNOWN", jetDef.Contains("EM") ? "EM" : jetDef.Contains("LC") ? "LCW" : "UNKNOWN")); - tex->DrawLatex(0.56,0.955,fixedValString.Data()); - tex->DrawLatex(0.56,0.905,Form("Data %s, #sqrt{s} = %d TeV",year.Data(),year=="2012"?8:year=="2011"?7:year=="2015"||year=="2016"?13:0)); + tex->DrawLatex(0.48,0.960,Form("anti-#it{k}_{t} #it{R} = %s, %s+JES + #it{in situ}",jetDef.Contains("AntiKt4") ? "0.4" : jetDef.Contains("AntiKt6") ? "0.6" : "UNKNOWN", jetDef.Contains("EM") ? "EM" : jetDef.Contains("LC") ? "LCW" : "UNKNOWN")); + tex->DrawLatex(0.48,0.905,fixedValString.Data()); + tex->DrawLatex(0.13,0.905,Form("Data %s, #sqrt{s} = %d TeV",year.Data(),year=="2012"?8:year=="2011"?7:year=="2015"||year=="2016"?13:0)); } @@ -116,9 +115,9 @@ void DrawLabels(const TH2D* histo, const double fixedValue1, const double fixedV if (addExtremumInfo && extremeX > 0 && extremeY > 0) { if (TString(histo->GetXaxis()->GetTitle()).Contains("#it{p}")) - tex->DrawLatex(0.01,0.015,Form("Mean value %.1f%%, max %.1f%% at (%ld,%ld) GeV",mean*100,extremum*100,lround(histo->GetXaxis()->GetBinCenter(extremeX)),lround(histo->GetYaxis()->GetBinCenter(extremeY)))); + tex->DrawLatex(0.01,0.015,Form("Mean value %.2f, max %.2f at (%ld,%ld) GeV",round(100*mean)/100.,round(100*extremum)/100.,lround(histo->GetXaxis()->GetBinCenter(extremeX)),lround(histo->GetYaxis()->GetBinCenter(extremeY)))); else - tex->DrawLatex(0.01,0.015,Form("Mean value %.1f%%, max %.1f%% at (%.2f,%.2f)",mean*100,extremum*100,histo->GetXaxis()->GetBinCenter(extremeX),histo->GetYaxis()->GetBinCenter(extremeY))); + tex->DrawLatex(0.01,0.015,Form("Mean value %.2f, max %.2f at (%.2f,%.2f)",round(100*mean)/100.,round(100*extremum)/100.,histo->GetXaxis()->GetBinCenter(extremeX),histo->GetYaxis()->GetBinCenter(extremeY))); } } @@ -126,10 +125,10 @@ void FormatHisto(TH2D* histo) { histo->SetTitleSize(0.06,"z"); histo->SetLabelSize(0.04,"z"); - histo->SetTitleOffset(1.15,"x"); + histo->SetTitleOffset(1.225,"x"); histo->SetTitleOffset(1.05,"y"); histo->SetTitleOffset(0.76,"z"); - histo->SetLabelOffset(0.003,"x"); + histo->SetLabelOffset(0.002,"x"); histo->GetXaxis()->SetMoreLogLabels(); } @@ -220,11 +219,7 @@ void PlotCorrelationHistos(const TString& outFile,TCanvas* canvas,const std::vec } } //meanDiff /= histo->GetNbinsX()*histo->GetNbinsY(); - if (numValidBins !=0){ - meanDiff /= numValidBins; - } else { - meanDiff = std::numeric_limits<double>::max(); - } + meanDiff /= numValidBins; // Set the range to the maximum (rounded up to nearest multiple of 5) if requested if (fixedRangeDiff < 1.e-3) @@ -390,7 +385,7 @@ int main (int argc, char* argv[]) for (size_t iEta = 0; iEta < fixedEtaS.size(); ++iEta) { std::vector<double> temp = jet::utils::vectorize<double>(fixedEtaS.at(iEta),","); - if (temp.size() == 1 /*&& !makeGrid*/) + if (temp.size() == 1 && !makeGrid) fixedEta.push_back(std::make_pair(temp.at(0),temp.at(0))); else if (temp.size() == 2) fixedEta.push_back(std::make_pair(temp.at(0),temp.at(1))); @@ -431,7 +426,7 @@ int main (int argc, char* argv[]) SetAtlasStyle(); gStyle->SetPalette(1); TCanvas* canvas = new TCanvas("canvas"); - canvas->SetMargin(0.12,0.15,minRepStyle?0.13:0.15,minRepStyle?0.18:0.10); + canvas->SetMargin(0.12,0.15,minRepStyle?0.13:0.135,minRepStyle?0.18:0.115); canvas->SetFillStyle(4000); canvas->SetFillColor(0); canvas->SetFrameBorderMode(0); diff --git a/Reconstruction/Jet/JetUncertainties/util/MakeUncertaintyPlots.cxx b/Reconstruction/Jet/JetUncertainties/util/MakeUncertaintyPlots.cxx index 47b6703bae45d8b5b90d0db2439d1247f8850ce7..8745d8a6eedf5f7f86034f38ce1f0da2bacf9f70 100644 --- a/Reconstruction/Jet/JetUncertainties/util/MakeUncertaintyPlots.cxx +++ b/Reconstruction/Jet/JetUncertainties/util/MakeUncertaintyPlots.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "JetUncertainties/JetUncertaintiesTool.h" @@ -71,14 +71,14 @@ void applyPublicFormat(TGraph& graph) graph.SetLineColor(kBlue); graph.SetLineStyle(2); if (!name.CompareTo("Flav. composition")) - graph.SetName(Form("%s, %s",name.Data(),optHelper.IsDijetComposition()?"inclusive jets":"unknown composition")); + graph.SetName(Form("%s, %s",name.Data(),optHelper.GetCompositionName().Data())); } else if (name.Contains("Flav. response")) { graph.SetLineColor(kGreen+1); graph.SetLineStyle(3); if (!name.CompareTo("Flav. response")) - graph.SetName(Form("%s, %s",name.Data(),optHelper.IsDijetComposition()?"inclusive jets":"unknown composition")); + graph.SetName(Form("%s, %s",name.Data(),optHelper.GetCompositionName().Data())); } else if (name.Contains("Pileup") || name.Contains("Pile-up")) { @@ -169,7 +169,12 @@ void DrawFillLabel(TString txt, double x, double y, TH1 *h, bool logX = optHelpe if (logX) { userxlow = exp(log(xlow) + fracxaxislow*(log(xhigh) - log(xlow))); userxhigh = exp(log(xlow) + fracxaxishigh*(log(xhigh) - log(xlow))); - if (optHelper.IsLargeR()) + if (optHelper.fillShift().first != 0 || optHelper.fillShift().second != 0) + { + userxlow -= optHelper.fillShift().first; + userxhigh -= optHelper.fillShift().second; + } + else if (optHelper.IsLargeR()) { userxlow -= 15; userxhigh -= 15; @@ -177,6 +182,11 @@ void DrawFillLabel(TString txt, double x, double y, TH1 *h, bool logX = optHelpe } else { userxlow = xlow + fracxaxislow*(xhigh - xlow); userxhigh = xlow + fracxaxishigh*(xhigh - xlow); + if (optHelper.fillShift().first != 0 || optHelper.fillShift().second != 0) + { + userxlow -= optHelper.fillShift().first; + userxhigh -= optHelper.fillShift().second; + } if (optHelper.IsTLA()) { userxlow -= 15; @@ -261,7 +271,7 @@ void DrawAtlasLabel(const TString& label = optHelper.GetATLASLabel(), const bool else if (!label.CompareTo("Preliminary")) xPos = 0.67; else if (label == "") - xPos = 0.75; + xPos = 0.8; else xPos = 0.7; } @@ -293,6 +303,16 @@ std::vector<TString> GetJetDesc(const TString& jetAlgoIn) jetAlgo.ReplaceAll("LCTopo",""); jetAlgo.ReplaceAll("TopoLC",""); } + else if (jetAlgo.Contains("EMPFlow")) + { + calib = "PFlow+JES"; + jetAlgo.ReplaceAll("EMPFlow",""); + } + else if (jetAlgo.Contains("TrackCaloCluster")) + { + calib = "TCC+JES"; + jetAlgo.ReplaceAll("TrackCaloCluster",""); + } if (calib == "") { printf("Failed to parse calib for: %s\n",jetAlgoIn.Data()); @@ -429,7 +449,7 @@ TString GetLargeJetDesc(const TString& jetAlgoIn) return ""; } - jetSubPart = Form("Trimmed (f_{cut} = %.2f, #font[52]{R}_{sub} = %.1f)%s",float(jet::utils::getTypeObjFromString<int>(pTfrac))/100.,float(jet::utils::getTypeObjFromString<int>(smallR))/100.,optHelper.IsPublicFormat() ? ", #it{p}_{T}^{jet} > 150 GeV" : ""); + jetSubPart = Form("Trimmed (#it{f}_{cut} = %.2f, #font[52]{R}_{sub} = %.1f)%s",float(jet::utils::getTypeObjFromString<int>(pTfrac))/100.,float(jet::utils::getTypeObjFromString<int>(smallR))/100.,optHelper.IsPublicFormat() ? ", #it{p}_{T}^{jet} > 150 GeV" : ""); } if (jetSubPart == "") @@ -447,9 +467,14 @@ void DrawJetLabel(const JetUncertaintiesTool* provider, const double yPos) { DrawText(GetLargeJetDesc(provider->getJetDef().c_str()),kBlack,yPos); } + else if (TString(provider->getJetDef().c_str()).Contains("Trimmed")) + { + DrawText(GetLargeJetDesc(provider->getJetDef().c_str()),kBlack,yPos-0.035); + } else //DrawText(GetJetDesc(provider->getJetDef().c_str())+" + #it{in situ} correction",kBlack,yPos); - DrawText(GetJetDesc(provider->getJetDef().c_str()).at(0)+" "+GetJetDesc(provider->getJetDef().c_str()).at(1)+", "+GetJetDesc(provider->getJetDef().c_str()).at(2)+" + #it{in situ} correction",kBlack,yPos); + //DrawText(GetJetDesc(provider->getJetDef().c_str()).at(0)+" "+GetJetDesc(provider->getJetDef().c_str()).at(1)+", "+GetJetDesc(provider->getJetDef().c_str()).at(2)+" + #it{in situ}",kBlack,yPos); + DrawText(GetJetDesc(provider->getJetDef().c_str()).at(0)+" "+GetJetDesc(provider->getJetDef().c_str()).at(1)+", "+GetJetDesc(provider->getJetDef().c_str()).at(2),kBlack,yPos); } TString getTagType(const JetUncertaintiesTool* provider) @@ -500,11 +525,26 @@ void DrawYearLabel(const JetUncertaintiesTool* provider, const double yPos) type = "Data 2015"; sqrtS = "13 TeV"; } - else if (release.BeginsWith("2016_Moriond")) + else if (release.BeginsWith("2016_Moriond") || release.BeginsWith("rel21_Moriond2018")) { type = "Data 2016"; sqrtS = "13 TeV"; } + else if (release.BeginsWith("rel21_Summer2018")|| release.BeginsWith("rel21_Fall2018")) + { + type = "Data 2015-2017"; + sqrtS = "13 TeV"; + } + else if (release.BeginsWith("rel21_Moriond2018")) + { + type = "Data 2015+2016"; + sqrtS = "13 TeV"; + } + else if (release.BeginsWith("rel21_Spring2019") || release.BeginsWith("rel21_Summer2019") || release.BeginsWith("rel21_Fall2020")) + { + type = "Data 2015-2017"; + sqrtS = "13 TeV"; + } if (type == "" || sqrtS == "") { printf("Could not parse year information from release: %s\n",release.Data()); @@ -574,12 +614,13 @@ double GetPunchthroughProb(const JetUncertaintiesTool* provider, const xAOD::Jet std::istringstream ss(release.Data()); std::string token; std::getline(ss, token, '_'); - int year = std::stoi(token); + std::cout << "Year: " << token << std::endl; + int year = token == "rel21" ? 2017 : std::stoi(token); if (year > 2012) { - filename = optHelper.GetInputsDir()+"PTprob.root"; + filename = optHelper.GetInputsDir()+"/PTprob.root"; histName = "h_PT_pT_EMJES4_norm"; } else { - filename = optHelper.GetInputsDir()+"PTprob_2012.root"; + filename = optHelper.GetInputsDir()+"/PTprob_2012.root"; if (jetType == "AntiKt4LCTopo") histName = "h_PT_pT_LCJES4_norm"; @@ -642,7 +683,7 @@ void setPileupShiftsForYear(const JetUncertaintiesTool* provider, xAOD::EventInf sigmaMu = 1.9; sigmaNPV = 2.9; } - else if (release.BeginsWith("2016_")) + else if (release.BeginsWith("2016_") || release.BeginsWith("rel21_Moriond2018") || release.BeginsWith("rel21_Summer2018") || release.BeginsWith("rel21_Fall2018") || release.BeginsWith("rel21_Spring2019") || release.BeginsWith("rel21_Summer2019") || release.BeginsWith("rel21_Fall2020") ) { // Kate, Nov 2016 // via Eric Corrigan's pileup studies @@ -661,9 +702,9 @@ void setPileupShiftsForYear(const JetUncertaintiesTool* provider, xAOD::EventInf NPV(*eInfo) = (jet?provider->getRefNPV(*jet):provider->getRefNPV())+sigmaNPV; } -double getQuadratureSumUncertainty(const JetUncertaintiesTool* provider, const std::vector<size_t>& compIndices,const xAOD::Jet& jet,const xAOD::EventInfo& eInfo,const size_t PTindex) +double getQuadratureSumUncertainty(const JetUncertaintiesTool* provider, const std::vector<int>& compIndices,const xAOD::Jet& jet,const xAOD::EventInfo& eInfo,const int PTindex) { - if (compIndices.size() == 0) + if (compIndices.size() == 0 && !optHelper.IgnoreNoMatch()) printf("WARNING: empty vector passed to getQuadratureSumUncertainty\n"); //for (size_t iComp = 0; iComp < compIndices.size(); ++iComp) // printf("Component %zu/%zu (%zu)\n",iComp,compIndices.size(),compIndices.at(iComp)); @@ -676,32 +717,55 @@ double getQuadratureSumUncertainty(const JetUncertaintiesTool* provider, const s else unc = provider->getNormalizedTAMassWeight(jet)/10.; } + else if (compIndices.size() == 1 && (compIndices.at(0) == 6666 || compIndices.at(0) == 7777)) // SPECIAL: nominal MC or data resolution + { + std::vector<jet::CompScaleVar::TypeEnum> scaleVars = optHelper.GetScaleVars(); + if (scaleVars.size() != 1) + printf("WARNING: cannot parse multiple scale variable resolutions at once, using index 0"); + + jet::JetTopology::TypeEnum topology = optHelper.GetTopology(); + + if (compIndices.at(0) == 6666) + unc = provider->getNominalResolutionMC(jet,scaleVars.at(0),topology); + else + unc = provider->getNominalResolutionData(jet,scaleVars.at(0),topology); + } else if (compIndices.size() == 1 && !optHelper.AbsValue()) { - const double factor = compIndices.at(0) != PTindex ? 1 : GetPunchthroughProb(provider,jet); + const double factor = abs(compIndices.at(0)) != PTindex ? 1 : GetPunchthroughProb(provider,jet); + const double inverted = compIndices.at(0) < 0 ? -1 : 1; double localUnc = 0; for (size_t iScaleVar = 0; iScaleVar < optHelper.GetScaleVars().size(); ++iScaleVar) - if (provider->getValidUncertainty(compIndices.at(0),localUnc,jet,eInfo,optHelper.GetScaleVars().at(iScaleVar))) - unc = factor*localUnc; + if (provider->getValidUncertainty(abs(compIndices.at(0)),localUnc,jet,eInfo,optHelper.GetScaleVars().at(iScaleVar))) + unc = factor*localUnc*inverted; } else { for (size_t iComp = 0; iComp < compIndices.size(); ++iComp) { if (compIndices.at(iComp) == 8888 || compIndices.at(iComp) == 9999) continue; + if (compIndices.at(iComp) == 6666 || compIndices.at(iComp) == 7777) continue; const double factor = compIndices.at(iComp) != PTindex ? 1 : GetPunchthroughProb(provider,jet); double localUnc = 0; for (size_t iScaleVar = 0; iScaleVar < optHelper.GetScaleVars().size(); ++iScaleVar) - if (provider->getValidUncertainty(compIndices.at(iComp),localUnc,jet,eInfo,optHelper.GetScaleVars().at(iScaleVar))) - unc += factor*factor*localUnc*localUnc; + { + const double inverted = compIndices.at(iComp) < 0 ? -1 : 1; + if (provider->getValidUncertainty(abs(compIndices.at(iComp)),localUnc,jet,eInfo,optHelper.GetScaleVars().at(iScaleVar))) + unc += factor*factor*localUnc*localUnc*inverted; + } } - unc = sqrt(unc); + if (unc > 0) + unc = sqrt(unc); + else if (optHelper.AbsValue()) + unc = sqrt(-unc); + else + unc = -sqrt(-unc); } return unc; } -std::vector<size_t> getComponentIndicesFromName(const JetUncertaintiesTool* provider,const TString& compName) +std::vector<int> getComponentIndicesFromName(const JetUncertaintiesTool* provider,const TString& compName) { // Map of name to index won't work as we need to worry about wildcard component names // So build a vector @@ -714,7 +778,7 @@ std::vector<size_t> getComponentIndicesFromName(const JetUncertaintiesTool* prov // Now parse component name to index/indices const std::vector<TString> subComponents = jet::utils::vectorize<TString>(compName,","); - std::vector<size_t> indices; + std::vector<int> indices; for (size_t iSubComp = 0; iSubComp < subComponents.size(); ++iSubComp) { // Check for wildcards @@ -724,7 +788,10 @@ std::vector<size_t> getComponentIndicesFromName(const JetUncertaintiesTool* prov const bool ALLCOMP = !subComponents.at(iSubComp).CompareTo("total",TString::kIgnoreCase) || !subComponents.at(iSubComp).CompareTo("#"); const bool CALOWEIGHT = !subComponents.at(iSubComp).CompareTo("caloweight",TString::kIgnoreCase); const bool TAWEIGHT = !subComponents.at(iSubComp).CompareTo("taweight",TString::kIgnoreCase); - const TString toFind = midWild ? subComponents.at(iSubComp) : TString(subComponents.at(iSubComp)).ReplaceAll("#",""); + const bool NOMRESMC = !subComponents.at(iSubComp).CompareTo("nominalresmc",TString::kIgnoreCase); + const bool NOMRESDATA = !subComponents.at(iSubComp).CompareTo("nominalresdata",TString::kIgnoreCase); + const bool inverted = subComponents.at(iSubComp).BeginsWith("INV__"); + const TString toFind = midWild ? subComponents.at(iSubComp) : TString(subComponents.at(iSubComp)).ReplaceAll("#","").ReplaceAll("INV__",""); // Treat the more difficult mid-wild case std::vector<TString> tokensToFind; @@ -761,21 +828,36 @@ std::vector<size_t> getComponentIndicesFromName(const JetUncertaintiesTool* prov indices.push_back(9999); break; } + else if (NOMRESMC) + { + foundIndex = true; + indices.push_back(6666); + break; + } + else if (NOMRESDATA) + { + foundIndex = true; + indices.push_back(7777); + break; + } else if (midWild) { + // There is a wildcard in the middle of the name // Check if the string starts with the first token and ends with the last token // We already ensured there are only two tokens if ( ( provNames.at(iProvComp).BeginsWith(tokensToFind.at(0),TString::kIgnoreCase) || (namePrefix != "" && provNames.at(iProvComp).BeginsWith(namePrefix+tokensToFind.at(0),TString::kIgnoreCase)) ) && provNames.at(iProvComp).EndsWith(tokensToFind.at(1),TString::kIgnoreCase)) { + // The wildcard may cover many components, so keep looping to make sure we find them all foundIndex = true; indices.push_back(iProvComp); - break; } } else if (!beginWild && !endWild) { + // Direct name equalitty (no wildcards) if (!provNames.at(iProvComp).CompareTo(toFind,TString::kIgnoreCase) || ( namePrefix != "" && !provNames.at(iProvComp).CompareTo(namePrefix+toFind,TString::kIgnoreCase) ) ) { + // There can only be one component with a given name, so break out if we find it foundIndex = true; indices.push_back(iProvComp); break; @@ -783,24 +865,31 @@ std::vector<size_t> getComponentIndicesFromName(const JetUncertaintiesTool* prov } else if (beginWild && !endWild) { + // The start of the name is a wildcard if (provNames.at(iProvComp).EndsWith(toFind,TString::kIgnoreCase)) { + // The wildcard may cover many components, so keep looping to make sure we find them all foundIndex = true; indices.push_back(iProvComp); } } else if (!beginWild && endWild) { + // The end of the name is a wildcard if (provNames.at(iProvComp).BeginsWith(toFind,TString::kIgnoreCase) || ( namePrefix != "" && provNames.at(iProvComp).BeginsWith(namePrefix+toFind,TString::kIgnoreCase) ) ) { + // The wildcard may cover many components, so keep looping to make sure we find them all foundIndex = true; indices.push_back(iProvComp); } } else { + // There are wildcards at the start and end of the name + // Look for the desired substring within the name if (provNames.at(iProvComp).Contains(toFind,TString::kIgnoreCase)) { + // The wildcards may cover many components, so keep looping to make sure we find them all foundIndex = true; indices.push_back(iProvComp); } @@ -808,9 +897,11 @@ std::vector<size_t> getComponentIndicesFromName(const JetUncertaintiesTool* prov } if (!foundIndex) printf("WARNING: Failed to find match for sub/component: %s\n",toFind.Data()); + else if (inverted) + indices.back() *= -1; } - if (!indices.size()) + if (!indices.size() && !optHelper.IgnoreNoMatch()) { printf("Failed to find any indices for component: %s\n",compName.Data()); exit(-1); @@ -819,9 +910,9 @@ std::vector<size_t> getComponentIndicesFromName(const JetUncertaintiesTool* prov return indices; } -std::vector< std::vector<size_t> > getComponentIndicesFromNames(const JetUncertaintiesTool* provider,const std::vector<TString>& compNames) +std::vector< std::vector<int> > getComponentIndicesFromNames(const JetUncertaintiesTool* provider,const std::vector<TString>& compNames) { - std::vector< std::vector<size_t> > indices; + std::vector< std::vector<int> > indices; // Now parse all of the names to provider indices for (size_t iComp = 0; iComp < compNames.size(); ++iComp) @@ -832,10 +923,12 @@ std::vector< std::vector<size_t> > getComponentIndicesFromNames(const JetUncerta { printf("Parsed component named: %s\n",compNames.at(iComp).Data()); for (size_t iIndex = 0; iIndex < indices.at(iComp).size(); ++iIndex) - if (indices.at(iComp).at(iIndex) < provider->getNumComponents()) - printf("\t %zu: %s\n",indices.at(iComp).at(iIndex),provider->getComponentName(indices.at(iComp).at(iIndex)).c_str()); + if (indices.at(iComp).at(iIndex) >= 0 && indices.at(iComp).at(iIndex) < static_cast<int>(provider->getNumComponents())) + printf("\t %d: %s\n",indices.at(iComp).at(iIndex),provider->getComponentName(indices.at(iComp).at(iIndex)).c_str()); + else if (indices.at(iComp).at(iIndex) < 0) + printf("\t %d: INVERTED %s\n",indices.at(iComp).at(iIndex)*-1,provider->getComponentName(indices.at(iComp).at(iIndex)*-1).c_str()); else - printf("\t %zu: SPECIAL\n",indices.at(iComp).at(iIndex)); + printf("\t %d: SPECIAL\n",indices.at(iComp).at(iIndex)); } return indices; @@ -843,11 +936,12 @@ std::vector< std::vector<size_t> > getComponentIndicesFromNames(const JetUncerta -void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vector<JetUncertaintiesTool*>& providers,const std::vector< std::vector< std::vector<size_t> > >& compSetIndices,const std::vector< std::vector<TString> >& labelNames,TH1D* frame,const double fixedValue,const std::vector<double>& scanBins,const bool fixedIsEta, const float mOverPt, const bool doComparison, const bool doCompareOnly) +void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vector<JetUncertaintiesTool*>& providers,const std::vector< std::vector< std::vector<int> > >& compSetIndices,const std::vector< std::vector<TString> >& labelNames,TH1D* frame,const double fixedValue,const std::vector<double>& scanBins,const bool fixedIsEta, const float mOverPt, const bool doComparison, const bool doCompareOnly, const bool mOverPtIsMass) { static SG::AuxElement::Accessor<int> Nsegments("GhostMuonSegmentCount"); static SG::AuxElement::Accessor<char> IsBjet("IsBjet"); static SG::AuxElement::Accessor<float> minDR("MinDR"); + static SG::AuxElement::Accessor<int> NJets("Njet"); // Combined mass helpers static jet::JetFourMomAccessor scaleCalo(jet::CompMassDef::getJetScaleString(jet::CompMassDef::CaloMass).Data()); @@ -884,6 +978,7 @@ void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vect eInfos->setStore(new xAOD::EventInfoAuxContainer()); eInfos->push_back(new xAOD::EventInfo()); xAOD::EventInfo* eInfo = eInfos->at(0); + if (optHelper.GetNjetFlavour() != -1) NJets(*eInfo) = optHelper.GetNjetFlavour(); size_t indexHelper = 0; @@ -902,6 +997,32 @@ void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vect jet->setJetP4(xAOD::JetFourMom_t(100.e3,0.,0.,0.)); setPileupShiftsForYear(provider,eInfo,jet); } + + // Fix the jet flavour if relevant + if (optHelper.FixedTruthLabel()) + { + jet->setAttribute("PartonTruthLabelID",optHelper.FixedTruthLabel()); + std::cout << "Fixed PartonTruthLabelID to " << optHelper.FixedTruthLabel() << std::endl; + } + + // Fix the large-R jet truth label if relevant + if (optHelper.FixedLargeRJetTruthLabel() != LargeRJetTruthLabel::UNKNOWN) + { + jet->setAttribute("LargeRJetTruthLabel",LargeRJetTruthLabel::enumToInt(optHelper.FixedLargeRJetTruthLabel())); + std::cout << "Fixed LargeRJetTruthLabel" << std::endl; + } + // Fix the Large-R jet tag accept if relevant + // TODO: enable when available + // if (optHelper.FixedLargeRJetTagAccept() != TagResult::UNKNOWN) + // { + // if (optHelper.FixedLargeRJetTagResultName() == "") + // { + // std::cout << "Unable to determine largeR jet tag result name, exiting for safety" << std::endl; + // exit(1); + // } + // jet->setAttribute(optHelper.FixedLargeRJetTagResultName().Data(),optHelper.FixedLargeRJetTagAccept()); + // std::cout << "Fixed tag result to " << optHelper.FixedLargeRJetTagAccept() << " for name " << optHelper.FixedLargeRJetTagResultName().Data() << std::endl; + // } // One totalHist per provider totalHists.push_back(new TH1D(Form("Total_%zu_hist",iProv),"",scanBins.size()-1,&scanBins[0])); @@ -918,10 +1039,10 @@ void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vect totalGraph->SetLineColor(kBlack); // One list of all indices per provider - const std::vector<size_t> allIndices = getComponentIndicesFromName(provider,"total"); + const std::vector<int> allIndices = getComponentIndicesFromName(provider,"total"); // Find the punch-through index, if applicable - size_t PTindex = allIndices.size(); + int PTindex = static_cast<int>(allIndices.size()); for (size_t iComp = 0; iComp < provider->getNumComponents(); ++iComp) if (TString(provider->getComponentName(iComp).c_str()).Contains("PunchThrough",TString::kIgnoreCase)) { @@ -956,7 +1077,7 @@ void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vect // Build the jet to work with const double pt = (fixedIsEta ? binValue : fixedValue)*1.e3; const double eta = (fixedIsEta ? fixedValue : binValue); - const double mass = mOverPt*pt; + const double mass = mOverPtIsMass ? mOverPt*1.e3 : mOverPt*pt; jet->setJetP4(xAOD::JetFourMom_t(pt,eta,0,mass)); // Combined mass helpers @@ -975,6 +1096,14 @@ void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vect if (pt > 1.5e6) isZero = true; + // Fix the TagScaleFactor to start at 1 to start with for scale factor uncertainties + std::vector<jet::CompScaleVar::TypeEnum> scaleVars = optHelper.GetScaleVars(); + if (optHelper.TagScaleFactorName() != "") + { + jet->setAttribute(optHelper.TagScaleFactorName().Data(),1.0); + //std::cout << "Set " << optHelper.TagScaleFactorName().Data() << " to 1.0" << std::endl; + } + // Fill components for (size_t iComp = 0; iComp < compSetIndices.at(iProv).size(); ++iComp) { @@ -1002,12 +1131,17 @@ void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vect // Build the jet to work with const double pt = (fixedIsEta ? binValue : fixedValue)*1.e3; const double eta = (fixedIsEta ? fixedValue : binValue); - const double mass = mOverPt*pt; + const double mass = mOverPtIsMass ? mOverPt*1.e3 : mOverPt*pt; jet->setJetP4(xAOD::JetFourMom_t(pt,eta,0,mass)); // Combined mass helpers - scaleCalo(*jet) = xAOD::JetFourMom_t(pt,eta,0,mass); - scaleTA(*jet) = xAOD::JetFourMom_t(pt,eta,0,mass); + scaleCalo.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass)); + scaleTA.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass)); + scaleCombQCD.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass)); + scaleCombWZ.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass)); + scaleCombHbb.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass)); + scaleCombTop.setAttribute(*jet, xAOD::JetFourMom_t(pt,eta,0,mass)); + scaleTAMoment(*jet) = mass ; // Kinematic cut when comparing large-R pre-recs bool isZero = false; @@ -1155,13 +1289,21 @@ void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vect const TString thisconfname = providers.at(i)->getConfigFile().c_str(); if (!(thisconfname.Contains("_2012/"))) sign = false; } + bool sameRelease = true; + const TString release0 = providers.at(0)->getRelease(); + for (size_t i=1; i<providers.size(); ++i) + if (providers.at(i)->getRelease() != release0) + sameRelease = false; if (optHelper.IsLargeR()) { DrawJetLabel(providers.at(0),0.83); - if (providers.size() == 1 || (providers.size()==2 && doComparison) || sign) + if (providers.size() == 1 || (providers.size()==2 && doComparison) || sign || sameRelease) DrawYearLabel(providers.at(0),0.92); //DrawText(Form("|#eta| = %.1f, M/#it{p}_{T}^{jet} = %.2f%s",fixedValue,mOverPt,optHelper.SpecifyTagger()?Form(", %s tagged",getTagType(providers.at(0)).Data()):""),kBlack,0.75); - DrawText(Form("|#eta_{jet}| < 2, m_{jet}/#it{p}_{T}^{jet} = %.2f%s",mOverPt,optHelper.SpecifyTagger()?Form(", %s tagged",getTagType(providers.at(0)).Data()):""),kBlack,0.73); + if (mOverPtIsMass) + DrawText(Form("|#eta_{jet}| < 2, m = %.0f GeV%s",mOverPt,optHelper.SpecifyTagger()?Form(", %s tagged",getTagType(providers.at(0)).Data()):""),kBlack,0.73); + else + DrawText(Form("|#eta_{jet}| < 2, m_{jet}/#it{p}_{T}^{jet} = %.2f%s",mOverPt,optHelper.SpecifyTagger()?Form(", %s tagged",getTagType(providers.at(0)).Data()):""),kBlack,0.73); } else { @@ -1173,15 +1315,25 @@ void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vect DrawJetLabel(providers.at(0),0.855);//0.905); - if (providers.size() == 1 || (providers.size()==2 && doComparison) || sign) + if (providers.size() == 1 || (providers.size()==2 && doComparison) || sign || sameRelease) DrawYearLabel(providers.at(0),0.910);//0.860); - DrawText(fixedIsEta?Form("#eta = %.1f",fixedValue):Form("#it{p}_{T}^{jet} = %.0f GeV",fixedValue),kBlack,0.81); - DrawScenarioLabel(providers.at(0),0.77); // 0.77 + if (mOverPtIsMass) + DrawText(fixedIsEta?Form("#eta = %.1f, m = %.0f GeV",fixedValue,mOverPt):Form("#it{p}_{T}^{jet} = %.0f GeV",fixedValue),kBlack,TString(providers.at(0)->getJetDef().c_str()).Contains("Trimmed") ? 0.74 : 0.805); + else if (optHelper.GetFixedMoverPtVals().size() > 1) + DrawText(fixedIsEta?Form("#eta = %.1f, m/p_{T} = %.2f",fixedValue,mOverPt):Form("#it{p}_{T}^{jet} = %.0f GeV",fixedValue),kBlack,TString(providers.at(0)->getJetDef().c_str()).Contains("Trimmed") ? 0.74 : 0.805); + else + DrawText(fixedIsEta?Form("#eta = %.1f",fixedValue):Form("#it{p}_{T}^{jet} = %.0f GeV",fixedValue),kBlack,TString(providers.at(0)->getJetDef().c_str()).Contains("Trimmed") ? 0.74 : 0.805); + DrawScenarioLabel(providers.at(0),0.76); // 0.77 } // Add legend - double legx=0.41, legy=!optHelper.IsLargeR()?0.78:0.68, dy = 0.045; //dy=0.070; + double legx=0.41, legy=0.78, dy = 0.045; //dy=0.070; + if (optHelper.IsLargeR()) + legy = 0.68; + else if (TString(providers.at(0)->getJetDef().c_str()).Contains("Trimmed")) + legy = 0.73; + if (doCompareOnly) { for (size_t i=0; i < totalGraphs.size(); i++) { const TString title = labelNames.at(i).at(0); @@ -1214,20 +1366,42 @@ void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vect legy -= 0.35*dy; } else if (optHelper.IsLargeR() && !optHelper.IsPublicFormat()) - DrawLineLabel(label,legx-0.10+0.3*(iComp%2),legy-=(dy*((iComp+1)%2)),compGraph); + DrawLineLabel(label,legx-0.125+0.3*(iComp%2),legy-=(dy*((iComp+1)%2)),compGraph); else if (optHelper.IsLargeR()) DrawLineLabel(label,legx,legy-=(dy+0.005),compGraph); + else if (optHelper.TwoColumnLegend()) + DrawLineLabel(label,legx-0.125+0.3*(iComp%2),legy-=(dy*((iComp+1)%2)),compGraph); else DrawLineLabel(label,legx,legy-=dy,compGraph); } // Write the plot frame->Draw("axis same"); - if (!outFile.EndsWith(".eps") && !outFile.EndsWith(".png")) - canvas->Print(outFile); + + // Ensure we don't have debugging enabled + if (optHelper.GetDumpFile() == "") + { + if (!outFile.EndsWith(".eps") && !outFile.EndsWith(".png")) + canvas->Print(outFile); + else + canvas->Print(TString(outFile).ReplaceAll(outFile.EndsWith(".eps")?".eps":".png",Form("/fig_%s_%s.%s",fixedIsEta?"eta":"pt",fixedIsEta?Form("%.1f",fixedValue):Form("%.0f",fixedValue),outFile.EndsWith(".eps")?"eps":"png"))); + } else - canvas->Print(TString(outFile).ReplaceAll(outFile.EndsWith(".eps")?".eps":".png",Form("/fig_%s_%s.%s",fixedIsEta?"eta":"pt",fixedIsEta?Form("%.1f",fixedValue):Form("%.0f",fixedValue),outFile.EndsWith(".eps")?"eps":"png"))); - + { + // Debug mode, just write out the graphs + printf("Preparing to dump to file: %s\n",optHelper.GetDumpFile().Data()); + TFile* dumpFile = TFile::Open(optHelper.GetDumpFile(),"NEW"); + dumpFile->cd(); + for (size_t iSet = 0; iSet < compGraphs.size(); ++iSet) + { + for (size_t iComp = 0 ; iComp < compGraphs.at(iSet).size(); ++iComp) + { + compGraphs.at(iSet).at(iComp)->Write(); + } + } + dumpFile->Close(); + } + // Free graphs/hists for (size_t iProv = 0; iProv < providers.size(); ++iProv) { @@ -1250,6 +1424,7 @@ void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vect const std::vector<double> ptValuesForEtaScan = optHelper.GetFixedPtVals(); const std::vector<double> etaValuesForPtScan = optHelper.GetFixedEtaVals(); const std::vector<double> mOverPtValuesForPtScan = optHelper.GetFixedMoverPtVals(); + const std::vector<double> massValuesForPtScan = optHelper.GetFixedMassVals(); // Scan ranges: all recently moved to 10x the bins const std::vector<double> etaScanValues = optHelper.GetEtaBins(); @@ -1258,25 +1433,73 @@ void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vect // Create the frames TH1D* frameEtaScan = new TH1D("frameEtaScan","",etaScanValues.size()-1,&etaScanValues[0]); TH1D* framePtScan = new TH1D("framePtScan","",ptScanValues.size()-1,&ptScanValues[0]); - const TString yAxisLabel = optHelper.IsJER()?"Uncertainty on #sigma(#it{p}_{T})/#it{p}_{T}" - : Form("Fractional J%sS uncertainty", - optHelper.GetScaleVars().size()==1 && optHelper.GetScaleVars().at(0)==jet::CompScaleVar::FourVec ? "E" - : optHelper.GetScaleVars().size()==1 && optHelper.GetScaleVars().at(0)==jet::CompScaleVar::Pt ? "Pt" - : optHelper.GetScaleVars().size()==1 && optHelper.GetScaleVars().at(0)==jet::CompScaleVar::Mass ? Form("M_{%s}",optHelper.getMassType().Data()) - : optHelper.GetScaleVars().size()==1 && optHelper.GetScaleVars().at(0)==jet::CompScaleVar::D12 ? "D_{12}" - : optHelper.GetScaleVars().size()==1 && optHelper.GetScaleVars().at(0)==jet::CompScaleVar::D23 ? "D_{23}" - : optHelper.GetScaleVars().size()==1 && optHelper.GetScaleVars().at(0)==jet::CompScaleVar::Tau21WTA ? "#tau_{21}^{wta}" - : optHelper.GetScaleVars().size()==1 && optHelper.GetScaleVars().at(0)==jet::CompScaleVar::Tau32WTA ? "#tau_{32}^{wta}" - : optHelper.GetScaleVars().size()==1 && optHelper.GetScaleVars().at(0)==jet::CompScaleVar::D2Beta1 ? "D_{2}" - : optHelper.GetScaleVars().size()==1 && optHelper.GetScaleVars().at(0)==jet::CompScaleVar::Qw ? "Qw" - : "?" - ); + + TString yAxisVar = ""; + if (optHelper.GetScaleVars().size() == 1) + { + switch (optHelper.GetScaleVars().at(0)) + { + case jet::CompScaleVar::FourVec: + yAxisVar = "E"; + break; + case jet::CompScaleVar::FourVecRes: + case jet::CompScaleVar::FourVecResAbs: + yAxisVar = "#it{p}_{T}"; // JER is evaluated on pT + break; + case jet::CompScaleVar::Pt: + case jet::CompScaleVar::PtRes: + case jet::CompScaleVar::PtResAbs: + yAxisVar = "#it{p}_{T}"; + break; + case jet::CompScaleVar::Mass: + case jet::CompScaleVar::MassRes: + case jet::CompScaleVar::MassResAbs: + yAxisVar = "M"; + break; + case jet::CompScaleVar::D12: + yAxisVar = "D_{12}"; + break; + case jet::CompScaleVar::D23: + yAxisVar = "D_{23}"; + break; + case jet::CompScaleVar::Tau21: + yAxisVar = "#tau_{21}"; + break; + case jet::CompScaleVar::Tau21WTA: + yAxisVar = "#tau_{21}^{wta}"; + break; + case jet::CompScaleVar::Tau32: + yAxisVar = "#tau_{32}"; + break; + case jet::CompScaleVar::Tau32WTA: + yAxisVar = "#tau_{32}^{wta}"; + break; + case jet::CompScaleVar::D2Beta1: + yAxisVar = "D_{2}"; + break; + case jet::CompScaleVar::C2Beta1: + yAxisVar = "C_{2}"; + break; + case jet::CompScaleVar::Qw: + yAxisVar = "Qw"; + break; + default: + yAxisVar = "?"; + } + } + + const TString yAxisLabel = optHelper.GetScaleVars().size() != 1 ? "Unknown" : + jet::CompScaleVar::isScaleType(optHelper.GetScaleVars().at(0)) ? + Form("Fractional J%sS uncertainty",yAxisVar.Data()) + : jet::CompScaleVar::isResolutionType(optHelper.GetScaleVars().at(0)) ? + Form("Uncertainty on #sigma(%s)/%s",yAxisVar.Data(),yAxisVar.Data()) + : "Unknown scale type"; frameEtaScan->GetXaxis()->SetTitleOffset(1.4); - frameEtaScan->GetYaxis()->SetTitleOffset(!optHelper.IsJER()?1.25:1.1); + frameEtaScan->GetYaxis()->SetTitleOffset(optHelper.GetScaleVars().size() == 1 && jet::CompScaleVar::isScaleType(optHelper.GetScaleVars().at(0))?1.25:1.125); frameEtaScan->GetXaxis()->SetTitle("#eta"); frameEtaScan->GetYaxis()->SetTitle(yAxisLabel.Data()); framePtScan->GetXaxis()->SetTitleOffset(1.4); - framePtScan->GetYaxis()->SetTitleOffset(!optHelper.IsJER()?1.25:1.1); + framePtScan->GetYaxis()->SetTitleOffset(optHelper.GetScaleVars().size() == 1 && jet::CompScaleVar::isScaleType(optHelper.GetScaleVars().at(0))?1.25:1.125); framePtScan->GetXaxis()->SetTitle("#it{p}_{T}^{jet} [GeV]"); framePtScan->GetYaxis()->SetTitle(yAxisLabel.Data()); framePtScan->GetXaxis()->SetMoreLogLabels(); @@ -1289,7 +1512,7 @@ void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vect // Convert components to indices - std::vector< std::vector< std::vector<size_t> > > compSetIndices; + std::vector< std::vector< std::vector<int> > > compSetIndices; for (size_t iProv = 0; iProv < providers.size(); ++iProv) compSetIndices.push_back(getComponentIndicesFromNames(providers.at(iProv),compSetComponents.at(iProv))); @@ -1297,14 +1520,32 @@ void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vect if (!optHelper.IsLargeR()) { for (size_t iFixed = 0; iFixed < etaValuesForPtScan.size(); ++iFixed) - MakeUncertaintyPlots(outFile,canvas,providers,compSetIndices,labelNames,framePtScan,etaValuesForPtScan.at(iFixed),ptScanValues,true,mOverPtValuesForPtScan.at(0),doComparison, doCompareOnly); + MakeUncertaintyPlots(outFile,canvas,providers,compSetIndices,labelNames,framePtScan,etaValuesForPtScan.at(iFixed),ptScanValues,true,mOverPtValuesForPtScan.at(0),doComparison, doCompareOnly,false); for (size_t iFixed = 0; iFixed < ptValuesForEtaScan.size(); ++iFixed) - MakeUncertaintyPlots(outFile,canvas,providers,compSetIndices,labelNames,frameEtaScan,ptValuesForEtaScan.at(iFixed),etaScanValues,false,mOverPtValuesForPtScan.at(0),doComparison, doCompareOnly); + MakeUncertaintyPlots(outFile,canvas,providers,compSetIndices,labelNames,frameEtaScan,ptValuesForEtaScan.at(iFixed),etaScanValues,false,mOverPtValuesForPtScan.at(0),doComparison, doCompareOnly,false); + if (massValuesForPtScan.size()) + { + for (size_t iFixed = 0; iFixed < massValuesForPtScan.size(); ++iFixed) + MakeUncertaintyPlots(outFile,canvas,providers,compSetIndices,labelNames,framePtScan,etaValuesForPtScan.size() ? etaValuesForPtScan.at(0) : 0,ptScanValues,true,massValuesForPtScan.at(iFixed),doComparison,doCompareOnly,true); + } + if (mOverPtValuesForPtScan.size() > 1) + { + for (size_t iFixed = 0; iFixed < mOverPtValuesForPtScan.size(); ++iFixed) + MakeUncertaintyPlots(outFile,canvas,providers,compSetIndices,labelNames,framePtScan,etaValuesForPtScan.size() ? etaValuesForPtScan.at(0) : 0,ptScanValues,true,mOverPtValuesForPtScan.at(iFixed),doComparison,doCompareOnly,false); + } } else { - for (size_t iFixed = 0; iFixed < mOverPtValuesForPtScan.size(); ++iFixed) - MakeUncertaintyPlots(outFile,canvas,providers,compSetIndices,labelNames,framePtScan,etaValuesForPtScan.at(0),ptScanValues,true,mOverPtValuesForPtScan.at(iFixed),doComparison, doCompareOnly); + if (massValuesForPtScan.size()) + { + for (size_t iFixed = 0; iFixed < massValuesForPtScan.size(); ++iFixed) + MakeUncertaintyPlots(outFile,canvas,providers,compSetIndices,labelNames,framePtScan,etaValuesForPtScan.at(0),ptScanValues,true,massValuesForPtScan.at(iFixed),doComparison,doCompareOnly,true); + } + else + { + for (size_t iFixed = 0; iFixed < mOverPtValuesForPtScan.size(); ++iFixed) + MakeUncertaintyPlots(outFile,canvas,providers,compSetIndices,labelNames,framePtScan,etaValuesForPtScan.at(0),ptScanValues,true,mOverPtValuesForPtScan.at(iFixed),doComparison, doCompareOnly,false); + } } @@ -1312,18 +1553,6 @@ void MakeUncertaintyPlots(const TString& outFile,TCanvas* canvas,const std::vect delete frameEtaScan; } -// Add your root files here if you are doing additional studies -TString getCompFile() { - - TString tmpFile; // const - if (optHelper.IsDijetComposition()) tmpFile = optHelper.GetInputsDir()+"/../random_stuff/DijetFlavourComp_Run2.root"; - else if (optHelper.IsGinosComposition()) tmpFile = optHelper.GetInputsDir()+"/../random_stuff/random_stuff/GinoComposition.root"; - else if (optHelper.IsReginasComposition()) tmpFile = optHelper.GetInputsDir()+"/../random_stuff/TTBarFlavourComp.root"; - else tmpFile = ""; - - return tmpFile; - -} int main (int argc, char* argv[]) { @@ -1360,6 +1589,7 @@ int main (int argc, char* argv[]) StatusCode::enableFailure(); bool doComparison = false; + bool compareJetDefs = false; TString compareMCType = ""; TString totalLabel = ""; TString otherJetDef = ""; @@ -1379,7 +1609,11 @@ int main (int argc, char* argv[]) mcTypes.push_back(compareMCType); compSets.push_back(""); labelSets.push_back(totalLabel); - if (comparisons.size()>3) jetDefs.push_back(comparisons.at(3)); + if (comparisons.size()>3) + { + compareJetDefs = true; + jetDefs.push_back(comparisons.at(3)); + } } bool doCompareOnly = optHelper.CompareOnly(); @@ -1461,16 +1695,20 @@ int main (int argc, char* argv[]) canvas->SetFrameBorderMode(0); canvas->cd(); - // If this is not an eps, start the output - if (!outFile.EndsWith(".eps") && !outFile.EndsWith(".png")) - canvas->Print(outFile+"["); - // Otherwise, make a folder for the eps files - else - system(Form("mkdir -p %s",TString(outFile).ReplaceAll(outFile.EndsWith(".eps")?".eps":".png","").Data())); - + // Ensure we don't have debugging enabled + if (optHelper.GetDumpFile() == "") + { + // If this is not an eps, start the output + if (!outFile.EndsWith(".eps") && !outFile.EndsWith(".png")) + canvas->Print(outFile+"["); + // Otherwise, make a folder for the eps files + else + system(Form("mkdir -p %s",TString(outFile).ReplaceAll(outFile.EndsWith(".eps")?".eps":".png","").Data())); + + } // Run once per jet type - if (!(jetDefs.size() == configs.size() && jetDefs.size() != 1) || (doComparison && jetDefs.size() != 1)) + if (!(jetDefs.size() == configs.size() && jetDefs.size() != 1) || (doComparison && jetDefs.size() != 1 && !compareJetDefs)) { std::cout << "Going to process for multiple jet types!" << std::endl; @@ -1502,9 +1740,14 @@ int main (int argc, char* argv[]) printf("Failed to set ConfigFile to %s\n",configs.at(iConfig).Data()); exit(6); } + if (providers.back()->setProperty("IsData",optHelper.GetIsData()).isFailure()) + { + printf("Failed to set IsData to %s\n",optHelper.GetIsData() ? "true" : "false"); + exit(7); + } // Check if we want to change topology from unknown to dijet - const TString analysisFile = getCompFile(); + const TString analysisFile = optHelper.GetCompositionPath(); if (analysisFile) { @@ -1515,6 +1758,26 @@ int main (int argc, char* argv[]) } } + // Check if we want to set the CalibArea + if (optHelper.GetCalibArea() != "") + { + if (providers.back()->setProperty("CalibArea",optHelper.GetCalibArea().Data()).isFailure()) + { + printf("Failed to set CalibArea to %s\n",optHelper.GetCalibArea().Data()); + exit(7); + } + } + + // Check if we want to set the Path + if (optHelper.GetPath() != "") + { + if (providers.back()->setProperty("Path",optHelper.GetPath().Data()).isFailure()) + { + printf("Failed to set Path to %s\n",optHelper.GetPath().Data()); + exit(7); + } + } + // Set filters if specified if (optHelper.VariablesToShift().size()) @@ -1554,7 +1817,7 @@ int main (int argc, char* argv[]) const TString jetDef = jetDefs.at(iJetDef); const TString config = configs.at(iJetDef); - //Make a new provier + //Make a new provider providers.push_back(new JetUncertaintiesTool(Form("%s_%zu",jetDef.Data(),iJetDef))); //Set properties @@ -1573,9 +1836,14 @@ int main (int argc, char* argv[]) printf("Failed to set ConfigFile to %s\n",configs.at(iJetDef).Data()); exit(6); } + if (providers.back()->setProperty("IsData",optHelper.GetIsData()).isFailure()) + { + printf("Failed to set IsData to %s\n",optHelper.GetIsData() ? "true" : "false"); + exit(7); + } // Check if we want to change topology from unknown to dijet - const TString analysisFile = getCompFile(); + const TString analysisFile = optHelper.GetCompositionPath(); if (analysisFile) { @@ -1585,6 +1853,27 @@ int main (int argc, char* argv[]) exit(7); } } + + + // Check if we want to set the CalibArea + if (optHelper.GetCalibArea() != "") + { + if (providers.back()->setProperty("CalibArea",optHelper.GetCalibArea().Data()).isFailure()) + { + printf("Failed to set CalibArea to %s\n",optHelper.GetCalibArea().Data()); + exit(7); + } + } + + // Check if we want to set the Path + if (optHelper.GetPath() != "") + { + if (providers.back()->setProperty("Path",optHelper.GetPath().Data()).isFailure()) + { + printf("Failed to set Path to %s\n",optHelper.GetPath().Data()); + exit(7); + } + } // Set filters if specified @@ -1614,9 +1903,13 @@ int main (int argc, char* argv[]) providers.clear(); } - // If this is not an eps, end the output - if (!outFile.EndsWith(".eps") && !outFile.EndsWith(".png")) - canvas->Print(outFile+"]"); + // Ensure we don't have debugging enabled + if (optHelper.GetDumpFile() == "") + { + // If this is not an eps, end the output + if (!outFile.EndsWith(".eps") && !outFile.EndsWith(".png")) + canvas->Print(outFile+"]"); + } return 0; } diff --git a/Reconstruction/Jet/JetUncertainties/util/OptionHelper.h b/Reconstruction/Jet/JetUncertainties/util/OptionHelper.h index c415a417180043806acb195d0b9a5fc71abf20c7..5c955633f65a91164136ab8382f6f4924935b6e1 100644 --- a/Reconstruction/Jet/JetUncertainties/util/OptionHelper.h +++ b/Reconstruction/Jet/JetUncertainties/util/OptionHelper.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef JETUNCERTAINTIES_OPTIONHELPER_H @@ -8,9 +8,13 @@ #include "AsgMessaging/AsgMessaging.h" #include <vector> #include <utility> +#include <stdexcept> #include "TString.h" #include "JetUncertainties/Helpers.h" #include "JetUncertainties/UncertaintyEnum.h" +#include "ParticleJetTools/LargeRJetLabelEnum.h" +// TODO: enable when available +// #include "BoostedJetTaggers/TagResultEnum.h" namespace jet { @@ -32,6 +36,10 @@ class OptionHelper : public asg::AsgMessaging bool IsEtaDepPileup() const { checkInit(); return m_isEtaDepPU; } bool IgnorePT() const { checkInit(); return m_ignorePT; } TString GetNamePrefix() const { checkInit(); return m_compNamePrefix; } + TString GetCalibArea() const { checkInit(); return m_calibArea; } + TString GetPath() const { checkInit(); return m_path; } + bool GetIsData() const { checkInit(); return m_isData; } + bool IgnoreNoMatch() const { checkInit(); return m_ignoreNoMatch; } // Plot control bool DoATLASLabel() const { checkInit(); return m_doATLASLabel; } @@ -46,12 +54,15 @@ class OptionHelper : public asg::AsgMessaging bool AbsValue() const { checkInit(); return m_absVal; } bool LogPt() const { checkInit(); return m_logPt; } TString getMassType() const { checkInit(); return m_massType; } + std::pair<double,double> fillShift() const { checkInit(); return m_fillShift; } + bool TwoColumnLegend() const { checkInit(); return m_twoColumnLegend; } std::vector<double> GetPtBins() const; std::vector<double> GetEtaBins() const; std::vector<double> GetFixedPtVals() const; std::vector<double> GetFixedEtaVals() const; std::vector<double> GetFixedMoverPtVals() const; + std::vector<double> GetFixedMassVals() const; // Uncertainty types bool IsSmallR() const { checkInit(); return m_isSmallR; } @@ -60,10 +71,17 @@ class OptionHelper : public asg::AsgMessaging bool IsTLA() const { checkInit(); return m_isTLA; } // Compositions - bool IsUnknownComposition() const { checkInit(); return m_isUnknownComp; } - bool IsDijetComposition() const { checkInit(); return m_isDijetComp; } - bool IsGinosComposition() const { checkInit(); return m_isGinosComp; } - bool IsReginasComposition() const { checkInit(); return m_isReginasComp; } + bool IsSpecialComposition() const { checkInit(); return m_composition != ""; } + TString GetCompositionPath() const; + TString GetCompositionName() const; + int GetNjetFlavour() const { checkInit(); return m_nJetFlavour; } + int FixedTruthLabel() const { checkInit(); return m_truthLabel; } + LargeRJetTruthLabel::TypeEnum FixedLargeRJetTruthLabel() const {checkInit(); return m_largeRJetTruthLabel; } + + // Tagging SFs + TString TagScaleFactorName() const { checkInit(); return m_tagSFname; } + TString FixedLargeRJetTagResultName() const { checkInit(); return m_largeRjetTagResultName; } + int FixedLargeRJetTagAccept() const { checkInit(); return m_largeRjetTagAccept; } // Comparison helpers bool CompareOnly() const { checkInit(); return m_onlyCompare; } @@ -73,9 +91,13 @@ class OptionHelper : public asg::AsgMessaging // Variable control std::vector<CompScaleVar::TypeEnum> GetScaleVars() const { checkInit(); return m_scaleVars; } const std::vector<std::string> VariablesToShift() const { checkInit(); return m_systFilters; } + JetTopology::TypeEnum GetTopology() const { checkInit(); return m_topology; } // Layout control TString GetInputsDir() const { checkInit(); return m_inputsDir; } + + // Debug/similar control + TString GetDumpFile() const { checkInit(); return m_dumpFile; } private: bool m_isInit; @@ -84,6 +106,10 @@ class OptionHelper : public asg::AsgMessaging bool m_isEtaDepPU; bool m_ignorePT; TString m_compNamePrefix; + TString m_calibArea; + TString m_path; + bool m_isData; + bool m_ignoreNoMatch; bool m_doATLASLabel; TString m_ATLASLabel; @@ -97,22 +123,30 @@ class OptionHelper : public asg::AsgMessaging bool m_absVal; bool m_logPt; TString m_massType; + std::pair<double,double> m_fillShift; + bool m_twoColumnLegend; TString m_ptBins; TString m_etaBins; TString m_fixedPtVals; TString m_fixedEtaVals; TString m_fixedMoverPtVals; + TString m_fixedMassVals; bool m_isSmallR; bool m_isLargeR; bool m_isJER; bool m_isTLA; - bool m_isUnknownComp; - bool m_isDijetComp; - bool m_isGinosComp; - bool m_isReginasComp; + TString m_composition; + int m_nJetFlavour; + int m_truthLabel; + LargeRJetTruthLabel::TypeEnum m_largeRJetTruthLabel; + bool m_isDijet; // legacy support + + TString m_tagSFname; + TString m_largeRjetTagResultName; + int m_largeRjetTagAccept; bool m_onlyCompare; TString m_doCompare; @@ -120,11 +154,14 @@ class OptionHelper : public asg::AsgMessaging std::vector<CompScaleVar::TypeEnum> m_scaleVars; std::vector<std::string> m_systFilters; + JetTopology::TypeEnum m_topology; // allowing MakeUncertaintyPlots to be run from outside // of the testInputs/run/ directory TString m_inputsDir; + TString m_dumpFile; + TString getOptionValue(const std::vector<TString>& options, const TString optionName) const; template <typename T> T getOptionValueWithDefault(const std::vector<TString>& options, const TString optionName, const T defaultVal); @@ -143,6 +180,10 @@ OptionHelper::OptionHelper(const std::string& name) , m_isEtaDepPU(false) , m_ignorePT(false) , m_compNamePrefix("JET_") + , m_calibArea("") + , m_path("") + , m_isData(false) + , m_ignoreNoMatch(false) , m_doATLASLabel(true) , m_ATLASLabel("Internal") @@ -156,22 +197,30 @@ OptionHelper::OptionHelper(const std::string& name) , m_absVal(true) , m_logPt(true) , m_massType("") + , m_fillShift(0,0) + , m_twoColumnLegend(false) , m_ptBins("") , m_etaBins("") , m_fixedPtVals("") , m_fixedEtaVals("") , m_fixedMoverPtVals("") + , m_fixedMassVals("") , m_isSmallR(true) , m_isLargeR(false) , m_isJER(false) , m_isTLA(false) - , m_isUnknownComp(true) - , m_isDijetComp(false) - , m_isGinosComp(false) - , m_isReginasComp(false) + , m_composition("") + , m_nJetFlavour(-1) + , m_truthLabel(0) + , m_largeRJetTruthLabel(LargeRJetTruthLabel::UNKNOWN) + , m_isDijet(false) + + , m_tagSFname("") + , m_largeRjetTagResultName("") + , m_largeRjetTagAccept(0) , m_onlyCompare(false) , m_doCompare("") @@ -179,8 +228,11 @@ OptionHelper::OptionHelper(const std::string& name) , m_scaleVars() , m_systFilters() + , m_topology(JetTopology::UNKNOWN) - , m_inputsDir("./") + , m_inputsDir("/eos/atlas/atlascerngroupdisk/perf-jets/JetUncertainties/Inputs/") + + , m_dumpFile("") { } bool OptionHelper::Initialize(const std::vector<TString>& options) @@ -200,9 +252,14 @@ bool OptionHelper::Initialize(const std::vector<TString>& options) m_isEtaDepPU = getOptionValueWithDefault(options,"isEtaDepPileup",m_isEtaDepPU); m_ignorePT = getOptionValueWithDefault(options,"ignorePT",m_ignorePT); m_compNamePrefix = getOptionValueWithDefault(options,"prefix",m_compNamePrefix); + m_calibArea = getOptionValueWithDefault(options,"CalibArea",m_calibArea); + m_path = getOptionValueWithDefault(options,"Path",m_path); + m_isData = getOptionValueWithDefault(options,"IsData",m_isData); + m_ignoreNoMatch = getOptionValueWithDefault(options,"IgnoreNoMatch",m_ignoreNoMatch); m_doATLASLabel = getOptionValueWithDefault(options,"DoATLASLabel",m_doATLASLabel); m_ATLASLabel = getOptionValueWithDefault(options,"ATLASLabel",m_ATLASLabel); + if (m_ATLASLabel == "PUBLIC") m_ATLASLabel = ""; m_bunchSpacing = getOptionValueWithDefault(options,"bunchSpacing",m_bunchSpacing); m_doTotalUnc = getOptionValueWithDefault(options,"drawTotal",m_doTotalUnc); m_totalUncName = getOptionValueWithDefault(options,"totalUncName",m_totalUncName).Strip(TString::kBoth,'"'); @@ -225,25 +282,68 @@ bool OptionHelper::Initialize(const std::vector<TString>& options) m_absVal = getOptionValueWithDefault(options,"absVal",m_absVal); m_logPt = getOptionValueWithDefault(options,"logPt",m_logPt); m_massType = getOptionValueWithDefault(options,"massDef",m_massType); + TString fillShift = getOptionValue(options,"FillLabelShift"); + if (fillShift != "") + { + std::vector<double> shift = jet::utils::vectorize<double>(fillShift,"&"); + if (shift.size() != 2) + ATH_MSG_WARNING("FillLabelShift doesn't match expected format of \"val1&val2\". Skipping."); + else + { + const double lowShift = shift.at(0); + const double highShift = shift.at(1); + m_fillShift = std::make_pair(lowShift,highShift); + } + } + m_twoColumnLegend = getOptionValueWithDefault(options,"TwoColumnLegend",m_twoColumnLegend); m_ptBins = getOptionValueWithDefault(options,"ptBins",m_ptBins); m_etaBins = getOptionValueWithDefault(options,"etaBins",m_etaBins); m_fixedPtVals = getOptionValueWithDefault(options,"fixedPtVals",m_fixedPtVals); m_fixedEtaVals = getOptionValueWithDefault(options,"fixedEtaVals",m_fixedEtaVals); m_fixedMoverPtVals = getOptionValueWithDefault(options,"fixedMoverPtVals",m_fixedMoverPtVals); + m_fixedMassVals = getOptionValueWithDefault(options,"fixedMassVals",m_fixedMassVals); m_isLargeR = getOptionValueWithDefault(options,"isLargeR",m_isLargeR); m_isJER = getOptionValueWithDefault(options,"isJER",m_isJER); m_isTLA = getOptionValueWithDefault(options,"isTLA",m_isTLA); m_isSmallR = !(m_isLargeR || m_isJER); - m_isDijetComp = getOptionValueWithDefault(options,"isDijet",m_isDijetComp); - m_isGinosComp = getOptionValueWithDefault(options,"isGinos",m_isGinosComp); - m_isReginasComp = getOptionValueWithDefault(options,"isReginas",m_isReginasComp); - m_isUnknownComp = !m_isDijetComp; - if (m_isGinosComp) { - m_isDijetComp = false; - m_isUnknownComp = false; + m_composition = getOptionValueWithDefault(options,"Composition",m_composition); + m_nJetFlavour = getOptionValueWithDefault(options,"NjetFlavour",m_nJetFlavour); + m_truthLabel = getOptionValueWithDefault(options,"TruthLabel",m_truthLabel); + TString largeRJetTruthLabelStr = getOptionValue(options,"FatjetTruthLabel"); + if (largeRJetTruthLabelStr != "") + { + m_largeRJetTruthLabel = LargeRJetTruthLabel::stringToEnum(largeRJetTruthLabelStr); + if (m_largeRJetTruthLabel == LargeRJetTruthLabel::UNKNOWN) + { + ATH_MSG_WARNING("LargeRJetTruthLabel is UNKNOWN value, skipping usage: " << largeRJetTruthLabelStr.Data()); + } + } + m_isDijet = getOptionValueWithDefault(options,"isDijet",m_isDijet); + if (m_isDijet) + { + if (m_composition == "") + m_composition = "Dijet"; + else + { + ATH_MSG_ERROR("The composition was double-specified, please check that you don't specify both \"Composition\" and \"isDijet\""); + throw std::runtime_error("Double composition failure"); + } + } + + m_tagSFname = getOptionValueWithDefault(options,"TagSFName",m_tagSFname); + m_largeRjetTagResultName = getOptionValueWithDefault(options,"TagAcceptName",m_largeRjetTagResultName); + if (m_largeRjetTagResultName != "") + { + m_largeRjetTagAccept = getOptionValueWithDefault(options,"TagAcceptResult",0); + // TODO: enable when available + // if (TagResult::intToEnum(m_largeRjetTagAccept) == TagResult::UNKNOWN) + // { + // ATH_MSG_ERROR("The specified tag result doesn't match any expected value"); + // throw std::runtime_error("Bad tag result value"); + // } } m_onlyCompare = getOptionValueWithDefault(options,"compareOnly",m_onlyCompare); @@ -252,6 +352,8 @@ bool OptionHelper::Initialize(const std::vector<TString>& options) m_inputsDir = getOptionValueWithDefault(options,"inputsDir",m_inputsDir); + m_dumpFile = getOptionValueWithDefault(options,"dumpFile",m_dumpFile); + const TString localScaleVar = getOptionValue(options,"scaleVar"); if (localScaleVar == "") { @@ -264,6 +366,16 @@ bool OptionHelper::Initialize(const std::vector<TString>& options) for (size_t iVar = 0; iVar < localScaleVarVec.size(); ++iVar) m_scaleVars.push_back(CompScaleVar::stringToEnum(localScaleVarVec.at(iVar))); } + const TString jetTopology = getOptionValue(options,"topology"); + if (jetTopology != "") + { + m_topology = JetTopology::stringToEnum(jetTopology); + if (m_topology == JetTopology::UNKNOWN) + { + ATH_MSG_ERROR("The topology specified is invalid: " << jetTopology.Data()); + throw std::runtime_error("Topology failure"); + } + } const TString systFilterString = getOptionValue(options,"VariablesToShift"); if (systFilterString != "") @@ -316,7 +428,7 @@ void OptionHelper::checkInit() const if (!m_isInit) { ATH_MSG_FATAL("Asked for a value before initializing the tool"); - throw std::string("Initialization failure"); + throw std::runtime_error("Initialization failure"); } } @@ -335,7 +447,7 @@ std::vector<double> OptionHelper::getBins(const TString& toParse) const if (tokens.size() != 4) { ATH_MSG_FATAL("Unexpected format for bins: " << toParse.Data()); - throw std::string("Parse failure"); + throw std::runtime_error("Parse failure"); } // Check the type @@ -344,7 +456,7 @@ std::vector<double> OptionHelper::getBins(const TString& toParse) const if (!isUniform && !isLog) { ATH_MSG_FATAL("Unexpected binning type (token 0), only U/u and L/l are currently supported: " << toParse.Data()); - throw std::string("Parse failure"); + throw std::runtime_error("Parse failure"); } // Check the number of bins @@ -352,7 +464,7 @@ std::vector<double> OptionHelper::getBins(const TString& toParse) const if (!jet::utils::getTypeObjFromString(tokens.at(1),numBins)) { ATH_MSG_FATAL("Number of bins (token 1) was not an unsigned int: " << toParse.Data()); - throw std::string("Parse failure"); + throw std::runtime_error("Parse failure"); } // Check the min and max @@ -360,17 +472,17 @@ std::vector<double> OptionHelper::getBins(const TString& toParse) const if (!jet::utils::getTypeObjFromString(tokens.at(2),minVal)) { ATH_MSG_FATAL("Number of bins (token 2) was not a double: " << toParse.Data()); - throw std::string("Parse failure"); + throw std::runtime_error("Parse failure"); } if (!jet::utils::getTypeObjFromString(tokens.at(3),maxVal)) { ATH_MSG_FATAL("Number of bins (token 3) was not a double: " << toParse.Data()); - throw std::string("Parse failure"); + throw std::runtime_error("Parse failure"); } if (maxVal < minVal) { ATH_MSG_FATAL("The maximum value is smaller than the minimum: " << toParse.Data()); - throw std::string("Parse failure"); + throw std::runtime_error("Parse failure"); } // Done checking, finally return the bins @@ -420,7 +532,10 @@ std::vector<double> OptionHelper::GetFixedPtVals() const std::vector<double> bins; if (m_fixedPtVals != "") - bins = jet::utils::vectorize<double>(m_fixedPtVals,","); + { + if (m_fixedPtVals != "NONE") + bins = jet::utils::vectorize<double>(m_fixedPtVals,","); + } else bins = jet::utils::vectorize<double>("25,40,60,80,120",","); @@ -433,7 +548,10 @@ std::vector<double> OptionHelper::GetFixedEtaVals() const std::vector<double> bins; if (m_fixedEtaVals != "") - bins = jet::utils::vectorize<double>(m_fixedEtaVals,","); + { + if (m_fixedEtaVals != "NONE") + bins = jet::utils::vectorize<double>(m_fixedEtaVals,","); + } else if (IsLargeR()) bins = jet::utils::vectorize<double>("0",","); else if (IsJER()) @@ -450,7 +568,10 @@ std::vector<double> OptionHelper::GetFixedMoverPtVals() const std::vector<double> bins; if (m_fixedMoverPtVals != "") - bins = jet::utils::vectorize<double>(m_fixedMoverPtVals,","); + { + if (m_fixedMoverPtVals != "NONE") + bins = jet::utils::vectorize<double>(m_fixedMoverPtVals,","); + } else if (!IsLargeR()) bins = jet::utils::vectorize<double>("0",","); else if (IsPublicFormat()) @@ -461,6 +582,72 @@ std::vector<double> OptionHelper::GetFixedMoverPtVals() const return bins; } +std::vector<double> OptionHelper::GetFixedMassVals() const +{ + checkInit(); + std::vector<double> bins; + + if (m_fixedMassVals != "" && m_fixedMassVals != "NONE") + bins = jet::utils::vectorize<double>(m_fixedMassVals,","); + + return bins; +} + +TString OptionHelper::GetCompositionPath() const +{ + checkInit(); + + // Trivial case (unknown composition) + if (m_composition == "") + return ""; + // Path-based case (user specified file path, return it) + if (m_composition.Contains(".root")) + return m_composition; + // Name-based case (user specified name, return expected path) + else + { + if (!m_composition.CompareTo("Unknown",TString::kIgnoreCase)) + return ""; + if (!m_composition.CompareTo("Dijet",TString::kIgnoreCase)) + return GetInputsDir()+"/DijetFlavourComp_13TeV.root"; + if (!m_composition.CompareTo("Gino",TString::kIgnoreCase)) + return GetInputsDir()+"/GinoComposition.root"; + } + + ATH_MSG_FATAL("Unable to interpret special composition path: " << m_composition); + throw std::runtime_error("Composition path failure"); + return ""; +} + +TString OptionHelper::GetCompositionName() const +{ + checkInit(); + + // Trivial case (unknown composition) + if (m_composition == "") + return "unknown composition"; + // Path-based case (user specified the file path, return "custom" as name) + if (m_composition.Contains(".root")) + { + return "custom composition"; + } + // Name-based case (user specified name, interpret or return it) + if (!m_composition.Contains(".root")) + { + if (!m_composition.CompareTo("Unknown",TString::kIgnoreCase)) + return "unknown composition"; + if (!m_composition.CompareTo("Dijet",TString::kIgnoreCase)) + return "inclusive jets"; + if (!m_composition.CompareTo("Gino",TString::kIgnoreCase)) + return "Gino's composition"; + return m_composition + " composition"; + } + + ATH_MSG_FATAL("Unable to interpret special composition name: " << m_composition); + throw std::runtime_error("Composition name failure"); + return ""; +} + } // end jet namespace diff --git a/Reconstruction/Jet/JetUncertainties/util/testResolution.cxx b/Reconstruction/Jet/JetUncertainties/util/testResolution.cxx new file mode 100644 index 0000000000000000000000000000000000000000..6c580b0fe35365893ad8ea19049f2db4e99e1cf2 --- /dev/null +++ b/Reconstruction/Jet/JetUncertainties/util/testResolution.cxx @@ -0,0 +1,282 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#include "JetUncertainties/JetUncertaintiesTool.h" +#include "JetUncertainties/Helpers.h" + +#include "xAODJet/Jet.h" +#include "xAODJet/JetContainer.h" +#include "xAODJet/JetAuxContainer.h" +#include "xAODEventInfo/EventInfo.h" +#include "xAODEventInfo/EventInfoContainer.h" +#include "xAODEventInfo/EventInfoAuxContainer.h" + +#include "PATInterfaces/SystematicRegistry.h" +#include "PATInterfaces/SystematicVariation.h" +#include "PATInterfaces/SystematicsUtil.h" + +#ifdef ROOTCORE +# include "xAODRootAccess/TEvent.h" +# include "xAODRootAccess/TStore.h" +#endif // ROOTCORE + +#include "OptionHelper.h" + +#include "TH1D.h" +#include "TCanvas.h" +#include "TF1.h" +#include "TLatex.h" + + +void setJetKinematics(xAOD::Jet& jet, double pt, double eta, double phi, double mass) +{ + static jet::JetFourMomAccessor scaleCalo(jet::CompMassDef::getJetScaleString(jet::CompMassDef::CaloMass).Data()); + static jet::JetFourMomAccessor scaleTA(jet::CompMassDef::getJetScaleString(jet::CompMassDef::TAMass).Data()); + static jet::JetFourMomAccessor scaleCombQCD(jet::CompMassDef::getJetScaleString(jet::CompMassDef::CombMassQCD).Data()); + static jet::JetFourMomAccessor scaleCombWZ(jet::CompMassDef::getJetScaleString(jet::CompMassDef::CombMassWZ).Data()); + static jet::JetFourMomAccessor scaleCombHbb(jet::CompMassDef::getJetScaleString(jet::CompMassDef::CombMassHbb).Data()); + static jet::JetFourMomAccessor scaleCombTop(jet::CompMassDef::getJetScaleString(jet::CompMassDef::CombMassTop).Data()); + + jet.setJetP4( xAOD::JetFourMom_t(pt,eta,phi,mass)); + scaleCalo.setAttribute( jet, xAOD::JetFourMom_t(pt,eta,phi,mass)); + scaleTA.setAttribute( jet, xAOD::JetFourMom_t(pt,eta,phi,mass)); + scaleCombQCD.setAttribute(jet, xAOD::JetFourMom_t(pt,eta,phi,mass)); + scaleCombWZ.setAttribute( jet, xAOD::JetFourMom_t(pt,eta,phi,mass)); + scaleCombHbb.setAttribute(jet, xAOD::JetFourMom_t(pt,eta,phi,mass)); + scaleCombTop.setAttribute(jet, xAOD::JetFourMom_t(pt,eta,phi,mass)); +} + +int main (int argc, char* argv[]) +{ + StatusCode::enableFailure(); + jet::OptionHelper optHelper; + + + if (argc != 7 && argc != 8) + { + printf("Expected arguments:\n"); + printf("\t1. Output file (pdf)\n"); + printf("\t2. Jet definition\n"); + printf("\t3. MC type\n"); + printf("\t4. Config file\n"); + printf("\t5. Component name and variation\n"); + printf("\t\tExample: \"FourVecResUnc,+1\"\n"); + printf("\t6. IsData (\"true\" or \"false\")\n"); + printf("\t7. Options (optional argument), semi-colon delimited, examples:\n"); + printf("\t\tisDijet=false\n"); + printf("\t\tisLargeR=false\n"); + exit(1); + } + TString outFile = argv[1]; + TString jetDef = argv[2]; + TString mcType = argv[3]; + TString config = argv[4]; + TString component = argv[5]; + TString isDataStr = argv[6]; + if (argc == 8) optHelper.Initialize(jet::utils::vectorize<TString>(argv[7],";")); + else optHelper.Initialize(std::vector<TString>()); + + if (!outFile.EndsWith(".pdf")) + { + printf("Only pdf output files are currently supported\n"); + exit(1); + } + + if (jet::utils::vectorize<TString>(component,",").size() != 2) + { + printf("Bad component formatting, got \"%s\"\n",component.Data()); + exit(1); + } + TString compName = jet::utils::vectorize<TString>(component,",").at(0); + float shift = atof(jet::utils::vectorize<TString>(component,",").at(1)); + + bool isData = false; + if (!isDataStr.CompareTo("true",TString::kIgnoreCase)) + isData = true; + else if (!isDataStr.CompareTo("false",TString::kIgnoreCase)) + isData = false; + else + { + printf("Unable to determine whether to configure for data or MC: %s\n",isDataStr.Data()); + exit(1); + } + + JetUncertaintiesTool* tool = new JetUncertaintiesTool("JESprov"); + if (tool->setProperty("JetDefinition",jetDef.Data()).isFailure()) + exit(1); + if (tool->setProperty("MCType",mcType.Data()).isFailure()) + exit(1); + if (tool->setProperty("ConfigFile",config.Data()).isFailure()) + exit(1); + if (tool->setProperty("IsData",isData).isFailure()) + exit(1); + if (optHelper.GetPath() != "") + if (tool->setProperty("Path",optHelper.GetPath().Data()).isFailure()) + exit(1); + if (tool->setScaleToGeV().isFailure()) + exit(1); + if (tool->initialize().isFailure()) + exit(1); + + + // Build a jet container and a jet for us to manipulate later + xAOD::TEvent event; + xAOD::TStore store; + xAOD::JetContainer* jets = new xAOD::JetContainer(); + jets->setStore(new xAOD::JetAuxContainer()); + jets->push_back(new xAOD::Jet()); + xAOD::Jet* jet = jets->at(0); + + // Build an EventInfo object for us to manipulate later + xAOD::EventInfoContainer* eInfos = new xAOD::EventInfoContainer(); + eInfos->setStore(new xAOD::EventInfoAuxContainer()); + eInfos->push_back(new xAOD::EventInfo()); + xAOD::EventInfo* eInfo = eInfos->at(0); + + // Ensure that the specified component is a valid systematic + // This is a +1sigma variation + CP::SystematicVariation variation(Form("JET_%s",compName.Data()),shift); + if (!tool->isAffectedBySystematic(variation)) + { + printf("The specified variation was not recognized: JET_%s\n",compName.Data()); + exit(1); + } + CP::SystematicSet syst; + syst.insert(variation); + if (tool->applySystematicVariation(syst) != CP::SystematicCode::Ok) + { + printf("Failed to apply systematic variation\n"); + exit(1); + } + + // Get info on the variation + const size_t compIndex = tool->getComponentIndex("JET_"+compName); + const std::set<jet::CompScaleVar::TypeEnum> scaleVars = tool->getComponentScaleVars(compIndex); + const jet::CompScaleVar::TypeEnum scaleVar = scaleVars.size() == 1 ? *(scaleVars.begin()) : jet::CompScaleVar::UNKNOWN; + const jet::JetTopology::TypeEnum topology = tool->getComponentTopology(compIndex); + + printf("Component is index %zu, with ScaleVar %s and topology %s\n",compIndex,jet::CompScaleVar::enumToString(scaleVar).Data(),jet::JetTopology::enumToString(topology).Data()); + + // Prepare the canvas + TCanvas canvas("canvas"); + canvas.SetMargin(0.12,0.04,0.15,0.04); + canvas.SetFillStyle(4000); + canvas.SetFillColor(0); + canvas.SetFrameBorderMode(0); + canvas.cd(); + canvas.Print(outFile+"["); + + + // Prepare to add labels + TLatex tex; + tex.SetNDC(); + tex.SetTextFont(42); + tex.SetTextSize(0.04); + + + // Define the jet that we want to smear repeatedly + // Center the jet around pT of 1 TeV and mass of 100 GeV (easy numbers) + // eta_bins = [0.0,0.2,0.7,1.3,1.8,2.5,3.2,3.5,4.5] + const double pT = 1000; + const double mass = 100; + const double phi = 0; + const std::vector<double> etaVals = optHelper.GetFixedEtaVals(); + const int numSmear = 100000; + + for (const double eta : etaVals) + { + // Prepare a histogram to fill repeatedly as we smear the value + TH1D smearPt(Form("smearPt_eta%.2f",eta),"",100,500,1500); + TH1D smearMass(Form("smearMass_eta%.2f",eta),"",100,50,150); + smearPt.Sumw2(); + smearMass.Sumw2(); + smearPt.SetStats(0); + smearMass.SetStats(0); + smearPt.GetXaxis()->SetTitle("#it{p}_{T} [GeV]"); + smearMass.GetXaxis()->SetTitle("#it{m} [GeV]"); + smearPt.GetYaxis()->SetTitle("Number of events"); + smearMass.GetYaxis()->SetTitle("Number of events"); + + // Now smear repeatedly from the same starting jet + for (int iSmear = 0; iSmear < numSmear; ++iSmear) + { + setJetKinematics(*jet,pT,eta,phi,mass); + if (tool->applyCorrection(*jet,*eInfo) != CP::CorrectionCode::Ok) + { + printf("Error while smearing, iteration %d\n",iSmear); + exit(1); + } + // Fill the histograms with the smeared jet + smearPt.Fill(jet->pt()); + smearMass.Fill(jet->m()); + } + + // Get info on the expected values + setJetKinematics(*jet,pT,eta,phi,mass); + const double nomData = tool->getNominalResolutionData(*jet,scaleVar,topology); + const double nomMC = tool->getNominalResolutionMC(*jet,scaleVar,topology); + const double uncert = tool->getUncertainty(compIndex,*jet,*eInfo,scaleVar); + + const double fullUncMC = jet::CompScaleVar::isRelResolutionType(scaleVar) ? nomMC * uncert : uncert; + const double fullUncData = jet::CompScaleVar::isRelResolutionType(scaleVar) ? nomData * uncert : uncert; + const double smearMC = sqrt(pow(nomMC + fabs(shift*fullUncMC),2) - pow(nomMC,2)); + const double smearData = nomData != JESUNC_ERROR_CODE ? sqrt(pow(nomData + fabs(shift*fullUncData),2) - pow(nomData,2)) : 0; + + // Fit a Gaussian + TF1 fitPt("fitPt","gaus"); + smearPt.Fit(&fitPt,"E"); + TF1 fitMass("fitMass","gaus"); + smearMass.Fit(&fitMass,"E"); + + // Draw and print the plot + smearPt.Draw(); + tex.DrawLatex(0.70,0.9,"Gaussian fit results"); + tex.DrawLatex(0.70,0.85,Form("#mu = %.0f GeV",fitPt.GetParameter(1))); + tex.DrawLatex(0.70,0.80,Form("#sigma = %.1f GeV",fitPt.GetParameter(2))); + tex.DrawLatex(0.70,0.75,Form("#mu/#sigma = %.1f%%",fitPt.GetParameter(2)/fitPt.GetParameter(1)*100)); + tex.DrawLatex(0.15,0.9,"Expectation from tool"); + tex.DrawLatex(0.15,0.85,"#sigma_{smear}^{2} = (#sigma_{nom} + |N#delta#sigma|)^{2} - (#sigma_{nom})^{2}"); + if (nomData != JESUNC_ERROR_CODE) + tex.DrawLatex(0.15,0.80,Form("#sigma_{nom}^{data}/#it{p}_{T} = %.1f%%",100*nomData)); + else + tex.DrawLatex(0.15,0.80,Form("#sigma_{nom}^{data}/#it{p}_{T} = N/A")); + tex.DrawLatex(0.15,0.75,Form("#sigma_{nom}^{MC}/#it{p}_{T} = %.1f%%",100*nomMC)); + tex.DrawLatex(0.15,0.70,Form("#delta#sigma/#it{p}_{T} = %.1f%%",100*uncert)); + tex.DrawLatex(0.15,0.65,Form("N_{sigma} = %+.1f",shift)); + if (nomData != JESUNC_ERROR_CODE) + tex.DrawLatex(0.15,0.55,Form("#sigma_{smear}^{data}/#it{p}_{T} = %.1f%%",100*smearData)); + else + tex.DrawLatex(0.15,0.55,Form("#sigma_{smear}^{data}/#it{p}_{T} = N/A")); + tex.DrawLatex(0.15,0.50,Form("#sigma_{smear}^{MC}/#it{p}_{T} = %.1f%%",100*smearMC)); + canvas.Print(outFile); + + + + smearMass.Draw(); + tex.DrawLatex(0.70,0.9,"Gaussian fit results"); + tex.DrawLatex(0.70,0.85,Form("#mu = %.0f GeV",fitMass.GetParameter(1))); + tex.DrawLatex(0.70,0.80,Form("#sigma = %.1f GeV",fitMass.GetParameter(2))); + tex.DrawLatex(0.70,0.75,Form("#mu/#sigma = %.1f%%",fitMass.GetParameter(2)/fitMass.GetParameter(1)*100)); + tex.DrawLatex(0.15,0.9,"Expectation from tool"); + tex.DrawLatex(0.15,0.85,"#sigma_{smear}^{2} = (#sigma_{nom} + |N#delta#sigma|)^{2} - (#sigma_{nom})^{2}"); + if (nomData != JESUNC_ERROR_CODE) + tex.DrawLatex(0.15,0.80,Form("#sigma_{nom}^{data}/#it{p}_{T} = %.1f%%",100*nomData)); + else + tex.DrawLatex(0.15,0.80,Form("#sigma_{nom}^{data}/#it{p}_{T} = N/A")); + tex.DrawLatex(0.15,0.75,Form("#sigma_{nom}^{MC}/#it{p}_{T} = %.1f%%",100*nomMC)); + tex.DrawLatex(0.15,0.70,Form("#delta#sigma/#it{p}_{T} = %.1f%%",100*uncert)); + tex.DrawLatex(0.15,0.65,Form("N_{sigma} = %+.1f",shift)); + if (nomData != JESUNC_ERROR_CODE) + tex.DrawLatex(0.15,0.55,Form("#sigma_{smear}^{data}/#it{p}_{T} = %.1f%%",100*smearData)); + else + tex.DrawLatex(0.15,0.55,Form("#sigma_{smear}^{data}/#it{p}_{T} = N/A")); + tex.DrawLatex(0.15,0.50,Form("#sigma_{smear}^{MC}/#it{p}_{T} = %.1f%%",100*smearMC)); + canvas.Print(outFile); + } + + // Done printing + canvas.Print(outFile+"]"); + + return 0; +}