CMS 3D CMS Logo

TestPerformanceFWLite_ES.cc
Go to the documentation of this file.
1 #include <vector>
2 #include <iostream>
3 
4 #include "TFile.h"
5 #include "TTree.h"
7 
14 
15 int main(int argc, char** argv) {
17 
18  std::cout << "Test!!!" << std::endl << std::endl;
19  TFile f("performance_ssvm.root", "READ");
20 
21  fwlite::EventSetup es(&f);
22 
23  if (es.exists("BTagPerformanceRecord")) {
24  std::cout << "Got the right tree" << std::endl;
25  } else {
26  std::cout << "Can't find tree" << std::endl;
27  }
28 
29  fwlite::RecordID testRecID = es.recordID("BTagPerformanceRecord");
30 
31  int index = 1001;
33 
34  std::cout << "Got record ID " << testRecID << es.get(testRecID).startSyncValue().eventID() << std::endl;
35 
37  es.get(testRecID).get(plHandle, "MCPfTCHEMb");
39  es.get(testRecID).get(wpHandle, "MCPfTCHEMb");
40 
41  if (plHandle.isValid() && wpHandle.isValid()) {
42  BtagPerformance perf(*plHandle, *wpHandle);
43 
44  std::cout << "Values: " << PerformanceResult::BTAGNBEFF << " " << PerformanceResult::MUERR << " " << std::endl;
45 
46  // check beff, berr for eta=.6, et=55;
48 
49  // std::cout <<" My Performance Object is indeed a "<<typeid(perf).name()<<std::endl;
50 
51  std::cout << " test eta=0.6, et=55" << std::endl;
52 
53  p.insert(BinningVariables::JetAbsEta, 0.6);
54  p.insert(BinningVariables::JetEt, 55);
55  std::cout << " nbeff/nberr ?" << perf.isResultOk(PerformanceResult::BTAGNBEFF, p) << "/"
56  << perf.isResultOk(PerformanceResult::BTAGNBERR, p) << std::endl;
57  std::cout << " beff/berr ?" << perf.isResultOk(PerformanceResult::BTAGBEFF, p) << "/"
58  << perf.isResultOk(PerformanceResult::BTAGBERR, p) << std::endl;
59  std::cout << " beff/berr =" << perf.getResult(PerformanceResult::BTAGBEFF, p) << "/"
60  << perf.getResult(PerformanceResult::BTAGBERR, p) << std::endl;
61 
62  std::cout << " test eta=1.9, et=33" << std::endl;
63  p.insert(BinningVariables::JetAbsEta, 1.9);
64  p.insert(BinningVariables::JetEt, 33);
65  std::cout << " beff/berr ?" << perf.isResultOk(PerformanceResult::BTAGBEFF, p) << "/"
66  << perf.isResultOk(PerformanceResult::BTAGBERR, p) << std::endl;
67  std::cout << " beff/berr =" << perf.getResult(PerformanceResult::BTAGBEFF, p) << "/"
68  << perf.getResult(PerformanceResult::BTAGBERR, p) << std::endl;
69 
70  std::cout << " The WP is defined by a cut at " << perf.workingPoint().cut() << std::endl;
71  std::cout << " Discriminant is " << perf.workingPoint().discriminantName() << std::endl;
72 
73  std::cout << " now I ask for a calibration but I do not set eta in the binning point ---> should return all not "
74  "available "
75  << std::endl;
76  p.reset();
78  p.insert(BinningVariables::JetEt, 55);
79  std::cout << " beff/berr ?" << perf.isResultOk(PerformanceResult::BTAGBEFF, p) << "/"
80  << perf.isResultOk(PerformanceResult::BTAGBERR, p) << std::endl;
81  std::cout << " beff/berr =" << perf.getResult(PerformanceResult::BTAGBEFF, p) << "/"
82  << perf.getResult(PerformanceResult::BTAGBERR, p) << std::endl;
83 
84  // std::cout <<" now I ask for a calibration which is not present ---> should throw an exception "<<std::endl;
85 
86  // edm::ESHandle<BtagPerformance> perfH2;
87  // iSetup.get<BTagPerformanceRecord>().get("TrackCountingHighEff_tight",perfH2);
88 
89  } else {
90  std::cout << "invalid handle: workingPoint " << wpHandle.isValid() << " payload " << plHandle.isValid()
91  << std::endl;
92  try {
93  *wpHandle;
94  *plHandle;
95  } catch (std::exception& iE) {
96  std::cout << iE.what() << std::endl;
97  }
98  }
99 }
void syncTo(const edm::EventID &, const edm::Timestamp &)
Definition: EventSetup.cc:66
unsigned int RecordID
Definition: EventSetup.h:65
bool exists(const char *iRecordName) const
Definition: EventSetup.cc:74
const IOVSyncValue & startSyncValue() const
Definition: Record.cc:152
RecordID recordID(const char *iRecordName) const
Definition: EventSetup.cc:87
virtual const PerformanceWorkingPoint & workingPoint() const
const Record & get(const RecordID &) const
Definition: EventSetup.cc:117
static void enable()
enable automatic library loading
int main(int argc, char **argv)
double f[11][100]
bool get(HANDLE &, const char *iLabel="") const
Definition: Record.h:86
bool isValid() const
Definition: ESHandle.h:44
const edm::EventID & eventID() const
Definition: IOVSyncValue.h:40
virtual float getResult(PerformanceResult::ResultType, const BinningPointByMap &) const
virtual bool isResultOk(PerformanceResult::ResultType, const BinningPointByMap &) const
std::string discriminantName() const