CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
getbtagPerformance.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"
#include "PhysicsTools/FWLite/interface/CommandLineParser.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 21 of file getbtagPerformance.cc.

References optutl::VariableMapCont::addOption(), PerformanceResult::BTAGBEFF, PerformanceResult::BTAGBEFFCORR, PerformanceResult::BTAGBERR, PerformanceResult::BTAGBERRCORR, PerformanceResult::BTAGCEFF, PerformanceResult::BTAGCEFFCORR, PerformanceResult::BTAGCERR, PerformanceResult::BTAGCERRCORR, PerformanceResult::BTAGLEFF, PerformanceResult::BTAGLEFFCORR, PerformanceResult::BTAGLERR, PerformanceResult::BTAGLERRCORR, gather_cfg::cout, optutl::VariableMapCont::doubleValue(), AutoLibraryLoader::enable(), cppFunctionSkipper::exception, f, BtagPerformance::getResult(), optutl::CommandLineParser::help(), getHLTprescales::index, analyzePatCOC_cfg::inputFile, BinningPointByMap::insert(), fwlite::ESHandle< T >::isValid(), BinningVariables::JetAbsEta, BinningVariables::JetEt, AlCaHLTBitMon_ParallelJobs::p, optutl::CommandLineParser::parseArguments(), geometryXMLtoCSV::parser, and optutl::VariableMapCont::stringValue().

22 {
23  // load fwlite libraries
25  // command line options
26  optutl::CommandLineParser parser ("get performance");
27 
28  parser.addOption ("rootFile", CommandLineParser::kString,
29  "root filename");
30  parser.addOption ("payload", CommandLineParser::kString,
31  "for example MISTAGSSVHEM, MCPfTCHEMb", "MISTAGSSVHEM");
32  parser.addOption ("flavor", CommandLineParser::kString,
33  "for example b, c, or l", "b");
34  parser.addOption ("type", CommandLineParser::kString,
35  "for example eff or SF", "eff");
36  parser.addOption ("pt", CommandLineParser::kDouble,
37  "jet pt");
38  parser.addOption ("eta", CommandLineParser::kDouble,
39  "jet eta");
40 
41  // Parse the command line arguments
42  parser.parseArguments (argc, argv);
43 
44  if (argc<3) {
45  parser.help();
46  }
47 
48  string inputFile = parser.stringValue("rootFile");
49  string payload = parser.stringValue("payload");
50  string flavor = parser.stringValue("flavor");
51  string type = parser.stringValue("type");
52  double ajetpt = parser.doubleValue("pt");
53  double ajeteta = parser.doubleValue("eta");
54 
55  TFile f(inputFile.c_str(),"READ");
56 
57  fwlite::EventSetup es(&f);
58 
59  if ( ! es.exists("BTagPerformanceRecord") ) {
60  cout << "Can't find tree" << endl;
61  parser.help();
62  }
63 
64  fwlite::RecordID testRecID = es.recordID("BTagPerformanceRecord");
65 
66  int index = 1001;
67 
68  es.syncTo(edm::EventID(index,0,0),edm::Timestamp());
69 
71  es.get(testRecID).get(plHandle, payload.c_str() ); // MCPfTCHEMb
73  es.get(testRecID).get(wpHandle, payload.c_str() );
74 
75  if ( plHandle.isValid() && wpHandle.isValid() ) {
76  BtagPerformance perf(*plHandle, *wpHandle);
77 
78  //std::cout << "Values: "<<
79  // PerformanceResult::BTAGNBEFF<<" " <<
80  // PerformanceResult::MUERR<<" " <<
81  // std::endl;
82 
83  // check beff, berr for eta=.6, et=55;
85 
86 
88  p.insert(BinningVariables::JetEt, ajetpt );
89 
90  //std::cout <<" nbeff/nberr ?"<<perf.isResultOk(PerformanceResult::BTAGNBEFF,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGNBERR,p)<<std::endl;
91  //std::cout <<" beff/berr ?"<<perf.isResultOk(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGBERR,p)<<std::endl;
92  if ( type == "eff") {
93  if ( flavor == "b" ) cout <<"eff/err = "<<perf.getResult(PerformanceResult::BTAGBEFF,p)<<" / "<<perf.getResult(PerformanceResult::BTAGBERR,p) << endl;
94  if ( flavor == "c" ) cout <<"eff/err = "<<perf.getResult(PerformanceResult::BTAGCEFF,p)<<" / "<<perf.getResult(PerformanceResult::BTAGCERR,p) << endl;
95  if ( flavor == "l" ) cout <<"eff/err = "<<perf.getResult(PerformanceResult::BTAGLEFF,p)<<" / "<<perf.getResult(PerformanceResult::BTAGLERR,p) << endl;
96  } else if ( type == "SF") {
97  if ( flavor == "b" ) cout <<"SF/err = "<<perf.getResult(PerformanceResult::BTAGBEFFCORR,p)<<" / "<<perf.getResult(PerformanceResult::BTAGBERRCORR,p) << endl;
98  if ( flavor == "c" ) cout <<"SF/err = "<<perf.getResult(PerformanceResult::BTAGCEFFCORR,p)<<" / "<<perf.getResult(PerformanceResult::BTAGCERRCORR,p) << endl;
99  if ( flavor == "l" ) cout <<"SF/err = "<<perf.getResult(PerformanceResult::BTAGLEFFCORR,p)<<" / "<<perf.getResult(PerformanceResult::BTAGLERRCORR,p) << endl;
100  }
101 
102 
103  } else {
104  std::cout << "invalid handle: workingPoint " <<wpHandle.isValid()<<" payload "<<plHandle.isValid()<< std::endl;
105  try {
106  *wpHandle;
107  *plHandle;
108  }catch(std::exception& iE) {
109  std::cout <<iE.what()<<std::endl;
110  }
111  }
112 
113 }
type
Definition: HCALResponse.h:22
unsigned int RecordID
Definition: EventSetup.h:63
bool isValid() const
Definition: ESHandle.h:45
double f[11][100]
bool insert(BinningVariables::BinningVariablesType, float)
tuple argc
Definition: dir2webdir.py:41
static void enable()
enable automatic library loading
tuple cout
Definition: gather_cfg.py:121