00001 #ifndef JETUNCERTAINTIES_JETUNCERTAINTIESTOOL_H
00002 #define JETUNCERTAINTIES_JETUNCERTAINTIESTOOL_H
00003
00004 #include "JetCPInterfaces/ICPJetUncertaintiesTool.h"
00005 #include "JetUncertainties/UncertaintyEnum.h"
00006 #include "AsgTools/AsgTool.h"
00007
00008 #include <string>
00009 #include <vector>
00010 #include <unordered_map>
00011
00012 namespace jet
00013 {
00014 class UncertaintyHistogram;
00015 class ValidityHistogram;
00016 class UncertaintyComponent;
00017 class UncertaintyGroup;
00018 class UncertaintySet;
00019 class ConfigHelper;
00020 class GroupHelper;
00021 class ComponentHelper;
00022 }
00023
00024 class TFile;
00025 class TH2D;
00026 class TRandom3;
00027
00028 namespace xAOD
00029 {
00030 class ShallowAuxContainer;
00031 }
00032
00033 class JetUncertaintiesTool : virtual public ICPJetUncertaintiesTool,
00034 virtual public asg::AsgTool
00035 {
00036 ASG_TOOL_CLASS(JetUncertaintiesTool,ICPJetUncertaintiesTool)
00037
00038 public:
00039
00040 JetUncertaintiesTool(const std::string& name = "JetUncertaintiesTool");
00041 JetUncertaintiesTool(const JetUncertaintiesTool& toCopy);
00042 virtual ~JetUncertaintiesTool();
00043
00044
00045
00046 virtual StatusCode setScaleToMeV();
00047 virtual StatusCode setScaleToGeV();
00048
00049
00050 virtual StatusCode initialize();
00051
00052
00053 virtual void setRandomSeed(long long int seed) { m_userSeed = seed; }
00054
00055
00056
00057 virtual std::string getName() const { return m_name; }
00058 virtual std::string getRelease() const { return m_release; }
00059 virtual std::string getJetDef() const { return m_jetDef; }
00060 virtual std::string getMCType() const { return m_mcType; }
00061 virtual std::string getConfigFile() const { return m_configFile; }
00062 virtual std::string getPath() const { return m_path; }
00063 virtual std::string getAnalysisFile() const { return m_analysisFile; }
00064 virtual float getSqrtS() const;
00065
00066
00067 virtual float getRefMu() const;
00068 virtual float getRefNPV() const;
00069 virtual float getRefMu(const xAOD::Jet& jet) const;
00070 virtual float getRefNPV(const xAOD::Jet& jet) const;
00071
00072
00073
00074 virtual size_t getNumComponents() const;
00075 virtual size_t getComponentIndex(const std::string& name) const;
00076 virtual size_t getComponentIndex(const TString& name) const;
00077 virtual std::string getComponentName(const size_t index) const;
00078 virtual std::string getComponentDesc(const size_t index) const;
00079 virtual std::string getComponentCategory(const size_t index) const;
00080 virtual bool getComponentIsReducible(const size_t index) const;
00081
00082 virtual bool getComponentScalesFourVec(const size_t index) const;
00083 virtual bool getComponentScalesPt(const size_t index) const;
00084 virtual bool getComponentScalesMass(const size_t index) const;
00085 virtual bool getComponentScalesD12(const size_t index) const;
00086 virtual bool getComponentScalesD23(const size_t index) const;
00087 virtual bool getComponentScalesTau21(const size_t index) const;
00088 virtual bool getComponentScalesTau32(const size_t index) const;
00089 virtual bool getComponentScalesTau21WTA(const size_t index) const;
00090 virtual bool getComponentScalesTau32WTA(const size_t index) const;
00091 virtual bool getComponentScalesD2Beta1(const size_t index) const;
00092 virtual bool getComponentScalesQw(const size_t index) const;
00093 virtual bool getComponentScalesMultiple(const size_t index) const;
00094
00095 virtual std::vector<std::string> getComponentCategories() const;
00096 virtual std::vector<size_t> getComponentsInCategory(const std::string& category) const;
00097 virtual std::vector<std::string> getComponentNamesInCategory(const std::string& category) const;
00098
00099
00100
00101 virtual bool getValidity(size_t index, const xAOD::Jet& jet) const;
00102 virtual bool getValidity(size_t index, const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const;
00103 virtual bool getValidity(size_t index, const xAOD::Jet& jet, const jet::CompScaleVar::TypeEnum scaleVar) const;
00104 virtual bool getValidity(size_t index, const xAOD::Jet& jet, const xAOD::EventInfo& eInfo, const jet::CompScaleVar::TypeEnum scaleVar) const;
00105
00106 virtual double getUncertainty(size_t index, const xAOD::Jet& jet) const;
00107 virtual double getUncertainty(size_t index, const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const;
00108 virtual double getUncertainty(size_t index, const xAOD::Jet& jet, const jet::CompScaleVar::TypeEnum scaleVar) const;
00109 virtual double getUncertainty(size_t index, const xAOD::Jet& jet, const xAOD::EventInfo& eInfo, const jet::CompScaleVar::TypeEnum scaleVar) const;
00110
00111 virtual bool getValidUncertainty(size_t index, double& unc, const xAOD::Jet& jet) const;
00112 virtual bool getValidUncertainty(size_t index, double& unc, const xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const;
00113 virtual bool getValidUncertainty(size_t index, double& unc, const xAOD::Jet& jet, const jet::CompScaleVar::TypeEnum scaleVar) const;
00114 virtual bool getValidUncertainty(size_t index, double& unc, const xAOD::Jet& jet, const xAOD::EventInfo& eInfo, const jet::CompScaleVar::TypeEnum scaleVar) const;
00115
00116 virtual double getNormalizedCaloMassWeight(const xAOD::Jet& jet) const;
00117 virtual double getNormalizedTAMassWeight( const xAOD::Jet& jet) const;
00118
00119
00120
00121 virtual CP::CorrectionCode applyCorrection(xAOD::Jet& jet) const;
00122 virtual CP::CorrectionCode applyCorrection(xAOD::Jet& jet, const xAOD::EventInfo& eInfo) const;
00123 virtual CP::CorrectionCode correctedCopy(const xAOD::Jet& input, xAOD::Jet*& output) const;
00124 virtual CP::CorrectionCode correctedCopy(const xAOD::Jet& input, xAOD::Jet*& output, const xAOD::EventInfo& eInfo) const;
00125 virtual CP::CorrectionCode applyContainerCorrection(xAOD::JetContainer& inputs) const;
00126 virtual CP::CorrectionCode applyContainerCorrection(xAOD::JetContainer& inputs, const xAOD::EventInfo& eInfo) const;
00127
00128
00129
00130
00131 virtual bool isAffectedBySystematic(const CP::SystematicVariation& systematic) const;
00132 virtual CP::SystematicSet affectingSystematics() const;
00133 virtual CP::SystematicSet recommendedSystematics() const;
00134 virtual CP::SystematicSet appliedSystematics() const;
00135 virtual CP::SystematicCode applySystematicVariation(const CP::SystematicSet& systConfig);
00136
00137
00138
00139
00140 virtual TH2D* getPtCorrelationMatrix( const int numBins,
00141 const double minPt,
00142 const double maxPt,
00143 const double valEta );
00144 virtual TH2D* getPtCorrelationMatrix( const int numBins,
00145 const double minPt,
00146 const double maxPt,
00147 const double valEta1,
00148 const double valEta2);
00149 virtual TH2D* getEtaCorrelationMatrix( const int numBins,
00150 const double minEta,
00151 const double maxEta,
00152 const double valPt );
00153 virtual TH2D* getEtaCorrelationMatrix( const int numBins,
00154 const double minEta,
00155 const double maxEta,
00156 const double valPt1,
00157 const double valPt2 );
00158
00159 private:
00160
00161 bool m_isInit;
00162 const std::string m_name;
00163 float m_energyScale;
00164
00165
00166 std::string m_release;
00167 std::string m_jetDef;
00168 std::string m_mcType;
00169 std::string m_configFile;
00170 std::string m_path;
00171 std::string m_analysisFile;
00172 std::vector<std::string> m_systFilters;
00173
00174
00175 float m_refNPV;
00176 float m_refMu;
00177 jet::UncertaintyHistogram* m_refNPVHist;
00178 jet::UncertaintyHistogram* m_refMuHist;
00179 std::vector<jet::UncertaintyGroup*> m_groups;
00180
00181
00182 CP::SystematicSet m_recognizedSystematics;
00183 CP::SystematicSet m_recommendedSystematics;
00184 CP::SystematicSet m_currentSystSet;
00185 jet::UncertaintySet* m_currentUncSet;
00186 std::unordered_map<CP::SystematicSet,CP::SystematicSet> m_systFilterMap;
00187 std::unordered_map<CP::SystematicSet,jet::UncertaintySet*> m_systSetMap;
00188
00189
00190 jet::ValidityHistogram* m_fileValidHist;
00191
00192
00193 jet::UncertaintyHistogram* m_caloMassWeight;
00194 jet::UncertaintyHistogram* m_TAMassWeight;
00195 jet::CompMassDef::TypeEnum m_combMassWeightCaloMassDef;
00196 jet::CompMassDef::TypeEnum m_combMassWeightTAMassDef;
00197
00198
00199 long long int m_userSeed;
00200 TRandom3* m_rand;
00201
00202
00203 const std::string m_namePrefix;
00204
00205
00206
00207
00208
00209 StatusCode addUncertaintyGroup (const jet::ConfigHelper& helper);
00210 StatusCode addUncertaintyComponent(const jet::ConfigHelper& helper);
00211 jet::UncertaintyComponent* buildUncertaintyComponent(const jet::ComponentHelper& component) const;
00212 const xAOD::EventInfo* getDefaultEventInfo() const;
00213 StatusCode checkIndexInput(const size_t index) const;
00214 float getMassSmearingFactor(xAOD::Jet& jet, const double shift) const;
00215
00216
00217 StatusCode updateSplittingScale12(xAOD::Jet& jet, const double shift) const;
00218 StatusCode updateSplittingScale23(xAOD::Jet& jet, const double shift) const;
00219 StatusCode updateTau21(xAOD::Jet& jet, const double shift) const;
00220 StatusCode updateTau32(xAOD::Jet& jet, const double shift) const;
00221 StatusCode updateTau21WTA(xAOD::Jet& jet, const double shift) const;
00222 StatusCode updateTau32WTA(xAOD::Jet& jet, const double shift) const;
00223 StatusCode updateD2Beta1(xAOD::Jet& jet, const double shift) const;
00224 StatusCode updateQw(xAOD::Jet& jet, const double shift) const;
00225
00226
00227
00228 bool checkIfRecommendedSystematic(const jet::UncertaintyGroup& systematic) const;
00229 virtual CP::SystematicCode addAffectingSystematic(const CP::SystematicVariation& systematic, bool recommended);
00230 virtual CP::SystematicCode getFilteredSystematicSet(const CP::SystematicSet& systConfig, CP::SystematicSet& filteredSet);
00231 virtual CP::SystematicCode getUncertaintySet(const CP::SystematicSet& filteredSet, jet::UncertaintySet*& uncSet);
00232 };
00233
00234
00235 #endif