Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:09:31

0001 /*
0002  * =====================================================================================
0003  *
0004  *       Filename:  CSCOfflineClient.cc
0005  *
0006  *    Description:  CSC Offline Client
0007  *
0008  *        Version:  1.0
0009  *        Created:  08/20/2009 02:31:12 PM
0010  *       Revision:  none
0011  *       Compiler:  gcc
0012  *
0013  *         Author:  Valdas Rapsevicius (VR), valdas.rapsevicius@cern.ch
0014  *        Company:  CERN, CH
0015  *
0016  * =====================================================================================
0017  */
0018 
0019 #include "CSCOfflineClient.h"
0020 
0021 /**
0022  * @brief  Constructor.
0023  * @param  ps Parameters.
0024  */
0025 CSCOfflineClient::CSCOfflineClient(const edm::ParameterSet& ps) {
0026   edm::ParameterSet params = ps.getUntrackedParameter<edm::ParameterSet>("EventProcessor");
0027   config.load(params);
0028 
0029   dispatcher = new cscdqm::Dispatcher(&config, const_cast<CSCOfflineClient*>(this));
0030   dispatcher->init();
0031 
0032   if (ps.exists("MASKEDHW")) {
0033     maskedHW = ps.getUntrackedParameter<std::vector<std::string> >("MASKEDHW");
0034     // dispatcher->maskHWElements(maskedHW);
0035   }
0036 }
0037 
0038 /**
0039  * @brief  Destructor.
0040  */
0041 CSCOfflineClient::~CSCOfflineClient() {
0042   if (dispatcher)
0043     delete dispatcher;
0044 }
0045 
0046 /*** No longer triggered for DQMEDHarvester ***/
0047 /*
0048 void CSCOfflineClient::endRun(const edm::Run& r, const edm::EventSetup& c) {
0049 
0050   // *
0051   // *  Putting histograms to internal cache: EMU stuff
0052   // * /
0053   dbe->setCurrentFolder(config.getFOLDER_EMU());
0054   std::vector<std::string> me_names = dbe->getMEs();
0055   for (std::vector<std::string>::iterator iter = me_names.begin(); iter != me_names.end(); iter++) {
0056     std::string me_name = *iter;
0057     MonitorElement* me = dbe->get(config.getFOLDER_EMU() + me_name);
0058     cscdqm::HistoId id;
0059     if (me && cscdqm::HistoDef::getHistoIdByName(me_name, id)) {
0060       const cscdqm::EMUHistoDef def(id);
0061       cscdqm::MonitorObject* mo = new CSCMonitorObject(me);
0062       config.fnPutHisto(def, mo);
0063     }
0064   }
0065 
0066   // *
0067   // *  Putting histograms to internal cache: EventInfo
0068   // * /
0069 
0070   {
0071     std::string name = DIR_EVENTINFO;
0072     name += "reportSummaryMap";
0073     MonitorElement* me = dbe->get(name);
0074     if (me) {
0075       const cscdqm::EMUHistoDef def(cscdqm::h::EMU_CSC_STATS_SUMMARY);
0076       cscdqm::MonitorObject* mo = new CSCMonitorObject(me);
0077       config.fnPutHisto(def, mo);
0078     }
0079   }
0080 
0081   config.incNEvents();
0082   dispatcher->updateFractionAndEfficiencyHistos();
0083 
0084 }
0085 */
0086 
0087 // void CSCOfflineClient::bookHistograms(DQMStore::IBooker & ib, edm::Run const &, edm::EventSetup const &)
0088 void CSCOfflineClient::dqmEndJob(DQMStore::IBooker& ib, DQMStore::IGetter& igetter) {
0089   ibooker = &ib;
0090   dispatcher->book();
0091   if (!maskedHW.empty())
0092     dispatcher->maskHWElements(maskedHW);
0093 
0094   /*
0095    *  Putting histograms to internal cache: EMU stuff
0096    */
0097   ibooker->setCurrentFolder(config.getFOLDER_EMU());
0098   std::vector<std::string> me_names = igetter.getMEs();
0099   for (std::vector<std::string>::iterator iter = me_names.begin(); iter != me_names.end(); iter++) {
0100     std::string me_name = *iter;
0101     MonitorElement* me = igetter.get(config.getFOLDER_EMU() + me_name);
0102     cscdqm::HistoId id;
0103     if (me && cscdqm::HistoDef::getHistoIdByName(me_name, id)) {
0104       const cscdqm::EMUHistoDef def(id);
0105       cscdqm::MonitorObject* mo = new CSCMonitorObject(me);
0106       config.fnPutHisto(def, mo);
0107     }
0108   }
0109 
0110   /*
0111    *  Putting histograms to internal cache: EventInfo
0112    */
0113 
0114   {
0115     std::string name = DIR_EVENTINFO;
0116     name += "reportSummaryMap";
0117     MonitorElement* me = igetter.get(name);
0118     if (me) {
0119       const cscdqm::EMUHistoDef def(cscdqm::h::EMU_CSC_STATS_SUMMARY);
0120       cscdqm::MonitorObject* mo = new CSCMonitorObject(me);
0121       config.fnPutHisto(def, mo);
0122     }
0123   }
0124 
0125   config.incNEvents();
0126   dispatcher->updateFractionAndEfficiencyHistos();
0127 }
0128 
0129 /**
0130  * @brief  Book Monitor Object on Request.
0131  * @param  req Request.
0132  * @return MonitorObject created.
0133  */
0134 cscdqm::MonitorObject* CSCOfflineClient::bookMonitorObject(const cscdqm::HistoBookRequest& req) {
0135   cscdqm::MonitorObject* me = nullptr;
0136   std::string name = req.hdef->getName();
0137 
0138   std::string path = req.folder;
0139   if (!req.hdef->getPath().empty()) {
0140     path = path + req.hdef->getPath() + "/";
0141   }
0142 
0143   ibooker->cd();
0144   ibooker->setCurrentFolder(path);
0145 
0146   if (req.htype == cscdqm::INT) {
0147     me = new CSCMonitorObject(ibooker->bookInt(name));
0148     me->Fill(req.default_int);
0149   } else if (req.htype == cscdqm::FLOAT) {
0150     if (req.hdef->getId() == cscdqm::h::PAR_REPORT_SUMMARY) {
0151       ibooker->cd();
0152       ibooker->setCurrentFolder(DIR_EVENTINFO);
0153     } else if (cscdqm::Utility::regexMatch("^PAR_DCS_", cscdqm::h::keys[req.hdef->getId()])) {
0154       ibooker->cd();
0155       ibooker->setCurrentFolder(DIR_DCSINFO);
0156     } else if (cscdqm::Utility::regexMatch("^PAR_DAQ_", cscdqm::h::keys[req.hdef->getId()])) {
0157       ibooker->cd();
0158       ibooker->setCurrentFolder(DIR_DAQINFO);
0159     } else if (cscdqm::Utility::regexMatch("^PAR_CRT_", cscdqm::h::keys[req.hdef->getId()])) {
0160       ibooker->cd();
0161       ibooker->setCurrentFolder(DIR_CRTINFO);
0162     }
0163     me = new CSCMonitorObject(ibooker->bookFloat(name));
0164     me->Fill(req.default_float);
0165   } else if (req.htype == cscdqm::STRING) {
0166     me = new CSCMonitorObject(ibooker->bookString(name, req.default_string));
0167   }
0168 
0169   return me;
0170 }