SBND Timing Reconstruction Refactor#915
Conversation
… extended fragments combination
… not fulfill the requirements
…v10_11_01_hlay_functions Functionalise
…ected jittering of the extended fragments.
…indexing. Improve jittering application.
… timing corrections at an earlier stage of reconstruction
|
crt veto looks good |
|
@JosiePaton @PetrilloAtWork can you guys review for CAF? |
PetrilloAtWork
left a comment
There was a problem hiding this comment.
Some changes suggested here and there as usual, plus:
- something that looks like a bug (which must be fixed, hence the rejection)
- a questionable implementation of the difference of timestamps
A reiterated comment/recommendation: please format all the relevant comments on the usage of the functions and data member to Doxygen format.
| art::Handle<sbnd::timing::FrameShiftInfo> frameShiftHandle; | ||
| e.getByLabel(fFrameShiftModuleLabel, frameShiftHandle); | ||
|
|
||
| if(DAQHeaderHandle.isValid()) | ||
| { | ||
| artdaq::RawEvent rawHeaderEvent = artdaq::RawEvent(*DAQHeaderHandle); | ||
| raw_ts = rawHeaderEvent.timestamp() - fRawTSCorrection; | ||
| } | ||
| if(!frameShiftHandle.isValid()) | ||
| throw std::runtime_error("Frame Shift Info object is invalid, check data quality"); |
There was a problem hiding this comment.
Since the handle is only used to access its data, a more compact expression is:
| art::Handle<sbnd::timing::FrameShiftInfo> frameShiftHandle; | |
| e.getByLabel(fFrameShiftModuleLabel, frameShiftHandle); | |
| if(DAQHeaderHandle.isValid()) | |
| { | |
| artdaq::RawEvent rawHeaderEvent = artdaq::RawEvent(*DAQHeaderHandle); | |
| raw_ts = rawHeaderEvent.timestamp() - fRawTSCorrection; | |
| } | |
| if(!frameShiftHandle.isValid()) | |
| throw std::runtime_error("Frame Shift Info object is invalid, check data quality"); | |
| auto const & frameShift | |
| = e.getProduct<sbnd::timing::FrameShiftInfo> (fFrameShiftModuleLabel); |
that also throws an exception in case of failure; note that you lose control on the exception message though. Since art::Event::getByLabel() return the status of the operation, another alternative is:
| art::Handle<sbnd::timing::FrameShiftInfo> frameShiftHandle; | |
| e.getByLabel(fFrameShiftModuleLabel, frameShiftHandle); | |
| if(DAQHeaderHandle.isValid()) | |
| { | |
| artdaq::RawEvent rawHeaderEvent = artdaq::RawEvent(*DAQHeaderHandle); | |
| raw_ts = rawHeaderEvent.timestamp() - fRawTSCorrection; | |
| } | |
| if(!frameShiftHandle.isValid()) | |
| throw std::runtime_error("Frame Shift Info object is invalid, check data quality"); | |
| art::Handle<sbnd::timing::FrameShiftInfo> frameShiftHandle; | |
| if (!e.getByLabel(fFrameShiftModuleLabel, frameShiftHandle)) | |
| throw std::runtime_error("Frame Shift Info object is invalid, check data quality"); |
| { | ||
| std::set<uint32_t> unix_set = UnixSet(FEBDataVec); | ||
| ref_time_s = unix_set.size() ? *unix_set.rbegin(): 0; | ||
| } |
There was a problem hiding this comment.
Please fix the indentation (I suppose tabulate characters are mixed in).
|
|
||
| if(unix_diff < -1 || unix_diff > 1) | ||
| { | ||
| throw std::runtime_error(Form("Unix timestamps differ by more than 1 (%li)", unix_diff)); |
There was a problem hiding this comment.
Without pulling in ROOT's Form():
| throw std::runtime_error(Form("Unix timestamps differ by more than 1 (%li)", unix_diff)); | |
| throw std::runtime_error("Unix timestamps differ by more than 1 (" + std::to_string(unix_diff) + ")"); |
std::to_string() is defined in the C++ standard header string.
| if(unix_diff == 1) | ||
| t0_etrig -= 1e9; | ||
| else if(unix_diff == -1) | ||
| t0_etrig += 1e9; | ||
|
|
||
| if(t0_etrig < fETrigMin || t0_etrig > fETrigMax) | ||
| return stripHits; |
There was a problem hiding this comment.
Fix the code indentation:
| if(unix_diff == 1) | |
| t0_etrig -= 1e9; | |
| else if(unix_diff == -1) | |
| t0_etrig += 1e9; | |
| if(t0_etrig < fETrigMin || t0_etrig > fETrigMax) | |
| return stripHits; | |
| if(unix_diff == 1) | |
| t0_etrig -= 1e9; | |
| else if(unix_diff == -1) | |
| t0_etrig += 1e9; | |
| if(t0_etrig < fETrigMin || t0_etrig > fETrigMax) | |
| return stripHits; |
| art::ServiceHandle<SBND::CRTChannelMapService> fCRTChannelMapService; | ||
|
|
||
| std::string fFEBDataModuleLabel; | ||
| std::string fFrameShiftModuleLabel; |
There was a problem hiding this comment.
Note that the appropriate type is art::InputTag, not std::string.
Historically the latter was used because fhicl::ParameterSet::get<art::InputTag>() was broken; that time is long gone.
Not necessarily recommending the change here, unless you change all the tag data members.
| private: | ||
|
|
||
| // FCL Parameters | ||
| std::string fDAQHeaderModuleLabel; // Instance label for DAQ header product |
There was a problem hiding this comment.
Turn the comments into Doxygen format, so that they are rendered in the documentation. For example:
| std::string fDAQHeaderModuleLabel; // Instance label for DAQ header product | |
| std::string fDAQHeaderModuleLabel; ///< Instance label for DAQ header product |
| art::Handle<sbnd::timing::FrameShiftInfo> frameShiftHandle; | ||
| e.getByLabel(fFrameShiftLabel, frameShiftHandle); | ||
|
|
||
| if (!timingRefHandle.isValid()){ | ||
| throw cet::exception("WaveformAlignment") << "No raw::TimingReferenceInfo found w/ tag " << fTimingRefLabel << ". Check data quality!"; | ||
| if (!frameShiftHandle.isValid()){ | ||
| throw cet::exception("WaveformAlignment") << "No sbnd::timing::FrameShiftInfo found w/ tag " << fFrameShiftLabel << ". Check data quality!"; | ||
| } | ||
| else{ | ||
| raw::TimingReferenceInfo const& pmt_timing(*timingRefHandle); | ||
|
|
||
| _pmt_timing_type = pmt_timing.timingType; | ||
| _pmt_timing_ch = pmt_timing.timingChannel; | ||
|
|
||
| if (fDebugTimeRef){ | ||
| std::cout << "Timing Reference For Decoding PMT" << std::endl; | ||
| std::cout << " Type = " << _pmt_timing_type << " (SPECTDC = 0; PTB HLT = 1; CAEN-only = 3)." << std::endl; | ||
| std::cout << " Channel = " << _pmt_timing_ch << " (TDC ETRIG = 4; PTB BNB Beam+Light = 2)." << std::endl; | ||
| } | ||
| _frameDefault = frameShiftHandle->FrameDefault(); | ||
| _pmt_timing_type = frameShiftHandle->TimingTypeDefault(); | ||
| } |
There was a problem hiding this comment.
I suggest:
| art::Handle<sbnd::timing::FrameShiftInfo> frameShiftHandle; | |
| e.getByLabel(fFrameShiftLabel, frameShiftHandle); | |
| if (!timingRefHandle.isValid()){ | |
| throw cet::exception("WaveformAlignment") << "No raw::TimingReferenceInfo found w/ tag " << fTimingRefLabel << ". Check data quality!"; | |
| if (!frameShiftHandle.isValid()){ | |
| throw cet::exception("WaveformAlignment") << "No sbnd::timing::FrameShiftInfo found w/ tag " << fFrameShiftLabel << ". Check data quality!"; | |
| } | |
| else{ | |
| raw::TimingReferenceInfo const& pmt_timing(*timingRefHandle); | |
| _pmt_timing_type = pmt_timing.timingType; | |
| _pmt_timing_ch = pmt_timing.timingChannel; | |
| if (fDebugTimeRef){ | |
| std::cout << "Timing Reference For Decoding PMT" << std::endl; | |
| std::cout << " Type = " << _pmt_timing_type << " (SPECTDC = 0; PTB HLT = 1; CAEN-only = 3)." << std::endl; | |
| std::cout << " Channel = " << _pmt_timing_ch << " (TDC ETRIG = 4; PTB BNB Beam+Light = 2)." << std::endl; | |
| } | |
| _frameDefault = frameShiftHandle->FrameDefault(); | |
| _pmt_timing_type = frameShiftHandle->TimingTypeDefault(); | |
| } | |
| auto const& frameShift = e.getProduct<sbnd::timing::FrameShiftInfo>(fFrameShiftLabel); | |
| _frameDefault = frameShift.FrameDefault(); | |
| _pmt_timing_type = frameShift.TimingTypeDefault(); |
or, if control on the exception message is desired,
| art::Handle<sbnd::timing::FrameShiftInfo> frameShiftHandle; | |
| e.getByLabel(fFrameShiftLabel, frameShiftHandle); | |
| if (!timingRefHandle.isValid()){ | |
| throw cet::exception("WaveformAlignment") << "No raw::TimingReferenceInfo found w/ tag " << fTimingRefLabel << ". Check data quality!"; | |
| if (!frameShiftHandle.isValid()){ | |
| throw cet::exception("WaveformAlignment") << "No sbnd::timing::FrameShiftInfo found w/ tag " << fFrameShiftLabel << ". Check data quality!"; | |
| } | |
| else{ | |
| raw::TimingReferenceInfo const& pmt_timing(*timingRefHandle); | |
| _pmt_timing_type = pmt_timing.timingType; | |
| _pmt_timing_ch = pmt_timing.timingChannel; | |
| if (fDebugTimeRef){ | |
| std::cout << "Timing Reference For Decoding PMT" << std::endl; | |
| std::cout << " Type = " << _pmt_timing_type << " (SPECTDC = 0; PTB HLT = 1; CAEN-only = 3)." << std::endl; | |
| std::cout << " Channel = " << _pmt_timing_ch << " (TDC ETRIG = 4; PTB BNB Beam+Light = 2)." << std::endl; | |
| } | |
| _frameDefault = frameShiftHandle->FrameDefault(); | |
| _pmt_timing_type = frameShiftHandle->TimingTypeDefault(); | |
| } | |
| try { | |
| auto const& frameShift = e.getProduct<sbnd::timing::FrameShiftInfo>(fFrameShiftLabel); | |
| _frameDefault = frameShift.FrameDefault(); | |
| _pmt_timing_type = frameShift.TimingTypeDefault(); | |
| } | |
| catch(art::Exception const&) { | |
| throw cet::exception("WaveformAlignment") << "No sbnd::timing::FrameShiftInfo found w/ tag " << fFrameShiftLabel << ". Check data quality!"; | |
| } |
| art_dictionary(DICTIONARY_LIBRARIES | ||
| lardataobj::RawData) | ||
| art_make_library( | ||
| SOURCE TimingUtils.cc |
There was a problem hiding this comment.
This is redundant. Any reason to specify it?
| SOURCE TimingUtils.cc |
| //Subtract two timestamps in UTC format | ||
| //ts1 and ts2 are in nanoseconds in uint64_t format | ||
| //Return the difference in nanoseconds as double | ||
| double SubtractUTCTimestmap(const uint64_t& ts1, const uint64_t& ts2); |
There was a problem hiding this comment.
Same comment as somewhere earlier:
| double SubtractUTCTimestmap(const uint64_t& ts1, const uint64_t& ts2); | |
| double SubtractUTCTimestmap(uint64_t ts1, uint64_t ts2); |
|
|
||
| //Subtract two timestamps in UTC format | ||
| //ts1 and ts2 are in nanoseconds in uint64_t format | ||
| //Return the difference in nanoseconds as double |
There was a problem hiding this comment.
It may be useful to explicitly say which sign that difference has:
| //Return the difference in nanoseconds as double | |
| //Return the difference `ts1 - ts2` in nanoseconds as double |
Also, please convert this comment into Doxygen format.
Description
Link(s) to docdb describing changes (optional)
https://sbn-docdb.fnal.gov/cgi-bin/sso/ShowDocument?docid=46654
Relevant PR links (optional)
This PR needs the XA decoder PR in sbndcode to go in first:
#847
This PR needs to be merged together with this group of PRs:
Checklist
Reviewers,AssigneesDevelopement