Low-Energy Muon (LEM) Experiment  1.1.0
PTempCalibGui.h
Go to the documentation of this file.
1 /***************************************************************************
2 
3  PTempCalibGui.h
4 
5  Author: Andreas Suter
6  e-mail: andreas.suter@psi.ch
7 
8 ***************************************************************************/
9 
10 /***************************************************************************
11  * Copyright (C) 2010 by Andreas Suter *
12  * andreas.suter@psi.ch *
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  * This program is distributed in the hope that it will be useful, *
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22  * GNU General Public License for more details. *
23  * *
24  * You should have received a copy of the GNU General Public License *
25  * along with this program; if not, write to the *
26  * Free Software Foundation, Inc., *
27  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28  ***************************************************************************/
29 
30 #ifndef _PTEMPCALIBGUI_H_
31 #define _PTEMPCALIBGUI_H_
32 
33 #include <vector>
34 using namespace std;
35 
36 #include <TROOT.h>
37 #include <RQ_OBJECT.h>
38 #include <TGWindow.h>
39 #include <TGCanvas.h>
40 #include <TGTab.h>
41 #include <TGFrame.h>
42 #include <TGTextEntry.h>
43 #include <TGButton.h>
44 #include <TGComboBox.h>
45 #include <TGNumberEntry.h>
46 #include <TGLabel.h>
47 #include <TDatime.h>
48 #include <TCanvas.h>
49 #include <TGraph.h>
50 #include <TGraphErrors.h>
51 
52 #define TCG_WIDTH 425
53 #define TCG_HEIGHT 420
54 
55 #define TCG_NO_OF_RAW_DATA_CH 10
56 
57 //--------------------------------------------------------------------------
58 
61 
62 //--------------------------------------------------------------------------
63 class PRawData : public TQObject
64 {
65  RQ_OBJECT("PRawData")
66 
67  public:
68  PRawData();
69  virtual ~PRawData();
70 
71  virtual void SetLakeShore(const std::string lakeShore) { fLakeShore = lakeShore; }
72  virtual Bool_t IsDataPresent() { return fDataPresent; }
73  virtual UInt_t GetNoOfEntries() { return fNoOfEntries; }
74  virtual UInt_t GetNoOfRawDataReadings() { return fNoOfRawDataReadings; }
75  virtual UInt_t GetRawDataReadingOffset() { return fRawDataReadingOffset; }
76  virtual TString GetCtrlCh() { return fCtrlCh; }
77  virtual TString GetRawDataCh(UInt_t idx);
78  virtual Int_t MapChNo(UInt_t chNo);
79  virtual UInt_t GetRawDataSensorType(UInt_t idx);
80  virtual UInt_t GetSize() { return fDateTime.size(); }
81  virtual UInt_t GetStartTime() { return fStartDateTime.Get(); }
82  virtual UInt_t GetTime(UInt_t idx);
83  virtual Double_t GetTempMeasured(UInt_t idx);
84  virtual Double_t GetPressure(UInt_t idx);
85  virtual Double_t GetHeaterOutput(UInt_t idx);
86  virtual Double_t GetSetPointTemp(UInt_t idx);
87  virtual Double_t GetHeaterRange(UInt_t idx);
88  virtual Double_t GetBH1Flow(UInt_t idx);
89  virtual Double_t GetRawData(UInt_t ch, UInt_t idx);
90 
91  virtual void SetDataPresent(Bool_t bval) { fDataPresent = bval; }
92  virtual void SetNoOfEntries(UInt_t val) { fNoOfEntries = val; }
93  virtual void SetNoOfRawDataReadings(UInt_t val) { fNoOfRawDataReadings = val; }
94  virtual void SetRawDataReadingOffset(UInt_t val) { fRawDataReadingOffset = val; }
95  virtual void SetCtrlCh(const TString &str);
96  virtual void SetRawDataCh(const TString &str, UInt_t idx);
97  virtual void SetRawDataSensorType(UInt_t type, UInt_t idx);
98  virtual void SetStartDateTime(const char* dateTime) { fStartDateTime.Set(dateTime); }
99  virtual void AddDateTime(TDatime *dt);
100  virtual void AddTempMeasured(Double_t temp);
101  virtual void AddPressure(Double_t pressure);
102  virtual void AddHeaterOutput(Double_t heaterOutput);
103  virtual void AddSetPointTemp(Double_t setPoint);
104  virtual void AddHeaterRange(Double_t heaterRange);
105  virtual void AddBH1Flow(Double_t bh1Flow);
106  virtual void AddRawData(Double_t data, UInt_t ch);
107 
108  private:
109  std::string fLakeShore;
110 
111  Bool_t fDataPresent;
112 
113  UInt_t fNoOfEntries;
116  TString fCtrlCh;
117  TString fRawDataCh[TCG_NO_OF_RAW_DATA_CH];
118  UInt_t fRawDataSensorType[TCG_NO_OF_RAW_DATA_CH];
119 
120  TDatime fStartDateTime;
121  vector<TDatime*> fDateTime;
122  vector<Double_t> fTempMeasured;
123  vector<Double_t> fPressure;
124  vector<Double_t> fHeaterOutput;
125  vector<Double_t> fSetPointTemp;
126  vector<Double_t> fHeaterRange;
127  vector<Double_t> fBH1Flow;
128  vector< vector<Double_t> > fRawData;
129 
130  ClassDef(PRawData, 1)
131 };
132 
133 //--------------------------------------------------------------------------
134 class PDrawRawData : public TQObject
135 {
136  RQ_OBJECT("PDrawRawData")
137 
138  public:
139  PDrawRawData(UInt_t w, UInt_t h, PRawData &rawData, EPRawCh xIdx, EPRawCh yIdx, const std::string lakeShore);
140  virtual ~PDrawRawData();
141 
142  virtual void Show();
143 
144  private:
145  std::string fLakeShore;
146 
147  TCanvas *fCanvas;
148  TGraph *fGraph;
149 
150  virtual TString GetUnits(UInt_t idx);
151 
152  ClassDef(PDrawRawData, 1)
153 };
154 
155 //--------------------------------------------------------------------------
156 class PDrawMeanRawData : public TQObject
157 {
158  RQ_OBJECT("PDrawMeanRawData")
159 
160  public:
161  PDrawMeanRawData(UInt_t w, UInt_t h,
162  vector<Double_t> &temp, vector<Double_t> &errTemp,
163  vector<Double_t> &data, vector<Double_t> &errData,
164  TString yLabel);
165 
166  virtual ~PDrawMeanRawData();
167 
168  virtual void Show();
169 
170  private:
171  TCanvas *fCanvas;
172  TGraphErrors *fGraph;
173 
174  ClassDef(PDrawMeanRawData, 1)
175 };
176 
177 //--------------------------------------------------------------------------
178 class PCalibData : public TQObject
179 {
180  RQ_OBJECT("PCalibData")
181 
182  public:
183  PCalibData();
184  virtual ~PCalibData();
185 
186  virtual void Init();
187 
188  virtual Bool_t IsValid() { return fValid; }
189  virtual TString GetSensorModel() { return fSensorModel; }
190  virtual TString GetSerialNo() { return fSerialNo; }
191  virtual UInt_t GetDataFormat() { return fDataFormat; }
192  virtual Double_t GetSetPointLimit() { return fSetPointLimit; }
193  virtual UInt_t GetTempCoeff() { return fTempCoeff; }
194  virtual UInt_t GetNoOfPoints() { return fNoOfPoints; }
195  virtual UInt_t GetMeasuredSize() { return fMeasured.size(); }
196  virtual Double_t GetMeasured(UInt_t idx);
197  virtual UInt_t GetTempSize() { return fTemp.size(); }
198  virtual Double_t GetTemp(UInt_t idx);
199  virtual Double_t GetTemp(Double_t sensorValue);
200 
201  virtual void SetValid(Bool_t valid) { fValid = valid; }
202  virtual void SetSensorModel(TString &str) { fSensorModel = str; }
203  virtual void SetSerialNo(TString &str) { fSerialNo = str; }
204  virtual void SetDataFormat(UInt_t ival);
205  virtual void SetSetPointLimit(Double_t dval) { fSetPointLimit = dval; }
206  virtual void SetTempCoeff(UInt_t ival);
207  virtual void SetNoOfPoints(UInt_t ival) { fNoOfPoints = ival; }
208  virtual void AddMeasured(Double_t dval) { fMeasured.push_back(dval); }
209  virtual void AddTemp(Double_t dval) { fTemp.push_back(dval); }
210 
211  private:
212  Bool_t fValid; // flag showing if the data are valid
213  TString fSensorModel;
214  TString fSerialNo;
215  UInt_t fDataFormat; // 1 = mV/K, 2 = V/K, 3 = Ohm/K, 4 = Log(Ohm)/K, 5 = Log(Ohm)/Log(K)
216  Double_t fSetPointLimit;
217  UInt_t fTempCoeff; // 1 = negative, 2 = positive
218  UInt_t fNoOfPoints;
219 
220  vector<Double_t> fMeasured; // measured property, e.g. voltage for diodes
221  vector<Double_t> fTemp; // temperature corresponding to the measured property
222 
223  ClassDef(PCalibData, 1)
224 };
225 
226 //--------------------------------------------------------------------------
227 class PDrawCalibData : public TQObject
228 {
229  RQ_OBJECT("PDrawCalibData")
230 
231  public:
232  PDrawCalibData(UInt_t w, UInt_t h, PCalibData &calibData);
233  virtual ~PDrawCalibData();
234 
235  virtual void Show();
236 
237  private:
238  TCanvas *fCanvas;
239  TGraph *fGraph;
240 
241  ClassDef(PDrawCalibData, 1)
242 };
243 
244 //--------------------------------------------------------------------------
245 class PSensorInfo : public TGFrame
246 {
247  RQ_OBJECT("PSensorInfo")
248 
249  public:
250  PSensorInfo(TGGroupFrame *frame);
251  virtual ~PSensorInfo();
252 
253  virtual Int_t GetCh() { return fCh->GetSelected(); }
254  virtual Int_t GetSensorType() { return fType->GetSelected(); }
255  virtual Int_t GetDataFormat();
256  virtual TString GetSensorName() { return fName->GetDisplayText(); }
257  virtual TString GetSerialNo() { return fSerialNo->GetDisplayText(); }
258 
259  // slot
260  virtual void TypeChanged(Int_t);
261 
262  private:
263  TGLabel *fChLabel;
264  TGComboBox *fCh;
265  TGLabel *fTypeLabel;
266  TGComboBox *fType;
268  TGComboBox *fDataFormat;
269  TGLabel *fNameLabel;
270  TGTextEntry *fName;
271  TGLabel *fSerialNoLabel;
272  TGTextEntry *fSerialNo;
273 
274  ClassDef(PSensorInfo, 1)
275 };
276 
277 //--------------------------------------------------------------------------
278 
279 class PTempCalibSensors : public TQObject
280 {
281  RQ_OBJECT("PTempCalibSenors")
282 
283  public:
284  PTempCalibSensors(const TGWindow *p, const std::string lakeShore);
285  virtual ~PTempCalibSensors();
286 
287  virtual TGFrame *GetFrame() const { return fFrame; }
288  virtual void SetCanvas(TGCanvas *canvas);
289 
290  virtual UInt_t GetNoOfSensors() { return fNoOfSensors; }
291  virtual Int_t GetCh(UInt_t sensorIdx);
292  virtual Int_t GetSensorType(UInt_t sensorIdx);
293  virtual Int_t GetDataFormat(UInt_t sensorIdx);
294  virtual TString GetSensorName(UInt_t sensorIdx);
295  virtual TString GetSerialNo(UInt_t sensorIdx);
296 
297  // slots
298  virtual void SetNoOfSensors(Long_t);
299 
300  private:
301  std::string fLakeShore;
302 
303  TGCompositeFrame *fFrame;
304  TGCanvas *fCanvas;
305 
306  vector<TGGroupFrame*> fCalibSensorFrame;
307  vector<PSensorInfo*> fCalibSensorInfo;
308 
309  UInt_t fNoOfSensors;
310 
311  ClassDef(PTempCalibSensors, 1)
312 };
313 
314 //--------------------------------------------------------------------------
315 
316 class PTempCalibGui : public TQObject
317 {
318  RQ_OBJECT("PTempCalibGui")
319 
320  public:
321  PTempCalibGui(const TGWindow *p, UInt_t w, UInt_t h, const std::string lakeShore);
322  virtual ~PTempCalibGui();
323 
324  // slots
325  virtual void CloseWindow();
326  virtual void DoBrowse();
327  virtual void DoDrawRawData();
328  virtual void DoCalibration();
329  virtual void DoDrawWithErrors();
330  virtual void DoDrawCalibData();
331  virtual void DoTabSelected(Int_t id);
332 
333  virtual void NoOfThermoCalibChanged(Long_t); // *SIGNAL*
334 
335  private:
336  std::string fLakeShore;
337 
338  TGMainFrame *fMain;
339  TGHorizontalFrame *fFrame;
340  TGTab *fTab;
341 
342  TGTextEntry *fTab1FileName;
343  TGTextButton *fTab1BrowseButton;
344  TGTextEntry *fTab1StartTime;
345  TGComboBox *fTab1XComboBox;
346  TGComboBox *fTab1YComboBox;
347  TGTextButton *fTab1DrawButton;
348  TGTextButton *fTab1ExitButton;
349 
350 
353  TGTextButton *fTab2BrowseButton;
354  TGNumberEntry *fNoThermoForCalib;
355  TGNumberEntry *fDrawDataNo;
358  TGTextButton *fTab2CalibButton;
359  TGTextButton *fTab2DrawButton;
360  TGTextButton *fTab2ExitButton;
361 
362  TGTextEntry *fTab3FileName;
363  TGTextButton *fTab3BrowseButton;
364  TGTextButton *fTab3DrawButton;
365  TGTextButton *fTab3ExitButton;
366 
369 
370  virtual void LoadRawData(const char *filename);
371  virtual UInt_t UpdateHeaderInfo(vector<TString> &rawData, UInt_t idx);
372 
373  virtual void LoadCalibData(const char *filename);
374 
375  ClassDef(PTempCalibGui, 1)
376 };
377 
378 #endif // _PTEMPCALIBGUI_H_
TGTextButton * fTab2ExitButton
virtual void SetNoOfPoints(UInt_t ival)
virtual Int_t GetSensorType()
virtual TGFrame * GetFrame() const
TGTextEntry * fTab2SerialNoCalibThermo
std::string fLakeShore
virtual Double_t GetSetPointLimit()
TGTextButton * fTab3ExitButton
UInt_t fNoOfPoints
virtual UInt_t GetRawDataReadingOffset()
Definition: PTempCalibGui.h:75
virtual TString GetSensorModel()
PRawData fRawData
virtual void SetValid(Bool_t valid)
vector< Double_t > fTemp
TGLabel * fNameLabel
TGraph * fGraph
virtual UInt_t GetTempCoeff()
Bool_t fValid
TGTextButton * fTab3DrawButton
virtual TString GetCtrlCh()
Definition: PTempCalibGui.h:76
std::string fLakeShore
TString fSerialNo
TGTextEntry * fTab1FileName
virtual UInt_t GetNoOfSensors()
TGLabel * fSerialNoLabel
vector< Double_t > fPressure
vector< Double_t > fTempMeasured
virtual void SetLakeShore(const std::string lakeShore)
Definition: PTempCalibGui.h:71
TGCanvas * fTempCalibSensorsCanvas
Double_t fSetPointLimit
TString fSensorModel
virtual void SetNoOfEntries(UInt_t val)
Definition: PTempCalibGui.h:92
vector< vector< Double_t > > fRawData
virtual UInt_t GetTempSize()
TCanvas * fCanvas
virtual void AddMeasured(Double_t dval)
virtual void SetStartDateTime(const char *dateTime)
Definition: PTempCalibGui.h:98
PCalibData fCalibData
EPRawCh
Definition: PTempCalibGui.h:59
TCanvas * fCanvas
vector< TDatime * > fDateTime
TGTextButton * fTab2BrowseButton
PTempCalibSensors * fTempCalibSensorsContainer
TGComboBox * fTab1YComboBox
TGTextEntry * fTab3FileName
virtual void SetSerialNo(TString &str)
virtual void SetSensorModel(TString &str)
TGComboBox * fTab2ChannelCalibThermoComboBox
virtual void SetSetPointLimit(Double_t dval)
UInt_t fTempCoeff
TGTextButton * fTab1DrawButton
UInt_t fRawDataReadingOffset
virtual Int_t GetCh()
virtual TString GetSerialNo()
TGTextButton * fTab1BrowseButton
TGCanvas * fCanvas
vector< Double_t > fBH1Flow
virtual UInt_t GetNoOfEntries()
Definition: PTempCalibGui.h:73
virtual Bool_t IsDataPresent()
Definition: PTempCalibGui.h:72
TGTextEntry * fTab1StartTime
virtual UInt_t GetStartTime()
Definition: PTempCalibGui.h:81
TGMainFrame * fMain
TGraphErrors * fGraph
TGNumberEntry * fDrawDataNo
virtual TString GetSensorName()
vector< TGGroupFrame * > fCalibSensorFrame
virtual UInt_t GetDataFormat()
virtual Bool_t IsValid()
vector< Double_t > fHeaterRange
TGNumberEntry * fNoThermoForCalib
vector< PSensorInfo * > fCalibSensorInfo
TGCompositeFrame * fFrame
std::string fLakeShore
TGComboBox * fDataFormat
TGLabel * fDataFormatLabel
Bool_t fDataPresent
TGLabel * fTypeLabel
TString fCtrlCh
TGComboBox * fType
UInt_t fNoOfRawDataReadings
TGTextEntry * fSerialNo
TDatime fStartDateTime
vector< Double_t > fSetPointTemp
TGComboBox * fCh
TGComboBox * fTab1XComboBox
virtual UInt_t GetMeasuredSize()
TGTextEntry * fName
virtual UInt_t GetSize()
Definition: PTempCalibGui.h:80
virtual void SetDataPresent(Bool_t bval)
Definition: PTempCalibGui.h:91
virtual UInt_t GetNoOfRawDataReadings()
Definition: PTempCalibGui.h:74
TGTextButton * fTab2DrawButton
TGTextButton * fTab3BrowseButton
std::string fLakeShore
TGTextButton * fTab1ExitButton
virtual void SetNoOfRawDataReadings(UInt_t val)
Definition: PTempCalibGui.h:93
UInt_t fDataFormat
TGTextButton * fTab2CalibButton
vector< Double_t > fHeaterOutput
virtual void SetRawDataReadingOffset(UInt_t val)
Definition: PTempCalibGui.h:94
virtual UInt_t GetNoOfPoints()
#define TCG_NO_OF_RAW_DATA_CH
Definition: PTempCalibGui.h:55
UInt_t fNoOfEntries
TGLabel * fChLabel
vector< Double_t > fMeasured
TGHorizontalFrame * fFrame
virtual TString GetSerialNo()
virtual void AddTemp(Double_t dval)