CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  if( &b ) {
26  edm::LogInfo("Benchmark") << " Benchmark::book1D " << "booking "<<histname;
27  return b.book1D(histname,title,nbins,xmin,xmax)->getTH1F();
28  }
29  else assert(0);
30 }
31 
32 TH2F* Benchmark::book2D(DQMStore::IBooker& b, const char* histname, const char* title,
33  int nbinsx, float xmin, float xmax,
34  int nbinsy, float ymin, float ymax ) {
35  if( &b ) {
36  edm::LogInfo("Benchmark") << " Benchmark::book2D "<<"booked "<<histname;
37  return b.book2D(histname,title,nbinsx,xmin, xmax, nbinsy, ymin, ymax)->getTH2F();
38  }
39  else assert(0);
40 }
41 
42 TH2F* Benchmark::book2D(DQMStore::IBooker& b, const char* histname, const char* title,
43  int nbinsx, float* xbins,
44  int nbinsy, float ymin, float ymax ) {
45  if( &b ) {
46  edm::LogInfo("Benchmark") << " Benchmark::book2D " << " booked "<<histname;
47 
48  // need to build the y bin array manually, due to a missing function in 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  else assert(0);
58 }
59 
60 TProfile* Benchmark::bookProfile(DQMStore::IBooker& b, const char* histname, const char* title,
61  int nbinsx, float xmin, float xmax,
62  float ymin, float ymax, const char* option ) {
63  if( &b ) {
64  edm::LogInfo("Benchmark") << " Benchmark::bookProfile "<<"booked "<<histname;
65  return b.bookProfile(histname, title, nbinsx, xmin, xmax, 0.0, 0.0, option )->getTProfile();
66  }
67  else assert(0);
68 }
69 
70 TProfile* Benchmark::bookProfile(DQMStore::IBooker& b, const char* histname, const char* title,
71  int nbinsx, float* xbins,
72  float ymin, float ymax, const char* option ) {
73 
74  // 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.
75  vector<double> xbinsd(nbinsx+1);
76  for(int i=0; i<=nbinsx; ++i) {
77  xbinsd[i] = xbins[i];
78  }
79 
80  if( &b ) {
81  edm::LogInfo("Benchmark") << " Benchmark::bookProfile "<<"booked "<<histname;
82  return b.bookProfile(histname, title, nbinsx, &xbinsd[0], ymin, ymax, option)->getTProfile();
83  }
84  else assert(0);
85 }
86 
87 
89  //COLIN not sure about the root mode
90  if( dir_ )
91  dir_->Write();
92 
93  //COLIN remove old bullshit:
94  // if ( ame.size() != 0 && file_)
95  // cout<<"saving histograms in "<<fileName<<endl;
96  // file_->Write(fileName.c_str());
97 }
int i
Definition: DBlmapReader.cc:9
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:157
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:88
virtual ~Benchmark()
Definition: Benchmark.cc:13
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
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:32
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
TH1F * getTH1F(void) const
double b
Definition: hdecay.h:120
TProfile * getTProfile(void) const
dbl *** dir
Definition: mlp_gen.cc:35
TH2F * getTH2F(void) const
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:60