CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
BTagEntry.cc File Reference
#include <algorithm>
#include <sstream>
#include "CondFormats/BTauObjects/interface/BTagEntry.h"
#include "FWCore/Utilities/interface/Exception.h"

Go to the source code of this file.

Functions

std::string th1ToFormulaBinTree (const TH1 *hist, int start=0, int end=-1)
 
std::string th1ToFormulaLin (const TH1 *hist)
 

Function Documentation

std::string th1ToFormulaBinTree ( const TH1 *  hist,
int  start = 0,
int  end = -1 
)

Definition at line 145 of file BTagEntry.cc.

References end, dqm_diff::start, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by BTagEntry::BTagEntry().

145  {
146  if (end == -1) { // initialize
147  start = 0.;
148  end = hist->GetNbinsX()+1;
149  TH1* h2 = (TH1*) hist->Clone();
150  h2->SetBinContent(start, 0); // kill underflow
151  h2->SetBinContent(end, 0); // kill overflow
153  delete h2;
154  return res;
155  }
156  if (start == end) { // leave is reached
157  char tmp_buff[20];
158  sprintf(tmp_buff, "%g", hist->GetBinContent(start));
159  return std::string(tmp_buff);
160  }
161  if (start == end - 1) { // no parenthesis for neighbors
162  char tmp_buff[70];
163  sprintf(tmp_buff,
164  "x<%g ? %g:%g",
165  hist->GetXaxis()->GetBinUpEdge(start),
166  hist->GetBinContent(start),
167  hist->GetBinContent(end));
168  return std::string(tmp_buff);
169  }
170 
171  // top-down recursion
172  std::stringstream buff;
173  int mid = (end-start)/2 + start;
174  char tmp_buff[25];
175  sprintf(tmp_buff,
176  "x<%g ? (",
177  hist->GetXaxis()->GetBinUpEdge(mid));
178  buff << tmp_buff
179  << th1ToFormulaBinTree(hist, start, mid)
180  << ") : ("
181  << th1ToFormulaBinTree(hist, mid+1, end)
182  << ")";
183  return buff.str();
184 }
std::string th1ToFormulaBinTree(const TH1 *hist, int start=0, int end=-1)
Definition: BTagEntry.cc:145
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
#define end
Definition: vmac.h:37
std::string th1ToFormulaLin ( const TH1 *  hist)

Definition at line 125 of file BTagEntry.cc.

References i, and pileupCalc::nbins.

Referenced by BTagEntry::BTagEntry().

125  {
126  int nbins = hist->GetNbinsX();
127  TAxis const* axis = hist->GetXaxis();
128  std::stringstream buff;
129  buff << "x<" << axis->GetBinLowEdge(1) << " ? 0. : "; // default value
130  for (int i=1; i<nbins+1; ++i) {
131  char tmp_buff[50];
132  sprintf(tmp_buff,
133  "x<%g ? %g : ", // %g is the smaller one of %e or %f
134  axis->GetBinUpEdge(i),
135  hist->GetBinContent(i));
136  buff << tmp_buff;
137  }
138  buff << 0.; // default value
139  return buff.str();
140 }
int i
Definition: DBlmapReader.cc:9