CMS 3D CMS Logo

Public Member Functions | Private Attributes

BTagPerformance Class Reference

#include <BTagPerformance.h>

List of all members.

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 (yumiceva@fnal.gov)
Version:
Id:
BTagPerformance.h,v 1.2 2009/10/20 12:24:28 hegner Exp

Definition at line 16 of file BTagPerformance.h.


Constructor & Destructor Documentation

BTagPerformance::BTagPerformance ( ) [inline]

Definition at line 19 of file BTagPerformance.h.

{};

Member Function Documentation

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

Definition at line 41 of file BTagPerformance.h.

References b_all, b_tagged, c_all, c_tagged, align_tpl::cut, disc_map, fdisc, fflavor, fMaxDisc, fMinDisc, fNcuts, i, udsg_all, and udsg_tagged.

Referenced by PatBTagAnalyzer::analyze().

                                                     {

                fdisc = discriminator;
                fflavor = flavor;
                double binwidth = (fMaxDisc-fMinDisc)/((double) fNcuts);
                if (fflavor==5) b_all++;
                if (fflavor==4) c_all++;
                if ((fflavor>0 && fflavor<4)||(fflavor==21)) udsg_all++;
                
                for( int i=0; i<fNcuts; ++i ) {
                        double cut = i*binwidth + fMinDisc;
                        if (cut > fMaxDisc) cut = fMaxDisc;

                        disc_map[i] = cut;
                        if ( fdisc > cut ) {
                                if ( fflavor==5 ) b_tagged[i]++;
                                if ( fflavor==4 ) c_tagged[i]++;
                                if ((fflavor>0 && fflavor<4)||(fflavor==21)) udsg_tagged[i]++;
                        }
                }
        };
void BTagPerformance::Eval ( ) [inline]

Definition at line 63 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().

                    {
                double small = 1.e-5;
                int ip = 0;
                for(std::map<int,double>::const_iterator im=b_tagged.begin(); im!=b_tagged.end(); ++im) {

                        double eff = (im->second)/((double)b_all);
                        double err = sqrt(eff*(1-eff)/b_all);
                        if ( eff==0 || eff< small ) { eff = small; err=0; }
                        b_eff[ip] = eff;
                        b_effErr[ip] = err;
                        //g1["b"+fname].SetPoint(ip,eff,eff);
                        //h1["b"+fname]->Fill(eff);
                        ip++;
                }
                ip=0;
                for(std::map<int,double>::const_iterator im=c_tagged.begin(); im!=c_tagged.end(); ++im) {
                  
                  double eff = (im->second)/((double)c_all);
                  double err = sqrt(eff*(1-eff)/c_all);
                  if ( eff==0 || eff< small ) { eff = small; err=0; }
                  c_eff[ip] = eff;
                  c_effErr[ip] = err;
                  //g1["c"+fname].SetPoint(ip,b_tagged[ip],eff);
                        //h1["c"+fname]->Fill(eff);
                        ip++;
                }
                ip=0;
                for(std::map<int,double>::const_iterator im=udsg_tagged.begin(); im!=udsg_tagged.end(); 
++im) {

                        double eff = (im->second)/((double)udsg_all);
                        double err = sqrt(eff*(1-eff)/udsg_all);
                        if ( eff==0 || eff< small ) { eff = small; err=0; }
                        udsg_eff[ip] = eff;
                        udsg_effErr[ip] = err;
                        //g1["udsg"+fname].SetPoint(ip,b_tagged[ip],eff);
                        //h1["udsg"+fname]->Fill(eff);
                        ip++;
                }
                                
        };
TArrayD BTagPerformance::GetArray ( TString  option = "b") [inline]

Definition at line 115 of file BTagPerformance.h.

References fNcuts, and GetMap().

Referenced by PatBTagAnalyzer::endJob().

                                             {
          std::map<int,double> amap = GetMap(option);
          TArrayD tarray(fNcuts);
          for(std::map<int,double>::const_iterator im=amap.begin(); im!=amap.end(); ++im) {
                  //std::cout << "i= " << im->first << " value= " << im->second << std::endl;
            tarray[im->first] = im->second;
          }
          return tarray;
          
        };
double BTagPerformance::Getb_all ( ) [inline]

Definition at line 128 of file BTagPerformance.h.

References b_all.

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

Definition at line 129 of file BTagPerformance.h.

References c_all.

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

Definition at line 104 of file BTagPerformance.h.

References b_eff, b_effErr, c_eff, c_effErr, disc_map, udsg_eff, and udsg_effErr.

Referenced by GetArray().

                                                       {
          if (option=="b") return b_eff;
          if (option=="c") return c_eff;
          if (option=="udsg") return udsg_eff;
          if (option=="bErr") return b_effErr;
          if (option=="cErr") return c_effErr;
          if (option=="udsgErr") return udsg_effErr;
          if (option=="discriminator") return disc_map;
          else { assert(false); return disc_map;}
        };
int BTagPerformance::GetN ( ) [inline]

Definition at line 126 of file BTagPerformance.h.

References fNcuts.

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

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

Definition at line 130 of file BTagPerformance.h.

References udsg_all.

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

Definition at line 20 of file BTagPerformance.h.

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

Referenced by PatBTagAnalyzer::beginJob().

                                 {
                fname = name;
                fNcuts = 40;
                b_all = c_all = udsg_all = 0;
                for( int i=0; i<fNcuts; ++i) {
                  b_tagged[i] = 0;
                  c_tagged[i] = 0;
                  udsg_tagged[i] = 0;
                }
                
        };
void BTagPerformance::SetMaxDiscriminator ( double  value) [inline]

Definition at line 32 of file BTagPerformance.h.

References fMaxDisc, and relativeConstraints::value.

Referenced by PatBTagAnalyzer::beginJob().

{ fMaxDisc = value; };
void BTagPerformance::SetMinDiscriminator ( double  value) [inline]

Definition at line 31 of file BTagPerformance.h.

References fMinDisc, and relativeConstraints::value.

Referenced by PatBTagAnalyzer::beginJob().

{ fMinDisc = value; };
void BTagPerformance::SetNcuts ( int  value) [inline]

Definition at line 33 of file BTagPerformance.h.

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

                                   { 
          fNcuts = value;
          for( int i=0; i<fNcuts; ++i) {
            b_tagged[i] = 0;
            c_tagged[i] = 0;
            udsg_tagged[i] = 0;
          }
        };

Member Data Documentation

double BTagPerformance::b_all [private]

Definition at line 153 of file BTagPerformance.h.

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

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

Definition at line 142 of file BTagPerformance.h.

Referenced by Eval(), and GetMap().

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

Definition at line 145 of file BTagPerformance.h.

Referenced by Eval(), and GetMap().

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

Definition at line 150 of file BTagPerformance.h.

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

double BTagPerformance::c_all [private]

Definition at line 154 of file BTagPerformance.h.

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

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

Definition at line 143 of file BTagPerformance.h.

Referenced by Eval(), and GetMap().

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

Definition at line 146 of file BTagPerformance.h.

Referenced by Eval(), and GetMap().

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

Definition at line 151 of file BTagPerformance.h.

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

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

Definition at line 148 of file BTagPerformance.h.

Referenced by Add(), and GetMap().

Double_t* BTagPerformance::farray [private]

Definition at line 130 of file BTagPerformance.h.

double BTagPerformance::fdisc [private]

Definition at line 134 of file BTagPerformance.h.

Referenced by Add().

int BTagPerformance::fflavor [private]

Definition at line 135 of file BTagPerformance.h.

Referenced by Add().

double BTagPerformance::fMaxDisc [private]

Definition at line 137 of file BTagPerformance.h.

Referenced by Add(), and SetMaxDiscriminator().

double BTagPerformance::fMinDisc [private]

Definition at line 136 of file BTagPerformance.h.

Referenced by Add(), and SetMinDiscriminator().

std::string BTagPerformance::fname [private]

Definition at line 139 of file BTagPerformance.h.

Referenced by Set().

int BTagPerformance::fNcuts [private]

Definition at line 138 of file BTagPerformance.h.

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

double BTagPerformance::udsg_all [private]

Definition at line 155 of file BTagPerformance.h.

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

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

Definition at line 144 of file BTagPerformance.h.

Referenced by Eval(), and GetMap().

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

Definition at line 147 of file BTagPerformance.h.

Referenced by Eval(), and GetMap().

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

Definition at line 152 of file BTagPerformance.h.

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