00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00013
00014 #include "TString.h"
00015
00016 #include "MessageService/MsgService.h"
00017
00018 #include "LISummary/LIRun.h"
00019 #include <cmath>
00020
00021 ClassImp(LIRun)
00022
00023 CVSID("$Id: LIRun.cxx,v 1.15 2007/11/11 08:00:53 rhatcher Exp $");
00024
00025
00026
00027 LIRun::LIRun()
00028 {
00029 MSG("LIRun", Msg::kVerbose)
00030 <<"Running LIRun default constructor..."<<endl;
00031
00032 this->InitialiseVariables();
00033
00034 MSG("LIRun", Msg::kVerbose)
00035 <<"Finished LIRun default constructor"<<endl;
00036 }
00037
00038
00039
00040 LIRun::LIRun(Int_t pulserBox,Int_t led,LIRunType_t LIRunType,
00041 Detector::Detector_t detectorType)
00042 {
00043 MSG("LIRun", Msg::kVerbose)
00044 <<"Running LIRun constructor..."<<endl;
00045
00046 this->InitialiseVariables();
00047
00048 fLed=led;
00049 fPulserBox=pulserBox;
00050 fDetector=detectorType;
00051 fLIRunType=LIRunType;
00052
00053 MSG("LIRun", Msg::kVerbose)
00054 <<"Finished LIRun constructor"<<endl;
00055 }
00056
00057
00058
00059 LIRun::~LIRun()
00060 {
00061 MSG("LIRun", Msg::kVerbose)
00062 <<"Running LIRun destructor..."<<endl;
00063
00064
00065 MSG("LIRun", Msg::kVerbose)
00066 <<"Finished LIRun destructor"<<endl;
00067 }
00068
00069
00070
00071 bool operator==(LIRun a, LIRun b)
00072 {
00073 return a.GetPh()==b.GetPh();
00074 }
00075
00076
00077
00078 bool operator<(LIRun a, LIRun b)
00079 {
00080 return a.GetPh().size()<b.GetPh().size();
00081 }
00082
00083
00084 void LIRun::InitialiseVariables()
00085 {
00086 MSG("LIRun",Msg::kVerbose)
00087 <<"Running InitialiseVariables method..."<<endl;
00088
00089 fDetector=Detector::kUnknown;
00090 fLed=-1;
00091 fLIRunType=kUnknown;
00092 fMaxPin=-1;
00093 fMaxPin2=-1;
00094 fMinAdc=1e6;
00095 fMaxAdc=-1;
00096 fMinAdcF=1e6;
00097 fMaxAdcF=-1;
00098 fPulserBox=-1;
00099 fS="";
00100
00101 fHighestPh=-1;
00102 fHighestPin=-1;
00103 fLowestPh=-1;
00104 fLowestPin=-1;
00105
00106 MSG("LIRun",Msg::kVerbose)
00107 <<"InitialiseVariables method finished"<<endl;
00108 }
00109
00110
00111
00112 void LIRun::SetLIInfo(Int_t pB,Int_t l,LIRunType_t LIrt)
00113 {
00114 MSG("LIRun",Msg::kVerbose)
00115 <<"Running SetLIInfo method..."<<endl;
00116
00117 fLed=l;
00118 fPulserBox=pB;
00119 fLIRunType=LIrt;
00120
00121 MSG("LIRun",Msg::kVerbose)
00122 <<"SetLIInfo method finished"<<endl;
00123 }
00124
00125
00126
00127 void LIRun::AddPoint(Double_t newPh,Double_t a,
00128 Double_t p,Double_t p2,
00129 Double_t aF,
00130 Double_t aLow,Double_t aHigh,
00131 Double_t aLowF,Double_t aHighF)
00132 {
00133 MSG("LIRun",Msg::kVerbose)
00134 <<"Running AddPoint method..."<<endl;
00135
00136 UInt_t insertPoint=FindInsertPoint(fPh,newPh);
00137
00138
00139 SetNewPoint(fPh,newPh,insertPoint);
00140 SetNewPoint(fAdc,a,insertPoint);
00141
00142
00143 SetNewPoint(fPin,p,insertPoint);
00144 SetNewPoint(fPin2,p2,insertPoint);
00145 SetNewPoint(fAdcF,aF,insertPoint);
00146 SetNewPoint(fAdcLow,aLow,insertPoint);
00147 SetNewPoint(fAdcHigh,aHigh,insertPoint);
00148 SetNewPoint(fAdcLowF,aLowF,insertPoint);
00149 SetNewPoint(fAdcHighF,aHighF,insertPoint);
00150
00151
00152 if (p>fMaxPin) fMaxPin=p;
00153 if (p2>fMaxPin2) fMaxPin2=p2;
00154
00155 if (a>fMaxAdc) fMaxAdc=a;
00156 if (a<fMinAdc) fMinAdc=a;
00157
00158 if (aF>fMaxAdcF) fMaxAdcF=aF;
00159 if (aF<fMinAdcF) fMinAdcF=aF;
00160
00161 MSG("LIRun",Msg::kDebug)
00162 <<"Added point to LIRun object: ph="<<newPh<<", adc="<<a
00163 <<", pin="<<p<<", pin2="<<p2<<endl;
00164
00165 MSG("LIRun",Msg::kVerbose)
00166 <<"AddPoint method finished"<<endl;
00167 }
00168
00169
00170
00171 Double_t LIRun::GetMaxAdc()
00172 {
00173 return fMaxAdc;
00174 }
00175
00176
00177
00178 Double_t LIRun::GetMinAdc()
00179 {
00180 return fMinAdc;
00181 }
00182
00183
00184
00185 Double_t LIRun::GetMaxAdcF()
00186 {
00187 return fMaxAdcF;
00188 }
00189
00190
00191
00192 Double_t LIRun::GetMinAdcF()
00193 {
00194 return fMinAdcF;
00195 }
00196
00197
00198
00199 Double_t LIRun::GetMaxPin()
00200 {
00201 MSG("LIRun",Msg::kVerbose)
00202 <<"Running GetMaxPin method..."<<endl;
00203
00204 if (fMaxPin==fMaxPin2){
00205 MSG("LIRun",Msg::kWarning)
00206 <<"The two pins only have one max value, pin1="<<fMaxPin
00207 <<", pin2="<<fMaxPin2
00208 <<endl;
00209 }
00210 else if (fMaxPin>fMaxPin2){
00211 return fMaxPin;
00212 }
00213 else{
00214 return fMaxPin2;
00215 }
00216
00217 MSG("LIRun",Msg::kVerbose)
00218 <<"GetMaxPin method finished"<<endl;
00219 return -1;
00220 }
00221
00222
00223
00224 Double_t LIRun::GetMaxPin(Int_t pin1or2)
00225 {
00226 MSG("LIRun",Msg::kVerbose)
00227 <<"Running GetMaxPin method..."<<endl;
00228
00229 if (pin1or2==1){
00230 return fMaxPin;
00231 }
00232 else if (pin1or2==2){
00233 return fMaxPin2;
00234 }
00235 else {
00236 MSG("LIRun",Msg::kWarning)
00237 <<"There are only 2 pins, GetMaxPin must have argument"
00238 <<" value of 1 or 2"<<endl;
00239 }
00240
00241 MSG("LIRun",Msg::kVerbose)
00242 <<"GetMaxPin method finished"<<endl;
00243 return -1;
00244 }
00245
00246
00247
00248 vector<Double_t> LIRun::GetPh()
00249 {
00250 MSG("LIRun",Msg::kVerbose)
00251 <<"Running GetPh method..."<<endl;
00252
00253 MSG("LIRun",Msg::kVerbose)
00254 <<"GetPh method finished"<<endl;
00255 return fPh;
00256 }
00257
00258
00259
00260 Double_t LIRun::GetPh(UInt_t i)
00261 {
00262 MSG("LIRun",Msg::kVerbose)
00263 <<"Running GetPh method..."<<endl;
00264
00265 if (i<fPh.size()) return fPh[i];
00266 else {
00267 MSG("LIRun",Msg::kWarning)
00268 <<"Only "<<fPh.size()<<" elements available, returning -1"<<endl;
00269 return -1;
00270 }
00271
00272 MSG("LIRun",Msg::kVerbose)
00273 <<"GetPh method finished"<<endl;
00274 }
00275
00276
00277
00278 vector<Double_t> LIRun::GetAdc()
00279 {
00280 MSG("LIRun",Msg::kVerbose)
00281 <<"Running GetAdc method..."<<endl;
00282
00283 MSG("LIRun",Msg::kVerbose)
00284 <<"GetAdc method finished"<<endl;
00285 return fAdc;
00286 }
00287
00288
00289
00290 Double_t LIRun::GetAdc(UInt_t i)
00291 {
00292 MSG("LIRun",Msg::kVerbose)
00293 <<"Running GetAdc method..."<<endl;
00294
00295 if (i<fAdc.size()) return fAdc[i];
00296 else {
00297 MSG("LIRun",Msg::kWarning)
00298 <<"Only "<<fAdc.size()<<" elements available, returning -1"<<endl;
00299 return -1;
00300 }
00301
00302 MSG("LIRun",Msg::kVerbose)
00303 <<"GetAdc method finished"<<endl;
00304 }
00305
00306
00307
00308 vector<Double_t> LIRun::GetAdcF()
00309 {
00310 MSG("LIRun",Msg::kVerbose)
00311 <<"Running GetAdcF method..."<<endl;
00312
00313 MSG("LIRun",Msg::kVerbose)
00314 <<"GetAdcF method finished"<<endl;
00315 return fAdcF;
00316 }
00317
00318
00319
00320 vector<Double_t> LIRun::GetAdcLow()
00321 {
00322 MSG("LIRun",Msg::kVerbose)
00323 <<"Running GetAdcLow method..."<<endl;
00324
00325 MSG("LIRun",Msg::kVerbose)
00326 <<"GetAdcLow method finished"<<endl;
00327 return fAdcLow;
00328 }
00329
00330
00331
00332 vector<Double_t> LIRun::GetAdcLowF()
00333 {
00334 MSG("LIRun",Msg::kVerbose)
00335 <<"Running GetAdcLowF method..."<<endl;
00336
00337 MSG("LIRun",Msg::kVerbose)
00338 <<"GetAdcLowF method finished"<<endl;
00339 return fAdcLowF;
00340 }
00341
00342
00343
00344 vector<Double_t> LIRun::GetAdcHigh()
00345 {
00346 MSG("LIRun",Msg::kVerbose)
00347 <<"Running GetAdcHigh method..."<<endl;
00348
00349 MSG("LIRun",Msg::kVerbose)
00350 <<"GetAdcHigh method finished"<<endl;
00351 return fAdcHigh;
00352 }
00353
00354
00355
00356 vector<Double_t> LIRun::GetAdcHighF()
00357 {
00358 MSG("LIRun",Msg::kVerbose)
00359 <<"Running GetAdcHighF method..."<<endl;
00360
00361 MSG("LIRun",Msg::kVerbose)
00362 <<"GetAdcHighF method finished"<<endl;
00363 return fAdcHighF;
00364 }
00365
00366
00367
00368 vector<Double_t> LIRun::GetPin(Int_t pin1or2)
00369 {
00370 MSG("LIRun",Msg::kVerbose)
00371 <<"Running GetPin method..."<<endl;
00372
00373 if (pin1or2==2){
00374 return fPin2;
00375 }
00376 else{
00377 if (pin1or2!=1){
00378 MSG("LIRun",Msg::kWarning)
00379 <<"LIRun::GetPin(Int_t) must have an argument of 1 or 2"
00380 <<", returned pin 1 by default"<<endl;
00381 }
00382 return fPin;
00383 }
00384
00385 MSG("LIRun",Msg::kVerbose)
00386 <<"GetPin method finished"<<endl;
00387 }
00388
00389
00390
00391 Double_t LIRun::GetPin(Int_t pin1or2,UInt_t i)
00392 {
00393 MSG("LIRun",Msg::kVerbose)
00394 <<"Running GetPin method..."<<endl;
00395
00396
00397 if (pin1or2==2){
00398 if (i<fPin2.size()) return fPin2[i];
00399 else{
00400 MSG("LIRun",Msg::kWarning)
00401 <<"Only "<<fPin2.size()<<" elements available, returning -1"
00402 <<endl;
00403 return -1;
00404 }
00405 }
00406
00407 else{
00408 if (pin1or2!=1){
00409 MSG("LIRun",Msg::kWarning)
00410 <<"LIRun::GetPin(Int_t,UInt_t) must have first argument of 1or2"
00411 <<", returned pin 1 by default"<<endl;
00412 }
00413
00414
00415 if (i<fPin.size()) return fPin[i];
00416 else{
00417 MSG("LIRun",Msg::kWarning)
00418 <<"Only "<<fPin.size()<<" elements available, returning -1"
00419 <<endl;
00420 return -1;
00421 }
00422 }
00423
00424 MSG("LIRun",Msg::kVerbose)
00425 <<"GetPin method finished"<<endl;
00426 }
00427
00428
00429
00430 Detector::Detector_t LIRun::GetDetector()
00431 {
00432 MSG("LIRun",Msg::kVerbose)
00433 <<"Running GetLed method..."<<endl;
00434
00435 MSG("LIRun",Msg::kVerbose)
00436 <<"GetLed method finished"<<endl;
00437 return fDetector;
00438 }
00439
00440
00441
00442 Int_t LIRun::GetLed()
00443 {
00444 MSG("LIRun",Msg::kVerbose)
00445 <<"Running GetLed method..."<<endl;
00446
00447 MSG("LIRun",Msg::kVerbose)
00448 <<"GetLed method finished"<<endl;
00449 return fLed;
00450 }
00451
00452
00453
00454 Int_t LIRun::GetPb()
00455 {
00456 MSG("LIRun",Msg::kVerbose)
00457 <<"Running GetPb method..."<<endl;
00458
00459 MSG("LIRun",Msg::kVerbose)
00460 <<"GetPb method finished"<<endl;
00461 return fPulserBox;
00462 }
00463
00464
00465
00466 string LIRun::GetRunTypeAsString()
00467 {
00468 MSG("LIRun",Msg::kVerbose)
00469 <<"Running GetRunTypeAsString method..."<<endl;
00470
00471 if (fLIRunType==kUnknown) return "kUnknown";
00472 else if (fLIRunType==kFullCalib) return "kGainCurve";
00473 else if (fLIRunType==kDriftCalib) return "kDriftPoint";
00474 else return "RunType not valid";
00475
00476 MSG("LIRun",Msg::kVerbose)
00477 <<"GetRunTypeAsString method finished"<<endl;
00478 }
00479
00480
00481
00482 void LIRun::PrintAll()
00483 {
00484 MSG("LIRun",Msg::kDebug)
00485 <<"Running PrintAll method..."<<endl;
00486
00487
00488 string sConfig="";
00489
00490
00491 if (fMaxPin!=-1){
00492 sConfig+=", fMaxPin=";
00493 sConfig+=Form("%d",static_cast<Int_t>(fMaxPin));
00494 }
00495 if (fMaxPin2!=-1){
00496 sConfig+=", fMaxPin2=";
00497 sConfig+=Form("%d",static_cast<Int_t>(fMaxPin2));
00498 }
00499 if (fMaxAdc!=-1){
00500 sConfig+=", fMaxAdc=";
00501 sConfig+=Form("%d",static_cast<Int_t>(fMaxAdc));
00502 }
00503 if (fMinAdc!=1e6){
00504 sConfig+=", fMinAdc=";
00505 sConfig+=Form("%d",static_cast<Int_t>(fMinAdc));
00506 }
00507 if (fHighestPh!=-1 && fLowestPh!=-1){
00508 sConfig+=", (";
00509 sConfig+=Form("%d",static_cast<Int_t>(fLowestPh));
00510 sConfig+="<PH<";
00511 sConfig+=Form("%d",static_cast<Int_t>(fHighestPh));
00512 sConfig+=")";
00513 }
00514 if (fHighestPin!=-1 && fLowestPin!=-1){
00515 sConfig+=", (";
00516 sConfig+=Form("%d",static_cast<Int_t>(fLowestPin));
00517 sConfig+="<PinAdc<";
00518 sConfig+=Form("%d",static_cast<Int_t>(fHighestPin));
00519 sConfig+=")";
00520 }
00521
00522 if (fPulserBox!=-1 && fLed!=-1){
00523 MSG("LIRun",Msg::kInfo)
00524 <<"("<<fPulserBox<<":"<<fLed<<") "<<GetRunTypeAsString()<<sConfig
00525 <<endl;
00526 }
00527
00528 string sVectors="";
00529
00530 sVectors+=GetVectorAsString(fPh,"fPh = ");
00531 sVectors+=GetVectorAsString(fAdc,"fAdc = ");
00532 sVectors+=GetVectorAsString(fAdcF,"fAdcF = ");
00533 sVectors+=GetVectorAsString(fPin,"fPin = ");
00534 sVectors+=GetVectorAsString(fPin2,"fPin2 = ");
00535 sVectors+=GetVectorAsString(fAdcHigh,"fAdcHigh = ");
00536 sVectors+=GetVectorAsString(fAdcHighF,"fAdcHighF = ");
00537 sVectors+=GetVectorAsString(fAdcLow,"fAdcLow = ");
00538 sVectors+=GetVectorAsString(fAdcLowF,"fAdcLowF = ");
00539
00540 if (sVectors!=""){
00541 MSG("LIRun",Msg::kInfo)<<sVectors<<endl;
00542 }
00543
00544 MSG("LIRun",Msg::kDebug)
00545 <<"PrintAll method finished"<<endl;
00546 }
00547
00548
00549
00550 void LIRun::PrintConfig(LIRunType_t LIRunType)
00551 {
00552 MSG("LIRun",Msg::kVerbose)
00553 <<"Running PrintConfig method..."<<endl;
00554
00555
00556
00557 if (LIRunType==kGainCurve){
00558 MSG("LIRun",Msg::kInfo)<<endl<<"<fullCalib>"<<endl;
00559 }
00560 else if (LIRunType==kDriftPoint){
00561 MSG("LIRun",Msg::kInfo)<<endl<<"<driftCalib>"<<endl;
00562 }
00563
00564 Int_t numGainPoints=10;
00565
00566
00567 for (Int_t i=0;i<NUMPULSERBOXES;i++){
00568
00569 if (i>0) MSG("LIRun",Msg::kInfo)<<endl;
00570 for (Int_t j=0;j<NUMLEDS;j++){
00571
00572
00573 string sBox="";
00574 sBox=Form("%d",i);
00575 if (i<10) sBox="0"+sBox;
00576
00577 string sLed="";
00578 sLed=Form("%d",j+1);
00579 if (j<9) sLed="0"+sLed;
00580
00581 fS="box"+sBox+"led"+sLed+"#I=";
00582
00583 for (Int_t g=0;g<numGainPoints;g++){
00584
00585
00586 Double_t rem=0;
00587 Double_t newPh=0;
00588 rem=modf(1.1,&newPh);
00589 if (rem>0.5) newPh++;
00590
00591 string sPh=Form("%d",static_cast<Int_t>(newPh));
00592 fS+=sPh;
00593 if (g<numGainPoints-1) fS+=",";
00594 }
00595 fS+=";";
00596
00597 MSG("LIRun",Msg::kInfo)<<fS<<endl;
00598 }
00599 }
00600 if (LIRunType==kGainCurve){
00601 MSG("LIRun",Msg::kInfo)<<endl<<"</fullCalib>"<<endl;
00602 }
00603 else if (LIRunType==kDriftPoint){
00604 MSG("LIRun",Msg::kInfo)<<endl<<"</driftCalib>"<<endl;
00605 }
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627 MSG("LIRun",Msg::kVerbose)
00628 <<"PrintConfig method finished"<<endl;
00629 }
00630
00631
00632
00633 void LIRun::SetHighLowPhPoints(Double_t highestPh,Double_t lowestPh)
00634 {
00635 MSG("LIRun",Msg::kVerbose)
00636 <<"Running SetHighLowPhPoints method..."<<endl;
00637
00638 fHighestPh=highestPh;
00639 fLowestPh=lowestPh;
00640
00641 MSG("LIRun",Msg::kVerbose)
00642 <<"SetHighLowPhPoints method finished"<<endl;
00643 }
00644
00645
00646
00647 void LIRun::SetHighLowPinPoints(Double_t highestPin,
00648 Double_t lowestPin)
00649 {
00650 MSG("LIRun",Msg::kVerbose)
00651 <<"Running SetHighLowPinPoints method..."<<endl;
00652
00653 fHighestPin=highestPin;
00654 fLowestPin=lowestPin;
00655
00656 MSG("LIRun",Msg::kVerbose)
00657 <<"SetHighLowPinPoints method finished"<<endl;
00658 }
00659
00660
00661