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