CMS 3D CMS Logo

MuonGEMBaseHarvestor.h
Go to the documentation of this file.
1 #ifndef Validation_MuonGEMHits_MuonGEMBaseHarvestor_h
2 #define Validation_MuonGEMHits_MuonGEMBaseHarvestor_h
3 
10 
11 #include "TSystem.h"
12 #include "TString.h"
13 
15 public:
17 
18 protected:
19  // FIXME typename
20  template <typename T>
21  T* getElement(DQMStore::IGetter& getter, const TString& path);
22 
23  // 0.683 means 1 standard deviation of the normal distribution.
24  TProfile* computeEfficiency(
25  const TH1F& passed, const TH1F& total, const char* name, const char* title, Double_t confidence_level = 0.683);
26 
27  TH2F* computeEfficiency(const TH2F& passed, const TH2F& total, const char* name, const char* title);
28 
29  void bookEff1D(DQMStore::IBooker& ibooker,
30  DQMStore::IGetter& getter,
31  const TString& passed_path,
32  const TString& total_path,
33  const TString& folder,
34  const TString& eff_name,
35  const TString& eff_title = "Efficiency");
36 
37  void bookEff2D(DQMStore::IBooker& ibooker,
38  DQMStore::IGetter& getter,
39  const TString& passed_path,
40  const TString& total_path,
41  const TString& folder,
42  const TString& eff_name,
43  const TString& eff_title = "Efficiency");
44 
45  // Constnats
46  const std::string kLogCategory_; // see member initializer list
47 };
48 
49 #endif // Validation_MuonGEMHits_MuonGEMBaseHarvestor_h
50 
51 template <typename T>
53  std::string folder = gSystem->DirName(path);
54  std::string name = gSystem->BaseName(path);
55 
56  getter.setCurrentFolder(folder);
57  std::vector<std::string> mes = getter.getMEs();
58 
59  if (std::find(mes.begin(), mes.end(), name) == mes.end()) {
60  edm::LogInfo(kLogCategory_) << "doesn't contain " << path << std::endl;
61  return nullptr;
62  }
63 
64  T* hist = nullptr;
65  if (auto tmp_me = getter.get(path.Data())) {
66  if (auto tmp_hist = dynamic_cast<T*>(tmp_me->getRootObject()->Clone())) {
67  hist = tmp_hist;
68  hist->Sumw2();
69  } else {
70  edm::LogError(kLogCategory_) << "failed to getRootObject " << path << std::endl;
71  }
72 
73  } else {
74  edm::LogError(kLogCategory_) << "failed to get " << path << std::endl;
75  }
76 
77  return hist;
78 }
const std::string kLogCategory_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
virtual std::vector< std::string > getMEs() const
Definition: DQMStore.cc:720
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void bookEff2D(DQMStore::IBooker &ibooker, DQMStore::IGetter &getter, const TString &passed_path, const TString &total_path, const TString &folder, const TString &eff_name, const TString &eff_title="Efficiency")
MuonGEMBaseHarvestor(const edm::ParameterSet &, std::string)
void bookEff1D(DQMStore::IBooker &ibooker, DQMStore::IGetter &getter, const TString &passed_path, const TString &total_path, const TString &folder, const TString &eff_name, const TString &eff_title="Efficiency")
T * getElement(DQMStore::IGetter &getter, const TString &path)
__shared__ Hist hist
Log< level::Info, false > LogInfo
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
TProfile * computeEfficiency(const TH1F &passed, const TH1F &total, const char *name, const char *title, Double_t confidence_level=0.683)
long double T