EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairRtdbRun.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairRtdbRun.cxx
1 //*-- AUTHOR : Ilse Koenig
2 //*-- Created : 20/10/2004
3 
5 // FairRun
6 //
7 // class for the parameter versions of an event file
8 //
9 // The name of each run is the run id converted to a string.
10 // The run id number identifies the event file.
11 // In the parameter ROOT file the valid parameter versions are
12 // accessible via the name.
13 // Associated with the run is a list of container
14 // names with the versions of the containers in the two
15 // possible inputs and the output (class FairParVersions).
16 // The input versions are used during the initialisation
17 // used during the initialisation of the containers.
19 
20 #include "FairRtdbRun.h"
21 
22 #include <iostream>
23 #include <iomanip>
24 
25 using std::cout;
26 using std::ios;
27 using std::setw;
28 
31 
33  :TNamed(name,"version info"),
34  rootVersion(0)
35 {
36  // constructor with the name of the container
37  // rootVersion=0;
38  for(Int_t i=0; i<3; i++) {inputVersions[i]=-1;}
39 }
40 
41 FairRtdbRun::FairRtdbRun(const Text_t* name,const Text_t* refName)
42  : TNamed(name,"run parameters"),
43  parVersions(new TList()),
44  refRun(refName)
45 {
46  // constructor with the run id and reference run as strings
47  // parVersions=new TList();
48  // refRun=refName;
49 }
50 
52 // :TNamed(r,""),
53  :TNamed(),
54  parVersions(new TList()),
55  refRun("")
56 {
57  char name[255];
58  sprintf(name,"%i",r);
59  SetName(name);
60  setRefRun(rr);
61 }
62 
64  :TNamed(run),
65  parVersions(new TList()),
66  refRun(run.refRun)
67 {
68  // copy constructor
69  TList* lv=run.getParVersions();
70  TIter next(lv);
71  FairParVersion* pv;
72  while ((pv=(FairParVersion*)next())) {
73  parVersions->Add(pv);
74  }
75 }
76 
78  :TNamed(),
79  parVersions(NULL),
80  refRun("")
81 {
82  // default Constructor
83  // parVersions has to be set to zero otherwise the
84  // root file is not browsable
85 }
86 
88 {
89  // destructor
90  if (parVersions) {
91  parVersions->Delete();
92  delete parVersions;
93  parVersions=0;
94  }
95 }
96 
98 {
99  // adds a container version object to the list
100  parVersions->Add(pv);
101 }
102 
104 {
105  // return a container version object called by the name of
106  // the container
107  return (FairParVersion*)parVersions->FindObject(name);
108 }
109 
111 {
112  TIter next(parVersions);
113  FairParVersion* v;
114  while ((v=(FairParVersion*)next())) {
115  v->resetInputVersions();
116  }
117 }
118 
120 {
121  TIter next(parVersions);
122  FairParVersion* v;
123  while ((v=(FairParVersion*)next())) {
124  v->setRootVersion(0);
125  }
126 }
127 
129 {
130  // prints the list of container versions for this run
131  cout<<"run: "<<GetName()<<'\n';
132  FairParVersion* v;
133  TIter next(parVersions);
134  while ((v=(FairParVersion*)next())) {
135  cout.setf(ios::left,ios::adjustfield);
136  cout<<" "<<setw(45)<<v->GetName();
137  cout.setf(ios::right,ios::adjustfield);
138  cout<<setw(11)<<v->getInputVersion(1)
139  <<setw(11)<<v->getInputVersion(2)
140  <<setw(11)<<v->getRootVersion()<<'\n';
141  }
142 }
143 
144 void FairRtdbRun::write(std::fstream& fout)
145 {
146  // writes the list of container versions for this run to fstream
147  fout<<"run: "<<GetName()<<'\n';
148  FairParVersion* v;
149  TIter next(parVersions);
150  while ((v=(FairParVersion*)next())) {
151  fout.setf(ios::left,ios::adjustfield);
152  fout<<" "<<setw(45)<<v->GetName();
153  fout.setf(ios::right,ios::adjustfield);
154  fout<<setw(11)<<v->getInputVersion(1)
155  <<setw(11)<<v->getInputVersion(2)
156  <<setw(11)<<v->getRootVersion()<<'\n';
157  }
158 }