Go to the documentation of this file.00001
00002
00003 #include "TMbsCrateParam.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 CAEN_DEBUG kFALSE
00015 #define CAEN_TRIGGER_HISTO kFALSE
00016 #define CAEN_COINC_MAP 0
00017 #define CAEN_TDC_ENABLE 1
00018 #define CAEN_QDC_ENABLE 1
00019 #define LECROY_QDC_ENABLE 1
00020 #define VFTX_TDC_ENABLE 1
00021 #define QFW_ENABLE 1
00022
00023 TMbsCrateParam::TMbsCrateParam(const char* name) : TGo4Parameter(name)
00024 {
00025 ReadOptions();
00026 }
00027
00028
00029 TMbsCrateParam::~TMbsCrateParam()
00030 {
00031 }
00032
00033 Bool_t TMbsCrateParam::ReadOptions(){
00034
00035 uDebug = DEBUG_OPTION;
00036
00037 bCaenDebug = CAEN_DEBUG;
00038 bCaenTriggerTime = CAEN_TRIGGER_HISTO;
00039 uCaenCoincidenceMap = CAEN_COINC_MAP;
00040 for( Int_t iIndex1290 = 0; iIndex1290 < MAX_1290; iIndex1290++)
00041 uCaenTdcHistosEnabled[iIndex1290] = CAEN_TDC_ENABLE;
00042
00043 for( Int_t iIndex965 = 0; iIndex965 < MAX_965; iIndex965++)
00044 uCaenQdcHistosEnabled[iIndex965] = CAEN_QDC_ENABLE;
00045
00046 for( Int_t iIndex1182 = 0; iIndex1182 < MAX_1182; iIndex1182++)
00047 uLecroyQdcHistosEnabled[iIndex1182] = LECROY_QDC_ENABLE;
00048
00049 for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00050 uVftxHistosEnabled[iIndexVftx] = VFTX_TDC_ENABLE;
00051
00052 uQFWHistosEnabled = QFW_ENABLE;
00053
00054
00055 TString sOptionFileName = "./mbsUnpack_options.txt";
00056 Bool_t bFilenameFound = kFALSE;
00057 fstream optionFilenameFile("./Option_files.txt", ios::in);
00058
00059 if( optionFilenameFile.fail() == true)
00060 {
00061 cout<<"************************************************************************"<<endl;
00062 cout<<" File with option filename for MbsUnpacker not found: using the default value ";
00063 cout<<sOptionFileName<<endl;
00064 }
00065 else
00066 {
00067 TString line;
00068
00069
00070 while( !optionFilenameFile.eof() )
00071 {
00072 line.ReadLine(optionFilenameFile, kFALSE);
00073
00074 if(line(0) == '#' || line(0) == '*'||
00075 (line(0) == '/' && line(1) == '/') )
00076 {
00077
00078 ;
00079 }
00080 else if(line.Contains("mbsunpack")==kTRUE)
00081 {
00082 sOptionFileName = ((TString)line(11, line.Sizeof()-11 ));
00083 cout<<"************************************************************************"<<endl;
00084 cout<<"Using "<<sOptionFileName<<" as source for the options of MbsUnpack step"<<endl;
00085 bFilenameFound = kTRUE;
00086 break;
00087 }
00088 }
00089 if( optionFilenameFile.eof() && kFALSE == bFilenameFound )
00090 {
00091 cout<<"************************************************************************"<<endl;
00092 cout<<"Field for MbsUnpack step not found in File with option filename => Using "<<sOptionFileName<<endl;
00093 }
00094 }
00095
00096
00097 fstream setupFile(sOptionFileName, ios::in);
00098
00099
00100 if( setupFile.fail() == true)
00101 {
00102 cout<<"Error for TMbsCrateParam: Setup file "<<sOptionFileName<<" can not be opened or is missing."<<endl;
00103 cout<<"=> Using default values!"<<endl;
00104 }
00105 else
00106 {
00107 TString line;
00108
00109
00110 while( !setupFile.eof() )
00111 {
00112 line.ReadLine(setupFile, kFALSE);
00113 if(1 == uDebug)
00114 cout<<line<<endl;
00115
00116 if(line(0) == '#' || line(0) == '*')
00117 {
00118
00119 ;
00120 }
00121 else if(line.Contains("unpackdebug")==kTRUE)
00122 {
00123 uDebug = ((TString)line(13,10)).Atoi();
00124 if(1 == uDebug)
00125 cout<<"Debug ON!!!!!!"<<endl;
00126 }
00127 else if(line.Contains("caentdcdebug")==kTRUE)
00128 {
00129 bCaenDebug = ( 1 == ((TString)line(13,10)).Atoi() ) ;
00130 }
00131 else if(line.Contains("caentrigtime")==kTRUE)
00132 {
00133 bCaenTriggerTime = ( 1 == ((TString)line(13,10)).Atoi() );
00134 }
00135 else if(line.Contains("caencoincmap")==kTRUE)
00136 {
00137 uCaenCoincidenceMap = ((TString)line(13,10)).Atoi() ;
00138 }
00139 else if(line.Contains("caentdcena")==kTRUE)
00140 {
00141 line = line(11,3*MAX_1290);
00142 if( 0 != line.Sizeof() )
00143 {
00144 for(UInt_t temp_index = 0; temp_index < MAX_1290 && 0 != line.Sizeof(); temp_index++)
00145 {
00146 uCaenTdcHistosEnabled[temp_index] = ((TString)line(0,3)).Atoi();
00147 line = line(3,3*MAX_1290);
00148 }
00149 }
00150 }
00151 else if(line.Contains("caenqdcena")==kTRUE)
00152 {
00153 line = line(11,3*MAX_965);
00154 if( 0 != line.Sizeof() )
00155 {
00156 for(UInt_t temp_index = 0; temp_index < MAX_965 && 0 != line.Sizeof(); temp_index++)
00157 {
00158 uCaenQdcHistosEnabled[temp_index] = ((TString)line(0,3)).Atoi();
00159 line = line(3,3*MAX_965);
00160 }
00161 }
00162 }
00163 else if(line.Contains("qdc1182ena")==kTRUE)
00164 {
00165 line = line(11,3*MAX_1182);
00166 if( 0 != line.Sizeof() )
00167 {
00168 for(UInt_t temp_index = 0; temp_index < MAX_1182 && 0 != line.Sizeof(); temp_index++)
00169 {
00170 uLecroyQdcHistosEnabled[temp_index] = ((TString)line(0,3)).Atoi();
00171 line = line(3,3*MAX_1182);
00172 }
00173 }
00174 }
00175 else if(line.Contains("vftxrawena")==kTRUE)
00176 {
00177 line = line(11,3*MAX_FPGA_TDC);
00178 if( 0 != line.Sizeof() )
00179 {
00180 for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00181 {
00182 uVftxHistosEnabled[temp_index] = ((TString)line(0,3)).Atoi();
00183 line = line(3,3*MAX_FPGA_TDC);
00184 }
00185 }
00186 }
00187 else if(line.Contains("qfwhistena")==kTRUE)
00188 {
00189 uQFWHistosEnabled = ((TString)line(11,10)).Atoi();
00190 }
00191 }
00192 }
00193
00194 this->PrintOptions();
00195 return kTRUE;
00196 }
00197
00198
00199 Int_t TMbsCrateParam::PrintOptions(){
00200 cout<<"******************** MBS crate unpacker parameters *********************"<<endl;
00201 if(1 == uDebug)
00202 cout<<"Debug ON!!!!!!"<<endl;
00203 else cout<<"Debug OFF"<<endl;
00204
00205
00206 cout<<"------------------------------------------------------------------------"<<endl;
00207 cout<<"CAEN v1290 debug Histograms: "<<bCaenDebug<<endl;
00208 cout<<"CAEN v1290 trigger time Histograms: "<<bCaenTriggerTime<<endl;
00209 cout<<"Caen v1290 tdc index: |- ";
00210 for( Int_t iIndex1290 = 0; iIndex1290 < MAX_1290; iIndex1290++)
00211 {
00212 cout.width(2);
00213 cout<<iIndex1290<<" ";
00214 }
00215 cout<<endl<<"Unpacking histo. enabled |-> ";
00216 for( Int_t iIndex1290 = 0; iIndex1290 < MAX_1290; iIndex1290++)
00217 {
00218 cout.width(2);
00219 cout<<uCaenTdcHistosEnabled[iIndex1290]<<" ";
00220 }
00221 cout<<endl;
00222
00223
00224 cout<<"------------------------------------------------------------------------"<<endl;
00225 cout<<"Caen v965 qdc index: |- ";
00226 for( Int_t iIndex965 = 0; iIndex965 < MAX_965; iIndex965++)
00227 {
00228 cout.width(2);
00229 cout<<iIndex965<<" ";
00230 }
00231 cout<<endl<<"Unpacking histo. enabled |-> ";
00232 for( Int_t iIndex965 = 0; iIndex965 < MAX_965; iIndex965++)
00233 {
00234 cout.width(2);
00235 cout<<uCaenQdcHistosEnabled[iIndex965]<<" ";
00236 }
00237 cout<<endl;
00238
00239
00240 cout<<"------------------------------------------------------------------------"<<endl;
00241 cout<<"Lecroy 1182 qdc index: |- ";
00242 for( Int_t iIndex1182 = 0; iIndex1182 < MAX_1182; iIndex1182++)
00243 {
00244 cout.width(2);
00245 cout<<iIndex1182<<" ";
00246 }
00247 cout<<endl<<"Unpacking histo. enabled |-> ";
00248 for( Int_t iIndex1182 = 0; iIndex1182 < MAX_1182; iIndex1182++)
00249 {
00250 cout.width(2);
00251 cout<<uLecroyQdcHistosEnabled[iIndex1182] <<" ";
00252 }
00253 cout<<endl;
00254
00255
00256 cout<<"------------------------------------------------------------------------"<<endl;
00257 cout<<"VFTX FPGA TDC index: |- ";
00258 for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00259 {
00260 cout.width(2);
00261 cout<<iIndexVftx<<" ";
00262 }
00263 cout<<endl<<"Unpacking histo. enabled |-> ";
00264 for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00265 {
00266 cout.width(2);
00267 cout<<uVftxHistosEnabled[iIndexVftx] <<" ";
00268 }
00269 cout<<endl;
00270
00271
00272 cout<<"------------------------------------------------------------------------"<<endl;
00273 if( 1 == uQFWHistosEnabled )
00274 cout<<"QFW histograms: ON"<<endl;
00275 else cout<<"QFW histograms: OFF"<<endl;
00276 cout<<"************************************************************************"<<endl;
00277 return 0;
00278 }