123 gROOT->GetListOfCleanups()->Add(
this);
157 const char *
name ,
const char *title ,
166 gROOT->GetListOfCleanups()->Add(
this);
169 Warning(
"THStack",
"Need an axis.");
173 Warning(
"THStack",
"Need a histogram.");
178 if (!isTH2 && !isTH3) {
179 Warning(
"THStack",
"Need a histogram deriving from TH2 or TH3.");
194 Bool_t useX=(strchr(axis,
'x')) || (strchr(axis,
'X'));
195 Bool_t useY=(strchr(axis,
'y')) || (strchr(axis,
'Y'));
196 if ((!useX && !useY) || (useX && useY)) {
197 Warning(
"THStack",
"Need parameter axis=\"x\" or \"y\" for a TH2, not none or both.");
202 Warning(
"HStack",
"Histogram axis is NULL");
206 if (firstbin < 0) firstbin = 1;
207 if (lastbin < 0) lastbin =
nbins;
208 if (lastbin > nbins+1) lastbin =
nbins;
209 for (
Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
212 iBin, iBin, proj_option);
214 iBin, iBin, proj_option);
215 Add(hProj, draw_option);
223 if (dim<1 || dim>2) {
224 Warning(
"THStack",
"Invalid length for parameter axis.");
238 Warning(
"HStack",
"Histogram axis is NULL");
243 if (firstbin < 0) firstbin = 1;
244 if (lastbin < 0) lastbin =
nbins;
245 if (lastbin > nbins+1) lastbin =
nbins;
248 for (
Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
252 axis, proj_option, iBin));
253 Add(hProj, draw_option);
255 haxis->
SetRange(iFirstOld, iLastOld);
271 if (!haxis1 || !haxis2) {
272 Warning(
"HStack",
"Histogram axis is NULL");
278 if (firstbin < 0) firstbin = 1;
279 if (lastbin < 0) lastbin = nbins1;
280 if (lastbin > nbins1+1) lastbin = nbins1;
281 if (firstbin2 < 0) firstbin2 = 1;
282 if (lastbin2 < 0) lastbin2 = nbins2;
283 if (lastbin2 > nbins2+1) lastbin2 = nbins2;
288 for (
Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
290 for (
Int_t jBin=firstbin2; jBin<=lastbin2; jBin++) {
294 axis, proj_option, iBin));
295 Add(hProj, draw_option);
298 haxis1->
SetRange(iFirstOld1, iLastOld1);
299 haxis2->
SetRange(iFirstOld2, iLastOld2);
310 gROOT->GetListOfCleanups()->Remove(
this);
334 while ((h=(
TH1*)next()))
Add(h);
347 Error(
"Add",
"THStack supports only 1-d and 2-d histograms");
379 for (
Int_t i=1;i<nhists;i++) {
394 const Int_t kMaxDiff = 10;
395 Int_t distance = 9999;
398 if (distance <= 0) {
return distance;}
399 if (distance <= 1) {
gPad->SetSelected(
fHistogram);
return distance;}
404 if (!
fHists)
return distance;
408 for (
Int_t i=0;i<nhists;i++) {
412 if (dist <= 0)
return 0;
413 if (dist < kMaxDiff) {
434 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
492 for (
Int_t i=0;i<nhists;i++) {
495 if (them > themax) themax = them;
500 for (
Int_t i=0;i<nhists;i++) {
504 for (
Int_t j=first; j<=last;j++) {
536 for (
Int_t i=0;i<nhists;i++) {
539 if (them <= 0 && gPad && gPad->GetLogy()) them = h->
GetMinimum(0);
540 if (them < themin) themin = them;
545 for (
Int_t i=0;i<nhists;i++) {
549 for (
Int_t j=first; j<=last;j++) {
614 std::cout <<IsA()->GetName()
615 <<
" Name= "<<
GetName()<<
" Title= "<<
GetTitle()<<
" Option="<<option<<std::endl;
635 "Cannot merge - an object which doesn't inherit from THStack found in the list");
705 while ((obj = nextp())) {
711 if (nx*nx < npads) nx++;
713 if (((nx*ny)-nx) >= npads) ny--;
739 while ((h=(
TH1*)next())) {
750 char *nostack = strstr(loption,
"nostack");
751 char *nostackb = strstr(loption,
"nostackb");
752 char *candle = strstr(loption,
"candle");
765 if (
gPad->GetLogy()){
766 if (themin>0) themin *= .9;
767 else themin = themax*1.e-3;
781 if (!option[0]) strlcpy(loption,
"lego1",32);
783 if (xbins->
fN != 0 && ybins->
fN != 0) {
787 }
else if (xbins->
fN != 0 && ybins->
fN == 0) {
791 }
else if (xbins->
fN == 0 && ybins->
fN != 0) {
801 if (xbins->
fN != 0) {
814 if (nostack) {*nostack = 0; strncat(nostack,nostack+7,7);}
815 if (nostackb) {*nostackb = 0; strncat(nostackb,nostackb+8,8);}
849 if (strstr(loption,
"lego"))
return;
852 strlcpy(noption,loption,32);
854 if (nostack || candle) {
859 for (
Int_t i=0;i<nhists;i++) {
873 hAti->SetBarOffset(bo);
877 float candleSpace = 1./(nhists*2);
878 float candleOffset = - 1./2 + candleSpace + 2*candleSpace*i;
880 hAti->SetBarWidth(candleSpace);
881 hAti->SetBarOffset(candleOffset);
883 hAti->Paint(loption);
890 for (
Int_t i=0;i<nhists;i++) {
899 h1col = h1->GetFillColor();
900 h1fill = h1->GetFillStyle();
901 h1->SetFillColor(10);
902 h1->SetFillStyle(1001);
911 h1->SetFillColor(h1col);
912 h1->SetFillStyle(h1fill);
929 while ((h = (
TH1*) next())) {
957 out<<
GetName()<<
" = new THStack();"<<std::endl;
958 out<<
" "<<
GetName()<<
"->SetName("<<quote<<
GetName()<<quote<<
");"<<std::endl;
959 out<<
" "<<
GetName()<<
"->SetTitle("<<quote<<
GetTitle()<<quote<<
");"<<std::endl;
968 static Int_t frameNumber = 0;
973 hname += frameNumber;
991 <<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 option may contain...
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
Bool_t TestBit(UInt_t f) 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)
Option_t * GetOption() const
static Bool_t AddDirectoryStatus()
Static function: cannot be inlined on Windows/NT.
tomato 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.
TObject * At(Int_t idx) const
virtual void Draw(Option_t *chopt="")
Draw this multihist with its current attributes.
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 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.
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 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
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
bit set when zooming on Y axis
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)
Change (i.e.
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
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.
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.