The Parameter classes contain and manage all the numerical information needed to process the data (parameter). In order to analyse the simulated data, several numerical parameters are needed, as for example, calibration/digitization parameters or geometry positions of detectors. One common characteristic to most of these parameters is that they will go through several different versions corresponding, for example, to changes in the detectors definition or any other condition. This makes necessary to have a parameter repository with a well-defined versioning system. The runtime database (realized through the FairRuntimeDb class) is such a repository. Different inputs are supported : ASCII format , ROOT binary format and Oracle Database input.

  • Parameters are connected to a runId
  • FairBaseParSet: used to store relevant info from a simulation, reconstruction or analysis run:
  • FairDetGeoPar geometry parameters
    Stored for each detectors in FairDetector::ConstructGeometry()
  • Runtime database

    The runtime database is not a database in the classical sense. Instead, it is a parameter manager. It knows the I/Os defined by the user in the macro and all parameter containers needed for the actual analysis. It manages the automatic initialization and saving to an output and contains, after all initialization and saving is done, a complete list of runs and related parameter input and output versions.
    It is represented by the class FairRuntimeDb and instantiated in the macro.
    It holds two lists: the list of parameter containers, and the list of runs and related parameter versions. The containers can be initialized automatically from one or two inputs, and written out to one output. Possible inputs/output are

    • ROOT file
    • ascii file
    • Data Base (under construction)

    If a container can not or only partly be initialized from the first input, the missing information is taken automatically from the second input. Any combination of inputs is possible. In case of a ROOT file, the first input and the output might be identical.

    Parameter containers

    The parameters are stored in parameter containers which are accessible in the runtime database via their names. To avoid unnecessary initialization and storage, the design of these containers should consider the following aspects:

    • The containers should not hold parameters which are fixed, together with parameters which change very often (maybe from run to run).
    • Parameters needed by several tasks should be stored separately from the parameters used only by one task.
    • To guarantee data consistency, the reading of redundant information into two different containers is not allowed. Only one container should be initialized via reading, the other one (or the redundant part) by copying. (Otherwise only Data Base would guarantee data consistency.)

    All container classes are derived from a common base class FairParSet.They are instantiated in the program in the SetParTask() functions of the tasks (not in the constructors!) and added to the list of containers in the runtime database. However, it is also possible to create a container explicitely in a macro, to initialize it and to add it to the list. This feature can be used, when a container should be initialized from a special input and not automatically from one of the inputs defined in the runtime database.
    Parameters used privately in a task and calculated completely from other parameters should not be added to the list of parameter containers in the runtime database. Instead, their init() function should be called explicitly in the reinit() function of the task (called automatically after the initialization of all containers for each run).
    Each container has overloaded init() and write() functions for the parameter I/O, functions to support the version management, to clear the data and to print information.

    Parameter containers class implimentation example


    #include "FairContFact.h"
    class FairContainer;
    class FairTutorialDetContFact : public FairContFact
        void setAllContainers();
        ~FairTutorialDetContFact() {}
        FairParSet* createContainer(FairContainer*);
        ClassDef( FairTutorialDetContFact,0) // Factory for all MyDet parameter containers


    #include "FairTutorialDetContFact.h"
    #include "FairTutorialDetGeoPar.h"
    #include "FairRuntimeDb.h"
    #include <iostream>
    static FairTutorialDetContFact gFairTutorialDetContFact;
      /** Constructor (called when the library is loaded) */
      fTitle="Factory for parameter containers in libTutorial1";
    void FairTutorialDetContFact::setAllContainers()
      /** Creates the Container objects with all accepted
          contexts and adds them to
          the list of containers for the Tutorial1 library.
      FairContainer* p= new FairContainer("FairTutorialDetGeoPar",
                                          "FairTutorialDet Geometry Parameters",
    FairParSet* FairTutorialDetContFact::createContainer(FairContainer* c)
      /** Calls the constructor of the corresponding parameter container.
          For an actual context, which is not an empty string and not
          the default context
          of this container, the name is concatinated with the context.
      const char* name=c->GetName();
      FairParSet* p=NULL;
      if (strcmp(name,"FairTutorialDetGeoPar")==0) {
        p=new FairTutorialDetGeoPar(c->getConcatName().Data(),
      return p;

    Parameter class example


    // -------------------------------------------------------------------------
    // -----              FairTutorialDetDigiPar header file                  -----
    // -----                 Created 15/05/08  by F. Uhlig                 -----
    // -------------------------------------------------------------------------
    #include "FairParGenericSet.h"
    #include "TObject.h"
    #include "TObjArray.h"
    #include "TArrayF.h"
    #include "TArrayI.h"
    class FairParIo;
    class FairParamList;
    class FairTutorialDetDigiPar : public FairParGenericSet
        /** Standard constructor **/
        FairTutorialDetDigiPar(const char* name    = "FairTutorialDetDigiPar",
                               const char* title   = "Tutorial Det digi parameters",
                               const char* context = "Default");
        /** Destructor **/
        virtual ~FairTutorialDetDigiPar();
        /** Initialisation from input device**/
        //virtual Bool_t init(FairParIo* input);
        /** Output to file **/
        //  virtual Int_t write(FairParIo* output);
        //  virtual void print();
        virtual void printparams();
        /** Reset all parameters **/
        virtual void clear();
        void putParams(FairParamList*);
        Bool_t getParams(FairParamList*);
        TArrayF* ftutdetdigipar;  //
        TArrayI ftutdetdigiparsector; //
        Int_t ftutdetdigiparstation; //
        FairTutorialDetDigiPar(const FairTutorialDetDigiPar&);
        FairTutorialDetDigiPar& operator=(const FairTutorialDetDigiPar&);


    // -------------------------------------------------------------------------
    // -----                FairTutorialDetDigiPar source file              -----
    // -----                  Created 05/06/08  by F. Uhlig                -----
    // -------------------------------------------------------------------------
    #include "FairTutorialDetDigiPar.h"
    #include "FairParamList.h"
    #include "FairDetParIo.h"
    #include "FairParIo.h"
    #include "TString.h"
    #include "TMath.h"
    #include <iostream>
    using std::cout;
    using std::endl;
    // -----   Standard constructor   ------------------------------------------
    FairTutorialDetDigiPar::FairTutorialDetDigiPar(const char* name,
        const char* title,
        const char* context)
      : FairParGenericSet(name, title, context)
      ftutdetdigipar= new TArrayF(10);
      //ftutdetdigipar= new TArrayF(10);
    // -------------------------------------------------------------------------
    // -----   Destructor   ----------------------------------------------------
    // -------------------------------------------------------------------------
    // -----   Public method clear   -------------------------------------------
    void FairTutorialDetDigiPar::clear()
      status = kFALSE;
    // -------------------------------------------------------------------------
    // -----   Public method printParams ---------------------------------------
    void FairTutorialDetDigiPar::printparams()
      cout <<"Print"<<endl;
      cout << "ftutdetdigiparstation: " << ftutdetdigiparstation << endl;
      Int_t size =  ftutdetdigiparsector.GetSize();
      cout <<"size: " << size << endl;
      for ( Int_t i=0; i< size; i++) {
        cout << i <<" :" << ftutdetdigiparsector.GetAt(i) << endl;
      size =  ftutdetdigipar->GetSize();
      cout <<"size: " << size << endl;
      for ( Int_t i=0; i< size; i++) {
        cout << i <<" :" << ftutdetdigipar->GetAt(i) << endl;
    // -------------------------------------------------------------------------
    void FairTutorialDetDigiPar::putParams(FairParamList* l)
      //   print();
      cout << " I am in FairTutorialDetDigiPar::putParams " << endl;
      if (!l) { return; }
      l->add("FairTutorialDetDigiStations", ftutdetdigiparstation);
      l->add("FairTutorialDetDigiSectorsPerStation", ftutdetdigiparsector);
      Int_t count_sectors = 0;
      for ( Int_t i=0; i< ftutdetdigiparstation; i++) {
      Int_t array_size = (count_sectors * 10 + ftutdetdigiparstation * 3);
      cout << "Array Size: " << array_size << endl;
      /*   Float_t zwischen[array_size];
         for ( Int_t i=0; i< array_size; i++) {
           zwischen[i] = ftutdetdigipar.GetAt(i);
    Bool_t FairTutorialDetDigiPar::getParams(FairParamList* l)
      cout << " I am in FairTutorialDetDigiPar::getParams " << endl;
      if (!l) { return kFALSE; }
      if ( ! l->fill("FairTutorialDetDigiStations", &ftutdetdigiparstation) ) { return kFALSE; }
      if ( ! l->fill("FairTutorialDetDigiSectorsPerStation", &ftutdetdigiparsector) ) { return kFALSE; }
      Int_t count_sectors = 0;
      for ( Int_t i=0; i< ftutdetdigiparstation; i++) {
      cout << "Total number of sectors: " << count_sectors<<endl;
      Int_t array_size = (count_sectors * 10 + ftutdetdigiparstation * 3);
      cout << "Array Size: " << array_size << endl;
      //Float_t zwischen[array_size];
      if (!(l->fill("FairTutorialDetDigiPar",ftutdetdigipar))) {
        cout << "--W-- Could not initialize FairTutorialDetDigiPar"<< endl;
        return kFALSE;
      //ftutdetdigipar.Set(array_size, zwischen);
      return kTRUE;

    Reading Parameters using ROOT/ASCII files

    In the run macro, when initializing one has to add:

    FairRuntimeDb* rtdb=fRun->GetRuntimeDb();
    FairParRootFileIo* input=new FairParRootFileIo();

    create ASCII IO and open it:

    FairParAsciiFileIo* inputAscii = new FairParAsciiFileIo();

    create ROOT IO and open it:

    FairParRootFileIo* inputRoot=new FairParRootFileIo();

    set the different input to the runtime database


    setting the parameters in this order means, if a parameter was found in the first input (in this case ASCII) then it will be initialized from there, and even if it exist in the second input it will not be read again.

    Writting Parameters

    Writting Parameters to Root files:

    FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
    Bool_t kParameterMerged = kTRUE;
    FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged);

    Version management in the ROOT file

    In the ROOT file parameter containers are stored as objects. Every time an object is written it gets automatically a new version incrementing the former version by 1, starting with 1 in each newly created file. By default the Read() or Find() functions provided by ROOT read the object with the highest version. A retrieval of another version is possible by adding ";version number" to the name of the parameter container. The information 'which run corresponds to which version' of each parameter container must be stored in the ROOT file together with the data.