diff --git a/src/classes/Makefile.PMusr b/src/classes/Makefile.PMusr index 599792cf..b46658e9 100644 --- a/src/classes/Makefile.PMusr +++ b/src/classes/Makefile.PMusr @@ -44,7 +44,8 @@ CXXFLAGS = -g -Wall -Wno-trigraphs -fPIC PMUSRPATH = ../include MNPATH = $(ROOTSYS)/include GSLPATH = /usr/include/gsl -INCLUDES = -I $(PMUSRPATH) -I $(MNPATH) -I $(GSLPATH) +PSIBINPATH = ../external/MuSR_software/Class_MuSR_PSI +INCLUDES = -I$(PMUSRPATH) -I$(MNPATH) -I$(GSLPATH) -I$(PSIBINPATH) LD = g++ LDFLAGS = -g SOFLAGS = -O -shared @@ -94,6 +95,9 @@ OBJS += PFitterFcn.o OBJS += PFitter.o OBJS += PMusrCanvas.o PMusrCanvasDict.o +EXTOBJS = +EXTOBJS += MuSR_td_PSI_bin.o + SHLIB = libPMusr.so # make the shared lib: @@ -103,7 +107,7 @@ all: $(SHLIB) $(SHLIB): $(OBJS) @echo "---> Building shared library $(SHLIB) ..." /bin/rm -f $(SHLIB) - $(LD) $(OBJS) $(SOFLAGS) -o $(SHLIB) $(GLIBS) $(PSILIBS) $(MNLIB) $(GSLLIB) + $(LD) $(OBJS) $(EXTOBJS) $(SOFLAGS) -o $(SHLIB) $(GLIBS) $(PSILIBS) $(MNLIB) $(GSLLIB) @echo "done" # clean up: remove all object file (and core files) @@ -117,6 +121,9 @@ clean:; @rm -f $(OBJS) *Dict* core* $(OBJS): %.o: %.cpp $(CXX) $(INCLUDES) $(CXXFLAGS) -c $< +MuSR_td_PSI_bin.o: ../external/MuSR_software/Class_MuSR_PSI/MuSR_td_PSI_bin.cpp + $(CXX) $(INCLUDES) $(CXXFLAGS) -c ../external/MuSR_software/Class_MuSR_PSI/MuSR_td_PSI_bin.cpp + PStartupHandlerDict.cpp: ../include/PStartupHandler.h @echo "Generating dictionary $@..." rootcint -f $@ -c -p $^ diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index 86aa9e21..7905dfd4 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -31,6 +31,7 @@ #include #include +#include using namespace std; #include @@ -43,6 +44,7 @@ using namespace std; #include #include "TLemRunHeader.h" +#include "MuSR_td_PSI_bin.h" #include "PRunDataHandler.h" //-------------------------------------------------------------------------- @@ -420,6 +422,11 @@ bool PRunDataHandler::ReadRootFile() // add run to the run list fData.push_back(runData); + // clean up + for (unsigned int i=0; i> time resolution : " << runData.fTimeResolution; // add run to the run list fData.push_back(runData); + // clean up + for (unsigned int i=0; i> time resolution : " << runData.fTimeResolution; */ bool PRunDataHandler::ReadPsiBinFile() { - cout << endl << "PRunDataHandler::ReadPsiBinFile(): Sorry, not yet implemented ..."; - return false; +// cout << endl << "PRunDataHandler::ReadPsiBinFile(): Sorry, not yet implemented ..."; + + MuSR_td_PSI_bin psiBin; + int status; + bool success; + + // read psi bin file + status = psiBin.read(fRunPathName.Data()); + switch (status) { + case 0: // everything perfect + success = true; + break; + case 1: // couldn't open file, or failed while reading the header + cout << endl << "**ERROR** couldn't open psibin file, or failed while reading the header"; + cout << endl; + success = false; + break; + case 2: // unsupported version of the data + cout << endl << "**ERROR** psibin file: unsupported version of the data"; + cout << endl; + success = false; + break; + case 3: // error when allocating data buffer + cout << endl << "**ERROR** psibin file: error when allocating data buffer"; + cout << endl; + success = false; + break; + case 4: // number of histograms/record not equals 1 + cout << endl << "**ERROR** psibin file: number of histograms/record not equals 1"; + cout << endl; + success = false; + break; + default: // you never should have reached this point + success = false; + break; + } + + // if any reading error happend, get out of here + if (!success) + return success; + +cout << endl << "> " << psiBin.get_numberHisto_int() << ": "; +for (int i=0; i " << psiBin.get_nameHisto(i); +cout << endl; + + // fill necessary header informations + PIntVector ivec; + PRawRunData runData; + double dval; + // keep run name + runData.fRunName = fRunName; + // get run title + runData.fRunTitle = TString(psiBin.get_comment().c_str()); // run title + // get setup + runData.fSetup = TString(""); + // get field + status = sscanf(psiBin.get_field().c_str(), "%lfG", &dval); + if (status == 1) + runData.fField = dval; + // get temperature + status = sscanf(psiBin.get_temp().c_str(), "%lfK", &dval); + if (status == 1) + runData.fTemp = dval; + // get time resolution (ns) + runData.fTimeResolution = psiBin.get_binWidth_ns(); + // get t0's + ivec = psiBin.get_t0_vector(); + if (ivec.empty()) { + cout << endl << "**ERROR** psibin file: couldn't obtain any t0's"; + cout << endl; + return false; + } + for (unsigned int i=0; i +using namespace std ; +#include +#include +#include +#include "MuSR_td_PSI_bin.h" + + +//******************************* +//Implementation constructor +//******************************* + +/*! \brief Simple Constructor setting some pointers and variables + */ + + MuSR_td_PSI_bin::MuSR_td_PSI_bin() + { + + number_histo = 0; + histo = NULL; + } + + +//******************************* +//Implementation desructor +//******************************* + +/*! \brief Simple Destructor clearing some pointers and variables + */ + + MuSR_td_PSI_bin::~MuSR_td_PSI_bin() + { + +// if (histo != NULL) +// { +// for (int i=0; i < number_histo; i++) +// if (*(histo+i) != NULL) delete[] *(histo+i); +// delete [] histo; +// } + + number_histo = 0; + } + + +//******************************* +//Implementation read +//******************************* + +/*! \brief Method to read a PSI-bin file + * + * This method gives back: + * - 0 for succesful reading + * - 1 if the open file action or the reading of the header failed + * - 2 for an unsupported version of the data + * - 3 for an error when allocating data buffer + * - 4 if number of histograms/record not equals 1\n + * + * The parameter of the method is a const char * representing the name of the file to be open. + */ + + int MuSR_td_PSI_bin::read(const char * fileName) + { + ifstream file_name ; + Int16 *dum_Int16 ; + Int32 *dum_Int32 ; + Float32 *dum_Float32 ; + Int32 i ; + + if (histo != NULL) + { + for (int i=0; i < number_histo; i++) + if (*(histo+i) != NULL) delete[] *(histo+i); + delete [] histo; + } + number_histo = 0; + + file_name.open(fileName, ios_base::binary); // open PSI bin file + if (file_name.fail()) return 1; // ERROR open failed + + char *buffer_file = new char[1024] ; + if (!buffer_file) return 3; // ERROR allocating data buffer + + file_name.read(buffer_file, 1024) ; // read header into buffer + if (file_name.fail()) + { + file_name.close(); + delete [] buffer_file; + return 1; // ERROR reading header failed + } + // fill header data into member variables + strncpy(format_id,buffer_file,2); + format_id[2] = '\0' ; + if (strcmp(format_id,"1N") == 1) + { + file_name.close(); + delete [] buffer_file; + return 2 ; // ERROR unsupported version + } + + dum_Int16 = (Int16 *) &buffer_file[2] ; + tdc_resolution = *dum_Int16 ; + dum_Int16 = (Int16 *) &buffer_file[4] ; + tdc_overflow = *dum_Int16 ; + dum_Int16 = (Int16 *) &buffer_file[6] ; + num_run = *dum_Int16 ; + dum_Int16 = (Int16 *) &buffer_file[28] ; + length_histo = *dum_Int16 ; + dum_Int16 = (Int16 *) &buffer_file[30] ; + number_histo = *dum_Int16 ; + strncpy(sample,buffer_file+138,10) ; + sample[10] = '\0' ; + strncpy(temp,buffer_file+148,10) ; + temp[10] = '\0' ; + strncpy(field,buffer_file+158,10) ; + field[10] = '\0' ; + strncpy(orient,buffer_file+168,10) ; + orient[10] = '\0' ; + strncpy(comment,buffer_file+860,62) ; + comment[62] = '\0' ; + strncpy(date_start,buffer_file+218,9) ; + date_start[9] = '\0' ; + strncpy(date_stop,buffer_file+227,9) ; + date_stop[9] = '\0' ; + strncpy(time_start,buffer_file+236,8) ; + time_start[8] = '\0' ; + strncpy(time_stop,buffer_file+244,8) ; + time_stop[8] = '\0' ; + + dum_Int32 = (Int32 *) &buffer_file[424] ; + total_events = *dum_Int32 ; + + for (i=0; i<=15; i++) + { + strncpy(labels_histo[i],buffer_file+948+i*4,4) ; + labels_histo[i][4] = '\0' ; + dum_Int32 = (Int32 *) &buffer_file[296+i*4] ; + events_per_histo[i] = *dum_Int32 ; + dum_Int16 = (Int16 *) &buffer_file[458+i*2] ; + integer_t0[i] = *dum_Int16 ; + dum_Int16 = (Int16 *) &buffer_file[490+i*2] ; + first_good[i] = *dum_Int16 ; + dum_Int16 = (Int16 *) &buffer_file[522+i*2] ; + last_good[i] = *dum_Int16 ; + } + + for (i=0; i<=16; i++) + { + dum_Float32 = (Float32 *) &buffer_file[792+i*4] ; + real_t0[i] = *dum_Float32 ; + } + + for (i=0; i<=5; i++) + { + dum_Int32 = (Int32 *) &buffer_file[670+i*4] ; + scalers[i] = *dum_Int32 ; + strncpy(labels_scalers[i],buffer_file+924+i*4,4) ; + labels_scalers[i][4] = '\0' ; + } + + for (i=6; i<=17; i++) + { + dum_Int32 = (Int32 *) &buffer_file[360+(i-6)*4] ; + scalers[i] = *dum_Int32 ; + strncpy(labels_scalers[i],buffer_file+554+(i-6)*4,4) ; + labels_scalers[i][4] = '\0' ; + } + + dum_Float32 = (Float32 *) &buffer_file[1012] ; + bin_width = *dum_Float32 ; + + if (bin_width == 0.) + { + bin_width=(625.E-6)/8.*pow(Float32(2.),Float32(tdc_resolution)) ; + } + + for (i=0; i<=3; i++) + { + dum_Float32 = (Float32 *) &buffer_file[716+i*4] ; + temper[i] = *dum_Float32 ; + dum_Float32 = (Float32 *) &buffer_file[738+i*4] ; + temp_deviation[i] = *dum_Float32 ; + dum_Float32 = (Float32 *) &buffer_file[72+i*4] ; + mon_low[i] = *dum_Float32 ; + dum_Float32 = (Float32 *) &buffer_file[88+i*4] ; + mon_high[i] = *dum_Float32 ; + } + + dum_Int32 = (Int32 *) &buffer_file[712] ; + mon_num_events = *dum_Int32 ; + strncpy(mon_dev,buffer_file+60,12) ; + mon_dev[12] = '\0' ; + + dum_Int16 = (Int16 *) &buffer_file[128] ; // numdaf + num_data_records_file = *dum_Int16 ; + dum_Int16 = (Int16 *) &buffer_file[130] ; // lendaf + length_data_records_bins = *dum_Int16 ; + dum_Int16 = (Int16 *) &buffer_file[132] ; // kdafhi + num_data_records_histo = *dum_Int16 ; + dum_Int16 = (Int16 *) &buffer_file[134] ; // khidaf + + if (*dum_Int16 != 1) + { + cout << "ERROR number of histograms/record not equals 1!" + << " Required algorithm is not implemented!" << endl; + delete [] buffer_file ; + file_name.close(); + return 4; // ERROR algorithm not implemented + } + + dum_Int32 = (Int32 *) &buffer_file[654] ; + period_save = *dum_Int32 ; + dum_Int32 = (Int32 *) &buffer_file[658] ; + period_mon = *dum_Int32 ; + + if (buffer_file) delete [] buffer_file ; + + // allocate histograms + histo = new Int32* [int(number_histo)]; + + for (Int32 i=0; i dummy_vector ; + for (i=0; i with binning \ + * + * This method gives back: + * - an pointer of a double array + * - the NULL pointer if an invalid histogram number or binning is choosen + * + * The parameters of the method are the integers \ and \ representing the desired histogram number and binning. + */ + + double * MuSR_td_PSI_bin::get_histo_array(int histo_num , int binning) + { + if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 ) + return NULL ; + double *histo_array = new double[int(int(length_histo)/binning)] ; + for (int i = 0 ; i < int(int(length_histo)/binning) ; i++) + { + histo_array[i] = 0 ; + for (int j = 0 ; j < binning ; j++) + histo_array[i] += double(histo[histo_num][i*binning+j]) ; + } + return histo_array ; + } + + +//******************************* +//Implementation get_histo_vector +//******************************* + +/*! \brief Method to obtain a vector of double containing the values of the histogram \ with binning \ + * + * This method gives back: + * - a vector of double + * - an empty vector of double if an invalid number or binning is choosen + * + * The parameters of the method are the integers \ and \ representing the desired histogram number and binning. + */ + + vector MuSR_td_PSI_bin::get_histo_vector(int histo_num , int binning) + { + vector histo_vector ; //(int(length_histo/binning)) + if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 ) + return histo_vector ; + for (int i = 0 ; i < int(length_histo/binning) ; i++) + histo_vector.push_back(0.) ; + for (int i = 0 ; i < int(length_histo/binning) ; i++) + { + for (int j = 0 ; j < binning ; j++) + histo_vector[i] += double(histo[histo_num][i*binning+j]) ; + } + return histo_vector ; + } + + +//******************************* +//Implementation get_histo_vector_no0 +//******************************* + +/*! \brief Method to obtain a vector of double containing the values of the histogram \ with binning \ but wwhere the bins with zero counts are replaced by a count 0.1 + * + * This method gives back: + * - a vector of double + * - an empty vector of double if an invalid number or binning is choosen + * + * The parameters of the method are the integers \ and \ representing the desired histogram number and binning. + */ + + vector MuSR_td_PSI_bin::get_histo_vector_no0(int histo_num , int binning) + { + vector histo_vector; //(int(length_histo/binning)) ; + if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 ) + return histo_vector ; + for (int i = 0 ; i < int(length_histo/binning) ; i++) + histo_vector.push_back(0.) ; + for (int i = 0 ; i < int(length_histo/binning) ; i++) + { + for (int j = 0 ; j < binning ; j++) + histo_vector[i] += double(histo[histo_num][i*binning+j]) ; + if (histo_vector[i] < 0.5 ) + { + histo_vector[i] = 0.1 ; + } + } + return histo_vector ; + } + + +//********************************** +//Implementation get_histo_array_int +//********************************** + +/*! \brief Method to obtain an array of type integer containing the values of the histogram \ + * + * This method gives back: + * - an pointer of a integer array + * - the NULL pointer if an invalid histogram number is choosen + * + * The parameter of the method is the integer \ representing the desired histogram number. + */ + + int * MuSR_td_PSI_bin::get_histo_array_int(int histo_num) + { + if ( histo_num < 0 || histo_num >= int(number_histo)) + return NULL ; + int *histo_array = new int[length_histo] ; + for (int i = 0 ; i < int(length_histo) ; i++) + { + histo_array[i] = int(histo[histo_num][i]) ; + } + return histo_array ; + } + + +//******************************* +//Implementation get_histo_fromt0_array +//******************************* + +/*! \brief Method to obtain an array of type double containing the values of the histogram \ with binning \ from the point t0. An \ can also be specified (otherwise = 0). + * + * This method gives back: + * - an pointer of a double array + * - the NULL pointer if an invalid histogram number or binning is choosen + * + * The parameters of the method are the integers \ and \ representing the desired histogram number and binning. + */ + + double * MuSR_td_PSI_bin::get_histo_fromt0_array(int histo_num , int binning , int offset) + { + if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 ) + return NULL ; + double *histo_fromt0_array = new double[int((int(length_histo)-get_t0_int(histo_num)-offset+1)/binning)] ; + for (int i = 0 ; i < int((int(length_histo)-get_t0_int(histo_num)-offset)/binning) ; i++) + { + histo_fromt0_array[i] = 0 ; + for (int j = 0 ; j < binning ; j++) + histo_fromt0_array[i] += double(histo[histo_num][i*binning+j+get_t0_int(histo_num)+offset]) ; + } + return histo_fromt0_array ; + } + + +//******************************* +//Implementation get_histo_fromt0_vector +//******************************* + +/*! \brief Method to obtain a vector of double containing the values of the histogram \ with binning \ from the point t0. An \ can also be specified (otherwise = 0). + * + * This method gives back: + * - a vector of double + * - an empty vector of double if an invalid histogram number or binning is choosen + * + * The parameters of the method are the integers \ and \ representing the desired histogram number and binning. + */ + + vector MuSR_td_PSI_bin::get_histo_fromt0_vector(int histo_num , int binning , int offset) + { + vector histo_fromt0_vector ; // (int((int(length_histo)-get_t0_int(histo_num)+1)/binning)) ; + if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 ) + return histo_fromt0_vector ; + for (int i = 0 ; i < int((int(length_histo)-get_t0_int(histo_num)-offset)/binning) ; i++) + histo_fromt0_vector.push_back(0.) ; + for (int i = 0 ; i < int((int(length_histo)-get_t0_int(histo_num)-offset)/binning) ; i++) + { + for (int j = 0 ; j < binning ; j++) + histo_fromt0_vector[i] += double(histo[histo_num][i*binning+j+get_t0_int(histo_num)+offset]) ; + } + return histo_fromt0_vector ; + } + + +//******************************* +//Implementation get_histo_goodBins_array +//******************************* + +/*! \brief Method to obtain an array of type double containing the values of the histogram \ with binning \ from the point first_good until last_good + * + * This method gives back: + * - an pointer of a double array + * - the NULL pointer if an invalid histogram number or binning is choosen + * + * The parameters of the method are the integers \ and \ representing the desired histogram number and binning. + */ + + double * MuSR_td_PSI_bin::get_histo_goodBins_array(int histo_num , int binning) + { + if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 ) + return NULL ; + double *histo_goodBins_array = new double[int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num)+1)/binning)] ; + for (int i = 0 ; i < int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num))/binning) ; i++) + { + histo_goodBins_array[i] = 0 ; + for (int j = 0 ; j < binning ; j++) + histo_goodBins_array[i] += double(histo[histo_num][i*binning+j+get_firstGood_int(histo_num)]) ; + } + return histo_goodBins_array ; + } + + +//******************************* +//Implementation get_histo_goodBins_vector +//******************************* + +/*! \brief Method to obtain a vector of double containing the values of the histogram \ with binning \ from the point first_good until last_good + * + * This method gives back: + * - a vector of double + * - an empty vector of double if an invalid histogram number or binning is choosen + * + * The parameters of the method are the integers \ and \ representing the desired histogram number and binning. + */ + + vector MuSR_td_PSI_bin::get_histo_goodBins_vector(int histo_num , int binning) + { + vector histo_goodBins_vector ; + if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 ) + return histo_goodBins_vector ; + for (int i = 0 ; i < int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num))/binning) ; i++) + histo_goodBins_vector.push_back(0.) ; + for (int i = 0 ; i < int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num))/binning) ; i++) + { + for (int j = 0 ; j < binning ; j++) + histo_goodBins_vector[i] += double(histo[histo_num][i*binning+j+get_firstGood_int(histo_num)]) ; + } + return histo_goodBins_vector ; + } + + +//******************************* +//Implementation get_histo_fromt0_minus_bckgrd_array +//******************************* + +/*! \brief Method to obtain an array of type double containing the values of the histogram \ with binning \ from the point t0. A background calculated from the points \ and \ is subtracted. An \ can also be specified (otherwise = 0). + * + * This method gives back: + * - a pointer of a double array + * - the NULL pointer if one provides + * - an invalid histogram number + * - a binning smaller than 1 + * - invalid background limits + * + * The first parameters of the method are the integers \ and \ representing the desired histogram number and binning. + * Also the parameters \ and \ define the limits between which the background is calculated. + */ + +double * MuSR_td_PSI_bin::get_histo_fromt0_minus_bckgrd_array(int histo_num , int lower_bckgrd , + int higher_bckgrd , int binning, int offset) + { + double *histo_fromt0_minus_bckgrd_array = new double[int((int(length_histo)-get_t0_int(histo_num)-offset+1)/binning)] ; + if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 ) + return NULL ; + if ( lower_bckgrd < 0 || higher_bckgrd >= int(length_histo) || lower_bckgrd > higher_bckgrd ) + return NULL ; + double bckgrd = 0 ; + for (int k = lower_bckgrd ; k <= higher_bckgrd ; k++) + { + bckgrd += double(histo[histo_num][k]) ; + } + bckgrd = bckgrd/(higher_bckgrd-lower_bckgrd+1) ; + for (int i = 0 ; i < int((int(length_histo)-get_t0_int(histo_num)-offset)/binning) ; i++) + { + histo_fromt0_minus_bckgrd_array[i] = 0 ; + for (int j = 0 ; j < binning ; j++) + histo_fromt0_minus_bckgrd_array[i] += + double(histo[histo_num][i*binning+j+get_t0_int(histo_num)+offset]) - bckgrd; + } + return histo_fromt0_minus_bckgrd_array ; + } ; + + +//******************************* +//Implementation get_histo_fromt0_minus_bckgrd_vector +//******************************* + +/*! \brief Method to obtain a vector of double containing the values of the histogram \ with binning \ from the point t0. A background calculated from the points \ and \ is subtracted. An \ can also be specified (otherwise = 0). + * + * This method gives back: + * - a vector of double + * - an empty vector of double if one provides + * - an invalid histogram number + * - a binning smaller than 1 + * - invalid background limits + * + * The first parameters of the method are the integers \ and \ representing the desired histogram number and binning. + * Also the parameters \ and \ define the limits between which the background is calculated. + */ + + vector MuSR_td_PSI_bin::get_histo_fromt0_minus_bckgrd_vector(int histo_num , int lower_bckgrd , + int higher_bckgrd , int binning, int offset) + { + vector histo_fromt0_minus_bckgrd_vector ; // (int((int(length_histo)-get_t0_int(histo_num)+1)/binning)) ; + if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 ) + return histo_fromt0_minus_bckgrd_vector ; + if ( lower_bckgrd < 0 || higher_bckgrd >= int(length_histo) || lower_bckgrd > higher_bckgrd ) + return histo_fromt0_minus_bckgrd_vector ; + double bckgrd = 0 ; + for (int k = lower_bckgrd ; k <= higher_bckgrd ; k++) + { + bckgrd += double(histo[histo_num][k]) ; + } + bckgrd = bckgrd/(higher_bckgrd-lower_bckgrd+1) ; + for (int i = 0 ; i < int((int(length_histo)-get_t0_int(histo_num)-offset)/binning) ; i++) + histo_fromt0_minus_bckgrd_vector.push_back(0.) ; + for (int i = 0 ; i < int((int(length_histo)-get_t0_int(histo_num)-offset)/binning) ; i++) + { + for (int j = 0 ; j < binning ; j++) + histo_fromt0_minus_bckgrd_vector[i] += + double(histo[histo_num][i*binning+j+get_t0_int(histo_num)+offset]) - bckgrd; + } + return histo_fromt0_minus_bckgrd_vector ; + } + + +//******************************* +//Implementation get_histo_goodBins_minus_bckgrd_array +//******************************* + +/*! \brief Method to obtain an array of type double containing the values of the histogram \ with binning \ from the point first_good until the point last_good. A background calculated from the points \ and \ is subtracted + * + * This method gives back: + * - a pointer of a double array + * - the NULL pointer if one provides + * - an invalid histogram number + * - a binning smaller than 1 + * - invalid background limits + * + * The first parameters of the method are the integers \ and \ representing the desired histogram number and binning. + * Also the parameters \ and \ define the limits between which the background is calculated. + */ + +double * MuSR_td_PSI_bin::get_histo_goodBins_minus_bckgrd_array(int histo_num , int lower_bckgrd , + int higher_bckgrd , int binning) + { + double *histo_goodBins_minus_bckgrd_array = new double[int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num)+1)/binning)] ; + if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 ) + return NULL ; + if ( lower_bckgrd < 0 || higher_bckgrd >= int(length_histo) || lower_bckgrd > higher_bckgrd ) + return NULL ; + double bckgrd = 0 ; + for (int k = lower_bckgrd ; k <= higher_bckgrd ; k++) + { + bckgrd += double(histo[histo_num][k]) ; + } + bckgrd = bckgrd/(higher_bckgrd-lower_bckgrd+1) ; + for (int i = 0 ; i < int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num))/binning) ; i++) + { + histo_goodBins_minus_bckgrd_array[i] = 0 ; + for (int j = 0 ; j < binning ; j++) + histo_goodBins_minus_bckgrd_array[i] += + double(histo[histo_num][i*binning+j+get_firstGood_int(histo_num)]) - bckgrd; + } + return histo_goodBins_minus_bckgrd_array ; + } ; + + +//******************************* +//Implementation get_histo_goodBins_minus_bckgrd_vector +//******************************* + +/*! \brief Method to obtain a vector of double containing the values of the histogram \ with binning \ from the point first_good until the point last_good. A background calculated from the points \ and \ is subtracted + * + * This method gives back: + * - a vector of double + * - an empty vector of double if one provides + * - an invalid histogram number + * - a binning smaller than 1 + * - invalid background limits + * + * The first parameters of the method are the integers \ and \ representing the desired histogram number and binning. + * Also the parameters \ and \ define the limits between which the background is calculated. + */ + + vector MuSR_td_PSI_bin::get_histo_goodBins_minus_bckgrd_vector(int histo_num , int lower_bckgrd , + int higher_bckgrd , int binning) + { + vector histo_goodBins_minus_bckgrd_vector ; ; + if ( histo_num < 0 || histo_num >= int(number_histo) || binning <= 0 ) + return histo_goodBins_minus_bckgrd_vector ; + if ( lower_bckgrd < 0 || higher_bckgrd >= int(length_histo) || lower_bckgrd > higher_bckgrd ) + return histo_goodBins_minus_bckgrd_vector ; + double bckgrd = 0 ; + for (int k = lower_bckgrd ; k <= higher_bckgrd ; k++) + { + bckgrd += double(histo[histo_num][k]) ; + } + bckgrd = bckgrd/(higher_bckgrd-lower_bckgrd+1) ; + for (int i = 0 ; i < int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num))/binning) ; i++) + histo_goodBins_minus_bckgrd_vector.push_back(0.) ; + for (int i = 0 ; i < int((get_lastGood_int(histo_num)-get_firstGood_int(histo_num))/binning) ; i++) + { + for (int j = 0 ; j < binning ; j++) + histo_goodBins_minus_bckgrd_vector[i] += + double(histo[histo_num][i*binning+j+get_firstGood_int(histo_num)]) - bckgrd; + } + return histo_goodBins_minus_bckgrd_vector ; + } + + +//******************************* +//Implementation get_asymmetry_array +//******************************* + +/*! \brief Method to obtain an array of double containing the values of the asymmetry between 2 histograms. + * + * The asymmetry is calculated between the histograms \ and \ with an alpha parameter + * \. This method requires also a binning value \, as well as the background limits for both histograms. + * An \ value from t_0 can also be specified (otherwise = 0). + * Also an \ can be given to shift artificially the curve on the y-axis (otherwise = 0). + * + * This method gives back: + * - a array of double + * - the NULL pointer if one provides + * - an invalid histogram number + * - a binning smaller than 1 + * - invalid background limits + * + * The first parameters of the method are the integers \ and \, as well as the double \. + * Integers for the binning and for the background limits for both histograms.are also required. + */ + + double * MuSR_td_PSI_bin::get_asymmetry_array(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 , + double y_offset) + { + int max_t0 = max(get_t0_int(histo_num_plus),get_t0_int(histo_num_minus)) ; + double *asymmetry_array = new double[int((int(length_histo)-max_t0-offset+1)/binning)] ; + if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 ) + return NULL ; + if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) ) + return NULL ; + if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus ) + return NULL ; + if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus ) + return NULL ; + double *dummy_1 = new double ; + dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus , + higher_bckgrd_plus , binning , offset) ; + double *dummy_2 = new double ; + dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus , + higher_bckgrd_minus , binning , offset) ; + for (int i = 0 ; i < int((int(length_histo)-max_t0)/binning) ; i++) + { + asymmetry_array[i] = (dummy_1[i] - alpha_param * dummy_2[i]) / + (dummy_1[i] + alpha_param * dummy_2[i]) + y_offset ; + } + return asymmetry_array ; + } + + +//******************************* +//Implementation get_asymmetry_vector +//******************************* + +/*! \brief Method to obtain a vector of double containing the values of the asymmetry between 2 histograms. + * + * The asymmetry is calculated between the histograms \ and \ with an alpha parameter + * \. This method requires also a binning value \, as well as the background limits for both histograms. + * An \ value from t_0 can also be specified (otherwise = 0). + * Also an \ can be given to shift artificially the curve on the y-axis (otherwise = 0). + * + * This method gives back: + * - a vector of double + * - an empty vector of double if one provides + * - an invalid histogram number + * - a binning smaller than 1 + * - invalid background limits + * + * The first parameters of the method are the integers \ and \, as well as the double \. + * Integers for the binning and for the background limits for both histograms.are also required. + */ + + vector MuSR_td_PSI_bin::get_asymmetry_vector(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 , double y_offset) + { + int max_t0 = max(get_t0_int(histo_num_plus),get_t0_int(histo_num_minus)) ; + vector asymmetry_vector ; // (int((int(length_histo)-max_t0+1)/binning)) ; + if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 ) + return asymmetry_vector ; + if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) ) + return asymmetry_vector ; + if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus ) + return asymmetry_vector ; + if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus ) + return asymmetry_vector ; + double *dummy_1 = new double ; + dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus , + higher_bckgrd_plus , binning, offset) ; + double *dummy_2 = new double ; + dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus , + higher_bckgrd_minus , binning, offset) ; + for (int i = 0 ; i < int((int(length_histo)-max_t0-offset)/binning) ; i++) + asymmetry_vector.push_back(0.) ; + for (int i = 0 ; i < int((int(length_histo)-max_t0-offset)/binning) ; i++) + { + asymmetry_vector[i] = (dummy_1[i] - alpha_param * dummy_2[i]) / + (dummy_1[i] + alpha_param * dummy_2[i]) + y_offset ; + } + return asymmetry_vector ; + } + + +//******************************* +//Implementation get_error_asymmetry_array +//******************************* + +/*! \brief Method to obtain an array of double containing the values of the error of the asymmetry between 2 histograms. + * + * The error of the asymmetry is calculated with the histograms \ and \ with an alpha parameter + * \. This method requires also a binning value \, as well as the background limits for both histograms. + * An \ value from t_0 can also be specified (otherwise = 0) + * + * This method gives back: + * - a array of double + * - the NULL pointer if one provides + * - an invalid histogram number + * - a binning smaller than 1 + * - invalid background limits + * + * The first parameters of the method are the integers \ and \, as well as the double \. + * Integers for the binning and for the background limits for both histograms.are also required. + */ + + double * MuSR_td_PSI_bin::get_error_asymmetry_array(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) + { + int max_t0 = max(get_t0_int(histo_num_plus),get_t0_int(histo_num_minus)) ; + double *error_asymmetry_array = new double[int((int(length_histo)-max_t0-offset+1)/binning)] ; + if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 ) + return NULL ; + if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) ) + return NULL ; + if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus ) + return NULL ; + if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus ) + return NULL ; + double *dummy_1 = new double ; + dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus , + higher_bckgrd_plus , binning, offset) ; + double *dummy_2 = new double ; + dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus , + higher_bckgrd_minus , binning, offset) ; + for (int i = 0 ; i < int((length_histo-max_t0-offset)/binning) ; i++) + { + if (dummy_1[i] < 0.5 || dummy_2[i] < 0.5 ) + error_asymmetry_array[i] = 1.0 ; + else + error_asymmetry_array[i] = double(2.) * alpha_param * sqrt(dummy_1[i]*dummy_2[i]*(dummy_1[i]+dummy_2[i])) / + pow(dummy_1[i] + alpha_param * dummy_2[i],2.) ; + } + return error_asymmetry_array ; + } + + +//******************************* +//Implementation get_error_asymmetry_vector +//******************************* + +/*! \brief Method to obtain a vector of double containing the values of the error of the asymmetry between 2 histograms. + * + * The error of the asymmetry is calculated with the histograms \ and \ with an alpha parameter + * \. This method requires also a binning value \, as well as the background limits for both histograms. + * An \ value from t_0 can also be specified (otherwise = 0) + * + * This method gives back: + * - a vector of double + * - an empty vector of double if one provides + * - an invalid histogram number + * - a binning smaller than 1 + * - invalid background limits + * + * The first parameters of the method are the integers \ and \, as well as the double \. + * Integers for the binning and for the background limits for both histograms.are also required. + */ + + vector MuSR_td_PSI_bin::get_error_asymmetry_vector(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) + { + int max_t0 = max(get_t0_int(histo_num_plus),get_t0_int(histo_num_minus)) ; + vector error_asymmetry_vector ; //(int((int(length_histo)-max_t0+1)/binning)) ; + if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 ) + return error_asymmetry_vector ; + if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) ) + return error_asymmetry_vector ; + if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus ) + return error_asymmetry_vector ; + if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus ) + return error_asymmetry_vector ; + double *dummy_1 = new double ; + dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus , + higher_bckgrd_plus , binning, offset) ; + double *dummy_2 = new double ; + dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus , + higher_bckgrd_minus , binning, offset) ; + for (int i = 0 ; i < int((int(length_histo)-max_t0-offset)/binning) ; i++) + error_asymmetry_vector.push_back(0.) ; + for (int i = 0 ; i < int((int(length_histo-max_t0-offset))/binning) ; i++) + { + if (dummy_1[i] < 0.5 || dummy_2[i] < 0.5 ) + error_asymmetry_vector[i] = 1.0 ; + else + error_asymmetry_vector[i] = double(2.) * alpha_param * sqrt(dummy_1[i]*dummy_2[i]*(dummy_1[i]+dummy_2[i])) / + pow(dummy_1[i] + alpha_param * dummy_2[i],2.) ; + } + return error_asymmetry_vector ; + } + + +//******************************* +//Implementation get_asymmetry_goodBins_array +//******************************* + +/*! \brief Method to obtain an array of double containing the values of the asymmetry between 2 histograms. + * + * The array has a size corresponding to the minimum interval between first_good and last_good. + * It begins at the first_good coming at the latest after the corresponding t_0. + * The asymmetry is calculated between the histograms \ and \ with an alpha parameter + * \. This method requires also a binning value \, as well as the background limits for both histograms. + * + * This method gives back: + * - a array of double + * - the NULL pointer if one provides + * - an invalid histogram number + * - a binning smaller than 1 + * - invalid background limits + * + * The first parameters of the method are the integers \ and \, as well as the double \. + * Integers for the binning and for the background limits for both histograms.are also required. + */ + + double * MuSR_td_PSI_bin::get_asymmetry_goodBins_array(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 hsize = int((min(get_lastGood_int(histo_num_plus)-get_firstGood_int(histo_num_plus),get_lastGood_int(histo_num_minus)-get_firstGood_int(histo_num_minus))+1)/binning) ; + double *asymmetry_goodBins_array = new double[hsize] ; + if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 ) + return NULL ; + if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) ) + return NULL ; + if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus ) + return NULL ; + if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus ) + return NULL ; + double *dummy_1 = new double ; + dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus , + higher_bckgrd_plus , binning) ; + double *dummy_2 = new double ; + dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus , + higher_bckgrd_minus , binning) ; + int hstart = max(get_firstGood_int(histo_num_plus)-get_t0_int(histo_num_plus),get_firstGood_int(histo_num_minus)-get_t0_int(histo_num_minus)) ; + for (int i = 0 ; i < hsize ; i++) + { + asymmetry_goodBins_array[i] = (dummy_1[i+hstart] - alpha_param * dummy_2[i+hstart]) / + (dummy_1[i+hstart] + alpha_param * dummy_2[i+hstart]) ; + } + return asymmetry_goodBins_array ; + } + + +//******************************* +//Implementation get_asymmetry_goodBins_vector +//******************************* + +/*! \brief Method to obtain a vector of double containing the values of the asymmetry between 2 histograms. + * + * The vector has a size corresponding to the minimum interval between first_good and last_good. + * It begins at the first_good coming at the latest after the corresponding t_0. + * The asymmetry is calculated between the histograms \ and \ with an alpha parameter + * \. This method requires also a binning value \, as well as the background limits for both histograms. + * + * This method gives back: + * - a vector of double + * - an empty vector of double if one provides + * - an invalid histogram number + * - a binning smaller than 1 + * - invalid background limits + * + * The first parameters of the method are the integers \ and \, as well as the double \. + * Integers for the binning and for the background limits for both histograms.are also required. + */ + + vector MuSR_td_PSI_bin::get_asymmetry_goodBins_vector(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 hsize = int((min(get_lastGood_int(histo_num_plus)-get_firstGood_int(histo_num_plus),get_lastGood_int(histo_num_minus)-get_firstGood_int(histo_num_minus))+1)/binning) ; + vector asymmetry_goodBins_vector ; + if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 ) + return asymmetry_goodBins_vector ; + if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) ) + return asymmetry_goodBins_vector ; + if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus ) + return asymmetry_goodBins_vector ; + if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus ) + return asymmetry_goodBins_vector ; + double *dummy_1 = new double ; + dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus , + higher_bckgrd_plus , binning) ; + double *dummy_2 = new double ; + dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus , + higher_bckgrd_minus , binning) ; + for (int i = 0 ; i < hsize ; i++) + asymmetry_goodBins_vector.push_back(0.) ; + int hstart = max(get_firstGood_int(histo_num_plus)-get_t0_int(histo_num_plus),get_firstGood_int(histo_num_minus)-get_t0_int(histo_num_minus)) ; + for (int i = 0 ; i < hsize ; i++) + { + asymmetry_goodBins_vector[i] = (dummy_1[i+hstart] - alpha_param * dummy_2[i+hstart]) / + (dummy_1[i+hstart] + alpha_param * dummy_2[i+hstart]) ; + } + return asymmetry_goodBins_vector ; +cout << hsize << " " << hstart << endl ; + } + + +//******************************* +//Implementation get_error_asymmetry_goodBins_array +//******************************* + +/*! \brief Method to obtain an array of double containing the values of the error of the asymmetry between 2 histograms. + * + * The size is calculated as the asymmetry array. + * The error of the asymmetry is calculated with the histograms \ and \ with an alpha parameter + * \. This method requires also a binning value \, as well as the background limits for both histograms. + * + * This method gives back: + * - a array of double + * - the NULL pointer if one provides + * - an invalid histogram number + * - a binning smaller than 1 + * - invalid background limits + * + * The first parameters of the method are the integers \ and \, as well as the double \. + * Integers for the binning and for the background limits for both histograms are also required. + */ + + double * MuSR_td_PSI_bin::get_error_asymmetry_goodBins_array(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 hsize = int((min(get_lastGood_int(histo_num_plus)-get_firstGood_int(histo_num_plus),get_lastGood_int(histo_num_minus)-get_firstGood_int(histo_num_minus))+1)/binning) ; + double *error_asymmetry_goodBins_array = new double[hsize] ; + if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 ) + return NULL ; + if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) ) + return NULL ; + if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus ) + return NULL ; + if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus ) + return NULL ; + double *dummy_1 = new double ; + dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus , + higher_bckgrd_plus , binning) ; + double *dummy_2 = new double ; + dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus , + higher_bckgrd_minus , binning) ; + int hstart = max(get_firstGood_int(histo_num_plus)-get_t0_int(histo_num_plus),get_firstGood_int(histo_num_minus)-get_t0_int(histo_num_minus)) ; + for (int i = 0 ; i < hsize ; i++) + { + if (dummy_1[i+hstart] < 0.5 || dummy_2[i+hstart] < 0.5 ) + error_asymmetry_goodBins_array[i] = 1.0 ; + else + error_asymmetry_goodBins_array[i] = double(2.) * alpha_param * sqrt(dummy_1[i+hstart]*dummy_2[i+hstart]*(dummy_1[i+hstart]+dummy_2[i+hstart])) / + pow(dummy_1[i+hstart] + alpha_param * dummy_2[i+hstart],2.) ; + } + return error_asymmetry_goodBins_array ; + } + + +//******************************* +//Implementation get_error_asymmetry_goodBins_vector +//******************************* + +/*! \brief Method to obtain a vector of double containing the values of the error of the asymmetry between 2 histograms. + * + * The size is calculated as the asymmetry array. + * The error of the asymmetry is calculated with the histograms \ and \ with an alpha parameter + * \. This method requires also a binning value \, as well as the background limits for both histograms. + * + * This method gives back: + * - a vector of double + * - an empty vector of double if one provides + * - an invalid histogram number + * - a binning smaller than 1 + * - invalid background limits + * + * The first parameters of the method are the integers \ and \, as well as the double \. + * Integers for the binning and for the background limits for both histograms.are also required. + */ + + vector MuSR_td_PSI_bin::get_error_asymmetry_goodBins_vector(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 hsize = int((min(get_lastGood_int(histo_num_plus)-get_firstGood_int(histo_num_plus),get_lastGood_int(histo_num_minus)-get_firstGood_int(histo_num_minus))+1)/binning) ; + vector error_asymmetry_goodBins_vector ; + if ( histo_num_plus < 0 || histo_num_plus >= int(number_histo) || binning <= 0 ) + return error_asymmetry_goodBins_vector ; + if ( histo_num_minus < 0 || histo_num_minus >= int(number_histo) ) + return error_asymmetry_goodBins_vector ; + if ( lower_bckgrd_plus < 0 || higher_bckgrd_plus >= int(length_histo) || lower_bckgrd_plus > higher_bckgrd_plus ) + return error_asymmetry_goodBins_vector ; + if ( lower_bckgrd_minus < 0 || higher_bckgrd_minus >= int(length_histo) || lower_bckgrd_minus > higher_bckgrd_minus ) + return error_asymmetry_goodBins_vector ; + double *dummy_1 = new double ; + dummy_1 = get_histo_fromt0_minus_bckgrd_array(histo_num_plus , lower_bckgrd_plus , + higher_bckgrd_plus , binning) ; + double *dummy_2 = new double ; + dummy_2 = get_histo_fromt0_minus_bckgrd_array(histo_num_minus , lower_bckgrd_minus , + higher_bckgrd_minus , binning) ; + for (int i = 0 ; i < hsize ; i++) + error_asymmetry_goodBins_vector.push_back(0.) ; + int hstart = max(get_firstGood_int(histo_num_plus)-get_t0_int(histo_num_plus),get_firstGood_int(histo_num_minus)-get_t0_int(histo_num_minus)) ; + for (int i = 0 ; i < hsize ; i++) + { + if (dummy_1[i+hstart] < 0.5 || dummy_2[i+hstart] < 0.5 ) + error_asymmetry_goodBins_vector[i] = 1.0 ; + else + error_asymmetry_goodBins_vector[i] = double(2.) * alpha_param * sqrt(dummy_1[i+hstart]*dummy_2[i+hstart]*(dummy_1[i+hstart]+dummy_2[i+hstart])) / + pow(dummy_1[i+hstart] + alpha_param * dummy_2[i+hstart],2.) ; + } + return error_asymmetry_goodBins_vector ; + } + + +//******************************* +//Implementation get_scalers_vector +//******************************* + +/*! \brief Method providing a vector of long containing the values of the scalers + */ + + vector MuSR_td_PSI_bin::get_scalers_vector() + { + vector scalers_vect(16) ; + for ( int i = 0 ; i < 16 ; i++ ) + scalers_vect[i] = long(scalers[i]) ; + return scalers_vect ; + } + + +//******************************* +//Implementation get_max_t0_int +//******************************* + +/*! \brief Method to determine the maximum value of the t0 bins + */ + + int MuSR_td_PSI_bin::get_max_t0_int() + { + int max_t0 = 0 ; + for (int i = 0 ; i < int(number_histo) ; i++) + { + if (int(integer_t0[i]) > max_t0) + max_t0 = int(integer_t0[i]) ; + } + return max_t0 ; + } + + +//******************************* +//Implementation get_max_2_t0_int +//******************************* + +/*! \brief Method to determine the maximum value of the last good bins of 2 histograms + * + * returns -1 if the numbers of the histograms are invalid + */ + + int MuSR_td_PSI_bin::get_max_2_t0_int(int k, int j) + { + if (( k < 0 || k >= int(number_histo)) || ( j < 0 || j >= int(number_histo))) + return -1 ; + int max_t0 = int(integer_t0[j]) ; + if (int(integer_t0[k]) >= max_t0) + max_t0 = int(integer_t0[k]) ; + return max_t0 ; + } + + +//******************************* +//Implementation get_min_2_t0_int +//******************************* + +/*! \brief Method to determine the minimum value of the last good bins of 2 histograms + * + * returns -1 if the numbers of the histograms are invalid + */ + + int MuSR_td_PSI_bin::get_min_2_t0_int(int k, int j) + { + if (( k < 0 || k >= int(number_histo)) || ( j < 0 || j >= int(number_histo))) + return -1 ; + int min_t0 = int(integer_t0[j]) ; + if (int(integer_t0[k]) <= min_t0) + min_t0 = int(integer_t0[k]) ; + return min_t0 ; + } + + +//******************************* +//Implementation get_min_t0_int +//******************************* + +/*! \brief Method to determine the minimum value of the t0 bins + */ + + int MuSR_td_PSI_bin::get_min_t0_int() + { + int min_t0 = int(length_histo) ; + for (int i = 0 ; i < int(number_histo) ; i++) + { + if (int(integer_t0[i]) < min_t0) + min_t0 = int(integer_t0[i]) ; + } + return min_t0 ; + } + + + //******************************* +//Implementation get_binWidth_ps +//******************************* + +/*! \brief Method returning a double representing the bin-width in picoseconds + */ + + double MuSR_td_PSI_bin::get_binWidth_ps() + { + return double((double)bin_width*(double)1000000.) ; + } + + +//******************************* +//Implementation get_binWidth_ns +//******************************* + +/*! \brief Method returning a double representing the bin-width in nanoseconds + */ + + double MuSR_td_PSI_bin::get_binWidth_ns() + { + return double((double)bin_width*(double)1000.) ; + } ; + +//******************************* +//Implementation get_binWidth_us +//******************************* + +/*! \brief Method returning a double representing the bin-width in microseconds + */ + + double MuSR_td_PSI_bin::get_binWidth_us() + { + return double(bin_width) ; + } + + +//******************************* +//Implementation get_histoLength_bin +//******************************* + +/*! \brief Method returning an integer representing the histogram length in bins + */ + + int MuSR_td_PSI_bin::get_histoLength_bin() + { + return int(length_histo) ; + } + + +//******************************* +//Implementation get_numberHisto_int +//******************************* + +/*! \brief Method returning an integer representing the number of histograms + */ + + int MuSR_td_PSI_bin::get_numberHisto_int() + { + return int(number_histo) ; + } + + +//******************************* +//Implementation get_totalEvents_long +//******************************* + +/*! \brief Method returning a long representing the total number of events + */ + + long MuSR_td_PSI_bin::get_totalEvents_long() + { + return long(total_events) ; + } + + +//******************************* +//Implementation get_eventsHisto_long +//******************************* + +/*! \brief Method returning a long representing the number of events in a specified histograms + * + * A value of -1 is returned if the value of the histogram \ specified is invalid. + */ + + long MuSR_td_PSI_bin::get_eventsHisto_long(int i) + { + if ( i < 0 || i >= number_histo) + return -1 ; + else + return long(events_per_histo[i]) ; + } + + +//******************************* +//Implementation get_eventsHisto_vector +//******************************* + +/*! \brief Method returning a vector of long containing the number of events in the histograms + */ + + vector MuSR_td_PSI_bin::get_eventsHisto_vector() + { + vector eventsHisto(16) ; + for ( int i = 0 ; i < 16 ; i++ ) + eventsHisto[i] = long(events_per_histo[i]) ; + return eventsHisto ; + } + + +//******************************* +//Implementation get_t0_double +//******************************* + +/*! \brief Method returning a double representing the t0 point (from the "real" t0 in the header) for a specified histogram + * + * A value of -1. is returned if the value of the histogram \ specified is invalid. + */ + + double MuSR_td_PSI_bin::get_t0_double(int i) + { + if ( i < 0 || i >= int(number_histo)) + return -1. ; + else + return double(real_t0[i]) ; + } + + +//******************************* +//Implementation get_t0_int +//******************************* + +/*! \brief Method returning an integer representing the t0 point (from the "integer" t0 in the header) for a specified histogram + * + * A value of -1 is returned if the value of the histogram \ specified is invalid. + */ + + int MuSR_td_PSI_bin::get_t0_int(int i) + { + if ( i < 0 || i >= int(number_histo)) + return -1 ; + else + return int(integer_t0[i]) ; + } + +//******************************* +//Implementation get_t0_vector +//******************************* + +/*! \brief Method returning a vector of integer containing the t0 values of the histograms specified in the header + */ + + vector MuSR_td_PSI_bin::get_t0_vector() + { + vector t0(number_histo) ; + for ( int i = 0 ; i < int(number_histo) ; i++ ) + t0[i] = int(integer_t0[i]) ; + return t0 ; + } + + +//******************************* +//Implementation get_firstGood_int +//******************************* + +/*! \brief Method returning an integer representing the first good bin specified in the header for a specified histogram + * + * A value of -1 is returned if the value of the histogram \ specified is invalid. + */ + + int MuSR_td_PSI_bin::get_firstGood_int(int i) + { + if ( i < 0 || i >= int(number_histo)) + return -1 ; + else + return int(first_good[i]) ; + } + + +//******************************* +//Implementation get_firstGood_vector +//******************************* + +/*! \brief Method returning a vector of integer containing the first good bin values of the histograms specified in the header + */ + + vector MuSR_td_PSI_bin::get_firstGood_vector() + { + vector firstGood(number_histo) ; + for ( int i = 0 ; i < number_histo ; i++ ) + firstGood[i] = int(first_good[i]) ; + return firstGood ; + } + + +//******************************* +//Implementation put_firstGood_int +//******************************* + +/*! \brief Method to modify the first good bin (value \) of the histogram \ + * + * returns -1 if the histogram specified was invalid + */ + + int MuSR_td_PSI_bin::put_firstGood_int(int i, int j) + { + if ( i < 0 || i >= int(number_histo)) + return -1 ; + else + { + first_good[i] = Int16 (j) ; + return 0; + } + } + + +//******************************* +//Implementation get_lastGood_int +//******************************* + +/*! \brief Method returning an integer representing the last good bin specified in the header for a specified histogram + * + * A value of -1 is returned if the value of the histogram \ specified is invalid. + */ + + int MuSR_td_PSI_bin::get_lastGood_int(int i) + { + if ( i < 0 || i >= int(number_histo)) + return -1 ; + else + return int(last_good[i]) ; + } + + +//******************************* +//Implementation get_lastGood_vector +//******************************* + +/*! \brief Method returning a vector of integer containing the last good bin values of the histograms specified in the header + */ + + vector MuSR_td_PSI_bin::get_lastGood_vector() + { + vector lastGood(number_histo) ; + for ( int i = 0 ; i < number_histo ; i++ ) + lastGood[i] = int(last_good[i]) ; + return lastGood ; + } + + +//******************************* +//Implementation get_max_lastGoog_int +//******************************* + +/*! \brief Method returning an integer containing the maximum value of the "last good bins" of all histograms + */ + + int MuSR_td_PSI_bin::get_max_lastGood_int() + { + int max_lastGood = 0 ; + for (int i = 0 ; i < int(number_histo) ; i++) + { + if (int(last_good[i]) > max_lastGood) + max_lastGood = int(last_good[i]) ; + } + return max_lastGood ; + } + + +//******************************* +//Implementation get_max_2_lastGood_int +//******************************* + +/*! \brief Method to determine the maximum value of the "last good bins" of 2 histograms + * + * returns -1 if something is invalid + */ + + int MuSR_td_PSI_bin::get_max_2_lastGood_int(int k, int j) + { + if (( k < 0 || k >= int(number_histo)) || ( j < 0 || j >= int(number_histo))) + return -1 ; + else + { + int max_lastGood = int(last_good[j]) ; + if (int(last_good[k]) > max_lastGood) + max_lastGood = int(last_good[k]) ; + return max_lastGood ; + } + } + + +//******************************* +//Implementation get_min_lastGoog_int +//******************************* + +/*! \brief Method providing the minimum value of the last good bins + */ + + int MuSR_td_PSI_bin::get_min_lastGood_int() + { + int min_lastGood = int(last_good[0]) ; + for (int i = 1 ; i < int(number_histo) ; i++) + { + if (int(last_good[i]) < min_lastGood) + min_lastGood = int(last_good[i]) ; + } + return min_lastGood ; + } + + +//******************************* +//Implementation get_min_2_lastGood_int +//******************************* + +/*! \brief Method to determine the minimum value of the last good bins of 2 histograms + * + * returns -1 if something is invalid + */ + + int MuSR_td_PSI_bin::get_min_2_lastGood_int(int k, int j) + { + if (( k < 0 || k >= int(number_histo)) || ( j < 0 || j >= int(number_histo))) + return -1 ; + else + { int min_lastGood = int(last_good[j]) ; + if (int(last_good[k]) < min_lastGood) + min_lastGood = int(last_good[k]) ; + return min_lastGood ; + } + } + + +//******************************* +//Implementation put_lastGood_int +//******************************* + +/*! \brief Method to modify the last good bin (value \) of the histogram \ + * + * returns -1 if the histogram specified was invalid + */ + + int MuSR_td_PSI_bin::put_lastGood_int(int i, int j) + { + if ( i < 0 || i >= int(number_histo)) + return -1 ; + else + { + last_good[i] = Int16 (j) ; + return 0; + } + } + + +//******************************* +//Implementation get_runNumber_int +//******************************* + +/*! \brief Method returning an integer containing the run number + */ + + int MuSR_td_PSI_bin::get_runNumber_int() + { + return int(num_run) ; + } + + +//******************************* +//Implementation put_runNumber_int +//******************************* + +/*! \brief Method to modify the run number (value \) + * + * returns -1 if the integer specified was wrong + */ + + int MuSR_td_PSI_bin::put_runNumber_int(int i) + { + if (i <= 0 ) + return -1 ; + num_run = short(i) ; + return 0 ; + } + + +//******************************* +//Implementation get_sample() +//******************************* + +/*! \brief Method returning a string containing the sample name + */ + + string MuSR_td_PSI_bin::get_sample() + { + string strData ; + strData = sample ; + return strData ; + } + + +//******************************* +//Implementation get_temp() +//******************************* + +/*! \brief Method returning a string containing the temperature specified in the title + */ + + string MuSR_td_PSI_bin::get_temp() + { + string strData ; + strData = temp ; + return strData ; + } + + +//******************************* +//Implementation get_orient() +//******************************* + +/*! \brief Method returning a string containing the orientation specified in the title + */ + + string MuSR_td_PSI_bin::get_orient() + { + string strData ; + strData = orient ; + return strData ; ; + } + + +//******************************* +//Implementation get_field() +//******************************* + +/*! \brief Method returning a string containing the field specified in the title + */ + + string MuSR_td_PSI_bin::get_field() + { + string strData ; + strData = field ; + return strData ; + } + + +//******************************* +//Implementation get_comments() +//******************************* + +/*! \brief Method returning a string containing the comment specified in the title + */ + + string MuSR_td_PSI_bin::get_comment() + { + string strData ; + strData = comment ; + return strData ; + } + + +//******************************* +//Implementation get_nameHisto() +//******************************* + +/*! \brief Method returning a string containing the name of the histogram \ + * + * returns NULL if the histogram specified is invalid + */ + + string MuSR_td_PSI_bin::get_nameHisto(int i) + { + string strData ; + if (i < 0 || i >= int(number_histo)) + return NULL ; + else + { + strData = labels_histo[i] ; + return strData ; + } + } + + +//******************************* +//Implementation get_histoNames_vector() +//******************************* + +/*! \brief Method returning a vector of strings containing the names of the histograms + */ + + vector MuSR_td_PSI_bin::get_histoNames_vector() + { + vector str_Vector ; + string strData ; + for (int i = 0 ; i <= 15 ; i++) + { + strData = labels_histo[i] ; + str_Vector.push_back(strData) ; + } + return str_Vector; + } + + +//******************************* +//Implementation get_scalersNames_vector() +//******************************* + +/*! \brief Method returning a vector of strings containing the names of the scalers + */ + + vector MuSR_td_PSI_bin::get_scalersNames_vector() + { + vector str_Vector ; + string strData ; + for (int i = 0 ; i <= 17 ; i++) + { + strData = labels_scalers[i] ; + str_Vector.push_back(strData) ; + } + return str_Vector; + } + + +//******************************* +//Implementation get_temperatures_vector() +//******************************* + +/*! \brief Method returning a vector of doubles containing monitored values (usually temperatures) + */ + + vector MuSR_td_PSI_bin::get_temperatures_vector() + { + vector dbl_Temper ; + for (int i = 0 ; i <= 3 ; i++) + { + dbl_Temper.push_back(double(temper[i])) ; + } + return dbl_Temper; + } + + +//******************************* +//Implementation get_devTemperatures_vector() +//******************************* + +/*! \brief Method returning a vector of doubles containing standard deviations of the monitored values (usually temperatures) + */ + + vector MuSR_td_PSI_bin::get_devTemperatures_vector() + { + vector dbl_devTemper ; + for (int i = 0 ; i <= 3 ; i++) + { + dbl_devTemper.push_back(double(temp_deviation[i])) ; + } + return dbl_devTemper; + } + + +//******************************* +//Implementation get_timeStart_vector() +//******************************* + +/*! \brief Method returning a vector of strings containing 1) the date when the run was started and 2) the time when the run was started + */ + + vector MuSR_td_PSI_bin::get_timeStart_vector() + + { + vector timeStart(2) ; + timeStart[0] = date_start ; + timeStart[1] = time_start ; + return timeStart ; + } + + +//******************************* +//Implementation get_timeStop_vector() +//******************************* + +/*! \brief Method returning a vector of strings containing 1) the date when the run was stopped and 2) the time when the run was stopped + */ + + vector MuSR_td_PSI_bin::get_timeStop_vector() + + { + vector timeStop(2) ; + timeStop[0] = date_stop ; + timeStop[1] = time_stop ; + return timeStop ; + } + + +//******************************* +//Implementation max +//******************************* + + int MuSR_td_PSI_bin::max(int x, int y) + { + if (x >= y) + { + return x ; + } + return y ; + } + + +//******************************* +//Implementation min +//******************************* + + int MuSR_td_PSI_bin::min(int x, int y) + { + if (x >= y) + { + return y ; + } + return x ; + } + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/external/MuSR_software/Class_MuSR_PSI/MuSR_td_PSI_bin.h b/src/external/MuSR_software/Class_MuSR_PSI/MuSR_td_PSI_bin.h new file mode 100644 index 00000000..7a9cdcaf --- /dev/null +++ b/src/external/MuSR_software/Class_MuSR_PSI/MuSR_td_PSI_bin.h @@ -0,0 +1,290 @@ +/************************************************************************************** + + MuSR_td_PSI_bin.h + + declaration file of the class 'MuSR_td_PSI_bin' + + Main class to read td_bin PSI MuSR data. + +*************************************************************************************** + + begin : Alex Amato, October 2005 + modfied: : + copyright : (C) 2005 by + email : alex.amato@psi.ch + +***************************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + + +#ifndef MuSR_td_PSI_bin_H_ +#define MuSR_td_PSI_bin_H_ + +#include +using namespace std ; +#include +#include +#include +#include +#include + +#include "tydefs.h" + +class MuSR_td_PSI_bin { + + public: + MuSR_td_PSI_bin(); + ~MuSR_td_PSI_bin(); + + private: +// ------------------------------------start of the variables + char format_id[3] ; + + Int16 num_run ; + + char sample[11] ; + char temp[11] ; + char field[11] ; + char orient[11] ; + char comment[63] ; + + char date_start[10] ; + char date_stop[10] ; + char time_start[9] ; + char time_stop[9] ; + + Float32 bin_width ; + Int16 tdc_resolution ; + Int16 tdc_overflow ; + + Int16 number_histo ; + Int16 length_histo ; + char labels_histo[16][5] ; + + Int32 total_events ; + Int32 events_per_histo[16] ; + + Int16 integer_t0[16] ; + Int16 first_good[16] ; + Int16 last_good[16] ; + Float32 real_t0[17] ; + + Int32 scalers[18] ; + char labels_scalers[18][5] ; + + Float32 temper[4] ; + Float32 temp_deviation[4] ; + Float32 mon_low[4] ; + Float32 mon_high[4] ; + Int32 mon_num_events ; + char mon_dev[13] ; + + Int16 num_data_records_file ; + Int16 length_data_records_bins ; + Int16 num_data_records_histo ; + + Int32 period_save ; + Int32 period_mon ; + Int32 **histo ; + + public: + + vector< vector > histos_vector ; /*!< this public variables provides a direct access to the histograms + */ + +// ------------------------------------end of the variables + + public: + + int read(const char* fileName); + + int *get_histo_array_int(int histo_num); + double *get_histo_array(int histo_num , int binning) ; + vector get_histo_vector(int histo_num , int binning) ; + vector get_histo_vector_no0(int histo_num , int binning) ; + + double *get_histo_fromt0_array(int histo_num , + int binning , + int offset = 0) ; + + vector get_histo_fromt0_vector(int histo_num , + int binning , + int offset = 0) ; + + double *get_histo_goodBins_array(int histo_num , int binning) ; + + vector get_histo_goodBins_vector(int histo_num , int binning) ; + + double *get_histo_fromt0_minus_bckgrd_array(int histo_num , + int lower_bckgdr , + int higher_bckgdr , + int binning , + int offset = 0) ; + + vector get_histo_fromt0_minus_bckgrd_vector(int histo_num , + int lower_bckgdr , + int higher_bckgdr , + int binning , + int offset = 0) ; + + double *get_histo_goodBins_minus_bckgrd_array(int histo_num , + int lower_bckgrd , + int higher_bckgrd , + int binning) ; + + vector get_histo_goodBins_minus_bckgrd_vector(int histo_num , + int lower_bckgrd , + int higher_bckgrd , + int binning) ; + + double *get_asymmetry_array(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.) ; + + vector get_asymmetry_vector(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.) ; + + double *get_error_asymmetry_array(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) ; + + vector get_error_asymmetry_vector(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 *get_asymmetry_goodBins_array(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) ; + + vector get_asymmetry_goodBins_vector(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) ; + + double *get_error_asymmetry_goodBins_array(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) ; + + vector get_error_asymmetry_goodBins_vector(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) ; + + + double get_binWidth_ps(); + double get_binWidth_ns(); + double get_binWidth_us(); + + int get_histoLength_bin(); + + int get_numberHisto_int(); + + string get_nameHisto(int i) ; + vector get_histoNames_vector(); + + long get_eventsHisto_long(int i); + vector get_eventsHisto_vector(); + + long get_totalEvents_long(); + + vector get_scalers_vector() ; + vector get_scalersNames_vector() ; + + int get_t0_int(int i) ; + vector get_t0_vector() ; + double get_t0_double(int i) ; + + int get_max_t0_int () ; + int get_max_2_t0_int (int k, int j) ; + int get_min_t0_int () ; + int get_min_2_t0_int (int k, int j) ; + + int get_firstGood_int(int i) ; + vector get_firstGood_vector() ; + int put_firstGood_int(int i, int j) ; + + int get_lastGood_int(int i) ; + vector get_lastGood_vector() ; + int put_lastGood_int(int i, int j) ; + + int get_max_lastGood_int () ; + int get_max_2_lastGood_int (int k, int j) ; + int get_min_lastGood_int () ; + int get_min_2_lastGood_int (int k, int j) ; + + int get_runNumber_int() ; + int put_runNumber_int(int i) ; + + string get_sample() ; + string get_field() ; + string get_orient() ; + string get_temp() ; + string get_comment() ; + + vector get_timeStart_vector() ; + vector get_timeStop_vector() ; + + vector get_devTemperatures_vector() ; + vector get_temperatures_vector() ; + + private: + + int max(int x, int y) ; + int min(int x, int y) ; + +} ; +#endif diff --git a/src/external/MuSR_software/Class_MuSR_PSI/tydefs.h b/src/external/MuSR_software/Class_MuSR_PSI/tydefs.h new file mode 100644 index 00000000..31f26d9a --- /dev/null +++ b/src/external/MuSR_software/Class_MuSR_PSI/tydefs.h @@ -0,0 +1,283 @@ +#ifndef __tydefs_h__ +#define __tydefs_h__ + + /* + * +--------------------------------------------------------------+ + * | Paul Scherrer Institut | + * | Computing Division | + * | | + * | This software may be used freely by non-profit organizations.| + * | It may be copied provided that the name of P.S.I. and of the | + * | author is included. Neither P.S.I. nor the author assume any | + * | responsibility for the use of this software outside of P.S.I.| + * +--------------------------------------------------------------+ + * + * Project . . . . . . . . . . : Musr support software + * Component/Facility . . . . . : Define basic data types and functions + * File Name . . . . . . . . . : tydefs.h + * Title . . . . . . . . . . . : + * Abstract . . . . . . . . . . : + * + * + * Author . . . . . . . . . . . : RA84 + * Date of creation . . . . . . : March 1998 + * + * Date Name Modification + * ----------------------------------------------------------------- + * 04-MAY-1998 RA84 Header indluded + * 22-MAY-2002 RA95 && !defined(OS_OSF1) added for TRU64 + * 17-NOV-2005 RA36 + */ + +/* --------------------------------------------------------------------- */ + +/* --- OpenVMS (DECC or VAXC),(AXP or VAX) --- */ +#ifdef _WIN32 +#define INT64_SUPPORT +#endif + +#if ((defined(__DECC) || defined(__VAXC)) && !defined(unix) && !defined(OS_OSF1)) +#if defined (__ALPHA) + +#define MODEFS_CC_SYS "Compiled for VAXC or DECC OpenVMS ALPHA" + +typedef int Int16; +typedef unsigned int UInt16; +typedef long int Int32; +typedef unsigned long int UInt32; + +typedef Int16 * Int16Ptr; +typedef UInt16 * UInt16Ptr; +typedef Int32 * Int32Ptr; +typedef UInt32 * UInt32Ptr; + +#ifdef INCLUDE_CHARDEFS +typedef char Char; +typedef char * CharPtr; +typedef char * Str; +#endif + +#ifdef INCLUDE_BOOLDEF +typedef unsigned char BoolEnum; +#endif + +#else /* !defined( __ALPHA) */ + +#define MODEFS_CC_SYS "Compiled for VAXC or DECC OpenVMS VAX" + +typedef short int Int16; +typedef unsigned short int UInt16; +typedef int Int32; +typedef unsigned int UInt32; + +typedef Int16 * Int16Ptr; +typedef UInt16 * UInt16Ptr; +typedef Int32 * Int32Ptr; +typedef UInt32 * UInt32Ptr; + +#ifdef INCLUDE_CHARDEFS +typedef char Char; +typedef char * CharPtr; +typedef char * Str; +#endif + +#ifdef INCLUDE_BOOLDEF +typedef unsigned char BoolEnum; +#endif + +#endif /* #else __ALPHA */ + +#define VMS_SUCCESS 1 +#define VMS_ERROR 2 + + +/* --- DEC UNIX or OFS/1 (AXP or else) --- */ + +#elif defined (__osf__) + +#if defined (__alpha) +#define MODEFS_CC_SYS "Compiled for (DEC) OSF/1 or UNIX Alpha" +typedef short int Int16; +typedef unsigned short int UInt16; +typedef int Int32; +typedef unsigned int UInt32; + +typedef Int16 * Int16Ptr; +typedef UInt16 * UInt16Ptr; +typedef Int32 * Int32Ptr; +typedef UInt32 * UInt32Ptr; + +#ifdef INCLUDE_CHARDEFS +typedef char Char; +typedef char * CharPtr; +typedef char * Str; +#endif + +#ifdef INCLUDE_BOOLDEF +typedef unsigned char BoolEnum; +#endif + +#else /* !defined ( __alpha) */ + +#define MODEFS_CC_SYS "Compiled for (DEC) OSF/1 or UNIX NON Alpha" + +typedef int Int16; +typedef unsigned int UInt16; +typedef long int Int32; +typedef unsigned long int UInt32; + +typedef Int16 * Int16Ptr; +typedef UInt16 * UInt16Ptr; +typedef Int32 * Int32Ptr; +typedef UInt32 * UInt32Ptr; + +#ifdef INCLUDE_CHARDEFS +typedef char Char; +typedef char * CharPtr; +typedef char * Str; +#endif + +#ifdef INCLUDE_BOOLDEF +typedef unsigned char BoolEnum; +#endif + +#endif /* #else __alpha */ + + +/* --- other operating system --- */ + +#else /* other operating system */ + +//#ifdef _WIN32 +#if (defined(_WIN32) || defined(__linux__)) +#define MODEFS_CC_SYS "Compiled for Microsoft Windows 32-bit or Linux operating system" + +typedef short Int16; +typedef unsigned short UInt16; +typedef int Int32; +typedef unsigned int UInt32; + +typedef Int16 * Int16Ptr; +typedef UInt16 * UInt16Ptr; +typedef Int32 * Int32Ptr; +typedef UInt32 * UInt32Ptr; + +#ifdef INT64_SUPPORT +#define INT64_SUPPORTED +typedef __int64 Int64; +typedef unsigned __int64 UInt64; +typedef Int64 * Int64Ptr; +typedef UInt64 * UInt64Ptr; +#endif + +#ifdef INCLUDE_CHARDEFS +typedef char Char; +typedef char * CharPtr; +typedef char * Str; +#endif + +#ifdef INCLUDE_BOOLDEF +typedef unsigned char BoolEnum; +#endif + +#else + +#define MODEFS_CC_SYS "Compiled for other (#else) operating system" + +typedef int Int16; +typedef unsigned int UInt16; +typedef long int Int32; +typedef unsigned long int UInt32; + +typedef Int16 * Int16Ptr; +typedef UInt16 * UInt16Ptr; +typedef Int32 * Int32Ptr; +typedef UInt32 * UInt32Ptr; + +#ifdef INT64_SUPPORT +#define INT64_SUPPORTED +//typedef long int Int64; +//typedef unsigned long int UInt64; +typedef Int64 * Int64Ptr; +typedef UInt64 * UInt64Ptr; +#endif + +#ifdef INCLUDE_CHARDEFS +typedef char Char; +typedef char * CharPtr; +typedef char * Str; +#endif + +#ifdef INCLUDE_BOOLDEF +typedef unsigned char BoolEnum; +#endif + +#endif + +#endif + +/* --------------------------------------------------------------------- */ +/* not operating system specific (does not have to be portable) */ + +typedef float Float; +typedef double Double; +typedef float Float32; +typedef double Float64; + +#ifdef FLOAT128_SUPPORT +#define FLOAT128_SUPPORTED +typedef double Float128; +#endif + +/* --------------------------------------------------------------------- */ + +#define MAXUINT16 0xffff +#define MAXUINT32 0xffffffff +#ifdef INT64_SUPPORT +#define MAXUINT64 0xffffffffffffffff +#endif + +#define MAXINT16 0x7fff +#define MININT16 (-MAXINT16) +#define MAXINT32 0x7fffffff +#define MININT32 (-MAXINT32) +#ifdef INT64_SUPPORT +#define MAXINT64 0x7fffffffffffffff +#define MININT64 (-MAXINT64) +#endif + +/* --------------------------------------------------------------------- */ + +#define BOOL_TRUE 1 +#define BOOL_FALSE 0 + +#define ERRORRET -1 +#define MOSUCCESS 0 +#define MOERROR 1 + +/* --------------------------------------------------------------------- */ + +#define MOMESSAGEMAX 255 + +/* --------------------------------------------------------------------- */ + +#define SPRINTF sprintf +#define PRINTF printf +#define SSCANF sscanf +#define STRLEN strlen +#define STRCMP strcmp +#define STRCPY strcpy +#define STRCAT strcat +#define STRNCPY strncpy +#define STRNCMP strncmp +#define ATOL atol +#define MEMCPY memcpy +#define MALLOCF malloc +#define FREEF free +#define FOPENR fopen +#define FCLOSER fclose +#define FWRITER fwrite + +/* --------------------------------------------------------------------- */ + +#endif /* __modefs_h__ */ diff --git a/src/tests/skewedGaussianTest/paramInput.dat b/src/tests/skewedGaussianTest/paramInput.dat index 7838b91b..820b2eaa 100644 --- a/src/tests/skewedGaussianTest/paramInput.dat +++ b/src/tests/skewedGaussianTest/paramInput.dat @@ -16,7 +16,7 @@ asym, 0.24, 0.24, 0.24, 0.24 phase, 10.0, 90.0, 170.0, 270.0 #------------------------------------------------------ # N0's -N0, 110, 100, 102, 99 +N0, 1100, 1000, 1002, 990 #------------------------------------------------------ # bkg's bkg, 2, 1, 2, 3 diff --git a/src/tests/skewedGaussianTest/skewedGaussian.C b/src/tests/skewedGaussianTest/skewedGaussian.C index 145b3f94..604b6483 100644 --- a/src/tests/skewedGaussianTest/skewedGaussian.C +++ b/src/tests/skewedGaussianTest/skewedGaussian.C @@ -42,9 +42,9 @@ void skewedGaussian() char fln[256]; const Double_t w = 1.0; // weight of the skewed Gaussian - const Double_t B0 = 100.0; // skewed Gaussian B0 (G) + const Double_t B0 = 2500.0; // skewed Gaussian B0 (G) const Double_t sm = 4.5; // skewed Gaussian sigma- (G) - const Double_t sp = 4.5; // skewed Gaussian sigma+ (G) + const Double_t sp = 4.5; // skewed Gaussian sigma+ (G) const Double_t B0ext = 110.0; // external field Gaussian B0 (G) const Double_t sext = 1.2; // external field Gaussian sigma (G)