Go to the documentation of this file.00001
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
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
00031 uDebug = DEBUG_OPTION;
00032 iTriggerSelection = TRIGGER_SELECTION;
00033 uTriggerSelDebugHistos = TRIGGER_SEL_DEBUG_HIST;
00034 uNbEventAverageEfficiency = NB_EV_AVERAGE_EFFICIENCY;
00035 uDetectorOffsetToUse = DETECTOR_OFFSET_TO_USE;
00036
00037
00038 TString sOptionFileName = "./Matching_options.txt";
00039 Bool_t bFilenameFound = kFALSE;
00040 fstream optionFilenameFile("./Option_files.txt", ios::in);
00041
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 }
00048 else
00049 {
00050 TString line;
00051
00052
00053 while( !optionFilenameFile.eof() )
00054 {
00055 line.ReadLine(optionFilenameFile, kFALSE);
00056
00057 if(line(0) == '#' || line(0) == '*'||
00058 (line(0) == '/' && line(1) == '/') )
00059 {
00060
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 }
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 }
00077 }
00078
00079
00080 fstream setupFile(sOptionFileName, ios::in);
00081
00082
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
00093 while( !setupFile.eof() )
00094 {
00095 line.ReadLine(setupFile, kFALSE);
00096 if(1 == uDebug)
00097 cout<<line<<endl;
00098
00099 if(line(0) == '#' || line(0) == '*')
00100 {
00101
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 }
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 }
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 }
00149 }
00150
00151 PrintOptions();
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 }