From 499be37d0c7de0987e8ac8842294561af27f04c9 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Mon, 17 Dec 2012 14:04:53 +0000 Subject: [PATCH] deleted all the detector classes since they are all combined now git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@408 951219d9-93cf-4727-9268-0efd64621fa3 --- .../eigerDetector/eigerDetector.cpp | 12 - .../eigerDetector/eigerDetector.h | 166 ---- .../gotthardDetector/gotthardDetector.cpp | 718 --------------- .../gotthardDetector/gotthardDetector.h | 160 ---- .../mythenDetector/mythenDetector.cpp | 819 ------------------ .../mythenDetector/mythenDetector.h | 42 - 6 files changed, 1917 deletions(-) delete mode 100644 slsDetectorSoftware/eigerDetector/eigerDetector.cpp delete mode 100644 slsDetectorSoftware/eigerDetector/eigerDetector.h delete mode 100644 slsDetectorSoftware/gotthardDetector/gotthardDetector.cpp delete mode 100644 slsDetectorSoftware/gotthardDetector/gotthardDetector.h delete mode 100644 slsDetectorSoftware/mythenDetector/mythenDetector.cpp delete mode 100644 slsDetectorSoftware/mythenDetector/mythenDetector.h diff --git a/slsDetectorSoftware/eigerDetector/eigerDetector.cpp b/slsDetectorSoftware/eigerDetector/eigerDetector.cpp deleted file mode 100644 index 1ceb4583a..000000000 --- a/slsDetectorSoftware/eigerDetector/eigerDetector.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "eigerDetector.h" - - -using namespace std; - - - -eigerDetector::eigerDetector(int id): slsDetector(EIGER,id) - { - ; -} - diff --git a/slsDetectorSoftware/eigerDetector/eigerDetector.h b/slsDetectorSoftware/eigerDetector/eigerDetector.h deleted file mode 100644 index 8002973d9..000000000 --- a/slsDetectorSoftware/eigerDetector/eigerDetector.h +++ /dev/null @@ -1,166 +0,0 @@ - -#ifndef EIGER_DETECTOR_H -#define EIGER_DETECTOR_H - -using namespace std; - -/** - * - * @libdoc The eigerDetector class contains Eiger specific functions. - * - * @short This is class contains all Eiger specific functions - * @author Ian Johnson - * @version 0.1 - */ - - - -#include "slsDetector.h" - -class eigerDetector : public slsDetector{ - - - - public: - - - -/** (default) constructor - - \param id is the detector index which is needed to define the shared memory id. Different physical detectors should have different IDs in order to work independently - - -*/ - eigerDetector(int id=0); - //slsDetector(string const fname); - /** destructor */ - ~eigerDetector(){}; - - - - /** - reads a trim file - \param fname name of the file to be read - \param myMod pointer to the module structure which has to be set.
If it is NULL a new module structure will be created - \returns the pointer to myMod or NULL if reading the file failed - */ - - sls_detector_module* readTrimFile(string fname, sls_detector_module* myMod=NULL); - - /** - writes a trim file - \param fname name of the file to be written - \param mod module structure which has to be written to file - \returns OK or FAIL if the file could not be written - - \sa ::sls_detector_module - */ - int writeTrimFile(string fname, sls_detector_module mod); - - /** - writes a trim file for module number imod - the values will be read from the current detector structure - \param fname name of the file to be written - \param imod module number - \returns OK or FAIL if the file could not be written - \sa ::sls_detector_module sharedSlsDetector - */ - int writeTrimFile(string fname, int imod); - - - /** - writes a data file - \param name of the file to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' float (default) - \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector - \returns OK or FAIL if it could not write the file or data=NULL - - - */ - int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1); - - /** - writes a data file - \param name of the file to be written - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - */ - int writeDataFile(string fname, int *data); - - /** - reads a data file - \param name of the file to be read - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' float (default) - \param nch number of channels to be written to file. if <=0 defaults to the number of installed channels of the detector - \returns OK or FAIL if it could not read the file or data=NULL - - - */ - int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=0); - - /** - reads a data file - \param name of the file to be read - \param data array of data values - \returns OK or FAIL if it could not read the file or data=NULL - */ - int readDataFile(string fname, int *data); - - /** - returns the location of the calibration files - \sa sharedSlsDetector - */ - - /** - int readCalibrationFile(string fname, float &gain, float &offset); - - - \param fname file to be read - \param gain reference to the gain variable - \offset reference to the offset variable - \sa sharedSlsDetector - */ - int readCalibrationFile(string fname, float &gain, float &offset); - - - /** - writes a clibration file - \param fname file to be written - \param gain - \param offset - \sa sharedSlsDetector - */ - int writeCalibrationFile(string fname, float gain, float offset); - - - - - - - - - /** - decode data from the detector converting them to an array of floats, one for each channle - \param datain data from the detector - \returns pointer to a float array with a data per channel - */ - float* decodeData(int *datain); - - - - - - private: - - -}; - - -#endif diff --git a/slsDetectorSoftware/gotthardDetector/gotthardDetector.cpp b/slsDetectorSoftware/gotthardDetector/gotthardDetector.cpp deleted file mode 100644 index 6b6a98a62..000000000 --- a/slsDetectorSoftware/gotthardDetector/gotthardDetector.cpp +++ /dev/null @@ -1,718 +0,0 @@ -#include "gotthardDetector.h" -#include - -#include - -//using namespace std; - - /* detector configuration (no communication to server) */ - - /* - Every detector should have a basic configuration file containing: - type (mythen, pilatus etc.) - hostname - portnumber - communication type (default TCP/IP) - eventually secondary portnumber (e.g. mythen stop function) - number of modules installed if different from the detector size (x,y) - */ -/* -int gotthardDetector::readConfigurationFile(string const fname){ - - string ans; - string str; - ifstream infile; - int iargval; - int interrupt=0; - char *args[100]; - for (int ia=0; ia<100; ia++) { - args[ia]=new char[1000]; - } - - - string sargname, sargval; - int iline=0; - std::cout<< "config file name "<< fname << std::endl; - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - while (infile.good() and interrupt==0) { - sargname="none"; - sargval="0"; - getline(infile,str); - iline++; -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - if (str.find('#')!=string::npos) { -#ifdef VERBOSE - std::cout<< "Line is a comment " << std::endl; - std::cout<< str << std::endl; -#endif - continue; - } else if (str.length()<2) { -#ifdef VERBOSE - std::cout<< "Empty line " << std::endl; -#endif - continue; - } else { - istringstream ssstr(str); - iargval=0; - while (ssstr.good()) { - ssstr >> sargname; - //if (ssstr.good()) { -#ifdef VERBOSE - std::cout<< iargval << " " << sargname << std::endl; -#endif - strcpy(args[iargval],sargname.c_str()); - iargval++; - //} - } - ans=executeLine(iargval,args,PUT_ACTION); -#ifdef VERBOSE - std::cout<< ans << std::endl; -#endif - } - - iline++; - } - infile.close(); - } else { - std::cout<< "Error opening configuration file " << fname << " for reading" << std::endl; - return FAIL; - } -#ifdef VERBOSE - std::cout<< "Read configuration file of " << iline << " lines" << std::endl; -#endif - return iline; -}; - - -int gotthardDetector::writeConfigurationFile(string const fname){ - - string names[]={\ - "hostname",\ - "caldir",\ - "settingsdir",\ - "outdir",\ - // "nmod", - "clientip",\ - "clientmac"}; - - int nvar=6; - ofstream outfile; - int iv=0; - char *args[100]; - for (int ia=0; ia<100; ia++) { - args[ia]=new char[1000]; - } - - outfile.open(fname.c_str(),ios_base::out); - if (outfile.is_open()) { - for (iv=0; iv> sargname; - // if (ssstr.good()) { - strcpy(args[iargval],sargname.c_str()); -#ifdef VERBOSE - std::cout<< args[iargval] << std::endl; -#endif - iargval++; - // } - } - if (level==2) { - executeLine(iargval,args,PUT_ACTION); - } else { - if (string(args[0])==string("flatfield")) - ; - else if (string(args[0])==string("badchannels")) - ; - else if (string(args[0])==string("angconv")) - ; - else if (string(args[0])==string("trimbits")) - ; - else - executeLine(iargval,args,PUT_ACTION); - } - } - iline++; - } - infile.close(); - } else { - std::cout<< "Error opening " << fname << " for reading" << std::endl; - return FAIL; - } -#ifdef VERBOSE - std::cout<< "Read " << iline << " lines" << std::endl; -#endif - return iline; - -}; - - - - /* I/O */ - -/* - sls_detector_module* gotthardDetector::readSettingsFile(string fname, sls_detector_module *myMod){ - - int nflag=0; - - if (myMod==NULL) { - myMod=createModule(); - nflag=1; - } - string myfname; - string str; - ifstream infile; - ostringstream oss; - int iline=0; - string sargname; - int ival; - int ichan=0, ichip=0, idac=0; - string::size_type pos=0; - - - -#ifdef VERBOSE - std::cout<< "reading settings file for module number "<< myMod->module << std::endl; -#endif - myfname=fname; -#ifdef VERBOSE - std::cout<< "settings file name is "<< myfname << std::endl; -#endif - infile.open(myfname.c_str(), ios_base::in); - if (infile.is_open()) { - //---------------dacs--------------- - for (int iarg=0; iargnDacs; iarg++) { - getline(infile,str); - iline++; -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> sargname >> ival; -#ifdef VERBOSE - std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; -#endif - myMod->dacs[idac]=ival; - idac++; - } - - infile.close(); - strcpy(thisDetector->settingsFile,fname.c_str()); - return myMod; - } else { - std::cout<< "could not open settings file " << myfname << std::endl; - if (nflag) - deleteModule(myMod); - return NULL; - } - - }; - - -int gotthardDetector::writeSettingsFile(string fname, sls_detector_module mod){ - - ofstream outfile; - string names[]={"Vref", "VcascN","VcascP", "Vout", "Vcasc", "Vin", "Vref_comp", "Vib_test", "config", "HV", "macaddress","ipaddress"}; - int iv, ichan, ichip; - int iv1, idac; - int nb; - outfile.open(fname.c_str(), ios_base::out); - - if (outfile.is_open()) { - for (idac=0; idacnChans; ichan++) { - iv=mod.chanregs[ichip*thisDetector->nChans+ichan]; - iv1= (iv&0x3f); - outfile <>nb); - outfile << iv1 << " "; - nb=8; - iv1=((iv&(1<>nb); - outfile << iv1 << " "; - nb=7; - iv1=((iv&(1<>nb); - outfile <>nb); - outfile << iv1 << " "; - nb=11; - iv1= ((iv&0xfffff800)>>nb); - outfile << iv1 << std::endl; - } - } - outfile.close(); - return OK; - } else { - std::cout<< "could not open trim file " << fname << std::endl; - return FAIL; - } -}; - - - - -int gotthardDetector::writeSettingsFile(string fname, int imod){ - - return writeSettingsFile(fname,detectorModules[imod]); - -}; -*/ - -int gotthardDetector::writeDataFile(string fname, float *data, float *err, float *ang, char dataformat, int nch){ - - if (nch==-1) - nch=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; - - - ofstream outfile; - int idata; - if (data==NULL) - return FAIL; - - // args|=0x10; // one line per channel! - - outfile.open (fname.c_str(),ios_base::out); - if (outfile.is_open()) - { -#ifdef VERBOSE - std::cout<< "writeDataFile Writing to file " << fname << std::endl; -#endif - for (int ichan=0; ichannChans*thisDetector->nChips*thisDetector->nMods; ichan++) - outfile << ichan << " " << *(data+ichan) << std::endl; - outfile.close(); - return OK; - } else { - std::cout<< "Could not open file " << fname << "for writing"<< std::endl; - return FAIL; - } -}; - - - - - -int gotthardDetector::readDataFile(string fname, float *data, float *err, float *ang, char dataformat, int nch){ - - - ifstream infile; - int ichan, iline=0; - int interrupt=0; - float fdata, ferr, fang; - int maxchans; - int ich; - string str; - - if (nch==0) - maxchans=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; - else if (nch<0) - maxchans=0xfffffff; - else - maxchans=nch; - -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - while (infile.good() and interrupt==0) { - getline(infile,str); -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - if (ang==NULL) { - ssstr >> ichan >> fdata; - ich=ichan; - if (!ssstr.good()) { - interrupt=1; - break; - } - if (ich!=iline) - std::cout<< "Channel number " << ichan << " does not match with line number " << iline << " " << dataformat << std::endl; - } else { - ssstr >> fang >> fdata; - ich=iline; - } - if (!ssstr.good()) { - interrupt=1; - break; - } - if (err) - ssstr >> ferr; - if (!ssstr.good()) { - interrupt=1; - break; - } - if (ich> ichan >> idata; - if (!ssstr.good()) { - interrupt=1; - break; - } - if (ichan!=iline) { - std::cout<< " Expected channel "<< iline <<" but read channel "<< ichan << std::endl; - interrupt=1; - break; - } else { - if (ilinenChans*thisDetector->nChips*thisDetector->nMods) { - data[iline]=idata; - iline++; - } else { - interrupt=1; - break; - } - } - } - } else { - std::cout<< "Could not read file " << fname << std::endl; - return -1; - } - return iline; -}; - - - - -int gotthardDetector::readCalibrationFile(string fname, float &gain, float &offset){ - - string str; - ifstream infile; -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - getline(infile,str); -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> offset >> gain; - } else { - std::cout<< "Could not open calibration file "<< fname << std::endl; - gain=0.; - offset=0.; - return -1; - } - return 0; - -}; - -int gotthardDetector::writeCalibrationFile(string fname, float gain, float offset){ - - //std::cout<< "Function not yet implemented " << std::endl; - ofstream outfile; - - outfile.open (fname.c_str()); - - // >> i/o operations here << - if (outfile.is_open()) { - outfile << offset << " " << gain << std::endl; - } else { - std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl; - return -1; - } - - outfile.close(); - - return 0; - -}; - - diff --git a/slsDetectorSoftware/gotthardDetector/gotthardDetector.h b/slsDetectorSoftware/gotthardDetector/gotthardDetector.h deleted file mode 100644 index b3dd01a0f..000000000 --- a/slsDetectorSoftware/gotthardDetector/gotthardDetector.h +++ /dev/null @@ -1,160 +0,0 @@ - - - -#ifndef GOTTHARD_DETECTOR_H -#define GOTTHARD_DETECTOR_H - -//#include -#include "slsDetector.h" -#include "usersFunctions.h" - -#define defaultTDead {170,90,750} - -//using namespace std; -/** - \mainpage C++ class with GOTTHARD specific functions - * - - - @author Anna Bergamaschi - -*/ - - - -class gotthardDetector : public slsDetector{ - - - - public: - /** - (default) constructor - */ - gotthardDetector(int id=0, detectorType t=GOTTHARD) : slsDetector(t, id){}; - //slsDetector(string const fname); - // ~slsDetector(){while(dataQueue.size()>0){}}; - /** destructor */ - virtual ~gotthardDetector(){}; - - - - /** - reads configuration file fname calling executeLine - \param fname file to be read - */ - // int readConfigurationFile(string const fname); - /** - writes configuration file calling executeLine - \param fname file to write to - */ - // int writeConfigurationFile(string const fname); - /** - dumps all the possible detector parameters calling executeLine - \param fname file to write to - \param level 0 dumps only main parameters and filenames for flat field correction etc.; 2 dumps really the complete configuration including flat field files, badchannels files, trimbits, angular conversion etc. - */ - int dumpDetectorSetup(string const fname, int level=0); - /** - retrieves all possible detector parameters from file calling executeLine - \param fname file to be read - */ - int retrieveDetectorSetup(string const fname, int level=0); - - /** - reads a trim/settings file - \param fname name of the file to be read - \param myMod pointer to the module structure which has to be set.
If it is NULL a new module structure will be created - \returns the pointer to myMod or NULL if reading the file failed - */ - - // sls_detector_module* readSettingsFile(string fname, sls_detector_module* myMod=NULL); - - /** - writes a trim/settings file - \param fname name of the file to be written - \param mod module structure which has to be written to file - \returns OK or FAIL if the file could not be written - - \sa ::sls_detector_module - */ - //int writeSettingsFile(string fname, sls_detector_module mod); - - /** - writes a trim/settings file for module number imod - the values will be read from the current detector structure - \param fname name of the file to be written - \param imod module number - \returns OK or FAIL if the file could not be written - \sa ::sls_detector_module sharedSlsDetector - */ - //int writeSettingsFile(string fname, int imod); - - /** - writes a data file - \param name of the file to be written - \param data array of data values - \param err array of arrors on the data. If NULL no errors will be written - - \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' float (default) - \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector - \returns OK or FAIL if it could not write the file or data=NULL - - - */ - int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1); - - /** - writes a data file - \param name of the file to be written - \param data array of data values - \returns OK or FAIL if it could not write the file or data=NULL - */ - int writeDataFile(string fname, int *data); - - /** - reads a data file - \param name of the file to be read - \param data array of data values to be filled - \param err array of arrors on the data. If NULL no errors are expected on the file - - \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err) - \param dataformat format of the data: can be 'i' integer or 'f' float (default) - \param nch number of channels to be written to file. if <=0 defaults to the number of installed channels of the detector - \returns OK or FAIL if it could not read the file or data=NULL - - - */ - int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=0); - - /** - reads a data file - \param name of the file to be read - \param data array of data values - \returns OK or FAIL if it could not read the file or data=NULL - */ - int readDataFile(string fname, int *data); - - - /** - reads a calibration file - \param fname file to be read - \param gain reference to the gain variable - \offset reference to the offset variable - \sa sharedSlsDetector - */ - int readCalibrationFile(string fname, float &gain, float &offset); - /** - writes a clibration file - \param fname file to be written - \param gain - \param offset - \sa sharedSlsDetector - */ - int writeCalibrationFile(string fname, float gain, float offset); - - - -}; - - -#endif diff --git a/slsDetectorSoftware/mythenDetector/mythenDetector.cpp b/slsDetectorSoftware/mythenDetector/mythenDetector.cpp deleted file mode 100644 index f8f40f49b..000000000 --- a/slsDetectorSoftware/mythenDetector/mythenDetector.cpp +++ /dev/null @@ -1,819 +0,0 @@ -#include "mythenDetector.h" -#include - -#include - -//using namespace std; - - - - - /* detector configuration (no communication to server) */ - - /* - Every detector should have a basic configuration file containing: - type (mythen, pilatus etc.) - hostname - portnumber - communication type (default TCP/IP) - eventually secondary portnumber (e.g. mythen stop function) - number of modules installed if different from the detector size (x,y) - */ - -int mythenDetector::readConfigurationFile(string const fname){ - - string ans; - string str; - ifstream infile; - int iargval; - int interrupt=0; - char *args[100]; - for (int ia=0; ia<100; ia++) { - args[ia]=new char[1000]; - } - - - string sargname, sargval; - int iline=0; - std::cout<< "config file name "<< fname << std::endl; - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - while (infile.good() and interrupt==0) { - sargname="none"; - sargval="0"; - getline(infile,str); - iline++; -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - if (str.find('#')!=string::npos) { -#ifdef VERBOSE - std::cout<< "Line is a comment " << std::endl; - std::cout<< str << std::endl; -#endif - continue; - } else if (str.length()<2) { -#ifdef VERBOSE - std::cout<< "Empty line " << std::endl; -#endif - continue; - } else { - istringstream ssstr(str); - iargval=0; - while (ssstr.good()) { - ssstr >> sargname; - //if (ssstr.good()) { -#ifdef VERBOSE - std::cout<< iargval << " " << sargname << std::endl; -#endif - strcpy(args[iargval],sargname.c_str()); - iargval++; - //} - } - ans=executeLine(iargval,args,PUT_ACTION); -#ifdef VERBOSE - std::cout<< ans << std::endl; -#endif - } - iline++; - } - infile.close(); - } else { - std::cout<< "Error opening configuration file " << fname << " for reading" << std::endl; - return FAIL; - } -#ifdef VERBOSE - std::cout<< "Read configuration file of " << iline << " lines" << std::endl; -#endif - return iline; -}; - - -int mythenDetector::writeConfigurationFile(string const fname){ - - string names[]={\ - "hostname",\ - "caldir",\ - "trimdir",\ - "trimen",\ - "outdir",\ - "ffdir",\ - "headerbefore",\ - "headerafter",\ - "headerbeforepar",\ - "headerafterpar",\ - "nmod",\ - "badchannels",\ - "angconv",\ - "globaloff",\ - "binsize",\ - "threaded",\ - "waitstates",\ - "setlength",\ - "clkdivider"}; - int nvar=19; - ofstream outfile; - int iv=0; - char *args[100]; - for (int ia=0; ia<100; ia++) { - args[ia]=new char[1000]; - } - - - outfile.open(fname.c_str(),ios_base::out); - if (outfile.is_open()) { - for (iv=0; iv> sargname; - // if (ssstr.good()) { - strcpy(args[iargval],sargname.c_str()); -#ifdef VERBOSE - std::cout<< args[iargval] << std::endl; -#endif - iargval++; - // } - } - if (level==2) { - executeLine(iargval,args,PUT_ACTION); - } else { - if (string(args[0])==string("flatfield")) - ; - else if (string(args[0])==string("badchannels")) - ; - else if (string(args[0])==string("angconv")) - ; - else if (string(args[0])==string("trimbits")) - ; - else - executeLine(iargval,args,PUT_ACTION); - } - } - iline++; - } - infile.close(); - } else { - std::cout<< "Error opening " << fname << " for reading" << std::endl; - return FAIL; - } -#ifdef VERBOSE - std::cout<< "Read " << iline << " lines" << std::endl; -#endif - return iline; - -}; - - - - /* I/O */ - - - sls_detector_module* mythenDetector::readSettingsFile(string fname, sls_detector_module *myMod){ - - int nflag=0; - - if (myMod==NULL) { - myMod=createModule(); - nflag=1; - } - string myfname; - string str; - ifstream infile; - ostringstream oss; - int iline=0; - // string names[]={"Vtrim", "Vthresh", "Rgsh1", "Rgsh2", "Rgpr", "Vcal", "outBuffEnable"}; - string sargname; - int ival; - int ichan=0, ichip=0, idac=0; - - - -#ifdef VERBOSE - std::cout<< "reading trimfile for module number "<< myMod->module << std::endl; -#endif - //im=myMod->module; - //myMod->module=im; - // myMod->serialnumber=getId(MODULE_SERIAL_NUMBER, im); - // if (im<0) - myfname=fname; - /* else { - // oss << fname << ".sn" << setfill('0') <serialnumber - oss << fname << ".sn" << setfill('0') <module; - myfname=oss.str(); - - }*/ -#ifdef VERBOSE - std::cout<< "trim file name is "<< myfname << std::endl; -#endif - infile.open(myfname.c_str(), ios_base::in); - if (infile.is_open()) { - // while (infile.good() && isgood==1) { - for (int iarg=0; iargnDacs; iarg++) { - getline(infile,str); - iline++; -#ifdef VERBOSE - // std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> sargname >> ival; -#ifdef VERBOSE - std::cout<< sargname << " dac nr. " << idac << " is " << ival << std::endl; -#endif - myMod->dacs[idac]=ival; - idac++; - } - for (ichip=0; ichipnChips; ichip++) { - getline(infile,str); - iline++; -#ifdef VERBOSE - // std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> sargname >> ival; -#ifdef VERBOSE - // std::cout<< "chip " << ichip << " " << sargname << " is " << ival << std::endl; -#endif - - myMod->chipregs[ichip]=ival; - for (ichan=0; ichannChans; ichan++) { - getline(infile,str); -#ifdef VERBOSE - // std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - -#ifdef VERBOSE - // std::cout<< "channel " << ichan+ichip*thisDetector->nChans <<" iline " << iline<< std::endl; -#endif - iline++; - myMod->chanregs[ichip*thisDetector->nChans+ichan]=0; - for (int iarg=0; iarg<6 ; iarg++) { - ssstr >> ival; - //if (ssstr.good()) { - switch (iarg) { - case 0: -#ifdef VERBOSE - // std::cout<< "trimbits " << ival ; -#endif - myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival&0x3f; - break; - case 1: -#ifdef VERBOSE - //std::cout<< " compen " << ival ; -#endif - myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<9; - break; - case 2: -#ifdef VERBOSE - //std::cout<< " anen " << ival ; -#endif - myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<8; - break; - case 3: -#ifdef VERBOSE - //std::cout<< " calen " << ival ; -#endif - myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<7; - break; - case 4: -#ifdef VERBOSE - //std::cout<< " outcomp " << ival ; -#endif - myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<10; - break; - case 5: -#ifdef VERBOSE - //std::cout<< " counts " << ival << std::endl; -#endif - myMod->chanregs[ichip*thisDetector->nChans+ichan]|=ival<<11; - break; - default: - std::cout<< " too many columns" << std::endl; - break; - } - } - } - // } - } -#ifdef VERBOSE - std::cout<< "read " << ichan*ichip << " channels" <settingsFile,fname.c_str()); - return myMod; - } else { - std::cout<< "could not open trim file " << myfname << std::endl; - if (nflag) - deleteModule(myMod); - return NULL; - } - -}; - - -int mythenDetector::writeSettingsFile(string fname, sls_detector_module mod){ - - ofstream outfile; - string names[]={"Vtrim", "Vthresh", "Rgsh1", "Rgsh2", "Rgpr", "Vcal", "outBuffEnable"}; - int iv, ichan, ichip; - int iv1, idac; - int nb; - outfile.open(fname.c_str(), ios_base::out); - - if (outfile.is_open()) { - for (idac=0; idacnChans; ichan++) { - iv=mod.chanregs[ichip*thisDetector->nChans+ichan]; - iv1= (iv&0x3f); - outfile <>nb); - outfile << iv1 << " "; - nb=8; - iv1=((iv&(1<>nb); - outfile << iv1 << " "; - nb=7; - iv1=((iv&(1<>nb); - outfile <>nb); - outfile << iv1 << " "; - nb=11; - iv1= ((iv&0xfffff800)>>nb); - outfile << iv1 << std::endl; - } - } - outfile.close(); - return OK; - } else { - std::cout<< "could not open trim file " << fname << std::endl; - return FAIL; - } - -}; - - - - -int mythenDetector::writeSettingsFile(string fname, int imod){ - - return writeSettingsFile(fname,detectorModules[imod]); - -}; - - -int mythenDetector::writeDataFile(string fname, float *data, float *err, float *ang, char dataformat, int nch){ - - - - - if (nch==-1) - nch=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; - - - ofstream outfile; - int idata; - if (data==NULL) - return FAIL; - - // args|=0x10; // one line per channel! - - outfile.open (fname.c_str(),ios_base::out); - if (outfile.is_open()) - { -#ifdef VERBOSE - std::cout<< "writeDataFile Writing to file " << fname << std::endl; -#endif - for (int ichan=0; ichannChans*thisDetector->nChips*thisDetector->nMods; ichan++) - outfile << ichan << " " << *(data+ichan) << std::endl; - outfile.close(); - return OK; - } else { - std::cout<< "Could not open file " << fname << "for writing"<< std::endl; - return FAIL; - } -}; - - - - - -int mythenDetector::readDataFile(string fname, float *data, float *err, float *ang, char dataformat, int nch){ - - - ifstream infile; - int ichan, iline=0; - int interrupt=0; - float fdata, ferr, fang; - int maxchans; - int ich; - string str; - - if (nch==0) - maxchans=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods; - else if (nch<0) - maxchans=0xfffffff; - else - maxchans=nch; - -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - while (infile.good() and interrupt==0) { - getline(infile,str); -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - if (ang==NULL) { - ssstr >> ichan >> fdata; - ich=ichan; - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - if (ich!=iline) - std::cout<< "Channel number " << ichan << " does not match with line number " << iline << " " << dataformat << std::endl; - } else { - ssstr >> fang >> fdata; - ich=iline; - } - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - if (err) - ssstr >> ferr; - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - if (ich> ichan >> idata; - if (ssstr.fail() || ssstr.bad()) { - interrupt=1; - break; - } - if (ichan!=iline) { - std::cout<< " Expected channel "<< iline <<" but read channel "<< ichan << std::endl; - interrupt=1; - break; - } else { - if (ilinenChans*thisDetector->nChips*thisDetector->nMods) { - data[iline]=idata; - iline++; - } else { - interrupt=1; - break; - } - } - } - } else { - std::cout<< "Could not read file " << fname << std::endl; - return -1; - } - return iline; -}; - - - - -int mythenDetector::readCalibrationFile(string fname, float &gain, float &offset){ - - string str; - ifstream infile; -#ifdef VERBOSE - std::cout<< "Opening file "<< fname << std::endl; -#endif - infile.open(fname.c_str(), ios_base::in); - if (infile.is_open()) { - getline(infile,str); -#ifdef VERBOSE - std::cout<< str << std::endl; -#endif - istringstream ssstr(str); - ssstr >> offset >> gain; - } else { - std::cout<< "Could not open calibration file "<< fname << std::endl; - gain=0.; - offset=0.; - return -1; - } - return 0; -}; - -int mythenDetector::writeCalibrationFile(string fname, float gain, float offset){ - //std::cout<< "Function not yet implemented " << std::endl; - ofstream outfile; - - outfile.open (fname.c_str()); - - // >> i/o operations here << - if (outfile.is_open()) { - outfile << offset << " " << gain << std::endl; - } else { - std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl; - return -1; - } - - outfile.close(); - - return 0; -}; - - - diff --git a/slsDetectorSoftware/mythenDetector/mythenDetector.h b/slsDetectorSoftware/mythenDetector/mythenDetector.h deleted file mode 100644 index b53b7c282..000000000 --- a/slsDetectorSoftware/mythenDetector/mythenDetector.h +++ /dev/null @@ -1,42 +0,0 @@ - - - -#ifndef MYTHEN_DETECTOR_H -#define MYTHEN_DETECTOR_H - -//#include -#include "slsDetector.h" -#include "usersFunctions.h" - -#define defaultTDead {170,90,750} - -//using namespace std; -/** - \mainpage C++ class with MYTHEN specific functions - * - - - @author Anna Bergamaschi - -*/ - - - -class mythenDetector : public slsDetector{ - - - - public: - /** - (default) constructor - */ - mythenDetector(int id=0, detectorType t=MYTHEN) : slsDetector(t, id){}; - //slsDetector(string const fname); - // ~slsDetector(){while(dataQueue.size()>0){}}; - /** destructor */ - virtual ~mythenDetector(){}; - - - -}; -#endif