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 }
fwlite::EventSetup::get
const Record & get(const RecordID &) const
Definition: EventSetup.cc:117
fwlite::Record::startSyncValue
const IOVSyncValue & startSyncValue() const
Definition: Record.cc:152
BtagPerformance::getResult
virtual float getResult(PerformanceResult::ResultType, const BinningPointByMap &) const
Definition: BtagPerformance.cc:3
cmsBatch.argv
argv
Definition: cmsBatch.py:279
BtagPerformance.h
PerformanceWorkingPoint::discriminantName
std::string discriminantName() const
Definition: PerformanceWorkingPoint.h:13
fwlite::EventSetup::recordID
RecordID recordID(const char *iRecordName) const
Definition: EventSetup.cc:87
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
PerformanceResult::BTAGNBERR
Definition: PerformanceResult.h:19
dir2webdir.argc
argc
Definition: dir2webdir.py:39
RecordWriter.h
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
PerformanceWorkingPoint::cut
float cut() const
Definition: PerformanceWorkingPoint.h:12
fwlite::ESHandle
Definition: ESHandle.h:37
fwlite::Record::get
bool get(HANDLE &, const char *iLabel="") const
Definition: Record.h:87
main
int main(int argc, char **argv)
Definition: TestPerformanceFWLite_ES.cc:15
BtagPerformance::workingPoint
virtual const PerformanceWorkingPoint & workingPoint() const
Definition: BtagPerformance.h:22
BinningVariables::JetAbsEta
Definition: BinningVariables.h:16
BinningVariables::JetNTracks
Definition: BinningVariables.h:15
BinningPointByMap.h
EventSetup.h
BtagPerformance::isResultOk
virtual bool isResultOk(PerformanceResult::ResultType, const BinningPointByMap &) const
Definition: BtagPerformance.cc:7
PerformanceResult::MUERR
Definition: PerformanceResult.h:35
BtagPerformance
Definition: BtagPerformance.h:12
fwlite::ESHandle::isValid
bool isValid() const
Definition: ESHandle.h:44
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
FWLiteEnabler::enable
static void enable()
enable automatic library loading
Definition: FWLiteEnabler.cc:46
fwlite::RecordID
unsigned int RecordID
Definition: EventSetup.h:65
fwlite::EventSetup::syncTo
void syncTo(const edm::EventID &, const edm::Timestamp &)
Definition: EventSetup.cc:66
PerformanceResult::BTAGBERR
Definition: PerformanceResult.h:13
BinningPointByMap
Definition: BinningPointByMap.h:8
fwlite::EventSetup::exists
bool exists(const char *iRecordName) const
Definition: EventSetup.cc:74
PerformanceResult::BTAGNBEFF
Definition: PerformanceResult.h:18
PerformanceResult::BTAGBEFF
Definition: PerformanceResult.h:12
ESHandle.h
BinningVariables::JetEt
Definition: BinningVariables.h:13
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
Record.h
edm::EventID
Definition: EventID.h:31
FWLiteEnabler.h
fwlite::EventSetup
Definition: EventSetup.h:68
fwlite::IOVSyncValue::eventID
const edm::EventID & eventID() const
Definition: IOVSyncValue.h:40
edm::Timestamp
Definition: Timestamp.h:30