Go to the documentation of this file.00001
00002
00003 #include "TRootConverterParam.h"
00004 #include "TGo4Version.h"
00005 #if __GO4BUILDVERSION__ > 40502
00006 #include "go4iostream.h"
00007 #else
00008 #include "Riostream.h"
00009 #endif
00010
00011
00012 #define OUTPUT_FILE_ENABLE 0
00013 #define OUTPUT_FILENAME "testTree.root"
00014 #define ROOT_TREE_DISPLAY 0
00015 #define EVNT_BEF_RESET 5000
00016 #define GET4_DATA_IN_TREE 0
00017 #define TDC_REFERENCE -1
00018 #define CHANNEL_TDC_REFERENCE -1
00019 #define CAEN_TDC_MODE 1
00020 #define CAEN_TDC_MUTLTI 0
00021 #define CAEN_TDC_GENERAL_ENA 0
00022 #define PMT_TDC -1
00023 #define PMT_QDC -1
00024 #define RPC_TDC_LEADING -1
00025 #define RPC_TDC_LEADING -1
00026 #define TRIGLOG_DATA_IN_TREE 0
00027 #define HODOSCOPE_DATA_IN_TREE 0
00028 #define HODOSCOPE_DEBUG_HISTO 0
00029 #define VFTX_DATA_IN_TREE 0
00030 #define VFTX_FULL_DATA_MODE 0
00031 #define SCALORMU_IN_TREE 0
00032 #define VFTX_ENABLE 0
00033 #define SLOW_CONTROL_IN_TREE 0
00034 #define NB_SLOW_CONTROL_CH 0
00035
00036
00037
00038 TRootConverterParam::TRootConverterParam() : TGo4Parameter()
00039 {
00040 uRootDisplay = 0;
00041 uCleanOuputEnable = 0;
00042 uEventsUntilReset = 0;
00043 sOutputFilename = "";
00044 uAddGet4DataInTree = 0;
00045 iReferenceTdc = -1;
00046 iReferenceChannel1 = -1;
00047 iReferenceChannel2 = -1;
00048 uCaenMode = 0;
00049 uCaenMulti = 0;
00050 iPmtTdc = -1;
00051 iPmtQdc = -1;
00052 iRpcTdcLeading = -1;
00053 iRpcTdcTrailing = -1;
00054 uTriglogInputInTree = 0;
00055 uHodoInputInTree = 0;
00056 uHodoDebugHisto = 0;
00057 uVftxInTree = 0;
00058 uVftxFullDataMode = 0;
00059 uScalOrMuInTree = 0;
00060 uSlowControlInTree = 0;
00061 uNbSlowControlChan = 0;
00062 }
00063
00064
00065
00066 TRootConverterParam::TRootConverterParam(const char* name) : TGo4Parameter(name)
00067 {
00068 uRootDisplay = 0;
00069 uCleanOuputEnable = 0;
00070 uEventsUntilReset = 0;
00071 sOutputFilename = "";
00072 uAddGet4DataInTree = 0;
00073 iReferenceTdc = -1;
00074 iReferenceChannel1 = -1;
00075 iReferenceChannel2 = -1;
00076 uCaenMode = 0;
00077 uCaenMulti = 0;
00078 iPmtTdc = -1;
00079 iPmtQdc = -1;
00080 iRpcTdcLeading = -1;
00081 iRpcTdcTrailing = -1;
00082 uTriglogInputInTree = 0;
00083 uHodoInputInTree = 0;
00084 uHodoDebugHisto = 0;
00085 uVftxInTree = 0;
00086 uVftxFullDataMode = 0;
00087 uScalOrMuInTree = 0;
00088 uSlowControlInTree = 0;
00089 uNbSlowControlChan = 0;
00090
00091 ReadOptions();
00092 this->PrintOptions();
00093 }
00094
00095
00096 TRootConverterParam::~TRootConverterParam()
00097 {
00098 }
00099
00100 Bool_t TRootConverterParam::UpdateFrom(TGo4Parameter *pp)
00101 {
00102 if(pp->InheritsFrom("TRootConverterParam")) {
00103 TRootConverterParam * from = (TRootConverterParam *) pp;
00104 cout << "**** TRootConverterParam " << GetName() << " updated from source parameter" << endl;
00105 } else
00106 cout << "Wrong parameter object: " << pp->ClassName() << endl;
00107 return kTRUE;
00108 }
00109
00110 Bool_t TRootConverterParam::ReadOptions()
00111 {
00112 uRootDisplay = ROOT_TREE_DISPLAY;
00113 uCleanOuputEnable = OUTPUT_FILE_ENABLE;
00114 uEventsUntilReset = EVNT_BEF_RESET;
00115 sOutputFilename = OUTPUT_FILENAME;
00116 uAddGet4DataInTree = GET4_DATA_IN_TREE;
00117 iReferenceTdc = TDC_REFERENCE;
00118 iReferenceChannel1 = CHANNEL_TDC_REFERENCE;
00119 iReferenceChannel2 = CHANNEL_TDC_REFERENCE;
00120 uCaenMode = CAEN_TDC_MODE;
00121 uCaenMulti = CAEN_TDC_MUTLTI;
00122 for(UInt_t temp_index = 0; temp_index < MAX_HV_CHAN_SC; temp_index++)
00123 uGeneralCaenTdcEnabled[temp_index] = CAEN_TDC_GENERAL_ENA;
00124 iPmtTdc = PMT_TDC;
00125 iPmtQdc = PMT_QDC;
00126 iRpcTdcLeading = RPC_TDC_LEADING;
00127 iRpcTdcTrailing = RPC_TDC_LEADING;
00128 uTriglogInputInTree = TRIGLOG_DATA_IN_TREE;
00129 uHodoInputInTree = HODOSCOPE_DATA_IN_TREE;
00130 uHodoDebugHisto = HODOSCOPE_DEBUG_HISTO;
00131 uVftxInTree = VFTX_DATA_IN_TREE;
00132 uVftxFullDataMode = VFTX_FULL_DATA_MODE;
00133 uScalOrMuInTree = SCALORMU_IN_TREE;
00134 for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC; temp_index++)
00135 uVftxEnabled[temp_index] = VFTX_ENABLE;
00136 uSlowControlInTree = SLOW_CONTROL_IN_TREE;
00137 uNbSlowControlChan = NB_SLOW_CONTROL_CH;
00138 for(UInt_t temp_index = 0; temp_index < MAX_HV_CHAN_SC; temp_index++)
00139 {
00140 sScInputNamePosI[temp_index] = "";
00141 sScOutputNamePosI[temp_index]= "";
00142 sScInputNamePosU[temp_index] = "";
00143 sScOutputNamePosU[temp_index]= "";
00144 sScInputNameNegI[temp_index] = "";
00145 sScOutputNameNegI[temp_index]= "";
00146 sScInputNameNegU[temp_index] = "";
00147 sScOutputNameNegU[temp_index]= "";
00148 }
00149
00150
00151 TString sOptionFileName = "./rootconv_options.txt";
00152 Bool_t bFilenameFound = kFALSE;
00153 fstream optionFilenameFile("./Option_files.txt", ios::in);
00154
00155 if( optionFilenameFile.fail() == true)
00156 {
00157 cout<<"************************************************************************"<<endl;
00158 cout<<" File with option filename for Root Conv not found: using the default value ";
00159 cout<<sOptionFileName<<endl;
00160 }
00161 else
00162 {
00163 TString line;
00164
00165
00166 while( !optionFilenameFile.eof() )
00167 {
00168 line.ReadLine(optionFilenameFile, kFALSE);
00169
00170 if(line(0) == '#' || line(0) == '*'||
00171 (line(0) == '/' && line(1) == '/') )
00172 {
00173
00174 ;
00175 }
00176 else if(line.Contains("rootconv")==kTRUE)
00177 {
00178 sOptionFileName = ((TString)line(11, line.Sizeof()-11 ));
00179 cout<<"************************************************************************"<<endl;
00180 cout<<"Using "<<sOptionFileName<<" as source for the options of Root Conv step"<<endl;
00181 bFilenameFound = kTRUE;
00182 break;
00183 }
00184 }
00185 if( optionFilenameFile.eof() && kFALSE == bFilenameFound )
00186 {
00187 cout<<"************************************************************************"<<endl;
00188 cout<<"Field for Root Conv step not found in File with option filename => Using "<<sOptionFileName<<endl;
00189 }
00190 }
00191
00192
00193
00194
00195 fstream setupFile(sOptionFileName, ios::in);
00196 if( setupFile.fail() == true)
00197 {
00198 cout<<"Error for TRootConverterParam: Setup file "<<sOptionFileName<<" can not be opened or is missing."<<endl;
00199 cout<<"=> Using default values!"<<endl;
00200 }
00201 else
00202 {
00203 TString line;
00204 while( !setupFile.eof() )
00205 {
00206 line.ReadLine(setupFile, kFALSE);
00207 if(line(0) == '#' || line(0) == '*')
00208 {
00209
00210 ;
00211 }
00212 else if(line.Contains("disproot")==kTRUE)
00213 {
00214 uRootDisplay = ((TString)line(8,10)).Atoi();
00215 }
00216 else if(line.Contains("cleanoutp")==kTRUE)
00217 {
00218 uCleanOuputEnable = ((TString)line(10,10)).Atoi();
00219 }
00220 else if(line.Contains("nbevtrst")==kTRUE)
00221 {
00222 uEventsUntilReset = ((TString)line(8,10)).Atoi();
00223 }
00224 else if(line.Contains("cleanfile")==kTRUE)
00225 {
00226 sOutputFilename = line(10,120);
00227 }
00228 else if(line.Contains("get4intree")==kTRUE)
00229 {
00230 uAddGet4DataInTree = ((TString)line(11,10)).Atoi();
00231 }
00232 else if(line.Contains("indreftdc")==kTRUE)
00233 {
00234 iReferenceTdc = ((TString)line(10,10)).Atoi();
00235 }
00236 else if(line.Contains("charefone")==kTRUE)
00237 {
00238 iReferenceChannel1 = ((TString)line(10,10)).Atoi();
00239 }
00240 else if(line.Contains("chareftwo")==kTRUE)
00241 {
00242 iReferenceChannel2 = ((TString)line(10,10)).Atoi();
00243 }
00244 else if(line.Contains("caenmode")==kTRUE)
00245 {
00246 uCaenMode = ((TString)line(10,10)).Atoi();
00247 }
00248 else if(line.Contains("caenmulti")==kTRUE)
00249 {
00250 uCaenMulti = ((TString)line(10,10)).Atoi();
00251 }
00252 else if(line.Contains("caentdcena")==kTRUE)
00253 {
00254 line = line(11,39);
00255 if( 0 != line.Sizeof() )
00256 {
00257 for(UInt_t temp_index = 0; temp_index < MAX_1290 && 0 != line.Sizeof(); temp_index++)
00258 {
00259 uGeneralCaenTdcEnabled[temp_index] = ((TString)line(0,3)).Atoi();
00260 line = line(3,39);
00261 }
00262 }
00263 }
00264 else if(line.Contains("pmttdcind")==kTRUE)
00265 {
00266 iPmtTdc = ((TString)line(10,10)).Atoi();
00267 }
00268 else if(line.Contains("pmtqdcind")==kTRUE)
00269 {
00270 iPmtQdc = ((TString)line(10,10)).Atoi();
00271 }
00272 else if(line.Contains("rpctdclei")==kTRUE)
00273 {
00274 iRpcTdcLeading = ((TString)line(10,10)).Atoi();
00275 }
00276 else if(line.Contains("rpctdcfai")==kTRUE)
00277 {
00278 iRpcTdcTrailing = ((TString)line(10,10)).Atoi();
00279 }
00280 else if(line.Contains("trigintree")==kTRUE)
00281 {
00282 uTriglogInputInTree = ((TString)line(11,10)).Atoi();
00283 }
00284 else if(line.Contains("hodointree")==kTRUE)
00285 {
00286 uHodoInputInTree = ((TString)line(11,10)).Atoi();
00287 }
00288 else if(line.Contains("hodohisdeb")==kTRUE)
00289 {
00290 uHodoDebugHisto = ((TString)line(11,10)).Atoi();
00291 }
00292 else if(line.Contains("vftxintree")==kTRUE)
00293 {
00294 uVftxInTree = ((TString)line(11,10)).Atoi();
00295 }
00296 else if(line.Contains("vftxfullda")==kTRUE)
00297 {
00298 uVftxFullDataMode = ((TString)line(11,10)).Atoi();
00299 }
00300 else if(line.Contains("vftxenable")==kTRUE)
00301 {
00302 line = line(11,39);
00303 if( 0 != line.Sizeof() )
00304 {
00305 for(UInt_t temp_index = 0; temp_index < MAX_FPGA_TDC && 0 != line.Sizeof(); temp_index++)
00306 {
00307 uVftxEnabled[temp_index] = ((TString)line(0,3)).Atoi();
00308 line = line(3,39);
00309 }
00310 }
00311 }
00312 else if(line.Contains("scomintree")==kTRUE)
00313 {
00314 uScalOrMuInTree = ((TString)line(11,10)).Atoi();
00315 }
00316 else if(line.Contains("slcointree")==kTRUE)
00317 {
00318 uSlowControlInTree = ((TString)line(11,10)).Atoi();
00319 }
00320 else if(line.Contains("nbslowcoch")==kTRUE)
00321 {
00322 uNbSlowControlChan = ((TString)line(11,10)).Atoi();
00323 if( MAX_HV_CHAN_SC < uNbSlowControlChan)
00324 uNbSlowControlChan = MAX_HV_CHAN_SC;
00325 }
00326 else if(line.Contains("slowcontch")==kTRUE)
00327 {
00328 line = line(12,36);
00329 if( 0 != uNbSlowControlChan && 0 != line.Sizeof() )
00330 {
00331 UInt_t uChannelIndex = 0;
00332 for(UInt_t temp_index = 0; temp_index < uNbSlowControlChan && 0 != line.Sizeof(); temp_index++)
00333 {
00334 uChannelIndex = ((TString)line(0,3)).Atoi();
00335
00336 uSlowControlChans[temp_index]= uChannelIndex;
00337 sScInputNamePosI[temp_index] = Form("CBM:HV:A1526P:CH%d:imon", uChannelIndex);
00338 sScOutputNamePosI[temp_index]= Form("I_PosHv_ch%d", uChannelIndex);
00339 sScInputNamePosU[temp_index] = Form("CBM:HV:A1526P:CH%d:vmon", uChannelIndex);
00340 sScOutputNamePosU[temp_index]= Form("U_PosHv_ch%d", uChannelIndex);
00341 sScInputNameNegI[temp_index] = Form("CBM:HV:A1526N:CH%d:imon", uChannelIndex);
00342 sScOutputNameNegI[temp_index]= Form("I_NegHv_ch%d", uChannelIndex);
00343 sScInputNameNegU[temp_index] = Form("CBM:HV:A1526N:CH%d:vmon", uChannelIndex);
00344 sScOutputNameNegU[temp_index]= Form("U_NegHv_ch%d", uChannelIndex);
00345
00346 line = line(3,36);
00347 }
00348 }
00349 else if( 0 == line.Sizeof() )
00350 cout<<"Error: Some HV channel expected and empty string for exact indexes!"<<endl;
00351 }
00352
00353 }
00354 }
00355
00356 setupFile.close();
00357
00358 return kTRUE;
00359 }
00360 Int_t TRootConverterParam::PrintOptions()
00361 {
00362 cout<<"******************* ROOT Tree converter parameters *********************"<<endl;
00363
00364 if( uRootDisplay )
00365 cout<<"Clean data tree display in Go4: ON "<<endl;
00366 else cout<<"Clean data tree display in Go4: OFF"<<endl;
00367 if( uCleanOuputEnable )
00368 {
00369 cout<<"Output file for clean data tree: ON "<<endl;
00370 cout<<"Output filename: "<<sOutputFilename<<endl;
00371 }
00372 else cout<<"Output file for clean data tree: OFF"<<endl;
00373 if( uRootDisplay && 0 == uCleanOuputEnable )
00374 cout<<"Nb Events before periodic reset: "<<uEventsUntilReset<<endl;
00375 if(1 == uRootDisplay || 1 == uCleanOuputEnable )
00376 {
00377 if( 1 == uAddGet4DataInTree )
00378 cout<<"GET4 data added to the TTree: ON "<<endl;
00379 else cout<<"GET4 data added to the TTree: OFF"<<endl;
00380 if( -1 != iPmtTdc || -1 != iPmtQdc )
00381 {
00382 cout<<"Caen TDC for PMT data: "<<iPmtTdc<<endl;
00383 cout<<"Lecroy for PMT data: "<<iPmtQdc<<endl;
00384 }
00385 if( 0 == uCaenMode)
00386 {
00387 cout<<"mode for CAEN data in tree: COSY 2011 like "<<endl;
00388 if( -1 != iRpcTdcLeading || -1 != iRpcTdcTrailing )
00389 {
00390 cout<<"Caen TDC for RPC leading edge: "<<iRpcTdcLeading<<endl;
00391 cout<<"Caen TDC for RPC trailing edge: "<<iRpcTdcTrailing<<endl;
00392 }
00393 if( -1 != iReferenceTdc || -1 != iReferenceChannel1 || -1 != iReferenceChannel2)
00394 {
00395 cout<<"Caen TDC for t0 reference: "<<iReferenceTdc<<endl;
00396 cout<<"1st Caen TDC Channel for t0 ref: "<<iReferenceChannel1<<endl;
00397 cout<<"2nd Caen TDC Channel for t0 ref: "<<iReferenceChannel2<<endl;
00398 }
00399 }
00400 else
00401 {
00402 cout<<"mode for CAEN data in tree: General "<<endl;
00403 if( 1 == uCaenMulti )
00404 cout<<"CAEN multiple hits in TTree: ON "<<endl;
00405 else cout<<"CAEN multiple hits in TTree: OFF"<<endl;
00406
00407 cout<<"Caen v1290 tdc index: |- ";
00408 for( Int_t iIndex1290 = 0; iIndex1290 < MAX_1290; iIndex1290++)
00409 {
00410 cout.width(2);
00411 cout<<iIndex1290<<" ";
00412 }
00413 cout<<endl<<"Added in Tree? |-> ";
00414 for( Int_t iIndex1290 = 0; iIndex1290 < MAX_1290; iIndex1290++)
00415 {
00416 cout.width(2);
00417 cout<<uGeneralCaenTdcEnabled[iIndex1290]<<" ";
00418 }
00419 cout<<endl;
00420 }
00421 if( uTriglogInputInTree )
00422 cout<<"TrigLog data added to the TTree: ON "<<endl;
00423 else cout<<"TrigLog data added to the TTree: OFF"<<endl;
00424 if( uHodoInputInTree )
00425 cout<<"Hodoscope data added to the TTree: ON "<<endl;
00426 else cout<<"Hodoscope data added to the TTree: OFF"<<endl;
00427 if( uHodoDebugHisto )
00428 cout<<"Hodoscope debug histograms: ON "<<endl;
00429 else cout<<"Hodoscope debug histograms: OFF"<<endl;
00430 if( uVftxInTree )
00431 {
00432 cout<<"VFTX data added to the TTree: ON "<<endl;
00433
00434 if( uVftxFullDataMode )
00435 cout<<"VFTX data in tree: FULL = raw + calib "<<endl;
00436 else cout<<"VFTX data in tree: Only CALIB "<<endl;
00437
00438 cout<<"VFTX tdc index: |- ";
00439 for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00440 {
00441 cout.width(2);
00442 cout<<iIndexVftx<<" ";
00443 }
00444 cout<<endl<<"Added in Tree? |-> ";
00445 for( Int_t iIndexVftx = 0; iIndexVftx < MAX_FPGA_TDC; iIndexVftx++)
00446 {
00447 cout.width(2);
00448 cout<<uVftxEnabled[iIndexVftx]<<" ";
00449 }
00450 cout<<endl;
00451 }
00452 else cout<<"VFTX data added to the TTree: OFF"<<endl;
00453 if( uScalOrMuInTree )
00454 cout<<"ScalOrMu scalers added to TTree: ON "<<endl;
00455 else cout<<"ScalOrMu scalers added to TTree: OFF"<<endl;
00456 if( uSlowControlInTree )
00457 {
00458 cout<<"HDRPC HV value added to the TTree: ON "<<endl;
00459 cout<<"Nb slow control HV channels saved: "<<uNbSlowControlChan<<endl;
00460 cout<<"Index slow control HV channels: ";
00461 for(UInt_t temp_index = 0; temp_index < uNbSlowControlChan; temp_index++)
00462 cout<<uSlowControlChans[temp_index]<<" ";
00463 cout<<endl;
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476 }
00477 else cout<<"HDRPC HV value added to the TTree: OFF"<<endl;
00478 }
00479 cout<<"************************************************************************"<<endl;
00480
00481 return 0;
00482 }