Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:32

0001 // -*- C++ -*-
0002 //
0003 // Package:    TestPerformanceFW_ES
0004 // Class:      TestPerformanceFW_ES
0005 //
0006 /**\class TestPerformanceFW_ES TestPerformanceFW_ES.cc RecoBTag/TestPerformanceFW_ES/src/TestPerformanceFW_ES.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Tommaso Boccali
0015 //         Created:  Tue Nov 25 15:50:50 CET 2008
0016 //
0017 //
0018 
0019 // system include files
0020 #include <iostream>
0021 #include <memory>
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0026 
0027 #include "FWCore/Framework/interface/Event.h"
0028 #include "FWCore/Framework/interface/MakerMacros.h"
0029 #include "FWCore/Framework/interface/EventSetup.h"
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031 #include "FWCore/Framework/interface/ESHandle.h"
0032 //
0033 // class decleration
0034 //
0035 
0036 #include "RecoBTag/Records/interface/BTagPerformanceRecord.h"
0037 
0038 #include "CondFormats/PhysicsToolsObjects/interface/BinningPointByMap.h"
0039 #include "RecoBTag/PerformanceDB/interface/BtagPerformance.h"
0040 
0041 class TestPerformanceFW_ES_TFormula : public edm::one::EDAnalyzer<> {
0042 public:
0043   explicit TestPerformanceFW_ES_TFormula(const edm::ParameterSet&);
0044 
0045 private:
0046   std::string name_;
0047   edm::ESGetToken<BtagPerformance, BTagPerformanceRecord> token_;
0048   void analyze(const edm::Event&, const edm::EventSetup&) final;
0049 
0050   // ----------member data ---------------------------
0051 };
0052 
0053 //
0054 // constants, enums and typedefs
0055 //
0056 
0057 //
0058 // static data member definitions
0059 //
0060 
0061 //
0062 // constructors and destructor
0063 //
0064 
0065 TestPerformanceFW_ES_TFormula::TestPerformanceFW_ES_TFormula(const edm::ParameterSet& iConfig)
0066 
0067 {
0068   //now do what ever initialization is needed
0069   std::cout << " In the constructor" << std::endl;
0070 
0071   name_ = iConfig.getParameter<std::string>("AlgoName");
0072 
0073   token_ = esConsumes(edm::ESInputTag("", name_));
0074 }
0075 
0076 //
0077 // member functions
0078 //
0079 
0080 // ------------ method called to for each event  ------------
0081 void TestPerformanceFW_ES_TFormula::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0082   std::cout << " Studying performance with label " << name_ << std::endl;
0083 
0084   const BtagPerformance& perf = iSetup.getData(token_);
0085 
0086   //std::cout << "Values: "<<
0087   //  PerformanceResult::BTAGNBEFF<<" " <<
0088   //  PerformanceResult::MUERR<<" " <<
0089   //  std::endl;
0090 
0091   // check beff, berr for eta=.6, et=55;
0092   BinningPointByMap p;
0093 
0094   std::cout << " My Performance Object is indeed a " << typeid(&perf).name() << std::endl;
0095 
0096   //++++++++++++------  TESTING FOR CONTINIOUS DISCRIMINATORS      --------+++++++++++++
0097 
0098   std::cout << " The WP is defined by a cut at " << perf.workingPoint().cut() << std::endl;
0099   std::cout << " Discriminant is " << perf.workingPoint().discriminantName() << std::endl;
0100   std::cout << " Is cut based WP " << perf.workingPoint().cutBased() << std::endl;
0101 
0102   p.insert(BinningVariables::JetEta, 0.6);
0103   p.insert(BinningVariables::Discriminator, 0.23);
0104 
0105   std::cout << " test eta=0.6, discrim = 0.3" << std::endl;
0106   std::cout << " beff/berr ?" << perf.isResultOk(PerformanceResult::BTAGBEFF, p) << "/"
0107             << perf.isResultOk(PerformanceResult::BTAGBERR, p) << std::endl;
0108   std::cout << " beff/berr =" << perf.getResult(PerformanceResult::BTAGBEFF, p) << "/"
0109             << perf.getResult(PerformanceResult::BTAGBERR, p) << std::endl;
0110   std::cout << " bSF/bFSerr ?" << perf.isResultOk(PerformanceResult::BTAGBEFFCORR, p) << "/"
0111             << perf.isResultOk(PerformanceResult::BTAGBERRCORR, p) << std::endl;
0112   std::cout << " bSF/bSFerr =" << perf.getResult(PerformanceResult::BTAGBEFFCORR, p) << "/"
0113             << perf.getResult(PerformanceResult::BTAGBERRCORR, p) << std::endl;
0114 
0115   std::cout << std::endl;
0116 
0117   p.insert(BinningVariables::JetEta, 1.8);
0118   p.insert(BinningVariables::Discriminator, 0.53);
0119 
0120   std::cout << " NEW POINT " << std::endl;
0121 
0122   std::cout << " test eta=1.8, discrim = 0.3" << std::endl;
0123   std::cout << " beff/berr ?" << perf.isResultOk(PerformanceResult::BTAGBEFF, p) << "/"
0124             << perf.isResultOk(PerformanceResult::BTAGBERR, p) << std::endl;
0125   std::cout << " beff/berr =" << perf.getResult(PerformanceResult::BTAGBEFF, p) << "/"
0126             << perf.getResult(PerformanceResult::BTAGBERR, p) << std::endl;
0127   std::cout << " bSF/bFSerr ?" << perf.isResultOk(PerformanceResult::BTAGBEFFCORR, p) << "/"
0128             << perf.isResultOk(PerformanceResult::BTAGBERRCORR, p) << std::endl;
0129   std::cout << " bSF/bSFerr =" << perf.getResult(PerformanceResult::BTAGBEFFCORR, p) << "/"
0130             << perf.getResult(PerformanceResult::BTAGBERRCORR, p) << std::endl;
0131 
0132   p.insert(BinningVariables::JetEta, 0.8);
0133   p.insert(BinningVariables::Discriminator, 1.64);
0134 
0135   std::cout << std::endl;
0136 
0137   std::cout << " NEW POINT " << std::endl;
0138 
0139   std::cout << " test eta=3.8, discrim = 0.4" << std::endl;
0140   std::cout << " beff/berr ?" << perf.isResultOk(PerformanceResult::BTAGBEFF, p) << "/"
0141             << perf.isResultOk(PerformanceResult::BTAGBERR, p) << std::endl;
0142   std::cout << " beff/berr =" << perf.getResult(PerformanceResult::BTAGBEFF, p) << "/"
0143             << perf.getResult(PerformanceResult::BTAGBERR, p) << std::endl;
0144   std::cout << " bSF/bFSerr ?" << perf.isResultOk(PerformanceResult::BTAGBEFFCORR, p) << "/"
0145             << perf.isResultOk(PerformanceResult::BTAGBERRCORR, p) << std::endl;
0146   std::cout << " bSF/bSFerr =" << perf.getResult(PerformanceResult::BTAGBEFFCORR, p) << "/"
0147             << perf.getResult(PerformanceResult::BTAGBERRCORR, p) << std::endl;
0148 
0149   /*
0150   p.insert(BinningVariables::JetEta,0.6);
0151   p.insert(BinningVariables::Discriminator,2.3);
0152   
0153   std::cout <<" FROM MC test eta=0.6, discrim = 0.3"<<std::endl;
0154   std::cout <<" beff/berr ?"<<perf.isResultOk(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGBERR,p)<<std::endl;
0155   std::cout <<" beff/berr ="<<perf.getResult(PerformanceResult::BTAGBEFF,p)<<"/"<<perf.getResult(PerformanceResult::BTAGBERR,p)<<std::endl;
0156   std::cout <<" ceff/cerr ?"<<perf.isResultOk(PerformanceResult::BTAGCEFF,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGCERR,p)<<std::endl;
0157   std::cout <<" ceff/cerr ="<<perf.getResult(PerformanceResult::BTAGCEFF,p)<<"/"<<perf.getResult(PerformanceResult::BTAGCERR,p)<<std::endl;
0158   
0159   std::cout << std::endl;
0160   */
0161 
0162   //++++++++++++------  TESTING FOR CONTINIOUS DISCRIMINATORS      --------+++++++++++++
0163 
0164   /*
0165   std::cout <<" The WP is defined by a cut at "<<perf.workingPoint().cut()<<std::endl;
0166   std::cout <<" Discriminant is "<<perf.workingPoint().discriminantName()<<std::endl;
0167 
0168   std::cout <<" test eta=0.6, et=55"<<std::endl;
0169   p.insert(BinningVariables::JetEta,0.6);
0170   p.insert(BinningVariables::JetEt,55);
0171   std::cout <<" bSF/bSFerr ?"<<perf.isResultOk(PerformanceResult::BTAGLEFFCORR,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGLERRCORR,p)<<std::endl;
0172   std::cout <<" bSF/bSFerr ="<<perf.getResult(PerformanceResult::BTAGLEFFCORR,p)<<"/"<<perf.getResult(PerformanceResult::BTAGLERRCORR,p)<<std::endl;
0173   std::cout <<" beff/berr ?"<<perf.isResultOk(PerformanceResult::BTAGLEFF,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGLERR,p)<<std::endl;
0174   std::cout <<" bSF/bSFerr ="<<perf.getResult(PerformanceResult::BTAGLEFF,p)<<"/"<<perf.getResult(PerformanceResult::BTAGLERR,p)<<std::endl;
0175   */
0176 
0177   /*
0178   std::cout <<" test eta=1.9, et=33"<<std::endl;
0179   p.insert(BinningVariables::JetEta,1.9);
0180   p.insert(BinningVariables::JetEt,33);
0181   std::cout <<" beff/berr ?"<<perf.isResultOk(PerformanceResult::BTAGLEFFCORR,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGLERRCORR,p)<<std::endl;
0182   std::cout <<" beff/berr ="<<perf.getResult(PerformanceResult::BTAGLEFFCORR,p)<<"/"<<perf.getResult(PerformanceResult::BTAGLERRCORR,p)<<std::endl;
0183 
0184 
0185   std::cout <<" test eta=0.2, et=433"<<std::endl;
0186   p.insert(BinningVariables::JetEta,0.9);
0187   p.insert(BinningVariables::JetEt,433);
0188   std::cout <<" beff/berr ?"<<perf.isResultOk(PerformanceResult::BTAGLEFFCORR,p)<<"/"<<perf.isResultOk(PerformanceResult::BTAGLERRCORR,p)<<std::endl;
0189   std::cout <<" beff/berr ="<<perf.getResult(PerformanceResult::BTAGLEFFCORR,p)<<"/"<<perf.getResult(PerformanceResult::BTAGLERRCORR,p)<<std::endl;
0190   */
0191 
0192   //  std::cout <<" now I ask for a calibration which is not present ---> should throw an exception "<<std::endl;
0193 
0194   //  edm::ESHandle<BtagPerformance> perfH2;
0195   //  iSetup.get<BTagPerformanceRecord>().get("TrackCountingHighEff_tight",perfH2);
0196 }
0197 
0198 //define this as a plug-in
0199 DEFINE_FWK_MODULE(TestPerformanceFW_ES_TFormula);