spradlin / WCSim

The WCSim GEANT4 application
0 stars 0 forks source link

Clean up commented tables in WCSimConstructMaterials.cc #12

Open spradlin opened 2 years ago

spradlin commented 2 years ago

Warnings in WCSimConstructMaterials.cc

src/WCSimConstructMaterials.cc is an implementation file for class WCSimDetectorConstruction.

Warning text

Compiling WCSimConstructMaterials.cc ...
src/WCSimConstructMaterials.cc: In member function ‘void WCSimDetectorConstruction::ConstructMaterials()’:
src/WCSimConstructMaterials.cc:30:15: warning: unused variable ‘Vacuum’ [-Wunused-variable]
   G4Material* Vacuum =
               ^
src/WCSimConstructMaterials.cc:301:12: warning: unused variable ‘PPCKOV’ [-Wunused-variable]
   G4double PPCKOV[NUMENTRIES] =
            ^
src/WCSimConstructMaterials.cc:519:13: warning: unused variable ‘MIE_water’ [-Wunused-variable]
    G4double MIE_water[NUMENTRIES_water] = {
             ^
src/WCSimConstructMaterials.cc:551:13: warning: unused variable ‘MIE_water_const’ [-Wunused-variable]
    G4double MIE_water_const[3]={0.4,0.,1};// gforward, gbackward, forward backward ratio
             ^
src/WCSimConstructMaterials.cc:717:13: warning: unused variable ‘MIE_air’ [-Wunused-variable]
    G4double MIE_air[NUMENTRIES_water] =
             ^
src/WCSimConstructMaterials.cc:729:13: warning: unused variable ‘MIE_air_const’ [-Wunused-variable]
    G4double MIE_air_const[3]={0.99,0.99,0.8};// gforward, gbackward, forward backward ratio
             ^
src/WCSimConstructMaterials.cc:893:10: warning: unused variable ‘no_absorption’ [-Wunused-variable]
   double no_absorption = 1000.*m;
          ^
src/WCSimConstructMaterials.cc:894:10: warning: unused variable ‘immediate_absorption’ [-Wunused-variable]
   double immediate_absorption = 0.*m;
          ^

Unused variable Vacuum

This is a case in which a necessary allocator returns a pointer that is never used directly:

  G4Material* Vacuum = 
    new G4Material("Vacuum", 1., a, density,
                   kStateGas,temperature,pressure);

I commented out the variable declaration and assignment, but left the allocation call.

Unused property values

src/WCSimConstructMaterials.cc is riddled with what appear to be commented-out data tables. I do not know much about their history, but i would guess that this mess evolved organically, and that some of the tables are commented out rather than removed for ease of selecting alternatives. This is not a good way to handle this kind of thing.

For now, i can comment-out the unused arrays. This looks like it should have some follow-up and review to clean up the vestigial code.

Conclusion

After these changes, there are no more compiler warnings from WCSimConstructMaterials.cc.

However, the vestigial code in it should be reviewed and cleaned up.

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