CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
BTagPerformance Class Reference

#include <BTagPerformance.h>

Public Member Functions

void Add (double discriminator, int flavor)
 
 BTagPerformance ()
 
void Eval ()
 
TArrayD GetArray (TString option="b")
 
double Getb_all ()
 
double Getc_all ()
 
std::map< int, double > GetMap (TString option="b")
 
int GetN ()
 
double Getudsg_all ()
 
void Set (std::string name)
 
void SetMaxDiscriminator (double value)
 
void SetMinDiscriminator (double value)
 
void SetNcuts (int value)
 

Private Attributes

double b_all
 
std::map< int, double > b_eff
 
std::map< int, double > b_effErr
 
std::map< int, double > b_tagged
 
double c_all
 
std::map< int, double > c_eff
 
std::map< int, double > c_effErr
 
std::map< int, double > c_tagged
 
std::map< int, double > disc_map
 
Double_t * farray
 
double fdisc
 
int fflavor
 
double fMaxDisc
 
double fMinDisc
 
std::string fname
 
int fNcuts
 
double udsg_all
 
std::map< int, double > udsg_eff
 
std::map< int, double > udsg_effErr
 
std::map< int, double > udsg_tagged
 

Detailed Description

Analyze ROOT files produced by analyzer and create plots

Author
Francisco Yumiceva, Fermilab (yumic.nosp@m.eva@.nosp@m.fnal..nosp@m.gov)

Definition at line 17 of file BTagPerformance.h.

Constructor & Destructor Documentation

BTagPerformance::BTagPerformance ( )
inline

Definition at line 20 of file BTagPerformance.h.

20 {};

Member Function Documentation

void BTagPerformance::Add ( double  discriminator,
int  flavor 
)
inline

Definition at line 42 of file BTagPerformance.h.

References b_all, b_tagged, c_all, c_tagged, TkAlMuonSelectors_cfi::cut, disc_map, mvaPFMET_leptons_cfi::discriminator, fdisc, fflavor, fMaxDisc, fMinDisc, fNcuts, mps_fire::i, udsg_all, and udsg_tagged.

Referenced by PatBTagAnalyzer::analyze().

42  {
43 
45  fflavor = flavor;
46  double binwidth = (fMaxDisc-fMinDisc)/((double) fNcuts);
47  if (fflavor==5) b_all++;
48  if (fflavor==4) c_all++;
49  if ((fflavor>0 && fflavor<4)||(fflavor==21)) udsg_all++;
50 
51  for( int i=0; i<fNcuts; ++i ) {
52  double cut = i*binwidth + fMinDisc;
53  if (cut > fMaxDisc) cut = fMaxDisc;
54 
55  disc_map[i] = cut;
56  if ( fdisc > cut ) {
57  if ( fflavor==5 ) b_tagged[i]++;
58  if ( fflavor==4 ) c_tagged[i]++;
59  if ((fflavor>0 && fflavor<4)||(fflavor==21)) udsg_tagged[i]++;
60  }
61  }
62  };
std::map< int, double > udsg_tagged
std::map< int, double > b_tagged
std::map< int, double > c_tagged
std::map< int, double > disc_map
void BTagPerformance::Eval ( )
inline

Definition at line 64 of file BTagPerformance.h.

References b_all, b_eff, b_effErr, b_tagged, c_all, c_eff, c_effErr, c_tagged, mathSSE::sqrt(), udsg_all, udsg_eff, udsg_effErr, and udsg_tagged.

Referenced by PatBTagAnalyzer::endJob().

64  {
65  double small = 1.e-5;
66  int ip = 0;
67  for(std::map<int,double>::const_iterator im=b_tagged.begin(); im!=b_tagged.end(); ++im) {
68 
69  double eff = (im->second)/((double)b_all);
70  double err = sqrt(eff*(1-eff)/b_all);
71  if ( eff==0 || eff< small ) { eff = small; err=0; }
72  b_eff[ip] = eff;
73  b_effErr[ip] = err;
74  //g1["b"+fname].SetPoint(ip,eff,eff);
75  //h1["b"+fname]->Fill(eff);
76  ip++;
77  }
78  ip=0;
79  for(std::map<int,double>::const_iterator im=c_tagged.begin(); im!=c_tagged.end(); ++im) {
80 
81  double eff = (im->second)/((double)c_all);
82  double err = sqrt(eff*(1-eff)/c_all);
83  if ( eff==0 || eff< small ) { eff = small; err=0; }
84  c_eff[ip] = eff;
85  c_effErr[ip] = err;
86  //g1["c"+fname].SetPoint(ip,b_tagged[ip],eff);
87  //h1["c"+fname]->Fill(eff);
88  ip++;
89  }
90  ip=0;
91  for(std::map<int,double>::const_iterator im=udsg_tagged.begin(); im!=udsg_tagged.end();
92 ++im) {
93 
94  double eff = (im->second)/((double)udsg_all);
95  double err = sqrt(eff*(1-eff)/udsg_all);
96  if ( eff==0 || eff< small ) { eff = small; err=0; }
97  udsg_eff[ip] = eff;
98  udsg_effErr[ip] = err;
99  //g1["udsg"+fname].SetPoint(ip,b_tagged[ip],eff);
100  //h1["udsg"+fname]->Fill(eff);
101  ip++;
102  }
103 
104  };
std::map< int, double > udsg_tagged
std::map< int, double > b_tagged
std::map< int, double > b_effErr
std::map< int, double > udsg_eff
T sqrt(T t)
Definition: SSEVec.h:18
std::map< int, double > b_eff
std::map< int, double > c_tagged
std::map< int, double > c_effErr
std::map< int, double > udsg_effErr
std::map< int, double > c_eff
TArrayD BTagPerformance::GetArray ( TString  option = "b")
inline

Definition at line 116 of file BTagPerformance.h.

References fNcuts, GetMap(), and TSGForRoadSearch_cfi::option.

Referenced by PatBTagAnalyzer::endJob().

116  {
117  std::map<int,double> amap = GetMap(option);
118  TArrayD tarray(fNcuts);
119  for(std::map<int,double>::const_iterator im=amap.begin(); im!=amap.end(); ++im) {
120  //std::cout << "i= " << im->first << " value= " << im->second << std::endl;
121  tarray[im->first] = im->second;
122  }
123  return tarray;
124 
125  };
std::map< int, double > GetMap(TString option="b")
double BTagPerformance::Getb_all ( )
inline

Definition at line 129 of file BTagPerformance.h.

References b_all.

129 {return b_all; };
double BTagPerformance::Getc_all ( )
inline

Definition at line 130 of file BTagPerformance.h.

References c_all.

130 {return c_all; };
std::map< int,double> BTagPerformance::GetMap ( TString  option = "b")
inline

Definition at line 105 of file BTagPerformance.h.

References b_eff, b_effErr, c_eff, c_effErr, disc_map, TSGForRoadSearch_cfi::option, udsg_eff, and udsg_effErr.

Referenced by GetArray().

105  {
106  if (option=="b") return b_eff;
107  if (option=="c") return c_eff;
108  if (option=="udsg") return udsg_eff;
109  if (option=="bErr") return b_effErr;
110  if (option=="cErr") return c_effErr;
111  if (option=="udsgErr") return udsg_effErr;
112  if (option=="discriminator") return disc_map;
113  else { assert(false); return disc_map;}
114  };
std::map< int, double > b_effErr
std::map< int, double > udsg_eff
std::map< int, double > b_eff
std::map< int, double > c_effErr
std::map< int, double > udsg_effErr
std::map< int, double > disc_map
std::map< int, double > c_eff
int BTagPerformance::GetN ( )
inline

Definition at line 127 of file BTagPerformance.h.

References fNcuts.

Referenced by PatBTagAnalyzer::beginJob(), and PatBTagAnalyzer::endJob().

127 { return fNcuts; };
double BTagPerformance::Getudsg_all ( )
inline

Definition at line 131 of file BTagPerformance.h.

References farray, and udsg_all.

131 {return udsg_all; };
void BTagPerformance::Set ( std::string  name)
inline

Definition at line 21 of file BTagPerformance.h.

References b_all, b_tagged, c_all, c_tagged, fname, fNcuts, mps_fire::i, dataset::name, udsg_all, and udsg_tagged.

Referenced by PatBTagAnalyzer::beginJob().

21  {
22  fname = name;
23  fNcuts = 40;
24  b_all = c_all = udsg_all = 0;
25  for( int i=0; i<fNcuts; ++i) {
26  b_tagged[i] = 0;
27  c_tagged[i] = 0;
28  udsg_tagged[i] = 0;
29  }
30 
31  };
std::map< int, double > udsg_tagged
std::map< int, double > b_tagged
std::string fname
std::map< int, double > c_tagged
void BTagPerformance::SetMaxDiscriminator ( double  value)
inline
void BTagPerformance::SetMinDiscriminator ( double  value)
inline
void BTagPerformance::SetNcuts ( int  value)
inline

Definition at line 34 of file BTagPerformance.h.

References b_tagged, c_tagged, fNcuts, mps_fire::i, udsg_tagged, and relativeConstraints::value.

34  {
35  fNcuts = value;
36  for( int i=0; i<fNcuts; ++i) {
37  b_tagged[i] = 0;
38  c_tagged[i] = 0;
39  udsg_tagged[i] = 0;
40  }
41  };
std::map< int, double > udsg_tagged
std::map< int, double > b_tagged
std::map< int, double > c_tagged

Member Data Documentation

double BTagPerformance::b_all
private

Definition at line 154 of file BTagPerformance.h.

Referenced by Add(), Eval(), Getb_all(), and Set().

std::map< int, double > BTagPerformance::b_eff
private

Definition at line 143 of file BTagPerformance.h.

Referenced by Eval(), and GetMap().

std::map< int, double > BTagPerformance::b_effErr
private

Definition at line 146 of file BTagPerformance.h.

Referenced by Eval(), and GetMap().

std::map< int, double > BTagPerformance::b_tagged
private

Definition at line 151 of file BTagPerformance.h.

Referenced by Add(), Eval(), Set(), and SetNcuts().

double BTagPerformance::c_all
private

Definition at line 155 of file BTagPerformance.h.

Referenced by Add(), Eval(), Getc_all(), and Set().

std::map< int, double > BTagPerformance::c_eff
private

Definition at line 144 of file BTagPerformance.h.

Referenced by Eval(), and GetMap().

std::map< int, double > BTagPerformance::c_effErr
private

Definition at line 147 of file BTagPerformance.h.

Referenced by Eval(), and GetMap().

std::map< int, double > BTagPerformance::c_tagged
private

Definition at line 152 of file BTagPerformance.h.

Referenced by Add(), Eval(), Set(), and SetNcuts().

std::map< int, double > BTagPerformance::disc_map
private

Definition at line 149 of file BTagPerformance.h.

Referenced by Add(), and GetMap().

Double_t* BTagPerformance::farray
private

Definition at line 131 of file BTagPerformance.h.

Referenced by Getudsg_all().

double BTagPerformance::fdisc
private

Definition at line 135 of file BTagPerformance.h.

Referenced by Add().

int BTagPerformance::fflavor
private

Definition at line 136 of file BTagPerformance.h.

Referenced by Add().

double BTagPerformance::fMaxDisc
private

Definition at line 138 of file BTagPerformance.h.

Referenced by Add(), and SetMaxDiscriminator().

double BTagPerformance::fMinDisc
private

Definition at line 137 of file BTagPerformance.h.

Referenced by Add(), and SetMinDiscriminator().

std::string BTagPerformance::fname
private

Definition at line 140 of file BTagPerformance.h.

Referenced by Set().

int BTagPerformance::fNcuts
private

Definition at line 139 of file BTagPerformance.h.

Referenced by Add(), GetArray(), GetN(), Set(), and SetNcuts().

double BTagPerformance::udsg_all
private

Definition at line 156 of file BTagPerformance.h.

Referenced by Add(), Eval(), Getudsg_all(), and Set().

std::map< int, double > BTagPerformance::udsg_eff
private

Definition at line 145 of file BTagPerformance.h.

Referenced by Eval(), and GetMap().

std::map< int, double > BTagPerformance::udsg_effErr
private

Definition at line 148 of file BTagPerformance.h.

Referenced by Eval(), and GetMap().

std::map< int, double > BTagPerformance::udsg_tagged
private

Definition at line 153 of file BTagPerformance.h.

Referenced by Add(), Eval(), Set(), and SetNcuts().