HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hpiontrackercalrunpar.h
Go to the documentation of this file.
1 #ifndef HPIONTRACKERCALRUNPAR_H_
2 #define HPIONTRACKERCALRUNPAR_H_
3 
4 #include "TArrayD.h"
5 #include "TArrayF.h"
6 #include "TArrayI.h"
7 
8 #include "hparcond.h"
9 #include "hpario.h"
10 #include <map>
11 #include <vector>
12 #include <algorithm>
13 #include <iostream>
14 #include <iomanip>
15 #include <fstream>
16 
17 using namespace std;
18 
19 class HParamList;
20 
21 class HDetParAsciiFileIo;
22 
23 class HPionTrackerCalRunPars : public TObject {
24 
25 protected:
26  Int_t npars;
27  TArrayD offsets;
28 
29 public:
30 
31  HPionTrackerCalRunPars(Int_t size=4) { offsets.Set(size); clear();}
33  inline Int_t getNVals() { return offsets.GetSize(); }
34 
35  void setSize(Int_t size) { offsets.Set(size); clear(); }
36  void setVal(Int_t i,Float_t val) {
37  if( i >= 0 && i < getNVals()){
38  offsets[i] = val;
39  } else { Error("setVal()","Index i=%i out of bounds",i);}
40  }
41  Float_t getVal(Int_t i) {
42  if( i >= 0 && i < getNVals()){
43  return offsets[i];
44  } else {
45  Error("setVal()","Index i=%i out of bounds",i);
46  return 0;
47  }
48  }
49 
50  void copyVals(HPionTrackerCalRunPars* data){ for(Int_t i = 0; i < getNVals(); i ++) setVal(i,data->getVal(i)); }
51  void getVals(HPionTrackerCalRunPars* data) { for(Int_t i = 0; i < getNVals(); i ++) data->setVal(i,offsets[i]); }
52  void print(Int_t runID = -1){
53 
54  if(runID != -1) cout<<"RunID "<<setw(10)<<runID <<" = "<<flush;
55  else cout<<" = "<<flush;
56 
57  for(Int_t i = 0; i < getNVals() ; i ++){
58  if(i == 0) cout<<setw(8)<<offsets[i]<<flush;
59  else cout<<", "<<setw(8)<<offsets[i]<<flush;
60  }
61  cout<<endl;
62  }
63  Double_t* data() { return &offsets[0]; }
64  void clear() { for(Int_t i=0;i < getNVals();i++) offsets[i] = 0; }
65 
66  ClassDef(HPionTrackerCalRunPars,1)
67 };
68 
69 
70 
71 
73 
74 protected:
75 
76  map<Int_t, HPionTrackerCalRunPars* > fMRunID;
77  vector<Int_t> fVRunID; // list of runIDs
78  map<Int_t, HPionTrackerCalRunPars* >::iterator fMIter; //! remember the current runMap
79 
80 public:
81 
82  HPionTrackerCalRunPar(const Char_t* name = "PionTrackerCalRunPar",
83  const Char_t* title = "PionTracker Cal Parameters per run",
84  const Char_t* context = "PionTrackerCalRunParProduction");
86 
87  Bool_t findRunID(Int_t runID);
88  Bool_t removeRun(Int_t runID,Int_t level=1);
89  Bool_t addRun (Int_t runID,HPionTrackerCalRunPars* data,Bool_t overwrite=kFALSE);
90  Bool_t getRun (Int_t runID,HPionTrackerCalRunPars* data);
91  void finishRunList();
92  Bool_t getRangeRunID(Int_t& first,Int_t& last);
93  Int_t getNRunIDs() { return fVRunID.size();}
94  void getRunIDList(TArrayI* ar=0);
95  void printRunIDList();
96  void printRun(Int_t runID);
97 
98  void reset(Int_t level = 0);
99 
100  Bool_t init(HParIo*, Int_t*);
101  void clear();
102  void printParams();
103  void putParams(HParamList* l);
104  Bool_t getParams(HParamList* l);
105  virtual Int_t write(HParIo*);
106  virtual Int_t write(fstream& pFile);
107  virtual void putAsciiHeader(TString& b);
108 
109  ClassDef(HPionTrackerCalRunPar, 1) // Container for the PionTracker cal parameters per run
110 };
111 
112 
113 #endif /*HPIONTRACKERCALRUNPAR_H_*/
HPionTrackerCalRunPars(Int_t size=4)
void getVals(HPionTrackerCalRunPars *data)
Definition: hpario.h:11
void copyVals(HPionTrackerCalRunPars *data)
void print(Int_t runID=-1)
map< Int_t, HPionTrackerCalRunPars * >::iterator fMIter
map< Int_t, HPionTrackerCalRunPars * > fMRunID
void setVal(Int_t i, Float_t val)