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

beamtime/gsi-aug12/prod/go4/MATCHING/TMatchingParam.cxx (r4864/r3739)

Go to the documentation of this file.
00001 /* Generated by Together */
00002 
00003 #include "TMatchingParam.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 TRIGGER_SELECTION       -1
00015 #define TRIGGER_SEL_DEBUG_HIST   0
00016 #define NB_EV_AVERAGE_EFFICIENCY 0
00017 #define DETECTOR_OFFSET_TO_USE   1
00018 #define DT_FIT_ON                0
00019 
00020 TMatchingParam::TMatchingParam(const char* name) : TGo4Parameter(name)
00021 {
00022    ReadOptions();
00023 }
00024 
00025 //***********************************************************
00026 TMatchingParam::~TMatchingParam()
00027 {
00028 }
00029 
00030 Bool_t TMatchingParam::ReadOptions(){
00031    // Loading default values
00032    uDebug           = DEBUG_OPTION;
00033    iTriggerSelection = TRIGGER_SELECTION;                 // Trigger to be required for the matching
00034    uTriggerSelDebugHistos = TRIGGER_SEL_DEBUG_HIST;       // Disable/Enable the debug ;ode for trigger selection: 1 matching per trigger
00035    uNbEventAverageEfficiency = NB_EV_AVERAGE_EFFICIENCY;  // Number of event over which the efficiency of HD counter vs Rate is evaluated
00036    uDetectorOffsetToUse = DETECTOR_OFFSET_TO_USE;         // Select from which detector the offset for the dt matching should be taken: 0 = HD, 1 = Buc Ref
00037    
00038    uDtMatchingFitOn  = DT_FIT_ON;
00039 
00040    // Try to read the option filename from the general option files text file
00041    TString sOptionFileName = "./Matching_options.txt";
00042    Bool_t bFilenameFound = kFALSE;
00043    fstream optionFilenameFile("./Option_files.txt", ios::in);
00044    // Testing if the file does exist. If not I use default values
00045    if( optionFilenameFile.fail() == true)
00046    {
00047       cout<<"************************************************************************"<<endl;
00048       cout<<" File with option filename for Matching not found: using the default value ";
00049       cout<<sOptionFileName<<endl;
00050    } // if( optionFilenameFile.fail() == true)
00051       else
00052       {
00053          TString line;
00054 
00055          // Goes through all lines
00056          while( !optionFilenameFile.eof() )
00057          {
00058            line.ReadLine(optionFilenameFile, kFALSE); // Read a line of the option file and set the iterator automatically to the next line
00059 
00060            if(line(0) == '#' || line(0) == '*'||
00061                (line(0) == '/' && line(1) == '/') )
00062            {
00063               //Comment in the text file
00064               ;
00065            }
00066            else if(line.Contains("matching")==kTRUE)
00067            {
00068               sOptionFileName = ((TString)line(11, line.Sizeof()-11 ));
00069               cout<<"************************************************************************"<<endl;
00070               cout<<"Using "<<sOptionFileName<<" as source for the options of Matching step"<<endl;
00071               bFilenameFound = kTRUE;
00072               break;
00073            }
00074          } // while( !optionFilenameFile.eof() )
00075          if( optionFilenameFile.eof() && kFALSE == bFilenameFound )
00076          {
00077             cout<<"************************************************************************"<<endl;
00078             cout<<"Field for Matching step not found in File with option filename => Using "<<sOptionFileName<<endl;
00079          } // if( optionFilenameFile.eof() && kFALSE == bFilenameFound )
00080       } // else of if( optionFilenameFile.fail() == true)
00081 
00082    // Read the option file
00083    fstream setupFile(sOptionFileName, ios::in);
00084    
00085    // Testing if the option does exist. If not I use default values.
00086    if( setupFile.fail() == true)
00087    {
00088       cout<<"Error for TMatching: Setup file "<<sOptionFileName<<" can not be opened or is missing."<<endl;
00089       cout<<"=> Using default values!"<<endl;
00090    }
00091    else
00092    {
00093       TString line;
00094       
00095       // Goes through all lines
00096       while( !setupFile.eof() )
00097       {
00098          line.ReadLine(setupFile, kFALSE); // Read a line of the option file and set the iterator automatically to the next line
00099          if(1 == uDebug)
00100             cout<<line<<endl;
00101 
00102          if(line(0) == '#' || line(0) == '*')
00103          {
00104             //Comment in the text file
00105             ;
00106          }
00107          else if(line.Contains("debug")==kTRUE)
00108          {
00109             uDebug = ((TString)line(5,10)).Atoi();
00110             if(1 == uDebug)
00111                cout<<"Debug ON!!!!!!"<<endl;
00112          }
00113          else if(line.Contains("triggersel")==kTRUE)
00114          {
00115             iTriggerSelection = ((TString)line(11,10)).Atoi();
00116             if(1 == uDebug)
00117             {
00118                if( -1 == iTriggerSelection)
00119                   cout<<"Trigger used for matching selection: OFF"<<endl;
00120                   else cout<<"Trigger used for matching selection: "<<iTriggerSelection<<endl;
00121             } // if(1 == uDebug)
00122          }
00123          else if(line.Contains("trigseldeb")==kTRUE)
00124          {
00125             uTriggerSelDebugHistos = ((TString)line(11,10)).Atoi();
00126             if(1 == uDebug)
00127             {
00128                if( 1 == uTriggerSelDebugHistos)
00129                   cout<<"Trigger selection debug histograms:  ON"<<endl;
00130                   else cout<<"Trigger selection debug histograms:  OFF"<<endl;
00131             } // if(1 == uDebug)
00132          }
00133          else if(line.Contains("nbevaveffy")==kTRUE)
00134          {
00135             uNbEventAverageEfficiency = ((TString)line(11,10)).Atoi();
00136             if(1 == uDebug)
00137             {
00138                cout<<"Nb of event averaging HD efficiency: "<<uNbEventAverageEfficiency<<endl;
00139             }
00140          }
00141          else if(line.Contains("matoffsdet")==kTRUE)
00142          {
00143             uDetectorOffsetToUse = ((TString)line(11,10)).Atoi();
00144             if(1 == uDebug)
00145             {
00146                if( 1 == uDetectorOffsetToUse)
00147                   cout<<"Offset for dt in matching from:      Bucarest Reference counter"<<endl;
00148                   else cout<<"Offset for dt in matching from:      Heidelberg counter"<<endl;
00149             }
00150          }
00151       } // while( !setupFile.eof() )
00152    } //  else of if( setupFile.fail() == true)
00153    
00154    PrintOptions(); //print out all values to see, if the setting has worked correctly
00155    return kTRUE;
00156 }
00157 
00158 
00159 Int_t TMatchingParam::PrintOptions(){
00160    cout<<"********************* MATCHING calibration parameters **********************"<<endl;
00161    if(1 == uDebug)
00162       cout<<"Debug ON!!!!!!"<<endl;
00163       else cout<<"Debug OFF"<<endl;
00164    if( -1 == iTriggerSelection)
00165       cout<<"Trigger used for matching selection: OFF"<<endl;
00166       else cout<<"Trigger used for matching selection: "<<iTriggerSelection<<endl;
00167    if( 1 == uTriggerSelDebugHistos)
00168       cout<<"Trigger selection debug histograms:  ON"<<endl;
00169       else cout<<"Trigger selection debug histograms:  OFF"<<endl;
00170    cout<<"Nb of event averaging HD efficiency: "<<uNbEventAverageEfficiency<<endl;
00171    if( 1 == uDetectorOffsetToUse)
00172       cout<<"Offset for dt in matching from:      Bucarest Reference counter"<<endl;
00173       else cout<<"Offset for dt in matching from:      Heidelberg counter"<<endl;
00174 
00175    cout<<"************************************************************************"<<endl;
00176    
00177    return 0;
00178 }

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