diff --git a/DbTables/inc/CalBaselines.hh b/DbTables/inc/CalBaselines.hh new file mode 100644 index 0000000000..5170878e41 --- /dev/null +++ b/DbTables/inc/CalBaselines.hh @@ -0,0 +1,73 @@ +#ifndef DbTables_CalBaselines_hh +#define DbTables_CalBaselines_hh + +#include +#include +#include +#include +#include "cetlib_except/exception.h" +#include "Offline/DbTables/inc/DbTable.hh" +#include "Offline/DataProducts/inc/CaloSiPMId.hh" + +namespace mu2e { + + class CalBaselines : public DbTable { + public: + typedef std::shared_ptr ptr_t; + typedef std::shared_ptr cptr_t; + + class Row { + public: + Row(CaloSiPMId roid, float baseline, float threshold):_roid(roid),_baseline(baseline),_threshold(threshold) {} + CaloSiPMId roid() const { return _roid;} + float baseline() const { return _baseline; } + float threshold() const { return _threshold; } + + private: + CaloSiPMId _roid; + float _baseline; + float _threshold; + }; + + constexpr static const char* cxname = "CalBaselines"; + + CalBaselines():DbTable(cxname,"cal.baselines","roid,baseline,threshold"){} + + const Row& row(CaloSiPMId id) const { + return _rows.at(id.id()); + } + std::vector const& rows() const {return _rows;} + std::size_t nrow() const override { return _rows.size(); }; + size_t size() const override { return baseSize() + nrow()*sizeof(Row); }; + virtual std::size_t nrowFix() const override { return CaloConst::_nChannelDB; }; + const std::string orderBy() const { return std::string("roid"); } + + void addRow(const std::vector& columns) override { + std::uint16_t index = std::stoul(columns[0]); + // enforce order, so channels can be looked up by index + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { + throw cet::exception("CALOBASELINES_BAD_INDEX")<<"CalBaselines::addRow found index out of order:"< _rows; + + }; + +} +#endif diff --git a/DbTables/inc/CalChannelStatus.hh b/DbTables/inc/CalChannelStatus.hh index 1f8d7248db..27913cc7e5 100644 --- a/DbTables/inc/CalChannelStatus.hh +++ b/DbTables/inc/CalChannelStatus.hh @@ -32,7 +32,7 @@ namespace mu2e { CalChannelStatus():DbTable(cxname,"cal.channelstatus","roid,status"){} const Row& row(CaloSiPMId id) const { - return _rows[id.id()]; + return _rows.at(id.id()); } std::vector const& rows() const {return _rows;} std::size_t nrow() const override { return _rows.size(); }; @@ -43,7 +43,7 @@ namespace mu2e { void addRow(const std::vector& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index!=int(_rows.size())) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALOCHANNELSTATUS_BAD_INDEX")<<"CalChannelStatus::addRow found index out of order:"<& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index >= CaloConst::_nRawChannel || index != _rows.size()) { + if (index >= CaloConst::_nRawChannel || index != _rows.size()) { throw cet::exception("CALOCHANNELS_BAD_INDEX") << "CalChannels::addRow found index out of order: " <& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index >= CaloConst::_nChannelDB || index != _rows.size()) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALOCOSMICCALIB_BAD_INDEX") << "CalCosmicEnergyCalib::addRow found index out of order: " <& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index >= CaloConst::_nChannelDB || index != _rows.size()) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALCOSMICT0ALIGN_BAD_INDEX") << "CalCosmicT0Align::addRow found index out of order: " < +#include +#include +#include +#include "Offline/DbTables/inc/DbTable.hh" +#include "Offline/DataProducts/inc/CaloSiPMId.hh" + +namespace mu2e { + + class CalCosmicTimeCalib : public DbTable { + public: + + class Row { + public: + Row(CaloSiPMId roid, float T0, float ErrT0, float chisq, int nev): + _roid(roid),_T0(T0),_ErrT0(ErrT0),_chisq(chisq),_nev(nev) {} + CaloSiPMId roid() const { return _roid;} // Offline ID + float T0() const { return _T0; } + float ErrT0() const { return _ErrT0; } + float chisq() const { return _chisq; } + int nev() const { return _nev; } + + private: + CaloSiPMId _roid; + float _T0; + float _ErrT0; + float _chisq; + int _nev; + }; + + constexpr static const char* cxname = "CalCosmicTimeCalib"; + + CalCosmicTimeCalib():DbTable(cxname,"cal.cosmictimecalib", + "roid,t0,errt0,chisq,nev") {} + + const Row& row(CaloSiPMId roid) const { + return _rows.at(roid.id()); } + std::vector const& rows() const {return _rows;} + std::size_t nrow() const override { return _rows.size(); }; + size_t size() const override { return baseSize() + nrow()*sizeof(Row); }; + virtual std::size_t nrowFix() const override { return CaloConst::_nChannelDB; }; + const std::string orderBy() const { return std::string("roid"); } + void addRow(const std::vector& columns) override { + std::uint16_t index = std::stoul(columns[0]); + // enforce order, so channels can be looked up by index + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { + throw cet::exception("CalCosmicTimeCalib_BAD_INDEX") + << "CalCosmicTimeTable::addRow found index out of order: " + < _rows; + }; + +} +#endif diff --git a/DbTables/inc/CalEnergyCalib.hh b/DbTables/inc/CalEnergyCalib.hh index 66e4173fb4..63c12f518a 100644 --- a/DbTables/inc/CalEnergyCalib.hh +++ b/DbTables/inc/CalEnergyCalib.hh @@ -39,7 +39,7 @@ namespace mu2e { CalEnergyCalib():DbTable(cxname,"cal.energycalib","roid,adc2mev"){} const Row& row(CaloSiPMId id) const { - return _rows[id.id()]; + return _rows.at(id.id()); } std::vector const& rows() const {return _rows;} std::size_t nrow() const override { return _rows.size(); }; @@ -50,7 +50,7 @@ namespace mu2e { void addRow(const std::vector& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index!=int(_rows.size())) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALOENERGYCALIB_BAD_INDEX")<<"CalEnergyCalib::addRow found index out of order:"<& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index >= CaloConst::_nChannelDB || index != _rows.size()) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALOLaserEnergyCALIB_BAD_INDEX") << "CalLaserEnergyCalib::addRow found index out of order: " <& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index >= CaloConst::_nChannelDB || index != _rows.size()) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CalLaserTimeCalib_BAD_INDEX") << "CalLaserTimeTable::addRow found index out of order: " <& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index >= CaloConst::_nChannelDB || index != _rows.size()) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALOSOURCECALIB_BAD_INDEX") << "CalSourceEnergyCalib::addRow found index out of order: " < const& rows() const {return _rows;} std::size_t nrow() const override { return _rows.size(); }; @@ -50,7 +50,7 @@ namespace mu2e { void addRow(const std::vector& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index!=int(_rows.size())) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALOTIMECALIB_BAD_INDEX")<<"CalTimeCalib::addRow found index out of order:"<(new mu2e::CRVSiPM()); } else if (name == "CRVTime") { return std::shared_ptr(new mu2e::CRVTime()); + } else if (name=="CalBaselines") { + return std::shared_ptr(new mu2e::CalBaselines()); } else if (name=="CalChannels") { return std::shared_ptr(new mu2e::CalChannels()); } else if (name=="CalChannelStatus") { @@ -108,6 +112,8 @@ mu2e::DbTable::ptr_t mu2e::DbTableFactory::newTable(std::string const& name) { return std::shared_ptr(new mu2e::CalCosmicEnergyCalib()); } else if (name=="CalCosmicEnergyCalibInfo") { return std::shared_ptr(new mu2e::CalCosmicEnergyCalibInfo()); + } else if (name=="CalCosmicTimeCalib") { + return std::shared_ptr(new mu2e::CalCosmicTimeCalib()); } else if (name=="CalLaserEnergyCalib") { return std::shared_ptr(new mu2e::CalLaserEnergyCalib()); } else if (name=="CalLaserTimeCalib") {