Logo ROOT   6.16/01
Reference Guide
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 "TObjString.h"
27#include "TProof.h"
28#include "TProofDebug.h"
29#include "TROOT.h"
30#include "TSeqCollection.h"
31#include "TStyle.h"
32#include "TVirtualPad.h"
33
35
36
37////////////////////////////////////////////////////////////////////////////////
38/// Constructor
39
41{
42 if (proof == 0) proof = gProof;
43
44 TProof *p = dynamic_cast<TProof*>(proof);
45 if (p == 0) {
46 Error("TStatsFeedback", "no valid proof session found");
48 return;
49 }
50 fProof = p;
52
53 if (!(proof->Connect("Feedback(TList*)", "TStatsFeedback",
54 this, "Feedback(TList*)"))) {
55 Error("TStatsFeedback", "Connect() failed");
57 return;
58 }
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// Destructor
63
65{
66 // Required since we overload TObject::Hash.
68
69 fProof->Disconnect("Feedback(TList*)", this, "Feedback(TList*");
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// Display feedback
74
76{
77 TSeqCollection *canvases = gROOT->GetListOfCanvases();
78
79 PDB(kFeedback,1) Info("Feedback", "%d Objects", objs->GetSize());
80
81 // Attach to the histograms we want to plot
82 TH1D *hevt = 0, *hpck = 0;
83 TH1I *hass = 0;
84 TIter next(objs);
85 TObject *o = 0;
86 while((o = next())) {
87 if (!strcmp(o->GetName(), "PROOF_EventsHist")) {
88 hevt = dynamic_cast<TH1D *>(o);
89 } else if (!strcmp(o->GetName(), "PROOF_PacketsHist")) {
90 hpck = dynamic_cast<TH1D *>(o);
91 } else if (!strcmp(o->GetName(), "PROOF_ProcPcktHist")) {
92 hass = dynamic_cast<TH1I *>(o);
93 }
94 if (hevt && hpck && hass) break;
95 }
96 if (!hevt && !hpck && !hass) {
97 Warning("Feedback", "none of the requested histograms has been found!");
98 return;
99 }
100
101 // Number of histograms
102 Int_t nh = 3;
103 if (!hass) nh = 2;
104 // Create or attach to canvas
105 TString cvnm = TString::Format("Stats: %s", fProof->GetSessionTag());
106 TVirtualPad *cv = 0;
107 if (gROOT->GetListOfCanvases())
108 cv = (TVirtualPad *) canvases->FindObject(cvnm.Data());
109 if (cv && nh == 3 && !cv->GetPad(3)) SafeDelete(cv);
110 if (!cv) {
111 Int_t h = (nh == 3) ? 600 : 400;
112 TString cvcmd = TString::Format("new TCanvas(\"%s\", \"Feedback Stats\",10,300,600,%d)",
113 cvnm.Data(), h);
114 if (!(cv = (TVirtualPad *) gROOT->ProcessLine(cvcmd))) {
115 Warning("Feedback", "could not create canvas!");
116 return;
117 }
118 PDB(kFeedback,2) Info("Feedback", "created canvas %s", cvnm.Data());
119 // Create pads
120 cv->Divide(1, nh);
121 } else {
122 cv->cd();
123 PDB(kFeedback,2) Info("Feedback", "using canvas %s", cvnm.Data());
124 }
125 TVirtualPad *pd1 = (TVirtualPad *) cv->GetPad(1);
126 TVirtualPad *pd2 = (TVirtualPad *) cv->GetPad(2);
127 TVirtualPad *pd3 = (nh == 3) ? (TVirtualPad *) cv->GetPad(3) : 0;
128
129 UInt_t optstat = gStyle->GetOptStat();
130 gStyle->SetOptStat(11);
131 // Plot
132 if (hevt) {
133 if (pd1) pd1->cd();
134 hevt->SetFillColor(kGreen);
135 hevt->DrawCopy();
136 }
137 if (hpck) {
138 if (pd2) pd2->cd();
139 hpck->SetFillColor(kAzure-5);
140 hpck->DrawCopy();
141 }
142 if (hass) {
143 if (pd3) pd3->cd();
144 hass->SetFillColor(kGray);
145 hass->SetMaximum(2);
146 hass->DrawCopy();
147 }
148
149 cv->cd();
150 cv->Update();
151 gStyle->SetOptStat(optstat);
152}
#define SafeDelete(p)
Definition: RConfig.hxx:529
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
#define ClassImp(name)
Definition: Rtypes.h:363
@ kGray
Definition: Rtypes.h:62
@ kGreen
Definition: Rtypes.h:63
@ kAzure
Definition: Rtypes.h:64
#define PDB(mask, level)
Definition: TProofDebug.h:56
R__EXTERN TProof * gProof
Definition: TProof.h:1077
#define gROOT
Definition: TROOT.h:410
R__EXTERN TStyle * gStyle
Definition: TStyle.h:406
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:614
1-D histogram with an int per channel (see TH1 documentation)}
Definition: TH1.h:530
virtual void SetMaximum(Double_t maximum=-1111)
Definition: TH1.h:394
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
Definition: TH1.cxx:3021
A doubly linked list.
Definition: TList.h:44
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
@ kInvalidObject
if object ctor succeeded but object should not be used
Definition: TObject.h:68
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:854
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:867
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
Definition: TQObject.cxx:1025
Sequenceable collection abstract base class.
Utility class to display PROOF stats feedback histos during queries.
TStatsFeedback(TProof *proof=0)
Constructor.
~TStatsFeedback()
Destructor.
void Feedback(TList *objs)
Display feedback.
Basic string class.
Definition: TString.h:131
const char * Data() const
Definition: TString.h:364
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:2286
Int_t GetOptStat() const
Definition: TStyle.h:232
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:1444
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:50
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:399