CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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;
32  es.syncTo(edm::EventID(index, 0, 0), edm::Timestamp());
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 
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;
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();
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
virtual const PerformanceWorkingPoint & workingPoint() const
unsigned int RecordID
Definition: EventSetup.h:65
const IOVSyncValue & startSyncValue() const
Definition: Record.cc:152
bool isValid() const
Definition: ESHandle.h:44
RecordID recordID(const char *iRecordName) const
Definition: EventSetup.cc:87
virtual bool isResultOk(PerformanceResult::ResultType, const BinningPointByMap &) const
static void enable()
enable automatic library loading
bool insert(BinningVariables::BinningVariablesType, float)
tuple argc
Definition: dir2webdir.py:39
bool get(HANDLE &, const char *iLabel="") const
Definition: Record.h:86
virtual float getResult(PerformanceResult::ResultType, const BinningPointByMap &) const
tuple cout
Definition: gather_cfg.py:144
bool exists(const char *iRecordName) const
Definition: EventSetup.cc:74
const Record & get(const RecordID &) const
Definition: EventSetup.cc:117
std::string discriminantName() const
const edm::EventID & eventID() const
Definition: IOVSyncValue.h:40