-
Notifications
You must be signed in to change notification settings - Fork 56
SBND Timing Reconstruction Refactor #915
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
base: develop
Are you sure you want to change the base?
Changes from all commits
151b2c9
1e492fd
3f93ceb
b416a56
0d9f644
c1a42c0
e165606
60036c5
2f7ff45
15f34cd
3f44697
f527fb8
7e7c3c4
8d8d8a1
daa63dc
6739521
f7dead4
34e6ffe
500d130
a21b73f
4697328
8102b2e
ce18cbd
43f7614
6a24518
177f2b4
2d93ca4
857c9ed
3ca8e1b
d849488
370cd81
6dcca71
761ef7c
c66aaa3
a32bc3d
57b8b56
825c07d
c621ba3
f2bc6f9
9e19ef9
0ab99f6
a27480d
bb1ac48
7951a66
a2ea22b
4356756
d0c37f8
a6ecce2
39e8ff4
07d5fbc
6b65e1b
8ec8a0e
6bc5699
93faf62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,10 +23,9 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "sbnobj/SBND/CRT/FEBData.hh" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "sbnobj/SBND/CRT/CRTStripHit.hh" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "sbnobj/SBND/Timing/DAQTimestamp.hh" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "sbnobj/SBND/Timing/FrameShiftInfo.hh" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "sbndcode/Geometry/GeometryWrappers/CRTGeoService.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "sbndcode/Decoders/PTB/sbndptb.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "sbndcode/Timing/SBNDRawTimingObj.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "sbndcode/ChannelMaps/CRT/CRTChannelMapService.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -50,20 +49,23 @@ class sbnd::crt::CRTStripHitProducer : public art::EDProducer { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| void produce(art::Event& e) override; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::vector<CRTStripHit> CreateStripHits(art::Ptr<FEBData> &data, const uint32_t ref_time_s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const uint32_t ref_time_ns); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const uint32_t ref_time_ns, const uint32_t etrig_time_s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const uint32_t etrig_time_ns); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::set<uint32_t> UnixSet(const std::vector<art::Ptr<FEBData>> &datas); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool SPECTDCReference(art::Event& e, const uint64_t &raw_ts, uint64_t &ref_time); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool PTBHLTReference(art::Event& e, const uint64_t &raw_ts, uint64_t &ref_time, uint32_t &hlt_code); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| art::ServiceHandle<CRTGeoService> fCRTGeoService; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| art::ServiceHandle<SBND::CRTChannelMapService> fCRTChannelMapService; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::string fFEBDataModuleLabel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::string fFrameShiftModuleLabel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint16_t fADCThreshold; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::vector<double> fErrorCoeff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool fAllowFlag1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool fApplyETrigWindow; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| double fETrigMin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| double fETrigMax; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool fApplyTs0Window; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| double fTs0Min; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| double fTs0Max; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -72,24 +74,19 @@ class sbnd::crt::CRTStripHitProducer : public art::EDProducer { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| double fTs1Max; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool fCorrectForDifferentSecond; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool fReferenceTs0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int fTimingType; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::string fDAQHeaderModuleLabel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::string fDAQHeaderInstanceLabel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint32_t fRawTSCorrection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint32_t fMaxAllowedRefTimeDiff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::string fSPECTDCModuleLabel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint32_t fSPECTDCETrigChannel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::string fPTBModuleLabel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::vector<uint32_t> fAllowedPTBHLTs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sbnd::crt::CRTStripHitProducer::CRTStripHitProducer(fhicl::ParameterSet const& p) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : EDProducer{p} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fFEBDataModuleLabel(p.get<std::string>("FEBDataModuleLabel")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fFrameShiftModuleLabel(p.get<std::string>("FrameShiftModuleLabel")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fADCThreshold(p.get<uint16_t>("ADCThreshold")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fErrorCoeff(p.get<std::vector<double>>("ErrorCoeff")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fAllowFlag1(p.get<bool>("AllowFlag1")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fApplyETrigWindow(p.get<bool>("ApplyETrigWindow")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fETrigMin(p.get<double>("ETrigMin", 0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fETrigMax(p.get<double>("ETrigMax", std::numeric_limits<double>::max())) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fApplyTs0Window(p.get<bool>("ApplyTs0Window")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fTs0Min(p.get<double>("Ts0Min", 0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fTs0Max(p.get<double>("Ts0Max", std::numeric_limits<double>::max())) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -98,15 +95,6 @@ sbnd::crt::CRTStripHitProducer::CRTStripHitProducer(fhicl::ParameterSet const& p | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fTs1Max(p.get<double>("Ts1Max", std::numeric_limits<double>::max())) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fCorrectForDifferentSecond(p.get<bool>("CorrectForDifferentSecond")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fReferenceTs0(p.get<bool>("ReferenceTs0")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fTimingType(p.get<int>("TimingType", 0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fDAQHeaderModuleLabel(p.get<std::string>("DAQHeaderModuleLabel", "")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fDAQHeaderInstanceLabel(p.get<std::string>("DAQHeaderInstanceLabel", "")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fRawTSCorrection(p.get<uint32_t>("RawTSCorrection", 0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fMaxAllowedRefTimeDiff(p.get<uint32_t>("MaxAllowedRefTimeDiff", 0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fSPECTDCModuleLabel(p.get<std::string>("SPECTDCModuleLabel", "")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fSPECTDCETrigChannel(p.get<uint32_t>("SPECTDCETrigChannel", 4)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fPTBModuleLabel(p.get<std::string>("PTBModuleLabel", "")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| , fAllowedPTBHLTs(p.get<std::vector<uint32_t>>("AllowedPTBHLTs", {})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| produces<std::vector<CRTStripHit>>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| produces<art::Assns<FEBData, CRTStripHit>>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -127,66 +115,39 @@ void sbnd::crt::CRTStripHitProducer::produce(art::Event& e) | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::vector<art::Ptr<FEBData>> FEBDataVec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| art::fill_ptr_vector(FEBDataVec, FEBDataHandle); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint64_t raw_ts = 0, ref_time = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint32_t ref_time_s = 0, ref_time_ns = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint32_t ref_time_s = 0, ref_time_ns = 0, etrig_time_s = 0, etrig_time_ns = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(fReferenceTs0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| art::Handle<artdaq::detail::RawEventHeader> DAQHeaderHandle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.getByLabel(fDAQHeaderModuleLabel, fDAQHeaderInstanceLabel, DAQHeaderHandle); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+122
to
+126
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the handle is only used to access its data, a more compact expression is:
Suggested change
that also throws an exception in case of failure; note that you lose control on the exception message though. Since
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int timingType = fTimingType; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int timingCh = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint64_t ref_time = frameShiftHandle->FrameDefault(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(timingType == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint64_t spec_tdc_ref_time = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(SPECTDCReference(e, raw_ts, spec_tdc_ref_time)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref_time = spec_tdc_ref_time; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timingCh = fSPECTDCETrigChannel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ++timingType; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref_time_s = ref_time / sbnd::timing::kSecondInNanoseconds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref_time_ns = ref_time % sbnd::timing::kSecondInNanoseconds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(timingType == 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint64_t ptb_hlt_ref_time = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint32_t hlt_code = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(PTBHLTReference(e, raw_ts, ptb_hlt_ref_time, hlt_code)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref_time = ptb_hlt_ref_time; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timingCh = hlt_code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ++timingType; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timingReferenceInfo->timingType = frameShiftHandle->TimingTypeDefault(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timingReferenceInfo->timingChannel = frameShiftHandle->TimingChannelDefault(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(timingType == 2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::set<uint32_t> unix_set = UnixSet(FEBDataVec); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref_time = unix_set.size() ? *unix_set.rbegin() * static_cast<uint64_t>(1e9) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(timingReferenceInfo->timingType == sbnd::timing::kNoShiftType) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::set<uint32_t> unix_set = UnixSet(FEBDataVec); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref_time_s = unix_set.size() ? *unix_set.rbegin(): 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+137
to
+140
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please fix the indentation (I suppose tabulate characters are mixed in). |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref_time_s = ref_time / static_cast<uint64_t>(1e9); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref_time_ns = ref_time % static_cast<uint64_t>(1e9); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint64_t etrig_time = frameShiftHandle->FrameEtrig(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timingReferenceInfo->timingType = timingType; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timingReferenceInfo->timingChannel = timingCh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| etrig_time_s = etrig_time / sbnd::timing::kSecondInNanoseconds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| etrig_time_ns = etrig_time % sbnd::timing::kSecondInNanoseconds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for(auto data : FEBDataVec) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::vector<CRTStripHit> newStripHits = CreateStripHits(data, ref_time_s, ref_time_ns); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::vector<CRTStripHit> newStripHits = CreateStripHits(data, ref_time_s, ref_time_ns, etrig_time_s, etrig_time_ns); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for(auto hit : newStripHits) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -203,7 +164,8 @@ void sbnd::crt::CRTStripHitProducer::produce(art::Event& e) | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::vector<sbnd::crt::CRTStripHit> sbnd::crt::CRTStripHitProducer::CreateStripHits(art::Ptr<FEBData> &data, const uint32_t ref_time_s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const uint32_t ref_time_ns) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const uint32_t ref_time_ns, const uint32_t etrig_time_s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const uint32_t etrig_time_ns) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::vector<CRTStripHit> stripHits; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -249,6 +211,27 @@ std::vector<sbnd::crt::CRTStripHit> sbnd::crt::CRTStripHitProducer::CreateStripH | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(fReferenceTs0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t0 -= ref_time_ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(fApplyETrigWindow) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| double t0_etrig = (int)data->Ts0() + module.t0DelayCorrection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const int64_t unix_diff = static_cast<int64_t>(ref_time_s) - static_cast<int64_t>(etrig_time_s); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(unix_diff < -1 || unix_diff > 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw std::runtime_error(Form("Unix timestamps differ by more than 1 (%li)", unix_diff)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without pulling in ROOT's
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t0_etrig -= etrig_time_ns; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(unix_diff == 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t0_etrig -= 1e9; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else if(unix_diff == -1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t0_etrig += 1e9; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(t0_etrig < fETrigMin || t0_etrig > fETrigMax) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return stripHits; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+226
to
+232
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the code indentation:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(fApplyTs0Window && (t0 < fTs0Min || t0 > fTs0Max)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return stripHits; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -309,92 +292,4 @@ std::set<uint32_t> sbnd::crt::CRTStripHitProducer::UnixSet(const std::vector<art | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| return set; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool sbnd::crt::CRTStripHitProducer::SPECTDCReference(art::Event& e, const uint64_t &raw_ts, uint64_t &ref_time) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool found = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| art::Handle<std::vector<sbnd::timing::DAQTimestamp>> TDCHandle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.getByLabel(fSPECTDCModuleLabel, TDCHandle); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(!TDCHandle.isValid() || TDCHandle->size() == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return found; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::vector<art::Ptr<sbnd::timing::DAQTimestamp>> TDCVec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| art::fill_ptr_vector(TDCVec, TDCHandle); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint64_t min_diff = std::numeric_limits<int64_t>::max(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint64_t min_diff_ts = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for(auto ts : TDCVec) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(ts->Channel() == fSPECTDCETrigChannel) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint64_t diff = raw_ts > ts->Timestamp() ? raw_ts - ts->Timestamp() : ts->Timestamp() - raw_ts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(diff < min_diff) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| min_diff = diff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| min_diff_ts = ts->Timestamp(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| found = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(min_diff > fMaxAllowedRefTimeDiff) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref_time = min_diff_ts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return found; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool sbnd::crt::CRTStripHitProducer::PTBHLTReference(art::Event& e, const uint64_t &raw_ts, uint64_t &ref_time, uint32_t &hlt_code) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool found = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| art::Handle<std::vector<raw::ptb::sbndptb>> PTBHandle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.getByLabel(fPTBModuleLabel, PTBHandle); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(!PTBHandle.isValid() || PTBHandle->size() == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return found; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::vector<art::Ptr<raw::ptb::sbndptb>> PTBVec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| art::fill_ptr_vector(PTBVec, PTBHandle); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint64_t min_diff = std::numeric_limits<int64_t>::max(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint64_t min_diff_ts = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for(auto ptb : PTBVec) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for(auto hlt : ptb->GetHLTriggers()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint64_t hlt_timestamp = (hlt.timestamp * 20); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::bitset<32> hlt_word_bitset = std::bitset<32>(hlt.trigger_word); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for(uint32_t allowed_hlt : fAllowedPTBHLTs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(hlt_word_bitset[allowed_hlt]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uint64_t diff = raw_ts > hlt_timestamp ? raw_ts - hlt_timestamp : hlt_timestamp - raw_ts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(diff < min_diff) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| min_diff = diff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| min_diff_ts = hlt_timestamp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hlt_code = allowed_hlt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| found = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(min_diff > fMaxAllowedRefTimeDiff) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref_time = min_diff_ts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return found; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DEFINE_ART_MODULE(sbnd::crt::CRTStripHitProducer) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Note that the appropriate type is
art::InputTag, notstd::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.