CMS 3D CMS Logo

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