LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
geo::AuxDetGeometry Class Reference

The geometry of one entire detector, as served by art. More...

#include "AuxDetGeometry.h"

Public Member Functions

 AuxDetGeometry (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 
AuxDetGeometryCore const & GetProvider () const
 Returns a constant reference to the service provider. More...
 
AuxDetGeometryCore const * GetProviderPtr () const
 Returns a constant pointer to the service provider. More...
 

Private Member Functions

void preBeginRun (art::Run const &run)
 Updates the geometry if needed at the beginning of each new run. More...
 
void LoadNewGeometry (std::string gdmlfile, std::string rootfile)
 Expands the provided paths and loads the geometry description(s) More...
 
void InitializeChannelMap ()
 
AuxDetGeometryCoreGetProvider ()
 Returns a reference to the service provider. More...
 
AuxDetGeometryCoreGetProviderPtr ()
 Returns a pointer to the service provider. More...
 

Private Attributes

AuxDetGeometryCore fProvider
 the actual service provider More...
 
std::string fRelPath
 
bool fForceUseFCLOnly
 
fhicl::ParameterSet fSortingParameters
 Parameter set to define the channel map sorting. More...
 

Detailed Description

The geometry of one entire detector, as served by art.

This class extends the interface of the geometry service provider, GeometryCore, to the one of an art service. It handles the correct initialization of the provider using information

It relies on geo::ExptGeoHelperInterface service to obtain the channel mapping algorithm proper for the selected geometry.

The geometry initialization happens immediately on construction. Optionally, the geometry is automatically reinitialized on each run based on the information contained in the art::Run object.

Configuration

In addition to the parameters documented in geo::GeometryCore, the following parameters are supported:

  • RelativePath (string, default: no path): this path is prepended to the geometry file names before searching from them; the path string does not affect the file name
  • GDML (string, mandatory): path of the GDML file to be served to Geant4 for detector simulation. The full file is composed out of the optional relative path specified by RelativePath path and the base name specified in GDML parameter; this path is searched for in the directories configured in the FW_SEARCH_PATH environment variable;
  • ROOT (string, mandatory): currently overridden by GDML parameter, whose value is used instead; this path is assembled in the same way as the one for GDML parameter, except that no alternative (wireless) geometry is used even if DisableWiresInG4 is specified (see below); this file is used to load the geometry used in the internal simulation and reconstruction, basically everywhere except for the Geant4 simulation
  • DisableWiresInG4 (boolean, default: false): if true, Geant4 is loaded with an alternative geometry from a file with the standard name as configured with the /GDML/ parameter, but with an additional "_nowires" appended before the ".gdml" suffix
  • ForceUseFCLOnly (boolean, default: false): information on the current geometry is stored in each run by the event generator producers; if this information does not describe the current geometry, a new geometry is loaded according to the information in the run. If ForceUseFCLOnly is set to true, this mechanism is disabled and the geometry is just loaded at the beginning of the job from the information in the job configuration, once and for all.
  • SortingParameters (a parameter set; default: empty): this configuration is directly passed to the channel mapping algorithm (see geo::ChannelMapAlg); its content is dependent on the chosen implementation of ChannelMapAlg
Note
Currently, the file defined by GDML parameter is also served to ROOT for the internal geometry representation.

Definition at line 83 of file AuxDetGeometry.h.

Constructor & Destructor Documentation

geo::AuxDetGeometry::AuxDetGeometry ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry reg 
)

Definition at line 31 of file AuxDetGeometry.cc.

References fRelPath, LoadNewGeometry(), and preBeginRun().

32  : fProvider(pset)
33  , fRelPath(pset.get<std::string>("RelativePath", ""))
34  , fForceUseFCLOnly(pset.get<bool>("ForceUseFCLOnly", false))
35  , fSortingParameters(pset.get<fhicl::ParameterSet>("SortingParameters", {}))
36  {
37  // add a final directory separator ("/") to fRelPath if not already there
38  if (!fRelPath.empty() && (fRelPath.back() != '/')) fRelPath += '/';
39 
40  // register a callback to be executed when a new run starts
41  reg.sPreBeginRun.watch(this, &AuxDetGeometry::preBeginRun);
42 
43  //......................................................................
44  // 5.15.12 BJR: use the gdml file for both the fGDMLFile and fROOTFile
45  // variables as ROOT v5.30.06 is once again able to read in gdml files
46  // during batch operation, in this case think of fROOTFile meaning the
47  // file used to make the ROOT TGeoManager. I don't want to remove
48  // the separate variables in case ROOT breaks again
49  std::string GDMLFileName = pset.get<std::string>("GDML");
50  std::string ROOTFileName = pset.get<std::string>("GDML");
51 
52  // load the geometry
53  LoadNewGeometry(GDMLFileName, ROOTFileName);
54 
55  } // Geometry::Geometry()
fhicl::ParameterSet fSortingParameters
Parameter set to define the channel map sorting.
void LoadNewGeometry(std::string gdmlfile, std::string rootfile)
Expands the provided paths and loads the geometry description(s)
void preBeginRun(art::Run const &run)
Updates the geometry if needed at the beginning of each new run.
GlobalSignal< detail::SignalResponseType::FIFO, void(Run const &)> sPreBeginRun
AuxDetGeometryCore fProvider
the actual service provider

Member Function Documentation

AuxDetGeometryCore const& geo::AuxDetGeometry::GetProvider ( ) const
inline

Returns a constant reference to the service provider.

Definition at line 88 of file AuxDetGeometry.h.

Referenced by LoadNewGeometry(), and preBeginRun().

88 { return fProvider; }
AuxDetGeometryCore fProvider
the actual service provider
AuxDetGeometryCore& geo::AuxDetGeometry::GetProvider ( )
inlineprivate

Returns a reference to the service provider.

Definition at line 103 of file AuxDetGeometry.h.

103 { return fProvider; }
AuxDetGeometryCore fProvider
the actual service provider
AuxDetGeometryCore const* geo::AuxDetGeometry::GetProviderPtr ( ) const
inline

Returns a constant pointer to the service provider.

Definition at line 91 of file AuxDetGeometry.h.

91 { return &GetProvider(); }
AuxDetGeometryCore const & GetProvider() const
Returns a constant reference to the service provider.
AuxDetGeometryCore* geo::AuxDetGeometry::GetProviderPtr ( )
inlineprivate

Returns a pointer to the service provider.

Definition at line 106 of file AuxDetGeometry.h.

106 { return &GetProvider(); }
AuxDetGeometryCore const & GetProvider() const
Returns a constant reference to the service provider.
void geo::AuxDetGeometry::InitializeChannelMap ( )
private

Definition at line 91 of file AuxDetGeometry.cc.

References geo::AuxDetGeometryCore::ApplyChannelMap(), fProvider, and fSortingParameters.

Referenced by LoadNewGeometry().

92  {
93  // the channel map is responsible of calling the channel map configuration
94  // of the geometry
95  auto channelMap =
96  art::ServiceHandle<geo::AuxDetExptGeoHelperInterface>()->ConfigureAuxDetChannelMapAlg(
98  if (!channelMap) {
99  throw cet::exception("ChannelMapLoadFail") << " failed to load new channel map";
100  }
101  fProvider.ApplyChannelMap(move(channelMap));
102  } // Geometry::InitializeChannelMap()
void ApplyChannelMap(std::unique_ptr< geo::AuxDetChannelMapAlg > pChannelMap)
Initializes the geometry to work with this channel map.
fhicl::ParameterSet fSortingParameters
Parameter set to define the channel map sorting.
AuxDetGeometryCore fProvider
the actual service provider
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void geo::AuxDetGeometry::LoadNewGeometry ( std::string  gdmlfile,
std::string  rootfile 
)
private

Expands the provided paths and loads the geometry description(s)

Definition at line 105 of file AuxDetGeometry.cc.

References fRelPath, GetProvider(), InitializeChannelMap(), and geo::AuxDetGeometryCore::LoadGeometryFile().

Referenced by AuxDetGeometry(), and preBeginRun().

106  {
107  // start with the relative path
108  std::string GDMLFileName(fRelPath), ROOTFileName(fRelPath);
109 
110  // add the base file names
111  ROOTFileName.append(gdmlfile); // not rootfile (why?)
112  GDMLFileName.append(gdmlfile);
113 
114  // Search all reasonable locations for the GDML file that contains
115  // the detector geometry.
116  // cet::search_path constructor decides if initialized value is a path
117  // or an environment variable
118  cet::search_path sp("FW_SEARCH_PATH");
119 
120  std::string GDMLfile;
121  if (!sp.find_file(GDMLFileName, GDMLfile)) {
122  throw cet::exception("AuxDetGeometry") << "cannot find the gdml geometry file:"
123  << "\n"
124  << GDMLFileName << "\nbail ungracefully.\n";
125  }
126 
127  std::string ROOTfile;
128  if (!sp.find_file(ROOTFileName, ROOTfile)) {
129  throw cet::exception("AuxDetGeometry") << "cannot find the root geometry file:\n"
130  << "\n"
131  << ROOTFileName << "\nbail ungracefully.\n";
132  }
133 
134  // initialize the geometry with the files we have found
135  GetProvider().LoadGeometryFile(GDMLfile, ROOTfile);
136 
137  // now update the channel map
139 
140  } // Geometry::LoadNewGeometry()
void LoadGeometryFile(std::string gdmlfile, std::string rootfile)
Loads the geometry information from the specified files.
AuxDetGeometryCore const & GetProvider() const
Returns a constant reference to the service provider.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void geo::AuxDetGeometry::preBeginRun ( art::Run const &  run)
private

Updates the geometry if needed at the beginning of each new run.

Definition at line 57 of file AuxDetGeometry.cc.

References fForceUseFCLOnly, art::ProductRetriever::getMany(), GetProvider(), and LoadNewGeometry().

Referenced by AuxDetGeometry().

58  {
59  // FIXME this seems utterly wrong: constructor loads geometry based on an
60  // explicit parameter, whereas here we load it by detector name
61 
62  // if we are requested to stick to the configured geometry, do nothing
63  if (fForceUseFCLOnly) return;
64 
65  // check here to see if we need to load a new geometry.
66  // get the detector id from the run object
67  //std::vector< art::Handle<sumdata::RunData> > rdcol;
68  //run.getManyByType(rdcol);
69  auto rdcol = run.getMany<sumdata::RunData>();
70  if (rdcol.empty()) {
71  mf::LogWarning("LoadNewGeometry")
72  << "cannot find sumdata::RunData object to grab detector name\n"
73  << "this is expected if generating MC files\n"
74  << "using default geometry from configuration file\n";
75  return;
76  }
77 
78  // if the detector name is still the same, everything is fine
79  std::string newDetectorName = rdcol.front()->DetName();
80  if (GetProvider().DetectorName() == newDetectorName) return;
81 
82  // else {
83  // // the detector name is specified in the RunData object
84  // SetDetectorName(newDetectorName);
85  // }
86 
87  LoadNewGeometry(GetProvider().DetectorName() + ".gdml", GetProvider().DetectorName() + ".gdml");
88  } // Geometry::preBeginRun()
AuxDetGeometryCore const & GetProvider() const
Returns a constant reference to the service provider.
void LoadNewGeometry(std::string gdmlfile, std::string rootfile)
Expands the provided paths and loads the geometry description(s)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning

Member Data Documentation

bool geo::AuxDetGeometry::fForceUseFCLOnly
private

Force Geometry to only use the geometry files specified in the fcl file

Definition at line 112 of file AuxDetGeometry.h.

Referenced by preBeginRun().

AuxDetGeometryCore geo::AuxDetGeometry::fProvider
private

the actual service provider

Definition at line 108 of file AuxDetGeometry.h.

Referenced by InitializeChannelMap().

std::string geo::AuxDetGeometry::fRelPath
private

Relative path added to FW_SEARCH_PATH to search for geometry file

Definition at line 110 of file AuxDetGeometry.h.

Referenced by AuxDetGeometry(), and LoadNewGeometry().

fhicl::ParameterSet geo::AuxDetGeometry::fSortingParameters
private

Parameter set to define the channel map sorting.

Definition at line 114 of file AuxDetGeometry.h.

Referenced by InitializeChannelMap().


The documentation for this class was generated from the following files: