156 gROOT->GetListOfCleanups()->Add(
this);
190 const char *
name ,
const char *title ,
201 gROOT->GetListOfCleanups()->Add(
this);
204 Warning(
"THStack",
"Need an axis.");
208 Warning(
"THStack",
"Need a histogram.");
213 if (!isTH2 && !isTH3) {
214 Warning(
"THStack",
"Need a histogram deriving from TH2 or TH3.");
229 Bool_t useX=(strchr(axis,
'x')) || (strchr(axis,
'X'));
230 Bool_t useY=(strchr(axis,
'y')) || (strchr(axis,
'Y'));
231 if ((!useX && !useY) || (useX && useY)) {
232 Warning(
"THStack",
"Need parameter axis=\"x\" or \"y\" for a TH2, not none or both.");
237 Warning(
"HStack",
"Histogram axis is NULL");
241 if (firstbin < 0) firstbin = 1;
242 if (lastbin < 0) lastbin = nbins;
243 if (lastbin > nbins+1) lastbin = nbins;
244 for (
Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
247 iBin, iBin, proj_option);
249 iBin, iBin, proj_option);
250 Add(hProj, draw_option);
258 if (dim<1 || dim>2) {
259 Warning(
"THStack",
"Invalid length for parameter axis.");
273 Warning(
"HStack",
"Histogram axis is NULL");
278 if (firstbin < 0) firstbin = 1;
279 if (lastbin < 0) lastbin = nbins;
280 if (lastbin > nbins+1) lastbin = nbins;
283 for (
Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
287 axis, proj_option, iBin));
288 Add(hProj, draw_option);
290 haxis->
SetRange(iFirstOld, iLastOld);
306 if (!haxis1 || !haxis2) {
307 Warning(
"HStack",
"Histogram axis is NULL");
313 if (firstbin < 0) firstbin = 1;
314 if (lastbin < 0) lastbin = nbins1;
315 if (lastbin > nbins1+1) lastbin = nbins1;
316 if (firstbin2 < 0) firstbin2 = 1;
317 if (lastbin2 < 0) lastbin2 = nbins2;
318 if (lastbin2 > nbins2+1) lastbin2 = nbins2;
323 for (
Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
325 for (
Int_t jBin=firstbin2; jBin<=lastbin2; jBin++) {
329 axis, proj_option, iBin));
330 Add(hProj, draw_option);
333 haxis1->
SetRange(iFirstOld1, iLastOld1);
334 haxis2->
SetRange(iFirstOld2, iLastOld2);
347 gROOT->GetListOfCleanups()->Remove(
this);
366 fMaximum(hstack.fMaximum),
367 fMinimum(hstack.fMinimum)
385 Error(
"Add",
"THStack supports only 1-d and 2-d histograms");
398 Draw(
b ?
b->GetDrawOption() :
"");
417 for (
Int_t i=1;i<nhists;i++) {
432 const Int_t kMaxDiff = 10;
433 Int_t distance = 9999;
436 if (distance <= 0) {
return distance;}
437 if (distance <= 1) {
gPad->SetSelected(
fHistogram);
return distance;}
442 if (!
fHists)
return distance;
446 for (
Int_t i=0;i<nhists;i++) {
449 Int_t dist =
h->DistancetoPrimitive(px,py);
450 if (dist <= 0)
return 0;
451 if (dist < kMaxDiff) {
472 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
528 themax =
h->GetMaximum();
530 for (
Int_t i=0;i<nhists;i++) {
532 them =
h->GetMaximum();
533 if (them > themax) themax = them;
538 for (
Int_t i=0;i<nhists;i++) {
540 first =
h->GetXaxis()->GetFirst();
541 last =
h->GetXaxis()->GetLast();
543 e1 =
h->GetBinError(j);
544 c1 =
h->GetBinContent(j);
572 themin =
h->GetMinimum();
574 for (
Int_t i=0;i<nhists;i++) {
576 them =
h->GetMinimum();
577 if (them <= 0 && gPad && gPad->GetLogy()) them =
h->GetMinimum(0);
578 if (them < themin) themin = them;
583 for (
Int_t i=0;i<nhists;i++) {
585 first =
h->GetXaxis()->GetFirst();
586 last =
h->GetXaxis()->GetLast();
588 e1 =
h->GetBinError(j);
589 c1 =
h->GetBinContent(j);
628 return h->GetXaxis();
643 return h->GetYaxis();
652 std::cout <<IsA()->GetName()
653 <<
" Name= "<<
GetName()<<
" Title= "<<
GetTitle()<<
" Option="<<option<<std::endl;
673 "Cannot merge - an object which doesn't inherit from THStack found in the list");
704 strlcpy(option,choptin,128);
707 char *l1 = strstr(option,
"pfc");
708 char *l2 = strstr(option,
"plc");
709 char *l3 = strstr(option,
"pmc");
710 if (l1 || l2 || l3) {
712 if (l1) memcpy(l1,
" ",3);
713 if (l2) memcpy(l2,
" ",3);
714 if (l3) memcpy(l3,
" ",3);
716 if (
ws.IsWhitespace()) strncpy(option,
"\0",1);
722 gPad->IncrementPaletteColor(nhists, opt1);
723 for (
Int_t i=0;i<nhists;i++) {
724 ic =
gPad->NextPaletteColor();
759 while ((obj = nextp())) {
765 if (nx*nx < npads) nx++;
767 if (((nx*ny)-nx) >= npads) ny--;
791 while ((
h=(
TH1*)next())) {
793 if (
h->GetBuffer())
h->BufferEmpty(-1);
794 if (
h->GetXaxis()->GetXmin() <
xmin)
xmin =
h->GetXaxis()->GetXmin();
795 if (
h->GetXaxis()->GetXmax() >
xmax)
xmax =
h->GetXaxis()->GetXmax();
796 if (
h->GetYaxis()->GetXmin() <
ymin)
ymin =
h->GetYaxis()->GetXmin();
797 if (
h->GetYaxis()->GetXmax() >
ymax)
ymax =
h->GetYaxis()->GetXmax();
810 if (!nostack && !candle && !violin)
BuildStack();
817 if (
gPad->GetLogy()){
818 if (themin>0) themin *= .9;
819 else themin = themax*1.e-3;
829 TAxis *xaxis =
h->GetXaxis();
830 TAxis *yaxis =
h->GetYaxis();
832 if (
h->GetDimension() > 1) {
833 if (loption.
IsNull()) loption =
"lego1";
835 if (xbins->fN != 0 && ybins->
fN != 0) {
837 xaxis->
GetNbins(), xbins->GetArray(),
839 }
else if (xbins->fN != 0 && ybins->
fN == 0) {
841 xaxis->
GetNbins(), xbins->GetArray(),
843 }
else if (xbins->fN == 0 && ybins->
fN != 0) {
853 if (xbins->fN != 0) {
855 xaxis->
GetNbins(), xbins->GetArray());
869 if (nostack) loption.
ReplaceAll(
"nostack",
"");
907 if (loption.
Index(
"lego")>=0)
return;
910 strlcpy(noption,loption.
Data(),32);
912 if (nostack || candle || violin) {
917 for (
Int_t i=0;i<nhists;i++) {
919 if (nostackb) loption.
Form(
"%s%s b",noption,lnk->
GetOption());
924 if (nostackb) loption.
Form(
"%ssame%s b",noption,lnk->
GetOption());
934 if (candle || violin) {
935 float candleSpace = 1./(nhists*2);
936 float candleOffset = - 1./2 + candleSpace + 2*candleSpace*i;
948 for (
Int_t i=0;i<nhists;i++) {
990 while ((
h = (
TH1*) next())) {
1012 out<<
" "<<std::endl;
1013 if (
gROOT->ClassSaved(THStack::Class())) {
1018 out<<
GetName()<<
" = new THStack();"<<std::endl;
1019 out<<
" "<<
GetName()<<
"->SetName("<<quote<<
GetName()<<quote<<
");"<<std::endl;
1020 out<<
" "<<
GetName()<<
"->SetTitle("<<quote<<
GetTitle()<<quote<<
");"<<std::endl;
1029 static Int_t frameNumber = 0;
1034 hname += frameNumber;
1038 out<<
" "<<std::endl;
1048 hname +=
Form(
"_stack_%d",++hcount);
1050 h->SavePrimitive(out,
"nodraw");
1051 out<<
" "<<
GetName()<<
"->Add("<<
h->GetName()<<
","<<quote<<lnk->
GetOption()<<quote<<
");"<<std::endl;
1055 out<<
" "<<
GetName()<<
"->Draw("
1056 <<quote<<option<<quote<<
");"<<std::endl;
R__EXTERN TVirtualMutex * gROOTMutex
char * Form(const char *fmt,...)
R__EXTERN TStyle * gStyle
#define R__LOCKGUARD(mutex)
Array of doubles (64 bits per element).
const Double_t * GetArray() const
Fill Area Attributes class.
virtual Color_t GetFillColor() const
Return the fill area color.
virtual Style_t GetFillStyle() const
Return the fill area style.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Class to manage histogram axis.
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
const TArrayD * GetXbins() const
Int_t GetLast() const
Return last bin on the axis i.e.
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis using bin numbers.
Int_t GetFirst() const
Return first bin on the axis i.e.
THashList * GetLabels() const
Using a TBrowser one can browse all ROOT objects.
TClassRef is used to implement a permanent reference to a TClass object.
void * DynamicCast(const TClass *base, void *obj, Bool_t up=kTRUE)
Cast obj of this class type up to baseclass cl if up is true.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Collection abstract base class.
virtual void ls(Option_t *option="") const
List (ls) all objects in this collection.
virtual Int_t GetEntries() const
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
1-D histogram with a float per channel (see TH1 documentation)}
TH1 is the base class of all histogram classes in ROOT.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
virtual void SetTitle(const char *title)
See GetStatOverflows for more information.
virtual void SetBarOffset(Float_t offset=0.25)
Set the bar offset as fraction of the bin width for drawing mode "B".
virtual Int_t GetDimension() const
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
@ kIsZoomed
bit set when zooming on Y axis
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
TVirtualHistPainter * GetPainter(Option_t *option="")
Return pointer to painter.
virtual void SetMaximum(Double_t maximum=-1111)
virtual TObject * FindObject(const char *name) const
Search object named name in the list of functions.
virtual void SetMinimum(Double_t minimum=-1111)
virtual void SetName(const char *name)
Change the name of this histogram.
virtual void Paint(Option_t *option="")
Control routine to paint any kind of histograms.
static Bool_t AddDirectoryStatus()
Static function: cannot be inlined on Windows/NT.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a line.
virtual void SetBarWidth(Float_t width=0.5)
Set the width of bars as fraction of the bin width for drawing mode "B".
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
2-D histogram with a float per channel (see TH1 documentation)}
Service class for 2-Dim histogram classes.
TH1D * ProjectionY(const char *name="_py", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const
Project a 2-D histogram into a 1-D histogram along Y.
TH1D * ProjectionX(const char *name="_px", Int_t firstybin=0, Int_t lastybin=-1, Option_t *option="") const
Project a 2-D histogram into a 1-D histogram along X.
The 3-D histogram classes derived from the 1-D histogram classes.
virtual TH1 * Project3D(Option_t *option="x") const
Project a 3-d histogram into 1 or 2-d histograms depending on the option parameter,...
The Histogram stack class.
virtual void Print(Option_t *chopt="") const
Print the list of histograms.
TIter begin() const
Get iterator over internal hists list.
virtual ~THStack()
THStack destructor.
THStack()
THStack default constructor.
virtual void ls(Option_t *option="") const
List histograms in the stack.
virtual void Draw(Option_t *chopt="")
Draw this multihist with its current attributes.
void BuildStack()
build sum of all histograms Build a separate list fStack containing the running sum of all histograms
TAxis * GetYaxis() const
Get x axis of the histogram used to draw the stack.
virtual Long64_t Merge(TCollection *li, TFileMergeInfo *info)
Merge the THStack in the TList into this stack.
virtual void Paint(Option_t *chopt="")
Paint the list of histograms.
TH1 * GetHistogram() const
Returns a pointer to the histogram used to draw the axis Takes into account the two following cases.
virtual Double_t GetMaximum(Option_t *option="")
returns the maximum of all added histograms returns the maximum of all histograms if option "nostack"...
virtual void Add(TH1 *h, Option_t *option="")
add a new histogram to the list Only 1-d and 2-d histograms currently supported.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
TObjArray * GetStack()
Return pointer to Stack. Build it if not yet done.
Int_t GetNhists() const
Return the number of histograms in the stack.
virtual Double_t GetMinimum(Option_t *option="")
returns the minimum of all added histograms returns the minimum of all histograms if option "nostack"...
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum.
TH1 * fHistogram
Pointer to array of sums of TH1.
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from the list of histograms.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to each graph.
virtual void Modified()
invalidate sum of histograms
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum.
virtual void Browse(TBrowser *b)
Browse.
TAxis * GetXaxis() const
Get x axis of the histogram used to draw the stack.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
virtual void Add(TObject *obj)
virtual TObjLink * LastLink() const
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual TObjLink * FirstLink() const
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
virtual void RecursiveRemove(TObject *obj)
Remove object from this collection and recursively remove the object from all other objects (and coll...
virtual void Clear(Option_t *option="")
Remove all objects from the list.
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
virtual void AddAt(TObject *obj, Int_t idx)
Add object at position ids.
TObject * At(Int_t idx) const
TObject * GetObject() const
Option_t * GetOption() const
Collectable string class.
Mother of all ROOT objects.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
@ kCanDelete
if object in a list can be deleted
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
virtual Int_t IndexOf(const TObject *obj) const
Return index of object in collection.
Long64_t Merge(TCollection *list)
Merge this collection with all collections coming in the input list.
void ToLower()
Change string to lower-case.
Ssiz_t First(char c) const
Find first occurrence of a character c.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Double_t GetHistTopMargin() const
virtual void SetStack(TList *stack)=0
TVirtualPad is an abstract base class for the Pad and Canvas classes.
virtual TList * GetListOfPrimitives() const =0
virtual TVirtualPad * cd(Int_t subpadnumber=0)=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 Clear(Option_t *option="") override=0
Short_t Max(Short_t a, Short_t b)
Double_t Sqrt(Double_t x)
Short_t Min(Short_t a, Short_t b)
Double_t Log10(Double_t x)