00001
00003
00005
00006 #ifndef CPBTAGGINGEFFICIENCYTOOL_H
00007 #define CPBTAGGINGEFFICIENCYTOOL_H
00008
00009 #include "xAODBTaggingEfficiency/IBTaggingEfficiencyTool.h"
00010
00011 #include "xAODBTagging/BTagging.h"
00012
00013 #include "AsgTools/AsgTool.h"
00014 #include <string>
00015 #include <set>
00016 #include <vector>
00017 #include <map>
00018
00019
00020 #include "CalibrationDataInterface/CalibrationDataVariables.h"
00021 #include "CalibrationDataInterface/CalibrationDataInterfaceROOT.h"
00022 #include "PATInterfaces/ISystematicsTool.h"
00023
00024 class BTaggingEfficiencyTool: public asg::AsgTool,
00025 public virtual IBTaggingEfficiencyTool,
00026 public virtual CP::ISystematicsTool {
00027
00028
00030 ASG_TOOL_CLASS2( BTaggingEfficiencyTool , IBTaggingEfficiencyTool, ISystematicsTool )
00031
00032 public:
00033
00034
00036 BTaggingEfficiencyTool( const std::string& name );
00037
00039 virtual ~BTaggingEfficiencyTool();
00040
00041
00042
00043
00044
00045
00046
00049
00053 CP::CorrectionCode getScaleFactor( const xAOD::Jet & jet,
00054 float & sf) const;
00055
00059 CP::CorrectionCode getEfficiency( const xAOD::Jet & jet,
00060 float & eff) const;
00061
00065 CP::CorrectionCode getInefficiency( const xAOD::Jet & jet,
00066 float & eff) const;
00067
00071 CP::CorrectionCode getInefficiencyScaleFactor( const xAOD::Jet & jet,
00072 float & sf) const;
00073
00077 CP::CorrectionCode getMCEfficiency( const xAOD::Jet & jet,
00078 float & eff) const;
00079
00082
00086 CP::CorrectionCode getScaleFactor( int flavour, const Analysis::CalibrationDataVariables& v,
00087 float & sf) const;
00088
00092 CP::CorrectionCode getEfficiency( int flavour, const Analysis::CalibrationDataVariables& v,
00093 float & eff) const;
00094
00098 CP::CorrectionCode getInefficiency( int flavour, const Analysis::CalibrationDataVariables& v,
00099 float & eff) const;
00100
00104 CP::CorrectionCode getInefficiencyScaleFactor( int flavour, const Analysis::CalibrationDataVariables& v,
00105 float & sf) const;
00106
00110 CP::CorrectionCode getMCEfficiency( int flavour, const Analysis::CalibrationDataVariables& v,
00111 float & eff) const;
00112
00114
00117
00125 StatusCode initialize();
00126
00132 CP::SystematicCode applySystematicVariation(const CP::SystematicSet & set);
00133
00138 CP::SystematicSet affectingSystematics() const;
00139
00144 CP::SystematicSet recommendedSystematics() const;
00145
00147 bool isAffectedBySystematic(const CP::SystematicVariation & systematic ) const;
00148
00157 bool setMapIndex(const std::string& flavour, unsigned int index);
00158
00160
00164 const std::map<CP::SystematicVariation, std::vector<std::string> > listSystematics() const;
00165
00167 std::string getTaggerName() const { return m_taggerName;}
00168
00170 std::string getOperatingPoint() const { return m_OP;}
00171
00173 std::string getJetAuthor() const { return m_jetAuthor;}
00174
00175
00176
00177
00179 bool applySystematics() const { return m_applySyst;}
00181
00182 private:
00183
00184 struct SystInfo {
00185 SystInfo() : uncType(Analysis::SFEigen), isUp(true) {;}
00186 std::map<unsigned int, unsigned int> indexMap;
00187 Analysis::Uncertainty uncType;
00188
00189 bool isUp;
00190 bool getIndex( unsigned int flavourID, unsigned int & index) const;
00191 };
00192
00194 bool addSystematics(const std::vector<std::string> & systematicNames,unsigned int flavourID, Analysis::Uncertainty uncType);
00195
00197 std::vector<std::string> makeEigenSyst(const std::string & flav, int number);
00198
00200 bool getIndices(unsigned int flavour, unsigned int & sf, unsigned int & ef) const;
00201
00203 std::string getLabel(int flavourID) const {
00204 switch(flavourID) {
00205 case 5:
00206 return "B";
00207 break;
00208 case 4:
00209 return "C";
00210 break;
00211 case 15:
00212 return "T";
00213 break;
00214 case 0:
00215 return "Light";
00216 break;
00217 default:
00218 return "Light";
00219 }
00220 }
00221
00223 unsigned int getFlavourID(const std::string& label) const {
00224
00225 if( label.size() <1)
00226 return 0;
00227
00228 switch (label[0]) {
00229 case 'B':
00230 return 5; break;
00231 case 'C':
00232 return 4; break;
00233 case 'T':
00234 return 15; break;
00235 default:
00236 return 0;
00237 }
00238 }
00239
00245 bool fillVariables(const xAOD::Jet& jet, Analysis::CalibrationDataVariables& x) const;
00246
00249 bool fillVariables(const double jetPt, const double jetEta, const double jetTagWeight, Analysis::CalibrationDataVariables& x) const;
00250
00252 Analysis::CalibrationDataInterfaceROOT* m_CDI = nullptr;
00253
00256
00258 std::string m_SFFile;
00260 std::string m_EffFile;
00262 std::string m_SFBName;
00264 std::string m_SFCName;
00266 std::string m_SFTName;
00268 std::string m_SFLightName;
00270 std::string m_EVReductionB;
00272 std::string m_EVReductionC;
00274 std::string m_EVReductionLight;
00276 std::string m_EffBName;
00278 std::string m_EffCName;
00280 std::string m_EffTName;
00282 std::string m_EffLightName;
00284 std::string m_excludeFromEV;
00286 std::string m_taggerName;
00288 std::string m_OP;
00290 std::string m_jetAuthor;
00292 std::string m_systStrategy;
00294 bool m_useDevFile;
00296 bool m_coneFlavourLabel;
00298 bool m_oldConeFlavourLabel;
00299
00301
00304
00306 bool m_initialised;
00307
00308
00309 bool m_applySyst;
00310 SystInfo m_applyThisSyst;
00311
00312 std::map<CP::SystematicVariation,SystInfo> m_systematicsInfo;
00313
00314 CP::SystematicSet m_systematics;
00315
00316 bool m_isContinuous;
00317
00318
00319
00320
00321 std::map<std::string, unsigned int> m_mapIndices;
00322
00324 std::map<unsigned int, unsigned int> m_SFIndices;
00326 std::map<unsigned int, unsigned int> m_EffIndices;
00327
00329
00330 };
00331
00332 #endif // CPBTAGGINGEFFICIENCYTOOL_H
00333