Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:12:23

0001 #include "DQM/TrackingMonitorClient/interface/DQMScaleToClient.h"
0002 
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 //
0006 // -------------------------------------- Constructor --------------------------------------------
0007 //
0008 DQMScaleToClient::DQMScaleToClient(const edm::ParameterSet& iConfig)
0009     : inputmepset_(getHistoPSet(iConfig.getParameter<edm::ParameterSet>("inputme"))),
0010       outputmepset_(getOutputHistoPSet(iConfig.getParameter<edm::ParameterSet>("outputme"))) {
0011   edm::LogInfo("DQMScaleToClient") << "Constructor  DQMScaleToClient::DQMScaleToClient " << std::endl;
0012 
0013   scaled_ = nullptr;
0014 }
0015 
0016 MEPSet DQMScaleToClient::getHistoPSet(edm::ParameterSet pset) {
0017   return MEPSet{
0018       pset.getParameter<std::string>("name"),
0019       pset.getParameter<std::string>("folder"),
0020   };
0021 }
0022 
0023 OutputMEPSet DQMScaleToClient::getOutputHistoPSet(edm::ParameterSet pset) {
0024   return OutputMEPSet{
0025       pset.getParameter<std::string>("name"),
0026       pset.getParameter<std::string>("folder"),
0027       pset.getParameter<double>("factor"),
0028   };
0029 }
0030 
0031 //
0032 // -------------------------------------- beginJob --------------------------------------------
0033 //
0034 void DQMScaleToClient::beginJob() { edm::LogInfo("DQMScaleToClient") << "DQMScaleToClient::beginJob " << std::endl; }
0035 
0036 //
0037 // -------------------------------------- get and book in the endJob --------------------------------------------
0038 //
0039 void DQMScaleToClient::dqmEndJob(DQMStore::IBooker& ibooker_, DQMStore::IGetter& igetter_) {
0040   std::string hname = "";
0041 
0042   // create and cd into new folder
0043   std::string currentFolder = outputmepset_.folder;
0044   ibooker_.setCurrentFolder(currentFolder);
0045 
0046   //get available histograms
0047   hname = inputmepset_.folder + "/" + inputmepset_.name;
0048   MonitorElement* inputme = igetter_.get(hname);
0049 
0050   if (!inputme) {
0051     edm::LogError("DQMScaleToClient") << "MEs not found! "
0052                                       << inputmepset_.folder + "/" + inputmepset_.name + " not found " << std::endl;
0053     return;
0054   }
0055 
0056   //book new histogram
0057   ibooker_.setCurrentFolder(currentFolder);
0058   hname = outputmepset_.name;
0059   scaled_ = ibooker_.book1D(hname, (TH1F*)inputme->getTH1()->Clone(hname.c_str()));
0060 
0061   // handle mes
0062   double integral = (scaled_->getTH1()->Integral() > 0. ? scaled_->getTH1()->Integral() : 1.);
0063   scaled_->getTH1()->Scale(outputmepset_.factor / integral);
0064 }
0065 
0066 //
0067 // -------------------------------------- get in the endLumi if needed --------------------------------------------
0068 //
0069 void DQMScaleToClient::dqmEndLuminosityBlock(DQMStore::IBooker& ibooker_,
0070                                              DQMStore::IGetter& igetter_,
0071                                              edm::LuminosityBlock const& iLumi,
0072                                              edm::EventSetup const& iSetup) {
0073   edm::LogInfo("DQMScaleToClient") << "DQMScaleToClient::endLumi " << std::endl;
0074 }
0075 
0076 void DQMScaleToClient::fillMePSetDescription(edm::ParameterSetDescription& pset) {
0077   pset.add<std::string>("folder", "");
0078   pset.add<std::string>("name", "");
0079 }
0080 
0081 void DQMScaleToClient::fillOutputMePSetDescription(edm::ParameterSetDescription& pset) {
0082   pset.add<std::string>("folder", "");
0083   pset.add<std::string>("name", "");
0084   pset.add<double>("factor", 1.);
0085 }
0086 
0087 void DQMScaleToClient::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0088   edm::ParameterSetDescription desc;
0089   edm::ParameterSetDescription outputmePSet;
0090   fillOutputMePSetDescription(outputmePSet);
0091   desc.add<edm::ParameterSetDescription>("outputme", outputmePSet);
0092 
0093   edm::ParameterSetDescription inputmePSet;
0094   fillMePSetDescription(inputmePSet);
0095   desc.add<edm::ParameterSetDescription>("inputme", inputmePSet);
0096 
0097   descriptions.add("dqmScaleToClient", desc);
0098 }
0099 
0100 // Define this as a plug-in
0101 #include "FWCore/Framework/interface/MakerMacros.h"
0102 DEFINE_FWK_MODULE(DQMScaleToClient);