Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:17

0001 #ifndef Validation_MuonGEMHits_MuonGEMBaseHarvestor_h
0002 #define Validation_MuonGEMHits_MuonGEMBaseHarvestor_h
0003 
0004 #include "DQMServices/Core/interface/DQMEDHarvester.h"
0005 #include "DQMServices/Core/interface/DQMStore.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "Validation/MuonGEMHits/interface/GEMValidationUtils.h"
0010 
0011 #include "TSystem.h"
0012 #include "TString.h"
0013 
0014 class MuonGEMBaseHarvestor : public DQMEDHarvester {
0015 public:
0016   explicit MuonGEMBaseHarvestor(const edm::ParameterSet&, std::string);
0017 
0018 protected:
0019   // FIXME typename
0020   template <typename T>
0021   T* getElement(DQMStore::IGetter& getter, const TString& path);
0022 
0023   // 0.683 means 1 standard deviation of the normal distribution.
0024   TProfile* computeEfficiency(
0025       const TH1F& passed, const TH1F& total, const char* name, const char* title, Double_t confidence_level = 0.683);
0026 
0027   TH2F* computeEfficiency(const TH2F& passed, const TH2F& total, const char* name, const char* title);
0028 
0029   void bookEff1D(DQMStore::IBooker& ibooker,
0030                  DQMStore::IGetter& getter,
0031                  const TString& passed_path,
0032                  const TString& total_path,
0033                  const TString& folder,
0034                  const TString& eff_name,
0035                  const TString& eff_title = "Efficiency");
0036 
0037   void bookEff2D(DQMStore::IBooker& ibooker,
0038                  DQMStore::IGetter& getter,
0039                  const TString& passed_path,
0040                  const TString& total_path,
0041                  const TString& folder,
0042                  const TString& eff_name,
0043                  const TString& eff_title = "Efficiency");
0044 
0045   // Constnats
0046   const std::string kLogCategory_;  // see member initializer list
0047 };
0048 
0049 #endif  // Validation_MuonGEMHits_MuonGEMBaseHarvestor_h
0050 
0051 template <typename T>
0052 T* MuonGEMBaseHarvestor::getElement(DQMStore::IGetter& getter, const TString& path) {
0053   std::string folder = gSystem->DirName(path);
0054   std::string name = gSystem->BaseName(path);
0055 
0056   getter.setCurrentFolder(folder);
0057   std::vector<std::string> mes = getter.getMEs();
0058 
0059   if (std::find(mes.begin(), mes.end(), name) == mes.end()) {
0060     edm::LogInfo(kLogCategory_) << "doesn't contain " << path << std::endl;
0061     return nullptr;
0062   }
0063 
0064   T* hist = nullptr;
0065   if (auto tmp_me = getter.get(path.Data())) {
0066     if (auto tmp_hist = dynamic_cast<T*>(tmp_me->getRootObject()->Clone())) {
0067       hist = tmp_hist;
0068       hist->Sumw2();
0069     } else {
0070       edm::LogError(kLogCategory_) << "failed to getRootObject " << path << std::endl;
0071     }
0072 
0073   } else {
0074     edm::LogError(kLogCategory_) << "failed to get " << path << std::endl;
0075   }
0076 
0077   return hist;
0078 }