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