Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-13 23:26:55

0001 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0002 #include "DQMServices/Core/interface/DQMEDHarvester.h"
0003 #include "DQMServices/Core/interface/DQMStore.h"
0004 
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "FWCore/ServiceRegistry/interface/Service.h"
0009 
0010 class DQMHcalIsoTrackPostProcessor : public DQMEDHarvester {
0011 public:
0012   DQMHcalIsoTrackPostProcessor(const edm::ParameterSet &pset);
0013   ~DQMHcalIsoTrackPostProcessor() override{};
0014 
0015   //  void analyze(const edm::Event& event, const edm::EventSetup& eventSetup)
0016   //  override {};
0017   void dqmEndJob(DQMStore::IBooker &,
0018                  DQMStore::IGetter &) override;  // performed in the endJob
0019 
0020 private:
0021   std::string subDir_;
0022 };
0023 
0024 DQMHcalIsoTrackPostProcessor::DQMHcalIsoTrackPostProcessor(const edm::ParameterSet &pset) {
0025   subDir_ = pset.getUntrackedParameter<std::string>("subDir");
0026 }
0027 
0028 void DQMHcalIsoTrackPostProcessor::dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) {
0029   if (igetter.dirExists(subDir_)) {
0030     igetter.cd(subDir_);
0031   } else {
0032     edm::LogWarning("DQMHcalIsoTrackPostProcessor") << "cannot find directory: " << subDir_ << " , skipping";
0033     return;
0034   }
0035 
0036   MonitorElement *hSumEta[4], *hSumPhi[4], *hPurityEta[3], *hPurityPhi[3];
0037   std::string types[4] = {"L2", "L2x", "L3", "Off"};
0038   char name[100], title[200];
0039   for (int i = 0; i < 4; ++i) {
0040     sprintf(name, "/heta%s", types[i].c_str());
0041     std::string hname1 = ibooker.pwd() + std::string(name);
0042     int nbinEta = igetter.get(hname1)->getTH1F()->GetNbinsX();
0043     double xminEta = igetter.get(hname1)->getTH1F()->GetBinLowEdge(1);
0044     double xmaxEta =
0045         igetter.get(hname1)->getTH1F()->GetBinLowEdge(nbinEta) + igetter.get(hname1)->getTH1F()->GetBinWidth(nbinEta);
0046     sprintf(name, "/hphi%s", types[i].c_str());
0047     std::string hname2 = ibooker.pwd() + std::string(name);
0048     int nbinPhi = igetter.get(hname2)->getTH1F()->GetNbinsX();
0049     double xminPhi = igetter.get(hname2)->getTH1F()->GetBinLowEdge(1);
0050     double xmaxPhi =
0051         igetter.get(hname2)->getTH1F()->GetBinLowEdge(nbinEta) + igetter.get(hname2)->getTH1F()->GetBinWidth(nbinEta);
0052     sprintf(name, "hSum%sEta", types[i].c_str());
0053     hSumEta[i] = ibooker.book1D(name, name, nbinEta, xminEta, xmaxEta);
0054     sprintf(name, "hSum%sPhi", types[i].c_str());
0055     hSumPhi[i] = ibooker.book1D(name, name, nbinPhi, xminPhi, xmaxPhi);
0056     if (i < 3) {
0057       sprintf(name, "hPurity%sEta", types[i].c_str());
0058       sprintf(title, "Purity of %s sample vs #eta", types[i].c_str());
0059       hPurityEta[i] = ibooker.book1D(name, title, nbinEta, xminEta, xmaxEta);
0060       sprintf(name, "hPurity%sPhi", types[i].c_str());
0061       sprintf(title, "Purity of %s sample vs #phi", types[i].c_str());
0062       hPurityPhi[i] = ibooker.book1D(name, title, nbinPhi, xminPhi, xmaxPhi);
0063     }
0064   }
0065 
0066   for (int i = 0; i < 4; ++i) {
0067     sprintf(name, "/heta%s", types[i].c_str());
0068     std::string hname1 = ibooker.pwd() + std::string(name);
0069     edm::LogVerbatim("DQMHcal") << "PostProcesor " << hname1 << " " << igetter.get(hname1);
0070 
0071     hSumEta[i]->getTH1F()->Add(igetter.get(hname1)->getTH1F(), 1);
0072     sprintf(name, "/hphi%s", types[i].c_str());
0073     std::string hname2 = ibooker.pwd() + std::string(name);
0074     edm::LogVerbatim("DQMHcal") << "PostProcesor " << hname2 << " " << igetter.get(hname2);
0075 
0076     hSumPhi[i]->getTH1F()->Add(igetter.get(hname2)->getTH1F(), 1);
0077   }
0078 
0079   for (int i = 0; i < 3; ++i) {
0080     hPurityEta[i]->getTH1F()->Divide(hSumEta[i + 1]->getTH1F(), hSumEta[i]->getTH1F(), 1, 1);
0081     hPurityPhi[i]->getTH1F()->Divide(hSumPhi[i + 1]->getTH1F(), hSumPhi[i]->getTH1F(), 1, 1);
0082   }
0083 }
0084 
0085 DEFINE_FWK_MODULE(DQMHcalIsoTrackPostProcessor);