00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef MuSR_td_PSI_bin_H_
00030 #define MuSR_td_PSI_bin_H_
00031
00032 #include <iostream>
00033 using namespace std ;
00034 #include <fstream>
00035 #include <cstring>
00036 #include <cmath>
00037 #include <string>
00038 #include <vector>
00039
00040
00041
00042 const int MAXHISTO = 32;
00043 const int MAXSCALER = 32;
00044 const int MAXTEMPER = 4;
00045
00046 const int MAXLABELSIZE = 12;
00047
00048
00049
00050 class MuSR_td_PSI_bin {
00051
00052 public:
00053 MuSR_td_PSI_bin();
00054 ~MuSR_td_PSI_bin();
00055
00056 private:
00057
00058
00059 string filename;
00060 string readstatus;
00061 bool readingok;
00062
00063 char format_id[3] ;
00064
00065 int num_run ;
00066
00067 char sample[11] ;
00068 char temp[11] ;
00069 char field[11] ;
00070 char orient[11] ;
00071 char comment[63] ;
00072
00073 char date_start[10] ;
00074 char date_stop[10] ;
00075 char time_start[9] ;
00076 char time_stop[9] ;
00077
00078 float bin_width ;
00079
00080 int number_histo ;
00081 int length_histo ;
00082 char labels_histo[MAXHISTO][MAXLABELSIZE] ;
00083
00084 int total_events ;
00085 int events_per_histo[MAXHISTO] ;
00086
00087 int default_binning ;
00088
00089 float real_t0[MAXHISTO] ;
00090 int integer_t0[MAXHISTO] ;
00091 int first_good[MAXHISTO] ;
00092 int last_good[MAXHISTO] ;
00093
00094 int number_scaler ;
00095 int scalers[MAXSCALER] ;
00096 char labels_scalers[MAXSCALER][MAXLABELSIZE] ;
00097
00098 int number_temper ;
00099 float temper[MAXTEMPER] ;
00100 float temp_deviation[MAXTEMPER] ;
00101
00102 int **histo ;
00103
00104 public:
00105
00114 vector< vector<double> > histos_vector ;
00115
00116
00117
00118 public:
00119
00120 int read(const char* fileName);
00121
00122 int readbin(const char* fileName);
00123 int readmdu(const char* fileName);
00124
00125 bool readingOK() const;
00126 string ReadStatus() const;
00127 string Filename() const;
00128
00129 int Show() const;
00130 int Clear();
00131
00132 int get_histo_int(int histo_num, int j);
00133 double get_histo(int histo_num, int j);
00134
00135 int *get_histo_array_int(int histo_num);
00136 double *get_histo_array(int histo_num , int binning) ;
00137 vector<double> get_histo_vector(int histo_num , int binning) ;
00138 vector<double> get_histo_vector_no0(int histo_num , int binning) ;
00139
00140 double *get_histo_fromt0_array(int histo_num ,
00141 int binning ,
00142 int offset = 0) ;
00143
00144 vector<double> get_histo_fromt0_vector(int histo_num ,
00145 int binning ,
00146 int offset = 0) ;
00147
00148 double *get_histo_goodBins_array(int histo_num , int binning) ;
00149
00150 vector<double> get_histo_goodBins_vector(int histo_num , int binning) ;
00151
00152 double *get_histo_fromt0_minus_bckgrd_array(int histo_num ,
00153 int lower_bckgdr ,
00154 int higher_bckgdr ,
00155 int binning ,
00156 int offset = 0) ;
00157
00158 vector<double> get_histo_fromt0_minus_bckgrd_vector(int histo_num ,
00159 int lower_bckgdr ,
00160 int higher_bckgdr ,
00161 int binning ,
00162 int offset = 0) ;
00163
00164 double *get_histo_goodBins_minus_bckgrd_array(int histo_num ,
00165 int lower_bckgrd ,
00166 int higher_bckgrd ,
00167 int binning) ;
00168
00169 vector<double> get_histo_goodBins_minus_bckgrd_vector(int histo_num ,
00170 int lower_bckgrd ,
00171 int higher_bckgrd ,
00172 int binning) ;
00173
00174 double *get_asymmetry_array(int histo_num_plus,
00175 int histo_num_minus,
00176 double alpha_param,
00177 int binning,
00178 int lower_bckgrd_plus,
00179 int higher_bckgrd_plus,
00180 int lower_bckgrd_minus,
00181 int higher_bckgrd_minus ,
00182 int offset = 0,
00183 double y_offset = 0.) ;
00184
00185 vector<double> get_asymmetry_vector(int histo_num_plus ,
00186 int histo_num_minus ,
00187 double alpha_param ,
00188 int binning ,
00189 int lower_bckgrd_plus ,
00190 int higher_bckgrd_plus ,
00191 int lower_bckgrd_minus ,
00192 int higher_bckgrd_minus ,
00193 int offset = 0 ,
00194 double y_offset = 0.) ;
00195
00196 double *get_error_asymmetry_array(int histo_num_plus ,
00197 int histo_num_minus ,
00198 double alpha_param ,
00199 int binning ,
00200 int lower_bckgrd_plus ,
00201 int higher_bckgrd_plus ,
00202 int lower_bckgrd_minus ,
00203 int higher_bckgrd_minus ,
00204 int offset = 0) ;
00205
00206 vector<double> get_error_asymmetry_vector(int histo_num_plus ,
00207 int histo_num_minus ,
00208 double alpha_param ,
00209 int binning ,
00210 int lower_bckgrd_plus ,
00211 int higher_bckgrd_plus ,
00212 int lower_bckgrd_minus ,
00213 int higher_bckgrd_minus ,
00214 int offset = 0) ;
00215
00216 double *get_asymmetry_goodBins_array(int histo_num_plus ,
00217 int histo_num_minus ,
00218 double alpha_param ,
00219 int binning ,
00220 int lower_bckgrd_plus ,
00221 int higher_bckgrd_plus ,
00222 int lower_bckgrd_minus ,
00223 int higher_bckgrd_minus) ;
00224
00225 vector<double> get_asymmetry_goodBins_vector(int histo_num_plus ,
00226 int histo_num_minus ,
00227 double alpha_param ,
00228 int binning ,
00229 int lower_bckgrd_plus ,
00230 int higher_bckgrd_plus ,
00231 int lower_bckgrd_minus ,
00232 int higher_bckgrd_minus) ;
00233
00234 double *get_error_asymmetry_goodBins_array(int histo_num_plus ,
00235 int histo_num_minus ,
00236 double alpha_param ,
00237 int binning ,
00238 int lower_bckgrd_plus ,
00239 int higher_bckgrd_plus ,
00240 int lower_bckgrd_minus ,
00241 int higher_bckgrd_minus) ;
00242
00243 vector<double> get_error_asymmetry_goodBins_vector(int histo_num_plus ,
00244 int histo_num_minus ,
00245 double alpha_param ,
00246 int binning ,
00247 int lower_bckgrd_plus ,
00248 int higher_bckgrd_plus ,
00249 int lower_bckgrd_minus ,
00250 int higher_bckgrd_minus) ;
00251
00252
00253 double get_binWidth_ps();
00254 double get_binWidth_ns();
00255 double get_binWidth_us();
00256
00257 int get_histoLength_bin();
00258
00259 int get_numberHisto_int();
00260
00261 string get_nameHisto(int i) ;
00262 vector<string> get_histoNames_vector();
00263
00264 long get_eventsHisto_long(int i);
00265 vector<long> get_eventsHisto_vector();
00266
00267 long get_totalEvents_long();
00268
00269 int get_numberScaler_int();
00270 vector<long> get_scalers_vector() ;
00271 vector<string> get_scalersNames_vector() ;
00272
00273 int get_default_binning() ;
00274 int get_t0_int(int i) ;
00275 vector<int> get_t0_vector() ;
00276 double get_t0_double(int i) ;
00277
00278 int get_max_t0_int () ;
00279 int get_max_2_t0_int (int k, int j) ;
00280 int get_min_t0_int () ;
00281 int get_min_2_t0_int (int k, int j) ;
00282
00283 int get_firstGood_int(int i) ;
00284 vector<int> get_firstGood_vector() ;
00285 int put_firstGood_int(int i, int j) ;
00286
00287 int get_lastGood_int(int i) ;
00288 vector<int> get_lastGood_vector() ;
00289 int put_lastGood_int(int i, int j) ;
00290
00291 int get_max_lastGood_int () ;
00292 int get_max_2_lastGood_int (int k, int j) ;
00293 int get_min_lastGood_int () ;
00294 int get_min_2_lastGood_int (int k, int j) ;
00295
00296 int get_runNumber_int() ;
00297 int put_runNumber_int(int i) ;
00298
00299 string get_sample() ;
00300 string get_field() ;
00301 string get_orient() ;
00302 string get_temp() ;
00303 string get_comment() ;
00304
00305 vector<string> get_timeStart_vector() ;
00306 vector<string> get_timeStop_vector() ;
00307
00308 int get_numberTemperature_int() ;
00309 vector<double> get_temperatures_vector() ;
00310 vector<double> get_devTemperatures_vector() ;
00311
00312 private:
00313
00314 int tmax(int x, int y) ;
00315 int tmin(int x, int y) ;
00316
00317 } ;
00318 #endif
00319
00320
00321