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 #include <iostream>
00029 using namespace std ;
00030 #include <fstream>
00031 #include <cstring>
00032 #include <cmath>
00033
00034 #include "MuSR_td_PSI_bin.h"
00035
00036
00037
00038
00039
00040
00044 MuSR_td_PSI_bin::MuSR_td_PSI_bin()
00045 {
00046 histo = NULL;
00047 Clear();
00048 }
00049
00050
00051
00052
00053
00054
00058 MuSR_td_PSI_bin::~MuSR_td_PSI_bin()
00059 {
00060
00061 Clear();
00062
00063 }
00064
00065
00066
00067
00068
00069
00085 int MuSR_td_PSI_bin::read(const char * fileName)
00086 {
00087 ifstream file_name ;
00088
00089 Clear();
00090
00091 filename = fileName;
00092
00093 file_name.open(fileName, ios_base::binary);
00094 if (file_name.fail())
00095 {
00096 readstatus = "ERROR Open "+filename+" failed!";
00097 return 1;
00098 }
00099
00100 char *buffer_file = new char[3] ;
00101 if (!buffer_file)
00102 {
00103 readstatus = "ERROR Allocating data buffer";
00104 return 3;
00105 }
00106
00107 file_name.read(buffer_file, 2) ;
00108
00109 if (file_name.fail())
00110 {
00111 file_name.close();
00112 delete [] buffer_file;
00113 readstatus = "ERROR Reading "+filename+" header failed!";
00114 return 1;
00115 }
00116
00117 strncpy(format_id,buffer_file,2);
00118 format_id[2] = '\0' ;
00119
00120 file_name.close();
00121 delete [] buffer_file;
00122
00123
00124 if (strncmp(format_id,"1N",2) == 0)
00125 {
00126 return readbin(fileName);
00127 }
00128
00129
00130 else if ((strncmp(format_id,"M3",2) == 0) ||(strncmp(format_id,"T4",2) == 0) ||
00131 (strncmp(format_id,"T5",2) == 0))
00132 {
00133 return readmdu(fileName);
00134 }
00135 else
00136 {
00137 readstatus = "ERROR Unknown file format in "+filename+"!";
00138 return 2 ;
00139 }
00140
00141 }
00142
00143
00144
00145
00146
00147
00148
00149 #if ((defined(__DECC) || defined(__VAXC)) && !defined(unix) && !defined(OS_OSF1))
00150
00151 #if defined (__ALPHA)
00152 typedef short int Int16;
00153 typedef int Int32;
00154 #else
00155 typedef int Int16;
00156 typedef long int Int32;
00157 #endif
00158
00159
00160 #elif defined (__osf__)
00161
00162 #if defined (__alpha)
00163 typedef short int Int16;
00164 typedef int Int32;
00165 #else
00166 typedef int Int16;
00167 typedef long int Int32;
00168 #endif
00169
00170 #else
00171
00172
00173 #if (defined(_WIN32) || defined(__linux__) || defined(_WIN32GCC))
00174 typedef short Int16;
00175 typedef int Int32;
00176 #else
00177 typedef int Int16;
00178 typedef long int Int32;
00179 #endif
00180
00181 #endif
00182
00183 typedef float Float32;
00184
00185
00186
00202 int MuSR_td_PSI_bin::readbin(const char * fileName)
00203 {
00204 ifstream file_name ;
00205 Int16 *dum_Int16 ;
00206 Int32 *dum_Int32 ;
00207 Float32 *dum_Float32 ;
00208 int i ;
00209
00210 Int16 tdc_resolution ;
00211 Int16 tdc_overflow ;
00212
00213 Float32 mon_low[4] ;
00214 Float32 mon_high[4] ;
00215 Int32 mon_num_events ;
00216 char mon_dev[13] ;
00217
00218 Int16 num_data_records_file ;
00219 Int16 length_data_records_bins ;
00220 Int16 num_data_records_histo ;
00221
00222 Int32 period_save ;
00223 Int32 period_mon ;
00224
00225 Clear();
00226
00227 if (sizeof(Int16) != 2)
00228 {
00229 readstatus = "ERROR Size of Int16 data type is not 2 bytes!";
00230 return 1;
00231 }
00232
00233 if (sizeof(Int32) != 4)
00234 {
00235 readstatus = "ERROR Sizeof Int32 data type is not 4 bytes";
00236 return 1;
00237 }
00238
00239 if (sizeof(Float32) != 4)
00240 {
00241 readstatus = "ERROR Sizeof Float32 data type is not 4 bytes";
00242 return 1;
00243 }
00244
00245 filename = fileName;
00246
00247 file_name.open(fileName, ios_base::binary);
00248 if (file_name.fail())
00249 {
00250 readstatus = "ERROR Open "+filename+" failed!";
00251 return 1;
00252 }
00253
00254 char *buffer_file = new char[1024] ;
00255 if (!buffer_file)
00256 {
00257 readstatus = "ERROR Allocating buffer to read header failed!";
00258 return 3;
00259 }
00260
00261 file_name.read(buffer_file, 1024) ;
00262 if (file_name.fail())
00263 {
00264 file_name.close();
00265 delete [] buffer_file;
00266 readstatus = "ERROR Reading "+filename+" header failed!";
00267 return 1;
00268 }
00269
00270 strncpy(format_id,buffer_file,2);
00271 format_id[2] = '\0' ;
00272
00273 if (strcmp(format_id,"1N") != 0)
00274 {
00275 file_name.close();
00276 delete [] buffer_file;
00277 readstatus = "ERROR Unknown file format in "+filename+"!";
00278 return 2 ;
00279 }
00280
00281 dum_Int16 = (Int16 *) &buffer_file[2] ;
00282 tdc_resolution = *dum_Int16 ;
00283
00284 dum_Int16 = (Int16 *) &buffer_file[4] ;
00285 tdc_overflow = *dum_Int16 ;
00286
00287 dum_Int16 = (Int16 *) &buffer_file[6] ;
00288 num_run = *dum_Int16 ;
00289
00290 dum_Int16 = (Int16 *) &buffer_file[28] ;
00291 length_histo = *dum_Int16 ;
00292
00293 dum_Int16 = (Int16 *) &buffer_file[30] ;
00294 number_histo = *dum_Int16 ;
00295
00296 strncpy(sample,buffer_file+138,10) ;
00297 sample[10] = '\0' ;
00298
00299 strncpy(temp,buffer_file+148,10) ;
00300 temp[10] = '\0' ;
00301
00302 strncpy(field,buffer_file+158,10) ;
00303 field[10] = '\0' ;
00304
00305 strncpy(orient,buffer_file+168,10) ;
00306 orient[10] = '\0' ;
00307
00308 strncpy(comment,buffer_file+860,62) ;
00309 comment[62] = '\0' ;
00310
00311 strncpy(date_start,buffer_file+218,9) ;
00312 date_start[9] = '\0' ;
00313
00314 strncpy(date_stop,buffer_file+227,9) ;
00315 date_stop[9] = '\0' ;
00316
00317 strncpy(time_start,buffer_file+236,8) ;
00318 time_start[8] = '\0' ;
00319
00320 strncpy(time_stop,buffer_file+244,8) ;
00321 time_stop[8] = '\0' ;
00322
00323 dum_Int32 = (Int32 *) &buffer_file[424] ;
00324 total_events = *dum_Int32 ;
00325
00326 for (i=0; i<=15; i++)
00327 {
00328 strncpy(labels_histo[i],buffer_file+948+i*4,4) ;
00329 labels_histo[i][4] = '\0' ;
00330
00331 dum_Int32 = (Int32 *) &buffer_file[296+i*4] ;
00332 events_per_histo[i] = *dum_Int32 ;
00333
00334 dum_Int16 = (Int16 *) &buffer_file[458+i*2] ;
00335 integer_t0[i] = *dum_Int16 ;
00336
00337 dum_Int16 = (Int16 *) &buffer_file[490+i*2] ;
00338 first_good[i] = *dum_Int16 ;
00339
00340 dum_Int16 = (Int16 *) &buffer_file[522+i*2] ;
00341 last_good[i] = *dum_Int16 ;
00342 }
00343
00344 for (i=0; i<=15; i++)
00345 {
00346 dum_Float32 = (Float32 *) &buffer_file[792+i*4] ;
00347 real_t0[i] = *dum_Float32 ;
00348 }
00349
00350 number_scaler = 18;
00351
00352 for (i=0; i<=5; i++)
00353 {
00354 dum_Int32 = (Int32 *) &buffer_file[670+i*4] ;
00355 scalers[i] = *dum_Int32 ;
00356
00357 strncpy(labels_scalers[i],buffer_file+924+i*4,4) ;
00358 labels_scalers[i][4] = '\0' ;
00359 }
00360
00361 for (i=6; i<number_scaler; i++)
00362 {
00363 dum_Int32 = (Int32 *) &buffer_file[360+(i-6)*4] ;
00364 scalers[i] = *dum_Int32 ;
00365
00366 strncpy(labels_scalers[i],buffer_file+554+(i-6)*4,4) ;
00367 labels_scalers[i][4] = '\0' ;
00368 }
00369
00370 dum_Float32 = (Float32 *) &buffer_file[1012] ;
00371 bin_width = *dum_Float32 ;
00372
00373 if (bin_width == 0.)
00374 {
00375 bin_width=(625.E-6)/8.*pow(Float32(2.),Float32(tdc_resolution)) ;
00376 }
00377
00378 default_binning = 1;
00379
00380 number_temper = 4;
00381 for (i=0; i< number_temper; i++)
00382 {
00383 dum_Float32 = (Float32 *) &buffer_file[716+i*4] ;
00384 temper[i] = *dum_Float32 ;
00385
00386 dum_Float32 = (Float32 *) &buffer_file[738+i*4] ;
00387 temp_deviation[i] = *dum_Float32 ;
00388
00389 dum_Float32 = (Float32 *) &buffer_file[72+i*4] ;
00390 mon_low[i] = *dum_Float32 ;
00391
00392 dum_Float32 = (Float32 *) &buffer_file[88+i*4] ;
00393 mon_high[i] = *dum_Float32 ;
00394 }
00395
00396 dum_Int32 = (Int32 *) &buffer_file[712] ;
00397 mon_num_events = *dum_Int32 ;
00398 strncpy(mon_dev,buffer_file+60,12) ;
00399 mon_dev[12] = '\0' ;
00400
00401 dum_Int16 = (Int16 *) &buffer_file[128] ;
00402 num_data_records_file = *dum_Int16 ;
00403
00404 dum_Int16 = (Int16 *) &buffer_file[130] ;
00405 length_data_records_bins = *dum_Int16 ;
00406
00407 dum_Int16 = (Int16 *) &buffer_file[132] ;
00408 num_data_records_histo = *dum_Int16 ;
00409
00410 dum_Int16 = (Int16 *) &buffer_file[134] ;
00411 if (*dum_Int16 != 1)
00412 {
00413 cout << "ERROR number of histograms/record not equals 1!"
00414 << " Required algorithm is not implemented!" << endl;
00415 delete [] buffer_file ;
00416 file_name.close();
00417 readstatus = "ERROR Algorithm to read multiple histograms in one block -"
00418 " necessary to read " + filename + " - is not implemented!";
00419 return 4;
00420 }
00421
00422 dum_Int32 = (Int32 *) &buffer_file[654] ;
00423 period_save = *dum_Int32 ;
00424
00425 dum_Int32 = (Int32 *) &buffer_file[658] ;
00426 period_mon = *dum_Int32 ;
00427
00428 if (buffer_file) delete [] buffer_file ;
00429
00430 if (number_histo <= 0)
00431 {
00432 file_name.close();
00433 readstatus = "ERROR Less than 1 histogram in " + filename ;
00434 return 5;
00435 }
00436
00437
00438 histo = new int* [int(number_histo)];
00439 if (!histo)
00440 {
00441 Clear();
00442 file_name.close();
00443 readstatus = "ERROR Allocating histo[] failed!";
00444 return 3;
00445 }
00446
00447 for (i=0; i<number_histo; i++)
00448 {
00449 histo[i] = new int [length_histo];
00450
00451 if (!histo[i])
00452 {
00453 for (int j=0; j<i; j++)
00454 delete histo[j];
00455 delete [] histo;
00456 histo = NULL;
00457 Clear();
00458 file_name.close();
00459 readstatus = "ERROR Allocating histo[] failed!";
00460 return 3;
00461 }
00462 }
00463
00464 char *buffer_file_histo = new char[Int32(num_data_records_file)
00465 *Int32(length_data_records_bins)*4];
00466 if (!buffer_file_histo)
00467 {
00468 Clear();
00469 file_name.close();
00470 readstatus = "ERROR Allocating buffer to read histogram failed!";
00471 return 3;
00472 }
00473 file_name.seekg(1024, ios_base::beg) ;
00474
00475 file_name.read(buffer_file_histo, Int32(num_data_records_file)
00476 *Int32(length_data_records_bins)*4) ;
00477 if (file_name.fail())
00478 {
00479 Clear();
00480 delete [] buffer_file_histo;
00481 file_name.close();
00482 readstatus = "ERROR Reading data in "+filename+" failed!";
00483 return 6;
00484 }
00485 file_name.close();
00486
00487
00488 vector<double> dummy_vector ;
00489
00490 histos_vector.clear();
00491 for (i=0; i<number_histo; i++)
00492 {
00493 dummy_vector.clear() ;
00494 for (int j=0; j<length_histo; j++)
00495 {
00496 dum_Int32 = (Int32 *) &buffer_file_histo[(i*Int32(num_data_records_histo)*
00497 Int32(length_data_records_bins)+j)*sizeof(Int32)];
00498 histo[i][j]= *dum_Int32 ;
00499 dummy_vector.push_back(double(histo[i][j])) ;
00500 }
00501 histos_vector.push_back(dummy_vector) ;
00502 }
00503
00504 if (buffer_file_histo) delete [] buffer_file_histo;
00505
00506 readstatus = "SUCCESS";
00507 readingok = true;
00508
00509 return 0;
00510 }
00511
00512
00513
00514
00515
00516 #define DATESTR 12
00517 #define TIMESTR 9
00518
00519
00520 #define TITLESTR 40
00521 #define SUBTITLESTR 62
00522 #define DATAFORMATSTR 20
00523 #define DETECTLISTSTR 200
00524 #define TEMPLISTSTR 50
00525
00526
00527 #define PTAMODE_NONE 0
00528 #define PTAMODE_NORMAL 1
00529 #define PTAMODE_CLOCK 2
00530
00531 #define PTAMODE_ECHO 4
00532
00533
00534 #define PTATAGC_NONE 'N'
00535 #define PTATAGC_MUON 'M'
00536 #define PTATAGC_POSITRON 'P'
00537 #define PTATAGC_CLOCK 'C'
00538 #define PTATAGC_ECHO 'E'
00539 #define PTATAGC_VETO 'V'
00540 #define PTATAGC_UNKNOWN 'U'
00541
00542
00543 #define PTAMAXTAGS 16
00544 #define TDCMAXTAGS16 16
00545 #define TDCMAXTAGS32 32
00546
00547 #define MAXTAGSTR 12
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576 typedef struct _FeFileHeaderRec {
00577 char FmtId;
00578 char FmtVersion;
00579 char StartDate[DATESTR];
00580 char StartTime[TIMESTR];
00581 char EndDate[DATESTR];
00582 char EndTime[TIMESTR];
00583 Int32 RunNumber;
00584 Int32 FileVersion;
00585
00586
00587 char RunTitle[TITLESTR+1];
00588 char RunSubTitle[SUBTITLESTR+1];
00589 char DataFormat[DATAFORMATSTR];
00590 Int32 HistoResolution;
00591
00592 Int32 BinOffset;
00593 Int32 BinsPerHistogram;
00594 Int32 NumberOfDetectors;
00595 char DetectorNumberList[DETECTLISTSTR];
00596
00597
00598 char MeanTemp[TEMPLISTSTR];
00599 char TempDev[TEMPLISTSTR];
00600 } FeFileHeaderRec, *FeFileHeaderPtr;
00601
00602
00603 typedef struct _pTAFileHeaderRec {
00604 FeFileHeaderRec Header;
00605 Int32 BinSize;
00606 Int32 NumBytesHeader;
00607 Int32 NumBytesSettings;
00608 Int32 NumBytesTag;
00609 Int32 NumBytesStatistics;
00610 } pTAFileHeaderRec, *pTAFileHeaderPtr;
00611
00612
00613 typedef struct _pTATagRec {
00614 char Label[MAXTAGSTR];
00615 char Type;
00616
00617
00618 Int32 Rawminps;
00619 Int32 Rawmaxps;
00620 Int32 Rawminb;
00621 Int32 Rawmaxb;
00622
00623
00624 Int32 Histominps;
00625 Int32 Histomaxps;
00626 Int32 Histominb;
00627 Int32 Histomaxb;
00628 Int32 t0b;
00629 Int32 tfb;
00630 Int32 tlb;
00631 } pTATagRec, *pTATagPtr;
00632
00633
00634 typedef struct _pTASettingsRec {
00635 Int32 mode;
00636 Int32 preps;
00637 Int32 posps;
00638 Int32 preb;
00639 Int32 posb;
00640 Int32 ecsps;
00641 Int32 ectps;
00642 Int32 ecsb;
00643 Int32 ectb;
00644 Int32 timespan;
00645 Int32 minrate;
00646 Int32 eortag;
00647 Int32 eorlim;
00648 pTATagRec tag[PTAMAXTAGS];
00649 } pTASettingsRec, *pTASettingsPtr;
00650
00651
00652 typedef struct _pTATDCSettingsRec {
00653 Int32 mode;
00654 Int32 preps;
00655 Int32 posps;
00656 Int32 preb;
00657 Int32 posb;
00658 Int32 ecsps;
00659 Int32 ectps;
00660 Int32 ecsb;
00661 Int32 ectb;
00662 Int32 resolutioncode;
00663 Int32 minrate;
00664 Int32 eortag;
00665 Int32 eorlim;
00666 pTATagRec tag[TDCMAXTAGS16];
00667 } pTATDCSettingsRec, *pTATDCSettingsPtr;
00668
00669
00670 typedef struct _pTATDC32SettingsRec {
00671 Int32 mode;
00672 Int32 preps;
00673 Int32 posps;
00674 Int32 preb;
00675 Int32 posb;
00676 Int32 ecsps;
00677 Int32 ectps;
00678 Int32 ecsb;
00679 Int32 ectb;
00680 Int32 resolutioncode;
00681 Int32 minrate;
00682 Int32 eortag;
00683 Int32 eorlim;
00684 pTATagRec tag[TDCMAXTAGS32];
00685 } pTATDC32SettingsRec, *pTATDC32SettingsPtr;
00686
00687
00688 typedef struct _pTAStatisticRec {
00689 Int32 time;
00690 Int32 ESum;
00691 Int32 EMuon;
00692 Int32 EPositron;
00693 Int32 EClock;
00694 Int32 EEcho;
00695 Int32 EVeto;
00696 Int32 EUnknown;
00697 Int32 EMMPileup;
00698 Int32 EPrePileup;
00699 Int32 EPostPileup;
00700 Int32 EHOverflow;
00701 Int32 EDoublePositron;
00702 Int32 EAccepted;
00703 Int32 TagScaler[PTAMAXTAGS];
00704 Int32 HistogramScaler[PTAMAXTAGS];
00705 Int32 EOverFlowBits;
00706 Int32 TSOverFlowBits;
00707 Int32 HSOverFlowBits;
00708 Int32 HOverFlowBits;
00709 } pTAStatisticRec, *pTAStatisticPtr;
00710
00711
00712 typedef struct _pTATDCStatisticRec {
00713 Int32 time;
00714 Int32 ESum;
00715 Int32 EMuon;
00716 Int32 EPositron;
00717 Int32 EClock;
00718 Int32 EEcho;
00719 Int32 EVeto;
00720 Int32 EUnknown;
00721 Int32 EMMPileup;
00722 Int32 EPrePileup;
00723 Int32 EPostPileup;
00724 Int32 EHOverflow;
00725 Int32 EDoublePositron;
00726 Int32 EAccepted;
00727 Int32 TagScaler[TDCMAXTAGS16];
00728 Int32 HistogramScaler[TDCMAXTAGS16];
00729 Int32 EOverFlowBits;
00730 Int32 TSOverFlowBits;
00731 Int32 HSOverFlowBits;
00732 Int32 HOverFlowBits;
00733 } pTATDCStatisticRec, *pTATDCStatisticPtr;
00734
00735
00736 typedef struct _pTATDC32StatisticRec {
00737 Int32 time;
00738 Int32 ESum;
00739 Int32 EMuon;
00740 Int32 EPositron;
00741 Int32 EClock;
00742 Int32 EEcho;
00743 Int32 EVeto;
00744 Int32 EUnknown;
00745 Int32 EMMPileup;
00746 Int32 EPrePileup;
00747 Int32 EPostPileup;
00748 Int32 EHOverflow;
00749 Int32 EDoublePositron;
00750 Int32 EAccepted;
00751 Int32 TagScaler[TDCMAXTAGS32];
00752 Int32 HistogramScaler[TDCMAXTAGS32];
00753 Int32 EOverFlowBits;
00754 Int32 TSOverFlowBits;
00755 Int32 HSOverFlowBits;
00756 Int32 HOverFlowBits;
00757 } pTATDC32StatisticRec, *pTATDC32StatisticPtr;
00758
00759
00760
00775 int MuSR_td_PSI_bin::readmdu(const char * fileName)
00776 {
00777 ifstream file_name ;
00778 int i, j ;
00779
00780 Clear();
00781
00782 if (sizeof(Int32) != 4)
00783 {
00784 readstatus = "ERROR Sizeof( Int32 ) data type is not 4 bytes";
00785 return 1;
00786 }
00787
00788 filename = fileName;
00789
00790 file_name.open(fileName, ios_base::binary);
00791 if (file_name.fail())
00792 {
00793 readstatus = "ERROR Open "+filename+" failed!";
00794 return 1;
00795 }
00796
00797 pTAFileHeaderRec gpTAfhead;
00798
00799
00800 file_name.read((char *)&gpTAfhead, sizeof gpTAfhead) ;
00801 if (file_name.fail())
00802 {
00803 file_name.close();
00804 readstatus = "ERROR Reading "+filename+" header failed!";
00805 return 1;
00806 }
00807
00808 format_id[0] = gpTAfhead.Header.FmtId;
00809 format_id[1] = gpTAfhead.Header.FmtVersion;
00810 format_id[2] = '\0' ;
00811
00812 if ((strcmp(format_id,"M3") != 0) && (strcmp(format_id,"T4") != 0) &&
00813 (strcmp(format_id,"T5") != 0))
00814 {
00815 file_name.close();
00816 readstatus = "ERROR Unknown file format in "+filename+"!";
00817 return 2 ;
00818 }
00819
00820 if (sizeof(pTAFileHeaderRec) != gpTAfhead.NumBytesHeader)
00821 {
00822 file_name.close();
00823 readstatus = "ERROR Reading "+filename+" incorrect pTAFileHeaderRec size";
00824 return 1;
00825 }
00826
00827
00828 strncpy(sample,&gpTAfhead.Header.RunTitle[0],10) ;
00829 sample[10] = '\0' ;
00830
00831 strncpy(temp, &gpTAfhead.Header.RunTitle[10],10) ;
00832 temp[10] = '\0' ;
00833
00834 strncpy(field, &gpTAfhead.Header.RunTitle[20],10) ;
00835 field[10] = '\0' ;
00836
00837 strncpy(orient,&gpTAfhead.Header.RunTitle[30],10) ;
00838 orient[10] = '\0' ;
00839
00840 strncpy(comment,&gpTAfhead.Header.RunSubTitle[0],62) ;
00841 comment[62] = '\0' ;
00842
00843 strncpy(&date_start[0],&gpTAfhead.Header.StartDate[0],7) ;
00844 strncpy(&date_start[7],&gpTAfhead.Header.StartDate[9],2) ;
00845 date_start[9] = '\0' ;
00846
00847 strncpy(&date_stop[0],&gpTAfhead.Header.EndDate[0],7) ;
00848 strncpy(&date_stop[7],&gpTAfhead.Header.EndDate[9],2) ;
00849 date_stop[9] = '\0' ;
00850
00851 strncpy(time_start,&gpTAfhead.Header.StartTime[0],8) ;
00852 time_start[8] = '\0' ;
00853
00854 strncpy(time_stop,&gpTAfhead.Header.EndTime[0],8) ;
00855 time_stop[8] = '\0' ;
00856
00857 num_run = gpTAfhead.Header.RunNumber;
00858
00859 if (sizeof(pTATagRec) != gpTAfhead.NumBytesTag)
00860 {
00861 file_name.close();
00862 readstatus = "ERROR Reading "+filename+" incorrect pTATagRec size";
00863 return 1;
00864 }
00865
00866 #ifdef MIDEBUG1
00867 cout << "Header.MeanTemp = " << gpTAfhead.Header.MeanTemp << endl;
00868 cout << "Header.TempDev = " << gpTAfhead.Header.TempDev << endl;
00869 #endif
00870
00871
00872 number_temper = sscanf(gpTAfhead.Header.TempDev,"%f %f %f %f",
00873 &temp_deviation[0], &temp_deviation[1], &temp_deviation[2],
00874 &temp_deviation[3]);
00875
00876
00877 for (i=number_temper; i<MAXTEMPER; i++)
00878 temp_deviation[i] = 0.f;
00879
00880
00881 number_temper = sscanf(gpTAfhead.Header.MeanTemp,"%f %f %f %f",
00882 &temper[0], &temper[1], &temper[2], &temper[3]);
00883
00884
00885 for (i=number_temper; i<MAXTEMPER; i++)
00886 {
00887 temper[i] = 0.f;
00888 temp_deviation[i] = 0.f;
00889 }
00890
00891 #ifdef MIDEBUG1
00892 cout << "Header.DataFormat = " << gpTAfhead.Header.DataFormat << endl;
00893 cout << "Header.HistoResolution = " << gpTAfhead.Header.HistoResolution << endl;
00894 cout << "Header.BinOffset = " << gpTAfhead.Header.BinOffset << endl;
00895 cout << "Header.BinsPerHistogram = " << gpTAfhead.Header.BinsPerHistogram << endl;
00896 cout << "Header.NumberOfDetectors = " << gpTAfhead.Header.NumberOfDetectors << endl;
00897 cout << "Header.DetectorNumberList = " << gpTAfhead.Header.DetectorNumberList << endl;
00898 #endif
00899
00900
00901
00902 bool selected[MAXHISTO];
00903
00904 for (i=0; i < MAXHISTO; i++)
00905 selected[i] = false;
00906
00907 for (i=0,j=0; i <= (int)strlen(gpTAfhead.Header.DetectorNumberList); i++) {
00908 if ((gpTAfhead.Header.DetectorNumberList[i] == ' ') ||
00909 (gpTAfhead.Header.DetectorNumberList[i] == '\0')) {
00910 int it;
00911 if (sscanf(&gpTAfhead.Header.DetectorNumberList[j],"%d",&it) == 1) {
00912 j = i+1;
00913 if ((it >= 0) && (it < MAXHISTO)) {
00914 selected[it] = true;
00915 #ifdef MIDEBUG1
00916 cout << "Histogram " << it << " is selected " << endl;
00917 #endif
00918 } else {
00919 cout << "error " << it << " is out of range |0 - " << MAXHISTO-1 << "|"
00920 <<endl;
00921 }
00922 } else {
00923 cout << "error reading " << &gpTAfhead.Header.DetectorNumberList[j] << endl;
00924 }
00925 }
00926 }
00927
00928 int tothist = 0;
00929 int resolutionfactor = 1;
00930
00931
00932 if (strcmp(format_id,"M3") == 0)
00933 {
00934
00935 if (sizeof(pTASettingsRec) != gpTAfhead.NumBytesSettings)
00936 {
00937 file_name.close();
00938 readstatus = "ERROR Reading "+filename+" incorrect pTASettingsRec size";
00939 return 1;
00940 }
00941
00942 if (sizeof(pTAStatisticRec) != gpTAfhead.NumBytesStatistics)
00943 {
00944 file_name.close();
00945 readstatus = "ERROR Reading "+filename+" incorrect pTAStatisticRec size";
00946 return 1;
00947 }
00948
00949 pTASettingsRec gpTAsetpta;
00950 pTAStatisticRec gpTAstattotpta;
00951
00952 tothist = PTAMAXTAGS;
00953
00954 file_name.read((char *)&gpTAsetpta, sizeof gpTAsetpta);
00955 if (file_name.fail())
00956 {
00957 file_name.close();
00958 readstatus = "ERROR Reading "+filename+" settings failed!";
00959 return 1;
00960 }
00961
00962
00963 file_name.read((char *)&gpTAstattotpta, sizeof gpTAstattotpta) ;
00964 if (file_name.fail())
00965 {
00966 file_name.close();
00967 readstatus = "ERROR Reading "+filename+" statistics failed!";
00968 return 1;
00969 }
00970
00971 number_scaler = PTAMAXTAGS;
00972 for (i=0; i < number_scaler; i++)
00973 {
00974 strncpy(labels_scalers[i],gpTAsetpta.tag[i].Label,MAXLABELSIZE);
00975 labels_scalers[i][MAXLABELSIZE-1] = '\0';
00976
00977 scalers[i] = gpTAstattotpta.TagScaler[i];
00978 }
00979
00980 int timespan;
00981
00982 resolutionfactor = 1;
00983 timespan = gpTAfhead.Header.HistoResolution;
00984
00985 if (gpTAsetpta.timespan == 11)
00986 bin_width = 0.000625;
00987 else if (gpTAsetpta.timespan == 10)
00988 bin_width = 0.0003125;
00989 else if (gpTAsetpta.timespan == 9)
00990 bin_width = 0.00015625;
00991 else if (gpTAsetpta.timespan == 8)
00992 bin_width = 0.000078125;
00993 else if (gpTAsetpta.timespan == 7)
00994 bin_width = 0.0000390625;
00995 else if (gpTAsetpta.timespan == 6)
00996 bin_width = 0.00001953125;
00997 else
00998 {
00999 file_name.close();
01000 readstatus = "ERROR "+filename+" settings resolution code failed!";
01001 return 1;
01002 }
01003
01004 if (timespan+8-gpTAsetpta.timespan < 0)
01005 {
01006
01007 } else {
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020 for (i=0; i < timespan+8-gpTAsetpta.timespan; i++)
01021 resolutionfactor *= 2;
01022 }
01023
01024 length_histo = 0;
01025 number_histo = 0;
01026 for (i=0; i<tothist; i++)
01027 {
01028
01029 if (gpTAsetpta.tag[i].Type == PTATAGC_POSITRON)
01030 {
01031 int nbins;
01032
01033 #ifdef MIDEBUG1
01034 cout << "Tag[" << i << "] Histomin = " << gpTAsetpta.tag[i].Histominb
01035 << " Histomax = " << gpTAsetpta.tag[i].Histomaxb << endl;
01036 #endif
01037
01038 if ((nbins=(gpTAsetpta.tag[i].Histomaxb-gpTAsetpta.tag[i].Histominb + 1))>1)
01039 {
01040
01041
01042 if (selected[i])
01043 {
01044
01045 if (number_histo == 0)
01046 length_histo = nbins+gpTAsetpta.tag[i].Histominb;
01047
01048 else if (length_histo != nbins+gpTAsetpta.tag[i].Histominb)
01049 {
01050 cout << "Different histogram lengths!" << endl;
01051 }
01052 number_histo++;
01053 }
01054 }
01055 }
01056 }
01057
01058
01059 if (number_histo != gpTAfhead.Header.NumberOfDetectors)
01060 cout << "Number of found histos " << number_histo << " and number in header "
01061 << gpTAfhead.Header.NumberOfDetectors << " differ!" << endl;
01062
01063
01064 if (length_histo > 0) length_histo -= 1;
01065
01066 }
01067 else if (strcmp(format_id,"T4") == 0)
01068 {
01069
01070 if (sizeof(pTATDCSettingsRec) != gpTAfhead.NumBytesSettings)
01071 {
01072 file_name.close();
01073 readstatus = "ERROR Reading "+filename+" incorrect pTATDCSettingsRec size";
01074 return 1;
01075 }
01076
01077 if (sizeof(pTATDCStatisticRec) != gpTAfhead.NumBytesStatistics)
01078 {
01079 file_name.close();
01080 readstatus = "ERROR Reading "+filename+" incorrect pTATDCStatisticRec size";
01081 return 1;
01082 }
01083
01084 pTATDCSettingsRec gpTAsettdc;
01085 pTATDCStatisticRec gpTAstattottdc;
01086
01087 tothist = TDCMAXTAGS16;
01088
01089 file_name.read((char *)&gpTAsettdc, sizeof gpTAsettdc);
01090 if (file_name.fail())
01091 {
01092 file_name.close();
01093 readstatus = "ERROR Reading "+filename+" settings failed!";
01094 return 1;
01095 }
01096
01097 file_name.read((char *)&gpTAstattottdc, sizeof gpTAstattottdc) ;
01098 if (file_name.fail())
01099 {
01100 file_name.close();
01101 readstatus = "ERROR Reading "+filename+" statistics failed!";
01102 return 1;
01103 }
01104
01105 number_scaler = TDCMAXTAGS16;
01106 for (i=0; i < number_scaler; i++)
01107 {
01108 strncpy(labels_scalers[i],gpTAsettdc.tag[i].Label,MAXLABELSIZE);
01109 labels_scalers[i][MAXLABELSIZE-1] = '\0';
01110
01111 scalers[i] = gpTAstattottdc.TagScaler[i];
01112 }
01113
01114 resolutionfactor = gpTAfhead.Header.HistoResolution;
01115 if (gpTAsettdc.resolutioncode == 25)
01116 bin_width = 0.0000244140625;
01117 else if (gpTAsettdc.resolutioncode == 100)
01118 bin_width = 0.00009765625;
01119 else if (gpTAsettdc.resolutioncode == 200)
01120 bin_width = 0.0001953125;
01121 else if (gpTAsettdc.resolutioncode == 800)
01122 bin_width = 0.0007812500;
01123 else
01124 {
01125 file_name.close();
01126 readstatus = "ERROR "+filename+" settings resolution code failed!";
01127 return 1;
01128 }
01129
01130 length_histo = 0;
01131 number_histo = 0;
01132 for (i=0; i<tothist; i++)
01133 {
01134
01135 if (gpTAsettdc.tag[i].Type == PTATAGC_POSITRON)
01136 {
01137 int nbins;
01138
01139 #ifdef MIDEBUG1
01140 cout << "Tag[" << i << "] Histomin = " << gpTAsettdc.tag[i].Histominb
01141 << " Histomax = " << gpTAsettdc.tag[i].Histomaxb << endl;
01142 #endif
01143
01144 if ((nbins=(gpTAsettdc.tag[i].Histomaxb-gpTAsettdc.tag[i].Histominb + 1))>1)
01145 {
01146
01147 if (number_histo == 0)
01148 length_histo = nbins+gpTAsettdc.tag[i].Histominb;
01149
01150 else if (length_histo != nbins+gpTAsettdc.tag[i].Histominb)
01151 {
01152 cout << "Different histogram lengths!" << endl;
01153 }
01154 number_histo++;
01155 }
01156 }
01157 }
01158
01159 }
01160 else if (strcmp(format_id,"T5") == 0)
01161 {
01162
01163 if (sizeof(pTATDC32SettingsRec) != gpTAfhead.NumBytesSettings)
01164 {
01165 file_name.close();
01166 readstatus = "ERROR Reading "+filename+" incorrect pTATDC32SettingsRec size";
01167 return 1;
01168 }
01169
01170 if (sizeof(pTATDC32StatisticRec) != gpTAfhead.NumBytesStatistics)
01171 {
01172 file_name.close();
01173 readstatus = "ERROR Reading "+filename+" incorrect pTATDC32StatisticRec size";
01174 return 1;
01175 }
01176
01177 pTATDC32SettingsRec gpTAsettdc32;
01178 pTATDC32StatisticRec gpTAstattottdc32;
01179
01180 tothist = TDCMAXTAGS32;
01181
01182
01183 file_name.read((char *)&gpTAsettdc32, sizeof gpTAsettdc32) ;
01184 if (file_name.fail())
01185 {
01186 file_name.close();
01187 readstatus = "ERROR Reading "+filename+" settings failed!";
01188 return 1;
01189 }
01190
01191
01192 file_name.read((char *)&gpTAstattottdc32, sizeof gpTAstattottdc32) ;
01193 if (file_name.fail())
01194 {
01195 file_name.close();
01196 readstatus = "ERROR Reading "+filename+" statistics failed!";
01197 return 1;
01198 }
01199
01200 number_scaler = TDCMAXTAGS32;
01201 for (i=0; i < number_scaler; i++)
01202 {
01203 strncpy(labels_scalers[i],gpTAsettdc32.tag[i].Label,MAXLABELSIZE);
01204 labels_scalers[i][MAXLABELSIZE-1] = '\0';
01205
01206 scalers[i] = gpTAstattottdc32.TagScaler[i];
01207 }
01208
01209 resolutionfactor = gpTAfhead.Header.HistoResolution;
01210 if (gpTAsettdc32.resolutioncode == 25)
01211 bin_width = 0.0000244140625;
01212 else if (gpTAsettdc32.resolutioncode == 100)
01213 bin_width = 0.00009765625;
01214 else if (gpTAsettdc32.resolutioncode == 200)
01215 bin_width = 0.0001953125;
01216 else if (gpTAsettdc32.resolutioncode == 800)
01217 bin_width = 0.0007812500;
01218 else
01219 {
01220 file_name.close();
01221 readstatus = "ERROR "+filename+" settings resolution code failed!";
01222 return 1;
01223 }
01224
01225 length_histo = 0;
01226 number_histo = 0;
01227 for (i=0; i<tothist; i++)
01228 {
01229
01230 if (gpTAsettdc32.tag[i].Type == PTATAGC_POSITRON)
01231 {
01232 int nbins;
01233
01234 #ifdef MIDEBUG1
01235 cout << "Tag[" << i << "] Histomin = " << gpTAsettdc32.tag[i].Histominb
01236 << " Histomax = " << gpTAsettdc32.tag[i].Histomaxb << endl;
01237 #endif
01238
01239 if ((nbins=(gpTAsettdc32.tag[i].Histomaxb-gpTAsettdc32.tag[i].Histominb + 1))
01240 >1)
01241 {
01242
01243
01244 if (number_histo == 0)
01245 length_histo = nbins+gpTAsettdc32.tag[i].Histominb;
01246
01247 else if (length_histo != nbins+gpTAsettdc32.tag[i].Histominb)
01248 {
01249 cout << "Different histogram lengths!" << endl;
01250 }
01251 number_histo++;
01252 }
01253 }
01254 }
01255
01256 }
01257 else
01258 {
01259 tothist = 0;
01260 }
01261
01262
01263 if (tothist <= 0)
01264 {
01265 Clear();
01266 file_name.close();
01267 readstatus = "ERROR Less than 1 histogram in " + filename ;
01268 return 5;
01269 }
01270
01271 if (tothist > MAXHISTO)
01272 {
01273 cout << "ERROR number of histograms " << tothist << " exceedes maximum "
01274 << MAXHISTO << "! - Setting maximum number " << endl;
01275 tothist = MAXHISTO;
01276 }
01277
01278 #ifdef MIDEBUG1
01279 cout << "Number of histograms is " << number_histo << endl;
01280 cout << "Histogram length is " << length_histo << endl;
01281 cout << "Resolutionfactor for t0, fg, lg is " << resolutionfactor << endl;
01282 #endif
01283
01284 default_binning = resolutionfactor;
01285
01286
01287 histo = new int* [int(number_histo)];
01288 if (!histo)
01289 {
01290 Clear();
01291 file_name.close();
01292 readstatus = "ERROR Allocating histo failed!";
01293 return 3;
01294 }
01295
01296 for (i=0; i<number_histo; i++)
01297 {
01298 histo[i] = new int [length_histo];
01299
01300 if (!histo[i])
01301 {
01302 for (j=0; j<i; j++)
01303 delete histo[j];
01304 delete [] histo;
01305 histo = NULL;
01306 Clear();
01307 file_name.close();
01308 readstatus = "ERROR Allocating histo[] failed!";
01309 return 3;
01310 }
01311 }
01312
01313 pTATagRec tag;
01314
01315 total_events = 0;
01316
01317 for (i=0; i<number_histo; i++)
01318 events_per_histo[i] = 0;
01319
01320 int ihist = 0;
01321 Int32 *thist = NULL;
01322 vector<double> dummy_vector ;
01323
01324 histos_vector.clear();
01325 for (i=0,ihist=0; i< tothist; i++)
01326 {
01327 file_name.read((char *)&tag, sizeof tag) ;
01328 if (file_name.fail())
01329 {
01330 dummy_vector.clear() ;
01331 Clear();
01332 if (thist != NULL) delete [] thist; thist = NULL;
01333 file_name.close();
01334 readstatus = "ERROR Reading "+filename+" tag failed!";
01335 return 6;
01336 }
01337
01338 if (tag.Type == PTATAGC_POSITRON)
01339 {
01340 int nbins;
01341
01342 #ifdef MIDEBUG1
01343 cout << "Tag[" << i << "] " << tag.Label << " : Histomin = " << tag.Histominb
01344 << " Histomax = " << tag.Histomaxb << endl;
01345 #endif
01346
01347 if ((nbins=(tag.Histomaxb-tag.Histominb + 1))>1)
01348 {
01349 if (thist == NULL) thist = new Int32[nbins];
01350 if (thist == NULL)
01351 {
01352 Clear();
01353 file_name.close();
01354 readstatus = "ERROR Allocating histogram buffer failed!";
01355 return 3;
01356 }
01357
01358 file_name.read((char *)thist, sizeof(Int32)*nbins) ;
01359 if (file_name.fail())
01360 {
01361 Clear();
01362 if (thist != NULL) delete [] thist; thist = NULL;
01363 file_name.close();
01364 readstatus = "ERROR Reading "+filename+" hist failed!";
01365 return 6;
01366 }
01367
01368
01369
01370 if (selected[i] || (strcmp(format_id,"M3") != 0))
01371 {
01372
01373 if (ihist < MAXHISTO)
01374 {
01375 dummy_vector.clear() ;
01376
01377 strncpy(labels_histo[ihist],tag.Label,MAXLABELSIZE) ;
01378 labels_histo[ihist][MAXLABELSIZE-1] = '\0' ;
01379
01380
01381 if (!selected[i] && (strlen(labels_histo[ihist])<MAXLABELSIZE-2))
01382 strcat(labels_histo[ihist],"**");
01383
01384
01385
01386
01387 integer_t0[ihist] = (tag.t0b+1)*resolutionfactor -1;
01388 first_good[ihist] = (tag.tfb+1)*resolutionfactor -1;
01389 last_good[ihist] = tag.tlb*resolutionfactor ;
01390
01391
01392
01393 for (j=0; j<tag.Histominb; j++)
01394 {
01395 histo[ihist][j]= 0;
01396 dummy_vector.push_back(double(histo[ihist][j])) ;
01397 }
01398
01399 for (j=tag.Histominb; j<length_histo; j++)
01400 {
01401 histo[ihist][j]= *(thist+j-tag.Histominb);
01402 dummy_vector.push_back(double(histo[ihist][j])) ;
01403
01404
01405 if ((j >= first_good[ihist]) && (j <= last_good[ihist]))
01406 events_per_histo[ihist] += *(thist+j-tag.Histominb);
01407 }
01408 histos_vector.push_back(dummy_vector) ;
01409
01410
01411 if (selected[i])
01412 total_events += events_per_histo[ihist];
01413 }
01414 ihist++;
01415 }
01416 }
01417 }
01418 }
01419
01420 if (thist != NULL) delete [] thist; thist = NULL;
01421
01422 file_name.close();
01423
01424 readstatus = "SUCCESS";
01425 readingok = true;
01426
01427 return 0;
01428 }
01429
01430
01431
01432
01433
01440 bool MuSR_td_PSI_bin::readingOK() const {
01441 return readingok;
01442 }
01443
01444
01445
01446
01447
01454 string MuSR_td_PSI_bin::ReadStatus() const {
01455 return readstatus;
01456 }
01457
01458
01459
01460
01461
01467 string MuSR_td_PSI_bin::Filename() const {
01468 return filename;
01469 }
01470
01471
01472
01473
01474
01481 int MuSR_td_PSI_bin::get_histo_int(int histo_num, int j) {
01482 if (!readingok) return 0;
01483
01484 if (( histo_num < 0) || (histo_num >= int(number_histo)) ||
01485 (j < 0 ) || (j >= length_histo))
01486 return 0 ;
01487 #ifdef MIDEBUG
01488 cout << "histos_vector[0][0] = " << histos_vector[0][0] << endl;
01489 #endif
01490 return histo[histo_num][j];
01491 }
01492
01493
01494
01495
01496
01503 double MuSR_td_PSI_bin::get_histo(int histo_num, int j) {
01504 if (!readingok) return 0.;
01505
01506 if (( histo_num < 0) || (histo_num >= int(number_histo)) ||
01507 (j < 0 ) || (j >= length_histo))
01508 return 0. ;
01509 #ifdef MIDEBUG
01510 cout << "histos_vector[0][0] = " << histos_vector[0][0] << endl;
01511 #endif
01512 return (double)histo[histo_num][j];
01513 }
01514
01515
01516
01517
01518
01531 double * MuSR_td_PSI_bin::get_histo_array(int histo_num , int binning)
01532 {
01533 if (!readingok) return NULL;
01534
01535 if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 )
01536 return NULL ;
01537
01538 double *histo_array = new double[int(int(length_histo)/binning)] ;
01539
01540 if (!histo_array) return NULL;
01541
01542 for (int i = 0 ; i < int(int(length_histo)/binning) ; i++)
01543 {
01544 histo_array[i] = 0 ;
01545 for (int j = 0 ; j < binning ; j++)
01546 histo_array[i] += double(histo[histo_num][i*binning+j]) ;
01547 }
01548
01549 return histo_array ;
01550 }
01551
01552
01553
01554
01555
01556
01568 vector<double> MuSR_td_PSI_bin::get_histo_vector(int histo_num , int binning)
01569 {
01570 vector<double> histo_vector ;
01571
01572 if (!readingok) return histo_vector;
01573
01574 if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 )
01575 return histo_vector ;
01576
01577 for (int i = 0 ; i < int(length_histo/binning) ; i++)
01578 histo_vector.push_back(0.) ;
01579
01580 for (int i = 0 ; i < int(length_histo/binning) ; i++)
01581 {
01582 for (int j = 0 ; j < binning ; j++)
01583 histo_vector[i] += double(histo[histo_num][i*binning+j]) ;
01584 }
01585
01586 return histo_vector ;
01587 }
01588
01589
01590
01591
01592
01593
01606 vector<double> MuSR_td_PSI_bin::get_histo_vector_no0(int histo_num , int binning)
01607 {
01608 vector<double> histo_vector;
01609
01610 if (!readingok) return histo_vector;
01611
01612 if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 )
01613 return histo_vector ;
01614
01615 for (int i = 0 ; i < int(length_histo/binning) ; i++)
01616 histo_vector.push_back(0.) ;
01617
01618 for (int i = 0 ; i < int(length_histo/binning) ; i++)
01619 {
01620 for (int j = 0 ; j < binning ; j++)
01621 histo_vector[i] += double(histo[histo_num][i*binning+j]) ;
01622
01623 if (histo_vector[i] < 0.5 )
01624 {
01625 histo_vector[i] = 0.1 ;
01626 }
01627 }
01628
01629 return histo_vector ;
01630 }
01631
01632
01633
01634
01635
01636
01648 int * MuSR_td_PSI_bin::get_histo_array_int(int histo_num)
01649 {
01650 if (!readingok) return NULL;
01651
01652 if ( histo_num < 0 || histo_num >= int(number_histo))
01653 return NULL ;
01654
01655 int *histo_array = new int[length_histo] ;
01656
01657 if (!histo_array) return NULL;
01658
01659 for (int i = 0 ; i < int(length_histo) ; i++)
01660 {
01661 histo_array[i] = int(histo[histo_num][i]) ;
01662 }
01663
01664 return histo_array ;
01665 }
01666
01667
01668
01669
01670
01671
01685 double * MuSR_td_PSI_bin::get_histo_fromt0_array(int histo_num , int binning , int offset)
01686 {
01687 if (!readingok) return NULL;
01688
01689 if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 )
01690 return NULL ;
01691
01692 double *histo_fromt0_array =
01693 new double[int((int(length_histo)-get_t0_int(histo_num)-offset+1)/binning)] ;
01694
01695 if (!histo_fromt0_array) return NULL;
01696
01697 for (int i = 0 ; i < int((int(length_histo)-get_t0_int(histo_num)-offset)/binning) ; i++)
01698 {
01699 histo_fromt0_array[i] = 0 ;
01700 for (int j = 0 ; j < binning ; j++)
01701 histo_fromt0_array[i] +=
01702 double(histo[histo_num][i*binning+j+get_t0_int(histo_num)+offset]) ;
01703 }
01704
01705 return histo_fromt0_array ;
01706 }
01707
01708
01709
01710
01711
01712
01725 vector<double> MuSR_td_PSI_bin::get_histo_fromt0_vector(int histo_num , int binning , int offset)
01726 {
01727 vector<double> histo_fromt0_vector ;
01728
01729 if (!readingok) return histo_fromt0_vector;
01730
01731 if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 )
01732 return histo_fromt0_vector ;
01733
01734 for (int i = 0 ; i < int((int(length_histo)-get_t0_int(histo_num)-offset)/binning) ; i++)
01735 histo_fromt0_vector.push_back(0.) ;
01736
01737 for (int i = 0 ; i < int((int(length_histo)-get_t0_int(histo_num)-offset)/binning) ; i++)
01738 {
01739 for (int j = 0 ; j < binning ; j++)
01740 histo_fromt0_vector[i] +=
01741 double(histo[histo_num][i*binning+j+get_t0_int(histo_num)+offset]) ;
01742 }
01743
01744 return histo_fromt0_vector ;
01745 }
01746
01747
01748
01749
01750
01751
01764 double * MuSR_td_PSI_bin::get_histo_goodBins_array(int histo_num , int binning)
01765 {
01766 if (!readingok) return NULL;
01767 if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 )
01768 return NULL ;
01769
01770 double *histo_goodBins_array =
01771 new double[int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num)+1)/binning)] ;
01772
01773 if (!histo_goodBins_array) return NULL;
01774
01775 for (int i = 0 ; i < int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num))/binning) ; i++)
01776 {
01777 histo_goodBins_array[i] = 0 ;
01778 for (int j = 0 ; j < binning ; j++)
01779 histo_goodBins_array[i] +=
01780 double(histo[histo_num][i*binning+j+get_firstGood_int(histo_num)]) ;
01781 }
01782
01783 return histo_goodBins_array ;
01784 }
01785
01786
01787
01788
01789
01790
01803 vector<double> MuSR_td_PSI_bin::get_histo_goodBins_vector(int histo_num , int binning)
01804 {
01805 vector<double> histo_goodBins_vector ;
01806
01807 if (!readingok) return histo_goodBins_vector;
01808
01809 if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 )
01810 return histo_goodBins_vector ;
01811
01812 for (int i = 0 ; i < int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num))/binning) ; i++)
01813 histo_goodBins_vector.push_back(0.) ;
01814
01815 for (int i = 0 ; i < int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num))/binning) ; i++)
01816 {
01817 for (int j = 0 ; j < binning ; j++)
01818 histo_goodBins_vector[i] +=
01819 double(histo[histo_num][i*binning+j+get_firstGood_int(histo_num)]) ;
01820 }
01821
01822 return histo_goodBins_vector ;
01823 }
01824
01825
01826
01827
01828
01829
01849 double * MuSR_td_PSI_bin::get_histo_fromt0_minus_bckgrd_array(int histo_num ,
01850 int lower_bckgrd , int higher_bckgrd , int binning, int offset)
01851 {
01852 if (!readingok) return NULL;
01853
01854 if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 )
01855 return NULL ;
01856
01857 if ( lower_bckgrd < 0 || higher_bckgrd >= int(length_histo) || lower_bckgrd > higher_bckgrd )
01858 return NULL ;
01859
01860 double bckgrd = 0 ;
01861
01862 for (int k = lower_bckgrd ; k <= higher_bckgrd ; k++)
01863 {
01864 bckgrd += double(histo[histo_num][k]) ;
01865 }
01866 bckgrd = bckgrd/(higher_bckgrd-lower_bckgrd+1) ;
01867
01868 double *histo_fromt0_minus_bckgrd_array =
01869 new double[int((int(length_histo)-get_t0_int(histo_num)-offset+1)/binning)] ;
01870
01871 if (!histo_fromt0_minus_bckgrd_array) return NULL;
01872
01873 for (int i = 0 ; i < int((int(length_histo)-get_t0_int(histo_num)-offset)/binning) ; i++)
01874 {
01875 histo_fromt0_minus_bckgrd_array[i] = 0 ;
01876 for (int j = 0 ; j < binning ; j++)
01877 histo_fromt0_minus_bckgrd_array[i] +=
01878 double(histo[histo_num][i*binning+j+get_t0_int(histo_num)+offset]) - bckgrd;
01879 }
01880
01881 return histo_fromt0_minus_bckgrd_array ;
01882 } ;
01883
01884
01885
01886
01887
01906 vector<double> MuSR_td_PSI_bin::get_histo_fromt0_minus_bckgrd_vector(int histo_num , int lower_bckgrd ,
01907 int higher_bckgrd , int binning, int offset)
01908 {
01909 vector<double> histo_fromt0_minus_bckgrd_vector ;
01910
01911 if (!readingok) return histo_fromt0_minus_bckgrd_vector;
01912
01913 if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 )
01914 return histo_fromt0_minus_bckgrd_vector ;
01915
01916 if ( lower_bckgrd < 0 || higher_bckgrd >= int(length_histo) || lower_bckgrd > higher_bckgrd )
01917 return histo_fromt0_minus_bckgrd_vector ;
01918
01919 double bckgrd = 0 ;
01920 for (int k = lower_bckgrd ; k <= higher_bckgrd ; k++)
01921 {
01922 bckgrd += double(histo[histo_num][k]) ;
01923 }
01924 bckgrd = bckgrd/(higher_bckgrd-lower_bckgrd+1) ;
01925
01926 for (int i = 0 ; i < int((int(length_histo)-get_t0_int(histo_num)-offset)/binning) ; i++)
01927 histo_fromt0_minus_bckgrd_vector.push_back(0.) ;
01928
01929 for (int i = 0 ; i < int((int(length_histo)-get_t0_int(histo_num)-offset)/binning) ; i++)
01930 {
01931 for (int j = 0 ; j < binning ; j++)
01932 histo_fromt0_minus_bckgrd_vector[i] +=
01933 double(histo[histo_num][i*binning+j+get_t0_int(histo_num)+offset]) - bckgrd;
01934 }
01935
01936 return histo_fromt0_minus_bckgrd_vector ;
01937 }
01938
01939
01940
01941
01942
01943
01963 double * MuSR_td_PSI_bin::get_histo_goodBins_minus_bckgrd_array(int histo_num , int lower_bckgrd ,
01964 int higher_bckgrd , int binning)
01965 {
01966 if (!readingok) return NULL;
01967
01968 if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 )
01969 return NULL ;
01970
01971 if ( lower_bckgrd < 0 || higher_bckgrd >= int(length_histo) || lower_bckgrd > higher_bckgrd )
01972 return NULL ;
01973
01974 double bckgrd = 0 ;
01975 for (int k = lower_bckgrd ; k <= higher_bckgrd ; k++)
01976 {
01977 bckgrd += double(histo[histo_num][k]) ;
01978 }
01979 bckgrd = bckgrd/(higher_bckgrd-lower_bckgrd+1) ;
01980
01981 double *histo_goodBins_minus_bckgrd_array =
01982 new double[int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num)+1)/binning)] ;
01983
01984 if (!histo_goodBins_minus_bckgrd_array) return NULL;
01985
01986 for (int i = 0 ; i < int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num))/binning) ; i++)
01987 {
01988 histo_goodBins_minus_bckgrd_array[i] = 0 ;
01989 for (int j = 0 ; j < binning ; j++)
01990 histo_goodBins_minus_bckgrd_array[i] +=
01991 double(histo[histo_num][i*binning+j+get_firstGood_int(histo_num)]) - bckgrd;
01992 }
01993
01994 return histo_goodBins_minus_bckgrd_array ;
01995 } ;
01996
01997
01998
01999
02000
02001
02020 vector<double> MuSR_td_PSI_bin::get_histo_goodBins_minus_bckgrd_vector(int histo_num , int lower_bckgrd ,
02021 int higher_bckgrd , int binning)
02022 {
02023 vector<double> histo_goodBins_minus_bckgrd_vector ; ;
02024
02025 if (!readingok) return histo_goodBins_minus_bckgrd_vector;
02026
02027 if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 )
02028 return histo_goodBins_minus_bckgrd_vector ;
02029
02030 if ( lower_bckgrd < 0 || higher_bckgrd >= int(length_histo) || lower_bckgrd > higher_bckgrd )
02031 return histo_goodBins_minus_bckgrd_vector ;
02032
02033 double bckgrd = 0 ;
02034 for (int k = lower_bckgrd ; k <= higher_bckgrd ; k++)
02035 {
02036 bckgrd += double(histo[histo_num][k]) ;
02037 }
02038 bckgrd = bckgrd/(higher_bckgrd-lower_bckgrd+1) ;
02039
02040 for (int i = 0 ; i < int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num))/binning) ; i++)
02041 histo_goodBins_minus_bckgrd_vector.push_back(0.) ;
02042
02043 for (int i = 0 ; i < int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num))/binning) ; i++)
02044 {
02045 for (int j = 0 ; j < binning ; j++)
02046 histo_goodBins_minus_bckgrd_vector[i] +=
02047 double(histo[histo_num][i*binning+j+get_firstGood_int(histo_num)]) - bckgrd;
02048 }
02049
02050 return histo_goodBins_minus_bckgrd_vector ;
02051 }
02052
02053
02054
02055
02056
02057
02079 double * MuSR_td_PSI_bin::get_asymmetry_array(int histo_num_plus , int histo_num_minus , double alpha_param ,
02080 int binning , int lower_bckgrd_plus , int higher_bckgrd_plus ,
02081 int lower_bckgrd_minus , int higher_bckgrd_minus , int offset ,
02082 double y_offset)
02083 {
02084 int max_t0 = tmax(get_t0_int(histo_num_plus),get_t0_int(histo_num_minus)) ;
02085
02086 if (!readingok) return NULL;
02087
02088 if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 )
02089 return NULL ;
02090
02091 if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) )
02092 return NULL ;
02093
02094 if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus )
02095 return NULL ;
02096
02097 if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus )
02098 return NULL ;
02099
02100
02101 double *dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus ,
02102 higher_bckgrd_plus , binning , offset) ;
02103 if (dummy_1 == NULL) return NULL ;
02104
02105 double *dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus ,
02106 higher_bckgrd_minus , binning , offset) ;
02107 if (dummy_2 == NULL)
02108 {
02109 delete [] dummy_1;
02110 return NULL ;
02111 }
02112
02113 double *asymmetry_array = new double[int((int(length_histo)-max_t0-offset+1)/binning)] ;
02114
02115 if (!asymmetry_array) return NULL;
02116
02117 for (int i = 0 ; i < int((int(length_histo)-max_t0)/binning) ; i++)
02118 {
02119 asymmetry_array[i] = (dummy_1[i] - alpha_param * dummy_2[i]) /
02120 (dummy_1[i] + alpha_param * dummy_2[i]) + y_offset ;
02121 }
02122
02123 delete [] dummy_1;
02124 delete [] dummy_2;
02125
02126 return asymmetry_array ;
02127 }
02128
02129
02130
02131
02132
02133
02152 vector<double> MuSR_td_PSI_bin::get_asymmetry_vector(int histo_num_plus , int histo_num_minus , double alpha_param ,
02153 int binning , int lower_bckgrd_plus , int higher_bckgrd_plus ,
02154 int lower_bckgrd_minus , int higher_bckgrd_minus , int offset , double y_offset)
02155 {
02156 int max_t0 = tmax(get_t0_int(histo_num_plus),get_t0_int(histo_num_minus)) ;
02157
02158 vector<double> asymmetry_vector ;
02159
02160 if (!readingok) return asymmetry_vector;
02161
02162 if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 )
02163 return asymmetry_vector ;
02164
02165 if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) )
02166 return asymmetry_vector ;
02167
02168 if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus )
02169 return asymmetry_vector ;
02170
02171 if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus )
02172 return asymmetry_vector ;
02173
02174 double *dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus ,
02175 higher_bckgrd_plus , binning, offset) ;
02176 if (dummy_1 == NULL) return asymmetry_vector;
02177
02178 double *dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus ,
02179 higher_bckgrd_minus , binning, offset) ;
02180 if (dummy_2 == NULL)
02181 {
02182 delete [] dummy_1;
02183 return asymmetry_vector;
02184 }
02185
02186 for (int i = 0 ; i < int((int(length_histo)-max_t0-offset)/binning) ; i++)
02187 asymmetry_vector.push_back(0.) ;
02188
02189 for (int i = 0 ; i < int((int(length_histo)-max_t0-offset)/binning) ; i++)
02190 {
02191 asymmetry_vector[i] = (dummy_1[i] - alpha_param * dummy_2[i]) /
02192 (dummy_1[i] + alpha_param * dummy_2[i]) + y_offset ;
02193 }
02194
02195 delete [] dummy_1;
02196 delete [] dummy_2;
02197
02198 return asymmetry_vector ;
02199 }
02200
02201
02202
02203
02204
02205
02224 double * MuSR_td_PSI_bin::get_error_asymmetry_array(int histo_num_plus , int histo_num_minus , double alpha_param ,
02225 int binning , int lower_bckgrd_plus , int higher_bckgrd_plus ,
02226 int lower_bckgrd_minus , int higher_bckgrd_minus, int offset)
02227 {
02228 int max_t0 = tmax(get_t0_int(histo_num_plus),get_t0_int(histo_num_minus)) ;
02229
02230 if (!readingok) return NULL;
02231
02232 if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 )
02233 return NULL ;
02234
02235 if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) )
02236 return NULL ;
02237
02238 if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus )
02239 return NULL ;
02240
02241 if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus )
02242 return NULL ;
02243
02244 double *dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus ,
02245 higher_bckgrd_plus , binning, offset) ;
02246 if (dummy_1 == NULL) return NULL;
02247
02248 double *dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus ,
02249 higher_bckgrd_minus , binning, offset) ;
02250 if (dummy_2 == NULL)
02251 {
02252 delete [] dummy_1;
02253 return NULL;
02254 }
02255
02256 double *error_asymmetry_array = new double[int((int(length_histo)-max_t0-offset+1)/binning)] ;
02257
02258 if (!error_asymmetry_array) return NULL;
02259
02260 for (int i = 0 ; i < int((length_histo-max_t0-offset)/binning) ; i++)
02261 {
02262 if (dummy_1[i] < 0.5 || dummy_2[i] < 0.5 )
02263 error_asymmetry_array[i] = 1.0 ;
02264 else
02265 error_asymmetry_array[i] = double(2.) * alpha_param * sqrt(dummy_1[i]*dummy_2[i]*(dummy_1[i]+dummy_2[i])) /
02266 pow(dummy_1[i] + alpha_param * dummy_2[i],2.) ;
02267 }
02268
02269 delete [] dummy_1;
02270 delete [] dummy_2;
02271
02272 return error_asymmetry_array ;
02273 }
02274
02275
02276
02277
02278
02279
02297 vector<double> MuSR_td_PSI_bin::get_error_asymmetry_vector(int histo_num_plus , int histo_num_minus , double alpha_param ,
02298 int binning , int lower_bckgrd_plus , int higher_bckgrd_plus ,
02299 int lower_bckgrd_minus , int higher_bckgrd_minus, int offset)
02300 {
02301 int max_t0 = tmax(get_t0_int(histo_num_plus),get_t0_int(histo_num_minus)) ;
02302
02303 vector<double> error_asymmetry_vector ;
02304
02305 if (!readingok) return error_asymmetry_vector;
02306
02307 if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 )
02308 return error_asymmetry_vector ;
02309
02310 if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) )
02311 return error_asymmetry_vector ;
02312
02313 if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus )
02314 return error_asymmetry_vector ;
02315
02316 if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus )
02317 return error_asymmetry_vector ;
02318
02319 double *dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus ,
02320 higher_bckgrd_plus , binning, offset) ;
02321 if (dummy_1 == NULL) return error_asymmetry_vector ;
02322
02323 double *dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus ,
02324 higher_bckgrd_minus , binning, offset) ;
02325 if (dummy_2 == NULL)
02326 {
02327 delete [] dummy_1;
02328 return error_asymmetry_vector ;
02329 }
02330
02331 for (int i = 0 ; i < int((int(length_histo)-max_t0-offset)/binning) ; i++)
02332 error_asymmetry_vector.push_back(0.) ;
02333
02334 for (int i = 0 ; i < int((int(length_histo-max_t0-offset))/binning) ; i++)
02335 {
02336 if (dummy_1[i] < 0.5 || dummy_2[i] < 0.5 )
02337 error_asymmetry_vector[i] = 1.0 ;
02338 else
02339 error_asymmetry_vector[i] = double(2.) * alpha_param * sqrt(dummy_1[i]*dummy_2[i]*(dummy_1[i]+dummy_2[i])) /
02340 pow(dummy_1[i] + alpha_param * dummy_2[i],2.) ;
02341 }
02342
02343 delete [] dummy_1;
02344 delete [] dummy_2;
02345
02346 return error_asymmetry_vector ;
02347 }
02348
02349
02350
02351
02352
02353
02373 double * MuSR_td_PSI_bin::get_asymmetry_goodBins_array(int histo_num_plus , int histo_num_minus , double alpha_param ,
02374 int binning , int lower_bckgrd_plus , int higher_bckgrd_plus ,
02375 int lower_bckgrd_minus , int higher_bckgrd_minus)
02376 {
02377 int hsize = int((tmin(get_lastGood_int(histo_num_plus)-get_firstGood_int(histo_num_plus),
02378 get_lastGood_int(histo_num_minus)-get_firstGood_int(histo_num_minus))+1)/binning) ;
02379
02380 if (!readingok) return NULL;
02381
02382 if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 )
02383 return NULL ;
02384
02385 if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) )
02386 return NULL ;
02387
02388 if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus )
02389 return NULL ;
02390
02391 if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus )
02392 return NULL ;
02393
02394 double *dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus ,
02395 higher_bckgrd_plus , binning) ;
02396 if (dummy_1 == NULL) return NULL;
02397
02398 double *dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus ,
02399 higher_bckgrd_minus , binning) ;
02400 if (dummy_2 == NULL)
02401 {
02402 delete [] dummy_1;
02403 return NULL;
02404 }
02405
02406 int hstart = tmax(get_firstGood_int(histo_num_plus)-get_t0_int(histo_num_plus),get_firstGood_int(histo_num_minus)-get_t0_int(histo_num_minus)) ;
02407
02408 double *asymmetry_goodBins_array = new double[hsize] ;
02409
02410 if (!asymmetry_goodBins_array) return NULL;
02411
02412 for (int i = 0 ; i < hsize ; i++)
02413 {
02414 asymmetry_goodBins_array[i] = (dummy_1[i+hstart] - alpha_param * dummy_2[i+hstart]) /
02415 (dummy_1[i+hstart] + alpha_param * dummy_2[i+hstart]) ;
02416 }
02417
02418 delete [] dummy_1;
02419 delete [] dummy_2;
02420
02421 return asymmetry_goodBins_array ;
02422 }
02423
02424
02425
02426
02427
02428
02447 vector<double> MuSR_td_PSI_bin::get_asymmetry_goodBins_vector(int histo_num_plus , int histo_num_minus , double alpha_param ,
02448 int binning , int lower_bckgrd_plus , int higher_bckgrd_plus ,
02449 int lower_bckgrd_minus , int higher_bckgrd_minus)
02450 {
02451 int hsize = int((tmin(get_lastGood_int(histo_num_plus)-get_firstGood_int(histo_num_plus),
02452 get_lastGood_int(histo_num_minus)-get_firstGood_int(histo_num_minus))+1)/binning) ;
02453
02454 vector<double> asymmetry_goodBins_vector ;
02455
02456 if (!readingok) return asymmetry_goodBins_vector;
02457
02458 if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 )
02459 return asymmetry_goodBins_vector ;
02460
02461 if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) )
02462 return asymmetry_goodBins_vector ;
02463
02464 if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus )
02465 return asymmetry_goodBins_vector ;
02466
02467 if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus )
02468 return asymmetry_goodBins_vector ;
02469
02470 double *dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus ,
02471 higher_bckgrd_plus , binning) ;
02472 if (dummy_1 == NULL) return asymmetry_goodBins_vector ;
02473
02474 double *dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus ,
02475 higher_bckgrd_minus , binning) ;
02476 if (dummy_2 == NULL)
02477 {
02478 delete [] dummy_1;
02479 return asymmetry_goodBins_vector ;
02480 }
02481
02482 for (int i = 0 ; i < hsize ; i++)
02483 asymmetry_goodBins_vector.push_back(0.) ;
02484
02485 int hstart = tmax(get_firstGood_int(histo_num_plus)-get_t0_int(histo_num_plus),get_firstGood_int(histo_num_minus)-get_t0_int(histo_num_minus)) ;
02486
02487 for (int i = 0 ; i < hsize ; i++)
02488 {
02489 asymmetry_goodBins_vector[i] = (dummy_1[i+hstart] - alpha_param * dummy_2[i+hstart]) /
02490 (dummy_1[i+hstart] + alpha_param * dummy_2[i+hstart]) ;
02491 }
02492 delete [] dummy_1;
02493 delete [] dummy_2;
02494
02495 return asymmetry_goodBins_vector ;
02496 }
02497
02498
02499
02500
02501
02502
02521 double * MuSR_td_PSI_bin::get_error_asymmetry_goodBins_array(int histo_num_plus , int histo_num_minus , double alpha_param ,
02522 int binning , int lower_bckgrd_plus , int higher_bckgrd_plus ,
02523 int lower_bckgrd_minus , int higher_bckgrd_minus)
02524 {
02525 int hsize = int((tmin(get_lastGood_int(histo_num_plus)
02526 -get_firstGood_int(histo_num_plus),
02527 get_lastGood_int(histo_num_minus)
02528 -get_firstGood_int(histo_num_minus))+1)/binning) ;
02529
02530 if (!readingok) return NULL;
02531
02532 if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 )
02533 return NULL ;
02534
02535 if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) )
02536 return NULL ;
02537
02538 if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus )
02539 return NULL ;
02540
02541 if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus )
02542 return NULL ;
02543
02544 double *dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus ,
02545 lower_bckgrd_plus , higher_bckgrd_plus , binning) ;
02546 if (dummy_1 == NULL) return NULL;
02547
02548 double *dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus ,
02549 lower_bckgrd_minus , higher_bckgrd_minus , binning) ;
02550 if (dummy_2 == NULL)
02551 {
02552 delete [] dummy_1;
02553 return NULL;
02554 }
02555 int hstart = tmax(get_firstGood_int(histo_num_plus)-get_t0_int(histo_num_plus),
02556 get_firstGood_int(histo_num_minus)-get_t0_int(histo_num_minus)) ;
02557
02558 double *error_asymmetry_goodBins_array = new double[hsize] ;
02559
02560 if (!error_asymmetry_goodBins_array) return NULL;
02561
02562 for (int i = 0 ; i < hsize ; i++)
02563 {
02564 if (dummy_1[i+hstart] < 0.5 || dummy_2[i+hstart] < 0.5 )
02565 error_asymmetry_goodBins_array[i] = 1.0 ;
02566 else
02567 error_asymmetry_goodBins_array[i] =
02568 double(2.) * alpha_param * sqrt(dummy_1[i+hstart]*dummy_2[i+hstart]
02569 *(dummy_1[i+hstart]+dummy_2[i+hstart])) /
02570 pow(dummy_1[i+hstart] + alpha_param * dummy_2[i+hstart],2.) ;
02571 }
02572
02573 delete [] dummy_1;
02574 delete [] dummy_2;
02575
02576 return error_asymmetry_goodBins_array ;
02577 }
02578
02579
02580
02581
02582
02583
02605 vector<double> MuSR_td_PSI_bin::get_error_asymmetry_goodBins_vector(int histo_num_plus ,
02606 int histo_num_minus , double alpha_param ,
02607 int binning , int lower_bckgrd_plus ,
02608 int higher_bckgrd_plus ,
02609 int lower_bckgrd_minus , int higher_bckgrd_minus)
02610 {
02611 int hsize = int((tmin(get_lastGood_int(histo_num_plus)-get_firstGood_int(histo_num_plus),
02612 get_lastGood_int(histo_num_minus)-get_firstGood_int(histo_num_minus))+1)/binning) ;
02613
02614 vector<double> error_asymmetry_goodBins_vector ;
02615
02616 if (!readingok) return error_asymmetry_goodBins_vector;
02617
02618 if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 )
02619 return error_asymmetry_goodBins_vector ;
02620
02621 if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) )
02622 return error_asymmetry_goodBins_vector ;
02623
02624 if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus )
02625 return error_asymmetry_goodBins_vector ;
02626
02627 if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus )
02628 return error_asymmetry_goodBins_vector ;
02629
02630 double *dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus ,
02631 higher_bckgrd_plus , binning) ;
02632 if (dummy_1 == NULL) return error_asymmetry_goodBins_vector ;
02633
02634 double *dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus ,
02635 higher_bckgrd_minus , binning) ;
02636 if (dummy_2 == NULL)
02637 {
02638 delete [] dummy_1;
02639 return error_asymmetry_goodBins_vector ;
02640 }
02641
02642 for (int i = 0 ; i < hsize ; i++)
02643 error_asymmetry_goodBins_vector.push_back(0.) ;
02644
02645 int hstart = tmax(get_firstGood_int(histo_num_plus)-get_t0_int(histo_num_plus),get_firstGood_int(histo_num_minus)-get_t0_int(histo_num_minus)) ;
02646
02647 for (int i = 0 ; i < hsize ; i++)
02648 {
02649 if (dummy_1[i+hstart] < 0.5 || dummy_2[i+hstart] < 0.5 )
02650 error_asymmetry_goodBins_vector[i] = 1.0 ;
02651 else
02652 error_asymmetry_goodBins_vector[i] = double(2.) * alpha_param
02653 * sqrt(dummy_1[i+hstart]*dummy_2[i+hstart]*(dummy_1[i+hstart]+dummy_2[i+hstart])) /
02654 pow(dummy_1[i+hstart] + alpha_param * dummy_2[i+hstart],2.) ;
02655 }
02656
02657 delete [] dummy_1;
02658 delete [] dummy_2;
02659
02660 return error_asymmetry_goodBins_vector ;
02661 }
02662
02663
02664
02665
02666
02667
02671 int MuSR_td_PSI_bin::get_numberScaler_int()
02672 {
02673 return int(number_scaler) ;
02674 }
02675
02676
02677
02678
02679
02683 vector<long> MuSR_td_PSI_bin::get_scalers_vector()
02684 {
02685 vector<long> scalers_vect(number_scaler) ;
02686
02687 for ( int i = 0 ; i < number_scaler ; i++ )
02688 scalers_vect[i] = long(scalers[i]) ;
02689
02690 return scalers_vect ;
02691 }
02692
02693
02694
02695
02696
02697
02701 int MuSR_td_PSI_bin::get_max_t0_int()
02702 {
02703 int max_t0 = 0 ;
02704
02705 for (int i = 0 ; i < int(number_histo) ; i++)
02706 {
02707 if (int(integer_t0[i]) > max_t0)
02708 max_t0 = int(integer_t0[i]) ;
02709 }
02710 return max_t0 ;
02711 }
02712
02713
02714
02715
02716
02717
02723 int MuSR_td_PSI_bin::get_max_2_t0_int(int k, int j)
02724 {
02725 if (( k < 0 || k >= int(number_histo)) || ( j < 0 || j >= int(number_histo)))
02726 return -1 ;
02727
02728 int max_t0 = int(integer_t0[j]) ;
02729 if (int(integer_t0[k]) >= max_t0)
02730 max_t0 = int(integer_t0[k]) ;
02731
02732 return max_t0 ;
02733 }
02734
02735
02736
02737
02738
02739
02745 int MuSR_td_PSI_bin::get_min_2_t0_int(int k, int j)
02746 {
02747 if (( k < 0 || k >= int(number_histo)) || ( j < 0 || j >= int(number_histo)))
02748 return -1 ;
02749
02750 int min_t0 = int(integer_t0[j]) ;
02751 if (int(integer_t0[k]) <= min_t0)
02752 min_t0 = int(integer_t0[k]) ;
02753
02754 return min_t0 ;
02755 }
02756
02757
02758
02759
02760
02761
02765 int MuSR_td_PSI_bin::get_min_t0_int()
02766 {
02767 int min_t0 = int(length_histo) ;
02768
02769 for (int i = 0 ; i < int(number_histo) ; i++)
02770 {
02771 if (int(integer_t0[i]) < min_t0)
02772 min_t0 = int(integer_t0[i]) ;
02773 }
02774
02775 return min_t0 ;
02776 }
02777
02778
02779
02780
02781
02782
02786 double MuSR_td_PSI_bin::get_binWidth_ps()
02787 {
02788 return double((double)bin_width*(double)1000000.) ;
02789 }
02790
02791
02792
02793
02794
02795
02799 double MuSR_td_PSI_bin::get_binWidth_ns()
02800 {
02801 return double((double)bin_width*(double)1000.) ;
02802 }
02803
02804
02805
02806
02807
02811 double MuSR_td_PSI_bin::get_binWidth_us()
02812 {
02813 return double(bin_width) ;
02814 }
02815
02816
02817
02818
02819
02820
02824 int MuSR_td_PSI_bin::get_histoLength_bin()
02825 {
02826 return int(length_histo) ;
02827 }
02828
02829
02830
02831
02832
02833
02837 int MuSR_td_PSI_bin::get_numberHisto_int()
02838 {
02839 return int(number_histo) ;
02840 }
02841
02842
02843
02844
02845
02846
02850 long MuSR_td_PSI_bin::get_totalEvents_long()
02851 {
02852 return long(total_events) ;
02853 }
02854
02855
02856
02857
02858
02859
02865 long MuSR_td_PSI_bin::get_eventsHisto_long(int i)
02866 {
02867 if ( i < 0 || i >= number_histo)
02868 return -1 ;
02869 else
02870 return long(events_per_histo[i]) ;
02871 }
02872
02873
02874
02875
02876
02877
02881 vector<long> MuSR_td_PSI_bin::get_eventsHisto_vector()
02882 {
02883 vector<long> eventsHisto(number_histo) ;
02884
02885 for ( int i = 0 ; i < number_histo ; i++ )
02886 eventsHisto[i] = long(events_per_histo[i]) ;
02887 return eventsHisto ;
02888 }
02889
02890
02891
02892
02893
02899 double MuSR_td_PSI_bin::get_t0_double(int i)
02900 {
02901 if ( i < 0 || i >= int(number_histo))
02902 return -1. ;
02903 else
02904 return double(real_t0[i]) ;
02905 }
02906
02907
02908
02909
02910
02911
02915 int MuSR_td_PSI_bin::get_default_binning()
02916 {
02917 if (default_binning < 1)
02918 return 1;
02919 else
02920 return default_binning ;
02921 }
02922
02923
02924
02925
02926
02932 int MuSR_td_PSI_bin::get_t0_int(int i)
02933 {
02934 if ( i < 0 || i >= int(number_histo))
02935 return -1 ;
02936 else
02937 return int(integer_t0[i]) ;
02938 }
02939
02940
02941
02942
02943
02947 vector<int> MuSR_td_PSI_bin::get_t0_vector()
02948 {
02949 vector<int> t0(number_histo) ;
02950
02951 for ( int i = 0 ; i < int(number_histo) ; i++ )
02952 t0[i] = int(integer_t0[i]) ;
02953
02954 return t0 ;
02955 }
02956
02957
02958
02959
02960
02961
02967 int MuSR_td_PSI_bin::get_firstGood_int(int i)
02968 {
02969 if ( i < 0 || i >= int(number_histo))
02970 return -1 ;
02971 else
02972 return int(first_good[i]) ;
02973 }
02974
02975
02976
02977
02978
02979
02983 vector<int> MuSR_td_PSI_bin::get_firstGood_vector()
02984 {
02985 vector<int> firstGood(number_histo) ;
02986
02987 for ( int i = 0 ; i < number_histo ; i++ )
02988 firstGood[i] = int(first_good[i]) ;
02989
02990 return firstGood ;
02991 }
02992
02993
02994
02995
02996
02997
03003 int MuSR_td_PSI_bin::put_firstGood_int(int i, int j)
03004 {
03005 if ( i < 0 || i >= int(number_histo))
03006 return -1 ;
03007 else
03008 {
03009 first_good[i] = j ;
03010 return 0;
03011 }
03012 }
03013
03014
03015
03016
03017
03018
03024 int MuSR_td_PSI_bin::get_lastGood_int(int i)
03025 {
03026 if ( i < 0 || i >= int(number_histo))
03027 return -1 ;
03028 else
03029 return int(last_good[i]) ;
03030 }
03031
03032
03033
03034
03035
03036
03040 vector<int> MuSR_td_PSI_bin::get_lastGood_vector()
03041 {
03042 vector<int> lastGood(number_histo) ;
03043
03044 for ( int i = 0 ; i < number_histo ; i++ )
03045 lastGood[i] = int(last_good[i]) ;
03046
03047 return lastGood ;
03048 }
03049
03050
03051
03052
03053
03054
03058 int MuSR_td_PSI_bin::get_max_lastGood_int()
03059 {
03060 int max_lastGood = 0 ;
03061
03062 for (int i = 0 ; i < int(number_histo) ; i++)
03063 {
03064 if (int(last_good[i]) > max_lastGood)
03065 max_lastGood = int(last_good[i]) ;
03066 }
03067
03068 return max_lastGood ;
03069 }
03070
03071
03072
03073
03074
03075
03081 int MuSR_td_PSI_bin::get_max_2_lastGood_int(int k, int j)
03082 {
03083 if (( k < 0 || k >= int(number_histo)) || ( j < 0 || j >= int(number_histo)))
03084 return -1 ;
03085 else
03086 {
03087 int max_lastGood = int(last_good[j]) ;
03088
03089 if (int(last_good[k]) > max_lastGood)
03090 max_lastGood = int(last_good[k]) ;
03091
03092 return max_lastGood ;
03093 }
03094 }
03095
03096
03097
03098
03099
03100
03104 int MuSR_td_PSI_bin::get_min_lastGood_int()
03105 {
03106 int min_lastGood = int(last_good[0]) ;
03107
03108 for (int i = 1 ; i < int(number_histo) ; i++)
03109 {
03110 if (int(last_good[i]) < min_lastGood)
03111 min_lastGood = int(last_good[i]) ;
03112 }
03113
03114 return min_lastGood ;
03115 }
03116
03117
03118
03119
03120
03121
03127 int MuSR_td_PSI_bin::get_min_2_lastGood_int(int k, int j)
03128 {
03129 if (( k < 0 || k >= int(number_histo)) || ( j < 0 || j >= int(number_histo)))
03130 return -1 ;
03131 else
03132 {
03133 int min_lastGood = int(last_good[j]) ;
03134
03135 if (int(last_good[k]) < min_lastGood)
03136 min_lastGood = int(last_good[k]) ;
03137
03138 return min_lastGood ;
03139 }
03140 }
03141
03142
03143
03144
03145
03146
03152 int MuSR_td_PSI_bin::put_lastGood_int(int i, int j)
03153 {
03154 if ( i < 0 || i >= int(number_histo))
03155 return -1 ;
03156 else
03157 {
03158 last_good[i] = j ;
03159 return 0;
03160 }
03161 }
03162
03163
03164
03165
03166
03167
03171 int MuSR_td_PSI_bin::get_runNumber_int()
03172 {
03173 return int(num_run) ;
03174 }
03175
03176
03177
03178
03179
03180
03186 int MuSR_td_PSI_bin::put_runNumber_int(int i)
03187 {
03188 if (i <= 0 )
03189 return -1 ;
03190 else
03191 num_run = i ;
03192 return 0 ;
03193 }
03194
03195
03196
03197
03198
03199
03203 string MuSR_td_PSI_bin::get_sample()
03204 {
03205 string strData ;
03206
03207 strData = sample ;
03208
03209 return strData ;
03210 }
03211
03212
03213
03214
03215
03216
03220 string MuSR_td_PSI_bin::get_temp()
03221 {
03222 string strData ;
03223
03224 strData = temp ;
03225
03226 return strData ;
03227 }
03228
03229
03230
03231
03232
03233
03237 string MuSR_td_PSI_bin::get_orient()
03238 {
03239 string strData ;
03240
03241 strData = orient ;
03242
03243 return strData ;
03244 }
03245
03246
03247
03248
03249
03250
03254 string MuSR_td_PSI_bin::get_field()
03255 {
03256 string strData ;
03257
03258 strData = field ;
03259
03260 return strData ;
03261 }
03262
03263
03264
03265
03266
03267
03271 string MuSR_td_PSI_bin::get_comment()
03272 {
03273 string strData ;
03274
03275 strData = comment ;
03276
03277 return strData ;
03278 }
03279
03280
03281
03282
03283
03284
03290 string MuSR_td_PSI_bin::get_nameHisto(int i)
03291 {
03292 string strData ;
03293
03294 if (i < 0 || i >= int(number_histo))
03295 return NULL ;
03296 else
03297 {
03298 strData = labels_histo[i] ;
03299 return strData ;
03300 }
03301 }
03302
03303
03304
03305
03306
03307
03311 vector<string> MuSR_td_PSI_bin::get_histoNames_vector()
03312 {
03313 vector <string> str_Vector ;
03314
03315 string strData ;
03316 for (int i = 0 ; i < number_histo ; i++)
03317 {
03318 strData = labels_histo[i] ;
03319 str_Vector.push_back(strData) ;
03320 }
03321
03322 return str_Vector;
03323 }
03324
03325
03326
03327
03328
03329
03333 vector<string> MuSR_td_PSI_bin::get_scalersNames_vector()
03334 {
03335 vector <string> str_Vector ;
03336
03337 string strData ;
03338 for (int i = 0 ; i < number_scaler ; i++)
03339 {
03340 strData = labels_scalers[i] ;
03341 str_Vector.push_back(strData) ;
03342 }
03343
03344 return str_Vector;
03345 }
03346
03347
03348
03349
03350
03351
03355 int MuSR_td_PSI_bin::get_numberTemperature_int()
03356 {
03357 return int(number_temper) ;
03358 }
03359
03360
03361
03362
03363
03367 vector<double> MuSR_td_PSI_bin::get_temperatures_vector()
03368 {
03369 vector <double> dbl_Temper ;
03370
03371 for (int i = 0 ; i < number_temper ; i++)
03372 {
03373 dbl_Temper.push_back(double(temper[i])) ;
03374 }
03375
03376 return dbl_Temper;
03377 }
03378
03379
03380
03381
03382
03386 vector<double> MuSR_td_PSI_bin::get_devTemperatures_vector()
03387 {
03388 vector <double> dbl_devTemper ;
03389
03390 for (int i = 0 ; i < number_temper ; i++)
03391 {
03392 dbl_devTemper.push_back(double(temp_deviation[i])) ;
03393 }
03394
03395 return dbl_devTemper;
03396 }
03397
03398
03399
03400
03401
03406 vector<string> MuSR_td_PSI_bin::get_timeStart_vector()
03407
03408 {
03409 vector<string> timeStart(2) ;
03410
03411 timeStart[0] = date_start ;
03412 timeStart[1] = time_start ;
03413
03414 return timeStart ;
03415 }
03416
03417
03418
03419
03420
03421
03426 vector<string> MuSR_td_PSI_bin::get_timeStop_vector()
03427
03428 {
03429 vector<string> timeStop(2) ;
03430
03431 timeStop[0] = date_stop ;
03432 timeStop[1] = time_stop ;
03433
03434 return timeStop ;
03435 }
03436
03437
03438
03439
03440
03444 int MuSR_td_PSI_bin::Clear()
03445
03446 {
03447 int i,j;
03448
03449
03450
03451
03452 if (histo != NULL)
03453 {
03454 for (i=0; i < number_histo; i++)
03455 if (*(histo+i) != NULL)
03456 {
03457 delete[] *(histo+i);
03458 *(histo+i) = NULL;
03459 }
03460 delete [] histo;
03461 histo = NULL;
03462 }
03463
03464
03465 histos_vector.clear();
03466
03467
03468 filename = "?";
03469 readingok = false;
03470 readstatus = "";
03471
03472 strcpy(format_id,"??");
03473
03474 num_run = 0;
03475
03476 strcpy(sample, " ");
03477 strcpy(temp, " ");
03478 strcpy(field, " ");
03479 strcpy(orient, " ");
03480 strcpy(comment, " ");
03481 strcpy(date_start," ");
03482 strcpy(time_start," ");
03483 strcpy(date_stop, " ");
03484 strcpy(time_stop, " ");
03485
03486 bin_width = 0.f;
03487 number_histo = 0;
03488 length_histo = 0;
03489 total_events = 0;
03490 default_binning = 1;
03491
03492 for (i=0; i < MAXHISTO; i++)
03493 {
03494 for (j=0; j < MAXLABELSIZE-1; j++)
03495 labels_histo[i][j] = ' ';
03496 labels_histo[i][MAXLABELSIZE-1] = '\0';
03497 events_per_histo[i] = 0;
03498 real_t0[i] = 0.f;
03499 integer_t0[i] = 0;
03500 first_good[i] = 0;
03501 last_good[i] = 0;
03502 }
03503
03504 number_scaler = 0;
03505 for (i=0; i < MAXSCALER; i++)
03506 {
03507 for (j=0; j < MAXLABELSIZE-1; j++)
03508 labels_scalers[i][j] = ' ';
03509 labels_scalers[i][MAXLABELSIZE-1] = '\0';
03510
03511 scalers[i] = 0;
03512 }
03513
03514 number_temper = 0;
03515 for (i=0; i < MAXTEMPER; i++)
03516 {
03517 temper[i] = 0.f;
03518 temp_deviation[i] = 0.f;
03519 }
03520
03521 return 0;
03522 }
03523
03524
03525
03526
03530 int MuSR_td_PSI_bin::Show() const
03531
03532 {
03533 cout << "Filename is " << filename << endl;
03534 if (readingok) {
03535 int i;
03536
03537 cout << "Format Identifier is " << format_id << endl;
03538
03539 cout << "Run number is " << num_run << endl;
03540 cout << "Sample is " << sample << endl;
03541 cout << "Temperature is " << temp << endl;
03542 cout << "Field is " << field << endl;
03543 cout << "Orientation is " << orient << endl;
03544 cout << "Comment is " << comment << endl;
03545
03546 cout << "Start Date is " << date_start << endl;
03547 cout << "Start Time is " << time_start << endl;
03548
03549 cout << "End Date is " << date_stop << endl;
03550 cout << "End Time is " << time_stop << endl;
03551
03552 cout << "Bin width is " << bin_width << " [usec]" << endl;
03553 cout << "Number of histograms is " << number_histo << endl;
03554 cout << "Histogram length is " << length_histo << endl;
03555 cout << "Default binning is " << default_binning << endl;
03556 cout << "Total number of events is " << total_events << endl;
03557
03558 for (i=0; i < number_histo; i++) {
03559 cout << "Histogram " << i << " Name is >" << labels_histo[i]
03560 << "< Events per histogram is " << events_per_histo[i] << endl;
03561 cout << " real t0 is " << real_t0[i] << endl;
03562 cout << " t0 is " << integer_t0[i] << endl;
03563 cout << " first good bin is " << first_good[i] << endl;
03564 cout << " last good bin is " << last_good[i] << endl;
03565 }
03566
03567 cout << "Number of scalers is " << number_scaler << endl;
03568 for (i=0; i < number_scaler; i++) {
03569 cout << "Scaler " << i << " Name is >" << labels_scalers[i]
03570 << "< Value is " << scalers[i] << endl;
03571 }
03572
03573 cout << "Number of temperatures is " << number_temper << endl;
03574 for (i=0; i < number_temper; i++) {
03575 cout << "Temperature " << i << " is " << temper[i]
03576 << " Deviation is " << temp_deviation[i] << endl;
03577 }
03578
03579 } else {
03580 cout << readstatus << endl;
03581 }
03582 return 0;
03583 }
03584
03585
03586
03587
03588
03589
03590 int MuSR_td_PSI_bin::tmax(int x, int y)
03591 {
03592 if (x >= y)
03593 {
03594 return x ;
03595 }
03596 return y ;
03597 }
03598
03599
03600
03601
03602
03603
03604 int MuSR_td_PSI_bin::tmin(int x, int y)
03605 {
03606 if (x >= y)
03607 {
03608 return y ;
03609 }
03610 return x ;
03611 }
03612
03613
03614
03615
03616