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

beamtime/tof-tdctest/go4/MBSUNPACK/TMbsCrateParam.cxx (r4864/r4267)

Go to the documentation of this file.
00001 /* Generated by Together */
00002 
00003 #include "TMbsCrateParam.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 CAEN_DEBUG               kFALSE
00015 #define CAEN_TRIGGER_HISTO       kFALSE
00016 #define CAEN_COINC_MAP           0
00017 #define CAEN_TDC_ENABLE          1
00018 #define CAEN_QDC_ENABLE          1
00019 #define LECROY_QDC_ENABLE        1
00020 #define VFTX_TDC_ENABLE          1
00021 #define QFW_ENABLE               1
00022 
00023 TMbsCrateParam::TMbsCrateParam(const char* name) : TGo4Parameter(name)
00024 {
00025    ReadOptions();
00026 }
00027 
00028 //***********************************************************
00029 TMbsCrateParam::~TMbsCrateParam()
00030 {
00031 }
00032 
00033 Bool_t TMbsCrateParam::ReadOptions(){
00034    // Loading default values
00035    uDebug           = DEBUG_OPTION;
00036       // CAEN TDC v1290
00037    bCaenDebug       = CAEN_DEBUG;
00038    bCaenTriggerTime = CAEN_TRIGGER_HISTO;
00039    uCaenCoincidenceMap = CAEN_COINC_MAP;
00040    for( Int_t iIndex1290 = 0; iIndex1290 < MAX_1290; iIndex1290++)
00041       uCaenTdcHistosEnabled[iIndex1290] = CAEN_TDC_ENABLE;
00042       // CAEN QDC v965
00043    for( Int_t iIndex965 = 0; iIndex965 < MAX_965; iIndex965++)
00044       uCaenQdcHistosEnabled[iIndex965] = CAEN_QDC_ENABLE; 
00045       // Lecroy QDC 1182
00046    for( Int_t iIndex1182 = 0; iIndex1182 < MAX_1182; iIndex1182++)
00047       uLecroyQdcHistosEnabled[iIndex1182] = LECROY_QDC_ENABLE;
00048       // VFTX FPGA TDC
00049    for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00050       uVftxHistosEnabled[iIndexVftx] = VFTX_TDC_ENABLE;
00051       // QFW
00052    uQFWHistosEnabled = QFW_ENABLE;
00053    
00054    // Try to read the option filename from the general option files text file
00055    TString sOptionFileName = "./mbsUnpack_options.txt";
00056    Bool_t bFilenameFound = kFALSE;
00057    fstream optionFilenameFile("./Option_files.txt", ios::in);
00058    // Testing if the file does exist. If not I use default values
00059    if( optionFilenameFile.fail() == true)
00060    {
00061       cout<<"************************************************************************"<<endl;
00062       cout<<" File with option filename for MbsUnpacker not found: using the default value ";
00063       cout<<sOptionFileName<<endl;
00064    } // if( optionFilenameFile.fail() == true)
00065       else
00066       {
00067          TString line;
00068 
00069          // Goes through all lines
00070          while( !optionFilenameFile.eof() )
00071          {
00072            line.ReadLine(optionFilenameFile, kFALSE); // Read a line of the option file and set the iterator automatically to the next line
00073 
00074            if(line(0) == '#' || line(0) == '*'||
00075                (line(0) == '/' && line(1) == '/') )
00076            {
00077               //Comment in the text file
00078               ;
00079            }
00080            else if(line.Contains("mbsunpack")==kTRUE)
00081            {
00082               sOptionFileName = ((TString)line(11, line.Sizeof()-11 ));
00083               cout<<"************************************************************************"<<endl;
00084               cout<<"Using "<<sOptionFileName<<" as source for the options of MbsUnpack step"<<endl;
00085               bFilenameFound = kTRUE;
00086               break;
00087            }
00088          } // while( !optionFilenameFile.eof() )
00089          if( optionFilenameFile.eof() && kFALSE == bFilenameFound )
00090          {
00091             cout<<"************************************************************************"<<endl;
00092             cout<<"Field for MbsUnpack step not found in File with option filename => Using "<<sOptionFileName<<endl;
00093          } // if( optionFilenameFile.eof() && kFALSE == bFilenameFound )
00094       } // else of if( optionFilenameFile.fail() == true)
00095 
00096    // Read the option file
00097    fstream setupFile(sOptionFileName, ios::in);
00098    
00099    // Testing if the option does exist. If not I use default values.
00100    if( setupFile.fail() == true)
00101    {
00102       cout<<"Error for TMbsCrateParam: Setup file "<<sOptionFileName<<" can not be opened or is missing."<<endl;
00103       cout<<"=> Using default values!"<<endl;
00104    }
00105    else
00106    {
00107       TString line;
00108       
00109       // Goes through all lines
00110       while( !setupFile.eof() )
00111       {
00112          line.ReadLine(setupFile, kFALSE); // Read a line of the option file and set the iterator automatically to the next line
00113          if(1 == uDebug)
00114             cout<<line<<endl;
00115 
00116          if(line(0) == '#' || line(0) == '*')
00117          {
00118             //Comment in the text file
00119             ;
00120          }
00121          else if(line.Contains("unpackdebug")==kTRUE)
00122          {
00123             uDebug = ((TString)line(13,10)).Atoi();
00124             if(1 == uDebug)
00125                cout<<"Debug ON!!!!!!"<<endl;
00126          }
00127          else if(line.Contains("caentdcdebug")==kTRUE)
00128          {
00129             bCaenDebug = ( 1 == ((TString)line(13,10)).Atoi() ) ;
00130          }
00131          else if(line.Contains("caentrigtime")==kTRUE)
00132          {
00133             bCaenTriggerTime = ( 1 == ((TString)line(13,10)).Atoi() );
00134          }
00135          else if(line.Contains("caencoincmap")==kTRUE)
00136          {
00137             uCaenCoincidenceMap = ((TString)line(13,10)).Atoi() ;
00138          }
00139          else if(line.Contains("caentdcena")==kTRUE)
00140          {
00141             line = line(11,3*MAX_1290);
00142             if( 0 != line.Sizeof() )
00143             {
00144                for(UInt_t temp_index = 0; temp_index < MAX_1290 && 0 != line.Sizeof(); temp_index++)
00145                {
00146                   uCaenTdcHistosEnabled[temp_index] = ((TString)line(0,3)).Atoi();
00147                   line = line(3,3*MAX_1290);
00148                } // for(UInt_t temp_index = 0; temp_index < MAX_1290 && 0 != line.Sizeof(); temp_index++)
00149             } // if( 0 != line.Sizeof() )
00150          }
00151          else if(line.Contains("caenqdcena")==kTRUE)
00152          {
00153             line = line(11,3*MAX_965);
00154             if( 0 != line.Sizeof() )
00155             {
00156                for(UInt_t temp_index = 0; temp_index < MAX_965 && 0 != line.Sizeof(); temp_index++)
00157                {
00158                   uCaenQdcHistosEnabled[temp_index] = ((TString)line(0,3)).Atoi();
00159                   line = line(3,3*MAX_965);
00160                } // for(UInt_t temp_index = 0; temp_index < MAX_965 && 0 != line.Sizeof(); temp_index++)
00161             } // if( 0 != line.Sizeof() )
00162          }
00163          else if(line.Contains("qdc1182ena")==kTRUE)
00164          {
00165             line = line(11,3*MAX_1182);
00166             if( 0 != line.Sizeof() )
00167             {
00168                for(UInt_t temp_index = 0; temp_index < MAX_1182 && 0 != line.Sizeof(); temp_index++)
00169                {
00170                   uLecroyQdcHistosEnabled[temp_index] = ((TString)line(0,3)).Atoi();
00171                   line = line(3,3*MAX_1182);
00172                } // for(UInt_t temp_index = 0; temp_index < MAX_1182 && 0 != line.Sizeof(); temp_index++)
00173             } // if( 0 != line.Sizeof() )
00174          }
00175          else if(line.Contains("vftxrawena")==kTRUE)
00176          {
00177             line = line(11,3*MAX_FPGA_TDC);
00178             if( 0 != line.Sizeof() )
00179             {
00180                for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00181                {
00182                   uVftxHistosEnabled[temp_index] = ((TString)line(0,3)).Atoi();
00183                   line = line(3,3*MAX_FPGA_TDC);
00184                } // for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00185             } // if( 0 != line.Sizeof() )
00186          }
00187          else if(line.Contains("qfwhistena")==kTRUE)
00188          {
00189             uQFWHistosEnabled = ((TString)line(11,10)).Atoi();
00190          }
00191       } // while( !setupFile.eof() )
00192    } //  else of if( setupFile.fail() == true)
00193    
00194    this->PrintOptions(); //print out all values to see, if the setting has worked correctly
00195    return kTRUE;
00196 }
00197 
00198 
00199 Int_t TMbsCrateParam::PrintOptions(){
00200    cout<<"******************** MBS crate unpacker parameters *********************"<<endl;
00201    if(1 == uDebug)
00202       cout<<"Debug ON!!!!!!"<<endl;
00203       else cout<<"Debug OFF"<<endl;
00204       
00205    // CAEN TDC v1290
00206    cout<<"------------------------------------------------------------------------"<<endl;
00207    cout<<"CAEN v1290 debug Histograms:        "<<bCaenDebug<<endl; 
00208    cout<<"CAEN v1290 trigger time Histograms: "<<bCaenTriggerTime<<endl; 
00209    cout<<"Caen v1290 tdc index:      |-       ";
00210    for( Int_t iIndex1290 = 0; iIndex1290 < MAX_1290; iIndex1290++)
00211    {
00212       cout.width(2);
00213       cout<<iIndex1290<<" ";
00214    }
00215    cout<<endl<<"Unpacking histo. enabled   |->      ";
00216    for( Int_t iIndex1290 = 0; iIndex1290 < MAX_1290; iIndex1290++)
00217    {
00218       cout.width(2);
00219       cout<<uCaenTdcHistosEnabled[iIndex1290]<<" ";
00220    }
00221    cout<<endl;
00222    
00223    // CAEN QDC v965
00224    cout<<"------------------------------------------------------------------------"<<endl;
00225    cout<<"Caen v965 qdc index:       |-       ";
00226    for( Int_t iIndex965 = 0; iIndex965 < MAX_965; iIndex965++)
00227    {
00228       cout.width(2);
00229       cout<<iIndex965<<" ";
00230    }
00231    cout<<endl<<"Unpacking histo. enabled   |->      ";
00232    for( Int_t iIndex965 = 0; iIndex965 < MAX_965; iIndex965++)
00233    {
00234       cout.width(2);
00235       cout<<uCaenQdcHistosEnabled[iIndex965]<<" ";
00236    }
00237    cout<<endl;
00238    
00239    // Lecroy QDC 1182
00240    cout<<"------------------------------------------------------------------------"<<endl;
00241    cout<<"Lecroy 1182 qdc index:     |-       ";
00242    for( Int_t iIndex1182 = 0; iIndex1182 < MAX_1182; iIndex1182++)
00243    {
00244       cout.width(2);
00245       cout<<iIndex1182<<" ";
00246    }
00247    cout<<endl<<"Unpacking histo. enabled   |->      ";
00248    for( Int_t iIndex1182 = 0; iIndex1182 < MAX_1182; iIndex1182++)
00249    {
00250       cout.width(2);
00251       cout<<uLecroyQdcHistosEnabled[iIndex1182] <<" ";
00252    }
00253    cout<<endl;
00254    
00255    // VFTX FPGA TDC
00256    cout<<"------------------------------------------------------------------------"<<endl;
00257    cout<<"VFTX FPGA TDC index:       |-       ";
00258    for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00259    {
00260       cout.width(2);
00261       cout<<iIndexVftx<<" ";
00262    }
00263    cout<<endl<<"Unpacking histo. enabled   |->      ";
00264    for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00265    {
00266       cout.width(2);
00267       cout<<uVftxHistosEnabled[iIndexVftx] <<" ";
00268    }
00269    cout<<endl;
00270    
00271    // QFW
00272    cout<<"------------------------------------------------------------------------"<<endl;
00273    if( 1 == uQFWHistosEnabled )
00274       cout<<"QFW histograms:                     ON"<<endl;
00275       else cout<<"QFW histograms:                     OFF"<<endl;
00276    cout<<"************************************************************************"<<endl;
00277    return 0;
00278 }

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