Weird memory bug with waveform simulator#371
Weird memory bug with waveform simulator#371S81D wants to merge 2 commits intoANNIEsoft:Applicationfrom
Conversation
|
well.... this works, i guess. Some very minor things that seem like changes that aren't necessarily for the better:
At least only the last one seems like a necessary fix. However.... it is a bit of a worrisome workaround. That the current code stops working suggests there may be memory corruption, and burying our heads in the sand (and our lead on that corruption) is unlikely to be the best approach.
While I appreciate that this could take some time, if there is memory corruption happening, hiding our only lead to it is liable to come back and bite you later, requiring more time investment to get valid results... |
Actually exit the tool if a timing smearing value is not found
|
Sorry for the delay on this - I added a condition that actually checks if the channel jitter is not found. If so it stops the toolchain. |
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.