HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
htofcalpar.cc
Go to the documentation of this file.
1 //*-- Author : Ilse Koenig
2 //*-- Modified: 10/03/2000 by Ilse Koenig
3 //*-- Modified: 27/11/2000 by R. Holzmann
4 //*-- Modified: 09/05/2002 by D.Zovinec
5 
6 //_HADES_CLASS_DESCRIPTION
7 ///////////////////////////////////////////////////////////////////////////////
8 // HTofCalPar
9 //
10 // Calibration parameters for TOF
11 //
12 ///////////////////////////////////////////////////////////////////////////////
13 using namespace std;
14 #include "htofcalpar.h"
15 #include "hades.h"
16 #include "hruntimedb.h"
17 #include "hspectrometer.h"
18 #include "htofdetector.h"
19 #include "hpario.h"
20 #include "hdetpario.h"
21 #include <iostream>
22 #include <iomanip>
23 
28 
29 void HTofCalParCell::setDefaults(void) {
30  // sets the default values
31  leftK=0.065; // in ns/ch
32  rightK=0.065;
33  vGroup=160.0; // in mm/ns
34  posK=0.0;
35  timK=0.0;
36  pedestalL=0.0;
37  pedestalR=0.0;
38  attLen=0.0;
39  gainAsym=0.0;
40  edepK=1.0;
41  twC1=0.0;
42  twC2=0.0;
43  twC3=0.0;
44 }
45 
46 void HTofCalParCell::Streamer(TBuffer &R__b)
47 {
48  if (R__b.IsReading()) {
49  Version_t R__v = R__b.ReadVersion();
50  TObject::Streamer(R__b);
51  R__b >> leftK;
52  R__b >> rightK;
53  R__b >> vGroup;
54  R__b >> posK;
55  R__b >> timK;
56  R__b >> pedestalL;
57  R__b >> pedestalR;
58  R__b >> attLen;
59  R__b >> gainAsym;
60  if(R__v <= 1){
61  edepK = 0.0;
62  twC1 = 0.0;
63  twC2 = 0.0;
64  twC3 = 0.0;
65  }
66  if(R__v == 2){
67  R__b >> edepK;
68  twC1 = 0.0;
69  twC2 = 0.0;
70  twC3 = 0.0;
71  }
72  if(R__v >= 3){
73  R__b >> edepK;
74  R__b >> twC1;
75  R__b >> twC2;
76  R__b >> twC3;
77  }
78  } else {
79  R__b.WriteVersion(HTofCalParCell::IsA());
80  TObject::Streamer(R__b);
81  R__b << leftK;
82  R__b << rightK;
83  R__b << vGroup;
84  R__b << posK;
85  R__b << timK;
86  R__b << pedestalL;
87  R__b << pedestalR;
88  R__b << attLen;
89  R__b << gainAsym;
90  R__b << edepK;
91  R__b << twC1;
92  R__b << twC2;
93  R__b << twC3;
94  }
95 }
96 
97 HTofCalParMod::HTofCalParMod(Int_t s, Int_t m) {
98  // constructor creates an array of pointers of type HTofCalParCell
99  HDetector* det=gHades->getSetup()->getDetector("Tof");
100  Int_t n=det->getMaxComponents();
101  if (det->getModule(s,m)) {
102  array = new TObjArray(n);
103  for(Int_t i=0 ; i<n ; i++) array->AddAt(new HTofCalParCell(),i);
104  } else array = new TObjArray(0);
105 }
106 
108  // destructor
109  if(array)
110  {
111  array->Delete();
112  delete array;
113  }
114 }
115 
116 
118  // constructor creates an array of pointers of type HTofCalParCell
119  array = new TObjArray(n);
120  for(Int_t i=0 ; i<n ; i++)
121  array->AddAt(new HTofCalParMod(s,i),i);
122 }
123 
125  // destructor
126  array->Delete();
127  delete array;
128 }
129 
130 
131 HTofCalPar::HTofCalPar(const Char_t* name,const Char_t* title,
132  const Char_t* context)
133  : HParSet(name,title,context) {
134  // constructor creates an array of pointers of type HTofCalParSec
135  // The container name is set to "TofCalPar"
136  strcpy(detName,"Tof");
137  array = new TObjArray(6);
138  for (Int_t i=0; i<6; i++)
139  array->AddAt(new HTofCalParSec(i,22),i);
140 }
141 
142 
144  // destructor
145  array->Delete();
146  delete array;
147 }
148 
149 Bool_t HTofCalPar::init(HParIo* inp,Int_t* set) {
150  // intitializes the container from an input
151  HDetParIo* input=inp->getDetParIo("HTofParIo");
152  if (input) return (input->init(this,set));
153  return kFALSE;
154 }
155 
157  // writes the container to an output
158  HDetParIo* out=output->getDetParIo("HTofParIo");
159  if (out) return out->write(this);
160  return -1;
161 }
162 
164  // sets the default values
165  for(Int_t i0=0;i0<getSize();i0++) {
166  HTofCalParSec& sec=(*this)[i0];
167  Int_t n1=sec.getSize();
168  for(Int_t i1=0;i1<n1;i1++) {
169  HTofCalParMod& mod=sec[i1];
170  Int_t n2=mod.getSize();
171  for(Int_t i2=0;i2<n2;i2++) mod[i2].setDefaults();
172  }
173  }
174  status=kFALSE;
176 }
177 
178 void HTofCalPar::readline(const Char_t *buf, Int_t *set) {
179  // decodes one line read from ascii file I/O
180  Int_t s,m,c;
181  Float_t lk,rk,vg,pk,tk,pl,pr,al,ga,ek,twc1,twc2,twc3;
182  sscanf(buf,"%i%i%i%f%f%f%f%f%f%f%f%f%f%f%f%f",&s,&m,&c,&lk,&rk,&vg,&pk,&tk,&pl,&pr,&al,&ga,&ek,&twc1,&twc2,&twc3);
183  HTofCalParCell& cell=(*this)[s][m][c];
184  cell.setLeftK(lk);
185  cell.setRightK(rk);
186  cell.setVGroup(vg);
187  cell.setPosK(pk);
188  cell.setTimK(tk);
189  cell.setPedestalL(pl);
190  cell.setPedestalR(pr);
191  cell.setAttLen(al);
192  cell.setGainAsym(ga);
193  cell.setEdepK(ek);
194  cell.setTimeWalkC1(twc1);
195  cell.setTimeWalkC2(twc2);
196  cell.setTimeWalkC3(twc3);
197  set[(s*22+m)]=999;
198 }
199 
200 void HTofCalPar::putAsciiHeader(TString& header) {
201  // puts the ascii header to the string used in HTofParAsciiFileIo
202  header=
203  "# Calibration parameters for the TOF detector\n"
204  "# Format:\n"
205  "# sector module cell leftK rightK vGroup posK timK\n"
206  "# pedestalL pedestalR attLen gainAsym edepK twC1 twC2 twC3\n";
207 }
208 
209 Bool_t HTofCalPar::writeline(Char_t *buf,Int_t s, Int_t m, Int_t c) {
210  // writes one line to the buffer used by ascii file I/O
211  HTofCalParCell& cell=(*this)[s][m][c];
212  sprintf(buf,"%2i%2i%2i %8.5f %8.5f %7.3f %9.3f %8.3f %7.1f %7.1f %8.3f %9.3f %7.5f %6.3f %6.3f %6.3f\n",
213  s,m,c,cell.getLeftK(),cell.getRightK(),cell.getVGroup(),
214  cell.getPosK(),cell.getTimK(),cell.getPedestalL(),cell.getPedestalR(),
215  cell.getAttLen(),cell.getGainAsym(),cell.getEdepK(),
216  cell.getTimeWalkC1(),cell.getTimeWalkC2(),cell.getTimeWalkC3());
217  return kTRUE;
218 }
219 
221  // pauses printing
222  printf("Press any key to continue");
223  getchar();
224  printf("\n\n");
225 }
226 
228  // prints the parameters
229  printf("\n Calibration parameters for the TOF detector\n");
230  printf(" Format:\n");
231  printf(" sector module cell leftK rightK vGroup posK timK\n");
232  printf(" pedestalL pedestalR attLen gainAsym edepK twC1 twC2 twC3\n");
233  printf("==============================================================\n");
234  Text_t buf[155];
235  Int_t line=0;
236  Int_t n0 = getSize();
237  for(Int_t i0=0; i0<n0; i0++) {
238  Int_t n1 = (*this)[i0].getSize();
239  for(Int_t i1=0; i1<n1; i1++) {
240  Int_t n2 = (*this)[i0][i1].getSize();
241  for(Int_t i2=0; i2<n2; i2++) {
242  line++;
243  // if (line%24 == 0) printPause();
244  if (writeline(buf, i0, i1, i2)) printf(buf,strlen(buf));
245  }
246  }
247  }
248  printf("==============================================================\n");
249 }
Float_t getTimeWalkC1()
Definition: htofcalpar.h:37
Float_t getTimK()
Definition: htofcalpar.h:31
void putAsciiHeader(TString &)
Definition: htofcalpar.cc:200
void setVGroup(Float_t f)
Definition: htofcalpar.h:57
TObjArray * array
Definition: htofcalpar.h:100
void setRightK(Float_t f)
Definition: htofcalpar.h:56
ClassImp(HTofCalPar) ClassImp(HTofCalParSec) ClassImp(HTofCalParMod) ClassImp(HTofCalParCell) void HTofCalParCell
Definition: htofcalpar.cc:24
Int_t getSize()
Definition: htofcalpar.h:94
HTofCalParMod(Int_t s=0, Int_t m=0)
Definition: htofcalpar.cc:97
Text_t detName[20]
Definition: hparset.h:11
void setEdepK(Float_t f)
Definition: htofcalpar.h:64
Float_t getPedestalR()
Definition: htofcalpar.h:33
HTofCalPar(const Char_t *name="TofCalPar", const Char_t *title="Calibration parameters for Tof", const Char_t *context="TofCalProduction")
Definition: htofcalpar.cc:131
Float_t getEdepK()
Definition: htofcalpar.h:36
Float_t getPedestalL()
Definition: htofcalpar.h:32
void setTimeWalkC3(Float_t f)
Definition: htofcalpar.h:67
Float_t getRightK()
Definition: htofcalpar.h:28
void setPedestalL(Float_t f)
Definition: htofcalpar.h:60
Float_t getPosK()
Definition: htofcalpar.h:30
virtual Int_t getModule(Int_t sector, Int_t mod)
Definition: hdetector.cc:85
virtual Bool_t init(HParSet *, Int_t *)
Definition: hdetpario.h:27
~HTofCalPar(void)
Definition: htofcalpar.cc:143
Int_t n
Int_t getSize()
Definition: htofcalpar.h:110
void readline(const Char_t *, Int_t *)
Definition: htofcalpar.cc:178
virtual HDetParIo * getDetParIo(const Text_t *)
Definition: hpario.cc:50
void setTimK(Float_t f)
Definition: htofcalpar.h:59
Definition: hpario.h:11
void resetInputVersions()
Definition: hparset.cc:144
virtual Int_t write()
Definition: hparset.cc:119
void setTimeWalkC1(Float_t f)
Definition: htofcalpar.h:65
Bool_t writeline(Char_t *, Int_t, Int_t, Int_t)
Definition: htofcalpar.cc:209
TString input
Definition: GarReader.C:5
HSpectrometer * getSetup(void)
Definition: hades.h:112
HDetector * getDetector(const Char_t *name)
Definition: hparset.h:9
void printParam()
Definition: htofcalpar.cc:227
Hades * gHades
Definition: hades.cc:1213
Int_t getMaxComponents(void)
Definition: hdetector.h:25
Float_t getAttLen()
Definition: htofcalpar.h:34
void setAttLen(Float_t f)
Definition: htofcalpar.h:62
void setGainAsym(Float_t f)
Definition: htofcalpar.h:63
return output
Float_t getVGroup()
Definition: htofcalpar.h:29
void setPedestalR(Float_t f)
Definition: htofcalpar.h:61
Float_t getLeftK()
Definition: htofcalpar.h:27
Bool_t status
versions of container in the 2 possible inputs
Definition: hparset.h:13
Float_t getTimeWalkC2()
Definition: htofcalpar.h:38
void printPause(void)
Definition: htofcalpar.cc:220
void setLeftK(Float_t f)
Definition: htofcalpar.h:55
void setPosK(Float_t f)
Definition: htofcalpar.h:58
virtual Int_t write(HParSet *)
Definition: hdetpario.h:30
void setTimeWalkC2(Float_t f)
Definition: htofcalpar.h:66
HTofCalParSec(Int_t s=0, Int_t n=22)
Definition: htofcalpar.cc:117
Float_t getGainAsym()
Definition: htofcalpar.h:35
Float_t getTimeWalkC3()
Definition: htofcalpar.h:39
Int_t getSize()
Definition: htofcalpar.h:81
void clear()
Definition: htofcalpar.cc:163
virtual Bool_t init(void)
Definition: hparset.h:21