Public Member Functions | Private Member Functions | Private Attributes | List of all members
gar::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:

Note
Currently, the file defined by GDML parameter is also served to ROOT for the internal geometry representation.

Definition at line 96 of file AuxDetGeometry.h.

Constructor & Destructor Documentation

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

Definition at line 30 of file AuxDetGeometry_service.cc.

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

Member Function Documentation

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

Returns a constant reference to the service provider.

Definition at line 106 of file AuxDetGeometry.h.

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

Returns a reference to the service provider.

Definition at line 119 of file AuxDetGeometry.h.

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

Returns a constant pointer to the service provider.

Definition at line 109 of file AuxDetGeometry.h.

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

Returns a pointer to the service provider.

Definition at line 122 of file AuxDetGeometry.h.

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

Definition at line 85 of file AuxDetGeometry_service.cc.

86  {
87  // the channel map is responsible of calling the channel map configuration
88  // of the geometry
90  GetProviderPtr());
91  if ( !GetProvider().hasAuxDetChannelMap() ) {
92  throw cet::exception("ChannelMapLoadFail") << " failed to load new channel map";
93  }
94 
95  } // Geometry::InitializeChannelMap()
fhicl::ParameterSet fSortingParameters
Parameter set to define the channel map sorting.
AuxDetGeometryCore const & GetProvider() const
Returns a constant reference to the service provider.
AuxDetGeometryCore const * GetProviderPtr() const
Returns a constant pointer 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 gar::geo::AuxDetGeometry::LoadNewGeometry ( std::string  gdmlfile,
std::string  rootfile 
)
private

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

Definition at line 98 of file AuxDetGeometry_service.cc.

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

59  {
60  // if we are requested to stick to the configured geometry, do nothing
61  if (fForceUseFCLOnly) return;
62 
63  // check here to see if we need to load a new geometry.
64  // get the detector id from the run object
65  auto rdcol = run.getMany<sumdata::RunData>();
66  if (rdcol.empty()) {
67  MF_LOG_WARNING("LoadNewGeometry")
68  << "cannot find sumdata::RunData object to grab detector name\n"
69  << "this is expected if generating MC files\n"
70  << "using default geometry from configuration file\n";
71  return;
72  }
73 
74  // if the detector name is still the same, everything is fine
75  std::string newDetectorName = rdcol.front()->DetName();
76  if (GetProvider().DetectorName() == newDetectorName) return;
77 
78  LoadNewGeometry(GetProvider().DetectorName() + ".gdml",
79  GetProvider().DetectorName() + ".gdml");
80 
81  } // Geometry::preBeginRun()
std::string string
Definition: nybbler.cc:12
AuxDetGeometryCore const & GetProvider() const
Returns a constant reference to the service provider.
#define MF_LOG_WARNING(category)
void LoadNewGeometry(std::string gdmlfile, std::string rootfile)
Expands the provided paths and loads the geometry description(s)

Member Data Documentation

bool gar::geo::AuxDetGeometry::fForceUseFCLOnly
private

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

Definition at line 129 of file AuxDetGeometry.h.

AuxDetGeometryCore gar::geo::AuxDetGeometry::fProvider
private

the actual service provider

Definition at line 125 of file AuxDetGeometry.h.

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

Relative path added to FW_SEARCH_PATH to search for geometry file

Definition at line 127 of file AuxDetGeometry.h.

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

Parameter set to define the channel map sorting.

Definition at line 131 of file AuxDetGeometry.h.


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