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 "Cintex/Cintex.h"
#include "TFile.h"
#include "TTree.h"
#include "FWCore/FWLite/interface/AutoLibraryLoader.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 17 of file TestPerformanceFWLite_ES.cc.

References PerformanceResult::BTAGBEFF, PerformanceResult::BTAGBERR, PerformanceResult::BTAGNBEFF, PerformanceResult::BTAGNBERR, gather_cfg::cout, PerformanceWorkingPoint::cut(), PerformanceWorkingPoint::discriminantName(), AutoLibraryLoader::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().

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