Skip to content

CORSIKA support and small CRY improvements#35

Merged
kutschke merged 18 commits into
Mu2e:masterfrom
soleti:master
Nov 7, 2019
Merged

CORSIKA support and small CRY improvements#35
kutschke merged 18 commits into
Mu2e:masterfrom
soleti:master

Conversation

@soleti

@soleti soleti commented Oct 22, 2019

Copy link
Copy Markdown
Contributor

This pull request includes:

  • Support for CORSIKA binary files: the CosmicCORSIKA.cc module reads CORSIKA binary files and produces a GenParticleCollection of the particles that intersect a target box.
  • Small improvement for the CRY module: I added the support for a minimum threshold on the shower kinetic energy and a bug fix in the EventGenerator/fcl/cryTest.fcl file
  • The analysis module Analyses/src/CRYGenPlots_module.cc now produces also a TTree and not just histograms.

@kutschke kutschke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only append to these IDs. Never insert new values. This changes the meaning of identifiers already written to existing files.

@kutschke kutschke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a standard prolog definition for the geometry service. Please use that. By doing so people can change the default configuration of the geometry service without you needing to maintain .fcl files.

@soleti

soleti commented Oct 22, 2019

Copy link
Copy Markdown
Contributor Author

I fixed the GenId.hh file and the fcl geometry statement

@kutschke

Copy link
Copy Markdown
Contributor

Hi Roberto,

I added a lot of small picky comments. I also want to say that in the big picture this looks really good. I also find your coding style and commenting style very easy to follow.

I realize now that I should have sent this first but the github interface makes it natural to send it last!

Rob

@kutschke kutschke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Roberto,

We need to discuss two things:
1)
How do you plan to package CORSIKA and all of the other software in it's stack? UPS? You were on uBooNE right? Do they have everything packaged as UPS products?

We should discuss whether or not the file format you are using is the right long term choice for Mu2e. It was a great choice for getting started but we now need to think about how we will structure production runs for the next decade.

I won't have time to tape part in this until next week. These issues should not slow down this pull request but we should address them sooner rather than later.

Rob

Comment thread MCDataProducts/inc/GenId.hh
Comment thread Analyses/src/CORSIKAGenPlots_module.cc
Comment thread Analyses/src/CRYGenPlots_module.cc
Comment thread EventGenerator/fcl/cryTest.fcl
Comment thread Analyses/src/CORSIKAGenPlots_module.cc
Comment thread Analyses/src/CORSIKAGenPlots_module.cc

namespace mu2e {

class CorsikaEventGenerator : public art::EDProducer {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer that you make this a source module not a producer. Among other things this lets you end gracefully the job if you run out of input events.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I understand what you mean by source module, could you please clarify?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of inheriting from EDAnalyzer or EDProducer or EDFilter you do something else ( the rules are a little more complicated). Then you specify your module in the source : {} table of the fcl file, instead of EmptyEvent or RootInput. The big win is that if you run out of events then you can gracefully shutdown the job. If you implement jobs as EmptySource and a producer module then, if you run out of events, you have to throw an exception, which works but is not very user friendly.

Andrei has experience writing source modules. You can anexamples in:
Sources/src/FromEMFMARSFileWeighted_source.cc

The interface to art is not via inheritance. Instead you write a "detail class" then the actual source module is the instantiation of a source module template using your detail class as the template argument. It's just a different way for you to provide callbacks that are called by the art code at the right time with the right arguments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid this is beyond my C++ competencies... I left it as it was, also because it is the same approach of CRY, but I am happy to change it with a little of help from more expert people. Also, at the moment the module can't run out of events because if it reaches the last binary file it starts again from the first one, shifting the position of the cosmic rays by a random amount.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I talked with @brownd1978 and I see your point now. I will work on it but it will take a couple of days since I am not very familiar with it. At the moment I was avoiding the "end of the file" problem by starting again from the first file and moving the particle by a random amount (which is basically resampling) but I see it's better to separate the two logics.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote the Source module, however it wasn't as straightforward as I thought: the source module could access the geometry only after the first event had been processed, so I couldn't extrapolate the cosmic rays to the world borders. In order to avoid ugly solutions (such as storing a first empty event) I had to write also a producer which takes as input the output of the Source module and does the backwards extrapolation. I compared the outputs before and after these changes and they are the same.

Comment thread EventGenerator/src/CosmicCORSIKA.cc Outdated
@soleti

soleti commented Oct 23, 2019

Copy link
Copy Markdown
Contributor Author

Regarding the high-level issues:

  1. I don't think we need to package CORSIKA as a UPS product. Right now I just create a tarball of CORSIKA+FLUKA and send a script with jobsub and it works just fine. That's the way we used in MicroBooNE. The art module doesn't require CORSIKA because the output can be read without any CORSIKA library.

  2. About the file format: I don't use sqlite anymore, I read from the CORSIKA binary output directly and it's much faster (~x100). I don't think we need to store the CORSIKA binaries. My workflow idea is:

    1. Generate the CORSIKA binary output
    2. Read the CORSIKA binary file and produce the GenParticleCollection.
    3. Delete the CORSIKA binary output (you would still have the CORSIKA configuration in case you really want to check the binary in the future).
      Since CORSIKA binaries are very large (~4GB for 10000 showers) I think this is the best solution. However I am not sure technically how to implement it.

@kutschke

kutschke commented Oct 23, 2019 via email

Copy link
Copy Markdown
Contributor

@kutschke

kutschke commented Oct 29, 2019 via email

Copy link
Copy Markdown
Contributor

@brownd1978

brownd1978 commented Oct 29, 2019 via email

Copy link
Copy Markdown
Collaborator

@kutschke

kutschke commented Oct 29, 2019 via email

Copy link
Copy Markdown
Contributor

@brownd1978

Copy link
Copy Markdown
Collaborator

We need to disentangle this discussion from Roberto's pull request. If his code does what it's supposed to and isn't wrong we should approve it. We can then fix the Geometry initialization, and after that request updates from dependent code with workarounds.

@kutschke

kutschke commented Oct 29, 2019 via email

Copy link
Copy Markdown
Contributor

@kutschke

kutschke commented Oct 29, 2019 via email

Copy link
Copy Markdown
Contributor

@soleti

soleti commented Oct 31, 2019

Copy link
Copy Markdown
Contributor Author

The latest commit includes both the producer and the source module and it gives the same results of the previous version. My opinion is that it should be merged into master after this review is over and then I will do another pull request once the initialization of the Geometry service gets changed.

@brownd1978

brownd1978 commented Oct 31, 2019 via email

Copy link
Copy Markdown
Collaborator

@sdifalco sdifalco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Rob has already pointed out the most important issues with the interface with art and the rest of the Offline. I consider all the submitted changes worth to be submitted and valuable. I should try to run Corsika to find more potential issues. For the moment I approve the pull request

@kutschke

Copy link
Copy Markdown
Contributor

Here is where I think we stand:

  1. I could not find the issues in the code that Ray mentioned. I would like to see them before I decide if I am ready to sign off.

  2. I just added one comment on a fcl file and clicked start a review - it should be quick to resolve.

  3. I agree that the GeometryService and ups packaging issues can be deferred until later.

So once 1) and 2) are off the table I will be ready to approve.

@rlcee rlcee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After twice clicking on lines of code, entering comment text, and selecting "start a review".
None has seen an email alert or even my comment on github. Now I am filling in
a new box that appeared with a button "submit review".

Also I see my comments are labeled "outdated" probably because the code moved to
a new subdirectory.

Comment thread EventGenerator/src/CosmicCORSIKA.cc Outdated
Comment thread EventGenerator/src/CosmicCORSIKA.cc Outdated
const HepLorentzVector mom4 = particle.momentum();

const Hep3Vector position(
wrapvar(particle.position().x() + _flat(), _targetBoxXmin - _showerAreaExtension, _targetBoxXmax + _showerAreaExtension) + _cosmicReferencePointInMu2e.x(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I am not following the logic. If your accepted range is, for example, 0-10, then particles hitting at 15 get wrapped into 0-10, and so do particles that hit at 25. So it seems that you are potentially compressing the shower. Calling flat on each particle instead of once per event will scramble the shower correlations, won't it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting observation and the logic is explained here: https://internal.dunescience.org/doxygen/classevgen_1_1CORSIKAGen.html#details. I think it makes sense but please let me know if you find a flaw in it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link you point to says that if a shower has particles outside
the detector box, then those are folded into the
detector box, and then treated as a separate event coming at
a separate random time. I don't see that second part -
a separate event at another time. I think there are other ways to
handle it, but the issue of showers larger that the detector box
should be documented in plain English.
It looks like your last talk doesn't discuss it. I'm OK with
finishing this code review with a note that you should still
present a plan on this issue.

@pavel1murat

Copy link
Copy Markdown
Contributor

it looks that I'm the last one left - signing off

@pavel1murat

Copy link
Copy Markdown
Contributor

btw, why the Corsica module goes to Analyses and not EventGenerators?

@soleti

soleti commented Nov 1, 2019 via email

Copy link
Copy Markdown
Contributor Author

@gaponenko

gaponenko commented Nov 1, 2019 via email

Copy link
Copy Markdown
Contributor

@soleti

soleti commented Nov 1, 2019 via email

Copy link
Copy Markdown
Contributor Author

@gaponenko

gaponenko commented Nov 1, 2019 via email

Copy link
Copy Markdown
Contributor

@soleti

soleti commented Nov 1, 2019 via email

Copy link
Copy Markdown
Contributor Author

@kutschke

kutschke commented Nov 4, 2019

Copy link
Copy Markdown
Contributor

Two things.

  1. I don't understand your tiling solution as well as I think I should. Can you give a presentation on that at the meeting this Wednesday?

  2. You have responded to a lot of feedback and made a lot of changes. Have you done a clean clone and rebuild and run a test job?

There have been a lot of changes since you first comm

@soleti

soleti commented Nov 5, 2019 via email

Copy link
Copy Markdown
Contributor Author

@kutschke

kutschke commented Nov 7, 2019

Copy link
Copy Markdown
Contributor

Following yesterdays's talk I propose to merge this pull request today. Unless I hear otherwise I will
do it soon after 1:00 PM Fermilab time.

@kutschke kutschke merged commit 880d02f into Mu2e:master Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants