00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4CondArray.h"
00015
00016 #include <stdlib.h>
00017
00018 #include "Riostream.h"
00019 #include "TROOT.h"
00020 #include "TClass.h"
00021 #include "TObjArray.h"
00022
00023 #include "TGo4Log.h"
00024 #include "TGo4WinCond.h"
00025 #include "TGo4PolyCond.h"
00026 #include "TGo4CondArrayPainter.h"
00027
00028
00029 TGo4WinCond* TGo4CondArray::Win(Int_t i)
00030 {
00031 if(fiType != kGO4CONDWINDOW) return 0;
00032 return (TGo4WinCond*) At(i);
00033 }
00034
00035 TGo4PolyCond* TGo4CondArray::Poly(Int_t i)
00036 {
00037 if(fiType != kGO4CONDPOLYGON) return 0;
00038 return (TGo4PolyCond*) At(i);
00039 }
00040
00041 TGo4Condition * TGo4CondArray::operator[](Int_t i)
00042 {
00043 return (TGo4Condition*) condarr->At(i);
00044 }
00045
00046 TGo4Condition * TGo4CondArray::At(Int_t i)
00047 {
00048
00049 return (TGo4Condition*) condarr->At(i);
00050 }
00051
00052 TGo4CondArray::TGo4CondArray() :
00053 TGo4Condition(),
00054 condarr(0),
00055 fiNumCond(0),
00056 fiType(0),
00057 fiSelectedCond(0)
00058 {
00059 }
00060
00061 TGo4CondArray::TGo4CondArray(const char* name, Int_t elements, Int_t contype) :
00062 TGo4Condition(name,"TGo4CondArray"),
00063 condarr(0),
00064 fiNumCond(0),
00065 fiType(0),
00066 fiSelectedCond(0)
00067 {
00068 fiNumCond = elements;
00069 if(contype == kGO4CONDWINDOW) {
00070 condarr = new TObjArray(elements);
00071 fiType = contype;
00072 for(Int_t i = 0; i < elements; i++)
00073 condarr->AddLast(new TGo4WinCond(Form("%s%06d",name,i)));
00074 } else
00075 if(contype == kGO4CONDPOLYGON) {
00076 condarr = new TObjArray(elements);
00077 fiType = contype;
00078 for(Int_t i = 0; i < elements; i++)
00079 condarr->AddLast(new TGo4PolyCond(Form("%s%06d",name,i)));
00080 } else {
00081 fiNumCond = 0;
00082 fiType = 0;
00083 }
00084 }
00085
00086 TGo4CondArray::TGo4CondArray(const char* name, Int_t elements, const char* type)
00087 : TGo4Condition(name,type),fiSelectedCond(0)
00088 {
00089 fiNumCond = elements;
00090 if(strcmp(type,"TGo4WinCond")==0) {
00091 condarr = new TObjArray(elements);
00092 fiType = kGO4CONDWINDOW;
00093 for(Int_t i = 0; i < elements; i++)
00094 condarr->AddLast(new TGo4WinCond(Form("%s%06d",name,i)));
00095 } else
00096 if(strcmp(type,"TGo4PolyCond")==0) {
00097 condarr = new TObjArray(elements);
00098 fiType = kGO4CONDPOLYGON;
00099 for(Int_t i = 0; i < elements; i++)
00100 condarr->AddLast(new TGo4PolyCond(Form("%s%06d",name,i)));
00101 } else {
00102 fiNumCond = 0;
00103 fiType = 0;
00104 }
00105 }
00106
00107 TGo4CondArray::~TGo4CondArray()
00108 {
00109 if(fxPainter) delete fxPainter;
00110
00111
00112 fxPainter=0;
00113 if (condarr!=0) {
00114 condarr->Delete();
00115 delete condarr;
00116 }
00117
00118 }
00119
00120 Bool_t TGo4CondArray::IsArrayType(){return kTRUE;}
00121
00122
00123
00124 Bool_t TGo4CondArray::Test(Double_t x, Double_t y)
00125 {
00126 Bool_t rev=kTRUE;
00127 if(IsMultiEdit())
00128 {
00129 Int_t ii = condarr->GetLast()+1;
00130 for(Int_t i = 0; i < ii; i++)
00131 {
00132 IncCounts();
00133 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00134 Bool_t result=cond->Test(x,y);
00135 if(result) IncTrueCounts();
00136 rev&=result;
00137 }
00138 }
00139 else
00140 {
00141 TGo4Condition* conny=At(GetCurrentIndex());
00142 if(conny) rev=conny->Test(x,y);
00143 }
00144 return rev;
00145
00146 }
00147 Bool_t TGo4CondArray::Test(Double_t x)
00148 {
00149 Bool_t rev=kTRUE;
00150 if(IsMultiEdit())
00151 {
00152 Int_t ii = condarr->GetLast()+1;
00153 for(Int_t i = 0; i < ii; i++)
00154 {
00155 IncCounts();
00156 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00157 Bool_t result=cond->Test(x);
00158 if(result) IncTrueCounts();
00159 rev&=result;
00160 }
00161 }
00162 else
00163 {
00164 TGo4Condition* conny=At(GetCurrentIndex());
00165 if(conny) rev=conny->Test(x);
00166 }
00167 return rev;
00168 }
00169
00170
00171 void TGo4CondArray::PrintCondition(Bool_t points)
00172 {
00173
00174 Int_t ii = condarr->GetLast()+1;
00175 TGo4Condition* cond = (TGo4Condition*) condarr->At(0);
00176 std::cout << GetName() << " has " << ii << " " << cond->ClassName() << " conditions" << std::endl;
00177 for(Int_t i = 0; i < ii; i++)
00178 {
00179 TGo4Condition* cond = dynamic_cast<TGo4Condition*> (condarr->UncheckedAt(i));
00180 if (cond) cond->PrintCondition(points);
00181 }
00182 }
00183
00184 void TGo4CondArray::PrintBar()
00185 {
00186 Int_t ii = condarr->GetLast()+1;
00187 std::cout <<"-"<<ClassName()<<" "<<GetName()<<" Printout:" << std::endl;
00188
00189 for(Int_t i = 0; i < ii; i++)
00190 {
00191 TGo4Condition* cond = dynamic_cast<TGo4Condition*> (condarr->UncheckedAt(i));
00192 TROOT::IndentLevel();
00193 if (cond) cond->PrintBar();
00194 }
00195
00196 }
00197
00198 Int_t TGo4CondArray::GetNumberOfConditions()
00199 {
00200 return GetNumber();
00201 }
00202
00203
00204 Int_t TGo4CondArray::GetNumber() const
00205 {
00206 return (condarr->GetLast()+1);
00207 }
00208
00209
00210 const char* TGo4CondArray::GetType() const
00211 {
00212 TGo4Condition *cond = (TGo4Condition*) condarr->At(0);
00213 return cond->ClassName();
00214 }
00215
00216
00217 void TGo4CondArray::GetType(Int_t& type) const
00218 {
00219 type = fiType;
00220 }
00221
00222 void TGo4CondArray::Enable(){
00223 TGo4Condition::Enable();
00224 if(IsMultiEdit())
00225 {
00226 Int_t ii = condarr->GetLast()+1;
00227
00228 for(Int_t i = 0; i < ii; i++)
00229 {
00230 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00231 cond->Enable();
00232 }
00233 }
00234 else
00235 {
00236 TGo4Condition* conny=At(GetCurrentIndex());
00237 if(conny) conny->Enable();
00238 }
00239 }
00240
00241 void TGo4CondArray::Disable(Bool_t result)
00242 {
00243 TGo4Condition::Disable(result);
00244 if(IsMultiEdit())
00245 {
00246 Int_t ii = condarr->GetLast()+1;
00247
00248 for(Int_t i = 0; i < ii; i++)
00249 {
00250 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00251 cond->Disable(result);
00252 }
00253 }
00254 else
00255 {
00256 TGo4Condition* conny=At(GetCurrentIndex());
00257 if(conny) conny->Disable(result);
00258 }
00259 }
00260
00261 void TGo4CondArray::Invert(Bool_t on)
00262 {
00263 TGo4Condition::Invert(on);
00264 if(IsMultiEdit())
00265 {
00266 Int_t ii = condarr->GetLast()+1;
00267
00268 for(Int_t i = 0; i < ii; i++)
00269 {
00270 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00271 cond->Invert(on);
00272 }
00273 }
00274 else
00275 {
00276 TGo4Condition* conny=At(GetCurrentIndex());
00277 if(conny) conny->Invert(on);
00278 }
00279 }
00280
00281 void TGo4CondArray::MarkReset(Bool_t on)
00282 {
00283 TGo4Condition::MarkReset(on);
00284 if(IsMultiEdit())
00285 {
00286 Int_t ii = condarr->GetLast()+1;
00287 for(Int_t i = 0; i < ii; i++)
00288 {
00289 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00290 cond->MarkReset(on);
00291 }
00292 }
00293 else
00294 {
00295 TGo4Condition* conny=At(GetCurrentIndex());
00296 if(conny) conny->MarkReset(on);
00297 }
00298 }
00299
00300 void TGo4CondArray::GetFlags(Bool_t* enabled, Bool_t* lastresult, Bool_t* markreset,
00301 Bool_t* result, Bool_t* truevalue, Bool_t* falsevalue)
00302 {
00303 if(IsMultiEdit())
00304 {
00305 Int_t ii = condarr->GetLast()+1;
00306 for(Int_t i = 0; i < ii; i++)
00307 {
00308 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00309 cond->GetFlags(enabled,lastresult,markreset, result, truevalue, falsevalue);
00310 }
00311 }
00312 else
00313 {
00314 TGo4Condition* conny=At(GetCurrentIndex());
00315 if(conny) conny->GetFlags(enabled,lastresult,markreset, result, truevalue, falsevalue);
00316
00317 }
00318 }
00319
00320
00321
00322
00323
00324
00325 void TGo4CondArray::ResetCounts(){
00326 TGo4Condition::ResetCounts();
00327 if(IsMultiEdit())
00328 {
00329
00330 Int_t ii = condarr->GetLast()+1;
00331 for(Int_t i = 0; i < ii; i++)
00332 {
00333 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00334 cond->ResetCounts();
00335 }
00336 }
00337 else
00338 {
00339 TGo4Condition* conny=At(GetCurrentIndex());
00340 if(conny) conny->ResetCounts();
00341 }
00342 }
00343
00344 Int_t TGo4CondArray::Counts()
00345 {
00346 Int_t rev=0;
00347 if(IsMultiEdit())
00348 {
00349 rev=TGo4Condition::Counts();
00350 }
00351 else
00352 {
00353 TGo4Condition* conny=At(GetCurrentIndex());
00354 if(conny) rev=conny->Counts();
00355 }
00356 return rev;
00357 }
00358
00359 Int_t TGo4CondArray::TrueCounts()
00360 {
00361 Int_t rev=0;
00362 if(IsMultiEdit())
00363 {
00364 rev=TGo4Condition::Counts();
00365 }
00366 else
00367 {
00368 TGo4Condition* conny=At(GetCurrentIndex());
00369 if(conny) rev=conny->Counts();
00370 }
00371 return rev;
00372 }
00373
00374 Double_t TGo4CondArray::GetXLow()
00375 {
00376 Double_t rev=0;
00377 if(IsMultiEdit())
00378 {
00379 rev=-1;
00380 }
00381 else
00382 {
00383 TGo4Condition* conny=At(GetCurrentIndex());
00384 if(conny) rev=conny->GetXLow();
00385 }
00386 return rev;
00387 }
00388
00389 Double_t TGo4CondArray::GetXUp()
00390 {
00391 Double_t rev=0;
00392 if(IsMultiEdit())
00393 {
00394 rev=-1;
00395 }
00396 else
00397 {
00398 TGo4Condition* conny=At(GetCurrentIndex());
00399 if(conny) rev=conny->GetXUp();
00400 }
00401 return rev;
00402 }
00403
00404 Double_t TGo4CondArray::GetYLow()
00405 {
00406 Double_t rev=0;
00407 if(IsMultiEdit())
00408 {
00409 rev=-1;
00410 }
00411 else
00412 {
00413 TGo4Condition* conny=At(GetCurrentIndex());
00414 if(conny) rev=conny->GetYLow();
00415 }
00416 return rev;
00417 }
00418
00419 Double_t TGo4CondArray::GetYUp()
00420 {
00421 Double_t rev=0;
00422 if(IsMultiEdit())
00423 {
00424 rev=-1;
00425 }
00426 else
00427 {
00428 TGo4Condition* conny=At(GetCurrentIndex());
00429 if(conny) rev=conny->GetYUp();
00430 }
00431 return rev;
00432 }
00433
00434
00435
00436 void TGo4CondArray::SetValues(Double_t low1, Double_t up1){
00437 if(fiType == kGO4CONDWINDOW)
00438 {
00439 if(IsMultiEdit())
00440 {
00441 Int_t ii = condarr->GetLast()+1;
00442 for(Int_t i = 0; i < ii; i++)
00443 {
00444 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00445 cond->SetValues(low1,up1);
00446 }
00447 }
00448 else
00449 {
00450 TGo4Condition* conny=At(GetCurrentIndex());
00451 if(conny) conny->SetValues(low1,up1);
00452 }
00453 }
00454 }
00455
00456 void TGo4CondArray::SetValues(Double_t low1, Double_t up1, Double_t low2, Double_t up2){
00457 if(fiType == kGO4CONDWINDOW)
00458 {
00459 if(IsMultiEdit())
00460 {
00461 Int_t ii = condarr->GetLast()+1;
00462 for(Int_t i = 0; i < ii; i++)
00463 {
00464 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00465 cond->SetValues(low1,up1,low2,up2);
00466 }
00467 }
00468 else
00469 {
00470 TGo4Condition* conny=At(GetCurrentIndex());
00471 if(conny) conny->SetValues(low1,up1,low2,up2);
00472 }
00473 }
00474 }
00475
00476 void TGo4CondArray::SetValues(TCutG * newcut)
00477 {
00478 if(fiType == kGO4CONDPOLYGON)
00479 {
00480 if(IsMultiEdit())
00481 {
00482 Int_t ii = condarr->GetLast()+1;
00483 for(Int_t i = 0; i < ii; i++)
00484 {
00485 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00486 cond->SetValues(newcut);
00487 }
00488 }
00489 else
00490 {
00491 TGo4Condition* conny=At(GetCurrentIndex());
00492 if(conny) conny->SetValues(newcut);
00493 }
00494 }
00495 }
00496
00497 Bool_t TGo4CondArray::UpdateFrom(TGo4Condition * cond, Bool_t counts)
00498 {
00499 TGo4Condition::UpdateFrom(cond,counts);
00500 TGo4Condition *scond;
00501 TGo4Condition *dcond;
00502 TGo4CondArray *carr;
00503 if(cond->InheritsFrom(TGo4CondArray::Class()))
00504 {
00505 Int_t dii = condarr->GetLast()+1;
00506 Int_t sii = ((TGo4CondArray*)cond)->GetNumber();
00507 if(dii == sii)
00508 {
00509 Bool_t result=kTRUE;
00510 carr = (TGo4CondArray*)cond;
00511
00512 for(Int_t i = 0; i < dii; i++){
00513 dcond=(TGo4Condition*) condarr->UncheckedAt(i);
00514 scond=(TGo4Condition*) (*carr)[i];
00515 result = result && ( dcond->UpdateFrom(scond,counts));
00516 }
00517 return result;
00518 }
00519 else
00520 {
00521 return kFALSE;
00522 }
00523 }
00524 else
00525 {
00526 return kFALSE;
00527 }
00528 }
00529
00530 void TGo4CondArray::SetVisible(Bool_t on)
00531 {
00532 if(IsMultiEdit())
00533 {
00534 TGo4Condition::SetVisible(on);
00535 Int_t ii = condarr->GetLast()+1;
00536 for(Int_t i = 0; i < ii; i++)
00537 {
00538 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00539 cond->SetVisible(on);
00540 }
00541 }
00542 else
00543 {
00544 TGo4Condition* conny=At(GetCurrentIndex());
00545 if(conny) conny->SetVisible(on);
00546 }
00547 }
00548
00549 Bool_t TGo4CondArray::IsVisible()
00550 {
00551 Bool_t rev=kFALSE;
00552 if(IsMultiEdit())
00553 {
00554 rev=TGo4Condition::IsVisible();
00555 }
00556 else
00557 {
00558 TGo4Condition* conny=At(GetCurrentIndex());
00559 if(conny) rev=conny->IsVisible();
00560 }
00561 return rev;
00562 }
00563
00564 void TGo4CondArray::SetLabelDraw(Bool_t on)
00565 {
00566 if(IsMultiEdit())
00567 {
00568 TGo4Condition::SetLabelDraw(on);
00569 Int_t ii = condarr->GetLast()+1;
00570 for(Int_t i = 0; i < ii; i++)
00571 {
00572 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00573 cond->SetLabelDraw(on);
00574 }
00575 }
00576 else
00577 {
00578 TGo4Condition* conny=At(GetCurrentIndex());
00579 if(conny) conny->SetLabelDraw(on);
00580 }
00581 }
00582 Bool_t TGo4CondArray::IsLabelDraw()
00583 {
00584 Bool_t rev=kFALSE;
00585 if(IsMultiEdit())
00586 {
00587 rev=TGo4Condition::IsLabelDraw();
00588 }
00589 else
00590 {
00591 TGo4Condition* conny=At(GetCurrentIndex());
00592 if(conny) rev=conny->IsLabelDraw();
00593 }
00594 return rev;
00595 }
00596
00597
00598 void TGo4CondArray::SetLimitsDraw(Bool_t on)
00599 {
00600 if(IsMultiEdit())
00601 {
00602 TGo4Condition::SetLimitsDraw(on);
00603 Int_t ii = condarr->GetLast()+1;
00604 for(Int_t i = 0; i < ii; i++)
00605 {
00606 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00607 cond->SetLimitsDraw(on);
00608 }
00609 }
00610 else
00611 {
00612 TGo4Condition* conny=At(GetCurrentIndex());
00613 if(conny) conny->SetLimitsDraw(on);
00614 }
00615 }
00616
00617 Bool_t TGo4CondArray::IsLimitsDraw()
00618 {
00619 Bool_t rev=kFALSE;
00620 if(IsMultiEdit())
00621 {
00622 rev=TGo4Condition::IsLimitsDraw();
00623 }
00624 else
00625 {
00626 TGo4Condition* conny=At(GetCurrentIndex());
00627 if(conny) rev=conny->IsLimitsDraw();
00628 }
00629 return rev;
00630 }
00631
00632
00633 void TGo4CondArray::SetIntDraw(Bool_t on)
00634 {
00635 if(IsMultiEdit())
00636 {
00637 TGo4Condition::SetIntDraw(on);
00638 Int_t ii = condarr->GetLast()+1;
00639 for(Int_t i = 0; i < ii; i++)
00640 {
00641 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00642 cond->SetIntDraw(on);
00643 }
00644 }
00645 else
00646 {
00647 TGo4Condition* conny=At(GetCurrentIndex());
00648 if(conny) conny->SetIntDraw(on);
00649 }
00650 }
00651 Bool_t TGo4CondArray::IsIntDraw()
00652 {
00653 Bool_t rev=kFALSE;
00654 if(IsMultiEdit())
00655 {
00656 rev=TGo4Condition::IsIntDraw();
00657 }
00658 else
00659 {
00660 TGo4Condition* conny=At(GetCurrentIndex());
00661 if(conny) rev=conny->IsIntDraw();
00662 }
00663 return rev;
00664 }
00665 void TGo4CondArray::SetXMeanDraw(Bool_t on)
00666 {
00667 if(IsMultiEdit())
00668 {
00669 TGo4Condition::SetXMeanDraw(on);
00670 Int_t ii = condarr->GetLast()+1;
00671 for(Int_t i = 0; i < ii; i++)
00672 {
00673 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00674 cond->SetXMeanDraw(on);
00675 }
00676 }
00677 else
00678 {
00679 TGo4Condition* conny=At(GetCurrentIndex());
00680 if(conny) conny->SetXMeanDraw(on);
00681 }
00682 }
00683 Bool_t TGo4CondArray::IsXMeanDraw()
00684 {
00685 Bool_t rev=kFALSE;
00686 if(IsMultiEdit())
00687 {
00688 rev=TGo4Condition::IsXMeanDraw();
00689 }
00690 else
00691 {
00692 TGo4Condition* conny=At(GetCurrentIndex());
00693 if(conny) rev=conny->IsXMeanDraw();
00694 }
00695 return rev;
00696 }
00697 void TGo4CondArray::SetXRMSDraw(Bool_t on)
00698 {
00699 if(IsMultiEdit())
00700 {
00701 TGo4Condition::SetXRMSDraw(on);
00702 Int_t ii = condarr->GetLast()+1;
00703 for(Int_t i = 0; i < ii; i++)
00704 {
00705 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00706 cond->SetXRMSDraw(on);
00707 }
00708 }
00709 else
00710 {
00711 TGo4Condition* conny=At(GetCurrentIndex());
00712 if(conny) conny->SetXRMSDraw(on);
00713 }
00714 }
00715 Bool_t TGo4CondArray::IsXRMSDraw()
00716 {
00717 Bool_t rev=kFALSE;
00718 if(IsMultiEdit())
00719 {
00720 rev=TGo4Condition::IsXRMSDraw();
00721 }
00722 else
00723 {
00724 TGo4Condition* conny=At(GetCurrentIndex());
00725 if(conny) rev=conny->IsXRMSDraw();
00726 }
00727 return rev;
00728 }
00729 void TGo4CondArray::SetYMeanDraw(Bool_t on)
00730 {
00731 if(IsMultiEdit())
00732 {
00733 TGo4Condition::SetYMeanDraw(on);
00734 Int_t ii = condarr->GetLast()+1;
00735 for(Int_t i = 0; i < ii; i++)
00736 {
00737 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00738 cond->SetYMeanDraw(on);
00739 }
00740 }
00741 else
00742 {
00743 TGo4Condition* conny=At(GetCurrentIndex());
00744 if(conny) conny->SetYMeanDraw(on);
00745 }
00746 }
00747 Bool_t TGo4CondArray::IsYMeanDraw()
00748 {
00749 Bool_t rev=kFALSE;
00750 if(IsMultiEdit())
00751 {
00752 rev=TGo4Condition::IsYMeanDraw();
00753 }
00754 else
00755 {
00756 TGo4Condition* conny=At(GetCurrentIndex());
00757 if(conny) rev=conny->IsYMeanDraw();
00758 }
00759 return rev;
00760 }
00761 void TGo4CondArray::SetYRMSDraw(Bool_t on)
00762 {
00763 if(IsMultiEdit())
00764 {
00765 TGo4Condition::SetYRMSDraw(on);
00766 Int_t ii = condarr->GetLast()+1;
00767 for(Int_t i = 0; i < ii; i++)
00768 {
00769 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00770 cond->SetYRMSDraw(on);
00771 }
00772 }
00773 else
00774 {
00775 TGo4Condition* conny=At(GetCurrentIndex());
00776 if(conny) conny->SetYRMSDraw(on);
00777 }
00778 }
00779 Bool_t TGo4CondArray::IsYRMSDraw()
00780 {
00781 Bool_t rev=kFALSE;
00782 if(IsMultiEdit())
00783 {
00784 rev=TGo4Condition::IsYRMSDraw();
00785 }
00786 else
00787 {
00788 TGo4Condition* conny=At(GetCurrentIndex());
00789 if(conny) rev=conny->IsYRMSDraw();
00790 }
00791 return rev;
00792 }
00793 void TGo4CondArray::SetXMaxDraw(Bool_t on)
00794 {
00795 if(IsMultiEdit())
00796 {
00797 TGo4Condition::SetXMaxDraw(on);
00798 Int_t ii = condarr->GetLast()+1;
00799 for(Int_t i = 0; i < ii; i++)
00800 {
00801 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00802 cond->SetXMaxDraw(on);
00803 }
00804 }
00805 else
00806 {
00807 TGo4Condition* conny=At(GetCurrentIndex());
00808 if(conny) conny->SetXMaxDraw(on);
00809 }
00810 }
00811 Bool_t TGo4CondArray::IsXMaxDraw()
00812 {
00813 Bool_t rev=kFALSE;
00814 if(IsMultiEdit())
00815 {
00816 rev=TGo4Condition::IsXMaxDraw();
00817 }
00818 else
00819 {
00820 TGo4Condition* conny=At(GetCurrentIndex());
00821 if(conny) rev=conny->IsXMaxDraw();
00822 }
00823 return rev;
00824 }
00825 void TGo4CondArray::SetYMaxDraw(Bool_t on)
00826 {
00827 if(IsMultiEdit())
00828 {
00829 TGo4Condition::SetYMaxDraw(on);
00830 Int_t ii = condarr->GetLast()+1;
00831 for(Int_t i = 0; i < ii; i++)
00832 {
00833 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00834 cond->SetYMaxDraw(on);
00835 }
00836 }
00837 else
00838 {
00839 TGo4Condition* conny=At(GetCurrentIndex());
00840 if(conny) conny->SetYMaxDraw(on);
00841 }
00842 }
00843 Bool_t TGo4CondArray::IsYMaxDraw()
00844 {
00845 Bool_t rev=kFALSE;
00846 if(IsMultiEdit())
00847 {
00848 rev=TGo4Condition::IsYMaxDraw();
00849 }
00850 else
00851 {
00852 TGo4Condition* conny=At(GetCurrentIndex());
00853 if(conny) rev=conny->IsYMaxDraw();
00854 }
00855 return rev;
00856 }
00857 void TGo4CondArray::SetCMaxDraw(Bool_t on)
00858 {
00859 if(IsMultiEdit())
00860 {
00861 TGo4Condition::SetCMaxDraw(on);
00862 Int_t ii = condarr->GetLast()+1;
00863 for(Int_t i = 0; i < ii; i++)
00864 {
00865 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00866 cond->SetCMaxDraw(on);
00867 }
00868 }
00869 else
00870 {
00871 TGo4Condition* conny=At(GetCurrentIndex());
00872 if(conny) conny->SetCMaxDraw(on);
00873 }
00874 }
00875 Bool_t TGo4CondArray::IsCMaxDraw()
00876 {
00877 Bool_t rev=kFALSE;
00878 if(IsMultiEdit())
00879 {
00880 rev=TGo4Condition::IsCMaxDraw();
00881 }
00882 else
00883 {
00884 TGo4Condition* conny=At(GetCurrentIndex());
00885 if(conny) rev=conny->IsCMaxDraw();
00886 }
00887 return rev;
00888 }
00889
00890 Double_t TGo4CondArray::GetIntegral(TH1* histo, Option_t* opt)
00891 {
00892 Double_t rev=0;
00893 if(IsMultiEdit())
00894 {
00895
00896 Int_t ii = condarr->GetLast()+1;
00897 for(Int_t i = 0; i < ii; i++)
00898 {
00899 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00900 rev+=cond->GetIntegral(histo,opt);
00901 }
00902 }
00903 else
00904 {
00905 TGo4Condition* conny=At(GetCurrentIndex());
00906 if(conny) rev=conny->GetIntegral(histo,opt);
00907 }
00908 return rev;
00909 }
00910
00911 Double_t TGo4CondArray::GetMean(TH1* histo, Int_t axis)
00912 {
00913 Double_t rev=0;
00914 if(IsMultiEdit())
00915 {
00916
00917 Int_t ii = condarr->GetLast()+1;
00918 Double_t sum=0;
00919 for(Int_t i = 0; i < ii; i++)
00920 {
00921 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00922 sum+=cond->GetMean(histo,axis);
00923 rev=sum/ii;
00924 }
00925 }
00926 else
00927 {
00928 TGo4Condition* conny=At(GetCurrentIndex());
00929 if(conny) rev=conny->GetMean(histo,axis);
00930 }
00931 return rev;
00932 }
00933 Double_t TGo4CondArray::GetRMS(TH1* histo, Int_t axis)
00934 {
00935 Double_t rev=0;
00936 if(IsMultiEdit())
00937 {
00938 rev=-2;
00939 }
00940 else
00941 {
00942 TGo4Condition* conny=At(GetCurrentIndex());
00943 if(conny) rev=conny->GetRMS(histo,axis);
00944 }
00945 return rev;
00946 }
00947 Double_t TGo4CondArray::GetXMax(TH1* histo)
00948 {
00949 Double_t rev=0;
00950 if(IsMultiEdit())
00951 {
00952 rev=-2;
00953 }
00954 else
00955 {
00956 TGo4Condition* conny=At(GetCurrentIndex());
00957 if(conny) rev=conny->GetXMax(histo);
00958 }
00959 return rev;
00960 }
00961 Double_t TGo4CondArray::GetYMax(TH1* histo)
00962 {
00963 Double_t rev=0;
00964 if(IsMultiEdit())
00965 {
00966 rev=-2;
00967 }
00968 else
00969 {
00970 TGo4Condition* conny=At(GetCurrentIndex());
00971 if(conny) rev=conny->GetYMax(histo);
00972 }
00973 return rev;
00974 }
00975 Double_t TGo4CondArray::GetCMax(TH1* histo)
00976 {
00977 Double_t rev=0;
00978 if(IsMultiEdit())
00979 {
00980
00981 Int_t ii = condarr->GetLast()+1;
00982 for(Int_t i = 0; i < ii; i++)
00983 {
00984 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
00985 Double_t lmax=cond->GetCMax(histo);
00986 if(lmax>rev) rev=lmax;
00987 }
00988 }
00989 else
00990 {
00991 TGo4Condition* conny=At(GetCurrentIndex());
00992 if(conny) rev=conny->GetCMax(histo);
00993 }
00994 return rev;
00995 }
00996
00997
00998 TGo4Condition* TGo4CondArray::GetActiveCondition()
00999 {
01000 if(IsMultiEdit())
01001 return this;
01002 else
01003 return At(GetCurrentIndex());
01004 }
01005
01006
01007 void TGo4CondArray::SetChanged(Bool_t on)
01008 {
01009 for(Int_t i = 0; i <= condarr->GetLast(); i++) {
01010 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
01011 cond->SetChanged(on);
01012 }
01013 }
01014
01015
01016 Int_t TGo4CondArray::IsChanged()
01017 {
01018 Int_t cnt = 0;
01019 for(Int_t i = 0; i <= condarr->GetLast(); i++) {
01020 TGo4Condition* cond=(TGo4Condition*) condarr->UncheckedAt(i);
01021 cnt += cond->IsChanged();
01022 }
01023 return cnt;
01024 }
01025
01026
01027 Bool_t TGo4CondArray::IsPolygonType()
01028 {
01029 Bool_t rev=kFALSE;
01030 if(IsMultiEdit())
01031 {
01032 if(fiType == kGO4CONDPOLYGON)
01033 rev=kTRUE;
01034 else
01035 rev=kFALSE;
01036 }
01037 else
01038 {
01039 TGo4Condition* conny=At(GetCurrentIndex());
01040 if(conny) rev=conny->IsPolygonType();
01041 }
01042 return rev;
01043 }
01044
01045 void TGo4CondArray::SetCurrentIndex(Int_t ix)
01046 {
01047 fiSelectedCond=ix;
01048 }
01049
01050
01051 Int_t TGo4CondArray::GetCurrentIndex()
01052 {
01053 return fiSelectedCond;
01054 }
01055
01056
01057 void TGo4CondArray::Draw(Option_t* opt)
01058 {
01059 TGo4Condition::Draw(opt);
01060 Int_t selid = -1;
01061 if (opt!=0)
01062 if (strstr(opt,"sel=")==opt)
01063 selid = atoi(opt+4);
01064 for(Int_t i=0; i<GetNumber(); ++i) {
01065 TGo4Condition* con = At(i);
01066 bool selected = (selid<0) || (selid==i);
01067 if(con!=0)
01068 con->SetPainted(IsPainted() && selected);
01069 }
01070 }
01071
01072
01073
01074 void TGo4CondArray::SetPainter(TGo4ConditionPainter* painter)
01075 {
01076 if(painter==0) return;
01077 if(painter->InheritsFrom(TGo4CondArrayPainter::Class()))
01078 {
01079 if(fxPainter) delete fxPainter;
01080 fxPainter=painter;
01081 }
01082 else
01083 {
01084 TGo4Log::Warn("Could not set painter of class %s for TGo4CondArray %s",
01085 painter->ClassName(),GetName());
01086 }
01087 }
01088
01089 TGo4ConditionPainter* TGo4CondArray::CreatePainter()
01090 {
01091 TGo4ConditionPainter* painter=new TGo4CondArrayPainter(GetName());
01092 painter->SetCondition(this);
01093 return painter;
01094 }
01095
01096 Int_t TGo4CondArray::GetMemorySize()
01097 {
01098 Int_t size = sizeof(*this);
01099 if (GetName()!=0) size+=strlen(GetName());
01100 if (GetTitle()!=0) size+=strlen(GetTitle());
01101
01102 if (condarr!=0)
01103 size+=sizeof(*condarr) + condarr->GetEntriesFast() * sizeof(TObject*);
01104
01105 for (Int_t n=0;n<GetNumberOfConditions();n++) {
01106 TGo4Condition* cond = At(n);
01107 if (cond!=0) size+=cond->GetMemorySize();
01108
01109 }
01110
01111
01112 return size;
01113 }
01114
01115 void TGo4CondArray::SavePrimitive(std::ostream& out, Option_t* opt)
01116 {
01117 static int cnt = 0;
01118 TString extraargs = TString::Format(", %d, \"%s\"", GetNumber(), GetType());
01119 TString varname = MakeScript(out, Form("condarr%d", cnt++), opt, extraargs.Data());
01120
01121
01122 TString options = opt;
01123 const char* subname = strstr(opt, "name:");
01124 if (subname!=0) options.Resize(subname - opt);
01125
01126 for (int n=0; n<GetNumber(); n++) {
01127 TString subopt = options + TString::Format(" nocreate name:%s->At(%d)", varname.Data(), n);
01128 At(n)->SavePrimitive(out, subopt.Data());
01129 out << std::endl;
01130 }
01131 }