musrfit 1.10.0
MuSR_td_PSI_bin.h
Go to the documentation of this file.
1/**************************************************************************************
2
3 MuSR_td_PSI_bin.h
4
5 declaration file of the class 'MuSR_td_PSI_bin'
6
7 Main class to read mdu and td_bin PSI MuSR data.
8
9***************************************************************************************
10
11 begin : Alex Amato, October 2005
12 modified : Andrea Raselli, October 2009
13 : Andreas Suter, April 2019, May 2020
14 copyright : (C) 2005 by
15 email : alex.amato@psi.ch
16
17***************************************************************************************/
18
19/***************************************************************************
20 * *
21 * This program is free software; you can redistribute it and/or modify *
22 * it under the terms of the GNU General Public License as published by *
23 * the Free Software Foundation; either version 2 of the License, or *
24 * (at your option) any later version. *
25 * *
26 ***************************************************************************/
27
28
29
30#ifndef MuSR_td_PSI_bin_H_
31#define MuSR_td_PSI_bin_H_
32
33#include <iostream>
34#include <fstream>
35#include <cstring>
36#include <cmath>
37#include <string>
38#include <vector>
39
40/* ------------------------------------------------------------------ */
41
42const int MAXHISTO = 32; // maximum number of histos to process/store
43const int MAXSCALER = 32; // maximum number of scalers to process/store
44const int MAXTEMPER = 4; // maximum number of average temperatures
45
46const int MAXLABELSIZE = 12; // maximum size of labels
47
48const int MAXREC = 4096; // maximum allowed data record size
49
50/* ------------------------------------------------------------------ */
51
53
54 public:
57
58 private:
59 std::string fFilename;
60 std::string fReadStatus;
61 std::string fWriteStatus;
62 std::string fConsistencyStatus;
66
67 char fFormatId[3];
68
70
71 char fSample[11];
72 char fTemp[11];
73 char fField[11];
74 char fOrient[11];
75 char fSetup[11];
76 char fComment[63];
77
78 char fDateStart[10];
79 char fDateStop[10];
80 char fTimeStart[9];
81 char fTimeStop[9];
82
83 double fBinWidth;
84
88
91
93
98
102
106
107 std::vector< std::vector<int> > fHisto;
108
109 public:
110
119 std::vector< std::vector<double> > fHistosVector ;
120
121// ------------------------------------end of the variables
122
123 public:
124
125 int Read(const char* fileName); // generic read
126 int Write(const char *fileName); // generic write
127
128 int ReadBin(const char* fileName); // read MuSR PSI bin format
129 int WriteBin(const char *fileName); // write MuSR PSI bin format
130 int ReadMdu(const char* fileName); // read MuSR mdu format
131 int WriteMdu(const char* fileName); // write MuSR mdu format
132
133 bool ReadingOK() const;
134 bool WritingOK() const;
135 bool CheckDataConsistency(int tag=0); // tag: 0=reasonable, 1=strict
136 std::string ReadStatus() const;
137 std::string WriteStatus() const;
138 std::string ConsistencyStatus() const;
139 std::string Filename() const;
140
141 int Show() const;
142 int Clear();
143
144 int GetHistoInt(int histo_num, int j);
145 double GetHisto(int histo_num, int j);
146
147 std::vector<int> GetHistoArrayInt(int histo_num);
148 std::vector<double> GetHistoArray(int histo_num, int binning);
149 int PutHistoArrayInt(std::vector< std::vector<int> > &histo, int tag = 0);
150 std::vector<double> GetHistoVector(int histo_num, int binning);
151 std::vector<double> GetHistoVectorNo0(int histo_num, int binning);
152
153 double *GetHistoFromT0Array(int histo_num, int binning, int offset = 0);
154
155 std::vector<double> GetHistoFromT0Vector(int histo_num, int binning, int offset = 0);
156
157 double *GetHistoGoodBinsArray(int histo_num, int binning);
158
159 std::vector<double> GetHistoGoodBinsVector(int histo_num, int binning);
160
161 double *GetHistoFromT0MinusBkgArray(int histo_num,
162 int lower_bckgdr,
163 int higher_bckgdr,
164 int binning,
165 int offset = 0);
166
167 std::vector<double> GetHistoFromT0MinusBkgVector(int histo_num,
168 int lower_bckgdr,
169 int higher_bckgdr,
170 int binning,
171 int offset = 0);
172
173 double *GetHistoGoodBinsMinusBkgArray(int histo_num,
174 int lower_bckgrd,
175 int higher_bckgrd,
176 int binning);
177
178 std::vector<double> GetHistoGoodBinsMinusBkgVector(int histo_num,
179 int lower_bckgrd,
180 int higher_bckgrd,
181 int binning);
182
183 double *GetAsymmetryArray(int histo_num_plus,
184 int histo_num_minus,
185 double alpha_param,
186 int binning,
187 int lower_bckgrd_plus,
188 int higher_bckgrd_plus,
189 int lower_bckgrd_minus,
190 int higher_bckgrd_minus,
191 int offset = 0,
192 double y_offset = 0.);
193
194 std::vector<double> GetAsymmetryVector(int histo_num_plus,
195 int histo_num_minus,
196 double alpha_param,
197 int binning,
198 int lower_bckgrd_plus,
199 int higher_bckgrd_plus,
200 int lower_bckgrd_minus,
201 int higher_bckgrd_minus,
202 int offset = 0,
203 double y_offset = 0.);
204
205 double *GetErrorAsymmetryArray(int histo_num_plus,
206 int histo_num_minus,
207 double alpha_param,
208 int binning,
209 int lower_bckgrd_plus,
210 int higher_bckgrd_plus,
211 int lower_bckgrd_minus,
212 int higher_bckgrd_minus,
213 int offset = 0);
214
215 std::vector<double> GetErrorAsymmetryVector(int histo_num_plus,
216 int histo_num_minus,
217 double alpha_param,
218 int binning,
219 int lower_bckgrd_plus,
220 int higher_bckgrd_plus,
221 int lower_bckgrd_minus,
222 int higher_bckgrd_minus,
223 int offset = 0);
224
225 double *GetAsymmetryGoodBinsArray(int histo_num_plus,
226 int histo_num_minus,
227 double alpha_param,
228 int binning,
229 int lower_bckgrd_plus,
230 int higher_bckgrd_plus,
231 int lower_bckgrd_minus,
232 int higher_bckgrd_minus);
233
234 std::vector<double> GetAsymmetryGoodBinsVector(int histo_num_plus,
235 int histo_num_minus,
236 double alpha_param,
237 int binning,
238 int lower_bckgrd_plus,
239 int higher_bckgrd_plus,
240 int lower_bckgrd_minus,
241 int higher_bckgrd_minus);
242
243 double *GetErrorAsymmetryGoodBinsArray(int histo_num_plus,
244 int histo_num_minus,
245 double alpha_param,
246 int binning,
247 int lower_bckgrd_plus,
248 int higher_bckgrd_plus,
249 int lower_bckgrd_minus,
250 int higher_bckgrd_minus);
251
252 std::vector<double> GetErrorAsymmetryGoodBinsVector(int histo_num_plus,
253 int histo_num_minus,
254 double alpha_param,
255 int binning,
256 int lower_bckgrd_plus,
257 int higher_bckgrd_plus,
258 int lower_bckgrd_minus,
259 int higher_bckgrd_minus);
260
261
262 double GetBinWidthPicoSec();
263 void PutBinWidthPicoSec(double binWidth);
264 double GetBinWidthNanoSec();
265 void PutBinWidthNanoSec(double binWidth);
266 double GetBinWidthMicroSec();
267 void PutBinWidthMicroSec(double binWidth);
268
270 void PutHistoLengthBin(int val) { fLengthHisto = val; }
271
273 void PutNumberHistoInt(int val) { fNumberHisto = val; }
274
275 std::string GetNameHisto(int i);
276 int PutNameHisto(std::string histoName, int i);
277 std::vector<std::string> GetHistoNamesVector();
278 int PutHistoNamesVector(std::vector<std::string> &histoNames);
279
280 long GetEventsHistoLong(int i);
281 std::vector<long> GetEventsHistoVector();
282
283 long GetTotalEventsLong() { return long(fTotalEvents); }
284
285 int GetNumberScalerInt();
286 int PutNumberScalerInt(int val);
287 std::vector<long> GetScalersVector();
288 int PutScalersVector(std::vector<int> scalerData);
289 std::vector<std::string> GetScalersNamesVector();
290 int PutScalersNamesVector(std::vector<std::string> scalersName);
291
292 int GetDefaultBinning();
293 int GetT0Int(int i);
294 int PutT0Int(int histoNo, int t0);
295 std::vector<int> GetT0Vector();
296 int PutT0Vector(std::vector<int> &t0Data);
297 double GetT0Double(int i);
298
299 int GetMaxT0Int();
300 int GetMax2T0Int (int k, int j);
301 int GetMinT0Int();
302 int GetMin2T0Int (int k, int j);
303
304 int GetFirstGoodInt(int i);
305 std::vector<int> GetFirstGoodVector();
306 int PutFirstGoodInt(int i, int j);
307
308 int GetLastGoodInt(int i);
309 std::vector<int> GetLastGoodVector();
310 int PutLastGoodInt(int i, int j);
311
312 int GetMaxLastGoodInt();
313 int GetMax2LastGoodInt (int k, int j);
314 int GetMinLastGoodInt();
315 int GetMin2LastGoodInt (int k, int j);
316
317 int GetRunNumberInt() { return fNumRun; }
318 int PutRunNumberInt(int i);
319
320 std::string GetSample();
321 int PutSample(std::string sample);
322 std::string GetField();
323 int PutField(std::string field);
324 std::string GetOrient();
325 int PutOrient(std::string orientation);
326 std::string GetTemp();
327 int PutTemp(std::string temp);
328 std::string GetSetup();
329 int PutSetup(std::string setup);
330 std::string GetComment();
331 int PutComment(std::string comment);
332
333 std::vector<std::string> GetTimeStartVector();
334 int PutTimeStartVector(std::vector<std::string> timeStart);
335 std::vector<std::string> GetTimeStopVector();
336 int PutTimeStopVector(std::vector<std::string> timeStop);
337
339 int PutNumberTemperatureInt(int noOfTemps);
340 std::vector<double> GetTemperaturesVector();
341 int PutTemperaturesVector(std::vector<double> &temps);
342 std::vector<double> GetDevTemperaturesVector();
343 int PutDevTemperaturesVector(std::vector<double> &devTemps);
344
345 private:
346
347 int Tmax(int x, int y);
348 int Tmin(int x, int y);
349
350} ;
351#endif
352/************************************************************************************
353 * EOF MuSR_td_PSI_bin.h *
354 ************************************************************************************/
const int MAXSCALER
const int MAXHISTO
const int MAXLABELSIZE
const int MAXREC
const int MAXTEMPER
int Write(const char *fileName)
Method to write a PSI-bin or an MDU file.
double GetBinWidthPicoSec()
Method returning a double representing the bin-width in picoseconds.
std::string GetOrient()
Method returning a string containing the orientation specified in the title.
std::vector< double > GetHistoArray(int histo_num, int binning)
Method to obtain an array of type double containing the values of the histogram <histo_num> with binn...
int fFirstGood[MAXHISTO]
int GetT0Int(int i)
Method returning an integer representing the t0 point (from the "integer" t0 in the header) for a spe...
int fScalers[MAXSCALER]
int PutDevTemperaturesVector(std::vector< double > &devTemps)
Method setting a vector of doubles containing standard deviations of the monitored values (usually te...
int PutNameHisto(std::string histoName, int i)
Method setting a string containing the name of the histogram <i>
int PutT0Vector(std::vector< int > &t0Data)
Method setting a vector of integer containing the t0 values of the histograms specified in the header...
int GetMinT0Int()
Method to determine the minimum value of the t0 bins.
double * GetAsymmetryArray(int histo_num_plus, int histo_num_minus, double alpha_param, int binning, int lower_bckgrd_plus, int higher_bckgrd_plus, int lower_bckgrd_minus, int higher_bckgrd_minus, int offset=0, double y_offset=0.)
Method to obtain an array of double containing the values of the asymmetry between 2 histograms.
int GetLastGoodInt(int i)
Method returning an integer representing the last good bin specified in the header for a specified hi...
std::vector< double > GetHistoFromT0MinusBkgVector(int histo_num, int lower_bckgdr, int higher_bckgdr, int binning, int offset=0)
Method to obtain a vector of double containing the values of the histogram <histo_num> with binning <...
std::vector< int > GetT0Vector()
Method returning a vector of integer containing the t0 values of the histograms specified in the head...
std::string GetNameHisto(int i)
Method returning a string containing the name of the histogram <i>
int Tmin(int x, int y)
int PutNumberTemperatureInt(int noOfTemps)
Method setting an integer representing the number of temperatures.
std::vector< double > GetHistoGoodBinsVector(int histo_num, int binning)
Method to obtain a vector of double containing the values of the histogram <histo_num> with binning <...
int PutFirstGoodInt(int i, int j)
Method setting an integer representing the first good bin specified in the header for a specified his...
int PutTemp(std::string temp)
Method setting a string containing the fSample temperature.
bool WritingOK() const
Method to obtain if writing and processing of the data file was OK.
bool CheckDataConsistency(int tag=0)
Check if a given set of data is consistent with the PSI-BIN limitations. If false,...
int PutSample(std::string sample)
Method setting a string containing the fSample name.
std::vector< double > GetTemperaturesVector()
Method returning a vector of doubles containing monitored values (usually temperatures)
~MuSR_td_PSI_bin()
Simple Destructor clearing some pointers and variables.
std::vector< std::string > GetHistoNamesVector()
Method returning a vector of strings containing the names of the histograms.
std::vector< double > GetErrorAsymmetryVector(int histo_num_plus, int histo_num_minus, double alpha_param, int binning, int lower_bckgrd_plus, int higher_bckgrd_plus, int lower_bckgrd_minus, int higher_bckgrd_minus, int offset=0)
Method to obtain a vector of double containing the values of the error of the asymmetry between 2 his...
std::vector< int > GetLastGoodVector()
Method returning a vector of integer containing the last good bin values of the histograms specified ...
double * GetHistoGoodBinsMinusBkgArray(int histo_num, int lower_bckgrd, int higher_bckgrd, int binning)
Method to obtain an array of type double containing the values of the histogram <histo_num> with binn...
std::vector< int > GetHistoArrayInt(int histo_num)
Method to obtain an array of type integer containing the values of the histogram <histo_num>
int GetMax2T0Int(int k, int j)
Method to determine the maximum value of the last good bins of 2 histograms.
int PutT0Int(int histoNo, int t0)
Method setting an integer representing the t0 point (from the "integer" t0 in the header) for a speci...
char fLabelsScalers[MAXSCALER][MAXLABELSIZE]
int PutScalersNamesVector(std::vector< std::string > scalersName)
Method setting a vector of strings containing the names of the scalers.
double GetT0Double(int i)
Method returning a double representing the t0 point (from the "real" t0 in the header) for a specifie...
std::string ConsistencyStatus() const
Method to obtain error/success information on data consistency check.
int Clear()
Method to clear member variables before using instance for next read.
char fLabelsHisto[MAXHISTO][MAXLABELSIZE]
std::string GetField()
Method returning a string containing the field specified in the title.
std::vector< long > GetScalersVector()
Method providing a vector of long containing the values of the scalers.
double GetBinWidthMicroSec()
Method returning a double representing the bin-width in microseconds.
std::vector< std::vector< double > > fHistosVector
void PutNumberHistoInt(int val)
double * GetHistoFromT0Array(int histo_num, int binning, int offset=0)
Method to obtain an array of type double containing the values of the histogram <histo_num> with binn...
float fRealT0[MAXHISTO]
int PutField(std::string field)
Method setting a string containing the field.
int GetMin2T0Int(int k, int j)
Method to determine the minimum value of the last good bins of 2 histograms.
float fTemper[MAXTEMPER]
void PutBinWidthPicoSec(double binWidth)
Method setting a double representing the bin-width in picoseconds.
std::string Filename() const
Method to obtain the file name.
std::vector< double > GetAsymmetryVector(int histo_num_plus, int histo_num_minus, double alpha_param, int binning, int lower_bckgrd_plus, int higher_bckgrd_plus, int lower_bckgrd_minus, int higher_bckgrd_minus, int offset=0, double y_offset=0.)
Method to obtain a vector of double containing the values of the asymmetry between 2 histograms.
int PutComment(std::string comment)
Method setting a string containing the comment.
int ReadMdu(const char *fileName)
Method to read a MuSR MDU file.
int fIntegerT0[MAXHISTO]
int WriteBin(const char *fileName)
Method to write a PSI-bin file.
int GetMin2LastGoodInt(int k, int j)
Method to determine the minimum value of the last good bins of 2 histograms.
std::string GetTemp()
Method returning a string containing the temperature specified in the title.
int GetMinLastGoodInt()
Method providing the minimum value of the last good bins.
int Show() const
Method to show current values of member variables.
int ReadBin(const char *fileName)
Method to read a PSI-bin file.
std::string fReadStatus
std::vector< std::string > GetTimeStartVector()
Method returning a vector of strings containing 1) the date when the run was started and 2) the time ...
std::vector< double > GetHistoFromT0Vector(int histo_num, int binning, int offset=0)
Method to obtain a vector of double containing the values of the histogram <histo_num> with binning <...
int PutHistoArrayInt(std::vector< std::vector< int > > &histo, int tag=0)
Method to set the histograms which is a vector of vector of int's (histogram). There are two differen...
void PutBinWidthMicroSec(double binWidth)
Method setting a double representing the bin-width in microseconds.
std::vector< int > GetFirstGoodVector()
Method returning a vector of integer containing the first good bin values of the histograms specified...
double * GetHistoGoodBinsArray(int histo_num, int binning)
Method to obtain an array of type double containing the values of the histogram <histo_num> with binn...
std::string fWriteStatus
int PutLastGoodInt(int i, int j)
Method to modify the last good bin (value <j>) of the histogram <i>
int PutScalersVector(std::vector< int > scalerData)
Method set a vector of long containing the values of the scalers.
long GetEventsHistoLong(int i)
Method returning a long representing the number of events in a specified histograms.
std::vector< std::string > GetScalersNamesVector()
Method returning a vector of strings containing the names of the scalers.
std::vector< std::string > GetTimeStopVector()
Method returning a vector of strings containing 1) the date when the run was stopped and 2) the time ...
void PutBinWidthNanoSec(double binWidth)
Method setting a double representing the bin-width in nanoseconds.
std::vector< double > GetDevTemperaturesVector()
Method returning a vector of doubles containing standard deviations of the monitored values (usually ...
int GetMax2LastGoodInt(int k, int j)
Method to determine the maximum value of the "last good bins" of 2 histograms.
std::string WriteStatus() const
Method to obtain error/success information after writing.
std::string fConsistencyStatus
int PutTimeStartVector(std::vector< std::string > timeStart)
Method setting a vector of strings containing 1) the date when the run was started and 2) the time wh...
double * GetErrorAsymmetryGoodBinsArray(int histo_num_plus, int histo_num_minus, double alpha_param, int binning, int lower_bckgrd_plus, int higher_bckgrd_plus, int lower_bckgrd_minus, int higher_bckgrd_minus)
Method to obtain an array of double containing the values of the error of the asymmetry between 2 his...
std::vector< double > GetHistoVectorNo0(int histo_num, int binning)
Method to obtain a vector of double containing the values of the histogram <histo_num> with binning <...
double GetBinWidthNanoSec()
Method returning a double representing the bin-width in nanoseconds.
int PutHistoNamesVector(std::vector< std::string > &histoNames)
Method setting a vector containing the names of all the histograms.
int PutRunNumberInt(int i)
Method to modify the run number (value <i>)
std::string ReadStatus() const
Method to obtain error/success information after reading.
std::vector< double > GetErrorAsymmetryGoodBinsVector(int histo_num_plus, int histo_num_minus, double alpha_param, int binning, int lower_bckgrd_plus, int higher_bckgrd_plus, int lower_bckgrd_minus, int higher_bckgrd_minus)
Method to obtain a vector of double containing the values of the error of the asymmetry between 2 his...
std::vector< double > GetHistoGoodBinsMinusBkgVector(int histo_num, int lower_bckgrd, int higher_bckgrd, int binning)
Method to obtain a vector of double containing the values of the histogram <histo_num> with binning <...
int Read(const char *fileName)
Method to read a PSI-bin or an MDU file.
int GetMaxT0Int()
Method to determine the maximum value of the t0 bins.
double * GetAsymmetryGoodBinsArray(int histo_num_plus, int histo_num_minus, double alpha_param, int binning, int lower_bckgrd_plus, int higher_bckgrd_plus, int lower_bckgrd_minus, int higher_bckgrd_minus)
Method to obtain an array of double containing the values of the asymmetry between 2 histograms.
int PutSetup(std::string setup)
Method setting a string containing the setup.
int GetNumberScalerInt()
Method returning an integer representing the number of histograms.
int PutNumberScalerInt(int val)
Method seting the number of scalers present.
double GetHisto(int histo_num, int j)
Method to return the value of a single bin as double.
int GetMaxLastGoodInt()
Method returning an integer containing the maximum value of the "last good bins" of all histograms.
bool ReadingOK() const
Method to obtain if reading and processing of the data file was OK.
std::string GetSample()
Method returning a string containing the fSample name.
int GetFirstGoodInt(int i)
Method returning an integer representing the first good bin specified in the header for a specified h...
int fLastGood[MAXHISTO]
std::string fFilename
int GetDefaultBinning()
Method returning an integer representing the default binning.
std::vector< std::vector< int > > fHisto
float fTempDeviation[MAXTEMPER]
int GetHistoInt(int histo_num, int j)
Method to return the value of a single bin as integer.
double * GetErrorAsymmetryArray(int histo_num_plus, int histo_num_minus, double alpha_param, int binning, int lower_bckgrd_plus, int higher_bckgrd_plus, int lower_bckgrd_minus, int higher_bckgrd_minus, int offset=0)
Method to obtain an array of double containing the values of the error of the asymmetry between 2 his...
double * GetHistoFromT0MinusBkgArray(int histo_num, int lower_bckgdr, int higher_bckgdr, int binning, int offset=0)
Method to obtain an array of type double containing the values of the histogram <histo_num> with binn...
void PutHistoLengthBin(int val)
int Tmax(int x, int y)
std::vector< double > GetHistoVector(int histo_num, int binning)
Method to obtain a vector of double containing the values of the histogram <histo_num> with binning <...
std::string GetComment()
Method returning a string containing the comment specified in the title.
std::string GetSetup()
Method returning a string containing the setup.
int PutTemperaturesVector(std::vector< double > &temps)
Method setting a vector of doubles containing monitored values (usually temperatures)
std::vector< double > GetAsymmetryGoodBinsVector(int histo_num_plus, int histo_num_minus, double alpha_param, int binning, int lower_bckgrd_plus, int higher_bckgrd_plus, int lower_bckgrd_minus, int higher_bckgrd_minus)
Method to obtain a vector of double containing the values of the asymmetry between 2 histograms.
int PutOrient(std::string orientation)
Method setting a string containing the fSample orientation.
int WriteMdu(const char *fileName)
Method to write a MuSR MDU file.
int fEventsPerHisto[MAXHISTO]
std::vector< long > GetEventsHistoVector()
Method returning a vector of long containing the number of events in the histograms.
MuSR_td_PSI_bin()
Simple Constructor setting some pointers and variables.
int PutTimeStopVector(std::vector< std::string > timeStop)
Method setting a vector of strings containing 1) the date when the run was started and 2) the time wh...