Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
#include "DQMOffline/PFTau/interface/Benchmark.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "DQMServices/Core/interface/DQMStore.h"

#include <TDirectory.h>

using namespace std;

Benchmark::~Benchmark() noexcept(false) {}

void Benchmark::setDirectory(TDirectory *dir) { dir_ = dir; }

TH1F *Benchmark::book1D(
    DQMStore::IBooker &b, const char *histname, const char *title, int nbins, float xmin, float xmax) {
  edm::LogInfo("Benchmark") << " Benchmark::book1D "
                            << "booking " << histname;
  return b.book1D(histname, title, nbins, xmin, xmax)->getTH1F();
}

TH2F *Benchmark::book2D(DQMStore::IBooker &b,
                        const char *histname,
                        const char *title,
                        int nbinsx,
                        float xmin,
                        float xmax,
                        int nbinsy,
                        float ymin,
                        float ymax) {
  edm::LogInfo("Benchmark") << " Benchmark::book2D "
                            << "booked " << histname;
  return b.book2D(histname, title, nbinsx, xmin, xmax, nbinsy, ymin, ymax)->getTH2F();
}

TH2F *Benchmark::book2D(DQMStore::IBooker &b,
                        const char *histname,
                        const char *title,
                        int nbinsx,
                        float *xbins,
                        int nbinsy,
                        float ymin,
                        float ymax) {
  edm::LogInfo("Benchmark") << " Benchmark::book2D "
                            << " booked " << histname;

  // need to build the y bin array manually, due to a missing function in
  // DQMStore
  vector<float> ybins(nbinsy + 1);
  double binsize = (ymax - ymin) / nbinsy;
  for (int i = 0; i <= nbinsy; ++i) {
    ybins[i] = ymin + i * binsize;
  }

  return b.book2D(histname, title, nbinsx, xbins, nbinsy, &ybins[0])->getTH2F();
}

TProfile *Benchmark::bookProfile(DQMStore::IBooker &b,
                                 const char *histname,
                                 const char *title,
                                 int nbinsx,
                                 float xmin,
                                 float xmax,
                                 float ymin,
                                 float ymax,
                                 const char *option) {
  edm::LogInfo("Benchmark") << " Benchmark::bookProfile "
                            << "booked " << histname;
  return b.bookProfile(histname, title, nbinsx, xmin, xmax, 0.0, 0.0, option)->getTProfile();
}

TProfile *Benchmark::bookProfile(DQMStore::IBooker &b,
                                 const char *histname,
                                 const char *title,
                                 int nbinsx,
                                 float *xbins,
                                 float ymin,
                                 float ymax,
                                 const char *option) {
  // 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.
  vector<double> xbinsd(nbinsx + 1);
  for (int i = 0; i <= nbinsx; ++i) {
    xbinsd[i] = xbins[i];
  }

  edm::LogInfo("Benchmark") << " Benchmark::bookProfile "
                            << "booked " << histname;
  return b.bookProfile(histname, title, nbinsx, &xbinsd[0], ymin, ymax, option)->getTProfile();
}

void Benchmark::write() {
  // COLIN not sure about the root mode
  if (dir_)
    dir_->Write();

  // COLIN remove old bullshit:
  //   if ( ame.size() != 0 && file_)
  //     cout<<"saving histograms in "<<fileName<<endl;
  //     file_->Write(fileName.c_str());
}