Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /*
0002  * =====================================================================================
0003  *
0004  *       Filename:  EventProcessor.cc
0005  *
0006  *    Description:  EventProcessor Object General methods
0007  *
0008  *        Version:  1.0
0009  *        Created:  10/03/2008 10:47:11 AM
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 "CSCDQM_EventProcessor.h"
0020 
0021 namespace cscdqm {
0022 
0023   /**
0024    * @brief  Constructor.
0025    * @param  p_config Pointer to Global Configuration.
0026    */
0027   EventProcessor::EventProcessor(Configuration* const p_config) {
0028     config = p_config;
0029     // fFirstEvent = true;
0030     fCloseL1As = true;
0031   }
0032 
0033 #ifdef DQMGLOBAL
0034 
0035   /**
0036    * @brief  Constructor.
0037    * @param  p_config Pointer to Global Configuration.
0038    * @param  itag InputTag for input raw data.
0039    * @param  coco ref to ConsumesCollector received from caller (Dispatcher).
0040    */
0041   EventProcessor::EventProcessor(Configuration* const p_config,
0042                                  const edm::InputTag& itag,
0043                                  edm::ConsumesCollector& coco) {
0044     config = p_config;
0045 
0046     // set token for data access
0047     frdtoken = coco.consumes<FEDRawDataCollection>(itag);
0048 
0049     // fFirstEvent = true;
0050     fCloseL1As = true;
0051   }
0052 
0053 #endif
0054 
0055   /**
0056    * @brief  Initialize EventProcessor: reading out config information.
0057    */
0058   void EventProcessor::init() {}
0059 
0060   /**
0061    * @brief  Get EMU (Top Level) Monitoring Object
0062    * @param  histo MO identification
0063    * @param  me MO to return
0064    * @return true if MO was found, false - otherwise
0065    */
0066   const bool EventProcessor::getEMUHisto(const HistoId& histo, MonitorObject*& me) {
0067     if (config->fnGetCacheEMUHisto(histo, me))
0068       return (me != nullptr);
0069     EMUHistoDef histoD(histo);
0070     if (config->fnGetHisto(histoD, me))
0071       return (me != nullptr);
0072     return false;
0073   }
0074 
0075   /** 
0076    * @brief  Get FED Level Monitoring Object
0077    * @param  histo MO identification
0078    * @param  fedID FED identifier
0079    * @param  me MO to return
0080    * @return true if MO was found, false - otherwise
0081    */
0082   const bool EventProcessor::getFEDHisto(const HistoId& histo, const HwId& fedID, MonitorObject*& me) {
0083     if (config->fnGetCacheFEDHisto(histo, fedID, me))
0084       return (me != nullptr);
0085     FEDHistoDef histoD(histo, fedID);
0086     if (config->fnGetHisto(histoD, me))
0087       return (me != nullptr);
0088     return false;
0089   }
0090 
0091   /**
0092    * @brief  Get DDU Level Monitoring Object
0093    * @param  histo MO identification
0094    * @param  dduID DDU identifier
0095    * @param  me MO to return
0096    * @return true if MO was found, false - otherwise
0097    */
0098   const bool EventProcessor::getDDUHisto(const HistoId& histo, const HwId& dduID, MonitorObject*& me) {
0099     if (config->fnGetCacheDDUHisto(histo, dduID, me))
0100       return (me != nullptr);
0101     DDUHistoDef histoD(histo, dduID);
0102     if (config->fnGetHisto(histoD, me))
0103       return (me != nullptr);
0104     return false;
0105   }
0106 
0107   /**
0108    * @brief  Get CSC (Chamber) Level Monitoring Object
0109    * @param  histo MO identification
0110    * @param  crateID Chamber Crate identifier
0111    * @param  dmbSlot Chamber DMB identifier
0112    * @param  me MO to return
0113    * @return true if MO was found, false - otherwise
0114    */
0115   const bool EventProcessor::getCSCHisto(const HistoId& histo,
0116                                          const HwId& crateID,
0117                                          const HwId& dmbSlot,
0118                                          MonitorObject*& me) {
0119     if (config->fnGetCacheCSCHisto(histo, crateID, dmbSlot, 0, me))
0120       return (me != nullptr);
0121     CSCHistoDef histoD(histo, crateID, dmbSlot);
0122     if (config->fnGetHisto(histoD, me))
0123       return (me != nullptr);
0124     return false;
0125   }
0126 
0127   /**
0128    * @brief  Get CSC (Chamber) Level Monitoring Object with additional
0129    * identifier
0130    * @param  histo MO identification
0131    * @param  crateID Chamber Crate identifier
0132    * @param  dmbSlot Chamber DMB identifier
0133    * @param  adId Additional identifier, i.e. Layer number, CLCT number, etc.
0134    * @param  me MO to return
0135    * @return true if MO was found, false - otherwise
0136    */
0137   const bool EventProcessor::getCSCHisto(
0138       const HistoId& histo, const HwId& crateID, const HwId& dmbSlot, const HwId& adId, MonitorObject*& me) {
0139     if (config->fnGetCacheCSCHisto(histo, crateID, dmbSlot, adId, me))
0140       return (me != nullptr);
0141     CSCHistoDef histoD(histo, crateID, dmbSlot, adId);
0142     if (config->fnGetHisto(histoD, me))
0143       return (me != nullptr);
0144     return false;
0145   }
0146 
0147   /**
0148    * @brief  Get Parameter Monitoring Object
0149    * @param  histo MO identification
0150    * @param  me MO to return
0151    * @return true if MO was found, false - otherwise
0152    */
0153   const bool EventProcessor::getParHisto(const HistoId& histo, MonitorObject*& me) {
0154     if (config->fnGetCacheParHisto(histo, me))
0155       return (me != nullptr);
0156     ParHistoDef histoD(histo);
0157     if (config->fnGetHisto(histoD, me))
0158       return (me != nullptr);
0159     return false;
0160   }
0161 
0162   /**
0163    * @brief  Get CSC type and position from crate and dmb identifiers
0164    * @param  crateId CSC crate identifier
0165    * @param  dmbId CSC DMB identifier
0166    * @param  cscType CSC Type identifier to return
0167    * @param  cscPosition CSC Position identifier to return
0168    * @return true if parameters where found and filled, false - otherwise
0169    */
0170   const bool EventProcessor::getCSCFromMap(const unsigned int& crateId,
0171                                            const unsigned int& dmbId,
0172                                            unsigned int& cscType,
0173                                            unsigned int& cscPosition) const {
0174     bool result = false;
0175 
0176     CSCDetId cid;
0177     if (config->fnGetCSCDetId(crateId, dmbId, cid)) {
0178       cscPosition = cid.chamber();
0179       int iring = cid.ring();
0180       int istation = cid.station();
0181       int iendcap = cid.endcap();
0182       std::string tlabel = cscdqm::Utility::getCSCTypeLabel(iendcap, istation, iring);
0183       cscType = cscdqm::Utility::getCSCTypeBin(tlabel);
0184       result = true;
0185     }
0186 
0187     /*
0188     if (!result) {
0189       LOG_ERROR << "Event #" << config->getNEvents() << ": Invalid CSC=" << CSCHistoDef::getPath(crateId, dmbId);
0190     }
0191     */
0192 
0193     return result;
0194   }
0195 
0196   /**
0197    * @brief  Mask HW elements from the efficiency calculations. Can be applied
0198    * on runtime!
0199    * @param  tokens String tokens of the HW elements
0200    * @return elements masked
0201    */
0202   unsigned int EventProcessor::maskHWElements(std::vector<std::string>& tokens) {
0203     unsigned int masked = summary.setMaskedHWElements(tokens);
0204     LOG_INFO << masked << " HW Elements masked";
0205     return masked;
0206   }
0207 
0208 }  // namespace cscdqm