JANA2
C++ framework for multi-threaded data processing
JGeometry Class Referenceabstract

JGeometry is a virtual base class used to define the interface by which geometry information can be obtained in JANA. More...

#include <JGeometry.h>

Inheritance diagram for JGeometry:
[legend]

Public Types

enum  ATTR_LEVEL_t {
  attr_level_none = 0 ,
  attr_level_last = 1 ,
  attr_level_all = 2
}
 

Public Member Functions

 JGeometry (string url, int run, string context="default")
 
virtual const char * className (void)
 
void SetVerbose (int newval)
 
virtual bool Get (string xpath, string &sval)=0
 
virtual bool Get (string xpath, map< string, string > &svals)=0
 
virtual bool GetMultiple (string xpath, vector< string > &vsval)=0
 
virtual bool GetMultiple (string xpath, vector< map< string, string > > &vsvals)=0
 
virtual void GetXPaths (vector< string > &xpaths, ATTR_LEVEL_t level=attr_level_last, const string &filter="")=0
 
virtual string GetChecksum (void) const
 
template<class T >
bool Get (string xpath, T &val)
 
template<class T >
bool Get (string xpath, vector< T > &vals, string delimiter=" ")
 
template<class T >
bool Get (string xpath, map< string, T > &vals)
 
template<class T >
bool GetMultiple (string xpath, vector< T > &vval)
 
template<class T >
bool GetMultiple (string xpath, vector< vector< T > > &vvals, string delimiter=" ")
 
template<class T >
bool GetMultiple (string xpath, vector< map< string, T > > &vvals)
 
const int & GetRunRequested (void) const
 
const int & GetRunFound (void) const
 
const int & GetRunMin (void) const
 
const int & GetRunMax (void) const
 
const string & GetContext (void) const
 
const string & GetURL (void) const
 

Static Public Member Functions

static const char * static_className (void)
 

Protected Attributes

int run_min
 
int run_max
 
int run_found
 
int verbose =1
 

Detailed Description

JGeometry is a virtual base class used to define the interface by which geometry information can be obtained in JANA.

Implementing this base class allows the JANA end user to be agnostic as to the details of how the geometry info is stored. The geometry can be stored in a database or any number of file formats. The files can be stored locally, or on the network somewhere.

The primary advantage here is that it allows one to work with local files, but then easily switch to a remote source method when appropriate without requiring modifications to the end user code.

On the user side they will call one of the Get(...) methods which all get translated into a call of one of the two vitural methods:

virtual bool Get(string namepath, string &sval, map<string, string> &where)=0; virtual bool Get(string namepath, map<string, string> &svals, map<string, string> &where)=0;

These two virtual methods along with one to get a list of the available namepaths are the only things that need to be implemented in a concrete subclass of JGeometry.

A geometry element is specified by its namepath and an optional set of qualifiers (the where argument). The namepath is a hierarchal list of elements separated by forward slashes(/) analogous to a path on a unix filesystem. This path is always assumed to be relative to the url specified in the constructor. So, for instance, suppose one kept the geometry in a set XML files on the local filesystem and wished to access information from the file

/home/joe/calib/geom_Oct10_2017.xml

One would specify the url as:

file:///home/joe/calib/geom_Oct10_2017.xml

and then the namepath could be specified as the string:

"TOF/bar/X_Y_Z"

which would indicate the attribute "X_Y_Z" of the subtag "bar" of the tag "TOF" in the file "/home/joe/calib/geom_Oct10_2017.xml"

Member Function Documentation

◆ Get() [1/3]

template<class T >
bool JGeometry::Get ( string  xpath,
map< string, T > &  vals 
)

Templated method used to get a set of geometry attributes.

This method can be used to get a list of all attributes for a given xpath. The attributes are copied into the vals map with the attribute name as the key and the attribute value as the value. This relies on the non-templated, virtual Get(string, map<string,string>&) method to first get the values in the form of strings. It converts them using the stringstream class so T is restricted to the types it understands (int, float, double, string, ...).

If no element of the specified name is found, a value of boolean "false" is returned. A value of "true" is returned upon success.

◆ Get() [2/3]

template<class T >
bool JGeometry::Get ( string  xpath,
T &  val 
)

Templated method used to get a single geometry element.

This method will get the specified geometry element in the form of a string using the virtual (non-templated) Get(...) method. It will then convert the string into the data type on which val is based. It does this using the stringstream class so T is restricted to the types stringstream understands (int, float, double, string, ...).

If no element of the specified name is found, a value of boolean "false" is returned. A value of "true" is returned upon success.

◆ Get() [3/3]

template<class T >
bool JGeometry::Get ( string  xpath,
vector< T > &  vals,
string  delimiter = " " 
)

Templated method used to get a set of values from a geometry attribute.

This method can be used to get a list of values (possibly only one) from a single geometry attribute specified by xpath. The attribute is obtained as a string using the non-templated Get(...) method and the string broken into tokens separated by the delimiter (which defaults to a single white space). Each token is then converted into type T using the stringstream class so T is restricted to the types stringstream understands (int, float, double, string, ...).

If no element of the specified name is found, a value of boolean "false" is returned. A value of "true" is returned upon success.

◆ GetMultiple() [1/3]

template<class T >
bool JGeometry::GetMultiple ( string  xpath,
vector< map< string, T > > &  vvals 
)

Templated method used to get a set of geometry attributes.

This method can be used to get a list of all attributes for a given xpath. The attributes are copied into the vals map with the attribute name as the key and the attribute value as the value. This relies on the non-templated, virtual Get(string, map<string,string>&) method to first get the values in the form of strings. It converts them using the stringstream class so T is restricted to the types it understands (int, float, double, string, ...).

If no element of the specified name is found, a value of boolean "false" is returned. A value of "true" is returned upon success.

◆ GetMultiple() [2/3]

template<class T >
bool JGeometry::GetMultiple ( string  xpath,
vector< T > &  vval 
)

Templated method used to get multiple entries satisfying a single xpath.

This method will get the specified geometry element in the form of a string using the virtual (non-templated) Get(...) method. It will then convert the string into the data type on which val is based. It does this using the stringstream class so T is restricted to the types stringstream understands (int, float, double, string, ...).

This differs from the similar Get() method in that the geometry tree will be searched for all nodes satisfying the given xpath and all all values will be copied into the container provided. In Get(), only the first node encountered that satisfies the xpath will be copied.

If no element of the specified name is found, a value of boolean "false" is returned. A value of "true" is returned upon success.

◆ GetMultiple() [3/3]

template<class T >
bool JGeometry::GetMultiple ( string  xpath,
vector< vector< T > > &  vvals,
string  delimiter = " " 
)

Templated method used to get a set of values from a geometry attribute.

This method can be used to get a list of values (possibly only one) from a single geometry attribute specified by xpath. The attribute is obtained as a string using the non-templated Get(...) method and the string broken into tokens separated by the delimiter (which defaults to a single white space). Each token is then converted into type T using the stringstream class so T is restricted to the types stringstream understands (int, float, double, string, ...).

If no element of the specified name is found, a value of boolean "false" is returned. A value of "true" is returned upon success.


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