CMS 3D CMS Logo

Benchmark.cc
Go to the documentation of this file.
2 
4 
6 
7 #include <TDirectory.h>
8 
9 using namespace std;
10 
12 
13 void Benchmark::setDirectory(TDirectory *dir) { dir_ = dir; }
14 
16  DQMStore::IBooker &b, const char *histname, const char *title, int nbins, float xmin, float xmax) {
17  edm::LogInfo("Benchmark") << " Benchmark::book1D "
18  << "booking " << histname;
19  return b.book1D(histname, title, nbins, xmin, xmax)->getTH1F();
20 }
21 
23  const char *histname,
24  const char *title,
25  int nbinsx,
26  float xmin,
27  float xmax,
28  int nbinsy,
29  float ymin,
30  float ymax) {
31  edm::LogInfo("Benchmark") << " Benchmark::book2D "
32  << "booked " << histname;
33  return b.book2D(histname, title, nbinsx, xmin, xmax, nbinsy, ymin, ymax)->getTH2F();
34 }
35 
37  const char *histname,
38  const char *title,
39  int nbinsx,
40  float *xbins,
41  int nbinsy,
42  float ymin,
43  float ymax) {
44  edm::LogInfo("Benchmark") << " Benchmark::book2D "
45  << " booked " << histname;
46 
47  // need to build the y bin array manually, due to a missing function in
48  // DQMStore
49  vector<float> ybins(nbinsy + 1);
50  double binsize = (ymax - ymin) / nbinsy;
51  for (int i = 0; i <= nbinsy; ++i) {
52  ybins[i] = ymin + i * binsize;
53  }
54 
55  return b.book2D(histname, title, nbinsx, xbins, nbinsy, &ybins[0])->getTH2F();
56 }
57 
59  const char *histname,
60  const char *title,
61  int nbinsx,
62  float xmin,
63  float xmax,
64  float ymin,
65  float ymax,
66  const char *option) {
67  edm::LogInfo("Benchmark") << " Benchmark::bookProfile "
68  << "booked " << histname;
69  return b.bookProfile(histname, title, nbinsx, xmin, xmax, 0.0, 0.0, option)->getTProfile();
70 }
71 
73  const char *histname,
74  const char *title,
75  int nbinsx,
76  float *xbins,
77  float ymin,
78  float ymax,
79  const char *option) {
80  // need to convert the float bin array into a double bin array, because the
81  // DQMStore TProfile functions take floats, while the DQMStore TH2 functions
82  // take double.
83  vector<double> xbinsd(nbinsx + 1);
84  for (int i = 0; i <= nbinsx; ++i) {
85  xbinsd[i] = xbins[i];
86  }
87 
88  edm::LogInfo("Benchmark") << " Benchmark::bookProfile "
89  << "booked " << histname;
90  return b.bookProfile(histname, title, nbinsx, &xbinsd[0], ymin, ymax, option)->getTProfile();
91 }
92 
94  // COLIN not sure about the root mode
95  if (dir_)
96  dir_->Write();
97 
98  // COLIN remove old bullshit:
99  // if ( ame.size() != 0 && file_)
100  // cout<<"saving histograms in "<<fileName<<endl;
101  // file_->Write(fileName.c_str());
102 }
TH1F * book1D(DQMStore::IBooker &b, const char *histname, const char *title, int nbins, float xmin, float xmax)
book a 1D histogram, either with DQM or plain root depending if DQM_ has been initialized in a child ...
Definition: Benchmark.cc:15
virtual ~Benchmark() noexcept(false)
Definition: Benchmark.cc:11
const double xbins[]
static const char dir_[]
virtual void setDirectory(TDirectory *dir)
Definition: Benchmark.cc:13
void write()
write to the TFile, in plain ROOT mode. No need to call this function in DQM mode ...
Definition: Benchmark.cc:93
TH2F * book2D(DQMStore::IBooker &b, const char *histname, const char *title, int nbinsx, float xmin, float xmax, int nbinsy, float ymin, float ymax)
book a 2D histogram, either with DQM or plain root depending if DQM_ has been initialized in a child ...
Definition: Benchmark.cc:22
Log< level::Info, false > LogInfo
double b
Definition: hdecay.h:118
TProfile * bookProfile(DQMStore::IBooker &b, const char *histname, const char *title, int nbinsx, float xmin, float xmax, float ymin, float ymax, const char *option)
book a TProfile histogram, either with DQM or plain root depending if DQM_ has been initialized in a ...
Definition: Benchmark.cc:58