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 "Cintex/Cintex.h"
5 #include "TFile.h"
6 #include "TTree.h"
8 
9 
16 
17 int main(int argc, char ** argv)
18 {
20 
21  std::cout << "Test!!!" << std::endl << std::endl;
22  TFile f("performance_ssvm.root","READ");
23 
24  fwlite::EventSetup es(&f);
25 
26  if ( es.exists("BTagPerformanceRecord") ) {
27  std::cout << "Got the right tree" << std::endl;
28  } else {
29  std::cout << "Can't find tree" << std::endl;
30  }
31 
32  fwlite::RecordID testRecID = es.recordID("BTagPerformanceRecord");
33 
34  int index = 1001;
35  es.syncTo(edm::EventID(index,0,0),edm::Timestamp());
36 
37 
38  std::cout << "Got record ID " << testRecID << es.get(testRecID).startSyncValue().eventID()<<std::endl;
39 
41  es.get(testRecID).get(plHandle,"MCPfTCHEMb");
43  es.get(testRecID).get(wpHandle,"MCPfTCHEMb");
44 
45  if ( plHandle.isValid() && wpHandle.isValid() ) {
46  BtagPerformance perf(*plHandle, *wpHandle);
47 
48  std::cout << "Values: "<<
51  std::endl;
52 
53  // check beff, berr for eta=.6, et=55;
55 
56 // std::cout <<" My Performance Object is indeed a "<<typeid(perf).name()<<std::endl;
57 
58  std::cout <<" test eta=0.6, et=55"<<std::endl;
59 
60 
63  std::cout <<" nbeff/nberr ?"<<perf.isResultOk(PerformanceResult::BTAGNBEFF,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGNBERR,p)<<std::endl;
64  std::cout <<" beff/berr ?"<<perf.isResultOk(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGBERR,p)<<std::endl;
65  std::cout <<" beff/berr ="<<perf.getResult(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.getResult(PerformanceResult::BTAGBERR,p)<<std::endl;
66 
67  std::cout <<" test eta=1.9, et=33"<<std::endl;
70  std::cout <<" beff/berr ?"<<perf.isResultOk(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGBERR,p)<<std::endl;
71  std::cout <<" beff/berr ="<<perf.getResult(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.getResult(PerformanceResult::BTAGBERR,p)<<std::endl;
72 
73  std::cout <<" The WP is defined by a cut at "<<perf.workingPoint().cut()<<std::endl;
74  std::cout <<" Discriminant is "<<perf.workingPoint().discriminantName()<<std::endl;
75 
76  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;
77  p.reset();
80  std::cout <<" beff/berr ?"<<perf.isResultOk(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGBERR,p)<<std::endl;
81  std::cout <<" beff/berr ="<<perf.getResult(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.getResult(PerformanceResult::BTAGBERR,p)<<std::endl;
82 
83  // std::cout <<" now I ask for a calibration which is not present ---> should throw an exception "<<std::endl;
84 
85  // edm::ESHandle<BtagPerformance> perfH2;
86  // iSetup.get<BTagPerformanceRecord>().get("TrackCountingHighEff_tight",perfH2);
87 
88 
89  } else {
90  std::cout << "invalid handle: workingPoint " <<wpHandle.isValid()<<" payload "<<plHandle.isValid()<< std::endl;
91  try {
92  *wpHandle;
93  *plHandle;
94  }catch(std::exception& iE) {
95  std::cout <<iE.what()<<std::endl;
96  }
97  }
98 
99 }
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:45
int main(int argc, char **argv)
RecordID recordID(const char *iRecordName) const
Definition: EventSetup.cc:98
virtual bool isResultOk(PerformanceResult::ResultType, const BinningPointByMap &) const
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
static void enable()
enable automatic library loading
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