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

beamtime/gsi-aug12/hd/go4/VFTX/TVftxParam.cxx (r4864/r3214)

Go to the documentation of this file.
00001 /* Generated by Together */
00002 
00003 #include "TVftxParam.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 CALIB_HISTOS_ENABLE      0
00015 #define COINCIDENCE_MAPPING      0
00016 #define BIT_CONTROL              0
00017 #define FINE_TIME_HISTO_ENABLE   0
00018 #define COARSE_TIME_HIST_ENABLE  0
00019 #define CALIBRATION_ENABLE       0
00020 #define MIN_NB_HITS_CALIB     5000
00021 #define INITIAL_CAL_FILENAME     ""
00022 #define CALIBRATION_OUT_ENABLE   0
00023 #define TIME_HISTO_ENABLE        0
00024 #define TOT_HISTO_ENABLE         0
00025 
00026 TVftxParam::TVftxParam(const char* name) : TGo4Parameter(name)
00027 {
00028    ReadOptions();
00029 }
00030 
00031 //***********************************************************
00032 TVftxParam::~TVftxParam()
00033 {
00034 }
00035 
00036 Bool_t TVftxParam::ReadOptions(){
00037    // Loading default values
00038    uDebug           = DEBUG_OPTION;
00039    for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00040       uVftxCalHistosEnabled[iIndexVftx] = CALIB_HISTOS_ENABLE;
00041    uVftxCoincidenceMap = COINCIDENCE_MAPPING;
00042    uBitControl      = BIT_CONTROL;
00043    uFineHistEnable  = FINE_TIME_HISTO_ENABLE;
00044    uCoarseTimeHisto = COARSE_TIME_HIST_ENABLE; 
00045    uEnableCalib     = CALIBRATION_ENABLE;
00046    iMinNbHitsCalib  = MIN_NB_HITS_CALIB;
00047    sInitialCalibrationFilename = INITIAL_CAL_FILENAME;
00048    for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00049       uVftxInitalCalIndex[iIndexVftx] = iIndexVftx;
00050    uEnableCalibOutput = CALIBRATION_OUT_ENABLE;
00051    uTimeHistEnable  = TIME_HISTO_ENABLE;
00052    uTotHistoEnable  = TOT_HISTO_ENABLE;
00053    
00054    // Read the option file
00055    fstream setupFile("./Vftx_options.txt", ios::in);
00056    
00057    // Testing if the option does exist. If not I use default values.
00058    if( setupFile.fail() == true)
00059    {
00060       cout<<"Error: Setup file TVftx_options.txt can not be opened or is missing."<<endl;
00061       cout<<"=> Using default values!"<<endl;
00062    }
00063    else
00064    {
00065       TString line;
00066       line.ReadLine(setupFile, kFALSE); // Read a line of the option file and set the iterator automatically to the next line
00067       
00068       // Goes through all lines
00069       while( !setupFile.eof() )
00070       {
00071          if(line(0) == '#' || line(0) == '*')
00072          {
00073             //Comment in the text file
00074             ;
00075          }
00076          else if(line.Contains("debug")==kTRUE)
00077          {
00078             uDebug = ((TString)line(5,10)).Atoi();
00079             if(1 == uDebug)
00080                cout<<"Debug ON!!!!!!"<<endl;
00081          }
00082          else if(line.Contains("vftxcalena")==kTRUE)
00083          {
00084             line = line(11,3*MAX_FPGA_TDC);
00085             if( 0 != line.Sizeof() )
00086             {
00087                for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00088                {
00089                   uVftxCalHistosEnabled[temp_index] = ((TString)line(0,3)).Atoi();
00090                   line = line(3,3*MAX_FPGA_TDC);
00091                } // for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00092             } // if( 0 != line.Sizeof() )
00093          }
00094          else if(line.Contains("chcoimap")==kTRUE)
00095          {
00096             uVftxCoincidenceMap = ((TString)line(8,10)).Atoi();
00097             if(1 == uDebug)
00098                cout<<"Test uVftxCoincidenceMap: "<<uVftxCoincidenceMap<<endl;
00099          }
00100          else if(line.Contains("bitcontrol")==kTRUE)
00101          {
00102             uBitControl = ((TString)line(10,10)).Atoi();
00103             if(1 == uDebug)
00104                cout<<"Test uBitControl: "<<uBitControl<<endl;
00105          }
00106          else if(line.Contains("coarsetimehisto")==kTRUE)
00107          {
00108             uCoarseTimeHisto = ((TString)line(15,10)).Atoi();
00109             if(1 == uDebug)
00110                cout<<"Test uCoarseTimeHisto: "<<uCoarseTimeHisto<<endl;
00111          }
00112          else if(line.Contains("finetime")==kTRUE)
00113          {
00114             uFineHistEnable = ((TString)line(8,10)).Atoi();
00115             if(1 == uDebug)
00116                cout<<"Test uFineHistEnable: "<<uFineHistEnable<<endl;
00117          }
00118          else if(line.Contains("finetevo")==kTRUE)
00119          {
00120             uFineEvolutionHistEnable = ((TString)line(8,10)).Atoi();
00121             if(1 == uDebug)
00122                cout<<"Test uFineEvolutionHistEnable: "<<uFineEvolutionHistEnable<<endl;
00123          }
00124          else if(line.Contains("calibena")==kTRUE)
00125          {
00126             uEnableCalib = ((TString)line(9,10)).Atoi();
00127             if(1 == uDebug)
00128                cout<<"Test uEnableCalib: "<<uEnableCalib<<endl;
00129          }
00130          else if(line.Contains("calibnb")==kTRUE)
00131          {
00132             iMinNbHitsCalib = ((TString)line(8,10)).Atoi();
00133             if(1 == uDebug)
00134                cout<<"Test iMinNbHitsCalib: "<<iMinNbHitsCalib<<endl;
00135          }
00136          else if(line.Contains("initialcalibfile")==kTRUE)
00137          {
00138             sInitialCalibrationFilename = (TString)line(17,128);
00139             if(1 == uDebug)
00140                cout<<"Test sInitialCalibrationFilename: "<<sInitialCalibrationFilename<<endl;
00141          } 
00142          else if(line.Contains("inicalindex")==kTRUE)
00143          {
00144             line = line(12,3*MAX_FPGA_TDC);
00145             if( 0 != line.Sizeof() )
00146             {
00147                for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00148                {
00149                   uVftxInitalCalIndex[temp_index] = ((TString)line(0,3)).Atoi();
00150                   line = line(3,3*MAX_FPGA_TDC);
00151                } // for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00152             } // if( 0 != line.Sizeof() )
00153          }
00154          else if(line.Contains("caliboutena")==kTRUE)
00155          {
00156             uEnableCalibOutput = ((TString)line(12,10)).Atoi();
00157             if(1 == uDebug)
00158                cout<<"Test uEnableCalibOutput: "<<uEnableCalibOutput<<endl;
00159          }
00160          else if(line.Contains("timeplot")==kTRUE)
00161          {
00162             uTimeHistEnable = ((TString)line(8,10)).Atoi();
00163             if(1 == uDebug)
00164                cout<<"Test uTimeHistEnable: "<<uTimeHistEnable<<endl;
00165          }
00166          else if(line.Contains("totplot")==kTRUE)
00167          {
00168             uTotHistoEnable = ((TString)line(8,10)).Atoi();
00169             if(1 == uDebug)
00170                cout<<"Test uTotHistoEnable: "<<uTotHistoEnable<<endl;
00171          }
00172          else if(line.Contains("outroot")==kTRUE)
00173          {
00174             iRootOutput = ((TString)line(8,10)).Atoi();
00175          } 
00176          else if(line.Contains("filenameoutput")==kTRUE)
00177          {
00178             sOutputFilename = (TString)line(15,128);
00179          } 
00180          else if(line.Contains("disproot")==kTRUE)
00181          {
00182             iRootDisplay = ((TString)line(8,10)).Atoi();
00183          }
00184          line.ReadLine(setupFile, kFALSE);
00185          if(1 == uDebug)
00186             cout<<line<<endl;
00187       }
00188    }
00189    if( uEnableCalib )
00190    {
00191       cout<<" Fine time Histos needed for corrections => Enable!!"<<endl;
00192       uFineHistEnable = 1;
00193 
00194       if( -1 == iMinNbHitsCalib &&
00195           ( kTRUE == sInitialCalibrationFilename.EqualTo("") ||
00196             kTRUE == sInitialCalibrationFilename.EqualTo("-") ) )
00197       {
00198          cout<<" Nb of hits per channel needed for corrections disabled while calibration file disabled ";
00199          cout<<"=> Enable iMinNbHitsCalib and set it to 400!!"<<endl;
00200          iMinNbHitsCalib = 400;
00201       }
00202    }
00203    
00204    this->PrintOptions(); //print out all values to see, if the setting has worked correctly
00205    return kTRUE;
00206 }
00207 
00208 
00209 Int_t TVftxParam::PrintOptions(){
00210    cout<<"********************* VFTX calibration parameters **********************"<<endl;
00211    if(1 == uDebug)
00212       cout<<"Debug ON!!!!!!"<<endl;
00213       else cout<<"Debug OFF"<<endl;
00214    cout<<"VFTX FPGA TDC index:       |-      ";
00215    for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00216    {
00217       cout.width(2);
00218       cout<<iIndexVftx<<" ";
00219    }
00220    cout<<endl<<"Calibration histo. enabled |->     ";
00221    for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00222    {
00223       cout.width(2);
00224       cout<<uVftxCalHistosEnabled[iIndexVftx] <<" ";
00225    }
00226    cout<<endl;
00227    cout<<"Channel coincidence mapping   :     "<<uVftxCoincidenceMap<<endl;
00228    cout<<"Control bit Histograms        :     "<<uBitControl<<endl; 
00229    cout<<"Fine Time Histograms          :     "<<uFineHistEnable<<endl;
00230    cout<<"Fine Time Evolution Histograms:     "<<uFineEvolutionHistEnable<<endl;
00231    cout<<"Coarse time Histograms        :     "<<uCoarseTimeHisto<<endl;
00232    if(1 == uEnableCalib)
00233       cout<<"Calibration                   :     ON"<<endl;
00234       else cout<<"Calibration                   :     OFF"<<endl;
00235    if( -1 == iMinNbHitsCalib &&
00236          kTRUE != sInitialCalibrationFilename.EqualTo("") && kTRUE != sInitialCalibrationFilename.EqualTo("-") )
00237    {
00238       cout<<"Filename for calib hist:            "<<sInitialCalibrationFilename<<endl;
00239       cout<<"VFTX FPGA TDC index:       |-      ";
00240       for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00241       {
00242          cout.width(2);
00243          cout<<iIndexVftx<<" ";
00244       }
00245       cout<<endl<<"Tdc initial calib. index:  |->     ";
00246       for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00247       {
00248          cout.width(2);
00249          cout<<uVftxInitalCalIndex[iIndexVftx] <<" ";
00250       }
00251       cout<<endl;
00252    }
00253       else
00254       {
00255          cout<<"Min nb hits for calib         :     "<<iMinNbHitsCalib<<endl;
00256          if( kTRUE != sInitialCalibrationFilename.EqualTo("") && kTRUE != sInitialCalibrationFilename.EqualTo("-") )
00257          {
00258             cout<<"Filename for intial calib hist:     "<<sInitialCalibrationFilename<<endl;
00259             cout<<"VFTX FPGA TDC index:       |-      ";
00260             for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00261             {
00262                cout.width(2);
00263                cout<<iIndexVftx<<" ";
00264             }
00265             cout<<endl<<"Tdc initial calib. index:  |->     ";
00266             for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00267             {
00268                cout.width(2);
00269                cout<<uVftxInitalCalIndex[iIndexVftx] <<" ";
00270             }
00271             cout<<endl;
00272          }
00273       }
00274    if(1 == uEnableCalib)
00275       cout<<"Calibration saved in root file:     ON"<<endl;
00276       else cout<<"Calibration saved in root file:     OFF"<<endl;
00277    cout<<"Time Histograms               :     "<<uTimeHistEnable<<endl;
00278    cout<<"Tot  Histograms               :     "<<uTotHistoEnable<<endl;
00279    cout<<"************************************************************************"<<endl;
00280    
00281    return 0;
00282 }

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