JANA2
C++ framework for multi-threaded data processing
|
Public Types | |
enum | containerType_t { kUnknownType , kVector , kMap , kVectorVector , kVectorMap } |
Public Member Functions | |
JCalibration (string url, int run, string context="default") | |
virtual const char * | className (void) |
virtual bool | GetCalib (string namepath, map< string, string > &svals, uint64_t event_number=0)=0 |
virtual bool | GetCalib (string namepath, vector< string > &svals, uint64_t event_number=0)=0 |
virtual bool | GetCalib (string namepath, vector< map< string, string > > &svals, uint64_t event_number=0)=0 |
virtual bool | GetCalib (string namepath, vector< vector< string > > &svals, uint64_t event_number=0)=0 |
virtual bool | PutCalib (string namepath, int32_t run_min, int32_t run_max, uint64_t event_min, uint64_t event_max, string &author, map< string, string > &svals, string comment="") |
virtual bool | PutCalib (string namepath, int32_t run_min, int32_t run_max, uint64_t event_min, uint64_t event_max, string &author, vector< map< string, string > > &svals, string comment="") |
virtual void | GetListOfNamepaths (vector< string > &namepaths)=0 |
virtual void | GetEventBoundaries (vector< uint64_t > &event_boundaries) |
User-callable access to event boundaries. More... | |
template<class T > | |
bool | Get (string namepath, map< string, T > &vals, uint64_t event_number=0) |
template<class T > | |
bool | Get (string namepath, vector< T > &vals, uint64_t event_number=0) |
template<class T > | |
bool | Get (string namepath, vector< map< string, T > > &vals, uint64_t event_number=0) |
template<class T > | |
bool | Get (string namepath, vector< vector< T > > &vals, uint64_t event_number=0) |
template<class T > | |
bool | Get (string namepath, T &val) |
template<class T > | |
bool | Put (string namepath, int32_t run_min, int32_t run_max, uint64_t event_min, uint64_t event_max, string &author, map< string, T > &vals, const string &comment="") |
template<class T > | |
bool | Put (string namepath, int32_t run_min, int32_t run_max, uint64_t event_min, uint64_t event_max, string &author, vector< T > &vals, const string &comment="") |
template<class T > | |
bool | Put (string namepath, int32_t run_min, int32_t run_max, uint64_t event_min, uint64_t event_max, string &author, vector< map< string, T > > &vals, const string &comment="") |
template<class T > | |
bool | Put (string namepath, int32_t run_min, int32_t run_max, uint64_t event_min, uint64_t event_max, string &author, vector< vector< T > > &vals, const string &comment="") |
template<class T > | |
bool | Get (string namepath, const T *&vals, uint64_t event_number=0) |
const int32_t & | GetRun (void) const |
const string & | GetContext (void) const |
const string & | GetURL (void) const |
void | GetAccesses (map< string, vector< string > > &accesses) |
string | GetVariation (void) |
containerType_t | GetContainerType (string typeid_name) |
void | DumpCalibrationsToFiles (string basedir="./") |
void | WriteCalibFileVector (string dir, string fname, string pathname) |
void | WriteCalibFileMap (string dir, string fname, string pathname) |
void | WriteCalibFileVectorVector (string dir, string fname, string pathname) |
void | WriteCalibFileVectorMap (string dir, string fname, string pathname) |
template<> | |
bool | Get (string namepath, map< string, string > &vals, uint64_t event_number) |
template<> | |
bool | Get (string namepath, vector< string > &vals, uint64_t event_number) |
template<> | |
bool | Get (string namepath, vector< map< string, string > > &vals, uint64_t event_number) |
template<> | |
bool | Get (string namepath, vector< vector< string > > &vals, uint64_t event_number) |
Static Public Member Functions | |
static const char * | static_className (void) |
Protected Member Functions | |
template<typename T > | |
containerType_t | TrycontainerType (string typeid_name) |
virtual void | RetrieveEventBoundaries (void) |
Optional for DBs that support event-level boundaries. | |
Protected Attributes | |
int32_t | run_number |
pthread_mutex_t | accesses_mutex |
pthread_mutex_t | stored_mutex |
pthread_mutex_t | boundaries_mutex |
void JCalibration::DumpCalibrationsToFiles | ( | string | basedir = "./" | ) |
This method will loop through all of the namespaces in the access list and dump them into a set of files that can be read using the JCalibrationFile sub-class. This can be used, for example, to capture the specific slice of the calibration database used for the current job for use by subsequent similar jobs.
bool JCalibration::Get | ( | string | namepath, |
const T *& | vals, | ||
uint64_t | event_number = 0 |
||
) |
Templated method used to get a set of calibration constants.
Get a pointer to the specified set of constants but keep them in the JCalibration object. If the specified constants have already been retrieved using type T, then the pointer is copied and the routine returns immediately. Otherwise, the constants are retrieved using one of the other Get() methods and stored locally before returning a pointer so subsequent calls will get the same pointer.
References Get().
bool JCalibration::Get | ( | string | namepath, |
map< string, T > & | vals, | ||
uint64_t | event_number = 0 |
||
) |
Templated method used to get a set of calibration constants.
This method will get the specified calibration constants in the form of strings using the virtual (non-templated) Get(...) method. It will then convert the strings into the data type on which the "value" part of vals is based. It does this using the stringstream class so T is restricted to the types it understands (int, float, double, string, ...).
The values are copied into vals using the keys it finds in the database, if any. If no keys are present, then numerical indices starting from zero are used. Note though that if non-keyed constants are used, then it may be more efficient for you to use the vector version of this method instead of the map one.
Referenced by Get(), JLargeCalibration::Get(), and JCalibrationManager::GetCalib().
bool JCalibration::Get | ( | string | namepath, |
T & | val | ||
) |
This is a convenience method for getting a single entry. It simply calls the vector version and returns the first entry. It returns true if the vector version returns true AND there is at least one entry in the vector. No check is made for there there being more than one entry in the vector.
References Get().
bool JCalibration::Get | ( | string | namepath, |
vector< map< string, T > > & | vals, | ||
uint64_t | event_number = 0 |
||
) |
Templated method used to get a set of calibration constants.
This method will get the specified calibration constants in the form of strings using the virtual (non-templated) Get(...) method. It will then convert the strings into the data type on which the "value" part of the maps in vals are based. It does this using the stringstream class so T is restricted to the types it understands (int, float, double, string, ...).
This version of Get is used to read in data formatted as a table. The values are stored in a vector of maps with keys obtained either from the last comment line before the first line of data, or, if no such comment line exists, using the column number as the key. For example:
p>
amp mean sigma 4.71 8.9 0.234 5.20 9.1 0.377 4.89 8.8 0.314 /tt> |
This would fill the vector vals with 3 elements. Each would be a map with 3 values using the keys "amp", "mean", and "sigma". To access them, use the syntax:
vals[row][key]
So, in the above example vals[0]["sigma"] would have the value 0.234 .
bool JCalibration::Get | ( | string | namepath, |
vector< T > & | vals, | ||
uint64_t | event_number = 0 |
||
) |
Templated method used to get a set of calibration constants.
This method will get the specified calibration constants in the form of strings using the virtual (non-templated) Get(...) method. It will then convert the strings into the data type on which the "value" part of vals is based. It does this using the stringstream class so T is restricted to the types it understands (int, float, double, string, ...).
The values are copied into vals in the order they are received from the virtual Get(...) method. If keys are returned with the data, they are discarded. Note though that if keyed constants are used, you may want to look at using the map version of this method instead of the vector one.
bool JCalibration::Get | ( | string | namepath, |
vector< vector< T > > & | vals, | ||
uint64_t | event_number = 0 |
||
) |
Templated method used to get a set of calibration constants.
This method will get the specified calibration constants in the form of strings using the virtual (non-templated) Get(...) method. It will then convert the strings into the data type on which the inner vector is based. It does this using the stringstream class so T is restricted to the types it understands (int, float, double, string, ...).
This version of Get is used to read in data formatted as a table. The values are stored in a vector of vectors with the inner vector representing a single row (i.e. one element for each column) and the outer vector collecting the rows. For example:
p>
amp mean sigma 4.71 8.9 0.234 5.20 9.1 0.377 4.89 8.8 0.314 /tt> |
This would fill the vector vals with 3 elements. Each would be a vector with 3 values. To access them, use the syntax:
vals[row][column]
So, in the above example vals[0][2] would have the value 0.234 .
|
virtual |
User-callable access to event boundaries.
Copy the event boundaries (if any) for this calibration's run into the caller supplied container. The contents of the container are replaced. If there are no boundaries, then the container is cleared and returned empty.
string JCalibration::GetVariation | ( | void | ) |
This is a special routine that looks for a string of the format "variation=XXX" in the context string and if found, returns the "XXX" part. Otherwise, it returns "default" assuming no variation was identified. This is here for convenience since the CCDB implementation will use strings of this format to specify variations. When looking for the variation, any spaces or semi-colon found in the string will be removed along with characters following it. This is to allow semi-colon or space seperated lists in the variation.
bool JCalibration::Put | ( | string | namepath, |
int32_t | run_min, | ||
int32_t | run_max, | ||
uint64_t | event_min, | ||
uint64_t | event_max, | ||
string & | author, | ||
map< string, T > & | vals, | ||
const string & | comment = "" |
||
) |
Templated method used to write a set of calibration constants.
This method will write the specified calibration constants in the form of strings using the virtual (non-templated) PutCalib(...) method. It will then convert the strings into the data type on which the "value" part of vals is based. It does this using the stringstream class so T is restricted to the types it understands (int, float, double, string, ...).
bool JCalibration::Put | ( | string | namepath, |
int32_t | run_min, | ||
int32_t | run_max, | ||
uint64_t | event_min, | ||
uint64_t | event_max, | ||
string & | author, | ||
vector< map< string, T > > & | vals, | ||
const string & | comment = "" |
||
) |
Templated method used to write a set of calibration constants.
This method will write the specified calibration constants in the form of strings using the virtual (non-templated) PutCalib(...) method. It will then convert the strings into the data type on which the "value" part of vals is based. It does this using the stringstream class so T is restricted to the types it understands (int, float, double, string, ...).
bool JCalibration::Put | ( | string | namepath, |
int32_t | run_min, | ||
int32_t | run_max, | ||
uint64_t | event_min, | ||
uint64_t | event_max, | ||
string & | author, | ||
vector< T > & | vals, | ||
const string & | comment = "" |
||
) |
Templated method used to write a set of calibration constants.
This method will write the specified calibration constants in the form of strings using the virtual (non-templated) PutCalib(...) method. It will then convert the strings into the data type on which the "value" part of vals is based. It does this using the stringstream class so T is restricted to the types it understands (int, float, double, string, ...).
bool JCalibration::Put | ( | string | namepath, |
int32_t | run_min, | ||
int32_t | run_max, | ||
uint64_t | event_min, | ||
uint64_t | event_max, | ||
string & | author, | ||
vector< vector< T > > & | vals, | ||
const string & | comment = "" |
||
) |
Templated method used to write a set of calibration constants.
This method will write the specified calibration constants in the form of strings using the virtual (non-templated) PutCalib(...) method. It will then convert the strings into the data type on which the "value" part of vals is based. It does this using the stringstream class so T is restricted to the types it understands (int, float, double, string, ...).