Repository navigation
Gen2 Production PR: Update to SBND LightPropagation Module #967
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
aantonakis
merged 4 commits into
production/sbnd-gen2
from
bugfix_gen2_mctiming_merge_correctedopflash
Nov 17, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ad2ce28
Fix data-side CorrectedOpFlash timing: SCE label and RWM-to-gate alig…
VCLanNguyen eb069ca
Apply different corrections for VIS light in data and MC
asanchezcastillo 048b7c8
Merge branch 'production/sbnd-gen2' into bugfix_gen2_mctiming_merge_c…
aantonakis 1777717
Merge branch 'production/sbnd-gen2' into bugfix_gen2_mctiming_merge_c…
aantonakis 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
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,7 +13,7 @@ sbnd::LightPropagationCorrection::LightPropagationCorrection(fhicl::ParameterSet | |||||
| fOpFlashLabel_tpc1 ( p.get<std::string>("OpFlashLabel_tpc1") ), | ||||||
| fSpacePointLabel( p.get<std::string>("SpacePointLabel") ), | ||||||
| fOpHitsModuleLabel( p.get<std::string>("OpHitsModuleLabel") ), | ||||||
| fSPECTDCLabel( p.get<std::string>("SPECTDCLabel") ), | ||||||
| fFrameShiftInfoLabel( p.get<std::string>("FrameShiftInfoLabel") ), | ||||||
| fFlashMatchingTool( p.get<std::string>("FlashMatchingTool") ), | ||||||
| fSaveCorrectionTree( p.get<bool>("SaveCorrectionTree") ), | ||||||
| fSpeedOfLight( p.get<double>("SpeedOfLight") ), | ||||||
|
|
@@ -128,10 +128,27 @@ void sbnd::LightPropagationCorrection::produce(art::Event & e) | |||||
| std::vector< art::Ptr<recob::Slice> > sliceVect; | ||||||
| art::fill_ptr_vector(sliceVect, sliceHandle); | ||||||
|
|
||||||
| // Get the FrameShiftInfo product required to go to the RWM/gate reference frame | ||||||
| bool haveFrameShiftInfo = true; | ||||||
| if(!fIsMC) | ||||||
| { | ||||||
| // Data: stream-agnostic -- FrameApplyAtCaf is already resolved per-stream (BNB/Offbeam/Xmuon) by FrameShift_module | ||||||
| art::Handle<sbnd::timing::FrameShiftInfo> frameShiftHandle; | ||||||
| e.getByLabel(fFrameShiftInfoLabel, frameShiftHandle); | ||||||
| if (!frameShiftHandle.isValid()){ | ||||||
| std::cout << "No FrameShiftInfo product found. Skip this event." << std::endl; | ||||||
| haveFrameShiftInfo = false; | ||||||
| } | ||||||
| else{ | ||||||
| fFrameApplyAtCaf = frameShiftHandle->FrameApplyAtCaf(); | ||||||
| } | ||||||
| } | ||||||
| // MC: block above is skipped, fFrameApplyAtCaf stays 0 -- no shift applied | ||||||
|
|
||||||
| //Vector for recob PFParticles | ||||||
| std::vector<art::Ptr<recob::PFParticle>> pfpVect; | ||||||
| // --- Get the candidate slices | ||||||
| for(size_t ix=0; ix<sliceVect.size(); ix++){ | ||||||
| for(size_t ix=0; ix<sliceVect.size() && haveFrameShiftInfo; ix++){ | ||||||
| ResetSliceInfo(); | ||||||
| // --- Get the slice | ||||||
| auto & slice = sliceVect[ix]; | ||||||
|
|
@@ -201,29 +218,7 @@ void sbnd::LightPropagationCorrection::produce(art::Event & e) | |||||
| continue; // Skip to the next slice if the nu score is below threshold | ||||||
| } | ||||||
| this->GetPropagationTimeCorrectionPerChannel(); | ||||||
|
|
||||||
| // Get the SPECTDC product required to go to the RWM reference frame | ||||||
|
|
||||||
| if(!fIsMC) | ||||||
| { | ||||||
| art::Handle<std::vector<sbnd::timing::DAQTimestamp>> tdcHandle; | ||||||
| e.getByLabel(fSPECTDCLabel, tdcHandle); | ||||||
| if (!tdcHandle.isValid() || tdcHandle->size() == 0){ | ||||||
| std::cout << "No SPECTDC products found. Skip this event." << std::endl; | ||||||
| ResetSliceInfo(); | ||||||
| continue; | ||||||
| } | ||||||
| else{ | ||||||
| const std::vector<sbnd::timing::DAQTimestamp> tdc_v(*tdcHandle); | ||||||
| for (size_t i=0; i<tdc_v.size(); i++){ | ||||||
| auto tdc = tdc_v[i]; | ||||||
| const uint32_t ch = tdc.Channel(); | ||||||
| const uint64_t ts = tdc.Timestamp(); | ||||||
| if(ch == 2) fRWMTime = ts%uint64_t(1e9); | ||||||
| if(ch == 4) fEventTriggerTime = ts%uint64_t(1e9); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| // Get all the OpT0 objects associated to the slice | ||||||
| std::vector<art::Ptr<recob::OpFlash>> flashFM; | ||||||
| if(fFlashMatchingTool == "OpT0Finder" ){ | ||||||
|
|
@@ -283,8 +278,6 @@ void sbnd::LightPropagationCorrection::beginJob() | |||||
| fTree->Branch("eventID", &fEvent, "eventID/i"); | ||||||
| fTree->Branch("runID", &fRun, "runID/i"); | ||||||
| fTree->Branch("subrunID", &fSubrun, "subrunID/i"); | ||||||
| fTree->Branch("RWMTime", &fRWMTime); | ||||||
| fTree->Branch("EventTriggerTime", &fEventTriggerTime); | ||||||
| fTree->Branch("NuScore", &fNuScore); | ||||||
| fTree->Branch("FMScore", &fFMScore); | ||||||
| fTree->Branch("OpFlashTimeOld", &fOpFlashTimeOld); | ||||||
|
|
@@ -318,8 +311,7 @@ void sbnd::LightPropagationCorrection::ResetEventVars() | |||||
| fRun = 0; | ||||||
| fSubrun = 0; | ||||||
| _fNuScore = 0.0; | ||||||
| fRWMTime=0.; | ||||||
| fEventTriggerTime=0.; | ||||||
| fFrameApplyAtCaf=0.; | ||||||
| fNuScore.clear(); | ||||||
| fFMScore.clear(); | ||||||
| fOpFlashTimeOld.clear(); | ||||||
|
|
@@ -409,9 +401,16 @@ for(size_t opdet = 0; opdet < fOpDetID.size(); ++opdet) { | |||||
| double dy = fSpacePointY[sp] - _opDetY; | ||||||
| double dz = fSpacePointZ[sp] - _opDetZ; | ||||||
| double distanceToOpDet = std::sqrt(dx*dx + dy*dy + dz*dz); | ||||||
| double cathodeToOpDet = std::sqrt(_opDetX*_opDetX + (dy/2)*(dy/2) + (dz/2)*(dz/2)); // Distance from cathode to OpDet in mm | ||||||
| double spToCathode = std::sqrt( fSpacePointX[sp]*fSpacePointX[sp] + (dy/2)*(dy/2) + (dz/2)*(dz/2)); // Distance from space point to cathode in mm | ||||||
|
|
||||||
| double spToCathode; | ||||||
| double cathodeToOpDet; | ||||||
| if(fIsMC){ // Correct VIS light as is simulated in MC. | ||||||
|
Contributor
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. Can you add a link to the docdb explaining the difference between the data/MC approaches? It's non trivial, so it'd be nice for future reference.
Suggested change
|
||||||
| spToCathode = std::sqrt(fSpacePointX[sp]*fSpacePointX[sp]); // Distance from space point to cathode in mm | ||||||
| cathodeToOpDet = std::sqrt(_opDetX*_opDetX + (dy)*(dy) + (dz)*(dz)); // Distance from cathode to OpDet in mm | ||||||
| } | ||||||
| else{ // Correct VIS light to minimise bias in data. | ||||||
| spToCathode = std::sqrt( fSpacePointX[sp]*fSpacePointX[sp] + (dy/2)*(dy/2) + (dz/2)*(dz/2)); // Distance from space point to cathode in mm | ||||||
| cathodeToOpDet = std::sqrt(_opDetX*_opDetX + (dy/2)*(dy/2) + (dz/2)*(dz/2)); // Distance from cathode to OpDet in mm | ||||||
| } | ||||||
| float lightPropTimeVIS = spToCathode/fVGroupVUV + cathodeToOpDet/fVGroupVIS; // Speed | ||||||
| float lightPropTimeVUV = distanceToOpDet / fVGroupVUV; // Speed of light in mm/ns for VUV | ||||||
| float lightPropTime = 0; | ||||||
|
|
@@ -631,10 +630,11 @@ void sbnd::LightPropagationCorrection::CorrectOpFlash(art::Ptr<recob::OpFlash> c | |||||
| newFlashTime = flasht0; | ||||||
| particlePropTime = GetAverageParticlePropagationTime()/1000; | ||||||
| photonPropTime = GetAveragePhotonPropagationTime()/1000; | ||||||
| correctedOpFlashTiming.OpFlashT0 = originalFlashTime + fEventTriggerTime/1000 - fRWMTime/1000; | ||||||
| double const frameShift_us = fFrameApplyAtCaf/1000.; | ||||||
| correctedOpFlashTiming.OpFlashT0 = originalFlashTime + frameShift_us; | ||||||
| correctedOpFlashTiming.NuToFLight = (Zcenter/fSpeedOfLight)/1000; | ||||||
| correctedOpFlashTiming.NuToFCharge = (fRecoVz/fSpeedOfLight)/1000; | ||||||
| correctedOpFlashTiming.OpFlashT0Corrected = newFlashTime + fEventTriggerTime/1000 - fRWMTime/1000;; | ||||||
| correctedOpFlashTiming.OpFlashT0Corrected = newFlashTime + frameShift_us; | ||||||
| correctedOpFlashTiming.ParticlePropagationTime = particlePropTime; | ||||||
| correctedOpFlashTiming.PhotonPropagationTime = photonPropTime; | ||||||
| } | ||||||
|
|
||||||
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.
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.
I found the name of the variable confusing while making the review. The correction is all applied within this module, right? There is no correction left to be done by the user at CAF level.
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.
Gen2 overall still needs time correction at CAF-level... It just happens this one timing variable sbn::CorrectedOpFlash will get correction at reco2 instead CAF.
So this naming method is to stay consistent with what being done in CAF, see these lines: https://github.com/SBNSoftware/sbncode/blob/production/sbnd-gen2/sbncode/CAFMaker/CAFMaker_module.cc#L645-L674