LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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)
 
void preBeginRun (art::Run const &run)
 Updates the geometry if needed at the beginning of each new run. More...
 
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 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 97 of file AuxDetGeometry.h.

Constructor & Destructor Documentation

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

Definition at line 31 of file AuxDetGeometry_service.cc.

References fRelPath, fhicl::ParameterSet::get(), LoadNewGeometry(), preBeginRun(), and art::ActivityRegistry::sPreBeginRun.

32  : fProvider (pset)
33  , fRelPath (pset.get< std::string >("RelativePath", "" ))
34  , fForceUseFCLOnly (pset.get< bool >("ForceUseFCLOnly" , false))
35  , fSortingParameters(pset.get<fhicl::ParameterSet>("SortingParameters", fhicl::ParameterSet() ))
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 107 of file AuxDetGeometry.h.

References fProvider.

Referenced by GetProviderPtr(), InitializeChannelMap(), LoadNewGeometry(), and preBeginRun().

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

Returns a reference to the service provider.

Definition at line 120 of file AuxDetGeometry.h.

References fProvider.

120 { 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 110 of file AuxDetGeometry.h.

References GetProvider(), InitializeChannelMap(), and LoadNewGeometry().

Referenced by InitializeChannelMap().

110 { 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 123 of file AuxDetGeometry.h.

References GetProvider().

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

Definition at line 94 of file AuxDetGeometry_service.cc.

References fSortingParameters, GetProvider(), GetProviderPtr(), and geo::AuxDetGeometryCore::hasAuxDetChannelMap().

Referenced by GetProviderPtr(), and LoadNewGeometry().

95  {
96  // the channel map is responsible of calling the channel map configuration
97  // of the geometry
99 
100  if ( ! GetProvider().hasAuxDetChannelMap() ) {
101  throw cet::exception("ChannelMapLoadFail") << " failed to load new channel map";
102  }
103 
104  } // Geometry::InitializeChannelMap()
AuxDetGeometryCore const * GetProviderPtr() const
Returns a constant pointer to the service provider.
fhicl::ParameterSet fSortingParameters
Parameter set to define the channel map sorting.
AuxDetGeometryCore const & GetProvider() const
Returns a constant reference to the service provider.
bool hasAuxDetChannelMap() const
Returns whether we have a channel map.
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 107 of file AuxDetGeometry_service.cc.

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

Referenced by AuxDetGeometry(), GetProviderPtr(), and preBeginRun().

108  {
109  // start with the relative path
110  std::string GDMLFileName(fRelPath), ROOTFileName(fRelPath);
111 
112  // add the base file names
113  ROOTFileName.append(gdmlfile); // not rootfile (why?)
114  GDMLFileName.append(gdmlfile);
115 
116  // Search all reasonable locations for the GDML file that contains
117  // the detector geometry.
118  // cet::search_path constructor decides if initialized value is a path
119  // or an environment variable
120  cet::search_path sp("FW_SEARCH_PATH");
121 
122  std::string GDMLfile;
123  if( !sp.find_file(GDMLFileName, GDMLfile) ) {
124  throw cet::exception("AuxDetGeometry") << "cannot find the gdml geometry file:"
125  << "\n" << GDMLFileName
126  << "\nbail ungracefully.\n";
127  }
128 
129  std::string ROOTfile;
130  if( !sp.find_file(ROOTFileName, ROOTfile) ) {
131  throw cet::exception("AuxDetGeometry") << "cannot find the root geometry file:\n"
132  << "\n" << ROOTFileName
133  << "\nbail ungracefully.\n";
134  }
135 
136  // initialize the geometry with the files we have found
137  GetProvider().LoadGeometryFile(GDMLfile, ROOTfile);
138 
139  // now update the channel map
141 
142  } // 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)

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

Definition at line 58 of file AuxDetGeometry_service.cc.

References fForceUseFCLOnly, art::DataViewImpl::getManyByType(), GetProvider(), and LoadNewGeometry().

Referenced by AuxDetGeometry().

59  {
60  // FIXME this seems utterly wrong: constructor loads geometry based on an
61  // explicit parameter, whereas here we load it by detector name
62 
63  // if we are requested to stick to the configured geometry, do nothing
64  if (fForceUseFCLOnly) return;
65 
66  // check here to see if we need to load a new geometry.
67  // get the detector id from the run object
68  std::vector< art::Handle<sumdata::RunData> > rdcol;
69  run.getManyByType(rdcol);
70  if (rdcol.empty()) {
71  mf::LogWarning("LoadNewGeometry") << "cannot find sumdata::RunData object to grab detector name\n"
72  << "this is expected if generating MC files\n"
73  << "using default geometry from configuration file\n";
74  return;
75  }
76 
77  // if the detector name is still the same, everything is fine
78  std::string newDetectorName = rdcol.front()->DetName();
79  if (GetProvider().DetectorName() == newDetectorName) return;
80 
81  // else {
82  // // the detector name is specified in the RunData object
83  // SetDetectorName(newDetectorName);
84  // }
85 
87  GetProvider().DetectorName() + ".gdml",
88  GetProvider().DetectorName() + ".gdml"
89  );
90  } // 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 130 of file AuxDetGeometry.h.

Referenced by preBeginRun().

AuxDetGeometryCore geo::AuxDetGeometry::fProvider
private

the actual service provider

Definition at line 126 of file AuxDetGeometry.h.

Referenced by GetProvider().

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

Relative path added to FW_SEARCH_PATH to search for geometry file

Definition at line 128 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 132 of file AuxDetGeometry.h.

Referenced by InitializeChannelMap().


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