CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
8 
15 
16 int main(int argc, char ** argv)
17 {
19 
20  std::cout << "Test!!!" << std::endl << std::endl;
21  TFile f("performance_ssvm.root","READ");
22 
23  fwlite::EventSetup es(&f);
24 
25  if ( es.exists("BTagPerformanceRecord") ) {
26  std::cout << "Got the right tree" << std::endl;
27  } else {
28  std::cout << "Can't find tree" << std::endl;
29  }
30 
31  fwlite::RecordID testRecID = es.recordID("BTagPerformanceRecord");
32 
33  int index = 1001;
34  es.syncTo(edm::EventID(index,0,0),edm::Timestamp());
35 
36 
37  std::cout << "Got record ID " << testRecID << es.get(testRecID).startSyncValue().eventID()<<std::endl;
38 
40  es.get(testRecID).get(plHandle,"MCPfTCHEMb");
42  es.get(testRecID).get(wpHandle,"MCPfTCHEMb");
43 
44  if ( plHandle.isValid() && wpHandle.isValid() ) {
45  BtagPerformance perf(*plHandle, *wpHandle);
46 
47  std::cout << "Values: "<<
50  std::endl;
51 
52  // check beff, berr for eta=.6, et=55;
54 
55 // std::cout <<" My Performance Object is indeed a "<<typeid(perf).name()<<std::endl;
56 
57  std::cout <<" test eta=0.6, et=55"<<std::endl;
58 
59 
62  std::cout <<" nbeff/nberr ?"<<perf.isResultOk(PerformanceResult::BTAGNBEFF,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGNBERR,p)<<std::endl;
63  std::cout <<" beff/berr ?"<<perf.isResultOk(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGBERR,p)<<std::endl;
64  std::cout <<" beff/berr ="<<perf.getResult(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.getResult(PerformanceResult::BTAGBERR,p)<<std::endl;
65 
66  std::cout <<" test eta=1.9, et=33"<<std::endl;
69  std::cout <<" beff/berr ?"<<perf.isResultOk(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGBERR,p)<<std::endl;
70  std::cout <<" beff/berr ="<<perf.getResult(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.getResult(PerformanceResult::BTAGBERR,p)<<std::endl;
71 
72  std::cout <<" The WP is defined by a cut at "<<perf.workingPoint().cut()<<std::endl;
73  std::cout <<" Discriminant is "<<perf.workingPoint().discriminantName()<<std::endl;
74 
75  std::cout <<" now I ask for a calibration but I do not set eta in the binning point ---> should return all not available "<<std::endl;
76  p.reset();
79  std::cout <<" beff/berr ?"<<perf.isResultOk(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGBERR,p)<<std::endl;
80  std::cout <<" beff/berr ="<<perf.getResult(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.getResult(PerformanceResult::BTAGBERR,p)<<std::endl;
81 
82  // std::cout <<" now I ask for a calibration which is not present ---> should throw an exception "<<std::endl;
83 
84  // edm::ESHandle<BtagPerformance> perfH2;
85  // iSetup.get<BTagPerformanceRecord>().get("TrackCountingHighEff_tight",perfH2);
86 
87 
88  } else {
89  std::cout << "invalid handle: workingPoint " <<wpHandle.isValid()<<" payload "<<plHandle.isValid()<< std::endl;
90  try {
91  *wpHandle;
92  *plHandle;
93  }catch(std::exception& iE) {
94  std::cout <<iE.what()<<std::endl;
95  }
96  }
97 
98 }
void syncTo(const edm::EventID &, const edm::Timestamp &)
Definition: EventSetup.cc:72
virtual const PerformanceWorkingPoint & workingPoint() const
unsigned int RecordID
Definition: EventSetup.h:63
const IOVSyncValue & startSyncValue() const
Definition: Record.cc:166
bool isValid() const
Definition: ESHandle.h:44
int main(int argc, char **argv)
RecordID recordID(const char *iRecordName) const
Definition: EventSetup.cc:98
virtual bool isResultOk(PerformanceResult::ResultType, const BinningPointByMap &) const
static void enable()
enable automatic library loading
double f[11][100]
bool insert(BinningVariables::BinningVariablesType, float)
tuple argc
Definition: dir2webdir.py:38
bool get(HANDLE &, const char *iLabel="") const
Definition: Record.h:87
virtual float getResult(PerformanceResult::ResultType, const BinningPointByMap &) const
tuple cout
Definition: gather_cfg.py:121
bool exists(const char *iRecordName) const
Definition: EventSetup.cc:83
const Record & get(const RecordID &) const
Definition: EventSetup.cc:127
std::string discriminantName() const
const edm::EventID & eventID() const
Definition: IOVSyncValue.h:42