CMS 3D CMS Logo

Functions
TestPerformanceFWLite_ES.cc File Reference
#include <vector>
#include <iostream>
#include "TFile.h"
#include "TTree.h"
#include "FWCore/FWLite/interface/FWLiteEnabler.h"
#include "PhysicsTools/CondLiteIO/interface/RecordWriter.h"
#include "DataFormats/FWLite/interface/Record.h"
#include "DataFormats/FWLite/interface/EventSetup.h"
#include "DataFormats/FWLite/interface/ESHandle.h"
#include "CondFormats/PhysicsToolsObjects/interface/BinningPointByMap.h"
#include "RecoBTag/PerformanceDB/interface/BtagPerformance.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 15 of file TestPerformanceFWLite_ES.cc.

References PerformanceResult::BTAGBEFF, PerformanceResult::BTAGBERR, PerformanceResult::BTAGNBEFF, PerformanceResult::BTAGNBERR, gather_cfg::cout, PerformanceWorkingPoint::cut(), PerformanceWorkingPoint::discriminantName(), FWLiteEnabler::enable(), fwlite::IOVSyncValue::eventID(), cppFunctionSkipper::exception, fwlite::EventSetup::exists(), f, fwlite::Record::get(), fwlite::EventSetup::get(), BtagPerformance::getResult(), BtagPerformance::isResultOk(), fwlite::ESHandle< T >::isValid(), BinningVariables::JetAbsEta, BinningVariables::JetEt, BinningVariables::JetNTracks, PerformanceResult::MUERR, AlCaHLTBitMon_ParallelJobs::p, fwlite::EventSetup::recordID(), fwlite::Record::startSyncValue(), fwlite::EventSetup::syncTo(), and BtagPerformance::workingPoint().

15  {
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 
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 }
unsigned int RecordID
Definition: EventSetup.h:65
static void enable()
enable automatic library loading
double f[11][100]
bool isValid() const
Definition: ESHandle.h:44