Go to the documentation of this file.00001
00002
00003 #include "TVftxParam.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 CALIB_HISTOS_ENABLE 0
00015 #define REFERENCE_CHANNEL -1
00016 #define DIAMOND_CHANNEL -1
00017 #define COINCIDENCE_MAPPING 0
00018 #define BIT_CONTROL 0
00019 #define FINE_TIME_HISTO_ENABLE 0
00020 #define COARSE_TIME_HIST_ENABLE 0
00021 #define CALIBRATION_ENABLE 0
00022 #define MIN_NB_HITS_CALIB 5000
00023 #define INITIAL_CAL_FILENAME ""
00024 #define CALIBRATION_OUT_ENABLE 0
00025 #define TIME_HISTO_ENABLE 0
00026 #define TOT_HISTO_ENABLE 0
00027 #define AUTO_TDC_OFFSET_DET 0
00028
00029 TVftxParam::TVftxParam(const char* name) : TGo4Parameter(name)
00030 {
00031 ReadOptions();
00032 }
00033
00034
00035 TVftxParam::~TVftxParam()
00036 {
00037 }
00038
00039 Bool_t TVftxParam::ReadOptions(){
00040
00041 uDebug = DEBUG_OPTION;
00042 for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00043 {
00044 uVftxCalHistosEnabled[iIndexVftx] = CALIB_HISTOS_ENABLE;
00045 iVftxReferenceChannel[iIndexVftx] = REFERENCE_CHANNEL;
00046 iVftxDiamondChannel[iIndexVftx] = DIAMOND_CHANNEL;
00047 }
00048 uVftxCoincidenceMap = COINCIDENCE_MAPPING;
00049 uBitControl = BIT_CONTROL;
00050 uFineHistEnable = FINE_TIME_HISTO_ENABLE;
00051 uCoarseTimeHisto = COARSE_TIME_HIST_ENABLE;
00052 uEnableCalib = CALIBRATION_ENABLE;
00053 iMinNbHitsCalib = MIN_NB_HITS_CALIB;
00054 sInitialCalibrationFilename = INITIAL_CAL_FILENAME;
00055 for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00056 uVftxInitalCalIndex[iIndexVftx] = iIndexVftx;
00057 uEnableCalibOutput = CALIBRATION_OUT_ENABLE;
00058 uTimeHistEnable = TIME_HISTO_ENABLE;
00059 uTotHistoEnable = TOT_HISTO_ENABLE;
00060
00061 uAutomaticOffsetEnable = AUTO_TDC_OFFSET_DET;
00062 for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00063 iAutomaticTdcOffset[iIndexVftx] = 0;
00064
00065
00066 TString sOptionFileName = "./Vftx_options.txt";
00067 Bool_t bFilenameFound = kFALSE;
00068 fstream optionFilenameFile("./Option_files.txt", ios::in);
00069
00070 if( optionFilenameFile.fail() == true)
00071 {
00072 cout<<"************************************************************************"<<endl;
00073 cout<<" File with option filename for VFTX not found: using the default value ";
00074 cout<<sOptionFileName<<endl;
00075 }
00076 else
00077 {
00078 TString line;
00079
00080
00081 while( !optionFilenameFile.eof() )
00082 {
00083 line.ReadLine(optionFilenameFile, kFALSE);
00084
00085 if(line(0) == '#' || line(0) == '*'||
00086 (line(0) == '/' && line(1) == '/') )
00087 {
00088
00089 ;
00090 }
00091 else if(line.Contains("vftxcalib")==kTRUE)
00092 {
00093 sOptionFileName = ((TString)line(11, line.Sizeof()-11 ));
00094 cout<<"************************************************************************"<<endl;
00095 cout<<"Using "<<sOptionFileName<<" as source for the options of Vftx step"<<endl;
00096 bFilenameFound = kTRUE;
00097 break;
00098 }
00099 }
00100 if( optionFilenameFile.eof() && kFALSE == bFilenameFound )
00101 {
00102 cout<<"************************************************************************"<<endl;
00103 cout<<"Field for Vftx step not found in File with option filename => Using "<<sOptionFileName<<endl;
00104 }
00105 }
00106
00107
00108 fstream setupFile(sOptionFileName, ios::in);
00109
00110
00111 if( setupFile.fail() == true)
00112 {
00113 cout<<"Error for TVftxParam: Setup file "<<sOptionFileName<<" can not be opened or is missing."<<endl;
00114 cout<<"=> Using default values!"<<endl;
00115 }
00116 else
00117 {
00118 TString line;
00119
00120
00121 while( !setupFile.eof() )
00122 {
00123 line.ReadLine(setupFile, kFALSE);
00124 if(1 == uDebug)
00125 cout<<line<<endl;
00126
00127 if(line(0) == '#' || line(0) == '*')
00128 {
00129
00130 ;
00131 }
00132 else if(line.Contains("debug")==kTRUE)
00133 {
00134 uDebug = ((TString)line(5,10)).Atoi();
00135 if(1 == uDebug)
00136 cout<<"Debug ON!!!!!!"<<endl;
00137 }
00138 else if(line.Contains("vftxcalena")==kTRUE)
00139 {
00140 line = line(11,3*MAX_FPGA_TDC);
00141 if( 0 != line.Sizeof() )
00142 {
00143 for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00144 {
00145 uVftxCalHistosEnabled[temp_index] = ((TString)line(0,3)).Atoi();
00146 line = line(3,3*MAX_FPGA_TDC);
00147 }
00148 }
00149 }
00150 else if(line.Contains("referencec")==kTRUE)
00151 {
00152 line = line(11,3*MAX_FPGA_TDC);
00153 if( 0 != line.Sizeof() )
00154 {
00155 for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00156 {
00157 iVftxReferenceChannel[temp_index] = ((TString)line(0,3)).Atoi();
00158 line = line(3,3*MAX_FPGA_TDC);
00159 }
00160 }
00161 }
00162 else if(line.Contains("diamondcha")==kTRUE)
00163 {
00164 line = line(11,3*MAX_FPGA_TDC);
00165 if( 0 != line.Sizeof() )
00166 {
00167 for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00168 {
00169 iVftxDiamondChannel[temp_index] = ((TString)line(0,3)).Atoi();
00170 line = line(3,3*MAX_FPGA_TDC);
00171 }
00172 }
00173 }
00174 else if(line.Contains("chcoimap")==kTRUE)
00175 {
00176 uVftxCoincidenceMap = ((TString)line(8,10)).Atoi();
00177 if(1 == uDebug)
00178 cout<<"Test uVftxCoincidenceMap: "<<uVftxCoincidenceMap<<endl;
00179 }
00180 else if(line.Contains("bitcontrol")==kTRUE)
00181 {
00182 uBitControl = ((TString)line(10,10)).Atoi();
00183 if(1 == uDebug)
00184 cout<<"Test uBitControl: "<<uBitControl<<endl;
00185 }
00186 else if(line.Contains("coarsetimehisto")==kTRUE)
00187 {
00188 uCoarseTimeHisto = ((TString)line(15,10)).Atoi();
00189 if(1 == uDebug)
00190 cout<<"Test uCoarseTimeHisto: "<<uCoarseTimeHisto<<endl;
00191 }
00192 else if(line.Contains("finetime")==kTRUE)
00193 {
00194 uFineHistEnable = ((TString)line(8,10)).Atoi();
00195 if(1 == uDebug)
00196 cout<<"Test uFineHistEnable: "<<uFineHistEnable<<endl;
00197 }
00198 else if(line.Contains("finetevo")==kTRUE)
00199 {
00200 uFineEvolutionHistEnable = ((TString)line(8,10)).Atoi();
00201 if(1 == uDebug)
00202 cout<<"Test uFineEvolutionHistEnable: "<<uFineEvolutionHistEnable<<endl;
00203 }
00204 else if(line.Contains("calibena")==kTRUE)
00205 {
00206 uEnableCalib = ((TString)line(9,10)).Atoi();
00207 if(1 == uDebug)
00208 cout<<"Test uEnableCalib: "<<uEnableCalib<<endl;
00209 }
00210 else if(line.Contains("calibnb")==kTRUE)
00211 {
00212 iMinNbHitsCalib = ((TString)line(8,10)).Atoi();
00213 if(1 == uDebug)
00214 cout<<"Test iMinNbHitsCalib: "<<iMinNbHitsCalib<<endl;
00215 }
00216 else if(line.Contains("initialcalibfile")==kTRUE)
00217 {
00218 sInitialCalibrationFilename = (TString)line(17,128);
00219 if(1 == uDebug)
00220 cout<<"Test sInitialCalibrationFilename: "<<sInitialCalibrationFilename<<endl;
00221 }
00222 else if(line.Contains("inicalindex")==kTRUE)
00223 {
00224 line = line(12,3*MAX_FPGA_TDC);
00225 if( 0 != line.Sizeof() )
00226 {
00227 for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00228 {
00229 uVftxInitalCalIndex[temp_index] = ((TString)line(0,3)).Atoi();
00230 line = line(3,3*MAX_FPGA_TDC);
00231 }
00232 }
00233 }
00234 else if(line.Contains("caliboutena")==kTRUE)
00235 {
00236 uEnableCalibOutput = ((TString)line(12,10)).Atoi();
00237 if(1 == uDebug)
00238 cout<<"Test uEnableCalibOutput: "<<uEnableCalibOutput<<endl;
00239 }
00240 else if(line.Contains("timeplot")==kTRUE)
00241 {
00242 uTimeHistEnable = ((TString)line(8,10)).Atoi();
00243 if(1 == uDebug)
00244 cout<<"Test uTimeHistEnable: "<<uTimeHistEnable<<endl;
00245 }
00246 else if(line.Contains("totplot")==kTRUE)
00247 {
00248 uTotHistoEnable = ((TString)line(8,10)).Atoi();
00249 if(1 == uDebug)
00250 cout<<"Test uTotHistoEnable: "<<uTotHistoEnable<<endl;
00251 }
00252 else if(line.Contains("autooffs")==kTRUE)
00253 {
00254 uAutomaticOffsetEnable = ((TString)line(8,10)).Atoi();
00255 if(1 == uDebug)
00256 cout<<"Test uAutomaticOffsetEnable: "<<uAutomaticOffsetEnable<<endl;
00257 }
00258 }
00259 }
00260 if( uEnableCalib )
00261 {
00262 cout<<" Fine time Histos needed for corrections => Enable!!"<<endl;
00263 uFineHistEnable = 1;
00264
00265 if( -1 == iMinNbHitsCalib &&
00266 ( kTRUE == sInitialCalibrationFilename.EqualTo("") ||
00267 kTRUE == sInitialCalibrationFilename.EqualTo("-") ) )
00268 {
00269 cout<<" Nb of hits per channel needed for corrections disabled while calibration file disabled ";
00270 cout<<"=> Enable iMinNbHitsCalib and set it to 400!!"<<endl;
00271 iMinNbHitsCalib = 400;
00272 }
00273 }
00274
00275 this->PrintOptions();
00276 return kTRUE;
00277 }
00278
00279
00280 Int_t TVftxParam::PrintOptions(){
00281 cout<<"********************* VFTX calibration parameters **********************"<<endl;
00282 if(1 == uDebug)
00283 cout<<"Debug ON!!!!!!"<<endl;
00284 else cout<<"Debug OFF"<<endl;
00285 cout<<"VFTX FPGA TDC index: |- ";
00286 for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00287 {
00288 cout.width(2);
00289 cout<<iIndexVftx<<" ";
00290 }
00291 cout<<endl<<"Calibration histo. enabled |-> ";
00292 for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00293 {
00294 cout.width(2);
00295 cout<<uVftxCalHistosEnabled[iIndexVftx] <<" ";
00296 }
00297 cout<<endl;
00298 cout<<"Channel coincidence mapping : "<<uVftxCoincidenceMap<<endl;
00299 cout<<"Control bit Histograms : "<<uBitControl<<endl;
00300 cout<<"Fine Time Histograms : "<<uFineHistEnable<<endl;
00301 cout<<"Fine Time Evolution Histograms: "<<uFineEvolutionHistEnable<<endl;
00302 cout<<"Coarse time Histograms : "<<uCoarseTimeHisto<<endl;
00303 if(1 == uEnableCalib)
00304 cout<<"Calibration : ON"<<endl;
00305 else cout<<"Calibration : OFF"<<endl;
00306 if( -1 == iMinNbHitsCalib &&
00307 kTRUE != sInitialCalibrationFilename.EqualTo("") && kTRUE != sInitialCalibrationFilename.EqualTo("-") )
00308 {
00309 cout<<"Filename for calib hist: "<<sInitialCalibrationFilename<<endl;
00310 cout<<"VFTX FPGA TDC index: |- ";
00311 for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00312 {
00313 cout.width(2);
00314 cout<<iIndexVftx<<" ";
00315 }
00316 cout<<endl<<"Tdc initial calib. index: |-> ";
00317 for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00318 {
00319 cout.width(2);
00320 cout<<uVftxInitalCalIndex[iIndexVftx] <<" ";
00321 }
00322 cout<<endl;
00323 }
00324 else
00325 {
00326 cout<<"Min nb hits for calib : "<<iMinNbHitsCalib<<endl;
00327 if( kTRUE != sInitialCalibrationFilename.EqualTo("") && kTRUE != sInitialCalibrationFilename.EqualTo("-") )
00328 {
00329 cout<<"Filename for intial calib hist: "<<sInitialCalibrationFilename<<endl;
00330 cout<<"VFTX FPGA TDC index: |- ";
00331 for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00332 {
00333 cout.width(2);
00334 cout<<iIndexVftx<<" ";
00335 }
00336 cout<<endl<<"Tdc initial calib. index: |-> ";
00337 for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00338 {
00339 cout.width(2);
00340 cout<<uVftxInitalCalIndex[iIndexVftx] <<" ";
00341 }
00342 cout<<endl;
00343 }
00344 }
00345 if(1 == uEnableCalibOutput)
00346 cout<<"Calibration saved in root file: ON"<<endl;
00347 else cout<<"Calibration saved in root file: OFF"<<endl;
00348 cout<<"Time Histograms : "<<uTimeHistEnable<<endl;
00349 cout<<"Tot Histograms : "<<uTotHistoEnable<<endl;
00350 if(1 == uAutomaticOffsetEnable)
00351 cout<<"Automatic tdc offset detection: ON"<<endl;
00352 else cout<<"Automatic tdc offset detection: OFF"<<endl;
00353 cout<<"************************************************************************"<<endl;
00354
00355 return 0;
00356 }