134 gROOT->GetListOfCleanups()->Add(
this);
168 const char *name ,
const char *title ,
179 gROOT->GetListOfCleanups()->Add(
this);
182 Warning(
"THStack",
"Need an axis.");
186 Warning(
"THStack",
"Need a histogram.");
191 if (!isTH2 && !isTH3) {
192 Warning(
"THStack",
"Need a histogram deriving from TH2 or TH3.");
207 Bool_t useX=(strchr(axis,
'x')) || (strchr(axis,
'X'));
208 Bool_t useY=(strchr(axis,
'y')) || (strchr(axis,
'Y'));
209 if ((!useX && !useY) || (useX && useY)) {
210 Warning(
"THStack",
"Need parameter axis=\"x\" or \"y\" for a TH2, not none or both.");
215 Warning(
"HStack",
"Histogram axis is NULL");
219 if (firstbin < 0) firstbin = 1;
220 if (lastbin < 0) lastbin = nbins;
221 if (lastbin > nbins+1) lastbin = nbins;
222 for (
Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
225 iBin, iBin, proj_option);
227 iBin, iBin, proj_option);
228 Add(hProj, draw_option);
236 if (dim<1 || dim>2) {
237 Warning(
"THStack",
"Invalid length for parameter axis.");
251 Warning(
"HStack",
"Histogram axis is NULL");
256 if (firstbin < 0) firstbin = 1;
257 if (lastbin < 0) lastbin = nbins;
258 if (lastbin > nbins+1) lastbin = nbins;
261 for (
Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
265 axis, proj_option, iBin));
266 Add(hProj, draw_option);
268 haxis->
SetRange(iFirstOld, iLastOld);
284 if (!haxis1 || !haxis2) {
285 Warning(
"HStack",
"Histogram axis is NULL");
291 if (firstbin < 0) firstbin = 1;
292 if (lastbin < 0) lastbin = nbins1;
293 if (lastbin > nbins1+1) lastbin = nbins1;
294 if (firstbin2 < 0) firstbin2 = 1;
295 if (lastbin2 < 0) lastbin2 = nbins2;
296 if (lastbin2 > nbins2+1) lastbin2 = nbins2;
301 for (
Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
303 for (
Int_t jBin=firstbin2; jBin<=lastbin2; jBin++) {
307 axis, proj_option, iBin));
308 Add(hProj, draw_option);
311 haxis1->
SetRange(iFirstOld1, iLastOld1);
312 haxis2->
SetRange(iFirstOld2, iLastOld2);
325 gROOT->GetListOfCleanups()->Remove(
this);
350 while ((h=(
TH1*)next()))
Add(h);
363 Error(
"Add",
"THStack supports only 1-d and 2-d histograms");
395 for (
Int_t i=1;i<nhists;i++) {
411 Int_t distance = 9999;
414 if (distance <= 0) {
return distance;}
415 if (distance <= 1) {
gPad->SetSelected(
fHistogram);
return distance;}
420 if (!
fHists)
return distance;
424 for (
Int_t i=0;i<nhists;i++) {
428 if (dist <= 0)
return 0;
429 if (dist < kMaxDiff) {
450 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
508 for (
Int_t i=0;i<nhists;i++) {
511 if (them > themax) themax = them;
516 for (
Int_t i=0;i<nhists;i++) {
520 for (
Int_t j=first; j<=last;j++) {
552 for (
Int_t i=0;i<nhists;i++) {
555 if (them <= 0 && gPad && gPad->GetLogy()) them = h->
GetMinimum(0);
556 if (them < themin) themin = them;
561 for (
Int_t i=0;i<nhists;i++) {
565 for (
Int_t j=first; j<=last;j++) {
630 std::cout <<IsA()->GetName()
631 <<
" Name= "<<
GetName()<<
" Title= "<<
GetTitle()<<
" Option="<<option<<std::endl;
651 "Cannot merge - an object which doesn't inherit from THStack found in the list");
703 strlcpy(option,choptin,128);
706 char *l1 = strstr(option,
"pfc");
707 char *l2 = strstr(option,
"plc");
708 char *l3 = strstr(option,
"pmc");
709 if (l1 || l2 || l3) {
711 if (l1) strncpy(l1,
" ",3);
712 if (l2) strncpy(l2,
" ",3);
713 if (l3) strncpy(l3,
" ",3);
720 gPad->IncrementPaletteColor(nhists, opt1);
721 for (
Int_t i=0;i<nhists;i++) {
722 ic =
gPad->NextPaletteColor();
751 while ((obj = nextp())) {
757 if (nx*nx < npads) nx++;
759 if (((nx*ny)-nx) >= npads) ny--;
783 while ((h=(
TH1*)next())) {
794 char *nostack = strstr(loption,
"nostack");
795 char *nostackb = strstr(loption,
"nostackb");
796 char *candle = strstr(loption,
"candle");
797 char *violin = strstr(loption,
"violin");
810 if (
gPad->GetLogy()){
811 if (themin>0) themin *= .9;
812 else themin = themax*1.e-3;
826 if (!option[0]) strlcpy(loption,
"lego1",32);
828 if (xbins->
fN != 0 && ybins->
fN != 0) {
832 }
else if (xbins->
fN != 0 && ybins->
fN == 0) {
836 }
else if (xbins->
fN == 0 && ybins->
fN != 0) {
846 if (xbins->
fN != 0) {
859 if (nostack) {*nostack = 0; strncat(nostack,nostack+7,7);}
860 if (nostackb) {*nostackb = 0; strncat(nostackb,nostackb+8,8);}
894 if (strstr(loption,
"lego"))
return;
897 strlcpy(noption,loption,32);
899 if (nostack || candle || violin) {
904 for (
Int_t i=0;i<nhists;i++) {
918 hAti->SetBarOffset(bo);
921 if (candle || violin) {
922 float candleSpace = 1./(nhists*2);
923 float candleOffset = - 1./2 + candleSpace + 2*candleSpace*i;
925 hAti->SetBarWidth(candleSpace);
926 hAti->SetBarOffset(candleOffset);
928 hAti->Paint(loption);
935 for (
Int_t i=0;i<nhists;i++) {
944 h1col = h1->GetFillColor();
945 h1fill = h1->GetFillStyle();
946 h1->SetFillColor(10);
947 h1->SetFillStyle(1001);
956 h1->SetFillColor(h1col);
957 h1->SetFillStyle(h1fill);
977 while ((h = (
TH1*) next())) {
1005 out<<
GetName()<<
" = new THStack();"<<std::endl;
1006 out<<
" "<<
GetName()<<
"->SetName("<<quote<<
GetName()<<quote<<
");"<<std::endl;
1007 out<<
" "<<
GetName()<<
"->SetTitle("<<quote<<
GetTitle()<<quote<<
");"<<std::endl;
1016 static Int_t frameNumber = 0;
1021 hname += frameNumber;
1025 out<<
" "<<std::endl;
1035 hname +=
Form(
"_stack_%d",++hcount);
1042 out<<
" "<<
GetName()<<
"->Draw(" 1043 <<quote<<option<<quote<<
");"<<std::endl;
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
virtual const char * GetName() const
Returns name of object.
virtual void Print(Option_t *option="") const
Print some global quantities for this histogram.
virtual void Print(Option_t *chopt="") const
Print the list of histograms.
double dist(Rotation3D const &r1, Rotation3D const &r2)
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from the list of histograms.
virtual void Paint(Option_t *option="")
Control routine to paint any kind of histograms.
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Int_t GetFirst() const
Return first bin on the axis i.e.
virtual void SetMaximum(Double_t maximum=-1111)
TH1 * GetHistogram() const
Returns a pointer to the histogram used to draw the axis Takes into account the two following cases...
The Histogram stack class.
virtual TH1 * Project3D(Option_t *option="x") const
Project a 3-d histogram into 1 or 2-d histograms depending on the option parameter, which may contain a combination of the characters x,y,z,e.
TVirtualHistPainter * GetPainter(Option_t *option="")
Return pointer to painter.
Collectable string class.
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Double_t GetHistTopMargin() const
TString & ReplaceAll(const TString &s1, const TString &s2)
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.
R__EXTERN TStyle * gStyle
const Double_t * GetArray() const
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
TAxis * GetXaxis() const
Get x axis of the histogram used to draw the stack.
virtual Int_t GetEntries() const
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.
virtual void SetMinimum(Double_t minimum=-1111)
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Option_t * GetOption() const
static Bool_t AddDirectoryStatus()
Static function: cannot be inlined on Windows/NT.
1-D histogram with a float per channel (see TH1 documentation)}
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Short_t Min(Short_t a, Short_t b)
void ToLower()
Change string to lower-case.
virtual Long64_t Merge(TCollection *li, TFileMergeInfo *info)
Merge the THStack in the TList into this stack.
R__EXTERN TVirtualMutex * gROOTMutex
TObject * At(Int_t idx) const
virtual void Draw(Option_t *chopt="")
Draw this multihist with its current attributes.
bit set when zooming on Y axis
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
if object in a list can be deleted
virtual void SetBarWidth(Float_t width=0.5)
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
virtual Int_t GetDimension() const
Fill Area Attributes class.
virtual void Paint(Option_t *chopt="")
Paint the list of histograms.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
virtual Double_t GetMaximum(Option_t *option="")
returns the maximum of all added histograms returns the maximum of all histograms if option "nostack"...
TObjArray * GetStack()
Return pointer to Stack. Build it if not yet done.
const Double_t * GetBuffer() const
The TNamed class is the base class for all named ROOT classes.
THashList * GetLabels() const
Double_t Log10(Double_t x)
virtual void ls(Option_t *option="") const
List histograms in the stack.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void Modified()
invalidate sum of histograms
Ssiz_t First(char c) const
Find first occurrence of a character c.
virtual ~THStack()
THStack destructor.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
The 3-D histogram classes derived from the 1-D histogram classes.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to each graph.
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
void BuildStack()
build sum of all histograms Build a separate list fStack containing the running sum of all histograms...
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a line.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Using a TBrowser one can browse all ROOT objects.
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum.
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis from bin first to last.
Int_t GetLast() const
Return last bin on the axis i.e.
Service class for 2-Dim histogram classes.
Class to manage histogram axis.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
TIter begin() const
Get iterator over internal hists list.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Collection abstract base class.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
char * Form(const char *fmt,...)
virtual void Clear(Option_t *option="")=0
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
virtual void SetStack(TList *stack)=0
THStack()
THStack default constructor.
virtual TList * GetListOfPrimitives() const =0
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
virtual void AddAt(TObject *obj, Int_t idx)
Add object at position ids.
virtual TObjLink * FirstLink() const
virtual Double_t GetMinimum(Double_t minval=-FLT_MAX) const
Return minimum value larger than minval of bins in the range, unless the value has been overridden by...
virtual void SetName(const char *name)
Change the name of this histogram.
virtual void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.
virtual void Browse(TBrowser *b)
Browse.
virtual void ls(Option_t *option="") const
List (ls) all objects in this collection.
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 Color_t GetFillColor() const
Return the fill area color.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
#define R__LOCKGUARD(mutex)
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
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.
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Array of doubles (64 bits per element).
virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="")
Performs the operation: this = this + c1*f1 if errors are defined (see TH1::Sumw2), errors are also recalculated.
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
Mother of all ROOT objects.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
TObject * GetObject() const
TClassRef is used to implement a permanent reference to a TClass object.
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
virtual void Add(TObject *obj)
virtual void RecursiveRemove(TObject *obj)
Remove object from this collection and recursively remove the object from all other objects (and coll...
Short_t Max(Short_t a, Short_t b)
TAxis * GetYaxis() const
Get x axis of the histogram used to draw the stack.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
virtual Int_t BufferEmpty(Int_t action=0)
Fill histogram with all entries in the buffer.
virtual TObjLink * LastLink() const
Int_t GetNhists() const
Return the number of histograms in the stack.
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.
virtual void SetTitle(const char *title)
See GetStatOverflows for more information.
Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
virtual Style_t GetFillStyle() const
Return the fill area style.
Double_t Sqrt(Double_t x)
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
virtual Int_t GetSize() const
THist< 2, float, THistStatContent, THistStatUncertainty > TH2F
Bool_t IsWhitespace() const
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum.
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 SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
const TArrayD * GetXbins() const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Long64_t Merge(TCollection *list)
Merge this collection with all collections coming in the input list.
virtual const char * GetTitle() const
Returns title of object.
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
virtual Int_t IndexOf(const TObject *obj) const
Return index of object in collection.
const char * Data() const
TH1 * fHistogram
Pointer to array of sums of TH1.