next-exp / nexus

Geant4 simulation framework of the NEXT Collaboration
5 stars 55 forks source link

Dist sampler #171

Closed kvjmistry closed 1 year ago

kvjmistry commented 2 years ago

This PR creates two classes in utilities: FileReaderCSV and DistributionSampler. They contain generic functions used in the muon angle generator so any 1D, 2D and 3D input distribution (as a csv file) can be sampled from to produce a variable that follows the input distribution.

The muon angle generator class has been updated to use these functions as a use case.

Also add the option to not smear the sampled events controlled with a bool in case we want to generate events without smearing.

paolafer commented 1 year ago

I've realized that there are two sets of example macros using the MuonAngleGenerator class: one with the hallA label and the other one with the lsc label. The only difference I see (apart from the kind of simulation file used - although in both the other one is present, commented) is the region of generation and the angles_on parameter. In the former case, it is the hall A walls, and in the latter a surface just outside the lead castle. I understand that in this second case the file with the angle distribution is not necessary in the example, right? I would either make two different examples, with a different description to explain their use, or eliminate one of the two examples and add a commented line with the second option for the region, provided that we use it currently in some cases. @pnovella is the surface outside the castle (EXTERNAL region) without angle sampling used currently in the cosmogenic simulation?

kvjmistry commented 1 year ago

If the angles_on parameter is false, muons are simulated coming in the (0, 1, 0) direction: is that the expected behaviour? Is there any real case where we want that behaviour?

Right, this just simulated muons coming from top down. I can't think of anyone using this case for something useful. I am thinking when the angles_on is false, we should actually be using the MuonGenerator class functionality, but its in a different class. I wonder if it makes sense to merge these two classes where we use the MuonGenerator.cc code for angles_on = false and the existing MuonAngleGenerator.cc code for when angles_on = true. What do you think?

paolafer commented 1 year ago

If the angles_on parameter is false, muons are simulated coming in the (0, 1, 0) direction: is that the expected behaviour? Is there any real case where we want that behaviour?

Right, this just simulated muons coming from top down. I can't think of anyone using this case for something useful. I am thinking when the angles_on is false, we should actually be using the MuonGenerator class functionality, but its in a different class. I wonder if it makes sense to merge these two classes where we use the MuonGenerator.cc code for angles_on = false and the existing MuonAngleGenerator.cc code for when angles_on = true. What do you think?

I think it's a good idea. We could keep just one class (MuonGenerator seems the clearest name to me) and select if we want the sea level, no shielding or the LSC angular distribution via a parameter. I would remove the possibility of the (0, -1, 0) direction, if it's not used. Maybe the parameter could be called lsc, instead of angles_on, to make it clearer that it is the distribution at the LSC. In any case, a few lines of comments can also be placed in the code.

kvjmistry commented 1 year ago

Latest changes include:

kvjmistry commented 1 year ago
paolafer commented 1 year ago

@jmalbos, you were the original reviewer of this PR: do you have any further comments?