EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairParSet.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairParSet.cxx
1 //*-- AUTHOR : Ilse Koenig
2 //*-- Created : 20/10/2004
3 
5 // FairParSet
6 //
7 // Base class for all parameter containers
9 
10 #include "FairParSet.h"
11 
12 #include "FairRuntimeDb.h"
13 
14 #include <iostream>
15 
16 using std::cout;
17 
19 
20 FairParSet::FairParSet(const char* name,const char* title,const char* context)
21  : TNamed(name,title),
22  detName(""),
23  status(kFALSE),
24  changed(kFALSE),
25  paramContext(context),
26  author(""),
27  description(""),
28  fLogger(FairLogger::GetLogger())
29 {
30  for(Int_t i=0; i<3; i++) {versions[i]=-1;}
31 }
32 
34 {
35  // intitializes the container from an input in run time
36  // database. If this is not successful it is initialized from
37  // the second input. If this failes too, it returns an error.
38  // (calls internally the init function in the derived class)
40  //FairRunAna* fRun =FairRunAna::Instance();
41 // cout << "-I- FairParSet::init() " << GetName() << endl;
42 
43  Bool_t allFound=kFALSE;
44  FairParIo* io=0;
45  if (rtdb) {
46  io=rtdb->getFirstInput();
47  if (io) { allFound=init(io); }
48  if (!allFound) {
49  io=rtdb->getSecondInput();
50  //cout << "-I FairParSet::init() 2 " << io << std::endl;
51  if (io) { allFound=init(io); }
52  } else { setInputVersion(-1,2); }
53  }
54  if (allFound) { return kTRUE; }
55  fLogger->Error(MESSAGE_ORIGIN, "init() %s not initialized",GetName());
56  return kFALSE;
57 }
58 
60 {
61  // writes the container to the output defined in the runtime database
62  // returns the output version in the ROOT file
63  // returns -1 if error occured
64  // (calls internally the init function in the derived class)
66  if (output) { return write(output); }
67  fLogger->Error(MESSAGE_ORIGIN,"write() %s could not be written to output",GetName());
68  return -1;
69 }
70 
72 {
73  // prints information about container (versions,status,hasChanged...)
74  cout<<"----- "<<GetName()<<" -----"<<'\n';
75  if (!paramContext.IsNull()) { cout<<"Context/Purpose: "<<paramContext<<'\n'; }
76  if (!author.IsNull()) { cout<<"Author: "<<author<<'\n'; }
77  if (!description.IsNull()) { cout<<"Description: "<<description<<'\n'; }
78  cout<<"first input version: "<<versions[1]<<'\n';
79  cout<<"second input version: "<<versions[2]<<'\n';
80  if (changed) { cout<<"has changed"<<'\n'; }
81  else { cout<<"has not changed"<<'\n'; }
82  if (status) { cout<<"is static"<<'\n'; }
83  else { cout<<"is not static"<<'\n'; }
84 }
85 
87 {
88  // resets the input versions if the container is not static
89  if (!status) {
90  for(Int_t i=0; i<3; i++) {versions[i]=-1;}
91  changed=kFALSE;
92  }
93 }