CMS 3D CMS Logo

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