Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:55

0001 #ifndef MONPULSESHAPEDAT_H
0002 #define MONPULSESHAPEDAT_H
0003 
0004 #include <vector>
0005 #include <map>
0006 #include <stdexcept>
0007 
0008 #include "OnlineDB/EcalCondDB/interface/IDataItem.h"
0009 #include "OnlineDB/EcalCondDB/interface/MonRunTag.h"
0010 #include "OnlineDB/EcalCondDB/interface/MonRunIOV.h"
0011 #include "OnlineDB/EcalCondDB/interface/EcalLogicID.h"
0012 
0013 class MonPulseShapeDat : public IDataItem {
0014 public:
0015   friend class EcalCondDBInterface;
0016   MonPulseShapeDat();
0017   ~MonPulseShapeDat() override;
0018 
0019   // User data methods
0020   inline std::string getTable() override { return "MON_PULSE_SHAPE_DAT"; }
0021 
0022   inline void setSamples(std::vector<float>& samples, int gain) noexcept(false) {
0023     if (samples.size() != 10) {
0024       throw(std::runtime_error("MonPulseShapeDat::setSamples:  There should be 10 samples."));
0025     }
0026 
0027     if (gain == 1) {
0028       m_samplesG1 = samples;
0029     } else if (gain == 6) {
0030       m_samplesG6 = samples;
0031     } else if (gain == 12) {
0032       m_samplesG12 = samples;
0033     } else {
0034       throw(std::runtime_error("MonPulseShapeDat::setSamples:  Gain should be 1, 6 or 12"));
0035     }
0036   }
0037 
0038   inline std::vector<float> getSamples(int gain) const noexcept(false) {
0039     if (gain == 1) {
0040       return m_samplesG1;
0041     } else if (gain == 6) {
0042       return m_samplesG6;
0043     } else if (gain == 12) {
0044       return m_samplesG12;
0045     } else {
0046       throw(std::runtime_error("MonPulseShapeDat::getSamples:  Gain should be 1, 6 or 12"));
0047     }
0048   }
0049 
0050 private:
0051   void prepareWrite() noexcept(false) override;
0052 
0053   void writeDB(const EcalLogicID* ecid, const MonPulseShapeDat* item, MonRunIOV* iov) noexcept(false);
0054 
0055   void fetchData(std::map<EcalLogicID, MonPulseShapeDat>* fillVec, MonRunIOV* iov) noexcept(false);
0056 
0057   // User data
0058   std::vector<float> m_samplesG1;
0059   std::vector<float> m_samplesG6;
0060   std::vector<float> m_samplesG12;
0061 };
0062 
0063 #endif