Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
/*
 * =====================================================================================
 *
 *       Filename:  CSCOfflineClient.cc
 *
 *    Description:  CSC Offline Client
 *
 *        Version:  1.0
 *        Created:  08/20/2009 02:31:12 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Valdas Rapsevicius (VR), valdas.rapsevicius@cern.ch
 *        Company:  CERN, CH
 *
 * =====================================================================================
 */

#include "CSCOfflineClient.h"

/**
 * @brief  Constructor.
 * @param  ps Parameters.
 */
CSCOfflineClient::CSCOfflineClient(const edm::ParameterSet& ps) {
  edm::ParameterSet params = ps.getUntrackedParameter<edm::ParameterSet>("EventProcessor");
  config.load(params);

  dispatcher = new cscdqm::Dispatcher(&config, const_cast<CSCOfflineClient*>(this));
  dispatcher->init();

  if (ps.exists("MASKEDHW")) {
    maskedHW = ps.getUntrackedParameter<std::vector<std::string> >("MASKEDHW");
    // dispatcher->maskHWElements(maskedHW);
  }
}

/**
 * @brief  Destructor.
 */
CSCOfflineClient::~CSCOfflineClient() {
  if (dispatcher)
    delete dispatcher;
}

/*** No longer triggered for DQMEDHarvester ***/
/*
void CSCOfflineClient::endRun(const edm::Run& r, const edm::EventSetup& c) {

  // *
  // *  Putting histograms to internal cache: EMU stuff
  // * /
  dbe->setCurrentFolder(config.getFOLDER_EMU());
  std::vector<std::string> me_names = dbe->getMEs();
  for (std::vector<std::string>::iterator iter = me_names.begin(); iter != me_names.end(); iter++) {
    std::string me_name = *iter;
    MonitorElement* me = dbe->get(config.getFOLDER_EMU() + me_name);
    cscdqm::HistoId id;
    if (me && cscdqm::HistoDef::getHistoIdByName(me_name, id)) {
      const cscdqm::EMUHistoDef def(id);
      cscdqm::MonitorObject* mo = new CSCMonitorObject(me);
      config.fnPutHisto(def, mo);
    }
  }

  // *
  // *  Putting histograms to internal cache: EventInfo
  // * /

  {
    std::string name = DIR_EVENTINFO;
    name += "reportSummaryMap";
    MonitorElement* me = dbe->get(name);
    if (me) {
      const cscdqm::EMUHistoDef def(cscdqm::h::EMU_CSC_STATS_SUMMARY);
      cscdqm::MonitorObject* mo = new CSCMonitorObject(me);
      config.fnPutHisto(def, mo);
    }
  }

  config.incNEvents();
  dispatcher->updateFractionAndEfficiencyHistos();

}
*/

// void CSCOfflineClient::bookHistograms(DQMStore::IBooker & ib, edm::Run const &, edm::EventSetup const &)
void CSCOfflineClient::dqmEndJob(DQMStore::IBooker& ib, DQMStore::IGetter& igetter) {
  ibooker = &ib;
  dispatcher->book();
  if (!maskedHW.empty())
    dispatcher->maskHWElements(maskedHW);

  /*
   *  Putting histograms to internal cache: EMU stuff
   */
  ibooker->setCurrentFolder(config.getFOLDER_EMU());
  std::vector<std::string> me_names = igetter.getMEs();
  for (std::vector<std::string>::iterator iter = me_names.begin(); iter != me_names.end(); iter++) {
    std::string me_name = *iter;
    MonitorElement* me = igetter.get(config.getFOLDER_EMU() + me_name);
    cscdqm::HistoId id;
    if (me && cscdqm::HistoDef::getHistoIdByName(me_name, id)) {
      const cscdqm::EMUHistoDef def(id);
      cscdqm::MonitorObject* mo = new CSCMonitorObject(me);
      config.fnPutHisto(def, mo);
    }
  }

  /*
   *  Putting histograms to internal cache: EventInfo
   */

  {
    std::string name = DIR_EVENTINFO;
    name += "reportSummaryMap";
    MonitorElement* me = igetter.get(name);
    if (me) {
      const cscdqm::EMUHistoDef def(cscdqm::h::EMU_CSC_STATS_SUMMARY);
      cscdqm::MonitorObject* mo = new CSCMonitorObject(me);
      config.fnPutHisto(def, mo);
    }
  }

  config.incNEvents();
  dispatcher->updateFractionAndEfficiencyHistos();
}

/**
 * @brief  Book Monitor Object on Request.
 * @param  req Request.
 * @return MonitorObject created.
 */
cscdqm::MonitorObject* CSCOfflineClient::bookMonitorObject(const cscdqm::HistoBookRequest& req) {
  cscdqm::MonitorObject* me = nullptr;
  std::string name = req.hdef->getName();

  std::string path = req.folder;
  if (!req.hdef->getPath().empty()) {
    path = path + req.hdef->getPath() + "/";
  }

  ibooker->cd();
  ibooker->setCurrentFolder(path);

  if (req.htype == cscdqm::INT) {
    me = new CSCMonitorObject(ibooker->bookInt(name));
    me->Fill(req.default_int);
  } else if (req.htype == cscdqm::FLOAT) {
    if (req.hdef->getId() == cscdqm::h::PAR_REPORT_SUMMARY) {
      ibooker->cd();
      ibooker->setCurrentFolder(DIR_EVENTINFO);
    } else if (cscdqm::Utility::regexMatch("^PAR_DCS_", cscdqm::h::keys[req.hdef->getId()])) {
      ibooker->cd();
      ibooker->setCurrentFolder(DIR_DCSINFO);
    } else if (cscdqm::Utility::regexMatch("^PAR_DAQ_", cscdqm::h::keys[req.hdef->getId()])) {
      ibooker->cd();
      ibooker->setCurrentFolder(DIR_DAQINFO);
    } else if (cscdqm::Utility::regexMatch("^PAR_CRT_", cscdqm::h::keys[req.hdef->getId()])) {
      ibooker->cd();
      ibooker->setCurrentFolder(DIR_CRTINFO);
    }
    me = new CSCMonitorObject(ibooker->bookFloat(name));
    me->Fill(req.default_float);
  } else if (req.htype == cscdqm::STRING) {
    me = new CSCMonitorObject(ibooker->bookString(name, req.default_string));
  }

  return me;
}