00001
00002
00003 #include "TRPCParam.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 HIT_BUILDING_ENABLE 1
00013 #define BLOCK_ORDER_ENABLE 1
00014
00015 #define OUTPUT_FILE_ENABLE 0
00016 #define OUTPUT_FILENAME "testTree.root"
00017 #define ROOT_TREE_DISPLAY 0
00018 #define GET4_DATA_IN_TREE 1
00019 #define PMT_TDC -1;
00020 #define PMT_QDC -1;
00021 #define RPC_TDC_LEADING -1;
00022 #define RPC_TDC_LEADING -1;
00023 #define TDC_REFERENCE -1;
00024 #define CHANNEL_TDC_REFERENCE -1;
00025
00026 #define CORRELATION_GATE 26214.4 // ns
00027 #define CORRELATION_CHECK 50.0 //ns
00028
00029 #define TOT_HISTOGRAM_SIZE 75.0 //ns
00030
00031 #define BUFFERS_NB 3 // Number of 25 epochs blocks buffers to use for messages and hits ordering/matching
00032
00033
00034 #define HITS_FOR_RATE 10 // Number of hits over which average is doen for mean instant rate
00035
00036 #define DEBUG_CORRELATION 0 // adds debug 2D histograms for correlations
00037 #define TOT_CORRELATION 0 // adds Tot correlation histograms
00038
00039 #define MANUAL_DEBUG 1 // Enable messages about possible messages delays for
00040
00041
00042 #define NB_STRIPS 24 // Nb of strips for the beam profile monitor
00043
00044
00045 #define STRIPS_LEFT_LIST { 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }
00046 #define STRIPS_RIGHT_LIST { 31, 30, 29, 28, 27, 26, 25, 24, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47 }
00047 #define STRIPS_OFFSET_LIST { 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 3.0, 3.0,-3.6,-5.3,-2.3,-4.0,-6.0,-7.0,-5.1,-3.2, 0.0, 9.9, 5.2, 4.5, 3.5, 4.8, 7.2, 5.3 }
00048 #define BEAM_PROFILE_SIZE 32
00049
00050 #define NB_PADS_X 6 // Nb of pads in X direction for the beam profile monitor
00051 #define NB_PADS_Y 2 // Nb of pads in Y direction for the beam profile monitor
00052
00053
00054 #define PADS_LIST {{ 57, 58, 59, 60, 61, 62 }, \
00055 { 65, 66, 67, 68, 69, 71 } }
00056
00057
00058
00059 TRPCParam::TRPCParam() : TGo4Parameter()
00060 {
00061 uHitBuildingEnable = 0;
00062 uBlockOrderingEnable = 0;
00063
00064 uRootDisplay = 0;
00065 uCleanOuputEnable = 0;
00066 sOutputFilename = "";
00067 uAddGet4DataInTree = 0;
00068 iPmtTdc = -1;
00069 iPmtQdc = -1;
00070 iRpcTdcLeading = -1;
00071 iRpcTdcTrailing = -1;
00072 iReferenceTdc = -1;
00073 iReferenceChannel1 = -1;
00074 iReferenceChannel2 = -1;
00075
00076 fCorrelationGate = 0;
00077 fCorrelationCheck = 0;
00078 fTotSize = 0;
00079 uManualDebug = 0;
00080 uNbHitMeanRate = 0;
00081 uCorrelationHistoOn = 0;
00082 uTotCorrelationHistOn = 0;
00083
00084 uNbStrips = 0;
00085
00086
00087
00088 iBeamProfileSize = 0;
00089
00090 uNbPadsX = 0;
00091 uNbPadsY = 0;
00092
00093 }
00094
00095
00096
00097 TRPCParam::TRPCParam(const char* name) : TGo4Parameter(name)
00098 {
00099 uHitBuildingEnable = 0;
00100 uBlockOrderingEnable = 0;
00101
00102 uRootDisplay = 0;
00103 uCleanOuputEnable = 0;
00104 sOutputFilename = "";
00105 uAddGet4DataInTree = 0;
00106 iPmtTdc = -1;
00107 iPmtQdc = -1;
00108 iRpcTdcLeading = -1;
00109 iRpcTdcTrailing = -1;
00110 iReferenceTdc = -1;
00111 iReferenceChannel1 = -1;
00112 iReferenceChannel2 = -1;
00113
00114 fCorrelationGate = 0;
00115 fCorrelationCheck = 0;
00116 fTotSize = 0;
00117 uManualDebug = 0;
00118 uNbHitMeanRate = 0;
00119 uCorrelationHistoOn = 0;
00120 uTotCorrelationHistOn = 0;
00121
00122 uNbStrips = 0;
00123
00124
00125
00126 iBeamProfileSize = 0;
00127
00128 uNbPadsX = 0;
00129 uNbPadsY = 0;
00130
00131
00132 ReadOptions();
00133 this->PrintOptions();
00134 }
00135
00136
00137 TRPCParam::~TRPCParam()
00138 {
00139
00140
00141
00142
00143
00144
00145
00146 }
00147
00148
00149
00150 Bool_t TRPCParam::UpdateFrom(TGo4Parameter *pp)
00151 {
00152 if(pp->InheritsFrom("TRPCParam")) {
00153 TRPCParam * from = (TRPCParam *) pp;
00154
00155 fCorrelationGate = from->fCorrelationGate;
00156 fCorrelationCheck = from->fCorrelationCheck;
00157 uManualDebug = from->uManualDebug;
00158 uNbHitMeanRate = from->uNbHitMeanRate;
00159
00160 cout << "**** TRPCParam " << GetName() << " updated from source parameter" << endl;
00161 } else
00162 cout << "Wrong parameter object: " << pp->ClassName() << endl;
00163 return kTRUE;
00164 }
00165
00166 Bool_t TRPCParam::ReadOptions()
00167 {
00168 uHitBuildingEnable = HIT_BUILDING_ENABLE;
00169 uBlockOrderingEnable = BLOCK_ORDER_ENABLE;
00170
00171 uRootDisplay = ROOT_TREE_DISPLAY;
00172 uCleanOuputEnable = OUTPUT_FILE_ENABLE;
00173 sOutputFilename = OUTPUT_FILENAME;
00174 uAddGet4DataInTree = GET4_DATA_IN_TREE;
00175 iPmtTdc = PMT_TDC;
00176 iPmtQdc = PMT_QDC;
00177 iRpcTdcLeading = RPC_TDC_LEADING;
00178 iRpcTdcTrailing = RPC_TDC_LEADING;
00179 iReferenceTdc = TDC_REFERENCE;
00180 iReferenceChannel1 = CHANNEL_TDC_REFERENCE;
00181 iReferenceChannel2 = CHANNEL_TDC_REFERENCE;
00182
00183 fCorrelationGate = CORRELATION_GATE;
00184 fCorrelationCheck = CORRELATION_CHECK;
00185 fTotSize = TOT_HISTOGRAM_SIZE;
00186 uNbHitMeanRate = HITS_FOR_RATE;
00187 uManualDebug = MANUAL_DEBUG;
00188 uCorrelationHistoOn = DEBUG_CORRELATION;
00189 uTotCorrelationHistOn= TOT_CORRELATION;
00190
00191 uNbStrips = NB_STRIPS;
00192 UInt_t uStripLeftListTemp[NB_STRIPS] = STRIPS_LEFT_LIST;
00193 UInt_t uStripRightListTemp[NB_STRIPS] = STRIPS_RIGHT_LIST;
00194 Double_t dOffsetListTemp[NB_STRIPS] = STRIPS_OFFSET_LIST;
00195 iBeamProfileSize = BEAM_PROFILE_SIZE;
00196
00197 uNbPadsX = NB_PADS_X;
00198 uNbPadsY = NB_PADS_Y;
00199 UInt_t uPadsListTemp[NB_PADS_Y][NB_PADS_X] = PADS_LIST;
00200
00201
00202 fstream setupFile("rocget4_options.txt", ios::in);
00203 if( setupFile.fail() == true)
00204 {
00205 cout<<"Error opening setup file rocget4_options.txt"<<endl;
00206 cout<<"=> Using default values!"<<endl;
00207
00208 for(UInt_t temp_index = 0; temp_index < uNbStrips; temp_index++)
00209 {
00210 uStripLeftList[temp_index] = uStripLeftListTemp[temp_index];
00211 uStripRightList[temp_index] = uStripRightListTemp[temp_index];
00212 dOffsetList[temp_index] = dOffsetListTemp[temp_index];
00213 }
00214
00215 for(UInt_t temp_Yindex = 0; temp_Yindex < uNbPadsY; temp_Yindex++)
00216 for(UInt_t temp_Xindex = 0; temp_Xindex < uNbPadsX; temp_Xindex++)
00217 uPadsList[temp_Yindex][temp_Xindex] = uPadsListTemp[temp_Yindex][temp_Xindex];
00218 }
00219 else
00220 {
00221 TString line;
00222 line.ReadLine(setupFile, kFALSE);
00223 while( !setupFile.eof() )
00224 {
00225 if(line(0) == '#' || line(0) == '*')
00226 {
00227
00228 ;
00229 }
00230 else if(line.Contains("buildhits")==kTRUE)
00231 {
00232 uHitBuildingEnable = ((TString)line(10,10)).Atoi();
00233 }
00234 else if(line.Contains("orderbloc")==kTRUE)
00235 {
00236 uBlockOrderingEnable = ((TString)line(10,10)).Atoi();
00237 }
00238 else if(line.Contains("disproot")==kTRUE)
00239 {
00240 uRootDisplay = ((TString)line(8,10)).Atoi();
00241 }
00242 else if(line.Contains("cleanoutp")==kTRUE)
00243 {
00244 uCleanOuputEnable = ((TString)line(10,10)).Atoi();
00245 }
00246 else if(line.Contains("cleanfile")==kTRUE)
00247 {
00248 sOutputFilename = line(10,120);
00249 }
00250 else if(line.Contains("get4intree")==kTRUE)
00251 {
00252 uAddGet4DataInTree = ((TString)line(11,10)).Atoi();
00253 }
00254 else if(line.Contains("pmttdcind")==kTRUE)
00255 {
00256 iPmtTdc = ((TString)line(10,10)).Atoi();
00257 }
00258 else if(line.Contains("pmtqdcind")==kTRUE)
00259 {
00260 iPmtQdc = ((TString)line(10,10)).Atoi();
00261 }
00262 else if(line.Contains("rpctdclei")==kTRUE)
00263 {
00264 iRpcTdcLeading = ((TString)line(10,10)).Atoi();
00265 }
00266 else if(line.Contains("rpctdcfai")==kTRUE)
00267 {
00268 iRpcTdcTrailing = ((TString)line(10,10)).Atoi();
00269 }
00270 else if(line.Contains("indreftdc")==kTRUE)
00271 {
00272 iReferenceTdc = ((TString)line(10,10)).Atoi();
00273 }
00274 else if(line.Contains("charefone")==kTRUE)
00275 {
00276 iReferenceChannel1 = ((TString)line(10,10)).Atoi();
00277 }
00278 else if(line.Contains("chareftwo")==kTRUE)
00279 {
00280 iReferenceChannel2 = ((TString)line(10,10)).Atoi();
00281 }
00282 else if(line.Contains("corrgate")==kTRUE)
00283 {
00284 fCorrelationGate = ((TString)line(9,10)).Atof();
00285 }
00286 else if(line.Contains("corrcheck")==kTRUE)
00287 {
00288 fCorrelationCheck = ((TString)line(10,10)).Atof();
00289 }
00290 else if(line.Contains("totsize")==kTRUE)
00291 {
00292 fTotSize = ((TString)line(8,10)).Atof();
00293 }
00294 else if(line.Contains("mandeb")==kTRUE)
00295 {
00296 uManualDebug = ((TString)line(7,10)).Atoi();
00297 }
00298 else if(line.Contains("hitrate")==kTRUE)
00299 {
00300 uNbHitMeanRate = ((TString)line(8,10)).Atoi();
00301 }
00302 else if(line.Contains("corrhist")==kTRUE)
00303 {
00304 uCorrelationHistoOn = ((TString)line(9,10)).Atoi();
00305 }
00306 else if(line.Contains("totcorrh")==kTRUE)
00307 {
00308 uTotCorrelationHistOn = ((TString)line(9,10)).Atoi();
00309 }
00310 else if(line.Contains("nbstrips")==kTRUE)
00311 {
00312 uNbStrips = ((TString)line(9,10)).Atoi();
00313 if( uNbStrips > NB_STRIPS_MAX)
00314 {
00315 cout<<"Error: nb strips higher than max allowed -> replaced by max value: ";
00316 cout<<NB_STRIPS_MAX<<endl;
00317 uNbStrips = NB_STRIPS_MAX;
00318 }
00319 }
00320 else if(line.Contains("stripsleft")==kTRUE)
00321 {
00322 line = line(12,200);
00323 if( uNbStrips == 0 && line.Sizeof() )
00324 {
00325 cout<<"Warning: nbStrips is 0 and left strips array not empty: skip filling"<<line<<endl;
00326 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00327 }
00328 else
00329 {
00330 for(UInt_t temp_index = 0; temp_index < uNbStrips; temp_index++)
00331 {
00332 uStripLeftList[temp_index] = ((TString)line(0,5)).Atoi();
00333 line = line(5,200);
00334 }
00335 }
00336 }
00337 else if(line.Contains("stripsright")==kTRUE)
00338 {
00339 line = line(12,200);
00340 if( uNbStrips == 0 && line.Sizeof() )
00341 {
00342 cout<<"Warning: nbStrips is 0 and right strips array not empty: skip filling"<<line<<endl;
00343 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00344 }
00345 else
00346 {
00347 for(UInt_t temp_index = 0; temp_index < uNbStrips; temp_index++)
00348 {
00349 uStripRightList[temp_index] = ((TString)line(0,5)).Atoi();
00350 line = line(5,200);
00351 }
00352 }
00353 }
00354 else if(line.Contains("stripsoffs")==kTRUE)
00355 {
00356 line = line(12,200);
00357 if( uNbStrips == 0 && line.Sizeof() )
00358 {
00359 cout<<"Warning: nbStrips is 0 and strips offsets array not empty: skip filling"<<line<<endl;
00360 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00361 }
00362 else
00363 {
00364 for(UInt_t temp_index = 0; temp_index < uNbStrips; temp_index++)
00365 {
00366 dOffsetList[temp_index] = ((TString)line(0,5)).Atof();
00367 line = line(5,200);
00368 }
00369 }
00370 }
00371 else if(line.Contains("beamsize")==kTRUE)
00372 {
00373 iBeamProfileSize = ((TString)line(9,10)).Atoi();
00374 }
00375 else if(line.Contains("nbpadsx")==kTRUE)
00376 {
00377 uNbPadsX = ((TString)line(9,10)).Atoi();
00378 if( uNbPadsX > NB_PADS_X_MAX)
00379 {
00380 cout<<"Error: nb pads on X axis higher than max allowed -> replaced by max value ";
00381 cout<<NB_PADS_X_MAX<<endl;
00382 uNbPadsX = NB_PADS_X_MAX;
00383 }
00384 }
00385 else if(line.Contains("nbpadsy")==kTRUE)
00386 {
00387 uNbPadsY = ((TString)line(9,10)).Atoi();
00388 if( uNbPadsY > NB_PADS_Y_MAX)
00389 {
00390 cout<<"Error: nb pads on Y axis higher than max allowed -> replaced by max value ";
00391 cout<<NB_PADS_Y_MAX<<endl;
00392 uNbPadsY = NB_PADS_Y_MAX;
00393 }
00394 }
00395 else if(line.Contains("padsrow")==kTRUE)
00396 {
00397 for(UInt_t temp_indexY = 0; temp_indexY < uNbPadsY; temp_indexY++)
00398 {
00399 if( line.Contains( Form("padsrow%u", temp_indexY+1)) ==kTRUE)
00400 {
00401 line = line(12,200);
00402 for(UInt_t temp_indexX = 0; temp_indexX < uNbPadsX; temp_indexX++)
00403 {
00404 uPadsList[temp_indexY][temp_indexX] = ((TString)line(0,5)).Atoi();
00405 line = line(5,200);
00406 }
00407 }
00408 line.ReadLine(setupFile, kFALSE);
00409 }
00410 }
00411
00412 line.ReadLine(setupFile, kFALSE);
00413 }
00414 }
00415
00416 setupFile.close();
00417
00418 if( 0 == uHitBuildingEnable )
00419 {
00420 cout<<"-------------> Disable Block ordering because Hit building is disabled!"<<endl;
00421 uBlockOrderingEnable = 0;
00422 }
00423 if( 0 == uBlockOrderingEnable )
00424 {
00425 cout<<"-------------> Disable tree display in Go4 because Block ordering is disabled!"<<endl;
00426 uRootDisplay = 0;
00427 cout<<"-------------> Disable tree file output because Block ordering is disabled!"<<endl;
00428 uCleanOuputEnable = 0;
00429 cout<<"-------------> Disable Correlation Histos because Block ordering is disabled!"<<endl;
00430 uCorrelationHistoOn = 0;
00431 }
00432
00433 return kTRUE;
00434 }
00435 Int_t TRPCParam::PrintOptions()
00436 {
00437 cout<<"*************************************************"<<endl;
00438 cout<<" Option values RPC Param"<<endl;
00439 if( uHitBuildingEnable )
00440 cout<<"Message order and hit building: ON "<<endl;
00441 else cout<<"Message order and hit building: OFF"<<endl;
00442 if( uBlockOrderingEnable )
00443 cout<<"25 Epoch Block time ordering: ON "<<endl;
00444 else cout<<"25 Epoch Block time ordering: OFF"<<endl;
00445 cout<<"-------------------------------------------------"<<endl;
00446 if( uRootDisplay )
00447 cout<<"Clean data tree display in Go4: ON "<<endl;
00448 else cout<<"Clean data tree display in Go4: OFF"<<endl;
00449 if( uCleanOuputEnable )
00450 {
00451 cout<<"Output file for clean data tree: ON "<<endl;
00452 cout<<"Output filename: "<<sOutputFilename<<endl;
00453 }
00454 else cout<<"Output file for clean data tree: OFF"<<endl;
00455 if(1 == uRootDisplay || 1 == uCleanOuputEnable )
00456 {
00457 if( uAddGet4DataInTree )
00458 cout<<"GET4 data added to the TTree: ON "<<endl;
00459 else cout<<"GET4 data added to the TTree: OFF"<<endl;
00460 if( -1 != iPmtTdc || -1 != iPmtQdc )
00461 {
00462 cout<<"Caen TDC for PMT data: "<<iPmtTdc<<endl;
00463 cout<<"Lecroy for PMT data: "<<iPmtQdc<<endl;
00464 }
00465 if( -1 != iRpcTdcLeading || -1 != iRpcTdcTrailing )
00466 {
00467 cout<<"Caen TDC for RPC leading edge: "<<iRpcTdcLeading<<endl;
00468 cout<<"Caen TDC for RPC trailing edge: "<<iRpcTdcTrailing<<endl;
00469 }
00470 if( -1 != iReferenceTdc || -1 != iReferenceChannel1 || -1 != iReferenceChannel2)
00471 {
00472 cout<<"Caen TDC for t0 reference: "<<iReferenceTdc<<endl;
00473 cout<<"1st Caen TDC Channel for t0 ref: "<<iReferenceChannel1<<endl;
00474 cout<<"2nd Caen TDC Channel for t0 ref: "<<iReferenceChannel2<<endl;
00475 }
00476 }
00477 cout<<"-------------------------------------------------"<<endl;
00478 cout<<"Correlation gate: "<<fCorrelationGate<<" ns"<<endl;
00479 cout<<"Correlation check: "<<fCorrelationCheck<<" ns"<<endl;
00480 cout<<"ToT histo size: [ 0; "<<fTotSize<<"], in ns, bining = 100ps (2 GET4 bin)"<<endl;
00481 if( uManualDebug )
00482 cout<<"Debug Output for manual corr: ON "<<endl;
00483 else cout<<"Debug Output for manual corr: OFF"<<endl;
00484 cout<<"Nb hits for rate average: "<<uNbHitMeanRate<<endl;
00485 if( uCorrelationHistoOn )
00486 cout<<"Histograms for 2D correlations: ON "<<endl;
00487 else cout<<"Histograms for 2D correlations: OFF"<<endl;
00488 if( uTotCorrelationHistOn )
00489 cout<<"Histograms for tot correlations: ON "<<endl;
00490 else cout<<"Histograms for tot correlations: OFF"<<endl;
00491
00492 cout<<"-------------------------------------------------"<<endl;
00493 cout<<"Nb strips in beam profile: "<<uNbStrips<<endl;
00494 cout<<"Strip channel: |- ";
00495 for(UInt_t temp_index = 0; temp_index < uNbStrips; temp_index++)
00496 {
00497 cout.width(2);
00498 cout<<temp_index<<" ";
00499 }
00500 cout<<endl<<"Left |-> ";
00501 for(UInt_t temp_index = 0; temp_index < uNbStrips; temp_index++)
00502 {
00503 cout.width(2);
00504 cout<<uStripLeftList[temp_index]<<" ";
00505 }
00506 cout<<endl<<"Right |-> ";
00507 for(UInt_t temp_index = 0; temp_index < uNbStrips; temp_index++)
00508 {
00509 cout.width(2);
00510 cout<<uStripRightList[temp_index]<<" ";
00511 }
00512 cout<<endl;
00513 cout<<"Strip offset: |- ";
00514 for(UInt_t temp_index = 0; temp_index < uNbStrips; temp_index++)
00515 {
00516 cout.width(4);
00517 cout<<temp_index<<" ";
00518 }
00519 cout<<endl<<" |-> ";
00520 for(UInt_t temp_index = 0; temp_index < uNbStrips; temp_index++)
00521 {
00522 cout.width(4);
00523 cout<<dOffsetList[temp_index]<<" ";
00524 }
00525 cout<<endl;
00526 cout<<"Size of beam profile in X: "<<iBeamProfileSize<<" cm "<<endl;
00527 cout<<"-------------------------------------------------"<<endl;
00528 cout<<"Nb pads in X axis in beam profile: "<<uNbPadsX<<endl;
00529 cout<<"Nb pads in Y axis in beam profile: "<<uNbPadsY<<endl;
00530 cout<<"Strip channel: |- ";
00531 for(UInt_t temp_index = 0; temp_index < uNbPadsX; temp_index++)
00532 {
00533 cout.width(2);
00534 cout<<temp_index<<" ";
00535 }
00536 for(UInt_t temp_indexY = 0; temp_indexY < uNbPadsY; temp_indexY++)
00537 {
00538 cout<<endl<<"Row ";
00539 cout.width(2);
00540 cout<<temp_indexY<<" |-> ";
00541 for(UInt_t temp_indexX = 0; temp_indexX < uNbPadsX; temp_indexX++)
00542 {
00543 cout.width(2);
00544 cout<<uPadsList[temp_indexY][temp_indexX]<<" ";
00545 }
00546 }
00547 cout<<endl;
00548 cout<<"*************************************************"<<endl;
00549
00550 return 0;
00551 }