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