Skip to content

Commit

Permalink
Merge pull request #765 from kutschke/separateBFieldConfig
Browse files Browse the repository at this point in the history
Separate B field config
  • Loading branch information
brownd1978 authored Apr 19, 2022
2 parents d62b7ef + 918b85c commit 2326667
Show file tree
Hide file tree
Showing 25 changed files with 39 additions and 189 deletions.
2 changes: 1 addition & 1 deletion Analyses/fcl/DSBFieldDump.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services : {
GlobalConstantsService : { inputFile : "Offline/GlobalConstantsService/data/globalConstants_01.txt" }
GeometryService : {
inputFile : "Offline/Mu2eG4/geom/geom_common.txt"
bFieldFile : "Offline/Mu2eG4/geom/bfgeom_reco_v01.txt"
simulatedDetector : { tool_type: "Mu2e" }
}
TFileService: {
Expand Down Expand Up @@ -40,4 +41,3 @@ physics : {
e1 : [BFieldPlotter]
end_paths : [e1]
}
services.GeometryService.inputFile : "Offline/Mu2eG4/geom/geom_common_reco.txt"
2 changes: 1 addition & 1 deletion Analyses/fcl/DSField.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ physics : {
e1 : [BFieldPlotter]
end_paths : [e1]
}
services.GeometryService.inputFile : "Offline/Mu2eG4/geom/geom_common_no_tsu_ps.txt"
services.GeometryService.bFieldFile : "Offline/Mu2eG4/geom/bfgeom_no_tsu_ps_v01.txt"
15 changes: 10 additions & 5 deletions GeometryService/inc/GeometryService.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public:
struct Config {
using Name=fhicl::Name;
using Comment=fhicl::Comment;
fhicl::Atom<std::string> inputFile{Name("inputFile"),""};
fhicl::Atom<std::string> inputFile{Name("inputFile")};
fhicl::Atom<std::string> bFieldFile{Name("bFieldFile")};
fhicl::Atom<bool> allowReplacement{Name("allowReplacement"),true};
fhicl::Atom<bool> messageOnReplacement{Name("messageOnReplacement"),false};
fhicl::Atom<bool> messageOnDefault{Name("messageOnDefault"),false};
Expand Down Expand Up @@ -103,19 +104,23 @@ private:
// Some day this will become a database key or similar.
std::string _inputfile;

// The name of the file that contains the configuration of the B fields.
std::string _bFieldFile;

// Control the behaviour of messages from the SimpleConfig object holding
// the geometry parameters.
// the geometry parameters. These affect both SimpleConfig objects.
bool _allowReplacement;
bool _messageOnReplacement;
bool _messageOnDefault;
int _configStatsVerbosity;

// Print final config file after all replacements.
// Print final config file after all replacements. These affect both SimpleConfig objects.
bool _printConfig;
bool _printTopLevel;

// The object that parses run-time configuration file.
// The objects that parse the run-time configuration files.
std::unique_ptr<SimpleConfig> _config;
std::unique_ptr<SimpleConfig> _bfConfig;

const fhicl::ParameterSet _simulatedDetector;

Expand Down Expand Up @@ -166,7 +171,7 @@ private:
DetMap _detectors;

// Keep a count of how many runs we have seen.
int _run_count;
int _run_count = 0;

// This is not copyable or assignable - private and unimplemented.
GeometryService const& operator=(GeometryService const& rhs);
Expand Down
27 changes: 19 additions & 8 deletions GeometryService/src/GeometryService_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ namespace mu2e {
GeometryService::GeometryService( const Parameters& pars,
art::ActivityRegistry&iRegistry) :
_inputfile( pars().inputFile()),
_bFieldFile( pars().bFieldFile()),
_allowReplacement( pars().allowReplacement()),
_messageOnReplacement( pars().messageOnReplacement()),
_messageOnDefault( pars().messageOnDefault()),
Expand All @@ -106,8 +107,7 @@ namespace mu2e {
_config(nullptr),
_simulatedDetector( pars.get_PSet().get<fhicl::ParameterSet>("simulatedDetector")),
_standardMu2eDetector( _simulatedDetector.get<std::string>("tool_type") == "Mu2e"),
_detectors(),
_run_count()
_detectors()
{
iRegistry.sPreBeginRun.watch(this, &GeometryService::preBeginRun);
iRegistry.sPostEndJob.watch (this, &GeometryService::postEndJob );
Expand Down Expand Up @@ -149,17 +149,25 @@ namespace mu2e {
GeometryService::preBeginRun(art::Run const &) {

if(++_run_count > 1) {
mf::LogWarning("GEOM") << "This test version does not change geometry on run boundaries.";
if( _run_count == 2 ){
mf::LogWarning("GEOM") << "This test version does not change geometry on run boundaries.";
}
return;
}

_config = unique_ptr<SimpleConfig>(new SimpleConfig(_inputfile,
_allowReplacement,
_messageOnReplacement,
_messageOnDefault ));

_config->printOpen(cout,"Geometry");

_bfConfig = unique_ptr<SimpleConfig>(new SimpleConfig(_bFieldFile,
_allowReplacement,
_messageOnReplacement,
_messageOnDefault ));
_bfConfig->printOpen(cout,"BField");


if(_printTopLevel) {
//print the top level geometry file contents
//the top level often contains a single named config file or a list of specific version files
Expand Down Expand Up @@ -337,8 +345,8 @@ namespace mu2e {
}


if(_config->getBool("hasBFieldManager",false)){
std::unique_ptr<BFieldConfig> bfc( BFieldConfigMaker(*_config, beamline).getBFieldConfig() );
if(_bfConfig->getBool("hasBFieldManager",false)){
std::unique_ptr<BFieldConfig> bfc( BFieldConfigMaker(*_bfConfig, beamline).getBFieldConfig() );
BFieldManagerMaker bfmgr(*bfc);
addDetector(std::move(bfc));
addDetector(bfmgr.getBFieldManager());
Expand Down Expand Up @@ -390,11 +398,14 @@ namespace mu2e {

// Called after all modules have completed their end of job.
void GeometryService::postEndJob(){
_config->printAllSummaries( cout, _configStatsVerbosity, "Geom: " );
if ( _configStatsVerbosity <= 0 ) return;
ofstream gStats("geomStats.log");
_config ->printAllSummaries( gStats, _configStatsVerbosity, "" );
ofstream bStats("bFieldStats.log");
_bfConfig->printAllSummaries( bStats, _configStatsVerbosity, "" );
}



} // end namespace mu2e

DEFINE_ART_SERVICE(mu2e::GeometryService);
1 change: 1 addition & 0 deletions Mu2eG4/fcl/surfaceCheck.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ services.SeedService.maxUniqueEngines : 20
physics.producers.generate.inputfile : "Offline/EventGenerator/defaultConfigs/surfaceCheck.txt"

services.GeometryService.inputFile : "Offline/Mu2eG4/geom/geom_SurfaceCheck.txt"
services.GeometryService.bFieldFile : "Offline/Mu2eG4/geom/bfgeom_no_field.txt"
services.TFileService.fileName : "surfaceCheck.root"

2 changes: 2 additions & 0 deletions Mu2eG4/geom/bfgeom_no_field.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// - bfgeom_no_field.txt ( Magnetic field is zero everywhere )
//

bool hasBFieldManager = true;

// Form of DS field: 0 is full field;
// 1 is full upstream, const downstream;
// 2 is const throughout
Expand Down
2 changes: 2 additions & 0 deletions Mu2eG4/geom/bfgeom_v01.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// - bfgeam_DS50_reco_v01.txt ( DS field reduced to 50% and only maps needed for reconstrucion )
//

bool hasBFieldManager = true;

// Form of DS field: 0 is full field;
// 1 is full upstream, const downstream;
// 2 is const throughout
Expand Down
4 changes: 0 additions & 4 deletions Mu2eG4/geom/geom_2021_PhaseI_v02.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ bool hasProtonAbsorber = true;
bool hasTSdA = true;
bool hasExternalShielding = true;
bool hasDiskCalorimeter = true;
bool hasBFieldManager = true;
bool hasBeamline = true;
bool hasVirtualDetector = true; // some components, e.g. ProtonAbsorber assume vd presence now;
bool hasCosmicRayShield = true;
Expand Down Expand Up @@ -84,9 +83,6 @@ double mu2e.detectorSystemZ0 = 10171.; // mm G4BL: (17730-7292=9801 mm)
// Production target beam-scanning detectors
#include "Offline/Mu2eG4/geom/PTM.txt"

// Magnetic field maps
#include "Offline/Mu2eG4/geom/bfgeom_v01.txt"

//---------------------------------------
// Virtual detectors
//---------------------------------------
Expand Down
3 changes: 0 additions & 3 deletions Mu2eG4/geom/geom_SurfaceCheck.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ int g4.nSurfaceCheckPointsPercmsq = 1;
int g4.minSurfaceCheckPoints = 100; // per volume
int g4.maxSurfaceCheckPoints = 10000000; // per volume

vector<string> bfield.innerMaps = {};
vector<string> bfield.outerMaps = {};

// This tells emacs to view this file in c++ mode.
// Local Variables:
// mode:c++
Expand Down
3 changes: 0 additions & 3 deletions Mu2eG4/geom/geom_SurfaceCheck_Select.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ int g4.nSurfaceCheckPointsPercmsq = 1;
int g4.minSurfaceCheckPoints = 100; // per volume
int g4.maxSurfaceCheckPoints = 10000000; // per volume

vector<string> bfield.innerMaps = {};
vector<string> bfield.outerMaps = {};

// This tells emacs to view this file in c++ mode.
// Local Variables:
// mode:c++
Expand Down
11 changes: 0 additions & 11 deletions Mu2eG4/geom/geom_common_DS50.txt

This file was deleted.

12 changes: 0 additions & 12 deletions Mu2eG4/geom/geom_common_DS50_no_ds.txt

This file was deleted.

12 changes: 0 additions & 12 deletions Mu2eG4/geom/geom_common_DS50_no_tsu_ps.txt

This file was deleted.

12 changes: 0 additions & 12 deletions Mu2eG4/geom/geom_common_DS50_reco.txt

This file was deleted.

3 changes: 0 additions & 3 deletions Mu2eG4/geom/geom_common_extracted.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
// Start from recent baseline geometry
#include "Offline/Mu2eG4/geom/geom_common.txt"

// Set the magnetic field to zero everywhere.
#include "Offline/Mu2eG4/geom/bfgeom_no_field.txt"

// Special - for garage position!
bool inGaragePosition = true;
double garage.zOffset = 14000.0; // for creating special garageFakeDS(2/3)Vacuum volume
Expand Down
12 changes: 0 additions & 12 deletions Mu2eG4/geom/geom_common_muplus_DS50.txt

This file was deleted.

13 changes: 0 additions & 13 deletions Mu2eG4/geom/geom_common_muplus_DS50_no_ds.txt

This file was deleted.

13 changes: 0 additions & 13 deletions Mu2eG4/geom/geom_common_muplus_DS50_no_tsu_ps.txt

This file was deleted.

12 changes: 0 additions & 12 deletions Mu2eG4/geom/geom_common_muplus_no_ds.txt

This file was deleted.

12 changes: 0 additions & 12 deletions Mu2eG4/geom/geom_common_muplus_no_tsu_ps.txt

This file was deleted.

13 changes: 0 additions & 13 deletions Mu2eG4/geom/geom_common_no_ds.txt

This file was deleted.

11 changes: 0 additions & 11 deletions Mu2eG4/geom/geom_common_no_field.txt

This file was deleted.

13 changes: 0 additions & 13 deletions Mu2eG4/geom/geom_common_no_tsu_ps.txt

This file was deleted.

14 changes: 0 additions & 14 deletions Mu2eG4/geom/geom_common_reco.txt

This file was deleted.

4 changes: 3 additions & 1 deletion fcl/standardServices.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ Services : {
# a complete job
Core : {
message : @local::default_message
GeometryService : { inputFile : "Offline/Mu2eG4/geom/geom_common.txt"
GeometryService : {
inputFile : "Offline/Mu2eG4/geom/geom_common.txt"
bFieldFile : "Offline/Mu2eG4/geom/bfgeom_v01.txt"
simulatedDetector : { tool_type: "Mu2e" }
}
ConditionsService : { conditionsfile : "Offline/ConditionsService/data/conditions_01.txt" }
Expand Down

0 comments on commit 2326667

Please sign in to comment.