Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4CondArray.cxx

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

Generated on Fri Nov 28 12:59:06 2008 for Go4-v3.04-1 by  doxygen 1.4.2