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

Gamma conversion generator #1195

Merged
merged 9 commits into from
Feb 23, 2024
Merged

Gamma conversion generator #1195

merged 9 commits into from
Feb 23, 2024

Conversation

sdifalco
Copy link
Contributor

New complete generator for gamma conversion based on previous Michael Makenzie's module in Su2020 repository. As agreed with Rob the generator will go in the Mu2eG4 directory instead of the usual EventGenerator because it uses some G4 libraries. The SConscript in Mu2eG4/src also needs a fix: mu2e_DataProducts needs to be added in helper.make_plugins

@FNALbuild
Copy link
Collaborator

Hi @sdifalco,
You have proposed changes to files in these packages:

  • Mu2eG4

which require these tests: build.

@Mu2e/fnalbuild-users, @Mu2e/write have access to CI actions on main.

The following users requested to be notified about changes to these packages:
@resnegfk

⌛ The following tests have been triggered for a0d1604: build (Build queue is empty)

About FNALbuild. Code review on Mu2e/Offline.

@FNALbuild
Copy link
Collaborator

☔ The build is failing at a0d1604.

scons: *** [build/sl7-prof-e28-p055/Offline/tmp/Mu2eG4/src/GammaConvGenerator_module.os] Error 1
Test Result Details
test with Command did not list any other PRs to include
merge Merged a0d1604 at 635a10d
build (prof) Log file.
ceSimReco 〰️ Log file.
g4test_03MT 〰️ Log file.
transportOnly 〰️ Log file.
POT 〰️ Log file.
g4study 〰️ Log file.
cosmicSimReco 〰️ Log file.
cosmicOffSpill 〰️ Log file.
ceSteps 〰️ Log file.
ceDigi 〰️ Log file.
muDauSteps 〰️ Log file.
ceMix 〰️ Log file.
rootOverlaps 〰️ Log file.
g4surfaceCheck 〰️ Log file.
FIXME, TODO TODO (0) FIXME (0) in 1 files
clang-tidy 🔶 1 errors 27 warnings
whitespace check no whitespace errors found

N.B. These results were obtained from a build of this Pull Request at a0d1604 after being merged into the base branch at 635a10d.

For more information, please check the job page here.
Build artifacts are deleted after 5 days. If this is not desired, select Keep this build forever on the job page.

@kutschke
Copy link
Collaborator

Adding a comment that I sent to Stefano directly in response to a question from him. it may be of general interest.

Two things about accessing the log file. First, the log files takes a little while (minutes?) to reach their archival location. Often I retry a few minutes later and it works. It worksed for me a minute ago.

Second, and you may already know this: read the section on accessing log files in https://mu2ewiki.fnal.gov/wiki/GitHubWorkflow#GitHub_Pull_Request_Procedures_and_FNALbuild

The log file says that the problem occurs when compiling the module:

Offline/Mu2eG4/src/GammaConvGenerator_module.cc:28:10: fatal error: Offline/Mu2eUtilities/inc/GammaPairConversionSpectrum.hh: No such file or directory
28 | #include "Offline/Mu2eUtilities/inc/GammaPairConversionSpectrum.hh"

It looks like you are missing a header file – does it also have a matching .cc?

@FNALbuild
Copy link
Collaborator

📝 The HEAD of main has changed to 666d876. Tests are now out of date.

@sdifalco
Copy link
Contributor Author

@FNALbuild run build test

@FNALbuild
Copy link
Collaborator

⌛ The following tests have been triggered for 293938e: build (Build queue is empty)

@FNALbuild
Copy link
Collaborator

☀️ The build tests passed at 293938e.

Test Result Details
test with Command did not list any other PRs to include
merge Merged 293938e at 666d876
build (prof) Log file. Build time: 11 min 03 sec
ceSimReco Log file.
g4test_03MT Log file.
transportOnly Log file.
POT Log file.
g4study Log file.
cosmicSimReco Log file.
cosmicOffSpill Log file.
ceSteps Log file.
ceDigi Log file.
muDauSteps Log file.
ceMix Log file.
rootOverlaps Log file.
g4surfaceCheck Log file.
FIXME, TODO TODO (0) FIXME (0) in 3 files
clang-tidy 🔶 0 errors 135 warnings
whitespace check no whitespace errors found

N.B. These results were obtained from a build of this Pull Request at 293938e after being merged into the base branch at 666d876.

For more information, please check the job page here.
Build artifacts are deleted after 5 days. If this is not desired, select Keep this build forever on the job page.

}
//const auto& vols = PhysicalVolumeInfos->at(gammapart->simStage());
/*
PhysicalVolumeInfoSingleStage const* vols = &PhysicalVolumeInfos->at(gammapart->simStage());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please either remove the commented out code or put it behind a verbosity level. The one exception to this request is if the commented out code is something in development.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

}
G4Material*stopMat = findMaterialOrThrow((G4String const& )endInfo.materialName());
*/
G4Material*stopMat = findMaterialOrThrow((G4String const& )stopMaterial_);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am 99% sure that geometry and materials are defined at beginRun time. So you can move the lookup of the element fractions to beginRun and save only the information you need.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

geometry readout moved to beginrun

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unnecessary PhysVol collection unpacking deleted

}

// Take the converted gamma as SimParticle
const auto gammapart = gammas.at(eng_.operator unsigned int() % gammas.size());
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not guaranteed to uniformly sample the set of gammas. The effect is negligible. Did you do it this way since it's advertised as being faster than randFlat_,fireInt( gammas.size());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have inherited this from Michael's code. If you think it's better I can use randFlat.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changing to what is suggested

@sdifalco
Copy link
Contributor Author

@FNALbuild run build test

@kutschke
Copy link
Collaborator

@sdifalco please let me know when your are finished with this set of commits and I will rerun the CI

@FNALbuild
Copy link
Collaborator

⌛ The following tests have been triggered for 71d94e3: build (Build queue has 1 jobs)

@sdifalco
Copy link
Contributor Author

I have deleted the commented code I have found.
The map is now private (no need for a set function, a get function is enough for what I see)
I don't see the requested change inline in the code to avoid memory leakage: was this one?
Thanks

@sdifalco
Copy link
Contributor Author

Now I have warnings from
std::array <const double,3> sf1a={42.038,-8.29,0.958};
like "2.038 is a magic number; consider replacing it with a named constant"
should I have used
const std::array <double,3> sf1a={42.038,-8.29,0.958};
?

Thanks

@sdifalco
Copy link
Contributor Author

@FNALbuild run build test

@FNALbuild
Copy link
Collaborator

⌛ The following tests have been triggered for 71e9a7b: build (Build queue has 1 jobs)

@kutschke
Copy link
Collaborator

kutschke commented Feb 22, 2024 via email

@kutschke
Copy link
Collaborator

Now I have warnings from std::array <const double,3> sf1a={42.038,-8.29,0.958}; like "2.038 is a magic number; consider replacing it with a named constant" should I have used const std::array <double,3> sf1a={42.038,-8.29,0.958}; ?

Thanks

Let me check on thing - it will take 5 minutes.

@kutschke
Copy link
Collaborator

.... I think it is suggesting:

constexpr std::array<double,3> sfa1{42.038,-8.29,0.958};

And a small detail. Where you have:
const double FZ_const=8.;

If you write that as
constexpr double FZ_const=8.;

it gives the compiler more information. It explicitly says that FZ_const is a compile time constant and the optimizer may treat it as such. The way that your wrote it, it's very likely the optimizer will figure that out but it has to do some work to do so. It's not a big deal but it is an example of just do it right all of the time so that when it matters you will just do it right.

@FNALbuild
Copy link
Collaborator

☀️ The build tests passed at 71e9a7b.

Test Result Details
test with Command did not list any other PRs to include
merge Merged 71e9a7b at 07adcaa
build (prof) Log file. Build time: 11 min 19 sec
ceSimReco Log file.
g4test_03MT Log file.
transportOnly Log file.
POT Log file.
g4study Log file.
cosmicSimReco Log file.
cosmicOffSpill Log file.
ceSteps Log file.
ceDigi Log file.
muDauSteps Log file.
ceMix Log file.
rootOverlaps Log file.
g4surfaceCheck Log file.
FIXME, TODO TODO (0) FIXME (0) in 3 files
clang-tidy 🔶 0 errors 71 warnings
whitespace check no whitespace errors found

N.B. These results were obtained from a build of this Pull Request at 71e9a7b after being merged into the base branch at 07adcaa.

For more information, please check the job page here.
Build artifacts are deleted after 5 days. If this is not desired, select Keep this build forever on the job page.

@kutschke
Copy link
Collaborator

You only need this much:

spectrum_ (&randFlat_, useCorrelatedAngleOverKE_)

@sdifalco
Copy link
Contributor Author

I had to add static in front of constexpr to compile
I have fixed the memory leak as suggested
Thanks

@sdifalco
Copy link
Contributor Author

@FNALbuild run build test

@FNALbuild
Copy link
Collaborator

⌛ The following tests have been triggered for a6ea179: build (Build queue is empty)

@kutschke
Copy link
Collaborator

I had to add static in front of constexpr to compile I have fixed the memory leak as suggested Thanks

Thanks - I forgot about the static. Good catch. It's needed for constexpr data members but it is not needed for constexpr stack variables in function scope.

Presuming the CI goes well, I will merge tonight.

@FNALbuild
Copy link
Collaborator

☀️ The build tests passed at a6ea179.

Test Result Details
test with Command did not list any other PRs to include
merge Merged a6ea179 at 07adcaa
build (prof) Log file. Build time: 11 min 02 sec
ceSimReco Log file.
g4test_03MT Log file.
transportOnly Log file.
POT Log file.
g4study Log file.
cosmicSimReco Log file.
cosmicOffSpill Log file.
ceSteps Log file.
ceDigi Log file.
muDauSteps Log file.
ceMix Log file.
rootOverlaps Log file.
g4surfaceCheck Log file.
FIXME, TODO TODO (0) FIXME (0) in 3 files
clang-tidy 🔶 0 errors 53 warnings
whitespace check no whitespace errors found

N.B. These results were obtained from a build of this Pull Request at a6ea179 after being merged into the base branch at 07adcaa.

For more information, please check the job page here.
Build artifacts are deleted after 5 days. If this is not desired, select Keep this build forever on the job page.

@kutschke kutschke merged commit 5ad1433 into Mu2e:main Feb 23, 2024
14 checks passed
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.

4 participants