first crude implementation of psi-bin format base on Alex's class

This commit is contained in:
nemu
2008-04-09 10:42:10 +00:00
parent 47935d356a
commit 8fcf4a6362
7 changed files with 2568 additions and 7 deletions

View File

@ -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 $^

View File

@ -31,6 +31,7 @@
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
#include <TROOT.h>
@ -43,6 +44,7 @@ using namespace std;
#include <TH1F.h>
#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<runData.fDataBin.size(); i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
return true;
}
@ -628,6 +635,11 @@ cout << endl << ">> time resolution : " << runData.fTimeResolution;
// add run to the run list
fData.push_back(runData);
// clean up
for (unsigned int i=0; i<runData.fDataBin.size(); i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
return true;
}
@ -640,8 +652,104 @@ cout << endl << ">> 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_numberHisto_int(); i++)
cout << endl << "> " << 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<ivec.size(); i++)
runData.fT0s.push_back((double)ivec[i]);
// fill raw data
PDoubleVector histoData;
int *histo;
for (int i=0; i<psiBin.get_numberHisto_int(); i++) {
histo = psiBin.get_histo_array_int(i);
for (int j=0; j<psiBin.get_histoLength_bin(); j++) {
histoData.push_back(histo[j]);
}
runData.fDataBin.push_back(histoData);
histoData.clear();
}
// add run to the run list
fData.push_back(runData);
// clean up
runData.fT0s.clear();
for (unsigned int i=0; i<runData.fDataBin.size(); i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
return success;
}
//--------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -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 <iostream>
using namespace std ;
#include <fstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#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<double> > 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<double> get_histo_vector(int histo_num , int binning) ;
vector<double> get_histo_vector_no0(int histo_num , int binning) ;
double *get_histo_fromt0_array(int histo_num ,
int binning ,
int offset = 0) ;
vector<double> get_histo_fromt0_vector(int histo_num ,
int binning ,
int offset = 0) ;
double *get_histo_goodBins_array(int histo_num , int binning) ;
vector<double> 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<double> 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<double> 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<double> 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<double> 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<double> 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<double> 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<string> get_histoNames_vector();
long get_eventsHisto_long(int i);
vector<long> get_eventsHisto_vector();
long get_totalEvents_long();
vector<long> get_scalers_vector() ;
vector<string> get_scalersNames_vector() ;
int get_t0_int(int i) ;
vector<int> 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<int> get_firstGood_vector() ;
int put_firstGood_int(int i, int j) ;
int get_lastGood_int(int i) ;
vector<int> 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<string> get_timeStart_vector() ;
vector<string> get_timeStop_vector() ;
vector<double> get_devTemperatures_vector() ;
vector<double> get_temperatures_vector() ;
private:
int max(int x, int y) ;
int min(int x, int y) ;
} ;
#endif

View File

@ -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__ */

View File

@ -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

View File

@ -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)