HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hrun.cc
Go to the documentation of this file.
1 //*-- AUTHOR : Ilse Koenig
2 //*-- Modified : 03/02/2000 by Ilse Koenig
3 
4 //_HADES_CLASS_DESCRIPTION
5 ///////////////////////////////////////////////////////////////////
6 // HRun
7 //
8 // class for the parameter versions of an event file
9 //
10 // The name of each run is the run id converted to a string.
11 // The run id number identifies the event file. Each event has
12 // this number in the event header. It is also stored in Oracle
13 // and can be used to find the name of the corresponding LMD-file
14 // and the valid parameter versions.
15 // In the parameter ROOT file the valid parameter versions are
16 // accessible via the name.
17 // Associated with the run is a list of container
18 // names with the versions of the containers in the two
19 // possible inputs and the output (class HParVersions).
20 // The input versions are used during the initialisation
21 // used during the initialisation of the containers.
22 //
23 ///////////////////////////////////////////////////////////////////
24 
25 #include "hrun.h"
26 #include "hades.h"
27 #include "hmessagemgr.h"
28 
31 
32 HParVersion::HParVersion(const Text_t* name) : TNamed(name,"version info"){
33  // constructor with the name of the container
34  rootVersion=0;
35  for(Int_t i=0;i<3;i++) {inputVersions[i]=-1;}
36 }
37 
38 
39 HRun::HRun(const Text_t* name,const Text_t* refName)
40  : TNamed(name,"run parameters") {
41  // constructor with the run id and reference run as strings
42  parVersions=new TList();
43  refRun=refName;
44 }
45 
46 HRun::HRun(Int_t r,Int_t rr) {
47  // constructor with the run id and reference run as numbers
48  parVersions=new TList();
49  Char_t name[255];
50  sprintf(name,"%i",r);
51  SetName(name);
52  setRefRun(rr);
53 }
54 
55 HRun::HRun(HRun &run):TNamed(run) {
56  // copy constructor
57  SetName(run.GetName());
58  parVersions=new TList();
59  TList* lv=run.getParVersions();
60  TIter next(lv);
61  HParVersion* pv;
62  while ((pv=(HParVersion*)next())) {
63  parVersions->Add(pv);
64  }
65  refRun=run.refRun;
66 }
67 
69  // destructor
70  if (parVersions) {
71  parVersions->Delete();
72  delete parVersions;
73  parVersions=0;
74  }
75 }
76 
78  // adds a container version object to the list
79  parVersions->Add(pv);
80 }
81 
82 HParVersion* HRun::getParVersion(const Text_t* name) {
83  // return a container version object called by the name of
84  // the container
85  return (HParVersion*)parVersions->FindObject(name);
86 }
87 
89  TIter next(parVersions);
90  HParVersion* v;
91  while ((v=(HParVersion*)next())) {
92  v->resetInputVersions();
93  }
94 }
95 
97  TIter next(parVersions);
98  HParVersion* v;
99  while ((v=(HParVersion*)next())) {
100  v->setRootVersion(0);
101  }
102 }
103 
104 void HRun::print() {
105  // prints the list of container versions for this run
106 
107  //cout<<"run: "<<fName<<'\n';
108  gHades->getMsg()->info(10,HMessageMgr::DET_RUNTIMEDB,this->GetName(),"run: %d",getRunId());
109  TIter next(parVersions);
110  HParVersion* v;
111  while ((v=(HParVersion*)next())) {
112  gHades->getMsg()->info(10,HMessageMgr::DET_RUNTIMEDB,this->GetName(),"%-22s%10d%11d%9d", v->GetName(),v->getInputVersion(1),v->getInputVersion(2), v->getRootVersion());
113  }
114 }
115 
116 void HRun::write(fstream& fout) {
117  // writes the list of container versions for this run to fstream
118  fout<<"run: "<<GetName()<<'\n';
119  HParVersion* v;
120  TIter next(parVersions);
121  while ((v=(HParVersion*)next())) {
122  fout.setf(ios::left,ios::adjustfield);
123  fout<<" "<<setw(45)<<v->GetName();
124  fout.setf(ios::right,ios::adjustfield);
125  fout<<setw(11)<<v->getInputVersion(1)
126  <<setw(11)<<v->getInputVersion(2)
127  <<setw(11)<<v->getRootVersion()<<'\n';
128  }
129 }
Int_t getInputVersion(Int_t i)
Definition: hrun.h:22
~HRun()
Definition: hrun.cc:68
void resetInputVersions()
Definition: hrun.cc:88
Int_t getRunId(void)
Definition: hrun.h:61
ClassImp(HParVersion) ClassImp(HRun) HParVersion
Definition: hrun.cc:29
void resetInputVersions()
Definition: hrun.h:26
HRun()
name of the reference run for initialization
Definition: hrun.h:39
HParVersion * getParVersion(const Text_t *name)
Definition: hrun.cc:82
TList * getParVersions()
Definition: hrun.h:47
void info(Char_t level, Int_t det, const Char_t *className, const Char_t *text)
Definition: hmessagemgr.cc:473
Definition: hrun.h:34
Int_t getRootVersion()
Definition: hrun.h:30
Hades * gHades
Definition: hades.cc:1213
void resetOutputVersions()
Definition: hrun.cc:96
void print()
Definition: hrun.cc:104
void setRefRun(const Text_t *s)
Definition: hrun.h:49
TList * parVersions
Definition: hrun.h:36
void setRootVersion(Int_t v)
Definition: hrun.h:29
TString refRun
Definition: hrun.h:37
void write(fstream &)
Definition: hrun.cc:116
void addParVersion(HParVersion *pv)
Definition: hrun.cc:77
HMessageMgr * getMsg(void)
Definition: hades.h:113