CMS 3D CMS Logo

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 144 of file BTagEntry.cc.

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

Referenced by BTagEntry::BTagEntry().

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

Definition at line 124 of file BTagEntry.cc.

References mps_fire::i, and pileupCalc::nbins.

Referenced by BTagEntry::BTagEntry().

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