KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVINDRADB_e503.cpp
Go to the documentation of this file.
1 /*
2 $Id: KVINDRADB_e503.cpp,v 1.1 2009/01/22 15:39:26 franklan Exp $
3 $Revision: 1.1 $
4 $Date: 2009/01/22 15:39:26 $
5 */
6 
7 //Created by KVClassFactory on Wed Jan 21 13:44:30 2009
8 //Author: Chbihi
9 
10 #include "KVINDRADB_e503.h"
11 #include "KVDBParameterSet.h"
12 
13 using namespace std;
14 
16 
17 
18 
19 
21 void KVINDRADB_e503::init()
22 {
23  fDeltaPed = AddTable("DeltaPedestal", "Pedestal correction value of detectors");
24 }
25 
26 
27 
30 
32 {
33  // Default constructor
34  init();
35 }
36 
37 
38 
39 
41 
43 {
44  init();
45 }
46 
47 
48 
49 
52 
54 {
55  // Destructor
56 }
57 
58 
59 
60 
64 
66 {
67  // Read runlist and systems list, then read VAMOS scalers
68  // Read Brho and angle of Vamos for each run
69 
74 }
75 
76 
77 
78 
80 
82 {
83  ifstream fin;
84 
85  if (!OpenCalibFile("VamosScaler", fin)) {
86  Warning("ReadVamosScalers", "VAMOS scalers file not found : %s",
87  GetCalibFileName("VamosScaler"));
88  return;
89  }
90  Info("ReadVamosScalers", "Reading in Vamos Scaler file : %s",
91  GetCalibFileName("VamosScaler"));
92 
93  Float_t NormScaler = 0;
94  Float_t DT = 0;
95  Float_t NormVamos = 0;
96  TString sline;
97  Int_t irun = 0;
98  Int_t ScalerValue;
99  Char_t Crunnumber[40];
100  Char_t str[30];
101  while (fin.good()) { //reading the file
102  sline.ReadLine(fin);
103  if (!fin.eof()) { //fin du fichier
104  if (sline.Sizeof() > 1 && !sline.BeginsWith("#")) {
105  if (sline.BeginsWith("ScalersOfRunNumber")) {
106  sscanf(sline.Data(), "%30s %d ", Crunnumber, &irun);
107  KVINDRADBRun* idb = GetRun(irun);
108  if (idb) {
109  for (Int_t i = 0; i < 5; i++) { //retrouve dans les 4 prochaines lignes NormVamos,normSca etDT
110  sline.ReadLine(fin);
111 
112  if (sline.BeginsWith("NormVamos")) {
113  sscanf(sline.Data(), "%20s %f ", str, &NormVamos);
114  idb->Set(str, NormVamos);
115  }
116  if (sline.BeginsWith("NormScalers")) {
117  sscanf(sline.Data(), "%20s %f ", str, &NormScaler);
118  idb->Set(str, NormScaler);
119  }
120  if (sline.BeginsWith("DT")) {
121  sscanf(sline.Data(), "%20s %f ", str, &DT);
122  idb->Set(str, DT);
123  }
124 
125  }
126  for (Int_t i = 0; i < 40; i++) {
127  sline.ReadLine(fin);
128  sscanf(sline.Data(), "%s %d ", str, &ScalerValue);
129  idb->SetScaler(str, ScalerValue);
130  }
131 
132  }
133  }
134  }
135  }
136  }
137  fin.close();
138 }
139 
140 
141 
142 
144 
146 {
147  TString sline;
148  ifstream fin;
149 
150  if (!OpenCalibFile("VamosBrhoAngle", fin)) {
151  Warning("VamosBrhoAngle", "VAMOS Brho and angle file not found : %s",
152  GetCalibFileName("VamosBrhoAngle"));
153  return;
154  }
155 
156  Info("ReadVamosBrhoAngle", "Reading in VamosBrho and angle file : %s",
157  GetCalibFileName("VamosBrhoAngle"));
158 
159  Int_t run = 0;
160  Float_t Brho = -1;
161  Float_t theta = -1.;
162  while (fin.good()) { //reading the file
163  sline.ReadLine(fin);
164  if (!fin.eof()) { //fin du fichier
165  if (sline.Sizeof() > 1 && !sline.BeginsWith("#")) {
166  sscanf(sline.Data(), "%d %f %f ", &run, &Brho, &theta);
167 // cout<<" run = "<<run<<", Brho = "<<Brho<<", Theta = "<<theta<<endl;
168  if (Brho == 0) {
169  Brho = -1.;
170  theta = -1.;
171  }
172  KVINDRADBRun* idb = GetRun(run);
173  if (idb) {
174  idb->Set("Brho", Brho);
175  idb->Set("Theta", theta);
176  }
177  }
178  }
179  }
180 
181  fin.close();
182 }
183 
184 
185 
191 
193 {
194  // Reading the pedestal correction (DeltaPed). DeltaPed depends on
195  // the run number but it is the same for all detectors connected to the
196  // same QDC. The corrected pedestal is given by the reference
197  // pedestal + DeltaPed.
198  ifstream fin;
199 
200  if (!OpenCalibFile("PedestalCorrections", fin)) {
201  Warning("ReadPedestalCorrection", "Pedestal correction file not found : %s",
202  GetCalibFileName("PedestalCorrections"));
203  return;
204  }
205  Info("ReadPedestalCorrection", "Reading in pedestal correction file : %s",
206  GetCalibFileName("PedestalCorrections"));
207 
208 
209  TString sline;
210  while (fin.good()) { //reading the file
211  sline.ReadLine(fin);
212  // Skip comment line
213  if (sline.BeginsWith("#")) continue;
214 
215  if (sline.BeginsWith("+DeltaPed")) ReadDeltaPedestal(fin);
216  }
217  fin.close();
218 }
219 
220 
221 
230 
232 {
233  // Reading the pedestal correction (DeltaPed). Method called by
234  // KVINDRADB_e503::ReadPedestalCorrection(). DeltaPed is equal to
235  // DeltaNoise for high gain coder data. For anyother coder data,
236  // DetaPed is given by DeltaGene if DeltaGene is less than 20 channels,
237  // otherwise it is given by DeltaNoise. DeltaGene (DeltaNoise) is the
238  // difference between pedestal positions from the generator (noise)
239  // of the current run and of the reference run.
240 
241  KVString sline, signal, parname;
242  KVDBParameterSet* parset = NULL;
243  Int_t numQDC = -1;
244  KVNumberList runs;
245  Double_t Dped = -1., Dgene = -1., Dbruit = -1.;
246 
247  while (ifile.good()) { //reading the file
248  sline.ReadLine(ifile);
249  // Skip comment line
250  if (sline.BeginsWith("#")) continue;
251  // End character
252  if (sline.BeginsWith("!")) return;
253 
254  // QDC number
255  if (sline.BeginsWith("QDC=")) {
256  sline.Remove(0, 4);
257  numQDC = sline.Atoi();
258  continue;
259  }
260  // DeltaPed for each signal
261  Ssiz_t idx = sline.Index(":");
262  runs.SetList(TString(sline).Remove(idx));
263  sline.Remove(0, idx + 1);
264  sline.Begin(" ");
265  while (!sline.End()) {
266  signal = sline.Next(kTRUE);
267  Dgene = sline.Next(kTRUE).Atof();
268  Dbruit = sline.Next(kTRUE).Atof();
269 
270  // Marie-France's selection
271  Dped = ((Dgene > 20) || !strcmp(signal.Data(), "GG") ? Dbruit : Dgene);
272  if (Dped > 20) Warning("ReadDeltaPedestal", "DeltaPed>20 for runs %s, signal %s", runs.GetList(), signal.Data());
273 
274  parname.Form("QDC%.2d", numQDC);
275  parset = new KVDBParameterSet(parname.Data(), signal.Data(), 1);
276  parset->SetParameter(Dped);
277  fDeltaPed->AddRecord(parset);
278  LinkRecordToRunRange(parset, runs);
279  }
280  }
281 }
282 
283 //----------------------------------------------------------------------------------
284 
289 
291 {
292 //Read the names of pedestal files to use for each run range, found
293 //in file with name defined by the environment variable:
294 // [dataset name].INDRADB.Pedestals: ...
295 
296  ifstream fin;
297  if (!OpenCalibFile("Pedestals", fin)) {
298  Error("ReadPedestalList()", "Could not open file %s",
299  GetCalibFileName("Pedestals"));
300  return;
301  }
302  Info("ReadPedestalList()", "Reading pedestal file list...");
303 
304  KVString line;
305  Char_t filename_chio[80], filename_csi[80], filename_etalons[80];
306  UInt_t runlist[1][2];
307 
308  while (fin.good()) { //lecture du fichier
309 
310 // lecture des informations
311  line.ReadLine(fin);
312 
313 //recherche une balise '+'
314  if (line.BeginsWith('+')) { //balise trouvee
315 
316  line.Remove(0, 1);
317 
318  if (sscanf
319  (line.Data(), "Run Range : %u %u", &runlist[0][0],
320  &runlist[0][1]) != 2) {
321  Warning("ReadPedestalList()", "Format problem in line \n%s",
322  line.Data());
323  }
324 
325  line.ReadLine(fin);
326  sscanf(line.Data(), "%s", filename_chio);
327 
328  line.ReadLine(fin);
329  sscanf(line.Data(), "%s", filename_csi);
330 
331  line.ReadLine(fin);
332  sscanf(line.Data(), "%s", filename_etalons);
333 
334  TList RRList;
335  KVDBRecord* dummy = 0;
336  dummy = new KVDBRecord(filename_chio, "ChIo/Si pedestals");
337  dummy->AddKey("Runs", "Runs for which to use this pedestal file");
338  fPedestals->AddRecord(dummy);
339  RRList.Add(dummy);
340  dummy = new KVDBRecord(filename_csi, "CsI pedestals");
341  dummy->AddKey("Runs", "Runs for which to use this pedestal file");
342  fPedestals->AddRecord(dummy);
343  RRList.Add(dummy);
344  dummy = new KVDBRecord(filename_etalons, "Si75/SiLi pedestals");
345  dummy->AddKey("Runs", "Runs for which to use this pedestal file");
346  fPedestals->AddRecord(dummy);
347  RRList.Add(dummy);
348  LinkListToRunRanges(&RRList, 1, runlist);
349  } // balise trouvee
350  } // lecture du fichier
351  fin.close();
352  cout << "Pedestals Read" << endl;
353 }
354 
355 
int Int_t
unsigned int UInt_t
#define str(s)
Definition: KVBase.cpp:57
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
int Ssiz_t
char Char_t
double Double_t
float Float_t
const Bool_t kTRUE
int idb
To store calibration parameters in a database ,.
void SetParameter(UShort_t i, Double_t val)
Record folder for the database.
Definition: KVDBRecord.h:42
virtual Bool_t AddKey(KVDBKey *key, Bool_t check=kTRUE)
Definition: KVDBRecord.cpp:65
virtual Bool_t AddRecord(KVDBRecord *add)
Definition: KVDBTable.cpp:74
TString GetCalibFileName(const Char_t *type) const
Definition: KVExpDB.h:108
virtual void LinkListToRunRanges(TList *list, UInt_t rr_number, UInt_t run_ranges[][2])
Link the records contained in the list to the set of runs (see LinkRecordToRunRanges).
Definition: KVExpDB.cpp:164
virtual void LinkRecordToRunRange(KVDBRecord *rec, UInt_t first_run, UInt_t last_run)
Definition: KVExpDB.cpp:87
Bool_t OpenCalibFile(const Char_t *type, std::ifstream &fs) const
Definition: KVExpDB.cpp:433
Database entry for each run of an INDRA experiment.
Definition: KVINDRADBRun.h:29
Database for INDRA-VAMOS experiments E503 & E494S (2007)
virtual ~KVINDRADB_e503()
Destructor.
KVDBTable * fDeltaPed
virtual void ReadPedestalList()
virtual void ReadPedestalCorrection()
KVINDRADB_e503()
Default constructor.
virtual void ReadVamosScalers()
virtual void ReadVamosBrhoAndAngle()
virtual void ReadDeltaPedestal(ifstream &ifile)
DataBase of parameters for an INDRA campaign.
Definition: KVINDRADB.h:58
KVDBTable * fPedestals
table of pedestal files
Definition: KVINDRADB.h:72
KVINDRADBRun * GetRun(Int_t run) const
Definition: KVINDRADB.h:132
virtual void Build()
Definition: KVINDRADB.cpp:893
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:83
const Char_t * GetList() const
void SetList(const TString &)
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:72
void Begin(TString delim) const
Definition: KVString.cpp:565
Bool_t End() const
Definition: KVString.cpp:634
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:695
virtual void Remove(TObject *obj)
virtual void Add(TObject *obj)
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
Int_t Atoi() const
Double_t Atof() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
const char * Data() const
virtual Int_t Sizeof() const
void Form(const char *fmt,...)
TString & Remove(EStripType s, char c)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
std::istream & ReadLine(std::istream &str, Bool_t skipWhite=kTRUE)
TLine * line