DESY Hbb Analysis Framework
Public Member Functions | Protected Attributes | List of all members
analysis::tools::MuonIdWeight Class Reference

#include <MuonIdWeight.h>

Public Member Functions

std::shared_ptr< TH2D > histogram (const int &var=0)
 
 MuonIdWeight ()
 constructors More...
 
 MuonIdWeight (const std::string &)
 
float weight (const float &pt, const float &eta, const int &var=0)
 
 ~MuonIdWeight ()
 desctructor More...
 

Protected Attributes

std::map< int, std::shared_ptr< TH2D > > histos_
 

Detailed Description

Definition at line 40 of file MuonIdWeight.h.

Constructor & Destructor Documentation

MuonIdWeight::MuonIdWeight ( )

constructors

Definition at line 15 of file MuonIdWeight.cc.

16 {
17 }
MuonIdWeight::MuonIdWeight ( const std::string &  fname)

Definition at line 20 of file MuonIdWeight.cc.

References f, and histos_.

21 {
22  TH2D * tmp;
23  std::shared_ptr<TFile> f = std::make_shared<TFile>(fname.c_str(),"old");
24  tmp = (TH2D*) f->Get("weight_2down");
25  if ( tmp ) histos_[-2] = std::make_shared<TH2D>(*tmp);
26 
27  tmp = (TH2D*) f->Get("weight_1down");
28  if ( tmp ) histos_[-1] = std::make_shared<TH2D>(*tmp);
29 
30  tmp = (TH2D*) f->Get("weight");
31  if ( tmp ) histos_[0] = std::make_shared<TH2D>(*tmp);
32 
33  tmp = (TH2D*) f->Get("weight_1up");
34  if ( tmp ) histos_[1] = std::make_shared<TH2D>(*tmp);
35 
36  tmp = (TH2D*) f->Get("weight_2up");
37  if ( tmp ) histos_[2] = std::make_shared<TH2D>(*tmp);
38 
39  if ( ! histos_[-2] )
40  std::cout << "WARNING - MuonIdWeight::MuonIdWeight | Histogram weight_2down not found. Weight = 1" << std::endl;
41  if ( ! histos_[-1] )
42  std::cout << "WARNING - MuonIdWeight::MuonIdWeight | Histogram weight_1down not found. Weight = 1" << std::endl;
43  if ( ! histos_[0] )
44  std::cout << "WARNING - MuonIdWeight::MuonIdWeight | Histogram weight not found. Weight = 1" << std::endl;
45  if ( ! histos_[1] )
46  std::cout << "WARNING - MuonIdWeight::MuonIdWeight | Histogram weight_1up not found. Weight = 1" << std::endl;
47  if ( ! histos_[2] )
48  std::cout << "WARNING - MuonIdWeight::MuonIdWeight | Histogram weight_2up not found. Weight = 1" << std::endl;
49 }
std::map< int, std::shared_ptr< TH2D > > histos_
Definition: MuonIdWeight.h:50
TFile * f[10]
Definition: PlotsCompare.cc:24
MuonIdWeight::~MuonIdWeight ( )

desctructor

Definition at line 51 of file MuonIdWeight.cc.

52 {
53  // do anything here that needs to be done at desctruction time
54  // (e.g. close files, deallocate resources etc.)
55 }

Member Function Documentation

std::shared_ptr<TH2D> analysis::tools::MuonIdWeight::histogram ( const int &  var = 0)
float MuonIdWeight::weight ( const float &  pt,
const float &  eta,
const int &  var = 0 
)

Definition at line 64 of file MuonIdWeight.cc.

References histos_.

65 {
66  float weight = 1.;
67  if ( ! histos_[0] ) return weight;
68  if ( ! histos_[var] ) return weight;
69  int binx = histos_[var] -> GetXaxis()->FindBin(pt);
70  int biny = histos_[var] -> GetYaxis()->FindBin(eta);
71  weight = histos_[var] -> GetBinContent(binx, biny);
72  return weight;
73 }
float weight(const float &pt, const float &eta, const int &var=0)
Definition: MuonIdWeight.cc:64
std::map< int, std::shared_ptr< TH2D > > histos_
Definition: MuonIdWeight.h:50

Member Data Documentation

std::map<int,std::shared_ptr<TH2D> > analysis::tools::MuonIdWeight::histos_
protected

Definition at line 50 of file MuonIdWeight.h.

Referenced by MuonIdWeight(), and weight().


The documentation for this class was generated from the following files: