KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVINDRADB_e416a.cpp
Go to the documentation of this file.
1 /*
2 $Id: KVINDRADB_e416a.cpp,v 1.2 2007/02/14 14:12:31 franklan Exp $
3 $Revision: 1.2 $
4 $Date: 2007/02/14 14:12:31 $
5 */
6 
7 //Created by KVClassFactory on Tue Feb 13 19:00:55 2007
8 //Author: franklan
9 
10 #include "KVINDRADB_e416a.h"
11 #include "KVDB_BIC_Pressures.h"
12 
13 using namespace std;
14 
16 
17 
18 
19 
23 {
24  //Default constructor
25  fBICPressures = AddTable("BIC Pressures", "Pressures of BIC");
26 }
27 
28 
29 
30 
33 
35 {
36  //Destructor
37 }
38 
39 
40 
41 
43 
45 {
47  ReadBICPressures();
48 }
49 
50 
51 
52 
65 
67 {
68  //Read BIC pressures for different run ranges and enter into database.
69  //Format of file is:
70  //
71  //# some comments
72  //#which start with '#'
73 // Run Range : 289 385
74 // BIC_1 30.0
75 // BIC_2 30.0
76 // BIC_3 30.0
77  //
78  //Pressures (of CF4) are given in Torr.
79 
80  ifstream fin;
81  if (!OpenCalibFile("BICPressures", fin)) {
82  Error("ReadBICPressures()", "Could not open file %s",
83  GetCalibFileName("BICPressures"));
84  return;
85  }
86  Info("ReadBICPressures()", "Reading BIC pressures parameters...");
87 
88  TString sline;
89  UInt_t frun = 0, lrun = 0;
90  UInt_t run_ranges[MAX_NUM_RUN_RANGES][2];
91  UInt_t rr_number = 0;
92  Bool_t prev_rr = kFALSE; //was the previous line a run range indication ?
93  Bool_t read_pressure = kFALSE; // have we read any pressures recently ?
94 
95  KVDB_BIC_Pressures* parset = 0;
96  TList* par_list = new TList();
97 
98  //any ChIo not in list is assumed absent (pressure = 0)
99  Float_t pressure[3] = { 0, 0, 0 };
100 
101  while (fin.good()) { // parcours du fichier
102 
103  sline.ReadLine(fin);
104  if (sline.BeginsWith("Run Range :")) { // run range found
105  if (!prev_rr) { // New set of run ranges to read
106 
107  //have we just finished reading some pressures ?
108  if (read_pressure) {
109  parset = new KVDB_BIC_Pressures(pressure);
110  GetTable("BIC Pressures")->AddRecord(parset);
111  par_list->Add(parset);
112  LinkListToRunRanges(par_list, rr_number, run_ranges);
113  par_list->Clear();
114  for (int zz = 0; zz < 3; zz++) pressure[zz] = 0.;
115  read_pressure = kFALSE;
116  }
117  rr_number = 0;
118 
119  }
120  if (sscanf(sline.Data(), "Run Range : %u %u", &frun, &lrun) != 2) {
121  Warning("ReadBICPressures()",
122  "Bad format in line :\n%s\nUnable to read run range values",
123  sline.Data());
124  }
125  else {
126  prev_rr = kTRUE;
127  run_ranges[rr_number][0] = frun;
128  run_ranges[rr_number][1] = lrun;
129  rr_number++;
130  if (rr_number == MAX_NUM_RUN_RANGES) {
131  Error("ReadBICPressures", "Too many run ranges (>%d)",
132  rr_number);
133  rr_number--;
134  }
135  }
136  } // Run Range found
137  if (fin.eof()) { //fin du fichier
138  //have we just finished reading some pressures ?
139  if (read_pressure) {
140  parset = new KVDB_BIC_Pressures(pressure);
141  GetTable("BIC Pressures")->AddRecord(parset);
142  par_list->Add(parset);
143  LinkListToRunRanges(par_list, rr_number, run_ranges);
144  par_list->Clear();
145  for (int zz = 0; zz < 3; zz++) pressure[zz] = 0.;
146  read_pressure = kFALSE;
147  }
148  }
149  if (sline.BeginsWith("BIC")) { //line with BIC pressure data
150 
151  prev_rr = kFALSE;
152 
153  //split up BIC name and pressure
154  TObjArray* toks = sline.Tokenize(' ');
155  TString chio = ((TObjString*)(*toks)[0])->String();
156  KVString press = ((TObjString*)(*toks)[1])->String();
157  delete toks;
158 
159  read_pressure = kTRUE;
160 
161  if (chio == "BIC_1") pressure[0] = press.Atof();
162  else if (chio == "BIC_2") pressure[1] = press.Atof();
163  else if (chio == "BIC_3") pressure[2] = press.Atof();
164  else read_pressure = kFALSE;
165 
166  } //line with BIC pressure data
167  } //parcours du fichier
168  delete par_list;
169  fin.close();
170 }
171 
172 
173 
unsigned int UInt_t
#define MAX_NUM_RUN_RANGES
dimension of run_range arrays
Definition: KVINDRADB.h:34
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
char Char_t
const Bool_t kFALSE
bool Bool_t
float Float_t
const Bool_t kTRUE
Database entry for BIC (Blocking Ionisation Chamber) pressures (experiment E416A)
virtual ~KVINDRADB_e416a()
Destructor.
virtual void ReadBICPressures()
DataBase of parameters for an INDRA campaign.
Definition: KVINDRADB.h:58
virtual void Build()
Definition: KVINDRADB.cpp:893
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:72
virtual void Add(TObject *obj)
virtual void Clear(Option_t *option="")
Double_t Atof() const
TObjArray * Tokenize(const TString &delim) const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
const char * Data() const
std::istream & ReadLine(std::istream &str, Bool_t skipWhite=kTRUE)
void Info(const char *location, const char *va_(fmt),...)
void Error(const char *location, const char *va_(fmt),...)
void Warning(const char *location, const char *va_(fmt),...)
const char * String