Weird memory bug with waveform simulator #371
Open
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.
Describe your changes
The
PMTWaveformSimtool works as intended in the current, main repo. One feature of the simulator is the random time smearing that is applied to the MCHits before waveform template construction is performed. The time smearing is based on the laser data measurements, and is populated in the store by theLoadGeometrytool. The waveform simulator will grab the timing uncertainty by using the PMT ID to access the map.Everything works fine, except when this tool is used in combination with the
LoadReweightGENIEEventtool. For some reason the tool can no longer grab the timing uncertainties (using the channel key) from the store:ToolAnalysis/UserTools/PMTWaveformSim/PMTWaveformSim.cpp
Line 543 in 557f8b8
The map is blank and the value returned is nonsense (e-333) and the simulator instead returns the "default" value of 1ns. The performance of the code is not stable (it works, then re-making the exact same code causes it to not work). I assume its some weird memory issue when using
auto itand that the initialization is done with a pointer, but I can't find any reliable solutions. I'm making it seem more supernatural than it is but I have tried many different modifications and none reliably solve the problem.The proposed solution is to add the timing uncertainties ordinarily loaded into the store by the
LoadGeometrytool to the Lognorm csv file already utilized for template construction. This sidesteps the problem and the tool is able to reliably access the timing uncertainties.I also threw in a fatal error if the timing uncertainty cannot be grabbed - without it, it could lead to bias in vertex reconstruction if someone thinks the tool is applying time smearing (if time smearing is enabled in the config) and doesn't actually check the print out.
This fix is stable with the reweight tool and works as intended. Tested over many files.
Checklist before submitting your PR
newusage, there is a reason the data must be on the heapnewthere is adelete, unless I explicitly know why (e.g. ROOT or a BoostStore takes ownership)^ for the last two I am setting the random seed with
fRandom = new TRandom3();.Additional Material
Attach any validation or demonstration files here. You may also link to relavant docdb articles.