Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:06:58

0001 /*
0002  * =====================================================================================
0003  *
0004  *       Filename:  CSCMonitorModule.cc
0005  *
0006  *    Description:  CSC Monitor Module
0007  *
0008  *        Version:  1.0
0009  *        Created:  11/13/2008 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 "CSCMonitorModule.h"
0020 
0021 /**
0022  * @brief  Constructor.
0023  * @param  ps Parameters.
0024  */
0025 CSCMonitorModule::CSCMonitorModule(const edm::ParameterSet& ps)
0026     : hcrateToken_(esConsumes<CSCCrateMap, CSCCrateMapRcd>()) {
0027   edm::FileInPath fp;
0028 
0029   inputTag = ps.getUntrackedParameter<edm::InputTag>("InputObjects", (edm::InputTag)INPUT_TAG_LABEL);
0030   prebookEffParams = ps.getUntrackedParameter<bool>("PREBOOK_EFF_PARAMS", false);
0031   processDcsScalers = ps.getUntrackedParameter<bool>("PROCESS_DCS_SCALERS", true);
0032   edm::ParameterSet params = ps.getUntrackedParameter<edm::ParameterSet>("EventProcessor");
0033   config.load(params);
0034 
0035   fp = ps.getParameter<edm::FileInPath>("BOOKING_XML_FILE");
0036   config.setBOOKING_XML_FILE(fp.fullPath());
0037 
0038   // dbe = edm::Service<DQMStore>().operator->();
0039 
0040 #ifdef DQMLOCAL
0041   dispatcher = new cscdqm::Dispatcher(&config, const_cast<CSCMonitorModule*>(this));
0042 #endif
0043 #ifdef DQMGLOBAL
0044   //  edm::ConsumesCollector coco( consumesCollector() );
0045   dispatcher = new cscdqm::Dispatcher(&config, const_cast<CSCMonitorModule*>(this), inputTag, consumesCollector());
0046   dcstoken = consumes<DcsStatusCollection>(edm::InputTag("scalersRawToDigi"));
0047 
0048 #endif
0049 
0050   dispatcher->init();
0051 
0052   if (ps.exists("MASKEDHW")) {
0053     maskedHW = ps.getUntrackedParameter<std::vector<std::string> >("MASKEDHW");
0054     //dispatcher->maskHWElements(maskedHW);
0055   }
0056 }
0057 
0058 /**
0059  * @brief  Destructor.
0060  */
0061 CSCMonitorModule::~CSCMonitorModule() {
0062   if (dispatcher)
0063     delete dispatcher;
0064 }
0065 
0066 /**
0067  * @brief  Begin the run.
0068  * @param  r Run object
0069  * @param  c Event setup
0070  */
0071 
0072 /*
0073 void CSCMonitorModule::beginRun(const edm::Run& r, const edm::EventSetup& c) {
0074 
0075   if (prebookEffParams) {
0076     dispatcher->updateFractionAndEfficiencyHistos();
0077   }
0078 
0079 }
0080 */
0081 
0082 /**
0083  * @brief  Analyze Event.
0084  * @param  e Event to analyze
0085  * @param  c Event Setup
0086  */
0087 void CSCMonitorModule::analyze(const edm::Event& e, const edm::EventSetup& c) {
0088   // Get crate mapping from database
0089   edm::ESHandle<CSCCrateMap> hcrate;
0090   /// Use esConsumes to get crate mapping
0091   hcrate = c.getHandle(hcrateToken_);
0092   pcrate = hcrate.product();
0093 
0094   cscdqm::HWStandbyType standby;
0095 
0096   // Get DCS status scalers
0097   if (processDcsScalers) {
0098     edm::Handle<DcsStatusCollection> dcsStatus;
0099 #ifdef DQMLOCAL
0100     if (e.getByToken(dcstoken, dcsStatus)) {
0101 #endif
0102 #ifdef DQMGLOBAL
0103       if (e.getByToken(dcstoken, dcsStatus)) {
0104 #endif
0105         DcsStatusCollection::const_iterator dcsStatusItr = dcsStatus->begin();
0106         for (; dcsStatusItr != dcsStatus->end(); ++dcsStatusItr) {
0107           standby.applyMeP(dcsStatusItr->ready(DcsStatus::CSCp));
0108           standby.applyMeM(dcsStatusItr->ready(DcsStatus::CSCm));
0109         }
0110       }
0111       standby.process = true;
0112     }
0113 
0114     dispatcher->processEvent(e, inputTag, standby);
0115   }
0116 
0117   /**
0118  * @brief  Book Histograms in the beginRun.
0119  * @param  ib - DQMStore::IBooker interface access object
0120  * @param  edm::Run const & - not used
0121  * @param  edm::EventSetup const & - not used
0122  */
0123   void CSCMonitorModule::bookHistograms(DQMStore::IBooker & ib, edm::Run const&, edm::EventSetup const&) {
0124     /** Store pointer to IBooker to use it in ::bookMonitorObject() callback function used by the Dispatcher::book() method **/
0125     ibooker = &ib;
0126 
0127     /** 
0128     * Call Dispatcher histogram booking method to pre-boook all available histograms before processing data. 
0129     * New PREBOOK_ALL_HISTOS config option should be set to true (default).
0130     * That should disable original CSC on-the-fly histo booking during data processing. 
0131     * Changed for multi-threaded framework compatibility.
0132     * (pre-booking of all histos is not most efficient way for CSCi DQM). 
0133     *   
0134     **/
0135     dispatcher->book();
0136 
0137     if (!maskedHW.empty())
0138       dispatcher->maskHWElements(maskedHW);
0139     if (prebookEffParams) {
0140       dispatcher->updateFractionAndEfficiencyHistos();
0141     }
0142   }
0143 
0144   /**
0145  * @brief  Book Monitor Object on Request.
0146  * @param  req Request.
0147  * @return MonitorObject created.
0148  */
0149   cscdqm::MonitorObject* CSCMonitorModule::bookMonitorObject(const cscdqm::HistoBookRequest& req) {
0150     cscdqm::MonitorObject* me = nullptr;
0151     std::string name = req.hdef->getName();
0152 
0153     std::string path = req.folder;
0154     if (!req.hdef->getPath().empty()) {
0155       path = path + req.hdef->getPath() + "/";
0156     }
0157 
0158     //std::cout << "Moving to " << path << " for name = " << name << " with fullPath = " << req.hdef->getFullPath() << "\n";
0159 
0160     //dbe->setCurrentFolder(path);
0161     ibooker->cd();
0162     ibooker->setCurrentFolder(path);
0163 
0164     if (req.htype == cscdqm::INT) {
0165       me = new CSCMonitorObject(ibooker->bookInt(name));
0166       me->Fill(req.default_int);
0167     } else if (req.htype == cscdqm::FLOAT) {
0168       if (req.hdef->getId() == cscdqm::h::PAR_REPORT_SUMMARY || req.hdef->getId() == cscdqm::h::PAR_CRT_SUMMARY ||
0169           req.hdef->getId() == cscdqm::h::PAR_DAQ_SUMMARY || req.hdef->getId() == cscdqm::h::PAR_DCS_SUMMARY) {
0170         ibooker->cd();
0171         ibooker->setCurrentFolder(DIR_EVENTINFO);
0172       } else if (cscdqm::Utility::regexMatch("^PAR_DCS_", cscdqm::h::keys[req.hdef->getId()])) {
0173         ibooker->cd();
0174         ibooker->setCurrentFolder(DIR_DCSINFO);
0175       } else if (cscdqm::Utility::regexMatch("^PAR_DAQ_", cscdqm::h::keys[req.hdef->getId()])) {
0176         ibooker->cd();
0177         ibooker->setCurrentFolder(DIR_DAQINFO);
0178       } else if (cscdqm::Utility::regexMatch("^PAR_CRT_", cscdqm::h::keys[req.hdef->getId()])) {
0179         ibooker->cd();
0180         ibooker->setCurrentFolder(DIR_CRTINFO);
0181       }
0182       me = new CSCMonitorObject(ibooker->bookFloat(name));
0183       me->Fill(req.default_float);
0184     } else if (req.htype == cscdqm::STRING) {
0185       me = new CSCMonitorObject(ibooker->bookString(name, req.default_string));
0186     } else if (req.htype == cscdqm::H1D) {
0187       me = new CSCMonitorObject(ibooker->book1D(name, req.title, req.nchX, req.lowX, req.highX));
0188     } else if (req.htype == cscdqm::H2D) {
0189       if (req.hdef->getId() == cscdqm::h::EMU_CSC_STATS_SUMMARY) {
0190         ibooker->cd();
0191         ibooker->setCurrentFolder(DIR_EVENTINFO);
0192         name = "reportSummaryMap";
0193       }
0194       me = new CSCMonitorObject(
0195           ibooker->book2D(name, req.title, req.nchX, req.lowX, req.highX, req.nchY, req.lowY, req.highY));
0196     } else if (req.htype == cscdqm::H3D) {
0197       me = new CSCMonitorObject(ibooker->book3D(
0198           name, req.title, req.nchX, req.lowX, req.highX, req.nchY, req.lowY, req.highY, req.nchZ, req.lowZ, req.highZ));
0199     } else if (req.htype == cscdqm::PROFILE) {
0200       me = new CSCMonitorObject(ibooker->bookProfile(
0201           name, req.title, req.nchX, req.lowX, req.highX, req.nchY, req.lowY, req.highY, req.option.c_str()));
0202     } else if (req.htype == cscdqm::PROFILE2D) {
0203       me = new CSCMonitorObject(ibooker->bookProfile2D(name,
0204                                                        req.title,
0205                                                        req.nchX,
0206                                                        req.lowX,
0207                                                        req.highX,
0208                                                        req.nchY,
0209                                                        req.lowY,
0210                                                        req.highY,
0211                                                        req.nchZ,
0212                                                        req.lowZ,
0213                                                        req.highZ,
0214                                                        req.option.c_str()));
0215     }
0216 
0217     return me;
0218   }