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

beamtime/gsi-aug12/get4v10/go4/MATCHING/TMatchingParam.cxx (r4864/r3846)

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

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