-
Notifications
You must be signed in to change notification settings - Fork 100
New tracker conditions tables for TOT and HV trips #1826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
bonventre
wants to merge
2
commits into
Mu2e:main
Choose a base branch
from
bonventre:tottable
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| #ifndef DbTables_TrkHVTripStatus_hh | ||
| #define DbTables_TrkHVTripStatus_hh | ||
|
|
||
| #include "Offline/DataProducts/inc/StrawId.hh" | ||
| #include "Offline/DataProducts/inc/StrawIdMask.hh" | ||
| #include "Offline/DataProducts/inc/StrawStatus.hh" | ||
| #include "Offline/DbTables/inc/DbTable.hh" | ||
| #include "cetlib_except/exception.h" | ||
| #include <iomanip> | ||
| #include <map> | ||
| #include <regex> | ||
| #include <sstream> | ||
| #include <string> | ||
|
|
||
| namespace mu2e { | ||
|
|
||
| class TrkHVTripStatus : public DbTable { | ||
| public: | ||
|
|
||
| class Row { | ||
| public: | ||
| Row(int index, StrawId sid, uint32_t startevent, uint32_t endevent) : | ||
| _index(index), _sid(sid), _startevent(startevent), _endevent(endevent) {} | ||
| int index() const { return _index; } | ||
| StrawId const& id() const { return _sid; } | ||
| uint32_t startevent() const { return _startevent; } | ||
| uint32_t endevent() const { return _endevent; } | ||
|
|
||
| private: | ||
| int _index; | ||
| StrawId _sid; | ||
| uint32_t _startevent; | ||
| uint32_t _endevent; | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| typedef std::shared_ptr<TrkHVTripStatus> ptr_t; | ||
| typedef std::shared_ptr<const TrkHVTripStatus> cptr_t; | ||
|
|
||
| constexpr static const char* cxname = "TrkHVTripStatus"; | ||
|
|
||
| TrkHVTripStatus() : | ||
| DbTable(cxname, "trk.hvtripstatus", | ||
| "index,strawid,startevent,endevent") {} | ||
| const Row& rowAt(const std::size_t index) const { return _rows.at(index); } | ||
| std::vector<Row> const& rows() const { return _rows; } | ||
| std::size_t nrow() const override { return _rows.size(); }; | ||
| // this is a variable-size table, so don't overrido nrowFix() | ||
| size_t size() const override { return baseSize() + nrow() * sizeof(Row); }; | ||
| const std::string orderBy() const { return std::string("index"); } | ||
|
|
||
| void addRow(const std::vector<std::string>& columns) override { | ||
| int index = std::stoi(columns[0]); | ||
| auto sid = StrawId(columns[1]); | ||
| uint32_t startevent = std::stoul(columns[2]); | ||
| uint32_t endevent = std::stoul(columns[3]); | ||
| // enforce a strict sequential order | ||
| if (index != int(_rows.size())) { | ||
| throw cet::exception("TRKHVTRIPSTATUS_BAD_INDEX") | ||
| << "TrkHVTripStatus::addRow found index out of order: " << index | ||
| << " != " << _rows.size() << "\n"; | ||
| } | ||
| _rows.emplace_back(index, sid, startevent, endevent); | ||
| } | ||
|
|
||
| void rowToCsv(std::ostringstream& sstream, std::size_t irow) const override { | ||
| Row const& r = _rows.at(irow); | ||
| sstream << r.index() << ","; | ||
| sstream << r.id().plane() << "_" << r.id().panel() << "_" << r.id().straw() | ||
| << ","; | ||
| sstream << r.startevent() << ","; | ||
| sstream << r.endevent(); | ||
| } | ||
|
|
||
| virtual void clear() override { | ||
| baseClear(); | ||
| _rows.clear(); | ||
| } | ||
|
|
||
| private: | ||
| std::vector<Row> _rows; | ||
| }; | ||
|
|
||
| } // namespace mu2e | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| #ifndef DbTables_TrkTOTCalib_hh | ||
| #define DbTables_TrkTOTCalib_hh | ||
|
|
||
| #include "Offline/DbTables/inc/DbTable.hh" | ||
| #include <iomanip> | ||
| #include <map> | ||
| #include <sstream> | ||
| #include <string> | ||
|
|
||
| namespace mu2e { | ||
|
|
||
| class TrkTOTCalibParams : public DbTable { | ||
| public: | ||
| typedef std::shared_ptr<TrkTOTCalibParams> ptr_t; | ||
| typedef std::shared_ptr<const TrkTOTCalibParams> cptr_t; | ||
|
|
||
| class Row { | ||
| public: | ||
| Row(int totTBins, float totTBinWidth, int totEBins, float totEBinWidth) | ||
| : _totTBins(totTBins), _totTBinWidth(totTBinWidth), | ||
| _totEBins(totEBins), _totEBinWidth(totEBinWidth) {} | ||
| int totTBins() const { return _totTBins; } | ||
| float totTBinWidth() const { return _totTBinWidth; } | ||
| int totEBins() const { return _totEBins; } | ||
| float totEBinWidth() const { return _totEBinWidth; } | ||
| private: | ||
| int _totTBins; | ||
| float _totTBinWidth; | ||
| int _totEBins; | ||
| float _totEBinWidth; | ||
| }; | ||
|
|
||
| constexpr static const char* cxname = "TrkTOTCalibParams"; | ||
|
|
||
| TrkTOTCalibParams() : | ||
| DbTable(cxname, "trk.totcalibparams", | ||
| "tottbins,tottbinwidth,totebins,totebinwidth") {} | ||
| const Row& rowAt(const std::size_t index) const { return _rows.at(index); } | ||
| std::vector<Row> const& rows() const { return _rows; } | ||
| std::size_t nrow() const override { return _rows.size(); }; | ||
| virtual std::size_t nrowFix() const override { return 1; } | ||
| size_t size() const override { return baseSize() + nrow() * sizeof(Row); }; | ||
| const std::string orderBy() const { return std::string("tottbins"); } | ||
|
|
||
| void addRow(const std::vector<std::string>& columns) override { | ||
| if (_rows.size() != 0) | ||
| throw cet::exception("TRKTOTCALIBPARAMS_BAD_INDEX") | ||
| << "TrkTOTCalibParams::addRow adding more than one row\n"; | ||
| _rows.emplace_back(std::stoi(columns[0]), std::stof(columns[1]), | ||
| std::stoi(columns[2]), std::stof(columns[3])); | ||
| } | ||
|
|
||
| void rowToCsv(std::ostringstream& sstream, std::size_t irow) const override { | ||
| Row const& r = _rows.at(irow); | ||
| sstream << std::fixed << std::setprecision(1); | ||
| sstream << r.totTBins() << ","; | ||
| sstream << r.totTBinWidth() << ","; | ||
| sstream << r.totEBins() << ","; | ||
| sstream << r.totEBinWidth(); | ||
| } | ||
|
|
||
| virtual void clear() override { | ||
| baseClear(); | ||
| _rows.clear(); | ||
| } | ||
|
|
||
| private: | ||
| std::vector<Row> _rows; | ||
| }; | ||
|
|
||
| class TrkTOTCalib : public DbTable { | ||
| public: | ||
| typedef std::shared_ptr<TrkTOTCalib> ptr_t; | ||
| typedef std::shared_ptr<const TrkTOTCalib> cptr_t; | ||
|
|
||
| class Row { | ||
| public: | ||
| Row(int index, float driftTime, float driftError) | ||
| : _index(index), _driftTime(driftTime), _driftError(driftError) {} | ||
| int index() const { return _index; } | ||
| float driftTime() const { return _driftTime; } | ||
| float driftError() const { return _driftError; } | ||
| private: | ||
| int _index; | ||
| float _driftTime; | ||
| float _driftError; | ||
| }; | ||
|
|
||
| constexpr static const char* cxname = "TrkTOTCalib"; | ||
|
|
||
| TrkTOTCalib() : | ||
| DbTable(cxname, "trk.totcalib", | ||
| "index,drifttime,drifterror") {} | ||
| const Row& rowAt(const std::size_t index) const { return _rows.at(index); } | ||
| std::vector<Row> const& rows() const { return _rows; } | ||
| std::size_t nrow() const override { return _rows.size(); }; | ||
| size_t size() const override { return baseSize() + nrow() * sizeof(Row); }; | ||
| const std::string orderBy() const { return std::string("index"); } | ||
|
|
||
| void addRow(const std::vector<std::string>& columns) override { | ||
| int index = std::stoi(columns[0]); | ||
| // enforce a strict sequential order | ||
| if (index != int(_rows.size())) { | ||
| throw cet::exception("TRKTOTCALIB_BAD_INDEX") | ||
| << "TrkTOTCalib::addRow found index out of order: " << index | ||
| << " != " << _rows.size() << "\n"; | ||
| } | ||
| _rows.emplace_back(index,std::stof(columns[1]), std::stof(columns[2])); | ||
| } | ||
|
|
||
| void rowToCsv(std::ostringstream& sstream, std::size_t irow) const override { | ||
| Row const& r = _rows.at(irow); | ||
| sstream << std::fixed << std::setprecision(1); | ||
| sstream << r.driftTime() << ","; | ||
| sstream << r.driftError(); | ||
| } | ||
|
|
||
| virtual void clear() override { | ||
| baseClear(); | ||
| _rows.clear(); | ||
| } | ||
|
|
||
| private: | ||
| std::vector<Row> _rows; | ||
| }; | ||
|
|
||
| }; // namespace mu2e | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks unintentional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, maybe intentional in a test fcl..