115 gROOT->GetListOfCleanups()->Add(
this);
158 gROOT->GetListOfCleanups()->Add(
this);
161 Warning(
"THStack",
"Need an axis.");
165 Warning(
"THStack",
"Need a histogram.");
170 if (!isTH2 && !isTH3) {
171 Warning(
"THStack",
"Need a histogram deriving from TH2 or TH3.");
186 Bool_t useX=(strchr(axis,
'x')) || (strchr(axis,
'X'));
187 Bool_t useY=(strchr(axis,
'y')) || (strchr(axis,
'Y'));
188 if ((!useX && !useY) || (useX && useY)) {
189 Warning(
"THStack",
"Need parameter axis=\"x\" or \"y\" for a TH2, not none or both.");
194 Warning(
"HStack",
"Histogram axis is NULL");
198 if (firstbin < 0) firstbin = 1;
199 if (lastbin < 0) lastbin =
nbins;
200 if (lastbin > nbins+1) lastbin =
nbins;
201 for (
Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
204 iBin, iBin, proj_option);
206 iBin, iBin, proj_option);
207 Add(hProj, draw_option);
215 if (dim<1 || dim>2) {
216 Warning(
"THStack",
"Invalid length for parameter axis.");
230 Warning(
"HStack",
"Histogram axis is NULL");
235 if (firstbin < 0) firstbin = 1;
236 if (lastbin < 0) lastbin =
nbins;
237 if (lastbin > nbins+1) lastbin =
nbins;
240 for (
Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
244 axis, proj_option, iBin));
245 Add(hProj, draw_option);
247 haxis->
SetRange(iFirstOld, iLastOld);
263 if (!haxis1 || !haxis2) {
264 Warning(
"HStack",
"Histogram axis is NULL");
270 if (firstbin < 0) firstbin = 1;
271 if (lastbin < 0) lastbin = nbins1;
272 if (lastbin > nbins1+1) lastbin = nbins1;
273 if (firstbin2 < 0) firstbin2 = 1;
274 if (lastbin2 < 0) lastbin2 = nbins2;
275 if (lastbin2 > nbins2+1) lastbin2 = nbins2;
280 for (
Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
282 for (
Int_t jBin=firstbin2; jBin<=lastbin2; jBin++) {
286 axis, proj_option, iBin));
287 Add(hProj, draw_option);
290 haxis1->
SetRange(iFirstOld1, iLastOld1);
291 haxis2->
SetRange(iFirstOld2, iLastOld2);
302 gROOT->GetListOfCleanups()->Remove(
this);
320 fMaximum(hstack.fMaximum),
321 fMinimum(hstack.fMinimum)
339 Error(
"Add",
"THStack supports only 1-d and 2-d histograms");
371 for (
Int_t i=1;i<nhists;i++) {
386 const Int_t kMaxDiff = 10;
390 if (distance <= 0) {
return distance;}
400 for (
Int_t i=0;i<nhists;i++) {
404 if (dist <= 0)
return 0;
405 if (dist < kMaxDiff) {
426 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
484 for (
Int_t i=0;i<nhists;i++) {
487 if (them > themax) themax = them;
492 for (
Int_t i=0;i<nhists;i++) {
496 for (
Int_t j=first; j<=last;j++) {
528 for (
Int_t i=0;i<nhists;i++) {
531 if (them <= 0 && gPad && gPad->GetLogy()) them = h->
GetMinimum(0);
532 if (them < themin) themin = them;
537 for (
Int_t i=0;i<nhists;i++) {
541 for (
Int_t j=first; j<=last;j++) {
607 <<
" Name= "<<
GetName()<<
" Title= "<<
GetTitle()<<
" Option="<<option<<std::endl;
627 "Cannot merge - an object which doesn't inherit from THStack found in the list");
697 while ((obj = nextp())) {
703 if (nx*nx < npads) nx++;
705 if (((nx*ny)-nx) >= npads) ny--;
739 snprintf(loption,31,
"%s",opt.
Data());
740 char *nostack = strstr(loption,
"nostack");
741 char *nostackb = strstr(loption,
"nostackb");
753 if (
gPad->GetLogy()){
754 if (themin>0) themin *= .9;
755 else themin = themax*1.e-3;
769 if (!option[0]) strlcpy(loption,
"lego1",32);
771 if (xbins->
fN != 0 && ybins->
fN != 0) {
775 }
else if (xbins->
fN != 0 && ybins->
fN == 0) {
779 }
else if (xbins->
fN == 0 && ybins->
fN != 0) {
789 if (xbins->
fN != 0) {
802 if (nostack) {*nostack = 0; strncat(nostack,nostack+7,7);}
803 if (nostackb) {*nostackb = 0; strncat(nostackb,nostackb+8,8);}
837 if (strstr(loption,
"lego"))
return;
840 strlcpy(noption,loption,32);
847 for (
Int_t i=0;i<nhists;i++) {
849 if (nostackb) snprintf(loption,31,
"%s%s b",noption,lnk->
GetOption());
850 else snprintf(loption,31,
"%s%s",noption,lnk->
GetOption());
852 if (nostackb) snprintf(loption,31,
"%ssame%s b",noption,lnk->
GetOption());
853 else snprintf(loption,31,
"%ssame%s",noption,lnk->
GetOption());
861 hAti->
Paint(loption);
868 for (
Int_t i=0;i<nhists;i++) {
870 snprintf(loption,31,
"%s%s",noption,lnk->
GetOption());
872 snprintf(loption,31,
"%ssame%s",noption,lnk->
GetOption());
935 out<<
GetName()<<
" = new THStack();"<<std::endl;
936 out<<
" "<<
GetName()<<
"->SetName("<<quote<<
GetName()<<quote<<
");"<<std::endl;
937 out<<
" "<<
GetName()<<
"->SetTitle("<<quote<<
GetTitle()<<quote<<
");"<<std::endl;
946 static Int_t frameNumber = 0;
951 hname += frameNumber;
969 <<quote<<option<<quote<<
");"<<std::endl;
Int_t GetFirst() const
Return first bin on the axis i.e.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
virtual Int_t GetEntries() const
virtual const char * GetTitle() const
Returns title of object.
virtual Style_t GetFillStyle() const
Option_t * GetOption() const
virtual void SetBarOffset(Float_t offset=0.25)
double dist(Rotation3D const &r1, Rotation3D const &r2)
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().
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void SetMaximum(Double_t maximum=-1111)
The Histogram stack class.
Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
TAxis * GetXaxis() const
Get x axis of the histogram used to draw the stack.
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
TVirtualHistPainter * GetPainter(Option_t *option="")
return pointer to painter if painter does not exist, it is created
Collectable string class.
virtual void ls(Option_t *option="") const
List (ls) all objects in this collection.
TMatrixT< Element > & Add(TMatrixT< Element > &target, Element scalar, const TMatrixT< Element > &source)
Modify addition: target += scalar * source.
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
TString & ReplaceAll(const TString &s1, const TString &s2)
R__EXTERN TStyle * gStyle
virtual Int_t GetDimension() const
Double_t distance(const TPoint2 &p1, const TPoint2 &p2)
virtual void SetMinimum(Double_t minimum=-1111)
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.
virtual void SetFillStyle(Style_t fstyle)
virtual void Draw(Option_t *chopt="")
Draw this multihist with its current attributes.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
TH1 * Project3D(Option_t *option="x") const
Project a 3-d histogram into 1 or 2-d histograms depending on the option parameter option may contain...
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
virtual void SetBarWidth(Float_t width=0.5)
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
const char * Data() const
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
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"...
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
TObjArray * GetStack()
Return pointer to Stack. Build it if not yet done.
The TNamed class is the base class for all named ROOT classes.
Double_t Log10(Double_t x)
virtual TObjLink * LastLink() 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 Modified()
invalidate sum of histograms
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.
Int_t GetNhists() const
Return the number of histograms in the stack.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
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.
TAxis * GetYaxis() const
Get x axis of the histogram used to draw the stack.
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.
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.
virtual void Print(Option_t *option="") const
Print some global quantities for this histogram.
Service class for 2-Dim histogram classes.
Class to manage histogram axis.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
virtual void SetFillColor(Color_t fcolor)
2-D histogram with a float per channel (see TH1 documentation)}
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual Color_t GetFillColor() const
Collection abstract base class.
TObject * GetObject() const
Bool_t TestBit(UInt_t f) const
char * Form(const char *fmt,...)
virtual void Clear(Option_t *option="")=0
virtual const char * GetName() const
Returns name of object.
virtual void SetStack(TList *stack)=0
virtual TList * GetListOfPrimitives() const =0
virtual void ls(Option_t *option="") const
List histograms in the stack.
virtual TObjLink * FirstLink() const
virtual void AddAt(TObject *obj, Int_t idx)
Add object at position ids.
const Double_t * GetBuffer() const
const Double_t * GetArray() const
virtual void SetName(const char *name)
Change the name of this histogram.
virtual void Browse(TBrowser *b)
Browse.
virtual Int_t GetSize() const
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 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).
TH1 * GetHistogram() const
Returns a pointer to the histogram used to draw the axis Takes into account the two following cases...
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
Int_t GetLast() const
Return last bin on the axis i.e.
Mother of all ROOT objects.
TClassRef is used to implement a permanent reference to a TClass object.
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
THashList * GetLabels() const
Double_t GetHistTopMargin() const
virtual void Print(Option_t *chopt="") const
Print the list of histograms.
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)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual Int_t BufferEmpty(Int_t action=0)
Fill histogram with all entries in the buffer.
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
const TArrayD * GetXbins() const
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)
Change (i.e.
Double_t Sqrt(Double_t x)
virtual Int_t IndexOf(const TObject *obj) const
TObject * At(Int_t idx) const
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
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 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.
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...
Ssiz_t First(char c) const
Find first occurrence of a character c.
Long64_t Merge(TCollection *list)
Merge this collection with all collections coming in the input list.
TH1 * fHistogram
Pointer to array of sums of TH1.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.