File indexing completed on 2023-03-17 10:57:49
0001 #include <iostream>
0002
0003 #include "DQMOffline/JetMET/plugins/SusyPostProcessor.h"
0004 #include "DQMOffline/JetMET/interface/SusyDQM/Quantile.h"
0005 #include "FWCore/PluginManager/interface/ModuleDef.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007
0008 using namespace std;
0009
0010 const char* SusyPostProcessor::messageLoggerCatregory = "SusyDQMPostProcessor";
0011
0012 SusyPostProcessor::SusyPostProcessor(const edm::ParameterSet& pSet) {
0013 iConfig = pSet;
0014
0015 SUSYFolder = iConfig.getParameter<string>("folderName");
0016 _quantile = iConfig.getParameter<double>("quantile");
0017 }
0018
0019 SusyPostProcessor::~SusyPostProcessor() {}
0020
0021 void SusyPostProcessor::QuantilePlots(MonitorElement*& ME, double q_value, DQMStore::IBooker& ibooker_) {
0022 if (ME->getTH1()->GetEntries() > 0.) {
0023 Quantile q(static_cast<const TH1*>(ME->getTH1()));
0024 Float_t mean = q[q_value].first;
0025 Float_t RMS = q[q_value].second;
0026
0027 Float_t xLow = -5.5;
0028 Float_t xUp = 9.5;
0029 Int_t NBin = 15;
0030
0031 if (mean > 0.) {
0032 Float_t DBin = RMS * TMath::Sqrt(12.) / 2.;
0033 xLow = mean - int(mean / DBin + 2) * DBin;
0034 xUp = int(0.2 * mean / DBin) * DBin + mean + 5 * DBin;
0035 NBin = (xUp - xLow) / DBin;
0036 }
0037
0038 ibooker_.setCurrentFolder(ME->getPathname());
0039 TString name = ME->getTH1()->GetName();
0040 name += "_quant";
0041 ME = ibooker_.book1D(name, "", NBin, xLow, xUp);
0042 ME->Fill(mean - RMS);
0043 ME->Fill(mean + RMS);
0044 }
0045 }
0046
0047 void SusyPostProcessor::dqmEndJob(DQMStore::IBooker& ibook_, DQMStore::IGetter& iget_) {
0048
0049
0050 iget_.setCurrentFolder("JetMET/MET");
0051
0052 Dirs = iget_.getSubdirs();
0053
0054 std::vector<std::string> metFolders;
0055
0056 metFolders.push_back("Uncleaned/");
0057 metFolders.push_back("Cleaned/");
0058
0059
0060 TF1 mygaus("mygaus", "gaus");
0061
0062 for (int i = 0; i < int(Dirs.size()); i++) {
0063 std::string prefix = "dummy";
0064
0065 if (size_t(Dirs[i].find("met")) != string::npos)
0066 prefix = "met";
0067 if (size_t(Dirs[i].find("pfMet")) != string::npos)
0068 prefix = "pfMET";
0069
0070 for (std::vector<std::string>::const_iterator ic = metFolders.begin(); ic != metFolders.end(); ic++) {
0071 std::string dirName = Dirs[i] + "/" + *ic;
0072
0073 MEx = iget_.get(dirName + "/" + "MEx");
0074 MEy = iget_.get(dirName + "/" + "MEy");
0075
0076 if (MEx && MEx->kind() == MonitorElement::Kind::TH1F) {
0077 if (MEx->getTH1F()->GetEntries() > 50)
0078 MEx->getTH1F()->Fit(&mygaus, "q");
0079 }
0080
0081 if (MEy && MEy->kind() == MonitorElement::Kind::TH1F) {
0082 if (MEy->getTH1F()->GetEntries() > 50)
0083 MEy->getTH1F()->Fit(&mygaus, "q");
0084 }
0085 }
0086 }
0087
0088
0089
0090 iget_.setCurrentFolder(SUSYFolder);
0091 Dirs = iget_.getSubdirs();
0092 for (int i = 0; i < int(Dirs.size()); i++) {
0093 size_t found = Dirs[i].find("Alpha");
0094 if (found != string::npos)
0095 continue;
0096 if (!iget_.dirExists(Dirs[i])) {
0097 edm::LogError(messageLoggerCatregory) << "Directory " << Dirs[i] << " doesn't exist!!";
0098 continue;
0099 }
0100 vector<MonitorElement*> histoVector = iget_.getContents(Dirs[i]);
0101 for (int i = 0; i < int(histoVector.size()); i++) {
0102 QuantilePlots(histoVector[i], _quantile, ibook_);
0103 }
0104 }
0105 }