00001
00002
00003 #include "TPlasticsParam.h"
00004 #include "TGo4Log.h"
00005
00006 #include "TGo4Version.h"
00007 #if __GO4BUILDVERSION__ > 40502
00008 #include "go4iostream.h"
00009 #else
00010 #include "Riostream.h"
00011 #endif
00012
00013 #include "MBSUNPACK/TMbsCrateEvent.h"
00014
00015 #define NB_DIGITS_PLASTICS_INDEXES 5
00016 #define NB_DIGITS_PLASTICS_OFFSETS 9
00017
00018
00019 #define DEBUG 0
00020 #define NB_PLASTICS 0 // Nb of strips for the beam profile monitor
00021 #define TIME_CONV 10.0
00022
00023 #define PLASTICS_POSX 0
00024 #define PLASTICS_POSY 0
00025 #define PLASTICS_POSZ 0
00026 #define PLASTIC_ORIENTATION 0
00027 #define PLASTICS_WIDTH 0
00028 #define PLASTICS_LENGTH 0
00029 #define PLASTIC_TDC_TYPE 1
00030 #define PLASTIC_NB_SIDES 0
00031 #define PLASTICS_LEFT_TOT_TDC 0
00032 #define PLASTICS_LEFT_TOT_CHA 0
00033 #define PLASTICS_LEFT_TIME_TDC 0
00034 #define PLASTICS_LEFT_TIME_CHA 0
00035 #define PLASTICS_RIGHT_TIME_TDC 0
00036 #define PLASTICS_RIGHT_TIME_CHA 0
00037 #define PLASTICS_RIGHT_TOT_TDC 0
00038 #define PLASTICS_RIGHT_TOT_CHA 0
00039
00040 #define TDC_FOR_REFERENCE -1
00041 #define CH_FOR_REFERENCE -1
00042 #define TDC_FOR_DIAMOND_VFTX -1
00043 #define CH_FOR_DIAMOND_VFTX -1
00044
00045 #define TRIGGER_SELECTION -1
00046
00047 #define PLASTICS_PROFILE_OFFS 0
00048 #define PLASTICS_DIAMOND_OFFS 0
00049 #define PLASTICS_REFERENCE_OFFS 0
00050 #define PLASTICS_OFFSET_LEFT 0
00051 #define PLASTICS_OFFSET_RIGHT 0
00052
00053 #define PLASTICS_TOT_GAIN_LEFT 1
00054 #define PLASTICS_TOT_OFFS_LEFT 0
00055 #define PLASTICS_TOT_GAIN_RIGHT 1
00056 #define PLASTICS_TOT_OFFS_RIGHT 0
00057
00058
00059 TPlasticsParam::TPlasticsParam(const char* name) : TGo4Parameter(name)
00060 {
00061 ReadOptions();
00062 CalculateLeftRightOffset();
00063 PrintOptions();
00064 }
00065
00066
00067 TPlasticsParam::~TPlasticsParam()
00068 {
00069 }
00070
00071 Bool_t TPlasticsParam::ReadOptions(){
00072
00073 uDebug = DEBUG;
00074 iReferenceTdc = TDC_FOR_REFERENCE;
00075 iReferenceChannel = CH_FOR_REFERENCE;
00076 iDiamondTdcVFTX = TDC_FOR_DIAMOND_VFTX;
00077 iDiamondChannelVFTX = CH_FOR_DIAMOND_VFTX;
00078 uNbPlastics = NB_PLASTICS;
00079 dTimeConv = TIME_CONV;
00080 iTriggerSelection = TRIGGER_SELECTION;
00081
00082 for( Int_t iPlastic = 0; iPlastic < NB_PLASTICS_MAX; iPlastic ++)
00083 {
00084 dPlasticsPosX[iPlastic] = PLASTICS_POSX;
00085 dPlasticsPosY[iPlastic] = PLASTICS_POSY;
00086 dPlasticsPosZ[iPlastic] = PLASTICS_POSZ;
00087
00088 uOrientation[iPlastic] = PLASTIC_ORIENTATION;
00089 dPlasticWidth[iPlastic] = PLASTICS_WIDTH;
00090 dPlasticLength[iPlastic] = PLASTICS_LENGTH;
00091
00092 uPlasticTdcType[iPlastic] = PLASTIC_TDC_TYPE;
00093 uNbSides[iPlastic] = PLASTIC_NB_SIDES;
00094 uTdcPlasticLeftTot[iPlastic] = PLASTICS_LEFT_TOT_TDC;
00095 uChannelPlasticLeftTot[iPlastic] = PLASTICS_LEFT_TOT_CHA;
00096 uTdcPlasticLeftTime[iPlastic] = PLASTICS_LEFT_TIME_TDC;
00097 uChannelPlasticLeftTime[iPlastic] = PLASTICS_LEFT_TIME_CHA;
00098 uTdcPlasticRightTime[iPlastic] = PLASTICS_RIGHT_TIME_TDC;
00099 uChannelPlasticRightTime[iPlastic] = PLASTICS_RIGHT_TIME_CHA;
00100 uTdcPlasticRightTot[iPlastic] = PLASTICS_RIGHT_TOT_TDC;
00101 uChannelPlasticRightTot[iPlastic] = PLASTICS_RIGHT_TOT_CHA;
00102
00103 dProfOffsetList[iPlastic] = PLASTICS_PROFILE_OFFS;
00104 dDiaOffsetList[iPlastic] = PLASTICS_DIAMOND_OFFS;
00105 dRefOffsetList[iPlastic] = PLASTICS_REFERENCE_OFFS;
00106
00107 dOffsetListLeft[iPlastic] = PLASTICS_OFFSET_LEFT;
00108 dOffsetListRight[iPlastic] = PLASTICS_OFFSET_RIGHT;
00109
00110 dToTGainListLeft[iPlastic] = PLASTICS_TOT_GAIN_LEFT;
00111 dTotOffsetListLeft[iPlastic] = PLASTICS_TOT_OFFS_LEFT;
00112 dToTGainListRight[iPlastic] = PLASTICS_TOT_GAIN_RIGHT;
00113 dTotOffsetListRight[iPlastic] = PLASTICS_TOT_OFFS_RIGHT;
00114 }
00115
00116
00117 TString sOptionFileName = "./Plastics_options.txt";
00118
00119 Bool_t bFilenameFound = kFALSE;
00120 fstream optionFilenameFile("./Option_files.txt", ios::in);
00121
00122 if( optionFilenameFile.fail() == true)
00123 {
00124 cout<<"************************************************************************"<<endl;
00125 cout<<" File with option filename for TPlasticsParam "<<GetName()<<" not found: using the default value ";
00126 cout<<sOptionFileName<<endl;
00127 }
00128 else
00129 {
00130 TString line;
00131
00132
00133 while( !optionFilenameFile.eof() )
00134 {
00135 line.ReadLine(optionFilenameFile, kFALSE);
00136
00137 if(line(0) == '#' || line(0) == '*'||
00138 (line(0) == '/' && line(1) == '/') )
00139 {
00140
00141 ;
00142 }
00143 else if( line.Contains("plastics ")==kTRUE)
00144 {
00145 sOptionFileName = ((TString)line(11, line.Sizeof()-11 ));
00146 cout<<"************************************************************************"<<endl;
00147 cout<<"Using "<<sOptionFileName<<" as source for the options of TPlasticsParam "<<GetName()<<" step"<<endl;
00148 bFilenameFound = kTRUE;
00149 break;
00150 }
00151 }
00152 if( optionFilenameFile.eof() && kFALSE == bFilenameFound )
00153 {
00154 cout<<"************************************************************************"<<endl;
00155 cout<<"Field for TPlasticsParam "<<GetName()<<" step not found in File with option filename => Using "<<sOptionFileName<<endl;
00156 }
00157 }
00158
00159 fstream setupFile(sOptionFileName, ios::in);
00160
00161
00162 if( setupFile.fail() == true)
00163 {
00164 TGo4Log::Error("TPlasticsParam %s: Setup file %s can not be opened or is missing.", GetName(), sOptionFileName.Data());
00165 TGo4Log::Error("=> Using default values!");
00166 }
00167 else
00168 {
00169 TGo4Log::Info("TPlasticsParam %s: Load Setup file %s.", GetName(), sOptionFileName.Data());
00170 TString line;
00171
00172
00173 while( !setupFile.eof() )
00174 {
00175 line.ReadLine(setupFile, kFALSE);
00176 if(1 == uDebug)
00177 cout<<line<<endl;
00178
00179 if(line(0) == '#' || line(0) == '*')
00180 {
00181
00182 ;
00183 }
00184 else if(line.Contains("debug")==kTRUE)
00185 {
00186 uDebug = ((TString)line(12,10)).Atoi();
00187 if(1 == uDebug)
00188 cout<<"Debug ON!!!!!!"<<endl;
00189 }
00190 else if(line.Contains("tdcreferenc")==kTRUE)
00191 {
00192 iReferenceTdc = ((TString)line(12,10)).Atoi();
00193 if( iReferenceTdc > MAX_FPGA_TDC)
00194 {
00195 cout<<"Error: VFTX tdc for reference higher than max allowed -> replaced by default value: ";
00196 cout<<TDC_FOR_REFERENCE<<endl;
00197 iReferenceTdc = TDC_FOR_REFERENCE;
00198 }
00199 }
00200 else if(line.Contains("chareferenc")==kTRUE)
00201 {
00202 iReferenceChannel = ((TString)line(12,10)).Atoi();
00203 if( iReferenceChannel > FPGA_TDC_NBCHAN)
00204 {
00205 cout<<"Error: VFTX channel for reference higher than max allowed -> replaced by default value: ";
00206 cout<<CH_FOR_REFERENCE<<endl;
00207 iReferenceChannel = CH_FOR_REFERENCE;
00208 }
00209 }
00210 else if(line.Contains("tdcdiamvftx")==kTRUE)
00211 {
00212 iDiamondTdcVFTX = ((TString)line(12,10)).Atoi();
00213 if( iDiamondTdcVFTX > MAX_FPGA_TDC)
00214 {
00215 cout<<"Error: VFTX tdc for diamond higher than max allowed -> replaced by default value: ";
00216 cout<<TDC_FOR_DIAMOND_VFTX<<endl;
00217 iDiamondTdcVFTX = TDC_FOR_DIAMOND_VFTX;
00218 }
00219 }
00220 else if(line.Contains("chadiamvftx")==kTRUE)
00221 {
00222 iDiamondChannelVFTX = ((TString)line(12,10)).Atoi();
00223 if( iDiamondChannelVFTX > FPGA_TDC_NBCHAN)
00224 {
00225 cout<<"Error: VFTX channel for diamond higher than max allowed -> replaced by default value: ";
00226 cout<<CH_FOR_DIAMOND_VFTX<<endl;
00227 iDiamondChannelVFTX = CH_FOR_DIAMOND_VFTX;
00228 }
00229 }
00230 else if(line.Contains("nbplastics")==kTRUE)
00231 {
00232 uNbPlastics = ((TString)line(12,10)).Atoi();
00233 if( uNbPlastics > NB_PLASTICS_MAX)
00234 {
00235 cout<<"Error: nb plastics higher than max allowed "<<uNbPlastics;
00236 cout<<" -> replaced by max value: ";
00237 cout<<NB_PLASTICS_MAX<<endl;
00238 uNbPlastics = NB_PLASTICS_MAX;
00239 }
00240 }
00241 else if(line.Contains("timeconvcm")==kTRUE)
00242 {
00243 dTimeConv = ((TString)line(12,10)).Atof();
00244 }
00245 else if(line.Contains("triggsel")==kTRUE)
00246 {
00247 iTriggerSelection = ((TString)line(12,10)).Atoi();
00248 }
00249 else if(line.Contains("plastictdctype")==kTRUE)
00250 {
00251 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00252 if( uNbPlastics == 0 && line.Sizeof() )
00253 {
00254 if( 1 == uDebug )
00255 {
00256 cout<<"Warning: uNbPlastics is 0 and plastics tdc type array not empty: skip filling"<<line<<endl;
00257 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00258 }
00259 }
00260 else
00261 {
00262 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00263 {
00264 uPlasticTdcType[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atoi();
00265 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00266 }
00267 }
00268 }
00269 else if(line.Contains("plasticposx")==kTRUE)
00270 {
00271 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00272 if( uNbPlastics == 0 && line.Sizeof() )
00273 {
00274 if( 1 == uDebug )
00275 {
00276 cout<<"Warning: uNbPlastics is 0 and plastics pos X array not empty: skip filling"<<line<<endl;
00277 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00278 }
00279 }
00280 else
00281 {
00282 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00283 {
00284 dPlasticsPosX[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atof();
00285 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00286 }
00287 }
00288 }
00289 else if(line.Contains("plasticposy")==kTRUE)
00290 {
00291 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00292 if( uNbPlastics == 0 && line.Sizeof() )
00293 {
00294 if( 1 == uDebug )
00295 {
00296 cout<<"Warning: uNbPlastics is 0 and plastics pos Y array not empty: skip filling"<<line<<endl;
00297 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00298 }
00299 }
00300 else
00301 {
00302 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00303 {
00304 dPlasticsPosY[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atof();
00305 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00306 }
00307 }
00308 }
00309 else if(line.Contains("plasticposz")==kTRUE)
00310 {
00311 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00312 if( uNbPlastics == 0 && line.Sizeof() )
00313 {
00314 if( 1 == uDebug )
00315 {
00316 cout<<"Warning: uNbPlastics is 0 and plastics pos Z array not empty: skip filling"<<line<<endl;
00317 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00318 }
00319 }
00320 else
00321 {
00322 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00323 {
00324 dPlasticsPosZ[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atof();
00325 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00326 }
00327 }
00328 }
00329 else if(line.Contains("plasticorient")==kTRUE)
00330 {
00331 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00332 if( uNbPlastics == 0 && line.Sizeof() )
00333 {
00334 if( 1 == uDebug )
00335 {
00336 cout<<"Warning: uNbPlastics is 0 and plastics orientation array not empty: skip filling"<<line<<endl;
00337 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00338 }
00339 }
00340 else
00341 {
00342 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00343 {
00344 uOrientation[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atoi();
00345 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00346 }
00347 }
00348 }
00349 else if(line.Contains("plasticwidth")==kTRUE)
00350 {
00351 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00352 if( uNbPlastics == 0 && line.Sizeof() )
00353 {
00354 if( 1 == uDebug )
00355 {
00356 cout<<"Warning: uNbPlastics is 0 and plastics width array not empty: skip filling"<<line<<endl;
00357 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00358 }
00359 }
00360 else
00361 {
00362 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00363 {
00364 dPlasticWidth[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atof();
00365 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00366 }
00367 }
00368 }
00369 else if(line.Contains("plasticlength")==kTRUE)
00370 {
00371 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00372 if( uNbPlastics == 0 && line.Sizeof() )
00373 {
00374 if( 1 == uDebug )
00375 {
00376 cout<<"Warning: uNbPlastics is 0 and plastics length array not empty: skip filling"<<line<<endl;
00377 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00378 }
00379 }
00380 else
00381 {
00382 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00383 {
00384 dPlasticLength[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atof();
00385 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00386 }
00387 }
00388 }
00389 else if(line.Contains("planbside")==kTRUE)
00390 {
00391 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00392 if( uNbPlastics == 0 && line.Sizeof() )
00393 {
00394 if( 1 == uDebug )
00395 {
00396 cout<<"Warning: uNbPlastics is 0 and plastics nb read sides array not empty: skip filling"<<line<<endl;
00397 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00398 }
00399 }
00400 else
00401 {
00402 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00403 {
00404 uNbSides[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atoi();
00405 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00406 }
00407 }
00408 }
00409 else if(line.Contains("plalefttottdc")==kTRUE)
00410 {
00411 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00412 if( uNbPlastics == 0 && line.Sizeof() )
00413 {
00414 if( 1 == uDebug )
00415 {
00416 cout<<"Warning: uNbPlastics is 0 and plastics left tot tdc array not empty: skip filling"<<line<<endl;
00417 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00418 }
00419 }
00420 else
00421 {
00422 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00423 {
00424 uTdcPlasticLeftTot[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atoi();
00425 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00426 }
00427 }
00428 }
00429 else if(line.Contains("plalefttotcha")==kTRUE)
00430 {
00431 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00432 if( uNbPlastics == 0 && line.Sizeof() )
00433 {
00434 if( 1 == uDebug )
00435 {
00436 cout<<"Warning: uNbPlastics is 0 and plastics left tot channel array not empty: skip filling"<<line<<endl;
00437 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00438 }
00439 }
00440 else
00441 {
00442 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00443 {
00444 uChannelPlasticLeftTot[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atoi();
00445 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00446 }
00447 }
00448 }
00449 else if(line.Contains("plalefttimetdc")==kTRUE)
00450 {
00451 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00452 if( uNbPlastics == 0 && line.Sizeof() )
00453 {
00454 if( 1 == uDebug )
00455 {
00456 cout<<"Warning: uNbPlastics is 0 and plastics left time tdc array not empty: skip filling"<<line<<endl;
00457 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00458 }
00459 }
00460 else
00461 {
00462 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00463 {
00464 uTdcPlasticLeftTime[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atoi();
00465 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00466 }
00467 }
00468 }
00469 else if(line.Contains("plalefttimecha")==kTRUE)
00470 {
00471 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00472 if( uNbPlastics == 0 && line.Sizeof() )
00473 {
00474 if( 1 == uDebug )
00475 {
00476 cout<<"Warning: uNbPlastics is 0 and plastics left time channel array not empty: skip filling"<<line<<endl;
00477 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00478 }
00479 }
00480 else
00481 {
00482 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00483 {
00484 uChannelPlasticLeftTime[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atoi();
00485 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00486 }
00487 }
00488 }
00489 else if(line.Contains("plarighttimetdc")==kTRUE)
00490 {
00491 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00492 if( uNbPlastics == 0 && line.Sizeof() )
00493 {
00494 if( 1 == uDebug )
00495 {
00496 cout<<"Warning: uNbPlastics is 0 and plastics right time tdc array not empty: skip filling"<<line<<endl;
00497 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00498 }
00499 }
00500 else
00501 {
00502 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00503 {
00504 uTdcPlasticRightTime[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atoi();
00505 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00506 }
00507 }
00508 }
00509 else if(line.Contains("plarighttimecha")==kTRUE)
00510 {
00511 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00512 if( uNbPlastics == 0 && line.Sizeof() )
00513 {
00514 if( 1 == uDebug )
00515 {
00516 cout<<"Warning: uNbPlastics is 0 and plastics right time channel array not empty: skip filling"<<line<<endl;
00517 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00518 }
00519 }
00520 else
00521 {
00522 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00523 {
00524 uChannelPlasticRightTime[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atoi();
00525 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00526 }
00527 }
00528 }
00529 else if(line.Contains("plarighttottdc")==kTRUE)
00530 {
00531 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00532 if( uNbPlastics == 0 && line.Sizeof() )
00533 {
00534 if( 1 == uDebug )
00535 {
00536 cout<<"Warning: uNbPlastics is 0 and plastics right tot tdc array not empty: skip filling"<<line<<endl;
00537 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00538 }
00539 }
00540 else
00541 {
00542 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00543 {
00544 uTdcPlasticRightTot[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atoi();
00545 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00546 }
00547 }
00548 }
00549 else if(line.Contains("plarighttotcha")==kTRUE)
00550 {
00551 line = line(16,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00552 if( uNbPlastics == 0 && line.Sizeof() )
00553 {
00554 if( 1 == uDebug )
00555 {
00556 cout<<"Warning: uNbPlastics is 0 and plastics right tot channel array not empty: skip filling"<<line<<endl;
00557 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00558 }
00559 }
00560 else
00561 {
00562 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00563 {
00564 uChannelPlasticRightTot[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_INDEXES)).Atoi();
00565 line = line(NB_DIGITS_PLASTICS_INDEXES,NB_DIGITS_PLASTICS_INDEXES*NB_PLASTICS_MAX);
00566 }
00567 }
00568 }
00569 else if(line.Contains("platimeoff")==kTRUE)
00570 {
00571 line = line(16,NB_DIGITS_PLASTICS_OFFSETS*NB_PLASTICS_MAX);
00572 if( uNbPlastics == 0 && line.Sizeof() )
00573 {
00574 if( 1 == uDebug )
00575 {
00576 cout<<"Warning: nbPlastics is 0 and plastics profile offsets array not empty: skip filling"<<line<<endl;
00577 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00578 }
00579 }
00580 else
00581 {
00582 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00583 {
00584 dProfOffsetList[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_OFFSETS)).Atof();
00585 line = line(NB_DIGITS_PLASTICS_OFFSETS,NB_DIGITS_PLASTICS_OFFSETS*NB_PLASTICS_MAX);
00586 }
00587 }
00588 }
00589 else if(line.Contains("diatimeoff")==kTRUE)
00590 {
00591 line = line(16,NB_DIGITS_PLASTICS_OFFSETS*NB_PLASTICS_MAX);
00592 if( uNbPlastics == 0 && line.Sizeof() )
00593 {
00594 if( 1 == uDebug )
00595 {
00596 cout<<"Warning: nbPlastics is 0 and plastics diamond offsets array not empty: skip filling"<<line<<endl;
00597 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00598 }
00599 }
00600 else
00601 {
00602 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00603 {
00604 dDiaOffsetList[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_OFFSETS)).Atof();
00605 line = line(NB_DIGITS_PLASTICS_OFFSETS,NB_DIGITS_PLASTICS_OFFSETS*NB_PLASTICS_MAX);
00606 }
00607 }
00608 }
00609 else if(line.Contains("reftimeoff")==kTRUE)
00610 {
00611 line = line(16,NB_DIGITS_PLASTICS_OFFSETS*NB_PLASTICS_MAX);
00612 if( uNbPlastics == 0 && line.Sizeof() )
00613 {
00614 if( 1 == uDebug )
00615 {
00616 cout<<"Warning: nbPlastics is 0 and plastics reference offsets array not empty: skip filling"<<line<<endl;
00617 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00618 }
00619 }
00620 else
00621 {
00622 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00623 {
00624 dRefOffsetList[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_OFFSETS)).Atof();
00625 line = line(NB_DIGITS_PLASTICS_OFFSETS,NB_DIGITS_PLASTICS_OFFSETS*NB_PLASTICS_MAX);
00626 }
00627 }
00628 }
00629 else if(line.Contains("platotgainleft")==kTRUE)
00630 {
00631 line = line(16,NB_DIGITS_PLASTICS_OFFSETS*NB_PLASTICS_MAX);
00632 if( uNbPlastics == 0 && line.Sizeof() )
00633 {
00634 if( 1 == uDebug )
00635 {
00636 cout<<"Warning: nbPlastics is 0 and plastics left tot gain array not empty: skip filling"<<line<<endl;
00637 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00638 }
00639 }
00640 else
00641 {
00642 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00643 {
00644 dToTGainListLeft[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_OFFSETS)).Atof();
00645 line = line(NB_DIGITS_PLASTICS_OFFSETS,NB_DIGITS_PLASTICS_OFFSETS*NB_PLASTICS_MAX);
00646 }
00647 }
00648 }
00649 else if(line.Contains("platotoffsleft")==kTRUE)
00650 {
00651 line = line(16,NB_DIGITS_PLASTICS_OFFSETS*NB_PLASTICS_MAX);
00652 if( uNbPlastics == 0 && line.Sizeof() )
00653 {
00654 if( 1 == uDebug )
00655 {
00656 cout<<"Warning: nbPlastics is 0 and plastics left tot offsets array not empty: skip filling"<<line<<endl;
00657 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00658 }
00659 }
00660 else
00661 {
00662 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00663 {
00664 dTotOffsetListLeft[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_OFFSETS)).Atof();
00665 line = line(NB_DIGITS_PLASTICS_OFFSETS,NB_DIGITS_PLASTICS_OFFSETS*NB_PLASTICS_MAX);
00666 }
00667 }
00668 }
00669 else if(line.Contains("platotgainright")==kTRUE)
00670 {
00671 line = line(16,NB_DIGITS_PLASTICS_OFFSETS*NB_PLASTICS_MAX);
00672 if( uNbPlastics == 0 && line.Sizeof() )
00673 {
00674 if( 1 == uDebug )
00675 {
00676 cout<<"Warning: nbPlastics is 0 and plastics right tot gain array not empty: skip filling"<<line<<endl;
00677 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00678 }
00679 }
00680 else
00681 {
00682 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00683 {
00684 dToTGainListRight[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_OFFSETS)).Atof();
00685 line = line(NB_DIGITS_PLASTICS_OFFSETS,NB_DIGITS_PLASTICS_OFFSETS*NB_PLASTICS_MAX);
00686 }
00687 }
00688 }
00689 else if(line.Contains("platotoffsright")==kTRUE)
00690 {
00691 line = line(16,NB_DIGITS_PLASTICS_OFFSETS*NB_PLASTICS_MAX);
00692 if( uNbPlastics == 0 && line.Sizeof() )
00693 {
00694 if( 1 == uDebug )
00695 {
00696 cout<<"Warning: nbPlastics is 0 and plastics right tot offsets array not empty: skip filling"<<line<<endl;
00697 cout<<"(if line were inverted in the option file, it could be the error)"<<endl;
00698 }
00699 }
00700 else
00701 {
00702 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00703 {
00704 dTotOffsetListRight[temp_index] = ((TString)line(0,NB_DIGITS_PLASTICS_OFFSETS)).Atof();
00705 line = line(NB_DIGITS_PLASTICS_OFFSETS,NB_DIGITS_PLASTICS_OFFSETS*NB_PLASTICS_MAX);
00706 }
00707 }
00708 }
00709 }
00710 }
00711 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00712 if( 1 == uPlasticTdcType[temp_index] )
00713 {
00714 uTdcPlasticLeftTot[temp_index] = uTdcPlasticLeftTime[temp_index];
00715 if( 1 == uChannelPlasticLeftTime[temp_index]%2)
00716 uChannelPlasticLeftTot[temp_index] = uChannelPlasticLeftTime[temp_index] - 1;
00717 else uChannelPlasticLeftTot[temp_index] = uChannelPlasticLeftTime[temp_index] + 1;
00718 uTdcPlasticRightTot[temp_index] = uTdcPlasticRightTime[temp_index];
00719 if( 1 == uChannelPlasticRightTot[temp_index]%2)
00720 uChannelPlasticRightTime[temp_index] = uChannelPlasticRightTot[temp_index] - 1;
00721 else uChannelPlasticRightTime[temp_index] = uChannelPlasticRightTot[temp_index] + 1;
00722 }
00723
00724 return kTRUE;
00725 }
00726
00727
00728 Int_t TPlasticsParam::PrintOptions(){
00729 cout<<"********************* PLASTICS calibration parameters **********************"<<endl;
00730 cout<<"------------- Options for PLASTICS --------------"<<endl;
00731 cout<<"-------------------------------------------------"<<endl;
00732 if(1 == uDebug)
00733 cout<<" Debug ON!!!!!!"<<endl;
00734 else cout<<" Debug OFF"<<endl;
00735 if( -1 < iReferenceTdc && -1 < iReferenceChannel )
00736 {
00737 cout<<" Chan. used for diamond: "<<iReferenceChannel;
00738 cout<<" in TDC "<<iReferenceTdc<<" in VFTX probably"<<endl;
00739 }
00740 if( -1 < iDiamondTdcVFTX && -1 < iDiamondChannelVFTX )
00741 {
00742 cout<<" Chan. used for diamond: "<<iDiamondChannelVFTX;
00743 cout<<" in TDC "<<iDiamondTdcVFTX<<" in VFTX"<<endl;
00744 }
00745 cout<<" Nb Plastics: "<<uNbPlastics<<endl;
00746 cout<<" Time Convertion factor: "<<dTimeConv<<" cm/ns"<<endl;
00747 if( -1 == iTriggerSelection )
00748 cout<<" Trigger selection: OFF"<<endl;
00749 else cout<<" Trigger selection: Trigger "<<iTriggerSelection<<endl;
00750 cout<<"-------------------------------------------------"<<endl;
00751 cout<<" Plastic: |- ";
00752 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00753 {
00754 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00755 cout<<temp_index<<" ";
00756 }
00757 cout<<endl<<" Tdc Type |-> ";
00758 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00759 {
00760 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00761 cout<<uPlasticTdcType[temp_index]<<" ";
00762 }
00763 cout<<endl<<" Position X |-> ";
00764 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00765 {
00766 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00767 cout<<dPlasticsPosX[temp_index]<<" ";
00768 }
00769 cout<<endl<<" Position Y |-> ";
00770 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00771 {
00772 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00773 cout<<dPlasticsPosY[temp_index]<<" ";
00774 }
00775 cout<<endl<<" Position Z |-> ";
00776 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00777 {
00778 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00779 cout<<dPlasticsPosZ[temp_index]<<" ";
00780 }
00781 cout<<endl<<" Orientation |-> ";
00782 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00783 {
00784 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00785 cout<<uOrientation[temp_index]<<" ";
00786 }
00787 cout<<endl<<" Width |-> ";
00788 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00789 {
00790 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00791 cout<<dPlasticWidth[temp_index]<<" ";
00792 }
00793 cout<<endl<<" Length |-> ";
00794 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00795 {
00796 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00797 cout<<dPlasticLength[temp_index]<<" ";
00798 }
00799 cout<<endl<<" Nb sides |-> ";
00800 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00801 {
00802 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00803 cout<<uNbSides[temp_index]<<" ";
00804 } cout<<endl<<" Tdc Tot Left |-> ";
00805 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00806 {
00807 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00808 cout<<uTdcPlasticLeftTot[temp_index]<<" ";
00809 }
00810 cout<<endl<<" Channel Tot Left |-> ";
00811 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00812 {
00813 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00814 cout<<uChannelPlasticLeftTot[temp_index]<<" ";
00815 }
00816 cout<<endl<<" Tdc Time Left |-> ";
00817 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00818 {
00819 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00820 cout<<uTdcPlasticLeftTime[temp_index]<<" ";
00821 }
00822 cout<<endl<<" Channel Time Left |-> ";
00823 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00824 {
00825 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00826 cout<<uChannelPlasticLeftTime[temp_index]<<" ";
00827 }
00828 cout<<endl<<" Tdc Time Right |-> ";
00829 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00830 {
00831 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00832 cout<<uTdcPlasticRightTime[temp_index]<<" ";
00833 }
00834 cout<<endl<<" Channel Time Right |-> ";
00835 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00836 {
00837 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00838 cout<<uChannelPlasticRightTime[temp_index]<<" ";
00839 }
00840 cout<<endl<<" Tdc Tot Right |-> ";
00841 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00842 {
00843 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00844 cout<<uTdcPlasticRightTot[temp_index]<<" ";
00845 }
00846 cout<<endl<<" Channel Tot Right |-> ";
00847 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00848 {
00849 cout.width(NB_DIGITS_PLASTICS_INDEXES - 1);
00850 cout<<uChannelPlasticRightTot[temp_index]<<" ";
00851 }
00852 cout<<endl;
00853 cout<<"-------------------------------------------------"<<endl;
00854 cout<<" Plastic: |- ";
00855 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00856 {
00857 cout.width(NB_DIGITS_PLASTICS_OFFSETS - 1);
00858 cout<<temp_index<<" ";
00859 }
00860 cout<<endl<<" Beam Profile Offset|-> ";
00861 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00862 {
00863 cout.width(NB_DIGITS_PLASTICS_OFFSETS - 1);
00864 cout<<dProfOffsetList[temp_index]<<" ";
00865 }
00866 cout<<endl<<" Diamond Offset |-> ";
00867 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00868 {
00869 cout.width(NB_DIGITS_PLASTICS_OFFSETS - 1);
00870 cout<<dDiaOffsetList[temp_index]<<" ";
00871 }
00872 cout<<endl<<" Reference Offset |-> ";
00873 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00874 {
00875 cout.width(NB_DIGITS_PLASTICS_OFFSETS - 1);
00876 cout<<dRefOffsetList[temp_index]<<" ";
00877 }
00878 cout<<endl<<" Tot Gain Left |-> ";
00879 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00880 {
00881 cout.width(NB_DIGITS_PLASTICS_OFFSETS - 1);
00882 cout<<dToTGainListLeft[temp_index]<<" ";
00883 }
00884 cout<<endl<<" Tot Offset Left |-> ";
00885 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00886 {
00887 cout.width(NB_DIGITS_PLASTICS_OFFSETS - 1);
00888 cout<<dTotOffsetListLeft[temp_index]<<" ";
00889 }
00890 cout<<endl<<" Tot Gain Right |-> ";
00891 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00892 {
00893 cout.width(NB_DIGITS_PLASTICS_OFFSETS - 1);
00894 cout<<dToTGainListRight[temp_index]<<" ";
00895 }
00896 cout<<endl<<" Tot Offset Right |-> ";
00897 for(UInt_t temp_index = 0; temp_index < uNbPlastics; temp_index++)
00898 {
00899 cout.width(NB_DIGITS_PLASTICS_OFFSETS - 1);
00900 cout<<dTotOffsetListRight[temp_index]<<" ";
00901 }
00902 cout<<endl;
00903 cout<<"************************************************************************"<<endl;
00904
00905 return 0;
00906 }
00907
00908 Bool_t TPlasticsParam::CalculateLeftRightOffset()
00909 {
00910 for( UInt_t uPlastic = 0; uPlastic < uNbPlastics; uPlastic++)
00911 {
00912
00913
00914
00915 dOffsetListLeft[uPlastic] = 0.5*( (dProfOffsetList[uPlastic])+2.*(dDiaOffsetList[uPlastic]));
00916 dOffsetListRight[uPlastic] = 0.5*(-(dProfOffsetList[uPlastic])+2.*(dDiaOffsetList[uPlastic]));
00917 }
00918 return kTRUE;
00919 }