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

beamtime/gsi-aug12/prod/go4/VFTX/TVftxParam.cxx (r4864/r4011)

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 REFERENCE_CHANNEL        -1
00016 #define MAIN_REFERENCE_TDC       -1
00017 #define DIAMOND_CHANNEL          -1
00018 #define COINCIDENCE_MAPPING       0
00019 #define BIT_CONTROL               0
00020 #define FINE_TIME_HISTO_ENABLE    0
00021 #define COARSE_TIME_HIST_ENABLE   0
00022 #define CALIBRATION_ENABLE        0
00023 #define MIN_NB_HITS_CALIB      5000
00024 #define INITIAL_CAL_FILENAME      ""
00025 #define CALIBRATION_OUT_ENABLE    0
00026 #define TIME_HISTO_ENABLE         0
00027 #define TIME_HISTO_SINGLES_ENABLE 0
00028 #define TOT_HISTO_ENABLE          0
00029 #define MULTI_DIST_HISTO_ENABLE   0
00030 #define AUTO_TDC_OFFSET_DET       0
00031 
00032 #define SINGLE_CHAN_CALIB_INPUT   0
00033 #define SINGLE_CHAN_CALIB_OUTPUT  0
00034 
00035 TVftxParam::TVftxParam(const char* name) : TGo4Parameter(name)
00036 {
00037    ReadOptions();
00038 }
00039 
00040 //***********************************************************
00041 TVftxParam::~TVftxParam()
00042 {
00043 }
00044 
00045 Bool_t TVftxParam::ReadOptions(){
00046    // Loading default values
00047    uDebug           = DEBUG_OPTION;
00048    for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00049    {
00050       uVftxCalHistosEnabled[iIndexVftx] = CALIB_HISTOS_ENABLE;
00051       iVftxReference1Channel[iIndexVftx] = REFERENCE_CHANNEL;
00052       iVftxReference2Channel[iIndexVftx] = DIAMOND_CHANNEL;
00053    }
00054    iMainReferenceTdc = MAIN_REFERENCE_TDC;
00055    uVftxCoincidenceMap = COINCIDENCE_MAPPING;
00056    uBitControl      = BIT_CONTROL;
00057    uFineHistEnable  = FINE_TIME_HISTO_ENABLE;
00058    uCoarseTimeHisto = COARSE_TIME_HIST_ENABLE; 
00059    uEnableCalib     = CALIBRATION_ENABLE;
00060    iMinNbHitsCalib  = MIN_NB_HITS_CALIB;
00061    sInitialCalibrationFilename = INITIAL_CAL_FILENAME;
00062    for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00063       uVftxInitalCalIndex[iIndexVftx] = iIndexVftx;
00064    uEnableCalibOutput = CALIBRATION_OUT_ENABLE;
00065    uTimeHistEnable  = TIME_HISTO_ENABLE;
00066    uTimeHistSinglesEnable = TIME_HISTO_SINGLES_ENABLE;
00067    uTotHistoEnable  = TOT_HISTO_ENABLE;
00068    uMultiHitsDistanceHistoEnable = MULTI_DIST_HISTO_ENABLE;
00069 
00070    uAutomaticOffsetEnable = AUTO_TDC_OFFSET_DET;
00071    for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00072       iAutomaticTdcOffset[iIndexVftx] = 0;
00073    
00074    uSingleChannelCalibFilesEnable = SINGLE_CHAN_CALIB_INPUT;
00075    uSingleChannelCalibFilesOutput = SINGLE_CHAN_CALIB_OUTPUT;
00076 
00077    // Try to read the option filename from the general option files text file
00078    TString sOptionFileName = "./Vftx_options.txt";
00079    Bool_t bFilenameFound = kFALSE;
00080    fstream optionFilenameFile("./Option_files.txt", ios::in);
00081    // Testing if the file does exist. If not I use default values
00082    if( optionFilenameFile.fail() == true)
00083    {
00084       cout<<"************************************************************************"<<endl;
00085       cout<<" File with option filename for VFTX not found: using the default value ";
00086       cout<<sOptionFileName<<endl;
00087    } // if( optionFilenameFile.fail() == true)
00088       else
00089       {
00090          TString line;
00091 
00092          // Goes through all lines
00093          while( !optionFilenameFile.eof() )
00094          {
00095            line.ReadLine(optionFilenameFile, kFALSE); // Read a line of the option file and set the iterator automatically to the next line
00096 
00097            if(line(0) == '#' || line(0) == '*'||
00098                (line(0) == '/' && line(1) == '/') )
00099            {
00100               //Comment in the text file
00101               ;
00102            }
00103            else if(line.Contains("vftxcalib")==kTRUE)
00104            {
00105               sOptionFileName = ((TString)line(11, line.Sizeof()-11 ));
00106               cout<<"************************************************************************"<<endl;
00107               cout<<"Using "<<sOptionFileName<<" as source for the options of Vftx step"<<endl;
00108               bFilenameFound = kTRUE;
00109               break;
00110            }
00111          } // while( !optionFilenameFile.eof() )
00112          if( optionFilenameFile.eof() && kFALSE == bFilenameFound )
00113          {
00114             cout<<"************************************************************************"<<endl;
00115             cout<<"Field for Vftx step not found in File with option filename => Using "<<sOptionFileName<<endl;
00116          } // if( optionFilenameFile.eof() && kFALSE == bFilenameFound )
00117       } // else of if( optionFilenameFile.fail() == true)
00118 
00119    // Read the option file
00120    fstream setupFile(sOptionFileName, ios::in);
00121    
00122    // Testing if the option does exist. If not I use default values.
00123    if( setupFile.fail() == true)
00124    {
00125       cout<<"Error for TVftxParam: Setup file "<<sOptionFileName<<" can not be opened or is missing."<<endl;
00126       cout<<"=> Using default values!"<<endl;
00127    }
00128    else
00129    {
00130       TString line;
00131       
00132       // Goes through all lines
00133       while( !setupFile.eof() )
00134       {
00135          line.ReadLine(setupFile, kFALSE); // Read a line of the option file and set the iterator automatically to the next line
00136          if(1 == uDebug)
00137             cout<<line<<endl;
00138 
00139          if(line(0) == '#' || line(0) == '*')
00140          {
00141             //Comment in the text file
00142             ;
00143          }
00144          else if(line.Contains("debug")==kTRUE)
00145          {
00146             uDebug = ((TString)line(5,10)).Atoi();
00147             if(1 == uDebug)
00148                cout<<"Debug ON!!!!!!"<<endl;
00149          }
00150          else if(line.Contains("vftxcalena")==kTRUE)
00151          {
00152             line = line(11,3*MAX_FPGA_TDC);
00153             if( 0 != line.Sizeof() )
00154             {
00155                for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00156                {
00157                   uVftxCalHistosEnabled[temp_index] = ((TString)line(0,3)).Atoi();
00158                   line = line(3,3*MAX_FPGA_TDC);
00159                } // for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00160             } // if( 0 != line.Sizeof() )
00161          }
00162          else if(line.Contains("refonechan")==kTRUE)
00163          {
00164             line = line(11,3*MAX_FPGA_TDC);
00165             if( 0 != line.Sizeof() )
00166             {
00167                for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00168                {
00169                   iVftxReference1Channel[temp_index] = ((TString)line(0,3)).Atoi();
00170                   line = line(3,3*MAX_FPGA_TDC);
00171                } // for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00172             } // if( 0 != line.Sizeof() )
00173          }
00174          else if(line.Contains("reftwochan")==kTRUE)
00175          {
00176             line = line(11,3*MAX_FPGA_TDC);
00177             if( 0 != line.Sizeof() )
00178             {
00179                for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00180                {
00181                   iVftxReference2Channel[temp_index] = ((TString)line(0,3)).Atoi();
00182                   line = line(3,3*MAX_FPGA_TDC);
00183                } // for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00184             } // if( 0 != line.Sizeof() )
00185          }
00186          else if(line.Contains("mainreftdc")==kTRUE)
00187          {
00188             iMainReferenceTdc = ((TString)line(11,10)).Atoi();
00189             if(1 == uDebug)
00190                cout<<"Test iMainReferenceTdc: "<<iMainReferenceTdc<<endl;
00191          }
00192          else if(line.Contains("chcoimap")==kTRUE)
00193          {
00194             uVftxCoincidenceMap = ((TString)line(8,10)).Atoi();
00195             if(1 == uDebug)
00196                cout<<"Test uVftxCoincidenceMap: "<<uVftxCoincidenceMap<<endl;
00197          }
00198          else if(line.Contains("bitcontrol")==kTRUE)
00199          {
00200             uBitControl = ((TString)line(10,10)).Atoi();
00201             if(1 == uDebug)
00202                cout<<"Test uBitControl: "<<uBitControl<<endl;
00203          }
00204          else if(line.Contains("coarsetimehisto")==kTRUE)
00205          {
00206             uCoarseTimeHisto = ((TString)line(15,10)).Atoi();
00207             if(1 == uDebug)
00208                cout<<"Test uCoarseTimeHisto: "<<uCoarseTimeHisto<<endl;
00209          }
00210          else if(line.Contains("finetime")==kTRUE)
00211          {
00212             uFineHistEnable = ((TString)line(8,10)).Atoi();
00213             if(1 == uDebug)
00214                cout<<"Test uFineHistEnable: "<<uFineHistEnable<<endl;
00215          }
00216          else if(line.Contains("finetevo")==kTRUE)
00217          {
00218             uFineEvolutionHistEnable = ((TString)line(8,10)).Atoi();
00219             if(1 == uDebug)
00220                cout<<"Test uFineEvolutionHistEnable: "<<uFineEvolutionHistEnable<<endl;
00221          }
00222          else if(line.Contains("calibena")==kTRUE)
00223          {
00224             uEnableCalib = ((TString)line(9,10)).Atoi();
00225             if(1 == uDebug)
00226                cout<<"Test uEnableCalib: "<<uEnableCalib<<endl;
00227          }
00228          else if(line.Contains("calibnb")==kTRUE)
00229          {
00230             iMinNbHitsCalib = ((TString)line(8,10)).Atoi();
00231             if(1 == uDebug)
00232                cout<<"Test iMinNbHitsCalib: "<<iMinNbHitsCalib<<endl;
00233          }
00234          else if(line.Contains("initialcalibfile")==kTRUE)
00235          {
00236             sInitialCalibrationFilename = (TString)line(17,128);
00237             if(1 == uDebug)
00238                cout<<"Test sInitialCalibrationFilename: "<<sInitialCalibrationFilename<<endl;
00239          } 
00240          else if(line.Contains("inicalindex")==kTRUE)
00241          {
00242             line = line(12,3*MAX_FPGA_TDC);
00243             if( 0 != line.Sizeof() )
00244             {
00245                for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00246                {
00247                   uVftxInitalCalIndex[temp_index] = ((TString)line(0,3)).Atoi();
00248                   line = line(3,3*MAX_FPGA_TDC);
00249                } // for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00250             } // if( 0 != line.Sizeof() )
00251          }
00252          else if(line.Contains("caliboutena")==kTRUE)
00253          {
00254             uEnableCalibOutput = ((TString)line(12,10)).Atoi();
00255             if(1 == uDebug)
00256                cout<<"Test uEnableCalibOutput: "<<uEnableCalibOutput<<endl;
00257          }
00258          else if(line.Contains("timeplot")==kTRUE)
00259          {
00260             uTimeHistEnable = ((TString)line(8,10)).Atoi();
00261             if(1 == uDebug)
00262                cout<<"Test uTimeHistEnable: "<<uTimeHistEnable<<endl;
00263          }
00264          else if(line.Contains("timesing")==kTRUE)
00265          {
00266             uTimeHistSinglesEnable = ((TString)line(8,10)).Atoi();
00267             if(1 == uDebug)
00268                cout<<"Test uTimeHistSinglesEnable: "<<uTimeHistSinglesEnable<<endl;
00269          }
00270          else if(line.Contains("totplot")==kTRUE)
00271          {
00272             uTotHistoEnable = ((TString)line(8,10)).Atoi();
00273             if(1 == uDebug)
00274                cout<<"Test uTotHistoEnable: "<<uTotHistoEnable<<endl;
00275          }
00276          else if(line.Contains("muldist")==kTRUE)
00277          {
00278             uMultiHitsDistanceHistoEnable = ((TString)line(8,10)).Atoi();
00279             if(1 == uDebug)
00280                cout<<"Test uMultiHitsDistanceHistoEnable: "<<uMultiHitsDistanceHistoEnable<<endl;
00281          }
00282          else if(line.Contains("autooffs")==kTRUE)
00283          {
00284             uAutomaticOffsetEnable = ((TString)line(8,10)).Atoi();
00285             if(1 == uDebug)
00286                cout<<"Test uAutomaticOffsetEnable: "<<uAutomaticOffsetEnable<<endl;
00287          }
00288          else if(line.Contains("singchcalib")==kTRUE)
00289          {
00290             uSingleChannelCalibFilesEnable = ((TString)line(11,10)).Atoi();
00291             if(1 == uDebug)
00292                cout<<"Test uSingleChannelCalibFilesEnable: "<<uSingleChannelCalibFilesEnable<<endl;
00293          }
00294          else if(line.Contains("schcalibout")==kTRUE)
00295          {
00296             uSingleChannelCalibFilesOutput = ((TString)line(11,10)).Atoi();
00297             if(1 == uDebug)
00298                cout<<"Test uSingleChannelCalibFilesOutput: "<<uSingleChannelCalibFilesOutput<<endl;
00299          }
00300       } // while( !setupFile.eof() )
00301    } //  else of if( setupFile.fail() == true)
00302    if( uEnableCalib )
00303    {
00304       cout<<" Fine time Histos needed for corrections => Enable!!"<<endl;
00305       uFineHistEnable = 1;
00306 
00307       if( -1 == iMinNbHitsCalib &&
00308           ( kTRUE == sInitialCalibrationFilename.EqualTo("") ||
00309             kTRUE == sInitialCalibrationFilename.EqualTo("-") ) )
00310       {
00311          cout<<" Nb of hits per channel needed for corrections disabled while calibration file disabled ";
00312          cout<<"=> Enable iMinNbHitsCalib and set it to 400!!"<<endl;
00313          iMinNbHitsCalib = 400;
00314       }
00315    }
00316    
00317    this->PrintOptions(); //print out all values to see, if the setting has worked correctly
00318    return kTRUE;
00319 }
00320 
00321 
00322 Int_t TVftxParam::PrintOptions(){
00323    cout<<"********************* VFTX calibration parameters **********************"<<endl;
00324    if(1 == uDebug)
00325       cout<<"Debug ON!!!!!!"<<endl;
00326       else cout<<"Debug OFF"<<endl;
00327    cout<<"VFTX FPGA TDC index:       |-      ";
00328    for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00329    {
00330       cout.width(2);
00331       cout<<iIndexVftx<<" ";
00332    }
00333    cout<<endl<<"Calibration histo. enabled |->     ";
00334    for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00335    {
00336       cout.width(2);
00337       cout<<uVftxCalHistosEnabled[iIndexVftx] <<" ";
00338    }
00339    cout<<endl<<"1st reference channel      |->     ";
00340    for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00341    {
00342       cout.width(2);
00343       cout<<iVftxReference1Channel[iIndexVftx] <<" ";
00344    }
00345    cout<<endl<<"2nd reference channel      |->     ";
00346    for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00347    {
00348       cout.width(2);
00349       cout<<iVftxReference2Channel[iIndexVftx] <<" ";
00350    }
00351    cout<<endl;
00352    if( -1 < iMainReferenceTdc )
00353       cout<<"Main reference tdc            :     "<<iMainReferenceTdc<<endl;
00354       else cout<<"Main reference tdc            :     OFF"<<endl;
00355 
00356    cout<<"Channel coincidence mapping   :     "<<uVftxCoincidenceMap<<endl;
00357    cout<<"Control bit Histograms        :     "<<uBitControl<<endl; 
00358    cout<<"Fine Time Histograms          :     "<<uFineHistEnable<<endl;
00359    cout<<"Fine Time Evolution Histograms:     "<<uFineEvolutionHistEnable<<endl;
00360    cout<<"Coarse time Histograms        :     "<<uCoarseTimeHisto<<endl;
00361    if(1 == uEnableCalib)
00362       cout<<"Calibration                   :     ON"<<endl;
00363       else cout<<"Calibration                   :     OFF"<<endl;
00364    if( -1 == iMinNbHitsCalib &&
00365          kTRUE != sInitialCalibrationFilename.EqualTo("") && kTRUE != sInitialCalibrationFilename.EqualTo("-") )
00366    {
00367       cout<<"Filename for calib hist:            "<<sInitialCalibrationFilename<<endl;
00368       cout<<"VFTX FPGA TDC index:       |-      ";
00369       for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00370       {
00371          cout.width(2);
00372          cout<<iIndexVftx<<" ";
00373       }
00374       cout<<endl<<"Tdc initial calib. index:  |->     ";
00375       for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00376       {
00377          cout.width(2);
00378          cout<<uVftxInitalCalIndex[iIndexVftx] <<" ";
00379       }
00380       cout<<endl;
00381    }
00382       else
00383       {
00384          cout<<"Min nb hits for calib         :     "<<iMinNbHitsCalib<<endl;
00385          if( kTRUE != sInitialCalibrationFilename.EqualTo("") && kTRUE != sInitialCalibrationFilename.EqualTo("-") )
00386          {
00387             cout<<"Filename for intial calib hist:     "<<sInitialCalibrationFilename<<endl;
00388             cout<<"VFTX FPGA TDC index:       |-      ";
00389             for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00390             {
00391                cout.width(2);
00392                cout<<iIndexVftx<<" ";
00393             }
00394             cout<<endl<<"Tdc initial calib. index:  |->     ";
00395             for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00396             {
00397                cout.width(2);
00398                cout<<uVftxInitalCalIndex[iIndexVftx] <<" ";
00399             }
00400             cout<<endl;
00401          }
00402       }
00403    if(1 == uEnableCalibOutput)
00404       cout<<"Calibration saved in root file:     ON"<<endl;
00405       else cout<<"Calibration saved in root file:     OFF"<<endl;
00406    if( 1 == uTimeHistEnable )
00407       cout<<"Time Histograms               :     ON"<<endl;
00408       else cout<<"Time Histograms               :     OFF"<<endl;
00409    if( 1 == uTimeHistSinglesEnable )
00410       cout<<"Time Histograms Multiplicity 1:     ON"<<endl;
00411       else cout<<"Time Histograms Multiplicity 1:     OFF"<<endl;
00412    if( 1 == uTotHistoEnable )
00413       cout<<"Tot  Histograms               :     ON"<<endl;
00414       else cout<<"Tot  Histograms               :     OFF"<<endl;
00415    if( 1 == uMultiHitsDistanceHistoEnable )
00416       cout<<"Histograms Distance Multi Hits:     ON"<<endl;
00417       else cout<<"Histograms Distance Multi Hits:     OFF"<<endl;
00418    if(1 == uAutomaticOffsetEnable)
00419       cout<<"Automatic tdc offset detection:     ON"<<endl;
00420       else cout<<"Automatic tdc offset detection:     OFF"<<endl;
00421    if(1 == uSingleChannelCalibFilesEnable)
00422       cout<<"Use single channel calib files:     ON"<<endl;
00423       else cout<<"Use single channel calib files:     OFF"<<endl;
00424    switch( uSingleChannelCalibFilesOutput )
00425    {
00426       case 0:
00427          cout<<"Single channel calib files output:  OFF"<<endl;
00428          break;
00429       case 1:
00430          cout<<"Single channel calib files output:  New files from data"<<endl;
00431          break;
00432       case 2:
00433          cout<<"Single channel calib files output:  Update files with data"<<endl;
00434          break;
00435       default:
00436          break;
00437    }
00438 
00439    cout<<"************************************************************************"<<endl;
00440    
00441    return 0;
00442 }

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