CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

int main ( int  argc,
char **  argv 
)

Definition at line 16 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(), cmsHarvester::index, BinningPointByMap::insert(), BtagPerformance::isResultOk(), fwlite::ESHandle< T >::isValid(), BinningVariables::JetAbsEta, BinningVariables::JetEt, BinningVariables::JetNTracks, PerformanceResult::MUERR, AlCaHLTBitMon_ParallelJobs::p, fwlite::EventSetup::recordID(), BinningPointByMap::reset(), fwlite::Record::startSyncValue(), fwlite::EventSetup::syncTo(), and BtagPerformance::workingPoint().

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 }
unsigned int RecordID
Definition: EventSetup.h:63
bool isValid() const
Definition: ESHandle.h:44
static void enable()
enable automatic library loading
double f[11][100]
bool insert(BinningVariables::BinningVariablesType, float)
tuple cout
Definition: gather_cfg.py:121