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

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

Definition at line 92 of file AuxDetGeometry.h.

Constructor & Destructor Documentation

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", {}))
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()
std::string string
Definition: nybbler.cc:12
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 99 of file AuxDetGeometry.h.

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

Returns a reference to the service provider.

Definition at line 115 of file AuxDetGeometry.h.

115 { 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 102 of file AuxDetGeometry.h.

102 { 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 118 of file AuxDetGeometry.h.

118 { 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.

95  {
96  // the channel map is responsible of calling the channel map configuration
97  // of the geometry
98  auto channelMap = art::ServiceHandle<geo::AuxDetExptGeoHelperInterface>()->ConfigureAuxDetChannelMapAlg(fSortingParameters);
99  if (!channelMap) {
100  throw cet::exception("ChannelMapLoadFail") << " failed to load new channel map";
101  }
102  fProvider.ApplyChannelMap(move(channelMap));
103  } // 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.
def move(depos, offset)
Definition: depos.py:107
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 106 of file AuxDetGeometry_service.cc.

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

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") << "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()
std::string string
Definition: nybbler.cc:12
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 125 of file AuxDetGeometry.h.

AuxDetGeometryCore geo::AuxDetGeometry::fProvider
private

the actual service provider

Definition at line 121 of file AuxDetGeometry.h.

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

Relative path added to FW_SEARCH_PATH to search for geometry file

Definition at line 123 of file AuxDetGeometry.h.

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

Parameter set to define the channel map sorting.

Definition at line 127 of file AuxDetGeometry.h.


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