-
Notifications
You must be signed in to change notification settings - Fork 13
Move PMTBeamSignal data product from icaruscode to sbnobj #130
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a54b43e
add PMTBeamSignal to sbnobj, define new helper functions in PMTBeamSi…
aheggest 480b822
move cout statements to MessageFacility output
aheggest 519bea6
remove startmap from getFlashBunchTime function definition as it is n…
aheggest 92578e7
remove startmap from SelectFirstOpHitByTime function as its not needed
aheggest 05b33df
Merge branch 'develop' into feature/aheggest_RWMinCAF
kjplows 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,128 @@ | ||
| /** | ||
| * @file sbnobj/Common/PMT/Data/PMTBeamSignal.cxx | ||
| * @brief Holds the event-by-event RWM or EW times | ||
| * @author Anna Heggestuen (aheggest@colostate.edu), adapted from M. Vincenzi in https://github.com/SBNSoftware/icaruscode/pull/751 | ||
| * @date May 19, 2025 | ||
| * @see sbnobj/Common/PMT/Data/PMTBeamSignal.h | ||
| */ | ||
|
|
||
| //library header | ||
| #include "sbnobj/Common/PMT/Data/PMTBeamSignal.hh" | ||
|
|
||
| // framework libraries | ||
| #include "messagefacility/MessageLogger/MessageLogger.h" | ||
|
|
||
| // C/C++ standard libraries | ||
| #include <iostream> | ||
|
aheggest marked this conversation as resolved.
Outdated
|
||
|
|
||
| // ----------------------------------------------------------------------------- | ||
| void sbn::timing::SelectFirstOpHitByTime(const recob::OpHit* const hit, | ||
| std::map<int, double> &startmap, | ||
| std::map<int, double> &risemap) | ||
|
aheggest marked this conversation as resolved.
|
||
| { | ||
| const int ch = hit->OpChannel(); | ||
| double ts = hit->StartTime(); | ||
| double tr = hit->RiseTime(); | ||
| // select the first ophit (by time) in each channel | ||
| if (startmap.find(ch) != startmap.end()) | ||
| { | ||
| if (ts < startmap[ch]) | ||
| { | ||
| startmap[ch] = ts; | ||
| risemap[ch] = ts + tr; | ||
| } | ||
| } | ||
| else | ||
| { | ||
| startmap[ch] = ts; | ||
| risemap[ch] = ts + tr; | ||
| } | ||
| } | ||
| // ----------------------------------------------------------------------------- | ||
| int sbn::timing::getSideByChannel(const int channel) | ||
| { | ||
| /* | ||
| Channels are numbered from east to west, from North (cryo side) to South (beam side) | ||
| We look in the opposide direction wrt to the beam direction South->North: | ||
| - Left is the east wall of each cryostat; | ||
| - Right is the west side of each cryostat; | ||
| - [ 0:89 ] and [180:269] are on the left, | ||
| the return value of the function is 0; | ||
| - [ 90-179 ] and [ 270:359 ] are on the right, | ||
| the return value of the function is 1; | ||
| */ | ||
|
|
||
| int side = channel / 90; // always round down | ||
| return side % 2; | ||
| } | ||
|
|
||
| // ----------------------------------------------------------------------------- | ||
| double sbn::timing::getFlashBunchTime(std::map<int, double> startmap, | ||
| std::map<int, double> risemap, | ||
| std::vector<sbn::timing::PMTBeamSignal> RWMTimes) | ||
|
aheggest marked this conversation as resolved.
Outdated
|
||
| { | ||
| // if no RWM info available, all pmt_start_time_rwm are invalid | ||
| // return icarus::timing::NoTime as well for the flash | ||
| if (RWMTimes.empty()) | ||
| return sbn::timing::NoTime; | ||
|
|
||
| std::vector<int> channels; | ||
| std::vector<double> hit_rise_time_rwm; | ||
| for (auto it = startmap.begin(); it != startmap.end(); it++){ | ||
| int ch = it->first; | ||
| channels.push_back(ch); | ||
| auto rwm = RWMTimes.at(ch); | ||
| if (!rwm.isValid()){ | ||
| mf::LogTrace("PMTBeamSignal getFlashBunchTime") << "No RWM signal for channel " << ch << " " | ||
| << "(Crate " << rwm.crate << ", Board " << rwm.digitizerLabel | ||
| << ", SpecialChannel " << rwm.specialChannel << ")\n"; | ||
| } | ||
| float rwm_trigger = rwm.startTime; // rwm time w.r.t. trigger time [us] | ||
| hit_rise_time_rwm.push_back(risemap[ch] - rwm_trigger); | ||
| } | ||
|
|
||
| double tfirst_left = std::numeric_limits<double>::max(); | ||
| double tfirst_right = std::numeric_limits<double>::max(); | ||
|
|
||
| int nleft = 0; | ||
| int nright = 0; | ||
| for(std::size_t i = 0; i < hit_rise_time_rwm.size(); i++){ | ||
| int ch = channels[i]; | ||
| int side = sbn::timing::getSideByChannel(ch); | ||
| //int side = (ch / 90) % 2 ; //move this to a function as Matteo did to keep doc clear | ||
| double t = hit_rise_time_rwm[i]; // rise time w.r.t. rwm | ||
|
|
||
| // if any RWM copy is missing (therefore missing for an entire PMT crate), | ||
| // it might not be possible to use the first hits (they might not have a RMW time) | ||
| // so return icarus::timing::NoTime as in other bad cases | ||
| if (!RWMTimes[i].isValid()) | ||
| return sbn::timing::NoTime; | ||
|
|
||
| // count hits separetely on the two walls | ||
| if (side == 0) | ||
| { | ||
| nleft++; | ||
| if (t < tfirst_left) | ||
| tfirst_left = t; | ||
| } | ||
| else if (side == 1) | ||
| { | ||
| nright++; | ||
| if (t < tfirst_right) | ||
| tfirst_right = t; | ||
| } | ||
| } //end loop over m_hit_rise_time_rwm vector | ||
|
|
||
| // if there are no hits in one of the walls... very rare? | ||
| if (nleft < 1 || nright < 1) | ||
| { | ||
| mf::LogWarning("PMTBeamSignal getFlashBunchTime") << "Flash doesn't have hits on both walls!" | ||
| << "Left: " << nleft << " t " << tfirst_left << " " | ||
| << "Right: " << nright << " t " << tfirst_right; | ||
| // return what we have... | ||
| return (tfirst_left < tfirst_right) ? tfirst_left : tfirst_right; | ||
| } | ||
|
|
||
| return (tfirst_left + tfirst_right) / 2.; | ||
|
|
||
| } | ||
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,85 @@ | ||
| /** | ||
| * @file sbnobj/Common/PMT/Data/PMTBeamSignal.hh (moved from icaruscode/IcarusObj/PMTBeamSignal.h) | ||
| * @brief Holds the event-by-event RWM or EW times | ||
| * @author Matteo Vicenzi (mvicenzi@bnl.gov) | ||
| * @date March 14 2024, updated May 2025 | ||
| */ | ||
|
|
||
| #ifndef SBNOBJ_COMMON_PMT_DATA_PMTBEAMSIGNAL_HH | ||
| #define SBNOBJ_COMMON_PMT_DATA_PMTBEAMSIGNAL_HH | ||
|
|
||
| // LArSoft libraries | ||
| #include "lardataobj/RecoBase/OpHit.h" | ||
|
|
||
| // C/C++ standard libraries | ||
| #include <limits> | ||
| #include <string> | ||
| #include <vector> | ||
| #include <map> | ||
| #include <cstddef> | ||
| #include <iostream> //remove after testing | ||
|
aheggest marked this conversation as resolved.
Outdated
|
||
|
|
||
| namespace sbn::timing | ||
| { | ||
|
|
||
| /// Special value to denote no special channel information. | ||
| static constexpr auto NoChannel = std::numeric_limits<unsigned int>::max(); | ||
| /// Special value to denote no time channel information. | ||
| static constexpr double NoTime = std::numeric_limits<double>::max(); | ||
| // Special value to denote no sample information. | ||
| static constexpr std::size_t NoSample = 0; | ||
|
|
||
| void SelectFirstOpHitByTime(const recob::OpHit* const hit, | ||
| std::map<int, double> &startmap, | ||
| std::map<int, double> &risemap); | ||
|
|
||
| int getSideByChannel(const int channel); | ||
|
|
||
| /** | ||
| * @brief Beam time as seen by a PMT readout board. | ||
| * | ||
| * This could either be an early warning (EW) or a resistive wall monitor (RWM) time. | ||
| * These signals are delivered via fibers and digitized in special PMT channels. | ||
| * | ||
| * Both the time in @ref DetectorClocksElectronicsTime "electronics time scale" | ||
| * and time time relative to the hardware trigger are included. | ||
| * | ||
| * The information in this object may be missing: its validity should | ||
| * always be checked in advance with `isValid()`. | ||
| */ | ||
|
|
||
| struct PMTBeamSignal | ||
| { | ||
|
|
||
| /// Special channel this time was extracted from. | ||
| /// These are defined in `CAEN_V1730_setup_icarus.fcl`. | ||
| unsigned int specialChannel = NoChannel; | ||
|
|
||
| /// Board on which the special channel is on (e.g: WW-TOP-A). | ||
| /// Should match the same format as `icarusDB::PMTChannelInfo_t::digitizerLabel`. | ||
| std::string digitizerLabel = ""; | ||
|
|
||
| /// Crate this time applies to (e.g.: WW-TOP). | ||
| /// Corresponds to the first part of `digitizerLabel`. | ||
| std::string crate = ""; | ||
|
|
||
| /// Sample within the waveform where the reference signal is found. | ||
| std::size_t sample = NoSample; | ||
|
|
||
| /// Start time in electronics time [us]. | ||
| double startTimeAbs = NoTime; | ||
|
|
||
| /// Start time relative to trigger time [us]. | ||
| double startTime = NoTime; | ||
|
|
||
| /// Returns whether the time is valid. | ||
| bool isValid() const { return (sample != NoSample); } | ||
| }; | ||
|
|
||
| double getFlashBunchTime(std::map<int, double> startmap, | ||
| std::map<int, double> risemap, | ||
| std::vector<PMTBeamSignal> RWMTimes); | ||
|
|
||
| } // namespace sbn::timing | ||
|
|
||
| #endif // SBNOBJ_COMMON_PMT_DATA_PMTBEAMSIGNAL_HH | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.