Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TStatsFeedback.cxx
Go to the documentation of this file.
1// @(#)root/proofplayer:$Id$
2// Author: G. Ganis May 2012
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12
13/** \class TStatsFeedback
14\ingroup proofkernel
15
16Utility class to display PROOF stats feedback histos during queries
17
18*/
19
20#include "TStatsFeedback.h"
21
22#include "TError.h"
23#include "TH1.h"
24#include "TH2.h"
25#include "THashList.h"
26#include "TProof.h"
27#include "TProofDebug.h"
28#include "TROOT.h"
29#include "TSeqCollection.h"
30#include "TStyle.h"
31#include "TVirtualPad.h"
32
34
35
36////////////////////////////////////////////////////////////////////////////////
37/// Constructor
38
40{
41 if (proof == 0) proof = gProof;
42
43 TProof *p = dynamic_cast<TProof*>(proof);
44 if (p == 0) {
45 Error("TStatsFeedback", "no valid proof session found");
47 return;
48 }
49 fProof = p;
51
52 if (!(proof->Connect("Feedback(TList*)", "TStatsFeedback",
53 this, "Feedback(TList*)"))) {
54 Error("TStatsFeedback", "Connect() failed");
56 return;
57 }
58}
59
60////////////////////////////////////////////////////////////////////////////////
61/// Destructor
62
64{
65 // Required since we overload TObject::Hash.
67
68 fProof->Disconnect("Feedback(TList*)", this, "Feedback(TList*");
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Display feedback
73
75{
76 TSeqCollection *canvases = gROOT->GetListOfCanvases();
77
78 PDB(kFeedback,1) Info("Feedback", "%d Objects", objs->GetSize());
79
80 // Attach to the histograms we want to plot
81 TH1D *hevt = 0, *hpck = 0;
82 TH1I *hass = 0;
83 TIter next(objs);
84 TObject *o = 0;
85 while((o = next())) {
86 if (!strcmp(o->GetName(), "PROOF_EventsHist")) {
87 hevt = dynamic_cast<TH1D *>(o);
88 } else if (!strcmp(o->GetName(), "PROOF_PacketsHist")) {
89 hpck = dynamic_cast<TH1D *>(o);
90 } else if (!strcmp(o->GetName(), "PROOF_ProcPcktHist")) {
91 hass = dynamic_cast<TH1I *>(o);
92 }
93 if (hevt && hpck && hass) break;
94 }
95 if (!hevt && !hpck && !hass) {
96 Warning("Feedback", "none of the requested histograms has been found!");
97 return;
98 }
99
100 // Number of histograms
101 Int_t nh = 3;
102 if (!hass) nh = 2;
103 // Create or attach to canvas
104 TString cvnm = TString::Format("Stats: %s", fProof->GetSessionTag());
105 TVirtualPad *cv = 0;
106 if (gROOT->GetListOfCanvases())
107 cv = (TVirtualPad *) canvases->FindObject(cvnm.Data());
108 if (cv && nh == 3 && !cv->GetPad(3)) SafeDelete(cv);
109 if (!cv) {
110 Int_t h = (nh == 3) ? 600 : 400;
111 TString cvcmd = TString::Format("new TCanvas(\"%s\", \"Feedback Stats\",10,300,600,%d)",
112 cvnm.Data(), h);
113 if (!(cv = (TVirtualPad *) gROOT->ProcessLine(cvcmd))) {
114 Warning("Feedback", "could not create canvas!");
115 return;
116 }
117 PDB(kFeedback,2) Info("Feedback", "created canvas %s", cvnm.Data());
118 // Create pads
119 cv->Divide(1, nh);
120 } else {
121 cv->cd();
122 PDB(kFeedback,2) Info("Feedback", "using canvas %s", cvnm.Data());
123 }
124 TVirtualPad *pd1 = (TVirtualPad *) cv->GetPad(1);
125 TVirtualPad *pd2 = (TVirtualPad *) cv->GetPad(2);
126 TVirtualPad *pd3 = (nh == 3) ? (TVirtualPad *) cv->GetPad(3) : 0;
127
128 UInt_t optstat = gStyle->GetOptStat();
129 gStyle->SetOptStat(11);
130 // Plot
131 if (hevt) {
132 if (pd1) pd1->cd();
133 hevt->SetFillColor(kGreen);
134 hevt->DrawCopy();
135 }
136 if (hpck) {
137 if (pd2) pd2->cd();
138 hpck->SetFillColor(kAzure-5);
139 hpck->DrawCopy();
140 }
141 if (hass) {
142 if (pd3) pd3->cd();
143 hass->SetFillColor(kGray);
144 hass->SetMaximum(2);
145 hass->DrawCopy();
146 }
147
148 cv->cd();
149 cv->Update();
150 gStyle->SetOptStat(optstat);
151}
#define SafeDelete(p)
Definition RConfig.hxx:542
#define h(i)
Definition RSha256.hxx:106
#define ClassImp(name)
Definition Rtypes.h:377
@ kGray
Definition Rtypes.h:65
@ kGreen
Definition Rtypes.h:66
@ kAzure
Definition Rtypes.h:67
winID h TVirtualViewer3D TVirtualGLPainter p
#define PDB(mask, level)
Definition TProofDebug.h:56
R__EXTERN TProof * gProof
Definition TProof.h:1077
#define gROOT
Definition TROOT.h:406
R__EXTERN TStyle * gStyle
Definition TStyle.h:433
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:37
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
1-D histogram with a double per channel (see TH1 documentation)
Definition TH1.h:664
1-D histogram with an int per channel (see TH1 documentation)
Definition TH1.h:539
virtual void SetMaximum(Double_t maximum=-1111)
Definition TH1.h:403
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
Definition TH1.cxx:3109
A doubly linked list.
Definition TList.h:38
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:439
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:962
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:780
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:976
@ kInvalidObject
if object ctor succeeded but object should not be used
Definition TObject.h:72
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:950
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition TProof.h:316
const char * GetSessionTag() const
Definition TProof.h:909
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:869
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
Disconnects signal of this object from slot of receiver.
Sequenceable collection abstract base class.
Utility class to display PROOF stats feedback histos during queries.
~TStatsFeedback() override
Destructor.
TStatsFeedback(TProof *proof=0)
Constructor.
void Feedback(TList *objs)
Display feedback.
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
Int_t GetOptStat() const
Definition TStyle.h:243
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Definition TStyle.cxx:1636
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual void Update()=0
virtual TVirtualPad * GetPad(Int_t subpadnumber) const =0
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)=0
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.
Definition TROOT.h:395