• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

beamtime/gsi-aug12/get4v10/go4/SCALERS/TScalersParam.cxx (r4864/r3846)

Go to the documentation of this file.
00001 /* Generated by Together */
00002 
00003 #include "TScalersParam.h"
00004 
00005 #include "TGo4Version.h"
00006 #if __GO4BUILDVERSION__ > 40502
00007    #include "go4iostream.h"
00008 #else
00009    #include "Riostream.h"
00010 #endif
00011  
00012 // define default values
00013 #define DEBUG_OPTION               0
00014 #define REF_CLK_TRIGLOG_SCAL       0
00015 #define REF_CLK_TRIGLOG_CHAN      15
00016 #define REF_CLK_FREQUENCY     781250.0
00017 #define NB_DETECTORS_SCALORMU      0
00018 #define DETECTOR_SCALER            0
00019 #define NB_DIGITS_DETSCALMAP       3
00020 
00021 TScalersParam::TScalersParam(const char* name) : TGo4Parameter(name)
00022 {
00023    ReadOptions();
00024 }
00025 
00026 //***********************************************************
00027 TScalersParam::~TScalersParam()
00028 {
00029 }
00030 
00031 Bool_t TScalersParam::ReadOptions(){
00032    // Loading default values
00033    uDebug                   = DEBUG_OPTION;
00034    uReferenceClockScaler    = REF_CLK_TRIGLOG_SCAL;
00035    uReferenceClockChannel   = REF_CLK_TRIGLOG_CHAN;
00036    dReferenceClockFrequency = REF_CLK_FREQUENCY;
00037    dReferenceClockFrequencyTriglog  = REF_CLK_FREQUENCY;
00038    dReferenceClockFrequencyScalOrMu = REF_CLK_FREQUENCY;
00039    uNbDetectorsScalormu     = NB_DETECTORS_SCALORMU;
00040    for( Int_t iScalormuChan = 0; iScalormuChan < SCALORMU_NB_SCAL; iScalormuChan ++)
00041       uDetectorScaler[iScalormuChan] = DETECTOR_SCALER;
00042    
00043    // Try to read the option filename from the general option files text file
00044    TString sOptionFileName = "./Scalers_options.txt";
00045    Bool_t bFilenameFound = kFALSE;
00046    fstream optionFilenameFile("./Option_files.txt", ios::in);
00047    // Testing if the file does exist. If not I use default values
00048    if( optionFilenameFile.fail() == true)
00049    {
00050       cout<<"************************************************************************"<<endl;
00051       cout<<" File with option filename for Scalers not found: using the default value ";
00052       cout<<sOptionFileName<<endl;
00053    } // if( optionFilenameFile.fail() == true)
00054       else
00055       {
00056          TString line;
00057 
00058          // Goes through all lines
00059          while( !optionFilenameFile.eof() )
00060          {
00061            line.ReadLine(optionFilenameFile, kFALSE); // Read a line of the option file and set the iterator automatically to the next line
00062 
00063            if(line(0) == '#' || line(0) == '*'||
00064                (line(0) == '/' && line(1) == '/') )
00065            {
00066               //Comment in the text file
00067               ;
00068            }
00069            else if(line.Contains("scalers")==kTRUE)
00070            {
00071               sOptionFileName = ((TString)line(11, line.Sizeof()-11 ));
00072               cout<<"************************************************************************"<<endl;
00073               cout<<"Using "<<sOptionFileName<<" as source for the options of Scalers step"<<endl;
00074               bFilenameFound = kTRUE;
00075               break;
00076            }
00077          } // while( !optionFilenameFile.eof() )
00078          if( optionFilenameFile.eof() && kFALSE == bFilenameFound )
00079          {
00080             cout<<"************************************************************************"<<endl;
00081             cout<<"Field for Scalers step not found in File with option filename => Using "<<sOptionFileName<<endl;
00082          } // if( optionFilenameFile.eof() && kFALSE == bFilenameFound )
00083       } // else of if( optionFilenameFile.fail() == true)
00084 
00085    // Read the option file
00086    fstream setupFile(sOptionFileName, ios::in);
00087    
00088    // Testing if the option does exist. If not I use default values.
00089    if( setupFile.fail() == true)
00090    {
00091       cout<<"Error for TScalers: Setup file "<<sOptionFileName<<" can not be opened or is missing."<<endl;
00092       cout<<"=> Using default values!"<<endl;
00093    }
00094    else
00095    {
00096       TString line;
00097       
00098       // Goes through all lines
00099       while( !setupFile.eof() )
00100       {
00101          line.ReadLine(setupFile, kFALSE); // Read a line of the option file and set the iterator automatically to the next line
00102          if(1 == uDebug)
00103             cout<<line<<endl;
00104          if(line(0) == '#' || line(0) == '*'
00105                || (line(0) == '/'&& line(1) == '/' ))
00106          {
00107             //Comment in the text file
00108             ;
00109          }
00110          else if(line.Contains("debug")==kTRUE)
00111          {
00112             uDebug = ((TString)line(5,10)).Atoi();
00113             if(1 == uDebug)
00114                cout<<"Debug ON!!!!!!"<<endl;
00115          }
00116          else if(line.Contains("refclkscal")==kTRUE)
00117          {
00118             uReferenceClockScaler = ((TString)line(12,10)).Atoi();
00119             if(1 == uDebug)
00120                cout<<"Triglog scaler for Reference clock:  "<<uReferenceClockScaler<<endl;
00121          }
00122          else if(line.Contains("refclkchan")==kTRUE)
00123          {
00124             uReferenceClockChannel = ((TString)line(12,10)).Atoi();
00125             if(1 == uDebug)
00126                cout<<"Triglog channel for Reference clock: "<<uReferenceClockChannel<<endl;
00127          }
00128          else if(line.Contains("refclkfreq")==kTRUE)
00129          {
00130             dReferenceClockFrequency = ((TString)line(12,10)).Atoi();
00131             if(1 == uDebug)
00132                cout<<"Reference clock Frequency:           "<<dReferenceClockFrequency<<" Hz"<<endl;
00133          }
00134          else if(line.Contains("refclktrlo")==kTRUE)
00135          {
00136             dReferenceClockFrequencyTriglog = ((TString)line(12,10)).Atoi();
00137             if(1 == uDebug)
00138                cout<<"Reference clock Frequency Triglog:   "<<dReferenceClockFrequencyTriglog<<" Hz"<<endl;
00139          }
00140          else if(line.Contains("refclkscom")==kTRUE)
00141          {
00142             dReferenceClockFrequencyScalOrMu = ((TString)line(12,10)).Atoi();
00143             if(1 == uDebug)
00144                cout<<"Reference clock Frequency ScalOrMu:  "<<dReferenceClockFrequencyScalOrMu<<" Hz"<<endl;
00145          }
00146          else if(line.Contains("nbdetsumra")==kTRUE)
00147          {
00148             uNbDetectorsScalormu = ((TString)line(12,10)).Atoi();
00149             if(1 == uDebug)
00150                cout<<"Nb of detectors with full rate calc: "<<uNbDetectorsScalormu<<endl;
00151             if( SCALORMU_NB_SCAL < uNbDetectorsScalormu )
00152             {
00153                cout<<"Nb of detectors with full rate calc too high, set to max = nb scalormu channels"<<endl;
00154                uNbDetectorsScalormu = SCALORMU_NB_SCAL;
00155             }
00156          }
00157          else if(line.Contains("scaldetmap")==kTRUE)
00158          {
00159             line = line(12, NB_DIGITS_DETSCALMAP *SCALORMU_NB_SCAL);
00160             if( uNbDetectorsScalormu == 0 && line.Sizeof() )
00161             {
00162                if( 1 == uDebug )
00163                {
00164                cout<<"Warning: uNbDetectorsScalormu is 0 and detector to scaler array not empty: skip filling"<<line<<endl;
00165                cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00166                }
00167             }
00168             else
00169             {
00170                for(UInt_t temp_index = 0; temp_index < SCALORMU_NB_SCAL; temp_index++)
00171                {
00172                   uDetectorScaler[temp_index] = ((TString)line(0,NB_DIGITS_DETSCALMAP)).Atoi();
00173                   line = line(NB_DIGITS_DETSCALMAP, NB_DIGITS_DETSCALMAP*SCALORMU_NB_SCAL);
00174                }
00175             }
00176          }
00177       } // while( !setupFile.eof() )
00178    } //  else of if( setupFile.fail() == true)
00179 
00180    PrintOptions(); //print out all values to see, if the setting has worked correctly
00181    return kTRUE;
00182 }
00183 
00184 
00185 Int_t TScalersParam::PrintOptions(){
00186    cout<<"********************* SCALERS calibration parameters **********************"<<endl;
00187    if(1 == uDebug)
00188       cout<<"Debug ON!!!!!!"<<endl;
00189       else cout<<"Debug OFF"<<endl;
00190    cout<<"Triglog scaler for Reference clock:  "<<uReferenceClockScaler<<endl;
00191    cout<<"Triglog channel for Reference clock: "<<uReferenceClockChannel<<endl;
00192    cout<<"Reference clock Frequency:           "<<dReferenceClockFrequency<<" Hz"<<endl;
00193    cout<<"Reference clock Frequency Triglog:   "<<dReferenceClockFrequencyTriglog<<" Hz"<<endl;
00194    cout<<"Reference clock Frequency ScalOrMu:  "<<dReferenceClockFrequencyScalOrMu<<" Hz"<<endl;
00195    cout<<"Nb of detectors with full rate calc: "<<uNbDetectorsScalormu<<endl;
00196    cout<<"ScalOrMu channel:|-      ";
00197    for(UInt_t temp_index = 0; temp_index < SCALORMU_NB_SCAL; temp_index++)
00198    {
00199       cout.width(NB_DIGITS_DETSCALMAP - 1);
00200       cout<<temp_index<<" ";
00201    }
00202    cout<<endl<<"Detector         |->     ";
00203    for(UInt_t temp_index = 0; temp_index < SCALORMU_NB_SCAL; temp_index++)
00204    {
00205       cout.width(NB_DIGITS_DETSCALMAP - 1);
00206       cout<<uDetectorScaler[temp_index]<<" ";
00207    }
00208    cout<<endl;
00209 
00210    cout<<"************************************************************************"<<endl;
00211    
00212    return 0;
00213 }

Generated on Tue Dec 10 2013 04:52:20 for ROCsoft by  doxygen 1.7.1