Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:11:35

0001 #ifndef DQM_SiStripCommissioningSources_CommissioningTask_H
0002 #define DQM_SiStripCommissioningSources_CommissioningTask_H
0003 
0004 #include "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
0005 #include "DataFormats/Common/interface/DetSet.h"
0006 #include "DataFormats/Common/interface/DetSetNew.h"
0007 #include "DataFormats/SiStripCommon/interface/SiStripEventSummary.h"
0008 #include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h"
0009 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0010 #include "DQMServices/Core/interface/DQMStore.h"
0011 #include <vector>
0012 #include <string>
0013 #include <iomanip>
0014 #include <cstdint>
0015 
0016 class TAxis;
0017 namespace edm {
0018   class EventSetup;
0019 }
0020 
0021 /**
0022    @class CommissioningTask
0023 */
0024 class CommissioningTask {
0025 public:
0026   typedef dqm::legacy::DQMStore DQMStore;
0027   typedef dqm::legacy::MonitorElement MonitorElement;
0028   // ---------- Constructors, destructors ----------
0029 
0030   CommissioningTask(DQMStore*, const FedChannelConnection&, const std::string& my_name);
0031 
0032   virtual ~CommissioningTask();
0033 
0034   // ---------- Classes, structs ----------
0035 
0036   /** Simple container class holding pointer to root histogram, and
0037       vectors in which data are cached and used to update histo. */
0038   class HistoSet {
0039   public:
0040     HistoSet();
0041     void histo(MonitorElement*);
0042     MonitorElement* histo();
0043     uint32_t bin(float value);
0044     std::vector<float> vNumOfEntries_;
0045     std::vector<float> vSumOfContents_;
0046     std::vector<double> vSumOfSquares_;
0047     bool isProfile_;
0048     bool explicitFill_;
0049 
0050   private:
0051     MonitorElement* histo_;
0052     TAxis* axis_;
0053   };
0054 
0055   class CompactHistoSet {
0056   public:
0057     CompactHistoSet();
0058     void histo(MonitorElement*);
0059     MonitorElement* histo();
0060     std::vector<short> vNumOfEntries_;
0061     bool explicitFill_;
0062 
0063   private:
0064     MonitorElement* histo_;
0065   };
0066 
0067   // ---------- Public methods ----------
0068 
0069   /** Books histograms and constructs HistoSet cache. */
0070   void bookHistograms();
0071 
0072   /** Fills HistoSet cache. */
0073   void fillHistograms(const SiStripEventSummary&, const edm::DetSet<SiStripRawDigi>&);
0074 
0075   /** Fills HistoSet cache. */
0076   void fillHistograms(const SiStripEventSummary&,
0077                       const edm::DetSet<SiStripRawDigi>&,
0078                       const edm::DetSet<SiStripRawDigi>&);
0079 
0080   /** Fills HistoSet cache. */
0081   void fillHistograms(const SiStripEventSummary&,
0082                       const edm::DetSet<SiStripRawDigi>&,
0083                       const edm::DetSet<SiStripRawDigi>&,
0084                       const std::vector<uint16_t>&);
0085 
0086   /** Fill HistoSet cache for FED cabling (special case). */
0087   void fillHistograms(const SiStripEventSummary&, const uint16_t& fed_id, const std::map<uint16_t, float>& fed_ch);
0088 
0089   /** Updates histograms using HistoSet cache. */
0090   void updateHistograms();
0091 
0092   /** Get histogram filled counter. */
0093   inline const uint32_t& fillCntr() const;
0094 
0095   /** Get histogram update frequency. */
0096   inline const uint32_t& updateFreq() const;
0097 
0098   /** Set histogram update frequency. */
0099   inline void updateFreq(const uint32_t&);
0100 
0101   /** Returns the name of this commissioning task. */
0102   inline const std::string& myName() const;
0103 
0104   /** Define access to the EventSetup. */
0105   inline void eventSetup(const edm::EventSetup*);
0106 
0107 protected:
0108   // ---------- Protected methods ----------
0109 
0110   /** Updates the vectors of HistoSet. */
0111   void updateHistoSet(HistoSet&, const uint32_t& bin, const float& value);
0112   void updateHistoSet(CompactHistoSet&, const uint32_t& bin, const short& value);
0113 
0114   /** Updates the vectors of HistoSet. */
0115   void updateHistoSet(HistoSet&, const uint32_t& bin);
0116   void updateHistoSet(CompactHistoSet&, const uint32_t& bin);
0117 
0118   /** Updates the vectors of HistoSet. */
0119   void updateHistoSet(HistoSet&, const float& value);
0120   void updateHistoSet(CompactHistoSet&);
0121 
0122   /** Updates the MonitorElements of HistoSet. */
0123   void updateHistoSet(HistoSet&);
0124 
0125   /** Returns const pointer to DQM back-end interface object. */
0126   inline DQMStore* const dqm() const;
0127 
0128   /** */
0129   inline const FedChannelConnection& connection() const;
0130 
0131   /** Returns FEC key. */
0132   inline const uint32_t& fecKey() const;
0133 
0134   /** Returns FED key. */
0135   inline const uint32_t& fedKey() const;
0136 
0137   /** Access to the EventSetup. */
0138   inline const edm::EventSetup* const eventSetup() const;
0139 
0140 private:
0141   // ---------- Private methods ----------
0142 
0143   CommissioningTask() { ; }
0144 
0145   virtual void book();
0146 
0147   virtual void fill(const SiStripEventSummary&, const edm::DetSet<SiStripRawDigi>&);
0148 
0149   virtual void fill(const SiStripEventSummary&, const edm::DetSet<SiStripRawDigi>&, const edm::DetSet<SiStripRawDigi>&);
0150 
0151   virtual void fill(const SiStripEventSummary&,
0152                     const edm::DetSet<SiStripRawDigi>&,
0153                     const edm::DetSet<SiStripRawDigi>&,
0154                     const std::vector<uint16_t>&);
0155 
0156   virtual void fill(const SiStripEventSummary&, const uint16_t& fed_id, const std::map<uint16_t, float>& fed_ch);
0157 
0158   virtual void update();
0159 
0160   // ---------- Private member data ----------
0161 
0162   DQMStore* dqm_;
0163 
0164   uint32_t updateFreq_;
0165 
0166   uint32_t fillCntr_;
0167 
0168   FedChannelConnection connection_;
0169 
0170   uint32_t fedKey_;
0171 
0172   uint32_t fecKey_;
0173 
0174   bool booked_;
0175 
0176   std::string myName_;
0177 
0178   const edm::EventSetup* eventSetup_;
0179 };
0180 
0181 // ----- inline methods -----
0182 
0183 const uint32_t& CommissioningTask::fillCntr() const { return fillCntr_; }
0184 const uint32_t& CommissioningTask::updateFreq() const { return updateFreq_; }
0185 void CommissioningTask::updateFreq(const uint32_t& freq) { updateFreq_ = freq; }
0186 const std::string& CommissioningTask::myName() const { return myName_; }
0187 
0188 CommissioningTask::DQMStore* const CommissioningTask::dqm() const { return dqm_; }
0189 const FedChannelConnection& CommissioningTask::connection() const { return connection_; }
0190 
0191 const uint32_t& CommissioningTask::fecKey() const { return fecKey_; }
0192 const uint32_t& CommissioningTask::fedKey() const { return fedKey_; }
0193 
0194 void CommissioningTask::eventSetup(const edm::EventSetup* setup) { eventSetup_ = setup; }
0195 const edm::EventSetup* const CommissioningTask::eventSetup() const { return eventSetup_; }
0196 
0197 #endif  // DQM_SiStripCommissioningSources_CommissioningTask_H