Belle II Software light-2406-ragdoll
framework
Collaboration diagram for framework:

Modules

 framework data objects
 
 framework modules
 

Namespaces

namespace  Belle2::PyObjConvUtils
 Python object converter utilities namespace.
 
namespace  Belle2::_RelationsInterfaceImpl
 hide some implementation details.
 
namespace  Belle2::_StoreArrayImpl
 hide some implementation details.
 
namespace  Belle2::RootIOUtilities
 Some constants and helpers common to the RootInput and RootOutput modules.
 
namespace  Belle2::TangoPalette
 Implements a colour palette, see http://sobac.com/sobac/tangocolors.htm.
 
namespace  Belle2::HTML
 return information on objects in a nice format.
 
namespace  Belle2::IOIntercept
 Encapsulate all classes needed to intercept stdout and stderr.
 
namespace  Belle2::Stream
 Define (de)serialization methods for TObject.
 
namespace  Belle2::TestHelpers
 Some utilities to help with writing unit tests.
 
namespace  Belle2::Utils
 General utility functions.
 

Classes

class  CreateConsistencyInfoModule
 If you want to merge two events with the 'MergeDataStoreModule', it might be necessary to make sure that this combination of events make sense. More...
 
class  DataFlowVisualization
 class to visualize data flow between modules. More...
 
class  Environment
 This class stores all environment information required to run the framework, such as module or data filepaths, number of processes to be used in parallel processing etc. More...
 
class  EventProcessor
 provides the core event processing loop. More...
 
class  FileCatalog
 This class provides an interface to the file (metadata) catalog. More...
 
class  HistoModule
 HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions to be managed by HistoManager. More...
 
class  InputController
 A static class to control supported input modules. More...
 
class  MemoryPool< T, chunkSize >
 Class to provide a constant access time memory pool for one kind of objects. More...
 
class  MergeDataStoreModule
 Internal module used by Path.add_independent_merge_path(). More...
 
class  MetadataService
 This class provides a service for writing metadata about the basf2 execution and about output files to a json file. More...
 
class  Module
 Base class for Modules. More...
 
class  ModuleProxyBase
 The base module proxy class is used to create new instances of a module. More...
 
class  ModuleCondition
 Wraps a condition set on a Module instance. More...
 
class  ModuleManager
 The ModuleManager Class. More...
 
class  ModuleParam< T >
 A single parameter of the module. More...
 
class  ModuleParamBase
 Base class for module parameter. More...
 
class  ModuleParamInfoPython
 Class to store basic information about a parameter. More...
 
class  ModuleParamList
 The Module parameter list class. More...
 
class  ModuleStatistics
 Keep track of time and memory consumption during processing. More...
 
class  MRUCache< KEY, VALUE >
 Class implementing a generic Most Recently Used cache. More...
 
class  Path
 Implements a path consisting of Module and/or Path objects. More...
 
class  PathElement
 Base for classes that can be elements of a Path. More...
 
class  PathIterator
 Iterator over a Path (returning Module pointers). More...
 
class  ProcessStatistics
 Class to collect call statistics for all modules. More...
 
class  PyModule
 Python wrapper for Belle2::Module. More...
 
class  RandomGenerator
 Fast Random number Generator using on xorshift1024* [arXiv:1402.6246]. More...
 
class  RandomNumbers
 The class for handling the random number generation. More...
 
class  SteerRootInputModule
 Internal module used by Path.add_independent_merge_path(). More...
 
class  SubEventModule
 Framework-internal module that implements the functionality of Path::forEach() as well as Path::doWhile(). More...
 
class  SwitchDataStoreModule
 Internal module used by Path.add_independent_path(). More...
 
class  Database
 Singleton base class for the low-level interface to the database. More...
 
class  DBAccessorBase
 Base class for DBObjPtr and DBArray for easier common treatment. More...
 
class  DBArray< T >
 Class for accessing arrays of objects in the database. More...
 
class  OptionalDBArray< T >
 Optional DBArray: This class behaves the same as the DBArray except that it will not raise errors when an object could not be found in the database. More...
 
class  DBImportArray< T >
 Class for importing array of objects to the database. More...
 
class  DBImportBase
 Base class for importing objects to the database. More...
 
class  DBImportObjPtr< T >
 Class for importing a single object to the database. More...
 
class  DBObjPtr< T >
 Class for accessing objects in the database. More...
 
class  OptionalDBObjPtr< T >
 Optional DBObjPtr: This class behaves the same as the DBObjPtr except that it will not raise errors when an object could not be found in the database. More...
 
class  DBPointer< T, KEY, METHOD, NAME >
 Class for pointing to an element in an array stored in the database. More...
 
class  DBStore
 Singleton class to cache database objects. More...
 
class  DBStoreEntry
 Class to hold one entry from the ConditionsDB in the DBStore. More...
 
class  EventDependency
 Class for handling changing conditions as a function of event number. More...
 
class  IntervalOfValidity
 A class that describes the interval of experiments/runs for which an object in the database is valid. More...
 
class  IntraRunDependency
 Base class for handling changing conditions during a run. More...
 
class  PayloadFile
 A wrapper class for payload files used by the Database and DBStore classes. More...
 
class  DBObjPtr< PayloadFile >
 Specialization of DBObjPtr in case of PayloadFiles. More...
 
class  RelationVector< T >
 Class for type safe access to objects that are referred to in relations. More...
 
class  DataStore
 In the store you can park objects that have to be accessed by various modules. More...
 
class  DependencyMap
 Collect information about the dependencies between modules. More...
 
class  StoreArray< T >
 Accessor to arrays stored in the data store. More...
 
class  RelationArray
 Low-level class to create/modify relations between StoreArrays. More...
 
struct  RelationEntry
 Struct for relations. More...
 
class  RelationIndex< FROM, TO >
 Provides access to fast ( O(log n) ) bi-directional lookups on a specified relation. More...
 
class  RelationIndexBase
 Baseclass for all RelationIndexContainers. More...
 
class  RelationIndexContainer< FROM, TO >
 Class to store a bidirectional index between two StoreArrays. More...
 
class  RelationIndexManager
 Manager to keep a cache of existing RelationIndexContainers. More...
 
class  RelationsInterface< BASE >
 Defines interface for accessing relations of objects in StoreArray. More...
 
class  RelationVectorBase
 base class for RelationVector<T> More...
 
class  SelectSubsetBase
 Type-independent implementation details of SelectSubset. More...
 
class  SelectSubset< StoredClass >
 Class to create a subset of a given StoreArray together with the relations with other StoreArrays. More...
 
class  StoreAccessorBase
 Base class for StoreObjPtr and StoreArray for easier common treatment. More...
 
struct  StoreEntry
 Wraps a stored array/object, stored under unique (name, durability) key. More...
 
class  StoreObjPtr< T >
 Type-safe access to single objects in the data store. More...
 
class  BeamParameters
 This class contains the nominal beam parameters and the parameters used for smearing of the primary vertex and the beam energy and momentum. More...
 
class  BunchStructure
 Class to store the fill pattern of colliding bunches. More...
 
class  dEdxPDFs
 Base class for holding the dE/dx PDFs. More...
 
class  HardwareClockSettings
 Database object containing the nominal accelerator RF value and the prescales to derive the clock frequencies of the sub-detectors. More...
 
class  MagneticField
 Magnetic field map. More...
 
class  MagneticFieldComponent
 Abstract base class for BField components. More...
 
class  MagneticFieldComponentConstant
 Describe one component of the Geometry. More...
 
class  RunInfo
 Database object for Run Information. More...
 
class  Const
 This class provides a set of constants for the framework. More...
 
class  Gearbox
 Singleton class responsible for loading detector parameters from an XML file. More...
 
struct  InputHandlerFactory< T >
 Helper class to easily register new input handlers. More...
 
class  GearDir
 GearDir is the basic class used for accessing the parameter store. More...
 
class  Unit
 The Unit class. More...
 
class  B2Vector3< DataType >
 A fast and root compatible alternative to TVector3. More...
 
class  BFieldManager
 Bfield manager to obtain the magnetic field at any point. More...
 
class  LogConfig
 The LogConfig class. More...
 
class  LogConnectionBase
 Abstract base class for the different types of log connections. More...
 
class  LogConnectionConsole
 Implements a log connection to an IO Stream. More...
 
class  LogConnectionFilter
 Implements a log connection that filters repeated messages. More...
 
class  LogConnectionJSON
 Implements a log connection to stdout but with messages formatted as json objects to allow easy parsing by other tools, say jupyter notebooks. More...
 
class  LogConnectionTxtFile
 Implements a log connection to a text file. More...
 
class  LogConnectionUDP
 Log Connection to send the log message as JSON to a UDP server. More...
 
class  LogMessage
 The LogMessage class. More...
 
class  LogMethod
 The LogMethod class. More...
 
class  LogSystem
 Class for logging debug, info and error messages. More...
 
class  EvtGenDatabasePDG
 Replacement for TDatabasePDG that is filled from EvtGen's evt.pdl. More...
 
class  EvtGenParticlePDG
 Helper class for setting additional TParticlePDG members and storing the ones it doesn't have yet. More...
 
class  AsyncWrapper
 Wraps a given Module to execute it asynchronously. More...
 
class  DataStoreStreamer
 Stream/restore DataStore objects to/from EvtMessage. More...
 
struct  EvtHeader
 Header structure of streamed object list. More...
 
class  EvtMessage
 Class to manage streamed object. More...
 
class  GlobalProcHandler
 A class to manage processes for parallel processing. More...
 
class  MapMergeable< T >
 Wrap an STL map to make it mergeable. More...
 
class  Mergeable
 Abstract base class for objects that can be merged. More...
 
class  CharBuffer
 dynamic character buffer that knows its size. More...
 
class  InMessage
 Reusable Message class derived from TMessage (for reading only) More...
 
class  MsgHandler
 A class to encode/decode an EvtMessage. More...
 
class  PathUtils
 Helper utils for path arithmetics needed in the pEventProcessor. More...
 
class  pEventProcessor
 This class provides the core event processing loop for parallel processing. More...
 
class  ProcessMonitor
 Class to monitor all started framework processes (input, workers, output), kill them if requested and handle the signals from the OS. More...
 
class  ProcHandler
 A class to manage processes for parallel processing. More...
 
class  RbTupleManager
 Class to manage histograms defined in registered modules. More...
 
struct  RingBufInfo
 Internal metadata structure for RingBuffer. More...
 
class  RingBuffer
 Class to manage a Ring Buffer placed in an IPC shared memory. More...
 
class  RootMergeable< T >
 Wrap a root histogram or TNtuple to make it mergeable. More...
 
class  RxModule
 Module to decode data store contents from RingBuffer. More...
 
class  SemaphoreLocker
 Handles creation, locking and unlocking of System V semaphores. More...
 
class  SeqFile
 A class to manage I/O for a chain of blocked files. More...
 
class  SetMergeable< T >
 Wrap an STL set to make it mergeable. More...
 
class  TxModule
 Module for encoding data store contents into a RingBuffer. More...
 
class  ZMQEventProcessor
 This class provides the core event processing loop for parallel processing with ZMQ. More...
 
class  ZMQConfirmedInput
 Input part of a confirmed connection. More...
 
class  ZMQConfirmedOutput
 Output part of a confirmed connection. More...
 
class  ZMQConnection
 Base class for every connection with virtual functions to be implemented: More...
 
class  ZMQConnectionOverSocket
 Specialized connection over a ZMQ socket. More...
 
class  ZMQLoadBalancedInput
 Input part of a load-balanced connection. More...
 
class  ZMQLoadBalancedOutput
 Output part of a load-balanced connection. More...
 
class  ZMQNullConnection
 Connection doing just nothing: without the capability to pull, send or receive. Useful for template interfaces. More...
 
class  ZMQRawInput
 Input connection allowing to speak with non-zmq sockets via a ZMQ_STREAM socket. More...
 
class  ZMQRawOutput
 Output connection to speak to non-zmq sockets via a ZMQ_STREAM socket. More...
 
class  ZMQSimpleConnection
 Connection type to be used for answering simple requests, e.g. More...
 
class  ZMQIdMessage
 A message with the socket ID. Needed in input<->worker communication. More...
 
class  ZMQMessageFactory
 Helper class for creating new ID/No-ID messages. More...
 
class  ZMQMessageHelper
 Internal helper for creating ZMQ messages (should not be used otherwise). More...
 
class  ZMQModuleMessage< AMessageFrameNumber >
 A general message with as many parts as given as template argument. More...
 
class  ZMQNoIdMessage
 A message without an associated socket ID. Is used in most cases. More...
 
class  ProcessedEventBackup
 Storage item for the event backup storing the event message, the time stamp and the event meta data. More...
 
class  ProcessedEventsBackupList
 List-like structure for storing and retaining event backups. More...
 
class  ZMQRxOutputModule
 Module connecting the worker path with the output path on the output side. More...
 
class  ZMQRxWorkerModule
 Module connecting the input path with the worker path on the worker side. More...
 
class  ZMQTxInputModule
 Module connecting the input path with the worker path on the input side. More...
 
class  ZMQTxWorkerModule
 Module connecting the worker path with the output path on the worker side. More...
 
class  ZMQClient
 A helper class for communicating over ZMQ. Includes a multicast and (if needed) also a data socket. More...
 
class  EventMetaDataSerialization
 Helper class for (de)serializing the event meta data used for the event backup transferral. More...
 
class  StreamHelper
 Helper class for data store serialization. More...
 
class  ZMQAddressUtils
 Summary of some address helpers. More...
 
class  ZMQLogger
 Base class for the ZMQ connection to help monitor and log certain values. More...
 
class  ZMQParent
 A helper class for creating ZMQ sockets keeping track of the ZMQ context and terminating it if needed. More...
 
class  Framework
 This class combines all subsystems of the framework, and exports the main interface to Python. More...
 
class  LogPythonInterface
 Thin wrapper to expose a usable interface to the logging framework in python. More...
 
class  ProcessStatisticsPython
 Python interface for ProcessStatistics. More...
 
class  PyDBArray
 Class to access a DB Array from Python. More...
 
class  PyDBObj
 Class to access a DBObjPtr from Python. More...
 
class  PyStoreArray
 A (simplified) python wrapper for StoreArray. More...
 
class  PyStoreObj
 a (simplified) python wrapper for StoreObjPtr. More...
 
class  AbstractBooleanNode< AVariableManager >
 A parsed cut-string naturally has a tree shape which incorporates the infomation of operator precedence and evaluation order of the statements. More...
 
class  AbstractExpressionNode< AVariableManager >
 AbstractExpressionNode Superclass for all nodes which host expressions. More...
 
class  BaseAngle
 Class to compare if two angles are compatible withing a given error range. More...
 
class  ThetaAngle
 
class  PhiAngle
 
class  ObjArrayIterator< ArrayType, ValueType >
 Optimizes class to iterate over TObjArray and classes inheriting from it. More...
 
class  ArrayIterator< ArrayType, ValueType >
 Generic iterator class for arrays, allowing use of STL algorithms, range-based for etc. More...
 
class  CalcMeanCov< N, RealType >
 Class to calculate mean and and covariance between a number of parameters on running data without storing the actual values, also for weighted entries. More...
 
class  ConditionalGaussGenerator
 Class implementing n-dimensional random number generator from Gaussian distribution where the first component of the vector is generated first (using some external source) and the remaining components are generated based on the value of the first component. More...
 
struct  Visitor< operation >
 This is a class template which takes a template class operation as template argument. More...
 
struct  EqualVisitor
 Seperate Visitor struct for equal_to comparison of variant<double, int bool>. More...
 
class  UnaryBooleanNode< AVariableManager >
 Nodeclass with a single AbstractBooleanNode as child. More...
 
class  BinaryBooleanNode< AVariableManager >
 Nodeclass with two AbstractBooleanNode as children and a Boolean Operator (AND, OR) Check() method evaluates the child nodes and returns the result of the boolean operation. More...
 
class  UnaryRelationalNode< AVariableManager >
 Nodeclass with a single AbstractExpressioNode as child. More...
 
class  BinaryRelationalNode< AVariableManager >
 BooleanNode which has two AbstractExpressionNodes nodes and a ComparisonOperator. More...
 
class  TernaryRelationalNode< AVariableManager >
 BooleanNode which has three AbstractExpressionNodes nodes and two ComparisonOperator. More...
 
class  UnaryExpressionNode< AVariableManager >
 UnaryExpressionNode Node class with a single expression node as child. More...
 
class  BinaryExpressionNode< AVariableManager >
 BinaryExpressionNode Node which connects two expression nodes with an arithemtic operation. More...
 
class  DataNode< AVariableManager, T >
 Template class for storing the Constants (int, double, bool) of the Cutstring. More...
 
class  IdentifierNode< AVariableManager >
 Class which stores the name of a variable. More...
 
class  FunctionNode< AVariableManager >
 FunctionNode Node class for handling MetaVariables in cuts. More...
 
class  EnvironmentVariables
 Utility functions related to environment variables. More...
 
class  FileSystem
 Utility functions related to filename validation and filesystem access. More...
 
class  FormulaParserBase
 Base class with the non-templated part of the formula parser. More...
 
class  FormulaParser< VariableConstructor >
 FormulaParser to parse a text formula like "a + b * c ^ d" where the separate parts can be either variables (with and without arguments) or numbers. More...
 
struct  StringFormulaConstructor
 Example struct to be used with the FormulaParser to create a string representation of the formula, mainly for testing and debugging. More...
 
class  GeneralCut< AVariableManager >
 This class implements a common way to implement cut/selection functionality for arbitrary objects. More...
 
class  KeyValuePrinter
 create human-readable or JSON output for key value pairs. More...
 
class  LabToCms
 Class implementing general Lorentz Transformation between LAB and CMS system. More...
 
class  MakeROOTCompatible
 Helper class for converting strings into a ROOT-friendly format (e.g.: removing special characters in branch names, etc.) More...
 
class  MultivariateNormalGenerator
 Class to generate normal distributed, correlated random numbers given the mean values and the covariance matrix of all dimensions. More...
 
class  NodeFactory
 Wrapper class for static node compile functions. More...
 
class  BoostPythonModuleProxy
 Proxy class to register python modules (the things you can 'import'). More...
 
class  RootFileCreationManager
 This single instance class takes track of all open ROOT files open in "create" mode, usually meant for all the ntuple output modules. More...
 
class  ScopeGuard
 Simple ScopeGuard to execute a function at the end of the object lifetime. More...
 
struct  TRandomWrapper
 Wrap TRandom to be useable as a uniform random number generator with STL algorithms like std::shuffle. More...
 

Macros

#define BELLE2_DEFINE_EXCEPTION(ClassName, Message)
 Macro that defines an exception with the given message template.
 
#define _PACKAGE_   ""
 make sure REG_MODULE works outside the normal build system
 
#define REG_MODULE(moduleName)
 Register the given module (without 'Module' suffix) with the framework.
 
#define B2_GEARBOX_REGISTER_INPUTHANDLER(classname, prefix)    InputHandlerFactory<classname> Gearbox_InputHandlerFactory_##classname(prefix)
 Helper macro to easily register new input handlers.
 
#define DEFINE_UNIT_NAME(var, value, name)   const double Unit::var = Unit::registerConversion(name,value)
 Define a new Unit given a name for the conversion table.
 
#define DEFINE_UNIT(var, value)   DEFINE_UNIT_NAME(var,value,#var)
 Define a new Unit and take the variable name as name for the conversion table.
 
#define REGISTER_PYTHON_MODULE(moduleName)   Belle2::BoostPythonModuleProxy boostPythonModuleProxy##moduleName(#moduleName, PyInit_##moduleName);
 Register a python module to make available when loading the library.
 
#define REGISTER_PYTHON_MODULE_AUTOIMPORT(moduleName)   Belle2::BoostPythonModuleProxy boostPythonModuleProxy##moduleName(#moduleName, PyInit_##moduleName, true);
 Identical to REGISTER_PYTHON_MODULE(), but will also import the module into the global namespace after loading it.
 
#define B2INFO_MEASURE_TIME(txt, ...)
 Print an INFO message txt followed by the time it took to execute the statment given as second argument.
 
#define branch_unlikely(x)   (x)
 A macro to tell the compiler that the argument x will be very likely be false.
 
#define branch_likely(x)   (x)
 Usage:
 

Typedefs

typedef std::shared_ptr< ModuleModulePtr
 Defines a pointer to a module object as a boost shared pointer.
 
typedef std::list< ModulePtrModulePtrList
 Defines a std::list of shared module pointers.
 
using ModuleParamPtr = std::shared_ptr< ModuleParamBase >
 Defines a pointer to a module parameter as a boost shared pointer. *‍/.
 
typedef std::shared_ptr< PathPathPtr
 Defines a pointer to a path object as a boost shared pointer.
 
typedef RelationsInterface< TObject > RelationsObject
 Provides interface for getting/adding relations to objects in StoreArrays.
 
typedef std::pair< std::string, DataStore::EDurabilityAccessorParams
 Pair of parameters needed to find an object in the DataStore.
 
typedef B2Vector3< double > B2Vector3D
 typedef for common usage with double
 
typedef B2Vector3< float > B2Vector3F
 typedef for common usage with float
 

Enumerations

enum  ERecordType {
  MSG_EVENT ,
  MSG_BEGIN_RUN ,
  MSG_END_RUN ,
  MSG_TERMINATE ,
  MSG_NORECORD ,
  MSG_STREAMERINFO
}
 What type of message is this? More...
 
enum class  ProcType {
  c_Input = 'i' ,
  c_Worker = 'w' ,
  c_Output = 'o' ,
  c_Proxy = 'p' ,
  c_Monitor = 'm' ,
  c_Init = '0' ,
  c_Stopped = 's'
}
 Type of the process used for storing and mapping the child processes in the process handler. More...
 
enum class  EMessageTypes {
  c_confirmMessage = 'c' ,
  c_helloMessage = 'h' ,
  c_deleteWorkerMessage = 'd' ,
  c_lastEventMessage = 'l' ,
  c_readyMessage = 'r' ,
  c_terminateMessage = 'x' ,
  c_rawDataMessage = 'u' ,
  c_compressedDataMessage = 'v' ,
  c_eventMessage = 'w' ,
  c_goodbyeMessage = 'g' ,
  c_statisticMessage = 's' ,
  c_killWorkerMessage = 'k' ,
  c_monitoringMessage = 'm' ,
  c_newRunMessage = 'n'
}
 Type the messages can have. More...
 
enum  ZMQAddressType {
  c_input ,
  c_output ,
  c_pub ,
  c_sub ,
  c_control
}
 The type of a ZMQ socket address (which socket to use) More...
 
enum class  NodeType : int {
  UnaryBooleanNode ,
  BinaryBooleanNode ,
  UnaryRelationalNode ,
  BinaryRelationalNode ,
  TernaryRelationalNode ,
  UnaryExpressionNode ,
  BinaryExpressionNode ,
  FunctionNode ,
  IdentifierNode ,
  DoubleNode ,
  IntegerNode ,
  BooleanNode
}
 Enum of possible Nodes in parsing tree. More...
 
enum class  BooleanOperator : int {
  AND ,
  OR
}
 Enum for decoding the boolean operator type. More...
 
enum class  ComparisonOperator : int {
  EQUALEQUAL ,
  GREATEREQUAL ,
  LESSEQUAL ,
  GREATER ,
  LESS ,
  NOTEQUAL
}
 Enum for decoding the comparison operator type. More...
 
enum class  ArithmeticOperation : int {
  PLUS ,
  MINUS ,
  PRODUCT ,
  DIVISION ,
  POWER
}
 Enum for decoding the comparison operator type. More...
 

Functions

template<class T >
boost::python::object createROOTObjectPyCopy (const T &instance)
 Create a python wrapped copy from a class instance which has a ROOT dictionary.
 
std::istream & operator>> (std::istream &input, IntervalOfValidity &iov)
 
std::ostream & operator<< (std::ostream &output, const IntervalOfValidity &iov)
 
 ADD_BITMASK_OPERATORS (DataStore::EStoreFlags)
 Add bitmask operators to DataStore::EStoreFlags.
 
 DEFINE_UNIT (cm, 1.)
 Standard units with the value = 1.
 
 DEFINE_UNIT (ns, 1.)
 Standard of [time].
 
 DEFINE_UNIT (GHz, 1.)
 Standard of [frequency].
 
 DEFINE_UNIT (rad, 1.)
 Standard of [angle].
 
 DEFINE_UNIT (GeV, 1.)
 Standard of [energy, momentum, mass].
 
 DEFINE_UNIT (K, 1.)
 Standard of [temperature].
 
 DEFINE_UNIT (e, 1.)
 Standard of [electric charge].
 
 DEFINE_UNIT_NAME (g_cm3, 1., "g/cm3")
 Practical units with the value = 1.
 
 DEFINE_UNIT (km, Unit::cm *1e5)
 Derived units.
 
 DEFINE_UNIT (m, Unit::cm *1e2)
 [meters]
 
 DEFINE_UNIT (mm, Unit::m *1e-3)
 [millimeters]
 
 DEFINE_UNIT (um, Unit::m *1e-6)
 [micrometers]
 
 DEFINE_UNIT (nm, Unit::m *1e-9)
 [nanometers]
 
 DEFINE_UNIT (pm, Unit::m *1e-12)
 [picometers]
 
 DEFINE_UNIT (fm, Unit::m *1e-15)
 [femtometers]
 
 DEFINE_UNIT (m2, Unit::m *Unit::m)
 [square meters]
 
 DEFINE_UNIT (cm2, Unit::cm *Unit::cm)
 [square centimeters]
 
 DEFINE_UNIT (mm2, Unit::mm *Unit::mm)
 [square millimeters]
 
 DEFINE_UNIT (b, Unit::m2 *1e-28)
 [barn]
 
 DEFINE_UNIT (mb, Unit::b *1e-3)
 [millibarn]
 
 DEFINE_UNIT (ub, Unit::b *1e-6)
 [microbarn]
 
 DEFINE_UNIT (nb, Unit::b *1e-9)
 [nanobarn]
 
 DEFINE_UNIT (pb, Unit::b *1e-12)
 [picobarn]
 
 DEFINE_UNIT (fb, Unit::b *1e-15)
 [femtobarn]
 
 DEFINE_UNIT (ab, Unit::b *1e-18)
 [attobarn]
 
 DEFINE_UNIT (m3, Unit::m *Unit::m *Unit::m)
 [cubic meters]
 
 DEFINE_UNIT (cm3, Unit::cm *Unit::cm *Unit::cm)
 [cubic centimeters]
 
 DEFINE_UNIT (mm3, Unit::mm *Unit::mm *Unit::mm)
 [cubic millimeters]
 
 DEFINE_UNIT (s, Unit::ns *1e9)
 [second]
 
 DEFINE_UNIT (ms, Unit::s *1e-3)
 [millisecond]
 
 DEFINE_UNIT (us, Unit::s *1e-6)
 [microsecond]
 
 DEFINE_UNIT (ps, Unit::s *1e-12)
 [picosecond]
 
 DEFINE_UNIT (fs, Unit::s *1e-15)
 [femtosecond]
 
 DEFINE_UNIT (Hz, Unit::GHz *1e-9)
 [Hertz]
 
 DEFINE_UNIT (kHz, Unit::GHz *1e-6)
 [Kilohertz]
 
 DEFINE_UNIT (MHz, Unit::GHz *1e-3)
 [Megahertz]
 
 DEFINE_UNIT (mHz, Unit::GHz *1e-12)
 [Millihertz]
 
 DEFINE_UNIT (mrad, Unit::rad *1e-3)
 [millirad]
 
 DEFINE_UNIT (deg, TMath::DegToRad())
 degree to radians
 
 DEFINE_UNIT (eV, Unit::GeV *1e-9)
 [electronvolt]
 
 DEFINE_UNIT (keV, Unit::eV *1e3)
 [kiloelectronvolt]
 
 DEFINE_UNIT (MeV, Unit::eV *1e6)
 [megaelectronvolt]
 
 DEFINE_UNIT (TeV, Unit::eV *1e12)
 [teraelectronvolt]
 
 DEFINE_UNIT (J, 1.0/TMath::Qe() *Unit::eV)
 [joule]
 
 DEFINE_UNIT (V, Unit::eV/Unit::e)
 Standard of [voltage].
 
 DEFINE_UNIT (C, 1.0/TMath::Qe() *Unit::e)
 [Coulomb]
 
 DEFINE_UNIT (fC, Unit::C/1.0e15)
 [femtoCoulomb]
 
 DEFINE_UNIT (T, Unit::V *Unit::s/Unit::m2)
 [Tesla]
 
 DEFINE_UNIT (mT, Unit::T *1e-3)
 [millitesla]
 
 DEFINE_UNIT (Gauss, Unit::T *1e-4)
 [Gauss]
 
 DEFINE_UNIT (kGauss, Unit::Gauss *1e3)
 [kiloGauss]
 
 DEFINE_UNIT_NAME (mg_cm3, Unit::g_cm3 *1e-3, "mg/cm3")
 [mg/cm^3]
 
 DEFINE_UNIT_NAME (kg_cm3, Unit::g_cm3 *1e3, "kg/cm3")
 [kg/cm^3]
 
 DEFINE_UNIT_NAME (g_mm3, Unit::g_cm3/Unit::mm3, "g/mm3")
 [g/mm^3]
 
 DEFINE_UNIT_NAME (mg_mm3, Unit::mg_cm3/Unit::mm3, "mg/mm3")
 [mg/mm^3]
 
 DEFINE_UNIT_NAME (kg_mm3, Unit::kg_cm3/Unit::mm3, "kg/mm3")
 [kg/mm^3]
 
template<typename DataType >
Bool_t operator== (const TVector3 &a, const B2Vector3< DataType > &b)
 non-memberfunction Comparison for equality with a TVector3
 
template<typename DataType >
Bool_t operator!= (const TVector3 &a, const B2Vector3< DataType > &b)
 non-memberfunction Comparison for equality with a TVector3
 
template<typename DataType >
B2Vector3< DataType > operator* (DataType a, const B2Vector3< DataType > &p)
 non-memberfunction Scaling of 3-vectors with a real number
 
template<typename DataType >
B2Vector3< DataType > operator+ (const TVector3 &a, const B2Vector3< DataType > &b)
 non-memberfunction for adding a TVector3 to a B2Vector3
 
template<typename DataType >
B2Vector3< DataType > operator- (const TVector3 &a, const B2Vector3< DataType > &b)
 non-memberfunction for substracting a TVector3 from a B2Vector3
 
template<typename DataType >
B2Vector3< DataType > operator+ (const B2Vector3< DataType > &a, const TVector3 &b)
 non-memberfunction for adding a B2Vector3 to a TVector3
 
template<typename DataType >
B2Vector3< DataType > operator- (const B2Vector3< DataType > &a, const TVector3 &b)
 non-memberfunction for substracting a B2Vector3 from a TVector3
 
template<typename DataType >
B2Vector3< DataType > operator+ (const ROOT::Math::XYZVector &a, const B2Vector3< DataType > &b)
 non-memberfunction for adding a XYZVector to a B2Vector3
 
template<typename DataType >
B2Vector3< DataType > operator- (const ROOT::Math::XYZVector &a, const B2Vector3< DataType > &b)
 non-memberfunction for substracting a XYZVector from a B2Vector3
 
template<typename DataType >
B2Vector3< DataType > operator+ (const B2Vector3< DataType > &a, const ROOT::Math::XYZVector &b)
 non-memberfunction for adding a B2Vector3 to a XYZVector
 
template<typename DataType >
B2Vector3< DataType > operator- (const B2Vector3< DataType > &a, const ROOT::Math::XYZVector &b)
 non-memberfunction for substracting a B2Vector3 from a XYZVector
 
void injectBooleanOperatorToStream (std::ostream &stream, const BooleanOperator &boperator)
 Helper functions for AbstractBooleanNode and AbstractExpressionNode print() and decompile() members Shifts the correct characters into the ostream, depending on the BooleanOperator given.
 
void injectComparisonOperatorToStream (std::ostream &stream, const ComparisonOperator &coperator)
 Helper functions for AbstractBooleanNode and AbstractExpressionNode print() and decompile() members Shifts the correct characters into the ostream, depending on the ComparisonOperator given.
 
void injectArithmeticOperatorToStream (std::ostream &stream, const ArithmeticOperation &aoperation)
 Helper functions for AbstractBooleanNode and AbstractExpressionNode print() and decompile() members Shifts the correct characters into the ostream, depending on the ComparisonOperator given.
 
template<typename T >
convertString (const std::string &str)
 Converts a string to type T (one of float, double, long double, int, long int, unsigned long int).
 
unsigned long int findMatchedParenthesis (std::string str, char open='[', char close=']')
 Returns position of the matched closing parenthesis if the first character in the given string contains an opening parenthesis.
 
std::vector< std::string > splitOnDelimiterAndConserveParenthesis (std::string str, char delimiter, char open, char close)
 Split into std::vector on delimiter ignoring delimiters between parenthesis.
 
unsigned long int findIgnoringParenthesis (std::string str, std::string pattern, unsigned int begin=0)
 Returns the position of a pattern in a string ignoring everything that is in parenthesis.
 
bool almostEqualFloat (const float &a, const float &b)
 Helper function to test if two floats are almost equal.
 
bool almostEqualDouble (const double &a, const double &b)
 Helper function to test if two doubles are almost equal.
 
std::set< int64_t > generate_number_sequence (const std::string &str)
 Generate a sequence of numbers defined by a string.
 
template<>
float convertString (const std::string &str)
 Converts a string to float.
 
template<typename T >
void addParam (const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
 Adds a new parameter to the module.
 
template<typename T >
void addParam (const std::string &name, T &paramVariable, const std::string &description)
 Adds a new enforced parameter to the module.
 
template<typename T >
ModuleParam< T > & getParam (const std::string &name) const
 Returns a reference to a parameter.
 
static std::string TypeInfo ()
 Static function to generate a string description for the parameter type.
 
 ModuleParam (T &paramVariable, const std::string &description="", bool force=false)
 Constructor.
 
virtual ~ModuleParam ()
 Destructor.
 
void setValue (const T &value)
 Sets the value of a parameter.
 
void setDefaultValue (const T &defaultValue)
 Sets the default value of a parameter.
 
T & getValue ()
 Returns the value of the parameter.
 
T & getDefaultValue ()
 Returns the default value of the parameter.
 
virtual void setValueFromPythonObject (const boost::python::object &pyObject) final
 Implements a method for setting boost::python objects.
 
virtual void setValueToPythonObject (boost::python::object &pyObject, bool defaultValues=false) const final
 Returns a python object containing the value or the default value of the given parameter.
 
virtual void setValueFromParam (const ModuleParamBase &param) final
 Set value from other ModuleParam of same type.
 
void resetValue ()
 Resets the parameter value by assigning the default value to the parameter value.
 
template<typename T >
void addParameter (const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
 Adds a new parameter to the module list.
 
template<typename T >
void addParameter (const std::string &name, T &paramVariable, const std::string &description)
 Adds a new enforced parameter to the module list.
 
template<typename T >
void setParameter (const std::string &name, const T &value)
 Sets the value of a parameter given by its name.
 
template<typename T >
ModuleParam< T > & getParameter (const std::string &name) const
 Returns a reference to a parameter.
 
template<typename PythonObject >
void setParamPython (const std::string &name, const PythonObject &pyObj)
 Implements a method for setting boost::python objects.
 
template<typename PythonObject >
void getParamValuesPython (const std::string &name, PythonObject &pyOutput, bool defaultValues) const
 Returns a python object containing the value or default value of the given parameter.
 
uint64_t random64 ()
 Generate one 64bit unsigned integer between 0 and UINT64_MAX (both inclusive).
 
void RndmArray (Int_t n, Float_t *array)
 Fill an array of floats with random values in (0,1), both limits excluded.
 
void RndmArray (Int_t n, Double_t *array)
 Fill an array of doubles with random values in (0,1), both limits excluded.
 
void RndmArray (Int_t n, ULong64_t *array)
 Fill an array of unsigned 64bit integers with random values in [0, UINT64_MAX], both limits included.
 
void RndmArray (Int_t n, UInt_t *array)
 Fill an array of unsigned integers with random values in [0, UINT32_MAX], both limits included.
 
double random01 ()
 Generate a random double value between 0 and 1, both limits excluded.
 
static DatabaseInstance ()
 Instance of a singleton Database.
 
 ~Database ()
 Hidden destructor, as it is a singleton.
 
static void reset (bool keepConfig=false)
 Reset the database instance.
 
ScopeGuard createScopedUpdateSession ()
 Make sure we have efficient http pipelinging during initialize/beginRun but don't keep session alive for full processing time.
 
std::pair< TObject *, IntervalOfValiditygetData (const EventMetaData &event, const std::string &name)
 Request an object from the database.
 
bool getData (const EventMetaData &event, std::vector< DBQuery > &query)
 Request multiple objects from the database.
 
bool storeData (std::list< DBImportQuery > &query)
 Store multiple objects in the database.
 
bool storeData (const std::string &name, TObject *object, const IntervalOfValidity &iov)
 Store an object in the database.
 
std::string getGlobalTags ()
 Return the global tags used by the database.
 
void nextMetadataProvider ()
 Enable the next metadataprovider in the list.
 
void initialize (const EDatabaseState target=c_Ready)
 Initialize the database connection settings on first use.
 
static void exposePythonAPI ()
 Exposes setGlobalTag function of the Database class to Python.
 
 ~DBStore ()
 Destructor.
 
static DBStoreInstance ()
 Instance of a singleton DBStore.
 
DBStoreEntrygetEntry (DBStoreEntry::EPayloadType payloadType, const std::string &name, const TClass *objClass, bool array, bool required=true)
 Returns the entry with the requested name in the DBStore.
 
void update ()
 Updates all objects that are outside their interval of validity.
 
void update (const EventMetaData &event)
 Updates all objects that are outside their interval of validity.
 
void performUpdate (const EventMetaData &event)
 The main code that does an update, factored out so it can be used by both update and update(event).
 
void updateEvent ()
 Updates all intra-run dependent objects.
 
void updateEvent (const unsigned int eventNumber)
 Updates all intra-run dependent objects.
 
void performUpdateEvent (const EventMetaData &event)
 The main code that does an updateEvent.
 
void reset (bool keepEntries=false)
 Invalidate all payloads.
 
std::set< std::string > getAllEntryNames ()
 Return the names of all the payloads stored in the database at the time of this function is called.
 
void addConstantOverride (const std::string &name, TObject *obj, bool oneRun=false)
 Add constant override payload.
 
static DBStoreEntry fromObject (const std::string &name, const TObject *obj, bool isRequired)
 Construct a new DBStoreEntry with a requested name and an object directly.
 
 ~DBStoreEntry ()
 Clean up memory.
 
void updateObject (const EventMetaData &event)
 update the payload object according to the new event information.
 
void resetPayload ()
 reset the payload to nothing
 
void updatePayload (unsigned int revision, const IntervalOfValidity &iov, const std::string &filename, const std::string &checksum, const std::string &globaltag, const EventMetaData &event)
 Update the payload information for this entry and if appropriate open the new file and extract the object as needed.
 
void loadPayload (const EventMetaData &event)
 Actual load the payload from file after all info is set.
 
void overrideObject (TObject *obj, const IntervalOfValidity &iov)
 Set an override object in case we want to use a different object then actually provided by the database.
 
void notifyAccessors (bool onDestruction=false)
 Notify all the registered accessors.
 
bool checkType (EPayloadType type, const TClass *objClass, bool array, bool inverse=false) const
 Check if a given TClass is compatible with the type of this entry.
 
bool checkType (const TObject *object) const
 Check if a given TObject instance is compatible with the type of this entry.
 
template<class FunctionFrom , class FunctionTo >
void consolidate (const FunctionFrom &replaceFrom=FunctionFrom(), const FunctionTo &replaceTo=FunctionTo(), EConsolidationAction action=c_doNothing)
 Consolidate RelationElements.
 
void rebuild (bool force=false)
 Rebuild the index.
 
std::map< int, int > copySetWithRelations (std::function< bool(const StoredClass *)> f)
 Selects the elements, fill the subset and copies all the relations in which the set is involved.
 
void copyRelationsToSelf ()
 Copy any set -> set relations between selected objects.
 
void select (const std::function< bool(const StoredClass *)> &f)
 This method is the actual worker.
 
ROOT::Math::XYZVector getField (const ROOT::Math::XYZVector &pos) const
 Calculate the magnetic field at a given position.
 
void setBucket (unsigned i)
 Sets the fill status of RF bucket to true.
 
bool getBucket (int i) const
 Returns the fill status of RF bucket.
 
unsigned getNumOfFilledBuckets () const
 Returns the number of filled buckets.
 
unsigned generateBucketNumber () const
 Generates RF bucket number according to the fill pattern.
 
 Gearbox ()
 Singleton: private constructor.
 
 ~Gearbox ()
 Free structures on destruction.
 
static GearboxgetInstance ()
 Return reference to the Gearbox instance.
 
gearbox::InputContextopenXmlUri (const std::string &uri) const
 Function to be called when libxml requests a new input uri to be opened.
 
void setBackends (const std::vector< std::string > &backends)
 Select the backends to use to find resources.
 
void clearBackends ()
 Clear list of backends.
 
void open (const std::string &name="Belle2.xml", size_t cacheSize=c_DefaultCacheSize)
 Open connection to backend and parse tree.
 
void close ()
 Free internal structures of previously parsed tree and clear cache.
 
void overridePathValue (const PathOverride &poverride)
 Change the value of a given path expression.
 
PathValue getPathValue (const std::string &path) const
 Return the (cached) value of a given path.
 
virtual const TObject * getTObject (const std::string &path) const noexcept(false) override
 Get the parameter path as a TObject.
 
GearDir getDetectorComponent (const std::string &component)
 Return GearDir representing a given DetectorComponent.
 
static double convertValue (double value, const std::string &unitString)
 Converts a floating point value to the standard framework unit.
 
static double convertValueToUnit (double value, const std::string &unitString)
 Converts a floating point value from the standard framework unit to the given unit.
 
static double registerConversion (const std::string &name, double value)
 registers the name and value of a conversion in s_conversionFactors.
 
B2Vector3< DataType > & operator= (const B2Vector3< DataType > &b)
 Assignment via B2Vector3.
 
B2Vector3< DataType > & operator= (const TVector3 &b)
 Assignment via TVector3.
 
B2Vector3< DataType > & operator= (const ROOT::Math::XYZVector &b)
 Assignment via XYZVector.
 
B2Vector3< DataType > & operator+= (const B2Vector3< DataType > &b)
 addition
 
B2Vector3< DataType > & operator-= (const B2Vector3< DataType > &b)
 subtraction
 
B2Vector3< DataType > & operator*= (DataType a)
 scaling with real numbers
 
void SetXYZ (const TVector3 &tVec)
 set all coordinates using a reference to TVector3
 
void SetXYZ (const TVector3 *tVec)
 set all coordinates using a pointer to TVector3
 
void SetXYZ (const ROOT::Math::XYZVector &xyzVec)
 set all coordinates using a reference to XYZVector
 
void SetXYZ (const ROOT::Math::XYZVector *xyzVec)
 set all coordinates using a pointer to XYZVector
 
void GetXYZ (TVector3 *tVec) const
 directly copies coordinates to a TVector3
 
void GetXYZ (ROOT::Math::XYZVector *xyzVec) const
 directly copies coordinates to a XYZVector
 
TVector3 GetTVector3 () const
 returns a TVector3 containing the same coordinates
 
ROOT::Math::XYZVector GetXYZVector () const
 returns a XYZVector containing the same coordinates
 
DataType at (unsigned i) const
 safe member access (with boundary check!)
 
static std::string name ()
 Returns the name of the B2Vector.
 
ROOT::Math::XYZVector calculate (const ROOT::Math::XYZVector &pos) const
 Calculate the field value at a given position and return it.
 
static void getField (const double *pos, double *field)
 return the magnetic field at a given position.
 
const LogConfiggetCurrentLogConfig (const char *package=nullptr) const
 Returns the current LogConfig object used by the logging system.
 
bool isLevelEnabled (LogConfig::ELogLevel level, int debugLevel=0, const char *package=nullptr) const
 Returns true if the given log level is allowed by the log system (i.e.
 
 LogConnectionJSON (bool complete=false)
 The constructor.
 
bool sendMessage (const LogMessage &message) override
 Sends a log message.
 
std::string __repr__ () const
 Return a string repesentation of this particle to be used when printing the particle in python.
 
template<class AZMQClient >
void sendToSocket (const AZMQClient &socket)
 Publish this event backup directly to the given client.
 
template<class AZMQClient >
void sendWorkerBackupEvents (unsigned int worker, const AZMQClient &socket)
 Send all backups of a given worker directly to the multicast and delete them.
 
template<class AMulticastAnswer , class ASocketAnswer >
int poll (unsigned int timeout, AMulticastAnswer multicastAnswer, ASocketAnswer socketAnswer) const
 Poll both the multicast and the data socket until, either:
 
template<class ASocketAnswer >
int pollSocket (unsigned int timeout, ASocketAnswer socketAnswer) const
 Poll method to only the data socket.
 
template<class AMulticastAnswer >
int pollMulticast (unsigned int timeout, AMulticastAnswer multicastAnswer) const
 Poll method to only the multicast socket.
 
template<class AClass >
void log (const std::string &key, const AClass &value)
 Store a value under a certain key. Different types of values can be stored, namely long, double or string. Mixtures are not allowed for a given key.
 
template<size_t MAX_SIZE = 100>
void average (const std::string &key, double value)
 Instead of storeing the double value directly under the given key, store the average of the last MAX_SIZE values.
 
template<size_t AVERAGE_SIZE = 2000>
void timeit (const std::string &key)
 Measure the rate of calls with the same key every AVERAGE_SIZE calls (and also display the last time AVERAGE_SIZE was reached under <key>_last_measurement)
 
template<int AZMQType>
std::unique_ptr< zmq::socket_t > createSocket (const std::string &socketAddress, bool bind)
 Create a socket of the given type with the given address and bind or not bind it.
 
template<int AZMQType>
std::unique_ptr< zmq::socket_t > createSocket (const std::string &socketAddress)
 Create a socket of the given type while deciding on the bind behaviour via the address.
 
template<class AZMQMessage >
static void send (std::unique_ptr< zmq::socket_t > &socket, AZMQMessage message)
 Send a given message over the given created socket. You need to move in the message for zero-copy.
 
template<class value_type >
bool setMeanCov (const TVectorT< value_type > &mean, const TMatrixTBase< value_type > &cov)
 set mean and covariance matrix from ROOT vector/matrix objects, e.g.
 
template<class value_type >
bool setMeanCov (const ROOT::Math::XYZVector &mean, const TMatrixTBase< value_type > &cov)
 set the mean and covariance for the distribution.
 
static bool isSet (const std::string &name)
 Check if a value is set in the database.
 
static std::string get (const std::string &name, const std::string &fallback="")
 Get the value of an environment variable or the given fallback value if the variable is not set.
 
static std::vector< std::string > getList (const std::string &name, const std::vector< std::string > &fallback={}, const std::string &separators=" \t\n\r")
 Get a list of values from an environment variable or the given fallback list if the variable is not set.
 
static std::vector< std::string > getOrCreateList (const std::string &name, const std::string &fallback, const std::string &separators=" \t\n\r")
 Get a list of values from an environment variable or the given fallback string if the variable is not set.
 
static std::string expand (const std::string &text)
 Modify the given string and replace every occurence of $NAME or ${NAME} with the value of the environment variable NAME.
 
static char operatorToChar (EOperator op) noexcept
 Convert operator code to character.
 
static double applyOperator (EOperator op, double a, double b)
 Apply operator on two values.
 
static ENumberStatus checkNumber (ENumberStatus current, char next)
 Check if a string literal with a given number status continues to be a valid number if next is appended to it.
 
static void assertOperatorUsable (size_t stacksize)
 Make sure we have enough operands to use an operator.
 
void addOperator (EOperator op)
 Add an operator to the internal state, convert them to reverse polish notation using the shunting yard algorithm and execute them as they become available.
 
void flushPendingOperators ()
 Flush all pending operators at the end of processing.
 
void flushCurrentVariable ()
 Flush the currently parsed variable name and add it to the state either as variable or number.
 
EOperator checkForOperator (char next)
 Check if the next character is a operator.
 
void processString (const std::string &formula)
 Process the given formula and store the final state.
 
void raiseError (const std::runtime_error &e)
 Format the given runtime_error with context information and rethrow a new one.
 
std::shared_ptr< TFile > getFile (std::string, bool ignoreErrors=false)
 Get a file with a specific name, if is does not exist it will be created.
 
static RootFileCreationManagergetInstance ()
 Interface for the FileManager.
 

Variables

std::string DBPointer_defaultName = ""
 Use default name for array in DBPointer.
 
static constexpr auto XYZToTVector
 Helper function to convert XYZVector to TVector3.
 
static std::map< std::string, double > s_conversionFactors
 Map to be able to convert between units using string representations of the unit name.
 

Detailed Description

Macro Definition Documentation

◆ _PACKAGE_

#define _PACKAGE_   ""

make sure REG_MODULE works outside the normal build system

Definition at line 643 of file Module.h.

◆ B2_GEARBOX_REGISTER_INPUTHANDLER

#define B2_GEARBOX_REGISTER_INPUTHANDLER (   classname,
  prefix 
)     InputHandlerFactory<classname> Gearbox_InputHandlerFactory_##classname(prefix)

Helper macro to easily register new input handlers.

It will create a factory function for the InputHandler and register it with the Gearbox instance

Parameters
classnameClassname to create factory for
prefixPrefix to register the handler for, e.g. "file" to register a handler responsible for uris starting with file:

Definition at line 256 of file Gearbox.h.

◆ B2INFO_MEASURE_TIME

#define B2INFO_MEASURE_TIME (   txt,
  ... 
)
Value:
{\
std::stringstream __b2_timer_str__;\
__b2_timer_str__ << txt;\
::Belle2::Utils::Timer __b2_timer__(__b2_timer_str__.str());\
{__VA_ARGS__;}\
}
Small helper class that prints its lifetime when destroyed.
Definition: Utils.h:79

Print an INFO message txt followed by the time it took to execute the statment given as second argument.

Care should be taken not to define variables in this call since they will be scoped and thus unavaiable after the macro

Definition at line 102 of file Utils.h.

◆ BELLE2_DEFINE_EXCEPTION

#define BELLE2_DEFINE_EXCEPTION (   ClassName,
  Message 
)
Value:
class ClassName : public std::runtime_error { \
public: \
ClassName(): std::runtime_error(""), m_format(Message) { } \
~ClassName() noexcept {} \
virtual const char * what() const noexcept override { \
m_finalStr = m_format.str();\
return m_finalStr.c_str();\
}\
template <class T> ClassName& operator<<(const T& param) {\
m_format % param;\
return *this;\
}\
private:\
boost::format m_format;\
mutable std::string m_finalStr;\
};
STL namespace.

Macro that defines an exception with the given message template.

Use the macro inside your class (header file) and specify a class name for your exception, plus a format string that contains a description of what went wrong:

BELLE2_DEFINE_EXCEPTION(ModuleNotCreatedError, "Could not create module: %1%")
#define BELLE2_DEFINE_EXCEPTION(ClassName, Message)
Macro that defines an exception with the given message template.

When throwing, simply create an instance of this class, use operator<< to fill any placeholders (n%) specified, and pass this to the throw keyword:

throw (ModuleNotCreatedError() << moduleName);

Exceptions defined using this macro inherit from std::runtime_error, and can be queried using their what() member.

Definition at line 36 of file FrameworkExceptions.h.

◆ branch_likely

#define branch_likely (   x)    (x)

Usage:

if (branch_unlikely(my_number > 10)) {
  // executed only rarely
} else {
  // executed very often
}

Definition at line 133 of file Utils.h.

◆ branch_unlikely

#define branch_unlikely (   x)    (x)

A macro to tell the compiler that the argument x will be very likely be false.

This could result in optimized code as the compiler can reorder the code to reduce conditional jumps during execution. Due to the high efficiency of todays branch prediction systems the effect is probably small.

Warning
Use of this macro should be accompanied by a comment documenting the (significant) performance gains that justify its use. (Please make sure you compile in 'opt' mode.)
See also

Definition at line 134 of file Utils.h.

◆ DEFINE_UNIT

#define DEFINE_UNIT (   var,
  value 
)    DEFINE_UNIT_NAME(var,value,#var)

Define a new Unit and take the variable name as name for the conversion table.

Definition at line 35 of file UnitConst.cc.

◆ DEFINE_UNIT_NAME

#define DEFINE_UNIT_NAME (   var,
  value,
  name 
)    const double Unit::var = Unit::registerConversion(name,value)

Define a new Unit given a name for the conversion table.

Definition at line 33 of file UnitConst.cc.

◆ REG_MODULE

#define REG_MODULE (   moduleName)
Value:
namespace { struct ModuleProxy##moduleName: public ModuleProxyBase { \
ModuleProxy##moduleName(): ModuleProxyBase(#moduleName, "" _PACKAGE_) {} \
virtual ::Belle2::Module* createInstance() const override final { return new moduleName##Module(); } \
} proxy##moduleName##Module; }
#define _PACKAGE_
make sure REG_MODULE works outside the normal build system
Definition: Module.h:643

Register the given module (without 'Module' suffix) with the framework.

Definition at line 650 of file Module.h.

◆ REGISTER_PYTHON_MODULE

#define REGISTER_PYTHON_MODULE (   moduleName)    Belle2::BoostPythonModuleProxy boostPythonModuleProxy##moduleName(#moduleName, PyInit_##moduleName);

Register a python module to make available when loading the library.

Use it by defining your module via BOOST_PYTHON_MODULE(name), then call REGISTER_PYTHON_MODULE(name) with the same name.

After the library has been loaded, you can use 'import name' to import the defined objects.

Definition at line 36 of file RegisterPythonModule.h.

◆ REGISTER_PYTHON_MODULE_AUTOIMPORT

#define REGISTER_PYTHON_MODULE_AUTOIMPORT (   moduleName)    Belle2::BoostPythonModuleProxy boostPythonModuleProxy##moduleName(#moduleName, PyInit_##moduleName, true);

Identical to REGISTER_PYTHON_MODULE(), but will also import the module into the global namespace after loading it.

This might be useful to allow extra definitions for individual basf2 modules, consider for example:

//in MyTestModule.h (preferably as a member of your Module class):
enum class Shape {
Sphere,
Cube
};
//in MyTestModule.cc
#include <boost/python.hpp>
#include <framework/utilities/RegisterPythonModule.h>
//...
using namespace boost::python;
BOOST_PYTHON_MODULE(MyTest)
{
//export enum to python, e.g. Shape::Sphere becomes Shape.Sphere
enum_<Shape>("Shape")
.value("Sphere", Shape::Sphere)
.value("Cube", Shape::Cube)
;
}
#define REGISTER_PYTHON_MODULE_AUTOIMPORT(moduleName)
Identical to REGISTER_PYTHON_MODULE(), but will also import the module into the global namespace afte...

In a steering file, the type MyTest.Sphere is available immediately after register_module('MyTest').

Definition at line 74 of file RegisterPythonModule.h.

Typedef Documentation

◆ AccessorParams

typedef std::pair<std::string, DataStore::EDurability> AccessorParams

Pair of parameters needed to find an object in the DataStore.

Definition at line 24 of file StoreAccessorBase.h.

◆ B2Vector3D

typedef B2Vector3<double> B2Vector3D

typedef for common usage with double

Definition at line 516 of file B2Vector3.h.

◆ B2Vector3F

typedef B2Vector3<float> B2Vector3F

typedef for common usage with float

Definition at line 519 of file B2Vector3.h.

◆ ModuleParamPtr

using ModuleParamPtr = std::shared_ptr<ModuleParamBase>

Defines a pointer to a module parameter as a boost shared pointer. *‍/.

Definition at line 38 of file ModuleParamList.h.

◆ ModulePtr

typedef std::shared_ptr<Module> ModulePtr

Defines a pointer to a module object as a boost shared pointer.

Definition at line 43 of file Module.h.

◆ ModulePtrList

typedef std::list<ModulePtr> ModulePtrList

Defines a std::list of shared module pointers.

Definition at line 584 of file Module.h.

◆ PathPtr

typedef std::shared_ptr<Path> PathPtr

Defines a pointer to a path object as a boost shared pointer.

Definition at line 35 of file Path.h.

◆ RelationsObject

Provides interface for getting/adding relations to objects in StoreArrays.

See RelationsInterface for details.

Definition at line 441 of file RelationsObject.h.

Enumeration Type Documentation

◆ ArithmeticOperation

enum class ArithmeticOperation : int
strong

Enum for decoding the comparison operator type.

For encoding scheme in python

See also
a_operator_types in yacc.py

Definition at line 141 of file AbstractNodes.h.

141 : int {
142 PLUS,
143 MINUS,
144 PRODUCT,
145 DIVISION,
146 POWER
147 };

◆ BooleanOperator

enum class BooleanOperator : int
strong

Enum for decoding the boolean operator type.

For encoding scheme in python

See also
b_operator_types in yacc.py

Definition at line 119 of file AbstractNodes.h.

119 : int {
120 AND,
121 OR
122 };

◆ ComparisonOperator

enum class ComparisonOperator : int
strong

Enum for decoding the comparison operator type.

For encoding scheme in python

See also
c_operator_types in yacc.py

Definition at line 128 of file AbstractNodes.h.

128 : int {
129 EQUALEQUAL,
130 GREATEREQUAL,
131 LESSEQUAL,
132 GREATER,
133 LESS,
134 NOTEQUAL
135 };

◆ EMessageTypes

enum class EMessageTypes
strong

Type the messages can have.

Definition at line 16 of file ZMQDefinitions.h.

16 {
17 // Used by DAQ and Framework: general control messages
18 c_confirmMessage = 'c', // is sent when an event is confirmed to be at the output process
19 c_helloMessage = 'h', // registration
20 c_deleteWorkerMessage = 'd', // Delete the events of a given worker
21 c_lastEventMessage = 'l', // indicates the last event was processed by the process
22 c_readyMessage = 'r', // is sent from the worker to the input to show, that it can process an event
23 c_terminateMessage = 'x', // Ask all processes to (gently) stop
24
25 // Used by DAQ and Framework: event messages
26 c_rawDataMessage = 'u', // a normal message with event data but in raw format
27 c_compressedDataMessage = 'v', // a normal message with event data but in compressed format
28 c_eventMessage = 'w', // a normal message with event data
29
30 // Only needed by framework
31 c_goodbyeMessage = 'g', // un-registration
32 c_statisticMessage = 's', // the last statistics will be send from the output to the process monitor
33 c_killWorkerMessage = 'k', // is sent when a worker should be killed (because it needed too much time)
34
35 // Only needed by DAQ
36 c_monitoringMessage = 'm', // sent in DAQ package to monitor from remote
37 c_newRunMessage = 'n', // sent in DAQ package on starting
38 };

◆ ERecordType

What type of message is this?

Note: for parallel processing, the only type that can work is MSG_EVENT. Other messages would need to be sent once to each process, which would result in all kinds of race conditions.

Definition at line 25 of file EvtMessage.h.

25{ MSG_EVENT, MSG_BEGIN_RUN, MSG_END_RUN, MSG_TERMINATE, MSG_NORECORD, MSG_STREAMERINFO };

◆ NodeType

enum class NodeType : int
strong

Enum of possible Nodes in parsing tree.

NodeTypes in python are encoded with the corresponding dict

See also
node_types in yacc.py

Definition at line 100 of file AbstractNodes.h.

100 : int {
101 UnaryBooleanNode,
102 BinaryBooleanNode,
103 UnaryRelationalNode,
104 BinaryRelationalNode,
105 TernaryRelationalNode,
106 UnaryExpressionNode,
107 BinaryExpressionNode,
108 FunctionNode,
109 IdentifierNode,
110 DoubleNode,
111 IntegerNode,
112 BooleanNode
113 };

◆ ProcType

enum class ProcType
strong

Type of the process used for storing and mapping the child processes in the process handler.

Enumerator
c_Input 

Input Process.

c_Worker 

Worker/Reconstruction Process.

c_Output 

Output Process.

c_Proxy 

Multicast Proxy Process.

c_Monitor 

Monitoring Process.

c_Init 

Before the forks, the process is in init state.

c_Stopped 

The process is stopped/killed.

Definition at line 16 of file ProcHelper.h.

16 {
17 c_Input = 'i',
18 c_Worker = 'w',
19 c_Output = 'o',
20 c_Proxy = 'p',
21 c_Monitor = 'm',
22 c_Init = '0',
23 c_Stopped = 's'
24 };
@ c_Proxy
Multicast Proxy Process.
@ c_Output
Output Process.
@ c_Worker
Worker/Reconstruction Process.
@ c_Monitor
Monitoring Process.
@ c_Input
Input Process.
@ c_Stopped
The process is stopped/killed.
@ c_Init
Before the forks, the process is in init state.

◆ ZMQAddressType

The type of a ZMQ socket address (which socket to use)

Enumerator
c_output 

Input socket.

c_pub 

Output socket.

c_sub 

Multicast publish socket.

c_control 

Multicast subscribe socket.

Multicast control socket

Definition at line 18 of file ZMQAddressUtils.h.

18 {
19 c_input,
20 c_output,
21 c_pub,
22 c_sub,
24 };
@ c_sub
Multicast publish socket.
@ c_control
Multicast subscribe socket.
@ c_pub
Output socket.
@ c_output
Input socket.

Function Documentation

◆ __repr__()

std::string __repr__ ( ) const

Return a string repesentation of this particle to be used when printing the particle in python.

Definition at line 18 of file EvtGenParticlePDG.cc.

19 {
20 std::stringstream buf;
21 buf << "<Particle " << std::quoted(GetName());
22 buf << " mass=" << Mass() << " width=" << Width();
23 buf << std::setprecision(2) << " charge=" << (Charge() / 3.);
24 buf << " pdg=" << PdgCode() << ">";
25 return buf.str();
26 }

◆ addConstantOverride()

void addConstantOverride ( const std::string &  name,
TObject *  obj,
bool  oneRun = false 
)

Add constant override payload.

This payload will be valid for all possible iov and will be used instead of values from the database.

Parameters
nameName under which the object will be accessible
objPointer to the object to be used. Ownership will be transfered to the DBStore.
oneRunif true the override will only be in effect for this one run, not for any other runs
Warning
don't use this if you do not know exactly what you are doing. This is meant mainly for beamparameters

Definition at line 204 of file DBStore.cc.

205 {
206 IntervalOfValidity iov = IntervalOfValidity::always();
207 if (oneRun) {
208 int exp, run;
209 if (m_manualEvent) {
210 exp = m_manualEvent->getExperiment();
211 run = m_manualEvent->getRun();
212 } else {
213 exp = m_storeEvent->getExperiment();
214 run = m_storeEvent->getRun();
215 }
216 iov = IntervalOfValidity(exp, run, exp, run);
217 }
218 // Add the DBStore entry
219 auto iter = m_dbEntries.find(name);
220 if (iter == end(m_dbEntries)) {
221 iter = m_dbEntries.emplace(name, DBStoreEntry::fromObject(name, obj, true)).first;
222 }
223 DBStoreEntry& dbEntry = iter->second;
224 dbEntry.overrideObject(obj, iov);
225 // we need to remove this entry from the intraRunDependencies list now.
226 // Otherwise it will reset the object on the next event call
227 m_intraRunDependencies.erase(&dbEntry);
228 B2WARNING("An override for DBEntry " << name << " was created.");
229 }
StoreObjPtr< EventMetaData > m_storeEvent
StoreObjPtr for the EventMetaData to get the current experiment and run from the DataStore.
Definition: DBStore.h:174
std::set< DBStoreEntry * > m_intraRunDependencies
List of intra-run dependent conditions.
Definition: DBStore.h:169
std::optional< EventMetaData > m_manualEvent
Optional EventMetaData variable.
Definition: DBStore.h:181
std::unordered_map< std::string, DBStoreEntry > m_dbEntries
Map names to DBEntry objects.
Definition: DBStore.h:166
static IntervalOfValidity always()
Function that returns an interval of validity that is always valid, c.f.
static DBStoreEntry fromObject(const std::string &name, const TObject *obj, bool isRequired)
Construct a new DBStoreEntry with a requested name and an object directly.
Definition: DBStoreEntry.cc:37

◆ addOperator()

void addOperator ( EOperator  op)
private

Add an operator to the internal state, convert them to reverse polish notation using the shunting yard algorithm and execute them as they become available.

Definition at line 111 of file FormulaParser.cc.

112 {
114 //the last thing we added was a variable so a bracket doesn't make sense
115 if (!m_lastTokenWasOperator) throw std::runtime_error("missing operator");
116 // otherwise, ont the stack it goes
117 m_operatorStack.push(op);
118 return;
119 }
121 // closing bracket. Look for a matching opening bracket and execute all
122 // operators until then
125 if (op == EOperator::c_squareBracketClose) std::swap(correct, wrong);
126 while (!m_operatorStack.empty()) {
127 EOperator tok = m_operatorStack.top();
128 m_operatorStack.pop();
129 if (tok == wrong) throw std::runtime_error("wrong type of closing bracket");
130 if (tok == correct) return;
131 executeOperator(tok);
132 }
133 // stack is empty, still no bracket
134 throw std::runtime_error("unmatched bracket");
135 }
136
137 // Ok, now normal operators: there shouldn't be two in a row
138 if (m_lastTokenWasOperator) throw std::runtime_error("missing operand before operator");
140
141 // The operator precedence is in the upper 4 bits ... hrhr
142 // TODO: make a function for this?
143 int op_precedence = (int)op >> 4;
144 while (!m_operatorStack.empty()) {
145 EOperator tok = m_operatorStack.top();
146 // Stop at brackets
148 int tok_precedence = (int)tok >> 4;
149 // Pow operator has right assiocativity, all others are left associative
150 // TODO: make nicer?
151 bool tok_right = op == EOperator::c_power;
152 // If the token has lower precedence or equal precedence but is right associative stop taking tokens
153 if (tok_precedence < op_precedence or (tok_precedence == op_precedence and tok_right)) break;
154 // otherwise pop and execute
155 executeOperator(tok);
156 m_operatorStack.pop();
157 }
158 m_operatorStack.push(op);
159 }
virtual void executeOperator(EOperator op)=0
Execute an operator on the current state.
std::stack< EOperator > m_operatorStack
Stack of operators for the Shunting-yard algorithm.
EOperator
List of known operators.
Definition: FormulaParser.h:31
@ c_roundBracketClose
Close round bracket.
@ c_roundBracketOpen
Open round bracket.
@ c_squareBracketOpen
Open square bracket.
@ c_squareBracketClose
Close square bracket.
bool m_lastTokenWasOperator
Bool to check whether there were consecutive operators or variables.

◆ addParam() [1/2]

void addParam ( const std::string &  name,
T &  paramVariable,
const std::string &  description 
)
protected

Adds a new enforced parameter to the module.

This method has to be called in the constructor of the module. The user has to set the value for this parameter in the steering file.

Parameters
nameThe unique name of the parameter.
paramVariableThe member variable of the module to which the value from the steering file is written.
descriptionA description of the parameter.

Definition at line 567 of file Module.h.

568 {
569 m_moduleParamList.addParameter(name, paramVariable, description);
570 }
ModuleParamList m_moduleParamList
List storing and managing all parameter of the module.
Definition: Module.h:516
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.

◆ addParam() [2/2]

void addParam ( const std::string &  name,
T &  paramVariable,
const std::string &  description,
const T &  defaultValue 
)
protected

Adds a new parameter to the module.

This method has to be called in the constructor of the module.

Parameters
nameThe unique name of the parameter.
paramVariableThe member variable of the module to which the value from the steering file is written.
descriptionA description of the parameter.
defaultValueThe default value of the parameter which is used if there was no value given in the steering file.

Definition at line 560 of file Module.h.

561 {
562 m_moduleParamList.addParameter(name, paramVariable, description, defaultValue);
563 }

◆ addParameter() [1/2]

void addParameter ( const std::string &  name,
T &  paramVariable,
const std::string &  description 
)

Adds a new enforced parameter to the module list.

A parameter consists of a reference pointing to a member variable in the module which stores and allows fast access to the parameter value. In addition the type of the parameter is saved and a description is given. This parameter has to be set by the user in the steering file.

Parameters
nameThe unique name of the parameter.
paramVariableReference to the variable which stores the parameter value.
descriptionAn description of the parameter.

Definition at line 50 of file ModuleParamList.templateDetails.h.

53 {
54 ModuleParamPtr newParam(new ModuleParam<T>(paramVariable, description, true));
55
56 // Check if a parameter with the given name already exists
57 std::map<std::string, ModuleParamPtr>::iterator mapIter;
58 mapIter = m_paramMap.find(name);
59
60 if (mapIter == m_paramMap.end()) {
61 m_paramMap.insert(std::make_pair(name, newParam));
62 } else {
63 B2ERROR("A parameter with the name '" + name +
64 "' already exists! The name of a module parameter must be unique within a module.");
65 }
66 }
std::map< std::string, ModuleParamPtr > m_paramMap
Stores the module parameters together with a string name as key.
std::shared_ptr< ModuleParamBase > ModuleParamPtr
Defines a pointer to a module parameter as a boost shared pointer. *‍/.

◆ addParameter() [2/2]

void addParameter ( const std::string &  name,
T &  paramVariable,
const std::string &  description,
const T &  defaultValue 
)

Adds a new parameter to the module list.

A parameter consists of a reference pointing to a member variable in the module which stores and allows fast access to the parameter value. In addition the type of the parameter is saved and a description is given.

Parameters
nameThe unique name of the parameter.
paramVariableReference to the variable which stores the parameter value.
descriptionAn description of the parameter.
defaultValueThe default value of the parameter.

Definition at line 28 of file ModuleParamList.templateDetails.h.

32 {
33 ModuleParamPtr newParam(new ModuleParam<T>(paramVariable, description, false));
34
35 // Check if a parameter with the given name already exists
36 std::map<std::string, ModuleParamPtr>::iterator mapIter;
37 mapIter = m_paramMap.find(name);
38
39 if (mapIter == m_paramMap.end()) {
40 m_paramMap.insert(std::make_pair(name, newParam));
41 ModuleParam<T>* explModParam = static_cast<ModuleParam<T>*>(newParam.get());
42 explModParam->setDefaultValue(defaultValue);
43 } else {
44 B2ERROR("A parameter with the name '" + name +
45 "' already exists! The name of a module parameter must be unique within a module.");
46 }
47 }

◆ almostEqualDouble()

bool almostEqualDouble ( const double &  a,
const double &  b 
)

Helper function to test if two doubles are almost equal.

Forward declaration of function defined in framework/utilities/GeneralCut.cc.

Definition at line 26 of file CutHelpers.cc.

27 {
28 static_assert(sizeof(double) == sizeof(int64_t));
29 // cppcheck-suppress invalidPointerCast
30 return std::fabs(*(int64_t*)&a - * (int64_t*)&b) <= 2 or (a == b);
31 }

◆ almostEqualFloat()

bool almostEqualFloat ( const float &  a,
const float &  b 
)

Helper function to test if two floats are almost equal.

Definition at line 19 of file CutHelpers.cc.

20 {
21 static_assert(sizeof(float) == sizeof(int32_t));
22 // cppcheck-suppress invalidPointerCast
23 return std::fabs(*(int32_t*)&a - * (int32_t*)&b) <= 2 or (a == b);
24 }

◆ applyOperator()

double applyOperator ( EOperator  op,
double  a,
double  b 
)
static

Apply operator on two values.

Definition at line 36 of file FormulaParser.cc.

37 {
38 switch (op) {
39 case EOperator::c_plus: return a + b;
40 case EOperator::c_minus: return a - b;
41 case EOperator::c_multiply: return a * b;
42 case EOperator::c_divide: return a / b;
43 case EOperator::c_power: return std::pow(a, b);
44 default: throw std::runtime_error(std::string("Cannot apply operator ") + operatorToChar(op));
45 }
46 return 0;
47 }
static char operatorToChar(EOperator op) noexcept
Convert operator code to character.

◆ assertOperatorUsable()

void assertOperatorUsable ( size_t  stacksize)
staticprotected

Make sure we have enough operands to use an operator.

Definition at line 102 of file FormulaParser.cc.

103 {
104 // we only have binary operators so we need two operands
105 if (stacksize < 1)
106 throw std::runtime_error("could not parse, stack of operands empty. Please report, this is most likely a bug");
107 if (stacksize < 2)
108 throw std::runtime_error("Missing operand");
109 }

◆ at()

DataType at ( unsigned  i) const

safe member access (with boundary check!)

safe member access (with boundary check!) should always be used!

Definition at line 751 of file B2Vector3.h.

752 {
753 switch (i) {
754 case 0:
756 case 1:
758 case 2:
760 }
761 B2FATAL(this->name() << "::access operator: given index (i=" << i << ") is out of bounds!");
762 return 0.;
763 }
DataType m_coordinates[3]
Make sure that we only have floating point vectors.
Definition: B2Vector3.h:47
static std::string name()
Returns the name of the B2Vector.
Definition: B2Vector3.h:767

◆ average()

void average ( const std::string &  key,
double  value 
)

Instead of storeing the double value directly under the given key, store the average of the last MAX_SIZE values.

Definition at line 102 of file ZMQLogger.h.

103 {
104 auto& [averages, index] = m_averages[key];
105
106 if (averages.size() == MAX_SIZE) {
107 averages[index] = value;
108 index = (index + 1) % MAX_SIZE;
109 } else {
110 averages.push_back(value);
111 }
112
113 log(key, std::accumulate(averages.begin(), averages.end(), 0.0) / averages.size());
114 }
std::unordered_map< std::string, std::tuple< std::vector< double >, size_t > > m_averages
Internal storage of the previous values when calculating averages.
Definition: ZMQLogger.h:60
void log(const std::string &key, const AClass &value)
Store a value under a certain key. Different types of values can be stored, namely long,...
Definition: ZMQLogger.h:96

◆ calculate()

ROOT::Math::XYZVector calculate ( const ROOT::Math::XYZVector &  pos) const
inlineprivate

Calculate the field value at a given position and return it.

Parameters
posposition where to evaluate the magnetic field
Returns
magnetic field value at position pos

Definition at line 85 of file BFieldManager.h.

86 {
87 if (!m_magfield) B2FATAL("Could not load magnetic field configuration from database");
88 return m_magfield->getField(pos);
89 };
DBObjPtr< MagneticField > m_magfield
Pointer to the actual magnetic field in the database.
Definition: BFieldManager.h:82

◆ checkForOperator()

auto checkForOperator ( char  next)
private

Check if the next character is a operator.

Definition at line 192 of file FormulaParser.cc.

193 {
194 if (next == '+' or next == '-') {
195 // plus and minus are also part of literals so only treat it as operator
196 // if, together with the next character, this is not a valid float literal
198 if (isvalid != ENumberStatus::c_Invalid and checkNumber(isvalid, m_buffer.peek()) != ENumberStatus::c_Invalid) {
199 // this looks like a number don't interpret as operator
200 return EOperator::c_noop;
201 }
202 if (next == '+') return EOperator::c_plus;
203 if (next == '-') return EOperator::c_minus;
204 }
205 if (next == '/') return EOperator::c_divide;
206 if (next == '^') return EOperator::c_power;
207 if (next == '*') {
208 // is it python style '**'? if yes, remove one char from stream and
209 // assume pow
210 if (m_buffer.peek() == '*') {
211 m_buffer.get();
212 return EOperator::c_power;
213 }
214 // otherwise multiply
216 }
217 if (next == '(') return EOperator::c_roundBracketOpen;
218 if (next == ')') return EOperator::c_roundBracketClose;
219 if (next == '[') return EOperator::c_squareBracketOpen;
220 if (next == ']') return EOperator::c_squareBracketClose;
221 // no operator, so let's return just that
222 return EOperator::c_noop;
223 }
std::istringstream m_buffer
Buffer for the formula.
ENumberStatus m_currentVariableNameNumberStatus
State of the current variable name being a valid float literal.
static ENumberStatus checkNumber(ENumberStatus current, char next)
Check if a string literal with a given number status continues to be a valid number if next is append...

◆ checkNumber()

auto checkNumber ( ENumberStatus  current,
char  next 
)
static

Check if a string literal with a given number status continues to be a valid number if next is appended to it.

Definition at line 49 of file FormulaParser.cc.

50 {
51 switch (current) {
53 // invalid stays invalid
56 // numbers are allowed to start with digits, a dot or a sign
57 if (std::isdigit(next)) return ENumberStatus::c_Int;
58 if (next == '.') return ENumberStatus::c_LeadingDot;
59 if (next == '+' or next == '-') return ENumberStatus::c_Sign;
60 // everything else we don't like
63 // if we started with a sign we can only go to digit and dots, no exponent
64 if (std::isdigit(next)) return ENumberStatus::c_Int;
65 if (next == '.') return ENumberStatus::c_Dot;
68 // So far it's a valid int consisting only of [sign +] digits, next
69 // stage is more digits, a . or an exponent
70 if (std::isdigit(next)) return ENumberStatus::c_Int;
71 if (next == '.') return ENumberStatus::c_Dot;
72 if (next == 'E' or next == 'e') return ENumberStatus::c_Exponent;
75 // After the dot there can be more digits ... or a exponent
76 if (std::isdigit(next)) return ENumberStatus::c_Float;
77 if (next == 'E' or next == 'e') return ENumberStatus::c_Exponent;
80 // But if the dot was in the beginning then no exponent
81 if (std::isdigit(next)) return ENumberStatus::c_Float;
83 // so, we saw some digits after the dot ... more digits or exponent it is
85 if (std::isdigit(next)) return ENumberStatus::c_Float;
86 if (next == 'E' or next == 'e') return ENumberStatus::c_Exponent;
89 // and for the exponent we need either additional digits or a sign
90 if (std::isdigit(next)) return ENumberStatus::c_Scientific;
91 if (next == '+' or next == '-') return ENumberStatus::c_ExponentSign;
95 // and after the exponent sign and any digit thereafter only digits are possible
96 if (std::isdigit(next)) return ENumberStatus::c_Scientific;
98 }
100 }
@ c_LeadingDot
leading dot without preceding digits
@ c_Float
[leading sign] + [digits] + dot + digits
@ c_Scientific
exponent followed by sign and digits
@ c_Dot
[leading sign] + digits + dot
@ c_ExponentSign
exponent followed by plus or minus

◆ checkType() [1/2]

bool checkType ( const TObject *  object) const
private

Check if a given TObject instance is compatible with the type of this entry.

Definition at line 228 of file DBStoreEntry.cc.

229 {
230 // Get class information from object
231 if (object->InheritsFrom(IntraRunDependency::Class())) {
232 object = static_cast<const IntraRunDependency*>(object)->getAnyObject();
233 }
234 TClass* objClass = object->IsA();
235 bool array = (objClass == TClonesArray::Class());
236 if (array) {
237 objClass = static_cast<const TClonesArray*>(object)->GetClass();
238 }
239
240 return checkType(c_Object, objClass, array, true);
241 }
@ c_Object
A ROOT file containing a object with the name of the DBStoreEntry.
Definition: DBStoreEntry.h:56
bool checkType(const TObject *object) const
Check if a given TObject instance is compatible with the type of this entry.

◆ checkType() [2/2]

bool checkType ( EPayloadType  type,
const TClass *  objClass,
bool  array,
bool  inverse = false 
) const
private

Check if a given TClass is compatible with the type of this entry.

Definition at line 198 of file DBStoreEntry.cc.

199 {
200 if (type != m_payloadType) {
201 B2FATAL("Existing entry '" << m_name << "' is of a different type than requested");
202 }
203 // OK, all other checks only make sense for objects
204 if (type != c_Object) return true;
205 // Check whether the existing entry and the requested object are both arrays or both single objects
206 if (m_isArray != array) {
207 B2FATAL("Existing entry '" << m_name << "' is an " << ((m_isArray) ? "array" : "object") <<
208 " and the requested one an " << ((array) ? "array" : "object"));
209 }
210
211 // Check whether the existing entry and the requested object have the same type
212 if (!inverse) {
213 if (!m_objClass->InheritsFrom(objClass)) {
214 B2FATAL("Existing entry '" << m_name << "' of type " <<
215 m_objClass->GetName() << " doesn't match requested type " <<
216 objClass->GetName());
217 }
218 } else {
219 if (!objClass->InheritsFrom(m_objClass)) {
220 B2FATAL("Existing entry '" << m_name << "' of type " <<
221 m_objClass->GetName() << " doesn't match actual type " <<
222 objClass->GetName());
223 }
224 }
225 return true;
226 }
const std::string m_name
Name of this payload.
Definition: DBStoreEntry.h:173
const EPayloadType m_payloadType
Type of this payload.
Definition: DBStoreEntry.h:171
const bool m_isArray
True if this payload is an array of objects.
Definition: DBStoreEntry.h:177
const TClass *const m_objClass
Class of this payload.
Definition: DBStoreEntry.h:175

◆ clearBackends()

void clearBackends ( )

Clear list of backends.

Definition at line 127 of file Gearbox.cc.

128 {
129 for (gearbox::InputHandler* handler : m_handlers) delete handler;
130 m_handlers.clear();
131 }
std::vector< gearbox::InputHandler * > m_handlers
List of input handlers which will be used to find resources.
Definition: Gearbox.h:218

◆ close()

void close ( )

Free internal structures of previously parsed tree and clear cache.

Definition at line 169 of file Gearbox.cc.

170 {
171 if (m_xpathContext) xmlXPathFreeContext(m_xpathContext);
172 if (m_xmlDocument) xmlFreeDoc(m_xmlDocument);
173 m_xpathContext = nullptr;
174 m_xmlDocument = nullptr;
175
176 for (auto& entry : m_ownedObjects) {
177 delete entry.second;
178 }
179 m_ownedObjects.clear();
180
181 m_parameterCache->clear();
182 }
std::map< std::string, TObject * > m_ownedObjects
Map of queried objects (path -> TObject*).
Definition: Gearbox.h:215
xmlDocPtr m_xmlDocument
Pointer to the libxml Document structure.
Definition: Gearbox.h:209
MRUCache< std::string, PathValue > * m_parameterCache
Cache for already queried paths.
Definition: Gearbox.h:213
xmlXPathContextPtr m_xpathContext
Pointer to the libxml XPath context.
Definition: Gearbox.h:211

◆ consolidate()

void consolidate ( const FunctionFrom &  replaceFrom = FunctionFrom(),
const FunctionTo &  replaceTo = FunctionTo(),
EConsolidationAction  action = c_doNothing 
)

Consolidate RelationElements.

This function will loop over the relation and "compress" it by merging all elements with the same fromIndex.

The optional arguments can be used to replace indices in the relation, mainly useful in the simulation to replace the Geant4 TrackID with the index of the MCParticle at the end of the event

The Function objects should return a new (index,bool) pair for every index in the old relation. The returned index will be used as the new index in the relation and the bool pair indicates whether the original element got re-attributed or if it is just an index reordering. If it the original element got re-attributed the behaviour depends on the value of action, see EConsolidationAction

Warning: If action is set to c_negativeWeight and there is more than one element having the same from->to index pair after transformation the behaviour is undefined as the two elements get merged. It could happen that a negative and a positive weight get summed up, leaving the weight rather meaningless

See also
Identity, ReplaceMap, ReplaceVec, EConsolidationAction
Parameters
replaceFromFunction object containing replacements for the from indices
replaceToFunction object containing replacements for the to indices
actionAction to be performed when the old element got removed

Definition at line 466 of file RelationArray.h.

467 {
468 if (!isValid()) {
469 B2ERROR("Cannot consolidate an invalid relation (" << m_name << ")");
470 return;
471 }
472 typedef std::map<index_type, weight_type> element_t;
473 typedef std::map<index_type, element_t > buffer_t;
474 buffer_t buffer;
475
476 //Fill all existing elements in a nested map, adding the weights of
477 //duplicate elements
478 index_type lastFromIndex(0);
479 buffer_t::iterator lastFromIter = buffer.end();
480 unsigned int nElements = (*m_relations)->getEntries();
481 TClonesArray& elements = (*m_relations)->elements();
482 for (unsigned int i = 0; i < nElements; ++i) {
483 RelationElement& element = *static_cast<RelationElement*>(elements[i]);
484 //Replace from index
485 consolidation_type from = replaceFrom(element.getFromIndex());
486
487 //Ignore whole element if original element got deleted
488 if (action == c_deleteElement && from.second) continue;
489
490 //Check if the fromIndex is the same as the last one and reuse
491 //iterator if possible
492 if (from.first != lastFromIndex || lastFromIter == buffer.end()) {
493 lastFromIter = buffer.insert(make_pair(from.first, element_t())).first;
494 lastFromIndex = from.first;
495 }
496 //Loop over all elements of this relationelement and add them to the map
497 size_t size = element.getSize();
498 for (size_t j = 0; j < size; ++j) {
499 //Replace to Index
500 consolidation_type to = replaceTo(element.getToIndex(j));
501 //Ignore whole element if original element got deleted
502 if (action == c_deleteElement && to.second) continue;
503 double weight = element.getWeight(j);
504 //Original from or to element got deleted. Do whatever is specified by action
505 //Warning: if there is more than one element pointing to the same
506 //from->to element after transformation the negative weight option is
507 //not safe as we sum a positive and a negative weight when
508 //consolidating.
509 if (from.second || to.second) {
510 if (action == c_zeroWeight) {
511 weight = 0;
512 } else if (action == c_negativeWeight && weight > 0) {
513 weight = -weight;
514 }
515 }
516 //add the weight to the new from->to index pair
517 lastFromIter->second[to.first] += weight;
518 }
519 }
520 //Clear the existing relation
521 elements.Delete();
522 //Fill the map into the relation
523 for (buffer_t::iterator iter = buffer.begin(); iter != buffer.end(); ++iter) {
524 add(iter->first, iter->second.begin(), iter->second.end());
525 }
526 }
bool isValid() const
Check whether the object was created.
std::pair< index_type, bool > consolidation_type
Typedef declaring the return value of any consolidation mapping.
Definition: RelationArray.h:88
RelationElement::index_type index_type
Typedef to simplify use of correct index_type.
Definition: RelationArray.h:68
@ c_negativeWeight
Flip the sign of the weight to become negative if the original element got re-attributed.
Definition: RelationArray.h:79
@ c_zeroWeight
Set the weight of the relation to 0 if the original element got re-attributed.
Definition: RelationArray.h:80
@ c_deleteElement
Delete the whole relation element if the original element got re-attributed.
Definition: RelationArray.h:81
void add(index_type from, index_type to, weight_type weight=1.0)
Add a new element to the relation.
std::string m_name
Store name under which this object/array is saved.

◆ convertString() [1/2]

T convertString ( const std::string &  str)

Converts a string to type T (one of float, double, long double, int, long int, unsigned long int).

Throws std::invalid_argument on conversion errors, out_of_range if T cannot hold the given value. You can catch both possible exception types of the function (invalid_argument and out_of_range) using the base class logic_error

◆ convertString() [2/2]

float convertString ( const std::string &  str)

Converts a string to float.

Parameters
strstring which is converted to float
Returns
converted float

Definition at line 24 of file Conversion.cc.

25 {
26 std::string::size_type n;
27 float number = std::stof(str, &n);
28 if (n != str.size()) {
29 throw std::invalid_argument("Could only parse a part of the given string " + str);
30 }
31 return number;
32 }

◆ convertValue()

double convertValue ( double  value,
const std::string &  unitString 
)
static

Converts a floating point value to the standard framework unit.

If the given unit is not found, the value is returned unchanged (and an error printed).

Parameters
valueThe value which should be converted.
unitStringThe string of the unit of the specified value.
Returns
The value converted to the standard unit.

Definition at line 129 of file UnitConst.cc.

130 {
131 auto it = s_conversionFactors.find(unitString);
132 if (it == s_conversionFactors.end()) {
133 B2ERROR("Could not find conversion factor for unit " << unitString << ", assuming 1.0");
134 return value;
135 }
136 return it->second * value;
137 }
static std::map< std::string, double > s_conversionFactors
Map to be able to convert between units using string representations of the unit name.
Definition: Unit.h:163

◆ convertValueToUnit()

double convertValueToUnit ( double  value,
const std::string &  unitString 
)
static

Converts a floating point value from the standard framework unit to the given unit.

If the given unit is not found, the value is returned unchanged (and an error printed).

Parameters
valueThe value which should be converted.
unitStringThe string of the unit of the specified value.
Returns
The value converted to the given unit.

Definition at line 139 of file UnitConst.cc.

140 {
141 auto it = s_conversionFactors.find(unitString);
142 if (it == s_conversionFactors.end()) {
143 B2ERROR("Could not find conversion factor for unit " << unitString << ", assuming 1.0");
144 return value;
145 }
146 return value / it->second;
147 }

◆ copyRelationsToSelf()

void copyRelationsToSelf
protected

Copy any set -> set relations between selected objects.

Definition at line 390 of file SelectSubset.h.

391 {
392 for (const StoredClass& subsetObject1 : *m_subset) {
393 //TODO: change relation direction to set -> subset?
394 const StoredClass* setObject1 = subsetObject1.template getRelatedFrom<StoredClass>(m_set->getName());
395
396 if (setObject1 != nullptr) {
397 //get all objects in original set related to setObject1
398 const RelationVector<StoredClass>& relations = setObject1->template getRelationsTo<StoredClass>(m_set->getName());
399 for (unsigned int iRel = 0; iRel < relations.size(); iRel++) {
400 const StoredClass* setObject2 = relations.object(iRel);
401 const double weight = relations.weight(iRel);
402 //if setObject2 was selected into subset, inherit relation
403 const StoredClass* subsetObject2 = setObject2->template getRelatedTo<StoredClass>(m_subset->getName());
404 if (subsetObject2) {
405 subsetObject1.addRelationTo(subsetObject2, weight);
406 }
407 }
408 }
409 }
410 }
StoreArray< StoredClass > * m_set
The array we use as input.
Definition: SelectSubset.h:342
StoreArray< StoredClass > * m_subset
The array we create.
Definition: SelectSubset.h:344
const std::string & getName() const
Return name under which the object is saved in the DataStore.

◆ copySetWithRelations()

std::map< int, int > copySetWithRelations ( std::function< bool(const StoredClass *)>  f)
protected

Selects the elements, fill the subset and copies all the relations in which the set is involved.

Definition at line 351 of file SelectSubset.h.

352 {
353 std::map<int, int> oldToNew;
354 for (const StoredClass& setObject : *m_set) {
355 if (!f(&setObject))
356 continue;
357
358 oldToNew[setObject.getArrayIndex()] = m_subset->getEntries();
359 const StoredClass* subsetObject = m_subset->appendNew(setObject);
361 setObject.addRelationTo(subsetObject);
362 }
363
364
365 //TODO this is the slow bit, can probably be improved by directly dealing with indices
366 for (const auto& oldToNewPair : oldToNew) {
367 const StoredClass* setObject = (*m_set)[oldToNewPair.first];
368 const StoredClass* subsetObject = (*m_subset)[oldToNewPair.second];
369
370 for (std::string fromArray : m_inheritFromArrays) {
371 const RelationVector<RelationsObject>& relations = setObject->template getRelationsFrom<RelationsObject>(fromArray);
372 for (unsigned int iRel = 0; iRel < relations.size(); iRel++) {
373 relations.object(iRel)->addRelationTo(subsetObject, relations.weight(iRel));
374 }
375 }
376 for (std::string toArray : m_inheritToArrays) {
377 const RelationVector<RelationsObject>& relations = setObject->template getRelationsTo<RelationsObject>(toArray);
378 for (unsigned int iRel = 0; iRel < relations.size(); iRel++) {
379 subsetObject->addRelationTo(relations.object(iRel), relations.weight(iRel));
380 }
381 }
382 }
383
384 return oldToNew;
385 }
std::vector< std::string > m_inheritFromArrays
array names we inherit relations from.
Definition: SelectSubset.h:54
bool m_reduceExistingSet
If true, non-selected candidates are removed from m_set, m_subset only exists temporarily.
Definition: SelectSubset.h:60
std::vector< std::string > m_inheritToArrays
array names we inherit relations to.
Definition: SelectSubset.h:56
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216

◆ createROOTObjectPyCopy()

boost::python::object createROOTObjectPyCopy ( const T &  instance)

Create a python wrapped copy from a class instance which has a ROOT dictionary.

This piece of dark magic creates a python object referencing a ROOT object the same way as you would see it in the ROOT python module.

It will create a copy of the object using the copy constructor which is then owned by python.

Definition at line 26 of file PyObjROOTUtils.h.

27 {
28 const char* classname = instance.IsA()->GetName();
29 void* addr = new T(instance);
30 PyObject* obj = TPython::CPPInstance_FromVoidPtr(addr, classname, true);
31 return boost::python::object(boost::python::handle<>(obj));
32 }

◆ createScopedUpdateSession()

ScopeGuard createScopedUpdateSession ( )

Make sure we have efficient http pipelinging during initialize/beginRun but don't keep session alive for full processing time.

This will return an object which keeps the session open as long as it is alive.

Definition at line 62 of file Database.cc.

63 {
64 // make sure we reread testing text files in case they got updated
65 for (auto& testing : m_testingPayloads) {
66 testing.reset();
67 }
68 // and return a downloader session guard for the downloader we use
70 }
ScopeGuard ensureSession()
Make sure there's an active session and return a ScopeGuard object that closes the session on destruc...
Definition: Downloader.h:43
static Downloader & getDefaultInstance()
Return the default instance.
Definition: Downloader.cc:134
std::vector< Conditions::TestingPayloadStorage > m_testingPayloads
optional list of testing payload storages to look for existing payloads
Definition: Database.h:244

◆ createSocket() [1/2]

std::unique_ptr< zmq::socket_t > createSocket ( const std::string &  socketAddress)

Create a socket of the given type while deciding on the bind behaviour via the address.

An address in the form "tcp://ast:<port>" (with ast = *) means the socket is bound to a local interface. An address in the from "tcp://<host>:<port>" means it connects to the given host.

If you want to fore a given bind behaviour (and fail if the address is invalid), use the function above.

Definition at line 141 of file ZMQParent.h.

142 {
143 // We only check for "*" in the full address for now. This is fine, as neither a valid hostname nor a valid
144 // port number can ever contain a "*".
145 if (socketAddress.find("*") != std::string::npos) {
146 return createSocket<AZMQType>(socketAddress, true);
147 } else {
148 return createSocket<AZMQType>(socketAddress, false);
149 }
150 }

◆ createSocket() [2/2]

std::unique_ptr< zmq::socket_t > createSocket ( const std::string &  socketAddress,
bool  bind 
)

Create a socket of the given type with the given address and bind or not bind it.

Typical socket types are ZMQ_ROUTER, ZMQ_DEALER and ZMQ_STREAM.

The address needs to be in the form "tcp://ast:<port>" (with ast = *) if you want to bind to a local interface or "tcp://<host>:<port>" if you want to connect. Use the convenience function below if you want the program to decide based on your address and use this function if you want the program to force a specific bind behaviour (it will raise an exception if given an invalid address).

Definition at line 105 of file ZMQParent.h.

106 {
107 initialize();
108
109 try {
110 // TODO: options to test additionally in the future:
111 // * ZMQ_IMMEDIATE
112 // * ZMQ_PROBE_ROUTER
113 // * ZMQ_ROUTER_MANDATORY
114 // * ZMQ_ROUTER_NOTIFY
115 auto socket = std::make_unique<zmq::socket_t>(*m_context, AZMQType);
116
117 if (AZMQType == ZMQ_DEALER) {
118 auto identity = createIdentity();
119 socket->set(zmq::sockopt::routing_id, identity);
120 }
121
122 // Linger means: close the socket immediately if requested, do not wait until all messages have been sent.
123 // This is needed because if we want to ABORT, we usually know what we are doing (and want to do it now).
124 socket->set(zmq::sockopt::linger, 0);
125 if (bind) {
126 socket->bind(socketAddress.c_str());
127 } else {
128 socket->connect(socketAddress.c_str());
129 }
130
131 // Wait a bit to give the framework time to initialize the socket
132 std::this_thread::sleep_for(std::chrono::milliseconds(100));
133
134 return socket;
135 } catch (zmq::error_t& error) {
136 B2FATAL("Creating the ZMQ socket for address " << socketAddress << " failed because of: " << error.what());
137 }
138 }
void initialize()
Initialize the parent by creating the context.
Definition: ZMQParent.cc:44
static std::string createIdentity(unsigned int pid=0)
Create a unique ZMQ identity in the form <hostname>_<pid> (if pid is 0, use the current processes PID...
Definition: ZMQParent.cc:32
std::unique_ptr< zmq::context_t > m_context
ZMQ context.
Definition: ZMQParent.h:98

◆ DEFINE_UNIT() [1/2]

DEFINE_UNIT ( cm  ,
1.   
)

Standard units with the value = 1.

Standard of [length]

◆ DEFINE_UNIT() [2/2]

DEFINE_UNIT ( km  ,
Unit::cm 1e5 
)

Derived units.

[kilometers]

◆ DEFINE_UNIT_NAME()

DEFINE_UNIT_NAME ( g_cm3  ,
1.  ,
"g/cm3"   
)

Practical units with the value = 1.

These units are NOT consistent with the other standard units. Please use them carefully. Standard of [density]

◆ expand()

std::string expand ( const std::string &  text)
static

Modify the given string and replace every occurence of $NAME or ${NAME} with the value of the environment variable NAME.

Variables which are not found are returned unchanged

Definition at line 60 of file EnvironmentVariables.cc.

61 {
62 // we could implement this ourselves ... but that seems like a waste of
63 // time since there's a perfectly good implementation available.
64 namespace py = boost::python;
65 py::object path = py::import("os.path");
66 return py::extract<std::string>(path.attr("expandvars")(text));
67 }

◆ exposePythonAPI()

void exposePythonAPI ( )
static

Exposes setGlobalTag function of the Database class to Python.

Definition at line 272 of file Database.cc.

273 {
274 // To avoid confusion between std::arg and boost::python::arg we want a shorthand namespace as well
275 namespace py = boost::python;
276
277 // Make sure the default instance is created
279
280 // Don't show c++ signature in python doc to keep it simple
281 py::docstring_options options(true, true, false);
282
283 // Expose our shiny configuration object
285 }
static void exposePythonAPI()
expose this class to python
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:42

◆ findIgnoringParenthesis()

unsigned long int findIgnoringParenthesis ( std::string  str,
std::string  pattern,
unsigned int  begin = 0 
)

Returns the position of a pattern in a string ignoring everything that is in parenthesis.

Definition at line 49 of file CutHelpers.cc.

50 {
51
52 if (str.size() < pattern.size())
53 return std::string::npos;
54
55 for (unsigned int i = begin; i < str.size() - pattern.size(); ++i) {
56 if (str[i] == '[') {
57 i += findMatchedParenthesis(str.substr(i), '[', ']');
58 continue;
59 }
60 if (str[i] == '(') {
61 i += findMatchedParenthesis(str.substr(i), '(', ')');
62 continue;
63 }
64 if (str[i] == '{') {
65 i += findMatchedParenthesis(str.substr(i), '{', '}');
66 continue;
67 }
68
69 for (unsigned int j = 0; j < pattern.size(); ++j) {
70 if (str[i + j] != pattern[j]) {
71 break;
72 }
73 if (j == pattern.size() - 1) {
74 return i;
75 }
76 }
77 }
78 return std::string::npos;
79 }

◆ findMatchedParenthesis()

unsigned long int findMatchedParenthesis ( std::string  str,
char  open = '[',
char  close = ']' 
)

Returns position of the matched closing parenthesis if the first character in the given string contains an opening parenthesis.

Otherwise return 0.

Definition at line 33 of file CutHelpers.cc.

34 {
35 unsigned long int end = 1;
36 if (str[0] == open) {
37 unsigned int count = 1;
38 for (end = 1; end < str.size() and count > 0; ++end) {
39 if (str[end] == open) ++count;
40 else if (str[end] == close) --count;
41 }
42
43 if (count > 0)
44 throw std::runtime_error("Variable string has an invalid format: " + str);
45 }
46 return end - 1;
47 }

◆ flushCurrentVariable()

void flushCurrentVariable ( )
private

Flush the currently parsed variable name and add it to the state either as variable or number.

Definition at line 173 of file FormulaParser.cc.

174 {
175 if (!m_currentVariableName.empty()) {
176 if (!m_lastTokenWasOperator) throw std::runtime_error("Missing operator before variable");
178 // looks like a number, so add a number
180 char* ptr;
181 double value;
182 value = std::strtod(m_currentVariableName.c_str(), &ptr);
183 addVariable(InputToken(value));
184 } else {
186 }
187 }
188 m_currentVariableName.clear();
190 }
std::string m_currentVariableName
collect characters into a variable name
virtual void addVariable(const InputToken &token)=0
Add a variable token to the current state.
std::variant< std::string, double > InputToken
Input token type: an input tokein is either a string or a float variable.
Definition: FormulaParser.h:59

◆ flushPendingOperators()

void flushPendingOperators ( )
private

Flush all pending operators at the end of processing.

Definition at line 161 of file FormulaParser.cc.

162 {
163 while (!m_operatorStack.empty()) {
164 EOperator op = m_operatorStack.top();
165 m_operatorStack.pop();
166 // found a bracket but no more closing brackets to come ... so error
168 throw std::runtime_error("missing closing bracket");
169 executeOperator(op);
170 }
171 }

◆ fromObject()

DBStoreEntry fromObject ( const std::string &  name,
const TObject *  obj,
bool  isRequired 
)
static

Construct a new DBStoreEntry with a requested name and an object directly.

The constructor arguments type, objClass and isArray will be filled correctly by looking at obj

Parameters
namename of the payload, ususally the class name of the payload but can be any string identifying the payload in the database
objinstance of an object representing the correct type
isRequiredif false don't emit errors if the payload cannot be found for any run
Returns
new DBStoreEntry instance with the correct name and types set

Definition at line 37 of file DBStoreEntry.cc.

38 {
39 assert(obj);
40 bool isArray = dynamic_cast<const TClonesArray*>(obj) != nullptr;
41 TClass* objClass = isArray ? (dynamic_cast<const TClonesArray*>(obj)->GetClass()) : (obj->IsA());
42 return DBStoreEntry(c_Object, name, objClass, isArray, isRequired);
43 }
DBStoreEntry(EPayloadType type, const std::string &name, const TClass *objClass, bool isArray, bool isRequired)
Construct a new DBStoreEntry.
Definition: DBStoreEntry.h:68
bool isRequired() const
check whether this payload is required for operation
Definition: DBStoreEntry.h:115
bool isArray() const
get whether this payload is an array of objects or a single objects
Definition: DBStoreEntry.h:113

◆ Gearbox()

Gearbox ( )
private

Singleton: private constructor.

Definition at line 67 of file Gearbox.cc.

67 : m_xmlDocument(nullptr), m_xpathContext(nullptr),
68 m_parameterCache(new MRUCache<std::string, PathValue>(c_DefaultCacheSize))
69 {
70 xmlInitParser();
71 LIBXML_TEST_VERSION;
72 }

◆ generate_number_sequence()

std::set< int64_t > generate_number_sequence ( const std::string &  str)

Generate a sequence of numbers defined by a string.

The syntax looks like this: sequence = interval,interval,interval,... interval = begin:end number

For instance. 3,23:27,101 Would generate the following sequence of numbers 3,23,24,25,26,27,101

If intervals overlap the number is only returned once, so the following string 27,24:28,26:29 yields 24,25,26,27,28,29

Negative numbers and intervals are supported as well -3:3 yields -3,-2,-1,0,1,2,3

But reversed intervals are considered empty 5:3 yields an empty sequence

Returns a std::set, which contains the number sequence, each number (as stated above) occurs only once (obviously, since it's a set) and the numbers are ordered using the default Compare operator less<int> of std::set.

Definition at line 20 of file NumberSequence.cc.

21 {
22 // Tokenize input
23 std::vector<std::string> tokens;
24 unsigned int lastdelimiter = 0;
25 for (unsigned int i = 0; i < str.size(); ++i) {
26 if (str[i] == ',') {
27 tokens.push_back(str.substr(lastdelimiter, i - lastdelimiter));
28 lastdelimiter = i + 1;
29 }
30 }
31 std::string last = str.substr(lastdelimiter);
32 if (last.size() != 0) {
33 tokens.push_back(last);
34 }
35
36 // Convert tokens into intervals
37 std::vector<std::pair<int64_t, int64_t>> intervals;
38 intervals.reserve(tokens.size());
39 for (const auto& token : tokens) {
40 size_t interval_marker_position = token.find(':');
41 // Single number
42 if (interval_marker_position == std::string::npos) {
43 int64_t number = std::stol(token);
44 intervals.emplace_back(number, number);
45 } else {
46 int64_t interval_begin = std::stol(token.substr(0, interval_marker_position));
47 int64_t interval_end = std::stol(token.substr(interval_marker_position + 1));
48 intervals.emplace_back(interval_begin, interval_end);
49 }
50 }
51
52 // Convert tokens into number sequence
53 std::set<int64_t> sequence;
54 for (const auto& interval : intervals) {
55 for (int64_t number = interval.first; number <= interval.second; ++number)
56 sequence.insert(number);
57 }
58
59 return sequence;
60 }

◆ generateBucketNumber()

unsigned generateBucketNumber ( ) const

Generates RF bucket number according to the fill pattern.

Returns
bucket number

Definition at line 47 of file BunchStructure.cc.

48 {
49 if (m_fillPattern.empty()) return (gRandom->Integer(c_RFBuckets / 2) * 2);
50
51 if (m_filledBuckets.empty()) {
52 for (unsigned i = 0; i < c_RFBuckets; ++i) {
53 if (m_fillPattern[i]) m_filledBuckets.push_back(i);
54 }
55 }
56
57 int index = gRandom->Integer(m_filledBuckets.size());
58 return m_filledBuckets[index];
59 }
std::vector< unsigned > m_filledBuckets
cache for the filled bucket numbers
std::vector< bool > m_fillPattern
fill pattern, true means the bucket is filled

◆ get()

std::string get ( const std::string &  name,
const std::string &  fallback = "" 
)
static

Get the value of an environment variable or the given fallback value if the variable is not set.

Definition at line 25 of file EnvironmentVariables.cc.

26 {
27 char* envValue = std::getenv(name.c_str());
28 if (envValue != nullptr) {
29 std::string val(envValue);
30 boost::trim(val);
31 return envValue;
32 }
33 return fallback;
34 }

◆ getAllEntryNames()

std::set< std::string > getAllEntryNames ( )

Return the names of all the payloads stored in the database at the time of this function is called.

This is equivalent to getting all the payloads' names used by the current basf2 process.

Definition at line 196 of file DBStore.cc.

197 {
198 std::set<std::string> s{};
199 for (auto& [key, value] : m_dbEntries)
200 s.emplace(key);
201 return s;
202 };

◆ getBucket()

bool getBucket ( int  i) const

Returns the fill status of RF bucket.

Parameters
ibucket number (modulo c_RFBuckets applied internally)
Returns
true if bucket is filled

Definition at line 29 of file BunchStructure.cc.

30 {
31 if (m_fillPattern.empty()) return (i % 2 == 0);
32
33 int k = i % c_RFBuckets;
34 if (k < 0) k += c_RFBuckets;
35 return m_fillPattern[k];
36 }

◆ getCurrentLogConfig()

const LogConfig & getCurrentLogConfig ( const char *  package = nullptr) const
inline

Returns the current LogConfig object used by the logging system.

Will use the configuration of the current package, if available, or the current module, if available, or, otherwise, the global configuration.

The idea is that a module can call functions in a different package, and the log configuration for that package will be used.

Definition at line 258 of file LogSystem.h.

259 {
260 //module specific config?
262 return *m_moduleLogConfig;
263 }
264 //package specific config?
265 if (package && !m_packageLogConfigs.empty()) {
266 // cppcheck-suppress stlIfFind ; cppcheck doesn't like scoped variables in if statements
267 if (auto it = m_packageLogConfigs.find(package); it != m_packageLogConfigs.end()) {
268 const LogConfig& logConfig = it->second;
269 if (logConfig.getLogLevel() != LogConfig::c_Default)
270 return logConfig;
271 }
272 }
273 //global config
274 return m_logConfig;
275 }
ELogLevel getLogLevel() const
Returns the configured log level.
Definition: LogConfig.h:91
@ c_Default
Default: use globally configured log level.
Definition: LogConfig.h:32
std::map< std::string, LogConfig > m_packageLogConfigs
Stores the log configuration objects for packages.
Definition: LogSystem.h:213
LogConfig m_logConfig
The global log system configuration.
Definition: LogSystem.h:207
const LogConfig * m_moduleLogConfig
log config of current module
Definition: LogSystem.h:209

◆ getData() [1/2]

std::pair< TObject *, IntervalOfValidity > getData ( const EventMetaData event,
const std::string &  name 
)

Request an object from the database.

Parameters
eventThe metadata of the event for which the object should be valid.
nameName that identifies the object in the database.
Returns
A pair containing the object and the iov for which it is valid. Ownership will be given to the caller
Warning
The returned object has to be deleted by the caller

Definition at line 72 of file Database.cc.

73 {
74 DBStoreEntry entry(DBStoreEntry::c_Object, name, TObject::Class(), false, true);
75 std::vector<DBQuery> query{DBQuery{name, true}};
76 getData(event, query);
77 entry.updatePayload(query[0].revision, query[0].iov, query[0].filename, query[0].checksum, query[0].globaltag, event);
78 return std::make_pair(entry.releaseObject(), query[0].iov);
79 }
Conditions::PayloadMetadata DBQuery
Struct for bulk read queries.
Definition: Database.h:72
std::pair< TObject *, IntervalOfValidity > getData(const EventMetaData &event, const std::string &name)
Request an object from the database.
Definition: Database.cc:72

◆ getData() [2/2]

bool getData ( const EventMetaData event,
std::vector< DBQuery > &  query 
)

Request multiple objects from the database.

Parameters
eventThe metadata of the event for which the objects should be valid.
queryA list of DBQuery entries that contains the names of the objects to be retrieved. On return the object and iov fields are filled.

Definition at line 81 of file Database.cc.

82 {
83 // initialize lazily ...
85 // So first go over the requested payloads once, reset the info and check for any
86 // testing payloads we might want to use
87 const size_t testingPayloads = std::count_if(query.begin(), query.end(), [this, &event](auto & payload) {
88 // make sure the queries are "reset" to invalid revision and no filename before we start looking
89 payload.filename = "";
90 payload.revision = 0;
91 // and now look in all testing payload providers if any.
92 for (auto& tmp : m_testingPayloads) {
93 if (tmp.get(event, payload)) return true;
94 }
95 return false;
96 });
97 // if we already found all just return here
98 if (testingPayloads == query.size()) return true;
99 // nooow, lets look for proper payloads;
100 try {
101 m_metadataProvider->getPayloads(event.getExperiment(), event.getRun(), query);
102 } catch (std::exception&) {
103 // something went wrong with the metadata update ... so let's try next provider
104 B2WARNING("Conditions data: Problem with payload metadata provider, trying to fall back to next provider..."
105 << LogVar("provider", m_currentProvider));
107 return getData(event, query);
108 }
109 // and if we could find the metadata lets also locate the payloads ...
110 const size_t payloadsLocated = std::count_if(query.begin(), query.end(), [this](auto & payload) {
111 // make sure we don't overwrite local payloads or otherwise already valid filenames;
112 if (!payload.filename.empty()) return true;
113 // but don't check for payloads we could not find. But this is only a
114 // problem if they are required so report success for not required
115 // payloads
116 if (payload.revision == 0) return not payload.required;
117 // and locate the payload.
118 if (not m_payloadProvider->find(payload)) {
119 // if that fails lets let the user know: Even for optional payloads, if
120 // we know the metadata but cannot find the file something is fishy and
121 // should be reported.
122 auto loglevel = payload.required ? LogConfig::c_Error : LogConfig::c_Warning;
123 B2LOG(loglevel, 0, "Conditions data: Could not find file for payload"
124 << LogVar("name", payload.name) << LogVar("revision", payload.revision)
125 << LogVar("checksum", payload.checksum) << LogVar("globaltag", payload.globaltag));
126 return not payload.required;
127 }
128 return true;
129 });
130 // did we find all payloads?
131 return payloadsLocated == query.size();
132 }
std::string m_currentProvider
Name of the currently used metadata provider.
Definition: Database.h:232
std::unique_ptr< Conditions::MetadataProvider > m_metadataProvider
Currently active metadata provider.
Definition: Database.h:238
Class to store variables with their name which were sent to the logging service.
void initialize(const EDatabaseState target=c_Ready)
Initialize the database connection settings on first use.
Definition: Database.cc:197
void nextMetadataProvider()
Enable the next metadataprovider in the list.
Definition: Database.cc:159

◆ getDefaultValue()

T & getDefaultValue

Returns the default value of the parameter.

Returns
The default value of the parameter.

Definition at line 56 of file ModuleParam.templateDetails.h.

57 {
58 return m_defaultValue;
59 }
T m_defaultValue
The default value of the parameter.
Definition: ModuleParam.h:121

◆ getDetectorComponent()

GearDir getDetectorComponent ( const std::string &  component)

Return GearDir representing a given DetectorComponent.

Parameters
componentName of the DetectorComponent (e.g. IR, PXD)

Definition at line 314 of file Gearbox.cc.

315 {
316 return GearDir("/Detector/DetectorComponent[@name='" + component + "']/Content");
317 }

◆ getEntry()

DBStoreEntry * getEntry ( DBStoreEntry::EPayloadType  payloadType,
const std::string &  name,
const TClass *  objClass,
bool  array,
bool  required = true 
)

Returns the entry with the requested name in the DBStore.

If the DBStore entry does not exist yet it is added to the map.

If the DBStore map already contains an object under the key with a DIFFERENT type than the given type one, an error will be reported.

Parameters
payloadTypeType of the payload. Usually c_Object.
nameName under which the object is stored in the database (and in the DBStore).
objClassThe class of the object.
arrayWhether it is a TClonesArray or not.
requiredIf true emit errors if the object cannot be found
Returns
DBEntry, or nullptr if the requested type does not match the one in the DBStore

Definition at line 34 of file DBStore.cc.

36 {
37 // Check whether the map entry already exists
38 const auto& entry = m_dbEntries.find(name);
39 if (entry != m_dbEntries.end()) {
40 DBStoreEntry& dbEntry = entry->second;
41
42 // Check whether the types match
43 if (!dbEntry.checkType(type, objClass, array)) return nullptr;
44
45 B2DEBUG(39, "DBEntry " << name << " was requested once more.");
46 if (required && !dbEntry.isRequired()) {
47 dbEntry.require();
48 B2DEBUG(34, "DBEntry " << name << " is now required");
49 }
50 return &dbEntry;
51 }
52
53 // Add the DBStore entry
54 const auto iter = m_dbEntries.emplace(name, DBStoreEntry{type, name, objClass, array, required});
55 DBStoreEntry& dbEntry = iter.first->second;
56 B2DEBUG(34, "DBEntry " << name << " was created (" << (required ? "required" : "optional") << ")");
57
58 // If no object was obtained from the database yet, but it should be available, get it
59
60 // Check if we have a non-DataStore event to use
61 if (m_manualEvent) {
62 Database::DBQuery query(name, required);
63 if (Database::Instance().getData(*m_manualEvent, query)) {
64 dbEntry.updatePayload(query.revision, query.iov, query.filename, query.checksum, query.globaltag, *m_manualEvent);
65 }
66 if (dbEntry.isIntraRunDependent()) m_intraRunDependencies.insert(&dbEntry);
67 }
68 // Otherwise use the DataStore if it is valid
69 else if (m_storeEvent.isValid()) {
70 Database::DBQuery query(name, required);
71 if (Database::Instance().getData(*m_storeEvent, query)) {
72 dbEntry.updatePayload(query.revision, query.iov, query.filename, query.checksum, query.globaltag, *m_storeEvent);
73 }
74 if (dbEntry.isIntraRunDependent()) m_intraRunDependencies.insert(&dbEntry);
75 }
76 return &dbEntry;
77 }

◆ getField() [1/2]

void getField ( const double *  pos,
double *  field 
)
inlinestatic

return the magnetic field at a given position.

Parameters
[in]posposition in framework units, needs to be of at least size 3
[out]fieldmagnetic field field value at position pos in framework units

Definition at line 91 of file BFieldManager.h.

92 {
93 ROOT::Math::XYZVector fieldvec = getField(ROOT::Math::XYZVector(pos[0], pos[1], pos[2]));
94 field[0] = fieldvec.X();
95 field[1] = fieldvec.Y();
96 field[2] = fieldvec.Z();
97 }
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Definition: BFieldManager.h:91

◆ getField() [2/2]

ROOT::Math::XYZVector getField ( const ROOT::Math::XYZVector &  pos) const
inline

Calculate the magnetic field at a given position.

Parameters
posposition where the field should be evaluated in framework units.
Returns
magnetic field at pos in framework units.
Warning
The returned field is in basf2 units which is NOT Tesla. If you need the field strength in a fixed unit please divide the returned value by Unit::T or similar.

Definition at line 67 of file MagneticField.h.

68 {
69 ROOT::Math::XYZVector field;
70 for (auto c : m_components) {
71 if (c->inside(pos)) {
72 // is it an exclusive component? If so return the field
73 if (c->isExclusive()) return c->getField(pos);
74 // else add it to what we already have
75 field += c->getField(pos);
76 }
77 }
78 return field;
79 }
std::vector< MagneticFieldComponent * > m_components
Magnetic field components to evaluate the field.
Definition: MagneticField.h:62

◆ getFile()

std::shared_ptr< TFile > getFile ( std::string  fileName,
bool  ignoreErrors = false 
)

Get a file with a specific name, if is does not exist it will be created.

If the file cannot be created and opened an error is emitted and you get an empty shared_ptr. If you don't want an error to be emitted you can provide ignoreErrors=true as second argument.

WARNING: When you get this file it is probably not set as current directory so before you use it you have to call file->cd();

Definition at line 33 of file RootFileCreationManager.cc.

34 {
35 std::shared_ptr<TFile> ptr = m_files[fileName].lock();
36 if (!ptr) {
37 // make sure stupid gDirectory is not modified ... that means that users
38 // have to ptr->cd() but plays nice with other modules which might not
39 // set their cd() correctly.
40 TDirectory::TContext gDirectoryGuard;
41 // Create shared ptr for the file which will correctly close it when the last user disconnects.
42 ptr = std::shared_ptr<TFile>(TFile::Open(fileName.c_str(), "RECREATE"), TFile_Deleter);
43 // Check if the file is actually open ... otherwise no use in returning it
44 if (!ptr || !ptr->IsOpen()) {
45 if (!ignoreErrors) B2ERROR("Could not create file " << std::quoted(fileName));
46 return nullptr;
47 }
48 //remember this ...
49 m_files[fileName] = ptr;
50 }
51 return ptr;
52 }
std::map< std::string, std::weak_ptr< TFile > > m_files
store for the open files

◆ getGlobalTags()

std::string getGlobalTags ( )

Return the global tags used by the database.

If no conditions database is configured return an empty string. If more then one database is configured return all global tags concatenated by ','

Definition at line 154 of file Database.cc.

155 {
156 return boost::algorithm::join(m_globalTags, ",");
157 }
std::vector< std::string > m_globalTags
List of globaltags to be used.
Definition: Database.h:234

◆ getInstance() [1/2]

Gearbox & getInstance ( )
static

Return reference to the Gearbox instance.

Definition at line 81 of file Gearbox.cc.

82 {
83 static Gearbox instance;
84 return instance;
85 }
Gearbox()
Singleton: private constructor.
Definition: Gearbox.cc:67

◆ getInstance() [2/2]

RootFileCreationManager & getInstance ( )
static

Interface for the FileManager.

Definition at line 54 of file RootFileCreationManager.cc.

55 {
56 static RootFileCreationManager instance;
57 return instance;
58 }
RootFileCreationManager()
Constructor is private.

◆ getList()

std::vector< std::string > getList ( const std::string &  name,
const std::vector< std::string > &  fallback = {},
const std::string &  separators = " \t\n\r" 
)
static

Get a list of values from an environment variable or the given fallback list if the variable is not set.

By default the value of the environment variable is split by whitespace (" \t\n\r") but a different list of characters can be supplied, for example ":" for path lists or ", " for comma or space separated values

Definition at line 36 of file EnvironmentVariables.cc.

38 {
39 if (!isSet(name)) return fallback;
40 std::string value = get(name);
41 std::vector<std::string> items;
42 //Treat empty string as empty list
43 if (value.empty()) return items;
44 boost::split(items, value, boost::is_any_of(separators));
45 return items;
46 }
static std::string get(const std::string &name, const std::string &fallback="")
Get the value of an environment variable or the given fallback value if the variable is not set.
static bool isSet(const std::string &name)
Check if a value is set in the database.

◆ getNumOfFilledBuckets()

unsigned getNumOfFilledBuckets ( ) const

Returns the number of filled buckets.

Returns
the number of filled buckets

Definition at line 39 of file BunchStructure.cc.

40 {
41 if (m_fillPattern.empty()) return (c_RFBuckets / 2);
42
43 return std::count(m_fillPattern.begin(), m_fillPattern.end(), true);
44 }

◆ getOrCreateList()

std::vector< std::string > getOrCreateList ( const std::string &  name,
const std::string &  fallback,
const std::string &  separators = " \t\n\r" 
)
static

Get a list of values from an environment variable or the given fallback string if the variable is not set.

By default the value of the environment variable is split by whitespace (" \t\n\r") but a different list of characters can be supplied, for example ":" for path lists or ", " for comma or space separated values

In case the variable is not set this function will convert the fallback string to a list using the same rules as would apply for the envirnoment value itself.

Definition at line 48 of file EnvironmentVariables.cc.

50 {
51 //almost the same as above but we don't need to check if its set, we just parse the value or fallback into a list
52 std::string value = get(name, fallback);
53 std::vector<std::string> items;
54 //Treat empty string as empty list
55 if (value.empty()) return items;
56 boost::split(items, value, boost::is_any_of(separators));
57 return items;
58 }

◆ getParam()

ModuleParam< T > & getParam ( const std::string &  name) const

Returns a reference to a parameter.

The returned parameter has already the correct type.

Throws an exception of type ModuleParameterNotFoundError if a parameter with the given name does not exist. Throws an exception of type ModuleParameterTypeError if the parameter type of does not match to the template parameter.

Parameters
nameThe unique name of the parameter.
Returns
A reference to a module parameter having the correct type.

Definition at line 573 of file Module.h.

574 {
575 return m_moduleParamList.getParameter<T>(name);
576 }
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.

◆ getParameter()

ModuleParam< T > & getParameter ( const std::string &  name) const

Returns a reference to a parameter.

The returned parameter has already the correct type.

Throws an exception of type ModuleParameterNotFoundError if a parameter with the given name does not exist. Throws an exception of type ModuleParameterTypeError if the parameter type of does not match to the template parameter.

Parameters
nameThe unique name of the parameter.
Returns
A reference to a module parameter having the correct type.

Definition at line 80 of file ModuleParamList.templateDetails.h.

81 {
82 // Check if a parameter with the given name exists
83 std::map<std::string, ModuleParamPtr>::const_iterator mapIter;
84 mapIter = m_paramMap.find(name);
85
86 if (mapIter != m_paramMap.end()) {
87 ModuleParamPtr moduleParam = mapIter->second;
88
89 // Check the type of the stored parameter (currently done using the type identifier string)
90 if (moduleParam->getTypeInfo() == ModuleParam<T>::TypeInfo()) {
91 ModuleParam<T>* explModParam = static_cast<ModuleParam<T>*>(moduleParam.get());
92 return *explModParam;
93 } else
94 throwTypeError(name, moduleParam->getTypeInfo(), ModuleParam<T>::TypeInfo());
95 } else
97 }
static void throwTypeError(const std::string &name, const std::string &expectedTypeInfo, const std::string &typeInfo)
Throws an error for a requested parameter that exists but was request with the wrong type.
static void throwNotFoundError(const std::string &name)
Throws an error for a requested parameter that does not exist.
static std::string TypeInfo()
Static function to generate a string description for the parameter type.

◆ getParamValuesPython()

void getParamValuesPython ( const std::string &  name,
PythonObject &  pyOutput,
bool  defaultValues 
) const

Returns a python object containing the value or default value of the given parameter.

Calls according to the parameter type a specialized converter in PyObjConvUtils.h

Parameters
nameThe unique name of the parameter.
pyOutputReference to the output object containing the parameter value or default values.
defaultValuesIf true returns a list of default values otherwise a list of the parameter values.

Definition at line 112 of file ModuleParamList.templateDetails.h.

115 {
116 try {
118 p->setValueToPythonObject(pyOutput, defaultValues);
119 } catch (std::runtime_error& exc) {
120 B2ERROR(exc.what());
121 }
122 }
ModuleParamPtr getParameterPtr(const std::string &name) const
Returns a ModuleParamPtr to a parameter.

◆ getPathValue()

Gearbox::PathValue getPathValue ( const std::string &  path) const
private

Return the (cached) value of a given path.

Definition at line 247 of file Gearbox.cc.

248 {
249 PathValue value;
250 if (m_xpathContext == nullptr) B2FATAL("Gearbox is not connected");
251 //Get from cache if possible
252 if (m_parameterCache->retrieve(path, value)) {
253 return value;
254 }
255 //Nothing in cache, query xml
256 string query = ensureNode(path);
257 B2DEBUG(1000, "Gearbox XPath query: " << query);
258 xmlXPathObjectPtr result = xmlXPathEvalExpression((xmlChar*) query.c_str(), m_xpathContext);
259 if (result != nullptr && result->type == XPATH_NODESET && !xmlXPathNodeSetIsEmpty(result->nodesetval)) {
260 value.numNodes = xmlXPathNodeSetGetLength(result->nodesetval);
261 xmlNodePtr node = result->nodesetval->nodeTab[0];
262 //Example: <foo><bar/></foo>
263 // - bar has no children, so node->children is 0
264 // - foo has not text children, so node->children->content should be 0
265 // but xmlXPathOrderDocElems assigns them an index<0 to speed up XPath
266 // so we have to cast to a long integer and check if it is positive
267 if (node->children && (long)node->children->content > 0) {
268 xmlChar* valueString = xmlNodeListGetString(m_xmlDocument, node->children, 1);
269 value.value = (char*)valueString;
270 xmlFree(valueString);
271 }
272 //See if we have a unit attribute and add it
273 xmlAttrPtr attribute = node->properties;
274 while (attribute) {
275 B2DEBUG(1001, "Checking attribute " << attribute->name);
276 if (!strcmp((char*)attribute->name, "unit")) {
277 B2DEBUG(1001, "found Unit " << attribute->children->content);
278 value.unit = (char*)attribute->children->content;
279 break;
280 }
281 attribute = attribute->next;
282 }
283 //Remove leading and trailing whitespaces
284 boost::trim(value.value);
285 boost::trim(value.unit);
286 }
287 //Add to cache, empty or not: results won't change
288 m_parameterCache->insert(path, value);
289 B2DEBUG(1000, "Gearbox XPath result: " << value.numNodes << ", " << value.value << ", " << value.unit);
290
291 xmlXPathFreeObject(result);
292 return value;
293 }
std::string ensureNode(const std::string &path) const
make sure the path really corresponds to an XPath node expression by removing trailing slashes
Definition: Interface.cc:156

◆ getTObject()

const TObject * getTObject ( const std::string &  path) const
overridevirtual

Get the parameter path as a TObject.

Exceptions
gearbox::PathEmptyErrorif path is empty or does not exist
gearbox::TObjectConversionErrorif the value could not be deserialized
Parameters
pathPath of the parameter to get
Returns
pointer to object, owned and managed by gearbox. Object will be deleted once it is no longer valid (e.g. after the current run if it belongs to this run)

Implements Interface.

Definition at line 295 of file Gearbox.cc.

296 {
297 //do we already have an object for this path?
298 auto it = m_ownedObjects.find(path);
299 if (it != m_ownedObjects.end())
300 return it->second;
301
302 const string& value = getString(path);
303 //assume base64-encoded raw data.
304 TObject* object = Stream::deserializeEncodedRawData(value);
305 if (!object)
306 throw gearbox::TObjectConversionError() << path;
307
308 m_ownedObjects[path] = object;
309
310 return object;
311 }
virtual std::string getString(const std::string &path="") const noexcept(false) override
Get the parameter path as a string.
Definition: Gearbox.h:123
TObject * deserializeEncodedRawData(const std::string &base64Data)
Convert given serialized raw data back into TObject.
Definition: Stream.cc:72

◆ GetTVector3()

TVector3 GetTVector3

returns a TVector3 containing the same coordinates

Definition at line 725 of file B2Vector3.h.

726 {
727 return
728 TVector3(
729 static_cast<Double_t>(X()),
730 static_cast<Double_t>(Y()),
731 static_cast<Double_t>(Z())
732 );
733 }
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:431
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:433

◆ getValue()

T & getValue

Returns the value of the parameter.

Returns
The value of the parameter.

Definition at line 50 of file ModuleParam.templateDetails.h.

51 {
52 return m_paramVariable;
53 }
T & m_paramVariable
Reference to the member variable in the module which stores the parameter value.
Definition: ModuleParam.h:124

◆ GetXYZ() [1/2]

void GetXYZ ( ROOT::Math::XYZVector *  xyzVec) const

directly copies coordinates to a XYZVector

Definition at line 715 of file B2Vector3.h.

716 {
717 xyzVec->SetXYZ(static_cast<Double_t>(X()),
718 static_cast<Double_t>(Y()),
719 static_cast<Double_t>(Z()));
720 }

◆ GetXYZ() [2/2]

void GetXYZ ( TVector3 *  tVec) const

directly copies coordinates to a TVector3

Definition at line 706 of file B2Vector3.h.

707 {
708 tVec->SetXYZ(static_cast<Double_t>(X()),
709 static_cast<Double_t>(Y()),
710 static_cast<Double_t>(Z()));
711 }

◆ GetXYZVector()

ROOT::Math::XYZVector GetXYZVector

returns a XYZVector containing the same coordinates

returns a ROOT::Math::XYZVector containing the same coordinates

Definition at line 738 of file B2Vector3.h.

739 {
740 return
741 ROOT::Math::XYZVector(
742 static_cast<Double_t>(X()),
743 static_cast<Double_t>(Y()),
744 static_cast<Double_t>(Z())
745 );
746 }

◆ initialize()

void initialize ( const EDatabaseState  target = c_Ready)

Initialize the database connection settings on first use.

Definition at line 197 of file Database.cc.

198 {
199 if (m_configState >= target) return;
201
202 if (m_configState == c_PreInit) {
203 // first step: freeze the configuration object and determine the list of globaltags
204 // this calculates if tag replay is possible and will create an error otherwise but
205 // it will not do anything else than setting the final list of globaltags
206 conf.setInitialized(true);
207 m_globalTags = conf.getFinalListOfTags();
208 // trim the globaltag names for removing leading/trailing whitespaces, since they
209 // are a potential source of FATAL errors
210 std::transform(m_globalTags.begin(), m_globalTags.end(), m_globalTags.begin(),
211 [](const auto & tag) {
212 return boost::algorithm::trim_copy(tag);
213 });
214 // and remove duplicates, there's no need to look in the same gt multiple times
215 std::set<std::string> seen;
216 m_globalTags.erase(std::remove_if(m_globalTags.begin(), m_globalTags.end(),
217 [&seen](const auto & tag) {
218 return not seen.insert(tag).second;
219 }), m_globalTags.end());
220 // and also obtain usable tag states and metadata providers
221 m_usableTagStates = conf.getUsableTagStates();
222 m_metadataConfigurations = conf.getMetadataProviders();
223 // reverse because we want to pop out elements when used
224 std::reverse(m_metadataConfigurations.begin(), m_metadataConfigurations.end());
227 }
228 // do we want to stop early?
229 if (m_configState >= target) return;
231 // setup the first working provider;
232 if (m_metadataConfigurations.empty()) {
233 m_metadataProvider = std::make_unique<Conditions::NullMetadataProvider>();
234 } else {
236 }
237 // we will actually use the globaltags so print them now
238 if (!m_globalTags.empty()) {
239 // Globaltags are useable so print out the final list we're gonna use
240 if (m_globalTags.size() == 1) {
241 B2INFO("Conditions data: configured globaltag is " << m_globalTags[0]);
242 } else {
243 B2INFO("Conditions data: configured globaltags (highest priority first) are " << boost::algorithm::join(m_globalTags, ", "));
244 }
245 }
246 // Configure payload location/download
247 m_payloadProvider = std::make_unique<Conditions::PayloadProvider>(
248 conf.getPayloadLocations(),
249 conf.getDownloadCacheDirectory(),
250 conf.getDownloadLockTimeout()
251 );
252 // Also we need to be able to create payloads ...
253 m_payloadCreation = std::make_unique<Conditions::TestingPayloadStorage>(conf.getNewPayloadLocation());
254 // And maaaybe we want to use testing payloads
255 m_testingPayloads.clear();
256 for (const auto& path : conf.getTestingPayloadLocations()) {
257 B2INFO("Conditions data: configured to use testing payloads" << LogVar("location", path));
258 m_testingPayloads.emplace_back(path);
259 }
260 // If so, warn again ... because
261 if (not m_testingPayloads.empty()) {
262 B2WARNING(R"(Conditions data: configured to look for temporary testing payloads from one or more local folders.
263
264 This will lead to non-reproducible results and is strictly only for testing purposes.
265 It is NOT ALLOWED for official productions or data analysis and any results obtained like this WILL NOT BE PUBLISHED.
266 )");
267 }
269 }
270 }
static Configuration & getInstance()
Get a reference to the instance which will be used when the Database is initialized.
EDatabaseState m_configState
Current configuration state of the database.
Definition: Database.h:246
@ c_PreInit
Before any initialization.
Definition: Database.h:47
@ c_InitGlobaltagList
Globaltag list has been finalized metadata providers not and globaltags are not checked for usability...
Definition: Database.h:49
@ c_Ready
Everything is ready.
Definition: Database.h:51
std::unique_ptr< Conditions::PayloadProvider > m_payloadProvider
The active payload provider.
Definition: Database.h:240
std::set< std::string > m_usableTagStates
Set of usable globaltag states to be handed to the metadata providers.
Definition: Database.h:236
std::unique_ptr< Conditions::TestingPayloadStorage > m_payloadCreation
testing payload storage to create new payloads
Definition: Database.h:242
std::vector< std::string > m_metadataConfigurations
List of available metadata providers (which haven't been tried yet)
Definition: Database.h:230

◆ injectArithmeticOperatorToStream()

void injectArithmeticOperatorToStream ( std::ostream &  stream,
const ArithmeticOperation aoperation 
)

Helper functions for AbstractBooleanNode and AbstractExpressionNode print() and decompile() members Shifts the correct characters into the ostream, depending on the ComparisonOperator given.

For decompiling/printing we want the corresponding character of the operator e.g " + " for ArithmeticOperator::PLUS print() redirects to std::cout, decompile() should redirect to a std::stringstream Both streams subclass std::ostream. This allows the use of these functions in both cases.

Definition at line 57 of file AbstractNodes.cc.

58 {
59 switch (aoperation) {
60 case ArithmeticOperation::PLUS:
61 stream << " + ";
62 break;
63 case ArithmeticOperation::MINUS:
64 stream << " - ";
65 break;
66 case ArithmeticOperation::PRODUCT:
67 stream << " * ";
68 break;
69 case ArithmeticOperation::DIVISION:
70 stream << " / ";
71 break;
72 case ArithmeticOperation::POWER:
73 stream << " ** ";
74 break;
75 default:
76 throw std::runtime_error("Invalid ArithmeticOperator provided to injectArithmeticOperatorToStream.");
77 }
78 }

◆ injectBooleanOperatorToStream()

void injectBooleanOperatorToStream ( std::ostream &  stream,
const BooleanOperator boperator 
)

Helper functions for AbstractBooleanNode and AbstractExpressionNode print() and decompile() members Shifts the correct characters into the ostream, depending on the BooleanOperator given.

For decompiling/printing we want the corresponding character of the operator e.g " and " for BooleanOperator::AND print() redirects to std::cout, decompile() should redirect to a std::stringstream Both streams subclass std::ostream. This allows the use of these functions in both cases.

Definition at line 17 of file AbstractNodes.cc.

18 {
19 switch (boperator) {
20 case BooleanOperator::AND:
21 stream << " and ";
22 break;
23 case BooleanOperator::OR:
24 stream << " or ";
25 break;
26 default:
27 throw std::runtime_error("Invalid BooleanOperator provided to injectBooleanOperatorToStream.");
28 }
29 }

◆ injectComparisonOperatorToStream()

void injectComparisonOperatorToStream ( std::ostream &  stream,
const ComparisonOperator coperator 
)

Helper functions for AbstractBooleanNode and AbstractExpressionNode print() and decompile() members Shifts the correct characters into the ostream, depending on the ComparisonOperator given.

For decompiling/printing we want the corresponding character of the operator e.g " == " for ComparisonOperator::EQUALEQUAL print() redirects to std::cout, decompile() should redirect to a std::stringstream Both streams subclass std::ostream. This allows the use of these functions in both cases.

Definition at line 31 of file AbstractNodes.cc.

32 {
33 switch (coperator) {
34 case ComparisonOperator::EQUALEQUAL:
35 stream << " == ";
36 break;
37 case ComparisonOperator::GREATEREQUAL:
38 stream << " >= ";
39 break;
40 case ComparisonOperator::LESSEQUAL:
41 stream << " <= ";
42 break;
43 case ComparisonOperator::GREATER:
44 stream << " > ";
45 break;
46 case ComparisonOperator::LESS:
47 stream << " < ";
48 break;
49 case ComparisonOperator::NOTEQUAL:
50 stream << " != ";
51 break;
52 default:
53 throw std::runtime_error("Invalid ComparisonOperator provided to injectComparisonOperatorToStream.");
54 }
55 }

◆ Instance() [1/2]

Database & Instance ( )
static

Instance of a singleton Database.

Definition at line 42 of file Database.cc.

43 {
44 static Database instance;
45 return instance;
46 }
Database()=default
Hidden constructor, as it is a singleton.

◆ Instance() [2/2]

DBStore & Instance ( )
static

Instance of a singleton DBStore.

This method is used to access the DBStore directly. It is used internally in the DBStore accessor classes.

Definition at line 28 of file DBStore.cc.

29 {
30 static DBStore instance;
31 return instance;
32 }
DBStore()
Hidden constructor, as it is a singleton.
Definition: DBStore.h:151

◆ isLevelEnabled()

bool isLevelEnabled ( LogConfig::ELogLevel  level,
int  debugLevel = 0,
const char *  package = nullptr 
) const
inline

Returns true if the given log level is allowed by the log system (i.e.

>= the system level).

Parameters
levelThe log level which should be compared with the log level of the log system
debugLevelThe level for debug messages. Only used for the debug level.
packageCurrent package (e.g. framework). NULL for package-independent config.

Definition at line 277 of file LogSystem.h.

278 {
279 const LogConfig& config = getCurrentLogConfig(package);
280 const LogConfig::ELogLevel logLevelLimit = config.getLogLevel();
281 const int debugLevelLimit = config.getDebugLevel();
282 return logLevelLimit <= level && (level != LogConfig::c_Debug || debugLevelLimit >= debugLevel);
283 }
ELogLevel
Definition of the supported log levels.
Definition: LogConfig.h:26
@ c_Debug
Debug: for code development.
Definition: LogConfig.h:26
const LogConfig & getCurrentLogConfig(const char *package=nullptr) const
Returns the current LogConfig object used by the logging system.
Definition: LogSystem.h:258

◆ isSet()

bool isSet ( const std::string &  name)
static

Check if a value is set in the database.

Definition at line 19 of file EnvironmentVariables.cc.

20 {
21 char* envValue = std::getenv(name.c_str());
22 return envValue != nullptr;
23 }

◆ loadPayload()

void loadPayload ( const EventMetaData event)
private

Actual load the payload from file after all info is set.

Definition at line 115 of file DBStoreEntry.cc.

116 {
117 if (m_filename == "") {
118 // invalid payload nothing else to do
119 return;
120 }
121 if (m_payloadType != c_RawFile) {
122 // Open the payload file but make sure to go back to the previous
123 // directory to not disturb other code.
124 TDirectory* oldDirectory = gDirectory;
125 m_tfile = TFile::Open(m_filename.c_str());
126 gDirectory = oldDirectory;
127 // Check if the file is open
128 if (!m_tfile || !m_tfile->IsOpen()) {
129 B2ERROR("Cannot open " << std::quoted(m_filename) << " for reading");
130 deleteAndSetNullptr(m_tfile);
131 return;
132 }
133 m_tfile->SetBit(kCanDelete, false);
134 // File is open and we are a normal object entry?
135 if (m_payloadType == c_Object) {
136 // get the object
137 m_object = m_tfile->Get(m_name.c_str());
138 if (!m_object) {
139 B2ERROR("Failed to get " << std::quoted(m_name) << " from payload file "
140 << std::quoted(m_filename) << ".");
141 return;
142 }
143 m_object->SetBit(kCanDelete, false);
144 // check that it is compatible with what it should be
146 // resolve run dependency
147 if (m_object->InheritsFrom(IntraRunDependency::Class())) {
148 m_intraRunDependency = static_cast<IntraRunDependency*>(m_object);
150 B2DEBUG(34, "Found intra run dependency for " << m_name << ": " << m_intraRunDependency << ", " << m_object);
151 }
152 // TODO: depending on the object type we could now close the file. I
153 // guess we cannot close the file in case of TTree but we have to find
154 // out exactly which object types are safe before doing that?
155 }
156 }
157 }
@ c_RawFile
Just a plain old file, we don't look at it just provide the filename.
Definition: DBStoreEntry.h:52
IntraRunDependency * m_intraRunDependency
If the payload has intra run dependency this will point to the whole payload and m_object will just p...
Definition: DBStoreEntry.h:200
TFile * m_tfile
Pointer to the open ROOT TFile pointer for m_filename.
Definition: DBStoreEntry.h:195
std::string m_filename
filename containing which contains the actual payload data
Definition: DBStoreEntry.h:191
TObject * m_object
Pointer to the actual payload object.
Definition: DBStoreEntry.h:197
TObject * getObject(const EventMetaData &event) const
Get the conditions object that is valid for the given event.

◆ log()

void log ( const std::string &  key,
const AClass &  value 
)

Store a value under a certain key. Different types of values can be stored, namely long, double or string. Mixtures are not allowed for a given key.

Definition at line 96 of file ZMQLogger.h.

97 {
98 m_monitoring[key] = value;
99 }
std::map< std::string, std::variant< long, double, std::string > > m_monitoring
Internal storage of all stored values.
Definition: ZMQLogger.h:58

◆ LogConnectionJSON()

LogConnectionJSON ( bool  complete = false)
explicit

The constructor.

Parameters
completeif true ignore the LogInfo settings and output all parts of the message (like file, line, etc.)

Definition at line 19 of file LogConnectionJSON.cc.

19 : m_console{STDOUT_FILENO, false}, m_complete{complete}
20 {
21 }
LogConnectionConsole m_console
LogConnection to the console we use to dispatch the json objects.
bool m_complete
If true ignore the log message format settings and output everything.

◆ ModuleParam()

ModuleParam ( T &  paramVariable,
const std::string &  description = "",
bool  force = false 
)
explicit

Constructor.

A parameter consists of a reference pointing to a member variable in the module which stores and allows fast access to the parameter value. In addition the type of the parameter is saved and optionally a description can be given.

Parameters
paramVariableReference to the variable which stores the parameter value.
descriptionThe optional description of the parameter.
forceIf true the parameter has to be set by the user in the steering file.

Definition at line 28 of file ModuleParam.templateDetails.h.

28 :
29 ModuleParamBase(TypeInfo(), description, force), m_paramVariable(paramVariable) {};
ModuleParamBase(std::string typeInfo, std::string description, bool force)
Constructor.

◆ name()

std::string name
static

Returns the name of the B2Vector.

Returns a less readable (but more compatible) name of the B2Vector3.

Definition at line 767 of file B2Vector3.h.

768 {
769 return std::string("B2Vector3<") + typeid(DataType).name() + std::string(">");
770 }

◆ nextMetadataProvider()

void nextMetadataProvider ( )
protected

Enable the next metadataprovider in the list.

Definition at line 159 of file Database.cc.

160 {
161 if (m_metadataConfigurations.empty()) {
162 B2FATAL("Conditions data: No more metadata providers available");
163 }
165 m_metadataConfigurations.pop_back();
166 bool remote{false};
167 if (auto pos = m_currentProvider.find("://"); pos != std::string::npos) {
168 // found a protocol: if file remove, otherwise keep as is and set as remote ...
169 auto protocol = m_currentProvider.substr(0, pos);
170 boost::algorithm::to_lower(protocol);
171 if (protocol == "file") {
172 m_currentProvider = m_currentProvider.substr(pos + 3);
173 } else if (protocol == "http" or protocol == "https") {
174 remote = true;
175 } else {
176 B2FATAL("Conditions data: Unknown metadata protocol, only supported protocols for payload metadata are file, http, https"
177 << LogVar("protocol", protocol));
178 }
179 }
180 try {
181 if (remote) {
182 m_metadataProvider = std::make_unique<Conditions::CentralMetadataProvider>(m_currentProvider, m_usableTagStates);
183 } else {
184 m_metadataProvider = std::make_unique<Conditions::LocalMetadataProvider>(m_currentProvider, m_usableTagStates);
185 }
186 } catch (std::exception& e) {
187 B2WARNING("Conditions data: Metadata provider not usable, trying next one ..."
188 << LogVar("provider", m_currentProvider) << LogVar("error", e.what()));
189 return nextMetadataProvider();
190 }
191 // and check the tags are useable
192 if (!m_metadataProvider->setTags(m_globalTags)) {
193 B2FATAL("Conditions data: Problems with globaltag configuration, cannot continue");
194 }
195 }

◆ notifyAccessors()

void notifyAccessors ( bool  onDestruction = false)
private

Notify all the registered accessors.

Definition at line 190 of file DBStoreEntry.cc.

191 {
192 // Just notify all registered accessors ...
193 for (DBAccessorBase* object : m_accessors) object->storeEntryChanged(onDestruction);
194 // on destruction we also should clear the list ... we will not call them again
195 if (onDestruction) m_accessors.clear();
196 }
std::unordered_set< DBAccessorBase * > m_accessors
Vector of all the accessors registered with this entry.
Definition: DBStoreEntry.h:202

◆ open()

void open ( const std::string &  name = "Belle2.xml",
size_t  cacheSize = c_DefaultCacheSize 
)

Open connection to backend and parse tree.

Parameters
nameName of the tree to parse
cacheSizemaximum cache size in entries

Definition at line 133 of file Gearbox.cc.

134 {
135 //Check if we have an open connection and close first if so
136 if (m_xmlDocument) close();
137 //Check if we have at least one backend
138 if (m_handlers.empty())
139 B2FATAL("No backends defined, please use Gearbox::setBackends() first to specify how to access XML files.");
140
141 // register input callbacks for opening the files
142 xmlRegisterInputCallbacks(gearbox::matchXmlUri, gearbox::openXmlUri,
143 gearbox::readXmlData, gearbox::closeXmlContext);
144
145 //Open document
146 m_xmlDocument = xmlParseFile(name.c_str());
147 //libxml >= 2.7.0 introduced some limits on node size etc. which breaks reading VXDTF files
148 xmlXIncludeProcessFlags(m_xmlDocument, XML_PARSE_HUGE);
149
150 // reset input callbacks
151 xmlPopInputCallbacks();
152
153 if (!m_xmlDocument) B2FATAL("Could not connect gearbox to " << name);
154 m_xpathContext = xmlXPathNewContext(m_xmlDocument);
155 if (!m_xpathContext) B2FATAL("Could not create XPath context");
156
157 //Apply overrides
158 for (const auto& poverride : m_overrides) {
159 overridePathValue(poverride);
160 }
161
162 //Speeds up XPath computation on static documents.
163 xmlXPathOrderDocElems(m_xmlDocument);
164
165 //Set cachesize
166 m_parameterCache->setMaxSize(cacheSize);
167 }
std::vector< PathOverride > m_overrides
the existing overrides
Definition: Gearbox.h:223
void overridePathValue(const PathOverride &poverride)
Change the value of a given path expression.
Definition: Gearbox.cc:184
void close()
Free internal structures of previously parsed tree and clear cache.
Definition: Gearbox.cc:169

◆ openXmlUri()

gearbox::InputContext * openXmlUri ( const std::string &  uri) const
private

Function to be called when libxml requests a new input uri to be opened.

Definition at line 87 of file Gearbox.cc.

88 {
89 //Check input handlers one by one
90 for (gearbox::InputHandler* handler : m_handlers) {
91 //try to create context for uri, return if success
92 gearbox::InputContext* context = handler->open(uri);
93 if (context) return context;
94 }
95 B2ERROR("Could not find data for uri '" << uri << "'");
96 return nullptr;
97 }

◆ operator!=()

Bool_t operator!= ( const TVector3 &  a,
const B2Vector3< DataType > &  b 
)

non-memberfunction Comparison for equality with a TVector3

Definition at line 530 of file B2Vector3.h.

531 {
532 return !(a == b);
533 }

◆ operator*()

B2Vector3< DataType > operator* ( DataType  a,
const B2Vector3< DataType > &  p 
)

non-memberfunction Scaling of 3-vectors with a real number

Definition at line 537 of file B2Vector3.h.

538 {
539 return B2Vector3<DataType>(a * p.X(), a * p.Y(), a * p.Z());
540 }

◆ operator*=()

B2Vector3< DataType > & operator*= ( DataType  a)

scaling with real numbers

multiplication with a real number

Definition at line 652 of file B2Vector3.h.

653 {
654 m_coordinates[0] *= a;
655 m_coordinates[1] *= a;
656 m_coordinates[2] *= a;
657 return *this;
658 }

◆ operator+() [1/4]

B2Vector3< DataType > operator+ ( const B2Vector3< DataType > &  a,
const ROOT::Math::XYZVector &  b 
)

non-memberfunction for adding a B2Vector3 to a XYZVector

Definition at line 586 of file B2Vector3.h.

587 {
588 return B2Vector3<DataType>(a.X() + b.X(), a.Y() + b.Y(), a.Z() + b.Z());
589 }

◆ operator+() [2/4]

B2Vector3< DataType > operator+ ( const B2Vector3< DataType > &  a,
const TVector3 &  b 
)

non-memberfunction for adding a B2Vector3 to a TVector3

Definition at line 558 of file B2Vector3.h.

559 {
560 return B2Vector3<DataType>(a.X() + b.X(), a.Y() + b.Y(), a.Z() + b.Z());
561 }

◆ operator+() [3/4]

B2Vector3< DataType > operator+ ( const ROOT::Math::XYZVector &  a,
const B2Vector3< DataType > &  b 
)

non-memberfunction for adding a XYZVector to a B2Vector3

Definition at line 572 of file B2Vector3.h.

573 {
574 return B2Vector3<DataType>(a.X() + b.X(), a.Y() + b.Y(), a.Z() + b.Z());
575 }

◆ operator+() [4/4]

B2Vector3< DataType > operator+ ( const TVector3 &  a,
const B2Vector3< DataType > &  b 
)

non-memberfunction for adding a TVector3 to a B2Vector3

Definition at line 544 of file B2Vector3.h.

545 {
546 return B2Vector3<DataType>(a.X() + b.X(), a.Y() + b.Y(), a.Z() + b.Z());
547 }

◆ operator+=()

B2Vector3< DataType > & operator+= ( const B2Vector3< DataType > &  b)

addition

Definition at line 631 of file B2Vector3.h.

632 {
633 m_coordinates[0] += b.X();
634 m_coordinates[1] += b.Y();
635 m_coordinates[2] += b.Z();
636 return *this;
637 }

◆ operator-() [1/4]

B2Vector3< DataType > operator- ( const B2Vector3< DataType > &  a,
const ROOT::Math::XYZVector &  b 
)

non-memberfunction for substracting a B2Vector3 from a XYZVector

Definition at line 593 of file B2Vector3.h.

594 {
595 return B2Vector3<DataType>(a.X() - b.X(), a.Y() - b.Y(), a.Z() - b.Z());
596 }

◆ operator-() [2/4]

B2Vector3< DataType > operator- ( const B2Vector3< DataType > &  a,
const TVector3 &  b 
)

non-memberfunction for substracting a B2Vector3 from a TVector3

Definition at line 565 of file B2Vector3.h.

566 {
567 return B2Vector3<DataType>(a.X() - b.X(), a.Y() - b.Y(), a.Z() - b.Z());
568 }

◆ operator-() [3/4]

B2Vector3< DataType > operator- ( const ROOT::Math::XYZVector &  a,
const B2Vector3< DataType > &  b 
)

non-memberfunction for substracting a XYZVector from a B2Vector3

Definition at line 579 of file B2Vector3.h.

580 {
581 return B2Vector3<DataType>(a.X() - b.X(), a.Y() - b.Y(), a.Z() - b.Z());
582 }

◆ operator-() [4/4]

B2Vector3< DataType > operator- ( const TVector3 &  a,
const B2Vector3< DataType > &  b 
)

non-memberfunction for substracting a TVector3 from a B2Vector3

Definition at line 551 of file B2Vector3.h.

552 {
553 return B2Vector3<DataType>(a.X() - b.X(), a.Y() - b.Y(), a.Z() - b.Z());
554 }

◆ operator-=()

B2Vector3< DataType > & operator-= ( const B2Vector3< DataType > &  b)

subtraction

Definition at line 642 of file B2Vector3.h.

643 {
644 m_coordinates[0] -= b.X();
645 m_coordinates[1] -= b.Y();
646 m_coordinates[2] -= b.Z();
647 return *this;
648 }

◆ operator<<()

std::ostream & operator<< ( std::ostream &  output,
const IntervalOfValidity iov 
)
Parameters
outputThe output stream.
iovThe IntervalOfValidity object.

Definition at line 194 of file IntervalOfValidity.cc.

195 {
196 output << iov.m_experimentLow << "," << iov.m_runLow << "," << iov.m_experimentHigh << "," << iov.m_runHigh;
197
198 return output;
199 }

◆ operator=() [1/3]

B2Vector3< DataType > & operator= ( const B2Vector3< DataType > &  b)

Assignment via B2Vector3.

Definition at line 601 of file B2Vector3.h.

602 {
603 m_coordinates[0] = b.X();
604 m_coordinates[1] = b.Y();
605 m_coordinates[2] = b.Z();
606 return *this;
607 }

◆ operator=() [2/3]

B2Vector3< DataType > & operator= ( const ROOT::Math::XYZVector &  b)

Assignment via XYZVector.

Definition at line 621 of file B2Vector3.h.

622 {
623 m_coordinates[0] = b.X();
624 m_coordinates[1] = b.Y();
625 m_coordinates[2] = b.Z();
626 return *this;
627 }

◆ operator=() [3/3]

B2Vector3< DataType > & operator= ( const TVector3 &  b)

Assignment via TVector3.

Definition at line 611 of file B2Vector3.h.

612 {
613 m_coordinates[0] = b.X();
614 m_coordinates[1] = b.Y();
615 m_coordinates[2] = b.Z();
616 return *this;
617 }

◆ operator==()

Bool_t operator== ( const TVector3 &  a,
const B2Vector3< DataType > &  b 
)

non-memberfunction Comparison for equality with a TVector3

Definition at line 523 of file B2Vector3.h.

524 {
525 return (a.X() == b.X() && a.Y() == b.Y() && a.Z() == b.Z());
526 }

◆ operator>>()

std::istream & operator>> ( std::istream &  input,
IntervalOfValidity iov 
)
Parameters
inputThe input stream.
iovThe InervalOfValidity object.

Definition at line 150 of file IntervalOfValidity.cc.

151 {
152 iov = IntervalOfValidity();
153 if (!input.good()) {
154 throw std::runtime_error("cannot read from stream");
155 }
156
157 std::string str[4];
158 int index = 0;
159 while (input.good()) {
160 auto c = input.peek();
161 if (c == EOF) break;
162 if (((c == ' ') || (c == '\n') || (c == '\t'))) {
163 //ignore whitespace in the beginning
164 if (index == 0 && str[0].empty()) {
165 input.get();
166 continue;
167 }
168 //and stop parsing otherwise
169 break;
170 }
171 if (c == ',') {
172 index++;
173 if (index == 4) break;
174 } else {
175 str[index] += c;
176 }
177 input.get();
178 }
179 if (index != 3) {
180 throw std::invalid_argument("IoV needs to be four values (firstExp,firstRun,finalExp,finalRun)");
181 }
182 try {
183 iov.m_experimentLow = stoi(str[0]);
184 iov.m_runLow = stoi(str[1]);
185 iov.m_experimentHigh = stoi(str[2]);
186 iov.m_runHigh = stoi(str[3]);
187 } catch (std::invalid_argument& e) {
188 throw std::invalid_argument("experiment and run numbers must be integers");
189 }
190
191 return input;
192 }
A class that describes the interval of experiments/runs for which an object in the database is valid.

◆ operatorToChar()

char operatorToChar ( EOperator  op)
staticnoexcept

Convert operator code to character.

Definition at line 19 of file FormulaParser.cc.

20 {
21 switch (op) {
22 case EOperator::c_noop: return ' ';
23 case EOperator::c_plus: return '+';
24 case EOperator::c_minus: return '-';
25 case EOperator::c_multiply: return '*';
26 case EOperator::c_divide: return '/';
27 case EOperator::c_power: return '^';
28 case EOperator::c_roundBracketOpen: return '(';
29 case EOperator::c_roundBracketClose: return ')';
30 case EOperator::c_squareBracketOpen: return '[';
31 case EOperator::c_squareBracketClose: return ']';
32 }
33 return 0;
34 }

◆ overrideObject()

void overrideObject ( TObject *  obj,
const IntervalOfValidity iov 
)
private

Set an override object in case we want to use a different object then actually provided by the database.

Parameters
objInstance to use as payload, this entry will take over ownership.
iovinterval how long this object should be valid

Definition at line 159 of file DBStoreEntry.cc.

160 {
161 if (!checkType(obj)) return;
162
163 m_globaltag = "";
164 m_revision = 0;
165 m_filename = "";
166 m_iov = iov;
167 m_keep = true;
168 // object unchanged, nothing to do
169 if (m_object == obj) {
170 B2DEBUG(34, "DBEntry " << std::quoted(m_name) << " override unchanged");
171 return;
172 }
173 // We need to clean up the object but if someone hands us the same object
174 // we already own this would lead to invalid access later so make sure we
175 // only delete it when appropriate
176 if (!isIntraRunDependent()) {
177 delete m_object;
178 }
179 // clean up the other memory
180 deleteAndSetNullptr(m_intraRunDependency, m_tfile);
181 // and set, ready go
182 m_object = obj;
183 B2DEBUG(34, "DBEntry " << this << " " << std::quoted(m_name) << " override created: " << std::endl
184 << " object = " << m_object << std::endl
185 << " validity = " << m_iov << std::endl
186 << " -> notiying accessors");
188 }
bool isIntraRunDependent() const
return whether or not the payload might change even during the run
Definition: DBStoreEntry.h:119
IntervalOfValidity m_iov
validity of this payload
Definition: DBStoreEntry.h:189
unsigned int m_revision
revision of this payload
Definition: DBStoreEntry.h:187
bool m_keep
if True this payload should not be updated unless it's really out of date.
Definition: DBStoreEntry.h:183
std::string m_globaltag
globaltag name (or testing payloads path) from which this payload is picked.
Definition: DBStoreEntry.h:185
void notifyAccessors(bool onDestruction=false)
Notify all the registered accessors.

◆ overridePathValue()

void overridePathValue ( const PathOverride poverride)
private

Change the value of a given path expression.

Definition at line 184 of file Gearbox.cc.

185 {
186 if (m_xpathContext == nullptr) B2FATAL("Gearbox is not connected");
187 //Make sure it ends with a slash
188 string query = ensureNode(poverride.path);
189 //Ok, lets search for the path
190 B2INFO("Override '" << poverride.path << "' with '" << poverride.value
191 << "' (unit: '" << poverride.unit << "')");
192 xmlXPathObjectPtr result = xmlXPathEvalExpression((xmlChar*) query.c_str(), m_xpathContext);
193 if (result != nullptr && result->type == XPATH_NODESET && !xmlXPathNodeSetIsEmpty(result->nodesetval)) {
194 //Found it, so let's replace the content
195 int numNodes = xmlXPathNodeSetGetLength(result->nodesetval);
196 if (!poverride.multiple && numNodes > 1) {
197 B2ERROR("Cannot override '" << poverride.path << "': more than one node found");
198 return;
199 } else {
200 B2DEBUG(200, "Found " << numNodes << " nodes, overriding them all");
201 }
202 for (int i = numNodes - 1; i >= 0; --i) {
203 xmlNodePtr node = result->nodesetval->nodeTab[i];
204 //Check if children are only TEXT nodes
205 bool textOnly(true);
206 for (xmlNodePtr child = node->children; child; child = child->next) {
207 textOnly &= child->type == XML_TEXT_NODE;
208 if (!textOnly) break;
209 }
210 if (!textOnly) {
211 B2ERROR("Cannot override '" << poverride.path << "': not just text content");
212 continue;
213 }
214 xmlNodeSetContent(node, BAD_CAST poverride.value.c_str());
215
216 //Is the path an element? if so replace the unit, otherwise warn
217 if (node->type != XML_ELEMENT_NODE) {
218 if (!poverride.unit.empty())
219 B2WARNING("Cannot set unit '" << poverride.unit << "' on '"
220 << poverride.path << "': not an element");
221 } else {
222 xmlSetProp(node, BAD_CAST "unit", BAD_CAST poverride.unit.c_str());
223 }
224 //From libxml example xpath2.c:
225 //All the elements returned by an XPath query are pointers to
226 //elements from the tree *except* namespace nodes where the XPath
227 //semantic is different from the implementation in libxml2 tree.
228 //As a result when a returned node set is freed when
229 //xmlXPathFreeObject() is called, that routine must check the
230 //element type. But node from the returned set may have been removed
231 //by xmlNodeSetContent() resulting in access to freed data.
232 //There is 2 ways around it:
233 // - make a copy of the pointers to the nodes from the result set
234 // then call xmlXPathFreeObject() and then modify the nodes
235 //or
236 // - remove the reference to the modified nodes from the node set
237 // as they are processed, if they are not namespace nodes.
238 if (node->type != XML_NAMESPACE_DECL)
239 result->nodesetval->nodeTab[i] = nullptr;
240 }
241 } else {
242 B2ERROR("Cannot override '" << poverride.path << "': not found");
243 }
244 xmlXPathFreeObject(result);
245 }

◆ performUpdate()

void performUpdate ( const EventMetaData event)
private

The main code that does an update, factored out so it can be used by both update and update(event).

Definition at line 108 of file DBStore.cc.

109 {
110 // For the time being we will request updates for all payloads just to make
111 // sure we never miss an update. This is done once per run so it should be
112 // fine from performance.
113 // TODO: once we are sure somehow to not have duplicate iovs we can relax
114 // this requirement.
115 std::vector<Database::DBQuery> entries;
116 entries.reserve(m_dbEntries.size());
117 for (auto& entry : m_dbEntries) {
118 bool expired = !entry.second.getIoV().contains(event);
119 if (expired) {
120 B2DEBUG(34, "DBEntry " << entry.first << " out of date, will need update");
121 }
122 if (!entry.second.keepUntilExpired() || expired)
123 entries.emplace_back(entry.first, entry.second.isRequired());
124 // remove from intra run handling, will be added again after update if needed.
125 m_intraRunDependencies.erase(&entry.second);
126 }
127
128 // nothing to update
129 if (entries.empty()) return;
130
131 // Request new objects and IoVs from database
132 Database::Instance().getData(event, entries);
133
134 // Update DBStore entries
135 for (auto& query : entries) {
136 auto& dbEntry = m_dbEntries.find(query.name)->second;
137 dbEntry.updatePayload(query.revision, query.iov, query.filename, query.checksum, query.globaltag, event);
138 if (dbEntry.isIntraRunDependent()) m_intraRunDependencies.insert(&dbEntry);
139 }
140 }

◆ performUpdateEvent()

void performUpdateEvent ( const EventMetaData event)
private

The main code that does an updateEvent.

Factored out so it can be used by both updateEvent and updateEvent(eventNumber).

Definition at line 169 of file DBStore.cc.

170 {
171 // loop over intra-run dependent conditions and update the objects if needed
172 for (auto& dbEntry : m_intraRunDependencies) {
173 dbEntry->updateObject(event);
174 }
175 }

◆ poll()

int poll ( unsigned int  timeout,
AMulticastAnswer  multicastAnswer,
ASocketAnswer  socketAnswer 
) const

Poll both the multicast and the data socket until, either:

  • the timeout is raised. The method will return with 0.
  • a message came to the multicast socket. Then, the multicastAnswer will be called with the socket as an argument. If this method returns true, the polling will go on like before. If it returns false, the polling will be stopped. The return value of this function is 1.
  • a message came to the data socket. See above.

A note on the order: if there are messages on both the data socket and the multicast socket, first all messages to the multicast socket will be answered and then all messages to the data socket.

Definition at line 113 of file ZMQClient.h.

114 {
115 B2ASSERT("Can only run this on started clients", m_subSocket and m_socket);
116 bool repeat = true;
117 int pollResult;
118 do {
119 pollResult = pollSocketVector(m_pollSocketPtrList, timeout);
120 if (pollResult & 1) {
121 // The multicast is the first entry.
122 // Get all entries if possible, but do not block anymore.
123 std::vector<zmq::socket_t*> vector = {m_subSocket.get()};
124 while (pollSocketVector(vector, 0) and repeat) {
125 repeat = multicastAnswer(m_subSocket);
126 }
127 }
128
129 if (pollResult & 2) {
130 // Get all entries if possible, but do not block anymore.
131 std::vector<zmq::socket_t*> vector = {m_socket.get()};
132 while (pollSocketVector(vector, 0) and repeat) {
133 repeat = socketAnswer(m_socket);
134 }
135 }
136 } while (repeat and pollResult);
137
138 return pollResult;
139 }
std::unique_ptr< zmq::socket_t > m_subSocket
ZMQ sub socket.
Definition: ZMQClient.h:107
static int pollSocketVector(const std::vector< zmq::socket_t * > &socketList, int timeout)
Internal poll function.
Definition: ZMQClient.cc:118
std::vector< zmq::socket_t * > m_pollSocketPtrList
Will use this vector for polling.
Definition: ZMQClient.h:102
std::unique_ptr< zmq::socket_t > m_socket
ZMQ socket.
Definition: ZMQClient.h:109

◆ pollMulticast()

int pollMulticast ( unsigned int  timeout,
AMulticastAnswer  multicastAnswer 
) const

Poll method to only the multicast socket.

Basically the same as the poll function to both sockets, except: If the answer function returns false, the polling will stop as above, BUT: it will first answer all messages that are already in the socket!

Definition at line 162 of file ZMQClient.h.

163 {
164 B2ASSERT("Can only run this on started clients", m_subSocket);
165 std::vector<zmq::socket_t*> vector = {m_subSocket.get()};
166
167 bool repeat = true;
168 int pollResult;
169 do {
170 pollResult = pollSocketVector(vector, timeout);
171 if (pollResult) {
172 while (pollSocketVector(vector, 0)) {
173 repeat = multicastAnswer(m_subSocket);
174 }
175 }
176 } while (repeat and pollResult);
177
178 return pollResult;
179 }

◆ pollSocket()

int pollSocket ( unsigned int  timeout,
ASocketAnswer  socketAnswer 
) const

Poll method to only the data socket.

Basically the same as the poll function to both sockets, except: If the answer function returns false, the polling will stop as above, BUT: it will first answer all messages that are already in the socket!

Definition at line 142 of file ZMQClient.h.

143 {
144 B2ASSERT("Can only run this on started clients", m_socket);
145 std::vector<zmq::socket_t*> vector = {m_socket.get()};
146
147 bool repeat = true;
148 int pollResult;
149 do {
150 pollResult = pollSocketVector(vector, timeout);
151 if (pollResult) {
152 while (pollSocketVector(vector, 0)) {
153 repeat = socketAnswer(m_socket);
154 }
155 }
156 } while (repeat and pollResult);
157
158 return pollResult;
159 }

◆ processString()

void processString ( const std::string &  formula)
protected

Process the given formula and store the final state.

Definition at line 225 of file FormulaParser.cc.

226 {
227 // initialize buffer
228 m_buffer = std::istringstream(formula);
229 // clear stacks
230 std::stack<EOperator>().swap(m_operatorStack);
231 // and an empty identifier name
232 m_currentVariableName.clear();
234 // reset some other variable state
236 // and if the variable has arguments remember the nesting level of the ()
237 int nestlevel{0};
238 // Now loop over the whole formula character by character
239 for (char next; m_buffer.get(next);) {
240 // If nestlevel>0 we are in a variable(...) parameters area so ignore
241 // everything but keep track of how many open/closing brackets we saw
242 // until we are back to nestlevel=0
243 if (nestlevel > 0) {
244 m_currentVariableName += next;
245 if (next == '(') ++nestlevel;
246 if (next == ')') --nestlevel;
247 // finished variable arguments so variable is definitely done
248 if (nestlevel == 0) flushCurrentVariable();
249 // done with this character
250 continue;
251 }
252
253 // check for opening parenthesis: could be variable arguments or operation binding
254 if (next == '(' and not m_currentVariableName.empty()) {
255 m_currentVariableName += next;
256 ++nestlevel;
257 // definitely not a number anymore
259 // done with this character
260 continue;
261 }
262
263 // check for operator
264 auto opcode = checkForOperator(next);
265 if (opcode != EOperator::c_noop) {
266 // found operator, flush variable, add operator
268 addOperator(opcode);
269 // done with this character
270 continue;
271 }
272
273 // check for whitespace
274 if (next == ' ' or next == '\n' or next == '\t' or next == '\r') {
275 // variable is finished, just flush here.
277 // otherwise nothing to do with whitespace ...
278 continue;
279 }
280
281 // anything else is a identifier, most likely a variable name or a
282 // float literal now lets build up the variable name, first lets check
283 // if the variable name will still be a valid number
285 // then just add it to the state
286 m_currentVariableName += next;
287 }
288 if (nestlevel > 0) throw std::runtime_error("unterminated variable arguments");
289 // done with parsing, lets make sure everything is flushed
292 }
EOperator checkForOperator(char next)
Check if the next character is a operator.
void flushPendingOperators()
Flush all pending operators at the end of processing.
void addOperator(EOperator op)
Add an operator to the internal state, convert them to reverse polish notation using the shunting yar...
void flushCurrentVariable()
Flush the currently parsed variable name and add it to the state either as variable or number.

◆ raiseError()

void raiseError ( const std::runtime_error &  e)
protected

Format the given runtime_error with context information and rethrow a new one.

Definition at line 294 of file FormulaParser.cc.

295 {
296 // So lets some fun printing the error message :D
297 std::ostringstream message;
298 // check where we stopped parsing
299 auto pos = m_buffer.tellg();
300 // -1 -> after the end
301 if (pos == -1) pos = m_buffer.str().size() + 1;
302 // basic boring message + reason
303 message << "Error parsing formula at character " << pos << ": " << e.what() << std::endl;
304 // now lets go through the formula again, line by line. YES, multi line formula are a thing
305 std::istringstream errbuff(m_buffer.str());
306 long lastpos = 0;
307 bool arrowShown{false};
308 for (std::string line; std::getline(errbuff, line);) {
309 // print each line
310 message << " " << line << std::endl;
311 // and get the position after each line
312 auto curpos = errbuff.tellg();
313 // if it's the last line or if we are now beyond the error position then print an arrow
314 if (!arrowShown && (curpos == -1 || curpos >= pos)) { // -1 = last line
315 // from the beginning to the line to the position of the error
316 for (long i = lastpos - 1; i < pos; ++i) message << "-";
317 message << "^" << std::endl;
318 // but only show it once
319 arrowShown = true;
320 }
321 lastpos = curpos;
322 }
323 throw std::runtime_error(message.str());
324 }

◆ random01()

double random01 ( )
inline

Generate a random double value between 0 and 1, both limits excluded.

Returns
value in (0,1)

Definition at line 240 of file RandomGenerator.h.

241 {
242 // There are two possibilities to generate a uniform double between 0 and
243 // 1: multiply the integer by a constant or exploit the double
244 // representation and use some bit shift magic. We have both implementation
245 // here and they seem to produce the exact same output so we stick with the
246 // more readable one but leave the bitshift solution just in case
247#ifdef RANDOM_IEEE754
248 //Generate a double in (0,1) using magic bit hackery with doubles: The
249 //memory layout of a IEEE754 double precision floating point variable
250 //is [sign(1)|exponent(11)|fraction(52)] with values in parentheses
251 //being the number of bits. The actual value is then
252 //-1^{sign} * (1.fraction) * 2^{exponent-1023}. Setting sign to 0 the
253 //exponent to 1023 will thus return a value between 1 (inclusive) and 2
254 //(exclusive). So we shift the 64bit integer to the right by 12 bits
255 //(which gives as zeros for sign and exponent) and logical or this with
256 //the correct binary representation of the exponent
257
258 //To do this we use a union to modify the binary representation using
259 //an integer and then return the double value
260 union { uint64_t i; double d; } x;
261 x.i = random64() >> 12;
262 //This is a bit academic but we want (0,1) so if we happen to get
263 //exactly zero we try again. Chance is 1 in 2^52
264 if (x.i == 0) return random01();
265 x.i |= 0x3FF0000000000000ULL;
266 return x.d - 1.0;
267#else
268 //Generate a double (0,1) the traditional way by multiplying it with a
269 //constant. As doubles only have a precision of 52 bits we need to
270 //remove the 12 leading bits from our random int value
271 const uint64_t x = random64() >> 12;
272 //This is a bit academic but we want (0,1) so if we happen to get
273 //exactly zero we try again. Chance is 1 in 2^52
274 if (!x) return random01();
275 //return x / 2^{52};
276 return x * 2.220446049250313080847263336181640625e-16;
277#endif
278 }
double random01()
Generate a random double value between 0 and 1, both limits excluded.
uint64_t random64()
Generate one 64bit unsigned integer between 0 and UINT64_MAX (both inclusive).

◆ random64()

uint64_t random64 ( )
inline

Generate one 64bit unsigned integer between 0 and UINT64_MAX (both inclusive).

Returns
random value in [0, UINT64_MAX]

Definition at line 200 of file RandomGenerator.h.

201 {
202 //Generate random number using magic, taken from [arXiv:1402.6246] and only
203 //changed to conform to naming scheme
204 uint64_t s0 = m_state[ m_index ];
205 uint64_t s1 = m_state[ m_index = (m_index + 1) & 15 ];
206 s1 ^= s1 << 31;
207 s1 ^= s1 >> 11;
208 s0 ^= s0 >> 30;
209 return (m_state[ m_index ] = s0 ^ s1) * 1181783497276652981LL;
210 }
uint64_t m_state[16]
Internal state of the random number generator.
unsigned int m_index
currently active index in the internal state

◆ rebuild()

void rebuild ( bool  force = false)
protected

Rebuild the index.

Parameters
forceif force is true, the index will be rebuild even if the RelationArray says that it has not been modified

Definition at line 156 of file RelationIndexContainer.h.

157 {
159 if (!m_valid) {
160 B2DEBUG(100, "Relation " << m_storeRel.getName() << " does not exist, cannot build index");
161 m_index.clear();
164 return;
165 }
166
167 //Check if relation has been modified since we created the index
168 //If not, keep old contents
169 if (!force && !m_storeRel.getModified()) return;
170
171 B2DEBUG(100, "Building index for " << m_storeRel.getName());
172
173 //Reset modification flag
174 m_storeRel.setModified(false);
175
176 m_index.clear();
177
178 //Get related StoreArrays
181 const StoreArray<FROM> storeFrom(m_storeFrom.first, m_storeFrom.second);
182 const StoreArray<TO> storeTo(m_storeTo.first, m_storeTo.second);
183
184 //Get number of entries in relation and stores (also checks template type versus DataStore contents)
185 const RelationElement::index_type nFrom = storeFrom.getEntries();
186 const RelationElement::index_type nTo = storeTo.getEntries();
187 const unsigned int nRel = m_storeRel.getEntries();
188
189 //Loop over all RelationElements and add them to index
190 for (unsigned int i = 0; i < nRel; ++i) {
191 const RelationElement& r = m_storeRel[i];
192 RelationElement::index_type idxFrom = r.getFromIndex();
193 if (idxFrom >= nFrom)
194 B2FATAL("Relation " << m_storeRel.getName() << " is inconsistent: from-index (" << idxFrom << ") out of range");
195 const FROM* from = storeFrom[idxFrom];
196
197 //Loop over index and weight vector at once
198 const auto& indices = r.getToIndices();
199 const auto& weights = r.getWeights();
200 auto itIdx = indices.begin();
201 auto itWgt = weights.begin();
202 const auto& idxEnd = indices.end();
203 for (; itIdx != idxEnd; ++itIdx, ++itWgt) {
204 const RelationElement::index_type idxTo = *itIdx;
205 if (idxTo >= nTo)
206 B2FATAL("Relation " << m_storeRel.getName() << " is inconsistent: to-index (" << idxTo << ") out of range");
207 const TO* to = storeTo[idxTo];
208 m_index.insert(Element(idxFrom, idxTo, from, to, *itWgt));
209 }
210 }
211 }
const AccessorParams & getFromAccessorParams() const
Return the AccessorParams the attached relation points from.
bool getModified() const
Get modified flag of underlying container.
const AccessorParams & getToAccessorParams() const
Return the AccessorParams the attached relation points to.
void setModified(bool modified)
Set modified flag of underlying container.
int getEntries() const
Get the number of elements.
unsigned int index_type
type used for indices.
RelationArray m_storeRel
the underlying relation.
AccessorParams m_storeFrom
AccessorParams of the StoreArray the relation points from.
bool m_valid
Indicate wether the relation is valid.
ElementIndex m_index
Instance of the index.
AccessorParams m_storeTo
AccessorParams of the StoreArray the relation points to.
std::pair< std::string, DataStore::EDurability > AccessorParams
Pair of parameters needed to find an object in the DataStore.

◆ registerConversion()

double registerConversion ( const std::string &  name,
double  value 
)
staticprotected

registers the name and value of a conversion in s_conversionFactors.

Definition at line 149 of file UnitConst.cc.

150 {
151 if (!s_conversionFactors.insert(make_pair(name, value)).second) {
152 B2ERROR("Conversion factor for unit " << name << " already exists, ignoring");
153 }
154 return value;
155 }

◆ reset() [1/2]

void reset ( bool  keepConfig = false)
static

Reset the database instance.

Parameters
keepConfigif true the configuration object itself is not resetted so that initializing the database again will result in the same configuration as before. This is useful when running process multiple times.

Definition at line 50 of file Database.cc.

51 {
53 conf.setInitialized(false);
58 if (not keepConfig)
59 conf.reset();
60 }
void reset(bool keepEntries=false)
Invalidate all payloads.
Definition: DBStore.cc:177
static DBStore & Instance()
Instance of a singleton DBStore.
Definition: DBStore.cc:28

◆ reset() [2/2]

void reset ( bool  keepEntries = false)

Invalidate all payloads.

Parameters
keepEntriesKeep the existing entries so that future calls to update the database will try to obtain the payloads which were registered so far.

Definition at line 177 of file DBStore.cc.

178 {
179 if (!m_dbEntries.empty())
180 B2DEBUG(31, "DBStore::reset(): Cleaning all database information");
182 if (!keepEntries) {
183 m_dbEntries.clear();
184 } else {
185 for (auto& entry : m_dbEntries) {
186 entry.second.resetPayload();
187 }
188 }
189 // Make sure our EventMetaData pointer is reconnected on next access ...
190 // because probably this is after resetting the DataStore (BII-1262)
191 StoreObjPtr<EventMetaData> event;
192 m_storeEvent = event;
193 m_manualEvent = std::nullopt;
194 }

◆ resetPayload()

void resetPayload ( )
private

reset the payload to nothing

Definition at line 68 of file DBStoreEntry.cc.

69 {
70 m_globaltag = "";
71 m_revision = 0;
72 m_iov = IntervalOfValidity();
73 m_keep = false;
74 m_filename = "";
75 m_checksum = "";
76 // If the old object was intra run dependent then m_object is owned by the
77 // intra run dependency object. So set the pointer to null to not delete the object.
78 if (m_intraRunDependency) m_object = nullptr;
79 // and delete the old intra run dependency if it exists
80 deleteAndSetNullptr(m_object, m_intraRunDependency, m_tfile);
81 }
std::string m_checksum
checksum of the payload file
Definition: DBStoreEntry.h:193

◆ resetValue()

void resetValue

Resets the parameter value by assigning the default value to the parameter value.

Definition at line 87 of file ModuleParam.templateDetails.h.

88 {
90 m_setInSteering = false;
91 }
bool m_setInSteering
True, if the parameter value was changed in the steering file.

◆ RndmArray() [1/4]

void RndmArray ( Int_t  n,
Double_t *  array 
)
inline

Fill an array of doubles with random values in (0,1), both limits excluded.

Parameters
nnumber of doubles to generate
arraypointer to an array where the numbers should be stored

Definition at line 219 of file RandomGenerator.h.

220 {
221 //Fill the array, no optimization whatsoever necessary
222 for (int i = 0; i < n; ++i) array[i] = random01();
223 }

◆ RndmArray() [2/4]

void RndmArray ( Int_t  n,
Float_t *  array 
)
inline

Fill an array of floats with random values in (0,1), both limits excluded.

Parameters
nnumber of floats to generate
arraypointer to an array where the numbers should be stored

Definition at line 212 of file RandomGenerator.h.

213 {
214 //We could optimize this more thoroughly since one 64bit random int is
215 //enough to generate two floats but this would probably be rather academic
216 for (int i = 0; i < n; ++i) array[i] = random01();
217 }

◆ RndmArray() [3/4]

void RndmArray ( Int_t  n,
UInt_t *  array 
)
inline

Fill an array of unsigned integers with random values in [0, UINT32_MAX], both limits included.

Parameters
nnumber of ints to generate
arraypointer to an array where the numbers should be stored

Definition at line 231 of file RandomGenerator.h.

232 {
233 //Fill the most part of the array using 64bit numbers
234 RndmArray(n / 2, (ULong64_t*)array);
235 //Only for uneven number of elements we need to fill the last one using a
236 //32bit number
237 if (n % 2) array[n - 1] = random32();
238 }
uint32_t random32()
Generate one 32bit unsigned integer between 0 and UINT32_MAX (both inclusive)
void RndmArray(Int_t n, Float_t *array)
Fill an array of floats with random values in (0,1), both limits excluded.

◆ RndmArray() [4/4]

void RndmArray ( Int_t  n,
ULong64_t *  array 
)
inline

Fill an array of unsigned 64bit integers with random values in [0, UINT64_MAX], both limits included.

Parameters
nnumber of ints to generate
arraypointer to an array where the numbers should be stored

Definition at line 225 of file RandomGenerator.h.

226 {
227 //Fill the array, no optimization whatsoever necessary
228 for (int i = 0; i < n; ++i) array[i] = random64();
229 }

◆ select()

void select ( const std::function< bool(const StoredClass *)> &  f)

This method is the actual worker.

It selects the elements, fill the subset and all the relations in which the subset is involved.

Parameters
fthe pointer to the function (or a nameless lambda expression) returning true for the elements to be selected and false for the others.

Definition at line 414 of file SelectSubset.h.

415 {
417
418 if (m_inheritToSelf) {
420 }
421
424 }
425 }
bool m_inheritToSelf
If true, relations from set objects to set objects are copied.
Definition: SelectSubset.h:58
void swapSetsAndDestroyOriginal()
Swap set and subset (+relations), and keep only the reduced set.
Definition: SelectSubset.cc:14
std::map< int, int > copySetWithRelations(std::function< bool(const StoredClass *)> f)
Selects the elements, fill the subset and copies all the relations in which the set is involved.
Definition: SelectSubset.h:351
void copyRelationsToSelf()
Copy any set -> set relations between selected objects.
Definition: SelectSubset.h:390

◆ send()

void send ( std::unique_ptr< zmq::socket_t > &  socket,
AZMQMessage  message 
)
static

Send a given message over the given created socket. You need to move in the message for zero-copy.

Definition at line 153 of file ZMQParent.h.

154 {
155 AZMQMessage::element_type::toSocket(std::move(message), socket);
156 }

◆ sendMessage()

bool sendMessage ( const LogMessage message)
overridevirtual

Sends a log message.

Parameters
messageThe log message object.
Returns
Returns true if the message could be send.

Implements LogConnectionBase.

Definition at line 23 of file LogConnectionJSON.cc.

24 {
25 if (!isConnected()) return false;
26 m_console.write(message.toJSON(m_complete));
27 return true;
28 }
void write(const std::string &message)
Send a preformatted string message to the connected output.
bool isConnected() override
Returns true if the connection to the text file could be established.

◆ sendToSocket()

void sendToSocket ( const AZMQClient &  socket)

Publish this event backup directly to the given client.

Definition at line 56 of file ProcessedEventBackup.h.

57 {
58 auto message = ZMQMessageFactory::createMessage(EMessageTypes::c_eventMessage, m_eventMessage);
59 socket.publish(std::move(message));
60 B2DEBUG(100, "sent backup evt: " << m_eventMetaData.getEvent());
61 }
unsigned int getEvent() const
Event Getter.
EventMetaData m_eventMetaData
Getter for the stored event meta data.
std::unique_ptr< EvtMessage > m_eventMessage
Stored event message.
static auto createMessage(const std::string &msgIdentity, const EMessageTypes msgType, const std::unique_ptr< EvtMessage > &eventMessage)
Create an ID Message out of an identity, the type and an event message.

◆ sendWorkerBackupEvents()

void sendWorkerBackupEvents ( unsigned int  worker,
const AZMQClient &  socket 
)

Send all backups of a given worker directly to the multicast and delete them.

Definition at line 51 of file ProcessedEventsBackupList.h.

52 {
53 for (auto it = m_evtBackupVector.begin(); it != m_evtBackupVector.end();) {
54 if (it->getWorkerId() == worker) {
55 B2DEBUG(100, "Delete event: " << it->getEventMetaData().getEvent());
56 it->sendToSocket(socket);
57 // TODO: better: delete backup on confirmation message
58 m_evtBackupVector.erase(it);
59 B2DEBUG(100, "new backup list size: " << m_evtBackupVector.size());
60 } else {
61 it++;
62 }
63 }
64 }
std::vector< ProcessedEventBackup > m_evtBackupVector
The vector where the event backups are stored.

◆ setBackends()

void setBackends ( const std::vector< std::string > &  backends)

Select the backends to use to find resources.

Parameters
backendslist of URIs identifying the backends starting with the handler prefix followed by a colon, the rest is handler specific

Definition at line 99 of file Gearbox.cc.

100 {
102 for (const string& backend : backends) {
103 B2DEBUG(300, "Adding InputHandler for '" << backend << "'");
104 //Find correct InputHandler, assuming file backend by default if there is no colon in the
105 //uri
106 string prefix("file");
107 string accessinfo(backend);
108 size_t colon = backend.find(':');
109 if (colon != string::npos) {
110 prefix = backend.substr(0, colon);
111 accessinfo = backend.substr(colon + 1);
112 }
113 auto it = m_registeredHandlers.find(prefix);
114 if (it == m_registeredHandlers.end()) {
115 B2ERROR("Could not find input handler to handle '" << backend << "', ignoring");
116 continue;
117 }
118 gearbox::InputHandler* handler = it->second(accessinfo);
119 if (handler) {
120 m_handlers.push_back(handler);
121 } else {
122 B2ERROR("Problem creating input handler to handle '" << backend << "', ignoring");
123 }
124 }
125 }
std::map< std::string, gearbox::InputHandler::Factory * > m_registeredHandlers
Map of registered InputHandlers.
Definition: Gearbox.h:220
void clearBackends()
Clear list of backends.
Definition: Gearbox.cc:127

◆ setBucket()

void setBucket ( unsigned  i)

Sets the fill status of RF bucket to true.

Parameters
ibucket number (modulo c_RFBuckets applied internally)

Definition at line 20 of file BunchStructure.cc.

21 {
22 if (m_fillPattern.empty()) m_fillPattern.resize(c_RFBuckets, false);
23
24 m_fillPattern[i % c_RFBuckets] = true;
25 m_filledBuckets.clear();
26 }

◆ setDefaultValue()

void setDefaultValue ( const T &  defaultValue)

Sets the default value of a parameter.

Parameters
defaultValueThe parameter default value of the parameter.

Definition at line 42 of file ModuleParam.templateDetails.h.

43 {
44 m_defaultValue = defaultValue;
45 m_paramVariable = defaultValue;
46 m_setInSteering = false;
47 }

◆ setMeanCov() [1/2]

bool setMeanCov ( const ROOT::Math::XYZVector &  mean,
const TMatrixTBase< value_type > &  cov 
)

set the mean and covariance for the distribution.

Parameters
meanVector of mean values
covMatrix containing the covariance values
Returns
true if covariance could be decomposited, false otherwise

Definition at line 190 of file MultivariateNormalGenerator.h.

192 {
193 TVectorT<value_type> tmean(3);
194 tmean[0] = mean.X();
195 tmean[1] = mean.Y();
196 tmean[2] = mean.Z();
197 return setMeanCov(tmean, cov);
198 }
bool setMeanCov(int n, const double *mean, const double *cov)
set the mean and covariance for the distribution with array interface: mean and covariance are passed...

◆ setMeanCov() [2/2]

bool setMeanCov ( const TVectorT< value_type > &  mean,
const TMatrixTBase< value_type > &  cov 
)

set mean and covariance matrix from ROOT vector/matrix objects, e.g.

TMatrixD, TMatrixF, TMatrixDSym and so forth

Parameters
meanVector of mean values
covMatrix containing the covariance values
Returns
true if covariance could be decomposited, false otherwise

Definition at line 176 of file MultivariateNormalGenerator.h.

178 {
179 Eigen::VectorXd emean(mean.GetNrows());
180 Eigen::MatrixXd ecov(cov.GetNrows(), cov.GetNcols());
181 for (int i = 0; i < mean.GetNrows(); ++i) { emean(i) = mean(i); }
182 for (int i = 0; i < cov.GetNrows(); ++i) {
183 for (int j = 0; j < cov.GetNcols(); ++j) {
184 ecov(i, j) = cov(i, j);
185 }
186 }
187 return setMeanCov(emean, ecov);
188 }

◆ setParameter()

void setParameter ( const std::string &  name,
const T &  value 
)

Sets the value of a parameter given by its name.

A template based method which is invoked by the module.

Parameters
nameThe unique name of the parameter.
valueThe parameter value which should be assigned to the parameter given by its name.

Definition at line 69 of file ModuleParamList.templateDetails.h.

70 {
71 try {
72 ModuleParam<T>& explModParam = getParameter<T>(name);
73 explModParam.setValue(value);
74 } catch (std::runtime_error& exc) {
75 B2ERROR(exc.what());
76 }
77 }

◆ setParamPython()

void setParamPython ( const std::string &  name,
const PythonObject &  pyObj 
)

Implements a method for setting boost::python objects.

The method supports the following types: dict, list, int, double, string, bool The conversion of the python object to the C++ type and the final storage of the parameter value is done by specialized converter in PyObjConvUtils.h

Parameters
nameThe unique name of the parameter.
pyObjThe object which should be converted and stored as the parameter value.

Definition at line 104 of file ModuleParamList.templateDetails.h.

105 {
106
108 p->setValueFromPythonObject(pyObj);
109 }

◆ setValue()

void setValue ( const T &  value)

Sets the value of a parameter.

Parameters
valueThe parameter value which should be assigned to the parameter.

Definition at line 35 of file ModuleParam.templateDetails.h.

36 {
37 m_paramVariable = value;
38 m_setInSteering = true;
39 }

◆ setValueFromParam()

void setValueFromParam ( const ModuleParamBase param)
finalvirtual

Set value from other ModuleParam of same type.

Implements ModuleParamBase.

Definition at line 76 of file ModuleParam.templateDetails.h.

77 {
78 const ModuleParam<T>* p = dynamic_cast<const ModuleParam<T>*>(&param);
79 if (p) {
80 m_defaultValue = p->m_defaultValue;
81 m_paramVariable = p->m_paramVariable;
82 m_setInSteering = p->m_setInSteering;
83 }
84 }

◆ setValueFromPythonObject()

void setValueFromPythonObject ( const boost::python::object &  pyObject)
finalvirtual

Implements a method for setting boost::python objects.

The method supports the following types: list, dict, int, double, string, bool The conversion of the python object to the C++ type and the final storage of the parameter value is done by PyObjConvUtils::convertPythonObject.

Parameters
pyObjectThe object which should be converted and stored as the parameter value.

Implements ModuleParamBase.

Definition at line 62 of file ModuleParam.templateDetails.h.

63 {
65 }
T & getDefaultValue()
Returns the default value of the parameter.
void setValue(const T &value)
Sets the value of a parameter.
Scalar convertPythonObject(const boost::python::object &pyObject, Scalar)
Convert from Python to given type.

◆ setValueToPythonObject()

void setValueToPythonObject ( boost::python::object &  pyObject,
bool  defaultValues = false 
) const
finalvirtual

Returns a python object containing the value or the default value of the given parameter.

Parameters
pyObjectReference to the python object which is set to the parameter value.
defaultValuesIf true returns default value otherwise parameter value.

Implements ModuleParamBase.

Definition at line 68 of file ModuleParam.templateDetails.h.

70 {
71 pyObject =
73 }
boost::python::object convertToPythonObject(const Scalar &value)
------------— From C++ TO Python Converter ---------------------—

◆ SetXYZ() [1/4]

void SetXYZ ( const ROOT::Math::XYZVector &  xyzVec)

set all coordinates using a reference to XYZVector

Definition at line 680 of file B2Vector3.h.

681 {
682 m_coordinates[0] = static_cast<Double_t>(xyzVec.X());
683 m_coordinates[1] = static_cast<Double_t>(xyzVec.Y());
684 m_coordinates[2] = static_cast<Double_t>(xyzVec.Z());
685 }

◆ SetXYZ() [2/4]

void SetXYZ ( const ROOT::Math::XYZVector *  xyzVec)

set all coordinates using a pointer to XYZVector

Definition at line 689 of file B2Vector3.h.

690 {
691 m_coordinates[0] = static_cast<Double_t>(xyzVec->X());
692 m_coordinates[1] = static_cast<Double_t>(xyzVec->Y());
693 m_coordinates[2] = static_cast<Double_t>(xyzVec->Z());
694 }

◆ SetXYZ() [3/4]

void SetXYZ ( const TVector3 &  tVec)

set all coordinates using a reference to TVector3

Definition at line 662 of file B2Vector3.h.

663 {
664 m_coordinates[0] = static_cast<Double_t>(tVec.X());
665 m_coordinates[1] = static_cast<Double_t>(tVec.Y());
666 m_coordinates[2] = static_cast<Double_t>(tVec.Z());
667 }

◆ SetXYZ() [4/4]

void SetXYZ ( const TVector3 *  tVec)

set all coordinates using a pointer to TVector3

Definition at line 671 of file B2Vector3.h.

672 {
673 m_coordinates[0] = static_cast<Double_t>(tVec->X());
674 m_coordinates[1] = static_cast<Double_t>(tVec->Y());
675 m_coordinates[2] = static_cast<Double_t>(tVec->Z());
676 }

◆ splitOnDelimiterAndConserveParenthesis()

std::vector< std::string > splitOnDelimiterAndConserveParenthesis ( std::string  str,
char  delimiter,
char  open,
char  close 
)

Split into std::vector on delimiter ignoring delimiters between parenthesis.

Definition at line 81 of file CutHelpers.cc.

82 {
83
84 std::vector<std::string> result;
85 unsigned int lastdelimiter = 0;
86 for (unsigned int i = 0; i < str.size(); ++i) {
87 if (str[i] == open) {
88 i += findMatchedParenthesis(str.substr(i), open, close);
89 continue;
90 }
91 if (str[i] == delimiter) {
92 result.push_back(str.substr(lastdelimiter, i - lastdelimiter));
93 lastdelimiter = i + 1;
94 }
95 }
96 std::string last = str.substr(lastdelimiter);
97 if (last.size() != 0) {
98 result.push_back(last);
99 }
100 return result;
101 }

◆ storeData() [1/2]

bool storeData ( const std::string &  name,
TObject *  object,
const IntervalOfValidity iov 
)

Store an object in the database.

Parameters
nameName that identifies the object in the database.
objectThe object that should be stored in the database.
iovThe interval of validity of the the object.
Returns
True if the storage of the object succeeded.

Definition at line 141 of file Database.cc.

142 {
144 auto result = m_payloadCreation->storeData(name, obj, iov);
145 // we added payloads, make sure we reread testing files on next try
146 if (result) {
147 for (auto& testing : m_testingPayloads) {
148 testing.reset();
149 }
150 }
151 return result;
152 }

◆ storeData() [2/2]

bool storeData ( std::list< DBImportQuery > &  query)

Store multiple objects in the database.

Parameters
queryA list of DBImportQuery entries that contains the objects, their names, and their intervals of validity.
Returns
True if the storage of the object succeeded.

Definition at line 134 of file Database.cc.

135 {
136 return std::all_of(query.begin(), query.end(), [this](const auto & import) {
137 return storeData(import.name, import.object, import.iov);
138 });
139 }

◆ timeit()

void timeit ( const std::string &  key)

Measure the rate of calls with the same key every AVERAGE_SIZE calls (and also display the last time AVERAGE_SIZE was reached under <key>_last_measurement)

Definition at line 117 of file ZMQLogger.h.

118 {
119 auto& [calls, timestamp] = m_timeCounters[key];
120 if (calls % AVERAGE_SIZE == 0) {
121 auto current = std::chrono::high_resolution_clock::now();
122 double elapsed = std::chrono::duration_cast<std::chrono::duration<double>>(
123 current - timestamp).count();
124
125 log(key, AVERAGE_SIZE / elapsed);
126
127 timestamp = current;
128 calls = 0;
129
130 auto displayTime = std::chrono::system_clock::to_time_t(current);
131 log(key + "_last_measurement", std::ctime(&displayTime));
132 }
133 calls++;
134 }
std::unordered_map< std::string, std::tuple< unsigned long, std::chrono::system_clock::time_point > > m_timeCounters
Internal storage how often the timeit function for a given key was called and when it has last reache...
Definition: ZMQLogger.h:62

◆ TypeInfo()

std::string TypeInfo
static

Static function to generate a string description for the parameter type.

This string will be used to identify the contained type and guaranties some level of type safety in this type erasure.

Definition at line 22 of file ModuleParam.templateDetails.h.

23 {
25 }
static std::string name()
type name.

◆ update() [1/2]

void update ( )

Updates all objects that are outside their interval of validity.

This method is called by the framework for each new run.

Definition at line 79 of file DBStore.cc.

80 {
81 if (m_dbEntries.empty()) {
82 // make sure we at least fix the list of globaltags on the first time
84 return;
85 }
86
87 // Make sure our EventMetaData pointer is reconnected as it could get
88 // disconnected if the DataStore is reset.
89 // TODO: This can be removed once BII-1262 is fixed.
90 StoreObjPtr<EventMetaData> event;
91 m_storeEvent = event;
92 // Clear the m_manualEvent to indicate that we now want to use the DataStore event numbers
93 m_manualEvent = std::nullopt;
95 }
void performUpdate(const EventMetaData &event)
The main code that does an update, factored out so it can be used by both update and update(event).
Definition: DBStore.cc:108

◆ update() [2/2]

void update ( const EventMetaData event)

Updates all objects that are outside their interval of validity.

This method is for calling the DBStore manually using an EventMetaData object instead of relying on the DataStore containing one.

Definition at line 97 of file DBStore.cc.

98 {
99 if (m_dbEntries.empty()) {
100 // make sure we at least fix the list of globaltags on the first time
102 return;
103 }
104 m_manualEvent = event;
106 }

◆ updateEvent() [1/2]

void updateEvent ( )

Updates all intra-run dependent objects.

This method is called by the framework for each event.

Definition at line 142 of file DBStore.cc.

143 {
144 if (!m_manualEvent) {
146 } else {
147 B2WARNING("DBStore is currently using manual event information. But you are asking for the DataStore's EventMetaData "
148 "to be used to update the Intra-run dependencies. Update could not proceed. "
149 "Did you forget to call DBStore::Instance().update() before calling this function?");
150 }
151 }
void performUpdateEvent(const EventMetaData &event)
The main code that does an updateEvent.
Definition: DBStore.cc:169

◆ updateEvent() [2/2]

void updateEvent ( const unsigned int  eventNumber)

Updates all intra-run dependent objects.

This method is for specifying the event number to update to manually. Updates the m_manualEvent to use the event number given in the argument, before performing the intra-run update. This doesn't alter/use the DataStore EventMetaData.

Definition at line 153 of file DBStore.cc.

154 {
155 // As m_manualEvent doesn't use the DataStore, it isn't automatically updated and we must manually update the event
156 // number prior to updating the intra-run objects.
157 // This also updates it ready for getData if a DBObject gets constructed later.
158 if (m_manualEvent) {
159 m_manualEvent->setEvent(eventNumber);
161 } else {
162 B2WARNING("DBStore is not currently using manual event information. But you are asking for the event number to be set "
163 " to a custom value. Update of the Intra-run dependencies could not proceed. "
164 "Did you forget to call DBStore::Instance().update(event), or accidentally call DBStore::Instance().update() "
165 "prior to to this?");
166 }
167 }

◆ updateObject()

void updateObject ( const EventMetaData event)
private

update the payload object according to the new event information.

If the payload has no intra run dependency this does nothing, otherwise it will load the appropirate object for the given event and call the update notifications on changes to the object.

Definition at line 55 of file DBStoreEntry.cc.

56 {
57 // if we don't have intra run dependency we don't care about event number
58 if (!m_intraRunDependency) return;
59 // otherwise update the object and call notify all accessors on change
60 TObject* old = m_object;
62 if (old != m_object) {
63 B2DEBUG(35, "IntraRunDependency for " << m_name << ": new object (" << old << ", " << m_object << "), notifying accessors");
65 }
66 }

◆ updatePayload()

void updatePayload ( unsigned int  revision,
const IntervalOfValidity iov,
const std::string &  filename,
const std::string &  checksum,
const std::string &  globaltag,
const EventMetaData event 
)
private

Update the payload information for this entry and if appropriate open the new file and extract the object as needed.

If another version is already loaded the object will be deleted and the file closed.

If neither revision or filename change we assume the payload is not modified and will not update anything and not call any update notifications.

Parameters
revisionnew revision of the payload
iovnew interval of validity for the payload
filenamefilename for the payload
checksumchecksum of the payload
globaltagglobaltag name (or testing payloads path) from which the payload is picked
eventEventMetaData object

Definition at line 83 of file DBStoreEntry.cc.

85 {
86 m_iov = iov;
87 m_globaltag = globaltag;
88 // File is the same as before, no need to update anything else. We could
89 // check all identifiers like revision, filename and checksum
90 // > if (revision == m_revision && filename == m_filename && m_checksum == checksum) return;
91 // but this is a bit strict as we know we have some payloads with the same
92 // checksum but multiple revisions and there's no need to actually update
93 // the object. But at least lets make sure the revision number is reported the same as in the db
94 m_revision = revision;
95 if (m_checksum == checksum) return;
96 m_keep = false;
97 m_checksum = checksum;
98 m_filename = filename;
99 // If the old object was intra run dependent then m_object is owned by the
100 // intra run dependency object. So set the pointer to null to not delete the object.
101 if (m_intraRunDependency) m_object = nullptr;
102 // and delete the old intra run dependency if it exists
103 deleteAndSetNullptr(m_object, m_intraRunDependency, m_tfile);
104 loadPayload(event);
105 B2DEBUG(30, "DBEntry changed"
106 << LogVar("name", m_name)
107 << LogVar("globaltag", m_globaltag)
108 << LogVar("revision", m_revision)
109 << LogVar("checksum", m_checksum)
110 << LogVar("filename", m_filename)
111 << LogVar("validity", m_iov));
113 }
void loadPayload(const EventMetaData &event)
Actual load the payload from file after all info is set.

◆ ~DBStore()

~DBStore ( )

Destructor.

Definition at line 23 of file DBStore.cc.

24 {
25 reset();
26 }

◆ ~DBStoreEntry()

Clean up memory.

Some of the members are raw pointers to limit the include burden on this class as it will be included by anyone using Conditions data

Definition at line 45 of file DBStoreEntry.cc.

46 {
47 // if intra run dependency: object owned by the IntraRunDependency object so don't delete the object itself.
48 if (m_intraRunDependency) m_object = nullptr;
49 // and free all memory
50 deleteAndSetNullptr(m_object, m_intraRunDependency, m_tfile);
51 if (!m_accessors.empty()) B2DEBUG(38, "DBEntry " << m_name << " destroyed, notifying accessors");
52 notifyAccessors(true);
53 }

◆ ~Gearbox()

~Gearbox ( )

Free structures on destruction.

Definition at line 74 of file Gearbox.cc.

75 {
76 close();
78 delete m_parameterCache;
79 }

Variable Documentation

◆ DBPointer_defaultName

std::string DBPointer_defaultName = ""

Use default name for array in DBPointer.

Definition at line 19 of file DBPointer.h.

◆ s_conversionFactors

map< string, double > s_conversionFactors
staticprotected

Map to be able to convert between units using string representations of the unit name.

Definition at line 163 of file Unit.h.

◆ XYZToTVector

constexpr auto XYZToTVector
staticconstexpr
Initial value:
= [](const ROOT::Math::XYZVector& a)
{
return TVector3(a.X(), a.Y(), a.Z());
}

Helper function to convert XYZVector to TVector3.

Definition at line 24 of file VectorUtil.h.