00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4Condition.h"
00015
00016
00017 #include "TH1.h"
00018 #include "TROOT.h"
00019 #include "TList.h"
00020 #include "TCutG.h"
00021 #include "TVirtualPad.h"
00022 #include "Riostream.h"
00023 #include "snprintf.h"
00024
00025 #include "TGo4Log.h"
00026 #include "TGo4ConditionPainter.h"
00027
00028 const Double_t TGo4Condition::fgdUPDATEEPSILON=0.01;
00029
00030 Bool_t TGo4Condition::fgbLABELDRAW=kTRUE;
00031 Bool_t TGo4Condition::fgbLIMITSDRAW=kTRUE;
00032 Bool_t TGo4Condition::fgbINTDRAW=kTRUE;
00033 Bool_t TGo4Condition::fgbXMEANDRAW=kTRUE;
00034 Bool_t TGo4Condition::fgbXRMSDRAW=kTRUE;
00035 Bool_t TGo4Condition::fgbYMEANDRAW=kFALSE;
00036 Bool_t TGo4Condition::fgbYRMSDRAW=kFALSE;
00037 Bool_t TGo4Condition::fgbXMAXDRAW=kTRUE;
00038 Bool_t TGo4Condition::fgbYMAXDRAW=kFALSE;
00039 Bool_t TGo4Condition::fgbCMAXDRAW=kTRUE;
00040 TString TGo4Condition::fgxNUMFORMAT="%.4E";
00041
00042
00043
00044
00045
00046 TGo4Condition::TGo4Condition() :
00047 TNamed(),
00048 TAttLine(),
00049 TAttFill(),
00050 fxPainter(0),
00051 fxCutHis(0),
00052 fxHisto(0),
00053 fiIsChanged(0)
00054 {
00055 GO4TRACE((15,"TGo4Condition::TGo4Condition()",__LINE__, __FILE__));
00056 fiDim=0;
00057 fbEnabled = false;
00058 fbResult = true;
00059 fbTrue = true;
00060 fbFalse = false;
00061 fbMarkReset = false;
00062 fiCounts = 0;
00063 fiTrueCounts= 0;
00064 fbVisible=true;
00065 fbMultiEdit= true;
00066 fbHistogramLink=false;
00067 fdUpdateEpsilon=fgdUPDATEEPSILON;
00068 fbIsPainted=kFALSE;
00069 fbOwnedByEditor=kFALSE;
00070 fbStreamedCondition=kTRUE;
00071 InitLabelStyle();
00072 }
00073
00074
00075 TGo4Condition::TGo4Condition(const char* name, const char* title) :
00076 TNamed(name, title),
00077 TAttLine(),
00078 TAttFill(),
00079 fxPainter(0),
00080 fxCutHis(0),
00081 fxHisto(0),
00082 fiIsChanged(0)
00083 {
00084 GO4TRACE((15,"TGo4Condition::TGo4Condition(const char*)",__LINE__, __FILE__));
00085 fiDim=0;
00086 fbEnabled = false;
00087 fbResult = true;
00088 fbTrue = true;
00089 fbFalse = false;
00090 fbMarkReset = false;
00091 fiCounts = 0;
00092 fiTrueCounts = 0;
00093 fbVisible=true;
00094 fbMultiEdit= true;
00095 fbHistogramLink=false;
00096 fdUpdateEpsilon=fgdUPDATEEPSILON;
00097 fbIsPainted=kFALSE;
00098 fbOwnedByEditor=kFALSE;
00099 fbStreamedCondition=kFALSE;
00100 InitLabelStyle();
00101 }
00102
00103
00104 TGo4Condition::~TGo4Condition()
00105 {
00106 GO4TRACE((15,"TGo4Condition::~TGo4Condition()",__LINE__, __FILE__));
00107
00108 UnDraw("reset");
00109
00110 if(fxPainter) {
00111 delete fxPainter;
00112 fxPainter = 0;
00113 }
00114 if(fxCutHis) {
00115 delete fxCutHis;
00116 fxCutHis = 0;
00117 }
00118 }
00119
00120 Bool_t TGo4Condition::Test()
00121 {
00122 fiCounts++;
00123 return true;
00124 }
00125
00126
00127 void TGo4Condition::AddCondition(TGo4Condition* next)
00128 {
00129 GO4TRACE((14,"TGo4Condition::AddCondition(TGo4Condition*)",__LINE__, __FILE__));
00130 }
00131
00132 void TGo4Condition::IncTrueCounts()
00133 {
00134 GO4TRACE((12,"TGo4Condition::IncTrueCounts()",__LINE__, __FILE__));
00135 fiTrueCounts++;
00136 }
00137
00138 void TGo4Condition::IncCounts()
00139 {
00140 GO4TRACE((12,"TGo4Condition::IncCounts()",__LINE__, __FILE__));
00141 fiCounts++;
00142 }
00143
00144 Int_t TGo4Condition::Counts()
00145 {
00146 GO4TRACE((12,"TGo4Condition::Counts()",__LINE__, __FILE__));
00147 return fiCounts;
00148 }
00149
00150 Int_t TGo4Condition::TrueCounts()
00151 {
00152 GO4TRACE((12,"TGo4Condition::TrueCounts()",__LINE__, __FILE__));
00153 return fiTrueCounts;
00154 }
00155
00156 void TGo4Condition::ResetCounts()
00157 {
00158 GO4TRACE((12,"TGo4Condition::ResetCounts()",__LINE__, __FILE__));
00159 fiTrueCounts=0;
00160 fiCounts=0;
00161 }
00162
00163 void TGo4Condition::SetCounts(Int_t truecounts, Int_t counts)
00164 {
00165 GO4TRACE((12,"TGo4Condition::SetCounts()",__LINE__, __FILE__));
00166 fiTrueCounts=truecounts;
00167 fiCounts=counts;
00168 }
00169
00170
00171
00172 void TGo4Condition::Invert(Bool_t on)
00173 {
00174 GO4TRACE((12,"TGo4Condition::Invert",__LINE__, __FILE__));
00175 fbTrue = on ^ true;
00176 fbFalse = on ^ false;
00177 }
00178
00179
00180 void TGo4Condition::PrintCondition(Bool_t full)
00181 {
00182 Float_t perc;
00183 char line[128];
00184 char num[64];
00185 if(fiCounts==0)perc=0.0;
00186 else perc=100.0/fiCounts*fiTrueCounts;
00187 std::cout << "Name:" << GetName()
00188 << " type:" << ClassName()
00189 << " title:" << GetTitle() << std::endl;
00190 if(fbHistogramLink)
00191 std::cout << "Connected to histogram " << fxHistoName << std::endl;
00192 if(fbEnabled) {
00193 strcpy(line,"Is Checked ");
00194 } else {
00195 if(fbResult) strcpy(line,"Always True ");
00196 else strcpy(line,"Always False ");
00197 }
00198 if(fbTrue) strcat(line,"normal ");
00199 else strcat(line,"inverse ");
00200 snprintf(num,63,", tested: %8d true: %8d is %3.0f%%",fiCounts,fiTrueCounts,perc);
00201 strcat(line,num);
00202 std::cout << line << std::endl;
00203 }
00204
00205 void TGo4Condition::PrintBar()
00206 {
00207 Float_t perc;
00208 char line[128];
00209 char num[64];
00210 strcpy(num,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
00211 Char_t *pc;
00212 if(fiCounts==0) perc=0.0;
00213 else perc=100.0/fiCounts*fiTrueCounts;
00214 pc=num + (Int_t)perc/2;
00215 *pc=0;
00216 snprintf(line,127,"%-24s %8d %3.0f%% |%-50s|",GetName(),fiCounts,perc,num);
00217 *pc='+';
00218 std::cout << line << std::endl;
00219 }
00220
00221 void TGo4Condition::Print(Option_t* opt) const
00222 {
00223
00224 TGo4Condition* localthis=const_cast<TGo4Condition*>(this);
00225 TString option=opt;
00226 option.ToLower();
00227 if(option.IsNull() || option=="*")
00228 {
00229
00230 localthis->PrintBar();
00231 }
00232 else
00233 {
00234
00235 TString textbuffer="\nCondition ";
00236 textbuffer+=localthis->GetName();
00237 if(localthis->IsPolygonType())
00238 {
00239 textbuffer+=" (Polygon type, 2-dim)";
00240 }
00241 else
00242 {
00243 textbuffer+=" (Window type,";
00244 if(localthis->GetActiveCondition()->GetDimension()>1)
00245 textbuffer+=" 2-dim)";
00246 else
00247 textbuffer+=" 1-dim)";
00248 }
00249
00250
00251
00252 if(option.Contains("limits"))
00253 textbuffer +=
00254 TString::Format("\n! Xlow: \t\tXup: \t\tYlow: \t\tYup:\n %.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t",
00255 localthis->GetXLow(),localthis->GetXUp(),localthis->GetYLow(),localthis->GetYUp());
00256
00257 if(option.Contains("flags"))
00258 textbuffer +=
00259 TString::Format("\n! Status:\n! Enab.: \tVis.: \tRes.: \tTrue: \tCnts: \tTrueCnts:\n %d\t\t%d\t%d\t%d\t%d\t%d",
00260 localthis->fbEnabled, localthis->IsVisible(), localthis->fbResult, localthis->fbTrue,
00261 localthis->Counts(), localthis->TrueCounts());
00262
00263 if(option.Contains("stats"))
00264 {
00265
00266
00267 textbuffer+="\n! with";
00268 TH1* hist=localthis->GetWorkHistogram();
00269 if(hist)
00270 {
00271 textbuffer+=" histogram: ";
00272 textbuffer+=hist->GetName();
00273 textbuffer +=
00274 TString::Format("\n! Int:\t\tXmax:\t\tYmax:\t\tCmax:\t\tXmean:\t\tYmean:\t\tXrms:\t\tYrms:\n %.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f\t\t%.2f",
00275 localthis->GetIntegral(hist), localthis->GetXMax(hist),localthis->GetYMax(hist), localthis->GetCMax(hist),
00276 localthis->GetMean(hist,1), localthis->GetMean(hist,2), localthis->GetRMS(hist,1), localthis->GetRMS(hist,2));
00277 }
00278 else
00279 {
00280 textbuffer+="out histogram";
00281 }
00282 }
00283
00284 if(option.Contains("go4log"))
00285 {
00286 TGo4Log::Message(1,textbuffer.Data());
00287 }
00288 else
00289 {
00290 std::cout << textbuffer.Data() << std::endl;
00291 }
00292 }
00293 }
00294
00295
00296 Bool_t TGo4Condition::UpdateFrom(TGo4Condition * cond, Bool_t counts)
00297 {
00298 fbTrue = cond->TGo4Condition::IsTrue();
00299 fbFalse = cond->TGo4Condition::IsFalse();
00300 fbResult = cond->TGo4Condition::FixedResult();
00301 fbEnabled = cond->TGo4Condition::IsEnabled();
00302 fbMarkReset = cond->fbMarkReset;
00303 fbVisible=cond->TGo4Condition::IsVisible();
00304 fbLabelDraw=cond->TGo4Condition::IsLabelDraw();
00305 fbMultiEdit=cond->TGo4Condition::IsMultiEdit();
00306 fbIntDraw= cond->TGo4Condition::IsIntDraw();
00307 fbXMeanDraw= cond->TGo4Condition::IsXMeanDraw();
00308 fbXRMSDraw= cond->TGo4Condition::IsXRMSDraw();
00309 fbYMeanDraw= cond->TGo4Condition::IsYMeanDraw();
00310 fbYRMSDraw= cond->TGo4Condition::IsYRMSDraw();
00311 fbXMaxDraw= cond->TGo4Condition::IsXMaxDraw();
00312 fbYMaxDraw= cond->TGo4Condition::IsYMaxDraw();
00313 fbCMaxDraw= cond->TGo4Condition::IsCMaxDraw();
00314 fbHistogramLink=cond->TGo4Condition::IsHistogramLink();
00315 fxHistoName=cond->fxHistoName;
00316 fdUpdateEpsilon= cond->fdUpdateEpsilon;
00317 fiDim=cond->GetDimension();
00318 if(counts){
00319 fiCounts = cond->TGo4Condition::Counts();
00320 fiTrueCounts = cond->TGo4Condition::TrueCounts();
00321 fbMarkReset = false;
00322 }
00323 if(fbMarkReset){
00324 ResetCounts();
00325 fbMarkReset = false;
00326 }
00327
00328 return kTRUE;
00329 }
00330
00331 void TGo4Condition::GetValues(Int_t & dim, Double_t & xmin, Double_t & xmax, Double_t & ymin, Double_t & ymax)
00332 {
00333 xmin = GetXLow();
00334 xmax = GetXUp();
00335 ymin = GetYLow();
00336 ymax = GetYUp();
00337 dim = GetDimension();
00338
00339 }
00340 Double_t TGo4Condition::GetXLow(){return 0;}
00341 Double_t TGo4Condition::GetXUp(){return 0;}
00342 Double_t TGo4Condition::GetYLow(){return 0;}
00343 Double_t TGo4Condition::GetYUp(){return 0;}
00344 TCutG* TGo4Condition::GetCut(Bool_t owner){ return 0;}
00345 Bool_t TGo4Condition::IsPolygonType(){return kFALSE;}
00346 Bool_t TGo4Condition::IsArrayType(){return kFALSE;}
00347 TGo4Condition* TGo4Condition::GetActiveCondition(){return this;}
00348
00349 void TGo4Condition::SetCurrentIndex(Int_t) { }
00350 Int_t TGo4Condition::GetCurrentIndex()
00351 {
00352 return 0;
00353 }
00354
00355 Int_t TGo4Condition::GetNumberOfConditions()
00356 {
00357 return 1;
00358 }
00359
00360 Int_t TGo4Condition::GetMemorySize()
00361 {
00362 Int_t size = sizeof(*this);
00363 if (GetName()!=0) size+=strlen(GetName());
00364 if (GetTitle()!=0) size+=strlen(GetTitle());
00365 return size;
00366 }
00367
00368 void TGo4Condition::MarkReset(Bool_t on)
00369 {
00370 fbMarkReset = on;
00371 }
00372 void TGo4Condition::Clear(Option_t* opt){
00373 ResetCounts();
00374 }
00375
00376 void TGo4Condition::GetFlags(Bool_t* enabled, Bool_t* lastresult, Bool_t* markreset,
00377 Bool_t* result, Bool_t* truevalue, Bool_t* falsevalue)
00378 {
00379 *enabled=fbEnabled;
00380 *lastresult=fbLastResult;
00381 *markreset=fbMarkReset;
00382 *result=fbResult;
00383 *truevalue=fbTrue;
00384 *falsevalue=fbFalse;
00385 }
00386 void TGo4Condition::SetFlags(Bool_t enabled, Bool_t lastresult, Bool_t markreset,
00387 Bool_t result, Bool_t truevalue, Bool_t falsevalue)
00388 {
00389 fbEnabled=enabled;
00390 fbLastResult=lastresult;
00391 fbMarkReset=markreset;
00392 fbResult=result;
00393 fbTrue=truevalue;
00394 fbFalse=falsevalue;
00395 }
00396
00397
00398
00399 Double_t TGo4Condition::GetIntegral(TH1* histo, Option_t* opt)
00400 {
00401 return 0;
00402 }
00403
00404 Double_t TGo4Condition::GetMean(TH1* histo, Int_t axis)
00405 {
00406 return 0;
00407 }
00408 Double_t TGo4Condition::GetRMS(TH1* histo, Int_t axis)
00409 {
00410 return 0;
00411 }
00412 Double_t TGo4Condition::GetXMax(TH1* histo)
00413 {
00414 return 0;
00415 }
00416 Double_t TGo4Condition::GetYMax(TH1* histo)
00417 {
00418 return 0;
00419 }
00420 Double_t TGo4Condition::GetCMax(TH1* histo)
00421 {
00422 return 0;
00423 }
00424
00425 void TGo4Condition::Disable(Bool_t result)
00426 {
00427 fbEnabled=kFALSE;
00428 fbResult=result;
00429 }
00430
00431 void TGo4Condition::Enable()
00432 {
00433 fbEnabled=kTRUE;
00434 }
00435
00436
00437 void TGo4Condition::SetVisible(Bool_t on)
00438 {
00439 fbVisible=on;
00440 }
00441
00442 Bool_t TGo4Condition::IsVisible()
00443 {
00444 return fbVisible;
00445 }
00446
00447 void TGo4Condition::SetHistogramLink(Bool_t on)
00448 {
00449 fbHistogramLink=on;
00450 }
00451
00452 Bool_t TGo4Condition::IsHistogramLink()
00453 {
00454 return (Bool_t) fbHistogramLink;
00455 }
00456
00457 void TGo4Condition::SetLabelDraw(Bool_t on)
00458 {
00459 fbLabelDraw=on;
00460 }
00461
00462 Bool_t TGo4Condition::IsLabelDraw()
00463 {
00464 return fbLabelDraw;
00465 }
00466
00467 void TGo4Condition::SetLimitsDraw(Bool_t on)
00468 {
00469 fbLimitsDraw=on;
00470 }
00471
00472 Bool_t TGo4Condition::IsLimitsDraw()
00473 {
00474 return fbLimitsDraw;
00475 }
00476
00477 void TGo4Condition::SetIntDraw(Bool_t on)
00478 {
00479 fbIntDraw=on;
00480 }
00481 Bool_t TGo4Condition::IsIntDraw()
00482 {
00483 return fbIntDraw;
00484 }
00485 void TGo4Condition::SetXMeanDraw(Bool_t on)
00486 {
00487 fbXMeanDraw=on;
00488 }
00489 Bool_t TGo4Condition::IsXMeanDraw()
00490 {
00491 return fbXMeanDraw;
00492 }
00493 void TGo4Condition::SetXRMSDraw(Bool_t on)
00494 {
00495 fbXRMSDraw=on;
00496 }
00497 Bool_t TGo4Condition::IsXRMSDraw()
00498 {
00499 return fbXRMSDraw;
00500 }
00501 void TGo4Condition::SetYMeanDraw(Bool_t on)
00502 {
00503 fbYMeanDraw=on;
00504 }
00505 Bool_t TGo4Condition::IsYMeanDraw()
00506 {
00507 return fbYMeanDraw;
00508 }
00509 void TGo4Condition::SetYRMSDraw(Bool_t on)
00510 {
00511 fbYRMSDraw=on;
00512 }
00513 Bool_t TGo4Condition::IsYRMSDraw()
00514 {
00515 return fbYRMSDraw;
00516 }
00517 void TGo4Condition::SetXMaxDraw(Bool_t on)
00518 {
00519 fbXMaxDraw=on;
00520 }
00521 Bool_t TGo4Condition::IsXMaxDraw()
00522 {
00523 return fbXMaxDraw;
00524 }
00525 void TGo4Condition::SetYMaxDraw(Bool_t on)
00526 {
00527 fbYMaxDraw=on;
00528 }
00529 Bool_t TGo4Condition::IsYMaxDraw()
00530 {
00531 return fbYMaxDraw;
00532 }
00533 void TGo4Condition::SetCMaxDraw(Bool_t on)
00534 {
00535 fbCMaxDraw=on;
00536 }
00537 Bool_t TGo4Condition::IsCMaxDraw()
00538 {
00539 return fbCMaxDraw;
00540 }
00541
00542 const char* TGo4Condition::GetLabelNumFormat()
00543 {
00544 return fxNumFormat.Data();
00545 }
00546 void TGo4Condition::SetLabelNumFormat(const char* fmt)
00547 {
00548 fxNumFormat=fmt;
00549 }
00550
00551
00552 void TGo4Condition::SetHistogram(const char* name)
00553 {
00554 if ((name==0) || (*name==0)) {
00555 fxHistoName = "";
00556 fbHistogramLink = false;
00557 } else {
00558 fxHistoName = name;
00559 fbHistogramLink = true;
00560 }
00561 }
00562
00563 const char* TGo4Condition::GetLinkedHistogram()
00564 {
00565 return fxHistoName.Data();
00566 }
00567
00568 void TGo4Condition::SetPainter(TGo4ConditionPainter*)
00569 {
00570
00571
00572
00573 }
00574
00575
00576 void TGo4Condition::Paint(Option_t* opt)
00577 {
00579 if(fbStreamedCondition) {
00580 SetPainted(kTRUE);
00581 fbStreamedCondition=kFALSE;
00582 }
00583
00584 if(!IsPainted()) return;
00585 if(fxPainter==0) fxPainter=CreatePainter();
00586
00587 if(fxPainter!=0)
00588 {
00589 fxPainter->PaintCondition(opt);
00590 fxPainter->PaintLabel(opt);
00591 }
00592 }
00593
00594 void TGo4Condition::Draw(Option_t* opt)
00595 {
00596 if(TGo4Condition::IsVisible()) {
00597 if(gPad && gPad->GetListOfPrimitives()->FindObject(this)==0) {
00598 UnDraw();
00599 AppendPad(opt);
00600 }
00601 SetPainted(kTRUE);
00602 } else
00603 UnDraw(opt);
00604 }
00605
00606 void TGo4Condition::UnDraw(Option_t* opt)
00607 {
00608 SetPainted(kFALSE);
00609 gROOT->GetListOfCanvases()->RecursiveRemove(this);
00610
00611 if(fxPainter==0) fxPainter=CreatePainter();
00612
00613 if(fxPainter!=0) {
00614 fxPainter->UnPaintCondition(opt);
00615
00616 fxPainter->UnPaintLabel();
00617 }
00618 }
00619
00620 void TGo4Condition::Pop()
00621 {
00622 if(fxPainter!=0) fxPainter->DisplayToFront();
00623 }
00624
00625 TGo4ConditionPainter* TGo4Condition::CreatePainter()
00626 {
00627 return 0;
00628 }
00629
00630 void TGo4Condition::SaveLabelStyle()
00631 {
00632 TGo4Condition::fgbLABELDRAW=fbLabelDraw;
00633 TGo4Condition::fgbLIMITSDRAW=fbLimitsDraw;
00634 TGo4Condition::fgbINTDRAW=fbIntDraw;
00635 TGo4Condition::fgbXMEANDRAW=fbXMeanDraw;
00636 TGo4Condition::fgbXRMSDRAW=fbXRMSDraw;
00637 TGo4Condition::fgbYMEANDRAW=fbYMeanDraw;
00638 TGo4Condition::fgbYRMSDRAW=fbYRMSDraw;
00639 TGo4Condition::fgbXMAXDRAW=fbXMaxDraw;
00640 TGo4Condition::fgbYMAXDRAW=fbYMaxDraw;
00641 TGo4Condition::fgbCMAXDRAW=fbCMaxDraw;
00642 TGo4Condition::fgxNUMFORMAT=fxNumFormat;
00643 }
00644
00645 void TGo4Condition::InitLabelStyle()
00646 {
00647 fbLabelDraw=TGo4Condition::fgbLABELDRAW;
00648 fbLimitsDraw=TGo4Condition::fgbLIMITSDRAW;
00649 fbIntDraw=TGo4Condition::fgbINTDRAW;
00650 fbXMeanDraw=TGo4Condition::fgbXMEANDRAW;
00651 fbXRMSDraw=TGo4Condition::fgbXRMSDRAW;
00652 fbYMeanDraw=TGo4Condition::fgbYMEANDRAW;
00653 fbYRMSDraw=TGo4Condition::fgbYRMSDRAW;
00654 fbXMaxDraw=TGo4Condition::fgbXMAXDRAW;
00655 fbYMaxDraw=TGo4Condition::fgbYMAXDRAW;
00656 fbCMaxDraw=TGo4Condition::fgbCMAXDRAW;
00657 fxNumFormat=TGo4Condition::fgxNUMFORMAT;
00658 }
00659
00660 void TGo4Condition::ResetLabel(Option_t* opt)
00661 {
00662 if(fxPainter) {
00663 fxPainter->UnPaintLabel(opt);
00664 fxPainter->PaintLabel();
00665 }
00666 }
00667
00668 void TGo4Condition::SetWorkHistogram(TH1* histo)
00669 {
00670 fxHisto=histo;
00671 delete fxCutHis;
00672 fxCutHis=0;
00673 }
00674
00675 void TGo4Condition::DeletePainter()
00676 {
00677 if (fxPainter!=0) {
00678 delete fxPainter;
00679 fxPainter = 0;
00680 }
00681 }
00682
00683 const char* TGo4Condition::MakeScript(std::ostream& out, const char* varname, Option_t* opt, const char* arrextraargs)
00684 {
00685 Bool_t savemacro = (opt!=0) && (strstr(opt,"savemacro")!=0);
00686 Bool_t saveprefix = savemacro;
00687
00688 const char* subname = strstr(opt, "name:");
00689 if (subname != 0) { varname = subname + 5; saveprefix = kFALSE; }
00690
00691 if (saveprefix) {
00692 out << Form(" %s* %s = (%s*) go4->GetAnalysisCondition(\"%s\",\"%s\");",
00693 ClassName(), varname, ClassName(), GetName(), ClassName()) << std::endl;
00694 out << Form(" if (%s==0) {", varname) << std::endl;
00695 out << Form(" TGo4Log::Error(\"Could not find condition %s of class %s\");", GetName(), ClassName()) << std::endl;
00696 out << Form(" return;") << std::endl;
00697 out << Form(" }") << std::endl << std::endl;
00698 out << Form(" TGo4Log::Info(\"Set condition %s as saved at %s\");",
00699 GetName(),TDatime().AsString()) << std::endl << std::endl;
00700 } else
00701 if (!savemacro && ((opt==0) || (strstr(opt, "nocreate")==0))) {
00702 out << Form(" %s* %s = new %s(\"%s\"%s);", ClassName(), varname, ClassName(), GetName(), (arrextraargs ? arrextraargs : "")) << std::endl << std::endl;
00703 }
00704
00705 if (arrextraargs==0) {
00706
00707 Bool_t enabled,last,mark,result,vtrue,vfalse;
00708 GetFlags(&enabled, &last, &mark, &result, &vtrue, &vfalse);
00709
00710 out << " // SetFlags(enabled,last,mark,result,vtrue,vfalse);" << std::endl;
00711
00712 out << Form(" %s%s->SetFlags(%s, %s, %s, %s, %s, %s);",
00713 savemacro ? "if (flags) " : "", varname,
00714 enabled ? "kTRUE" : "kFALSE",
00715 last ? "kTRUE" : "kFALSE",
00716 mark ? "kTRUE" : "kFALSE",
00717 result ? "kTRUE" : "kFALSE",
00718 vtrue ? "kTRUE" : "kFALSE",
00719 vfalse ? "kTRUE" : "kFALSE") << std::endl;
00720
00721 out << Form(" %s%s->SetCounts(%d, %d);",
00722 savemacro ? "if (counters) " : "", varname,
00723 TrueCounts(), Counts()) << std::endl;
00724
00725 if (savemacro)
00726 out << Form(" if (reset) %s->ResetCounts();", varname) << std::endl;
00727 }
00728
00729 return varname;
00730 }