Skip to content
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

This is meant to address the issue reported in issue #39 #40

Closed
wants to merge 2 commits into from

Conversation

SFBayLaser
Copy link
Contributor

See #39

Generally, tbin is a short int in the range of a few "bins"... the offsets can be large (and event negative) and, if negative, will give nonsensical results for the tdc value. In comparing to the old SimChannel output module (DepoSetSimChannelSink) it seems clear that instead of simple "tbin" one really needs to substitite "m_tbins(tbin)/jm_tbins.binsize()".

Testing with ICARUS simlations in standard form give expected results with this change.

@FNALbuild
Copy link
Contributor

A new Pull Request was created by @SFBayLaser (Tracy Usher) for develop.

It involves the following packages:

larwirecell

@LArSoft/level-1-managers, @LArSoft/level-2-managers can you please review it and eventually sign? Thanks.

cms-bot commands are listed here

@FNALbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@FNALbuild
Copy link
Contributor

-code-checks
Pull request failed code-formatting checks. Please ensure that cetmodules has been setup and execute the following command from the top-level directory of your repository:

format-code \
  larwirecell/Components/DepoFluxWriter.cxx

Then commit the changes and push them to your PR branch.

@lgarren
Copy link
Member

lgarren commented Sep 19, 2023

@SFBayLaser please run clang format as suggested

@SFBayLaser
Copy link
Contributor Author

Wow! I am surprised there is a problem here... I modified one line of code (see comparison) and made no other changes so am really not understanding why it is failing clang-format.
Unfortunately, I seem unable to run clang-format on my local setup and I'm not finding instructions for resolving that. Is there a link where I can see what it is unhappy with?

@knoepfel
Copy link
Member

@SFBayLaser, you need to setup cetmodules (it will be setup as part of your development environment). And then you should just type:

$ format-code <path to your larwirecell dir>/larwirecell/Components/DepoFluxWriter.cxx

@FNALbuild
Copy link
Contributor

Pull request #40 was updated. @LArSoft/level-1-managers, @LArSoft/level-2-managers can you please check and sign again.

@FNALbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@SFBayLaser
Copy link
Contributor Author

Ok, I didn't realize we cared about fitting into the columns of an IBM card... should be good now.

@FNALbuild
Copy link
Contributor

+code-checks

@knoepfel
Copy link
Member

Thanks, @SFBayLaser. The clang-format file sets a width of 100 characters (a little wider than the IBM 80 limit), and it also places spaces around operators (like /). There's no perfect formatter, but it's better having consistent code than no automated formatting.

@knoepfel
Copy link
Member

trigger build

@FNALbuild
Copy link
Contributor

The tests are being triggered in jenkins.

@SFBayLaser
Copy link
Contributor Author

As you say, no perfect format! Generally, I find the clang format hard to read but that is personal preference... and I'm not tasked with maintaining all of this! ;-)

@FNALbuild
Copy link
Contributor

+LArSoft tests OK on slf7 for c7:prof
for details see
https://lar-ci-history.fnal.gov/LarCI/app/view_builds/index?offset=0&builds=lar_ci/20584&builds=
+build

@FNALbuild
Copy link
Contributor

+LArSoft tests OK on slf7 for e20:prof
for details see
https://lar-ci-history.fnal.gov/LarCI/app/view_builds/index?offset=0&builds=lar_ci/20585&builds=
+build

@FNALbuild
Copy link
Contributor

-icarus tests failed, with build warning,, with ignored warning for build, on slf7 for e20:prof
for details see
https://lar-ci-history.fnal.gov/LarCI/app/ns:icarus/view_builds/index?offset=0&builds=icarus_ci/8154&builds=
for details of the parent CI build see
https://lar-ci-history.fnal.gov/LarCI/app/view_builds/index?offset=0&builds=lar_ci/20585&builds=

@FNALbuild
Copy link
Contributor

-sbnd tests warning, with build warning,, with ignored warning for build, on slf7 for e20:prof
for details see
https://lar-ci-history.fnal.gov/LarCI/app/ns:sbnd/view_builds/index?offset=0&builds=sbnd_ci/12674&builds=
for details of the parent CI build see
https://lar-ci-history.fnal.gov/LarCI/app/view_builds/index?offset=0&builds=lar_ci/20585&builds=

@FNALbuild
Copy link
Contributor

-dune tests tests warning, with build warning,, with ignored warning for build, on slf7 for e20:prof
for details see
https://lar-ci-history.fnal.gov/LarCI/app/ns:dune/view_builds/index?offset=0&builds=dune_ci/16080&builds=
for details of the parent CI build see
https://lar-ci-history.fnal.gov/LarCI/app/view_builds/index?offset=0&builds=lar_ci/20585&builds=

@FNALbuild
Copy link
Contributor

@SFBayLaser
Copy link
Contributor Author

ICARUS build failure unrelated to this PR. I believe there are updates in icarusalg for other things that collided here.

@lgarren
Copy link
Member

lgarren commented Sep 19, 2023

@brettviren do you approve this PR?

@brettviren
Copy link
Member

@SFBayLaser Hi Tracy.

I'm not following the goal of this change.

I would expect the user to set the reference_time configuration parameter to achieve any arbitrary time offset.

I think this PR will change the definition of what DepoFluxWriter claims to provide.

@SFBayLaser
Copy link
Contributor Author

SFBayLaser commented Sep 20, 2023

Hi @brettviren, the goal is to have the truth information contained in the SimChannels to match to, for example, hit information. In practice, the SimChannel information is in units of "TDC counts" while the hit information is returned in units of "ticks". Using ICARIUS as the example, the difference between the two is an offset - ticks are one unit on a waveform (for ICARUS that is 400 ns but I don't think this matters) with the first bin of the waveform tick = 0. TDC counts are the same in terms of bin size (400 ns) but the start is referenced to a "tdc clock start time). The document you provided describes how to include these offsets, I believe this has been done correctly in our json definitions:
`local wcls_simchannel_sink =
g.pnode({
type: 'wclsDepoFluxWriter',
name: 'postdrift',
data: {
anodes: [wc.tn(anode) for anode in tools.anodes],
field_response: wc.tn(tools.field),

  // time binning
  tick: params.daq.tick,
  window_start: -340 * wc.us, // TriggerOffsetTPC from detectorclocks_icarus.fcl
  window_duration: params.daq.readout_time,

  nsigma: 3.0,

  reference_time: -1500 * wc.us, // G4RefTime from detectorclocks_icarus.fcl

  smear_long: 0.0,
  smear_tran: 0.0,

  time_offsets: [std.extVar('time_offset_u') * wc.us, std.extVar('time_offset_v') * wc.us, std.extVar('time_offset_y') * wc.us],

  // input from art::Event
  sed_label: 'largeant:TPCActive',

  // output to art::Event
  simchan_label: 'simpleSC',
},

}, nin=1, nout=1, uses=tools.anodes+[tools.field]);
`
With these values the current release does not produce tdc values that make sense and there is no ability to match to hit information. In comparing DepoFluxWriter to the old DepoSetSimChannelSink it seemed clear that the issue is as described in issue #39. Certainly if I make the change to a local installation of larwirecell and then run I get "perfect" matching of SimChannel information to Hits (hmmm.... how do I include an image here?).

image (6)
Ah! Example... so here the black curve is the raw waveform, blue an ROI of the deconvolved waveform, the purple is the SimChannel information from DepoFluxWriter and pink the SimChannel info from DepoSetSimChannelSink (in both cases the y have been scaled to fit the vertical scale)

I did not find any other way to include the offsets needed for ICARUS and produce correct results... happy to be shown that I am wrong...

@SFBayLaser
Copy link
Contributor Author

I should add that there is some urgency to try to resolve this issue quickly... The ML effort on ICARUS needs this to be able to start working again, we have a collaboration meeting in 1 month and would like to be able to demonstrate the ML effort is ready for the start of Run 3 (which nominally starts the beginning of November). Thanks for helping to push this forward!

@brettviren
Copy link
Member

Hi again, @SFBayLaser

I believe you want the tdc count to be relative to a time that includes the window_start time (in addition to the "G4RefTime").

This additional offset can simply be included in the definition of the reference_time configuration parameter. Since the reference_time is subtracted from the "nominal time" and the window_start is negative in your case, it would get added with a negative (hopefully I got that right). So, I think with the original C++ you can use this configuration line:

reference_time: -1500 * wc.us - self.window_start,

If this does not provide what you need, let's discuss more.

If it does give you what you need then I'm inclined to not merge this PR. The reason is that with this PR the user will implicitly get an unexpected arbitrary time offset (the window_start) from the nominal time. The documentation would need to be rewritten and users with different needs would need to actively undo this arbitrary time offset (with + self.window_start). Keeping the C++ as-is lets all the arbitrary time offsets be relative to a single nominal time and to be specified in one place (the config).

@SFBayLaser
Copy link
Contributor Author

Ok, will try and report back. It looks like it will do what I need at the expense of using the window_start time in two places in the json file. I might suggest the documentation be updated to make that point as a user like me might not have thought of it.
I should also point out that our timing scheme was taken directly from MicroBooNE and is also the same for SBND... I would be surprised if not the same at ProtoDUNE. So I don't think this is necessarily "arbitrary" but more common practice. Whether that is true in the future I can't say...

@SFBayLaser
Copy link
Contributor Author

SFBayLaser commented Sep 20, 2023

I can confirm that Brett's proposal will work for us. Here is same waveform pic as before:
image (7)
(note there are subtle differences in waveforms because I reran the detector simulation and it appears we don't start with the same seeds for the noise modeling)
So we can close both this PR and the corresponding issue.
Thanks!

@lgarren
Copy link
Member

lgarren commented Sep 20, 2023

Thanks @SFBayLaser and @brettviren !

@brettviren
Copy link
Member

@SFBayLaser Thanks so much for the thorough checks.

About the lack of reproducibility: this has a known cause which can actually be corrected in configuration. But to do that in a user-friendly way needs a little C++ work.

For reference, details are in this issue.

WireCell/wire-cell-toolkit#242

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants