spradlin / WCSim

The WCSim GEANT4 application
0 stars 0 forks source link

Check parsed bin boundaries for cosmics in WCSimPrimaryGeneratorAction #11

Open spradlin opened 2 years ago

spradlin commented 2 years ago

Warnings in WCSimPrimaryGeneratorAction

Warning text

Compiling WCSimPrimaryGeneratorAction.cc ...
src/WCSimPrimaryGeneratorAction.cc: In constructor ‘WCSimPrimaryGeneratorAction::WCSimPrimaryGeneratorAction(WCSimDetectorConstruction*)’:
src/WCSimPrimaryGeneratorAction.cc:122:12: warning: variable ‘cosThetaMean’ set but not used [-Wunused-but-set-variable]
     double cosThetaMean, cosThetaMin, cosThetaMax;
            ^
src/WCSimPrimaryGeneratorAction.cc:122:26: warning: variable ‘cosThetaMin’ set but not used [-Wunused-but-set-variable]
     double cosThetaMean, cosThetaMin, cosThetaMax;
                          ^
src/WCSimPrimaryGeneratorAction.cc:122:39: warning: variable ‘cosThetaMax’ set but not used [-Wunused-but-set-variable]
     double cosThetaMean, cosThetaMin, cosThetaMax;
                                       ^
src/WCSimPrimaryGeneratorAction.cc:123:12: warning: variable ‘phiMean’ set but not used [-Wunused-but-set-variable]
     double phiMean, phiMin, phiMax;
            ^
src/WCSimPrimaryGeneratorAction.cc:123:21: warning: variable ‘phiMin’ set but not used [-Wunused-but-set-variable]
     double phiMean, phiMin, phiMax;
                     ^
src/WCSimPrimaryGeneratorAction.cc:123:29: warning: variable ‘phiMax’ set but not used [-Wunused-but-set-variable]
     double phiMean, phiMin, phiMax;
                             ^

These warnings may indicate a real issue. These unused variables are part of the parsing input file to populate the histograms for simulating the cosmic muon flux. In the input files, like data/MuonFlux-HyperK-ThetaPhi.dat, the values that are parsed into these unused variables appear to define the bin centers and boundaries. The cosimic histos are two-dimensional in polar angles theta and phi.

This looks like an incomplete implementation to me. Instead of using the parsed values to establish the bin boundaries of the generator histograms, the WCSimPrimaryGeneratorAction constructor uses its own hard-coded bin partition without even checking for consistency. This is an issue waiting to happen.

Inconclusive

I have created an issue stub to follow-up on this.

Originally posted by @spradlin in https://github.com/spradlin/WCSim/issues/9#issuecomment-1002219110

spradlin commented 2 years ago

Also check that the histogram is being populated correctly. It looks like there is an off-by-one problem in the bin indexing. The input file data/MuonFlux-HyperK-ThetaPhi.dat uses 0-based indexing rather than Root's 1-based convention.