Go to the documentation of this file.00001
00002
00003 #include "TScalersParam.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 REF_CLK_TRIGLOG_SCAL 0
00015 #define REF_CLK_TRIGLOG_CHAN 15
00016 #define REF_CLK_FREQUENCY 781250.0
00017 #define NB_DETECTORS_SCALORMU 0
00018 #define DETECTOR_SCALER 0
00019 #define NB_DIGITS_DETSCALMAP 3
00020
00021 TScalersParam::TScalersParam(const char* name) : TGo4Parameter(name)
00022 {
00023 ReadOptions();
00024 }
00025
00026
00027 TScalersParam::~TScalersParam()
00028 {
00029 }
00030
00031 Bool_t TScalersParam::ReadOptions(){
00032
00033 uDebug = DEBUG_OPTION;
00034 uReferenceClockScaler = REF_CLK_TRIGLOG_SCAL;
00035 uReferenceClockChannel = REF_CLK_TRIGLOG_CHAN;
00036 dReferenceClockFrequency = REF_CLK_FREQUENCY;
00037 dReferenceClockFrequencyTriglog = REF_CLK_FREQUENCY;
00038 dReferenceClockFrequencyScalOrMu = REF_CLK_FREQUENCY;
00039 uNbDetectorsScalormu = NB_DETECTORS_SCALORMU;
00040 for( Int_t iScalormuChan = 0; iScalormuChan < SCALORMU_NB_SCAL; iScalormuChan ++)
00041 uDetectorScaler[iScalormuChan] = DETECTOR_SCALER;
00042
00043
00044 TString sOptionFileName = "./Scalers_options.txt";
00045 Bool_t bFilenameFound = kFALSE;
00046 fstream optionFilenameFile("./Option_files.txt", ios::in);
00047
00048 if( optionFilenameFile.fail() == true)
00049 {
00050 cout<<"************************************************************************"<<endl;
00051 cout<<" File with option filename for Scalers not found: using the default value ";
00052 cout<<sOptionFileName<<endl;
00053 }
00054 else
00055 {
00056 TString line;
00057
00058
00059 while( !optionFilenameFile.eof() )
00060 {
00061 line.ReadLine(optionFilenameFile, kFALSE);
00062
00063 if(line(0) == '#' || line(0) == '*'||
00064 (line(0) == '/' && line(1) == '/') )
00065 {
00066
00067 ;
00068 }
00069 else if(line.Contains("scalers")==kTRUE)
00070 {
00071 sOptionFileName = ((TString)line(11, line.Sizeof()-11 ));
00072 cout<<"************************************************************************"<<endl;
00073 cout<<"Using "<<sOptionFileName<<" as source for the options of Scalers step"<<endl;
00074 bFilenameFound = kTRUE;
00075 break;
00076 }
00077 }
00078 if( optionFilenameFile.eof() && kFALSE == bFilenameFound )
00079 {
00080 cout<<"************************************************************************"<<endl;
00081 cout<<"Field for Scalers step not found in File with option filename => Using "<<sOptionFileName<<endl;
00082 }
00083 }
00084
00085
00086 fstream setupFile(sOptionFileName, ios::in);
00087
00088
00089 if( setupFile.fail() == true)
00090 {
00091 cout<<"Error for TScalers: Setup file "<<sOptionFileName<<" can not be opened or is missing."<<endl;
00092 cout<<"=> Using default values!"<<endl;
00093 }
00094 else
00095 {
00096 TString line;
00097
00098
00099 while( !setupFile.eof() )
00100 {
00101 line.ReadLine(setupFile, kFALSE);
00102 if(1 == uDebug)
00103 cout<<line<<endl;
00104 if(line(0) == '#' || line(0) == '*'
00105 || (line(0) == '/'&& line(1) == '/' ))
00106 {
00107
00108 ;
00109 }
00110 else if(line.Contains("debug")==kTRUE)
00111 {
00112 uDebug = ((TString)line(5,10)).Atoi();
00113 if(1 == uDebug)
00114 cout<<"Debug ON!!!!!!"<<endl;
00115 }
00116 else if(line.Contains("refclkscal")==kTRUE)
00117 {
00118 uReferenceClockScaler = ((TString)line(12,10)).Atoi();
00119 if(1 == uDebug)
00120 cout<<"Triglog scaler for Reference clock: "<<uReferenceClockScaler<<endl;
00121 }
00122 else if(line.Contains("refclkchan")==kTRUE)
00123 {
00124 uReferenceClockChannel = ((TString)line(12,10)).Atoi();
00125 if(1 == uDebug)
00126 cout<<"Triglog channel for Reference clock: "<<uReferenceClockChannel<<endl;
00127 }
00128 else if(line.Contains("refclkfreq")==kTRUE)
00129 {
00130 dReferenceClockFrequency = ((TString)line(12,10)).Atoi();
00131 if(1 == uDebug)
00132 cout<<"Reference clock Frequency: "<<dReferenceClockFrequency<<" Hz"<<endl;
00133 }
00134 else if(line.Contains("refclktrlo")==kTRUE)
00135 {
00136 dReferenceClockFrequencyTriglog = ((TString)line(12,10)).Atoi();
00137 if(1 == uDebug)
00138 cout<<"Reference clock Frequency Triglog: "<<dReferenceClockFrequencyTriglog<<" Hz"<<endl;
00139 }
00140 else if(line.Contains("refclkscom")==kTRUE)
00141 {
00142 dReferenceClockFrequencyScalOrMu = ((TString)line(12,10)).Atoi();
00143 if(1 == uDebug)
00144 cout<<"Reference clock Frequency ScalOrMu: "<<dReferenceClockFrequencyScalOrMu<<" Hz"<<endl;
00145 }
00146 else if(line.Contains("nbdetsumra")==kTRUE)
00147 {
00148 uNbDetectorsScalormu = ((TString)line(12,10)).Atoi();
00149 if(1 == uDebug)
00150 cout<<"Nb of detectors with full rate calc: "<<uNbDetectorsScalormu<<endl;
00151 if( SCALORMU_NB_SCAL < uNbDetectorsScalormu )
00152 {
00153 cout<<"Nb of detectors with full rate calc too high, set to max = nb scalormu channels"<<endl;
00154 uNbDetectorsScalormu = SCALORMU_NB_SCAL;
00155 }
00156 }
00157 else if(line.Contains("scaldetmap")==kTRUE)
00158 {
00159 line = line(12, NB_DIGITS_DETSCALMAP *SCALORMU_NB_SCAL);
00160 if( uNbDetectorsScalormu == 0 && line.Sizeof() )
00161 {
00162 if( 1 == uDebug )
00163 {
00164 cout<<"Warning: uNbDetectorsScalormu is 0 and detector to scaler array not empty: skip filling"<<line<<endl;
00165 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00166 }
00167 }
00168 else
00169 {
00170 for(UInt_t temp_index = 0; temp_index < SCALORMU_NB_SCAL; temp_index++)
00171 {
00172 uDetectorScaler[temp_index] = ((TString)line(0,NB_DIGITS_DETSCALMAP)).Atoi();
00173 line = line(NB_DIGITS_DETSCALMAP, NB_DIGITS_DETSCALMAP*SCALORMU_NB_SCAL);
00174 }
00175 }
00176 }
00177 }
00178 }
00179
00180 PrintOptions();
00181 return kTRUE;
00182 }
00183
00184
00185 Int_t TScalersParam::PrintOptions(){
00186 cout<<"********************* SCALERS calibration parameters **********************"<<endl;
00187 if(1 == uDebug)
00188 cout<<"Debug ON!!!!!!"<<endl;
00189 else cout<<"Debug OFF"<<endl;
00190 cout<<"Triglog scaler for Reference clock: "<<uReferenceClockScaler<<endl;
00191 cout<<"Triglog channel for Reference clock: "<<uReferenceClockChannel<<endl;
00192 cout<<"Reference clock Frequency: "<<dReferenceClockFrequency<<" Hz"<<endl;
00193 cout<<"Reference clock Frequency Triglog: "<<dReferenceClockFrequencyTriglog<<" Hz"<<endl;
00194 cout<<"Reference clock Frequency ScalOrMu: "<<dReferenceClockFrequencyScalOrMu<<" Hz"<<endl;
00195 cout<<"Nb of detectors with full rate calc: "<<uNbDetectorsScalormu<<endl;
00196 cout<<"ScalOrMu channel:|- ";
00197 for(UInt_t temp_index = 0; temp_index < SCALORMU_NB_SCAL; temp_index++)
00198 {
00199 cout.width(NB_DIGITS_DETSCALMAP - 1);
00200 cout<<temp_index<<" ";
00201 }
00202 cout<<endl<<"Detector |-> ";
00203 for(UInt_t temp_index = 0; temp_index < SCALORMU_NB_SCAL; temp_index++)
00204 {
00205 cout.width(NB_DIGITS_DETSCALMAP - 1);
00206 cout<<uDetectorScaler[temp_index]<<" ";
00207 }
00208 cout<<endl;
00209
00210 cout<<"************************************************************************"<<endl;
00211
00212 return 0;
00213 }