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 "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"
#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 20 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(), FWLiteEnabler::enable(), cppFunctionSkipper::exception, f, BtagPerformance::getResult(), optutl::CommandLineParser::help(), cmsHarvester::index, analyzePatCleaning_cfg::inputFile, BinningPointByMap::insert(), fwlite::ESHandle< T >::isValid(), BinningVariables::JetAbsEta, BinningVariables::JetEt, AlCaHLTBitMon_ParallelJobs::p, optutl::CommandLineParser::parseArguments(), geometryXMLtoCSV::parser, and optutl::VariableMapCont::stringValue().

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