ATLAS Offline Software
Functions
BTaggingEfficiencyToolTester.cxx File Reference
#include <AsgTools/StandaloneToolHandle.h>
#include "FTagAnalysisInterfaces/IBTaggingEfficiencyTool.h"
#include <string>
#include <iomanip>
Include dependency graph for BTaggingEfficiencyToolTester.cxx:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 15 of file BTaggingEfficiencyToolTester.cxx.

15  {
16 
17  const char* TEST_NAME = argv[0];
18  if (argc < 3) {
19  ANA_MSG_ERROR ( "No right inputs received!" );
20  ANA_MSG_ERROR ( "Usage: " << TEST_NAME << "[CDI path] [b-tagger name] [WP name]" );
21  return 1;
22  }
23 
24  std::string CDIPath = argv[1];
25  std::string taggerName = argv[2];
26  std::string workingPointName = argv[3];
27  std::string JetCollectionName = "AntiKt4EMPFlowJets";
28  // select your efficiency map based on the DSID of your sample:
29  unsigned int sample_dsid = 410470;
30 
31  asg::StandaloneToolHandle<IBTaggingEfficiencyTool> tool("BTaggingEfficiencyTool/BTagEffTest");
32  StatusCode code1 = tool.setProperty("ScaleFactorFileName", CDIPath);
33  StatusCode code2 = tool.setProperty("TaggerName", taggerName);
34  StatusCode code3 = tool.setProperty("OperatingPoint", workingPointName);
35  StatusCode code4 = tool.setProperty("JetAuthor", JetCollectionName);
36  StatusCode code5 = tool.setProperty("MinPt", 20000);
37  StatusCode code6 = tool.setProperty("OutputLevel", MSG::WARNING);
38  StatusCode code7 = tool.initialize();
39  std::vector<StatusCode> codes = {code1, code2, code3, code4, code5, code6, code7};
40  for (const auto& code : codes) {
41  if (code != StatusCode::SUCCESS) {
42  ANA_MSG_ERROR ( "Initialization of tool " << tool->name() << " failed! ");
43  return 1;
44  }
45  }
46  ANA_MSG_INFO("Initialization of tool " << tool->name() << " finished.");
47 
48  tool->setMapIndex(sample_dsid);
49 
50  ANA_MSG_INFO( "-----------------------------------------------------");
51  const std::map<CP::SystematicVariation, std::vector<std::string> > allowed_variations = tool->listSystematics();
52  ANA_MSG_INFO("Allowed systematics variations for tool " << tool->name() << ":");
53  for (auto var : allowed_variations) {
54  ANA_MSG_INFO( std::setw(40) << std::left << var.first.name() << ":");
55  for (auto flv : var.second)
56  ANA_MSG_INFO( " " << flv);
57  }
58  ANA_MSG_DEBUG( "-----------------------------------------------------");
59 
60 
61  ANA_MSG_DEBUG( "Creating a jet");
62  xAOD::JetFourMom_t p4(50000.,0.7,0.3,1000.);
63 
64  xAOD::Jet * jet = new xAOD::Jet();
65  jet->makePrivateStore();
66  ANA_MSG_DEBUG( "Setting jet 4 momentum");
67  jet->setJetP4(p4);
68  ANA_MSG_DEBUG("Setting jet attribute");
69  jet->setAttribute("HadronConeExclTruthLabelID", 5);
70  float sf=0;
71  float eff=0;
73  ANA_MSG_DEBUG( "Testing function calls without systematics...");
74 
75  result = tool->getEfficiency(*jet,eff);
76  if( result!=CorrectionCode::Ok) {
77  ANA_MSG_ERROR("b jet get efficiency failed!");
78  return 1;
79  }
80  else {
81  ANA_MSG_DEBUG( "b jet get efficiency succeeded: " << eff );
82  }
83  result = tool->getScaleFactor(*jet,sf);
84 
85  if( result!=CorrectionCode::Ok) {
86  ANA_MSG_ERROR("b jet get scale factor failed");
87  return 1;
88  }
89  else {
90  ANA_MSG_INFO( "b jet get scale factor succeeded: " << sf );
91  }
92 
93  ANA_MSG_DEBUG( "Testing function calls with systematics...");
94  CP::SystematicSet systs = tool->affectingSystematics();
95  for( CP::SystematicSet::const_iterator iter = systs.begin();
96  iter!=systs.end(); ++iter) {
99  set.insert(var);
100  StatusCode sresult = tool->applySystematicVariation(set);
101  if( sresult !=StatusCode::SUCCESS) {
102  ANA_MSG_ERROR( var.name() << " apply systematic variation FAILED ");
103  }
104  result = tool->getScaleFactor(*jet,sf);
105  if( result!=CorrectionCode::Ok) {
106  ANA_MSG_ERROR( var.name() << " getScaleFactor FAILED");
107  } else {
108  ANA_MSG_DEBUG( var.name() << " " << sf);
109  }
110  }
111 
112  // don't forget to switch back off the systematics...
113  CP::SystematicSet defaultSet;
114  StatusCode dummyResult = tool->applySystematicVariation(defaultSet);
115  if (dummyResult != StatusCode::SUCCESS)
116  ANA_MSG_ERROR( "problem disabling systematics setting!");
117 
118  return 0;
119 }
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
Analysis::dummyResult
const CalibResult dummyResult(dummyValue, dummyValue)
get_generator_info.result
result
Definition: get_generator_info.py:21
CP::SystematicSet::const_iterator
std::set< SystematicVariation >::const_iterator const_iterator
Definition: SystematicSet.h:52
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
CP::SystematicVariation
Definition: SystematicVariation.h:47
python.ExitCodes.codes
dictionary codes
helper to get a human-readable string
Definition: ExitCodes.py:49
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
asg::StandaloneToolHandle
an "initializing" ToolHandle for stand-alone applications
Definition: StandaloneToolHandle.h:44
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
CP::SystematicSet::end
const_iterator end() const
description: const iterator to the end of the set
Definition: SystematicSet.h:59
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:224
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition: JetTypes.h:17
pmontree.code
code
Definition: pmontree.py:443
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
CP::SystematicSet::begin
const_iterator begin() const
description: const iterator to the beginning of the set
Definition: SystematicSet.h:55
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
dqt_zlumi_alleff_HIST.eff
int eff
Definition: dqt_zlumi_alleff_HIST.py:113
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288