Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TH2Poly.cxx
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// TH2Poly v2.1
3// Author: Olivier Couet, Deniz Gunceler, Danilo Piparo
4
5/*************************************************************************
6 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#include "TH2Poly.h"
14#include "TMultiGraph.h"
15#include "TGraph.h"
16#include "TList.h"
17#include "TMath.h"
18
19#include <cassert>
20#include <ostream>
21
22/** \class TH2Poly
23 \ingroup Histograms
242D Histogram with Polygonal Bins
25
26## Overview
27`TH2Poly` is a 2D Histogram class (TH2) allowing to define polygonal
28bins of arbitrary shape.
29
30Each bin in the `TH2Poly` histogram is a `TH2PolyBin` object.
31`TH2PolyBin` is a very simple class containing the vertices (stored
32as `TGraph`s or `TMultiGraph`s ) and contents of the polygonal
33bin as well as several related functions.
34
35Essentially, a `TH2Poly` is a TList of `TH2PolyBin` objects
36with methods to manipulate them.
37
38Bins are defined using one of the `AddBin()` methods. The bin definition
39should be done before filling.
40
41The histogram can be filled with `Fill(Double_t x, Double_t y, Double_t w)
42`. `w` is the weight.
43If no weight is specified, it is assumed to be 1.
44
45Not all histogram's area need to be binned. Filling an area without bins,
46will falls into the overflows. Adding a bin is not retroactive; it doesn't
47affect previous fillings. A `Fill()` call, that
48was previously ignored due to the lack of a bin at the specified location, is
49not reconsidered when that location is binned later.
50
51If there are two overlapping bins, the first one in the list will be incremented
52by `Fill()`.
53
54The histogram may automatically extends its limits if a bin outside the
55histogram limits is added. This is done when the default constructor (with no
56arguments) is used. It generates a histogram with no limits along the X and Y
57axis. Adding bins to it will extend it up to a proper size.
58
59`TH2Poly` implements a partitioning algorithm to speed up bins' filling
60(see the "Partitioning Algorithm" section for details).
61The partitioning algorithm divides the histogram into regions called cells.
62The bins that each cell intersects are recorded in an array of `TList`s.
63When a coordinate in the histogram is to be filled; the method (quickly) finds
64which cell the coordinate belongs. It then only loops over the bins
65intersecting that cell to find the bin the input coordinate corresponds to.
66The partitioning of the histogram is updated continuously as each bin is added.
67The default number of cells on each axis is 25. This number could be set to
68another value in the constructor or adjusted later by calling the
69`ChangePartition(Int_t, Int_t)` method. The partitioning algorithm is
70considerably faster than the brute force algorithm (i.e. checking if each bin
71contains the input coordinates), especially if the histogram is to be filled
72many times.
73
74The following very simple macro shows how to build and fill a `TH2Poly`:
75~~~ {.cpp}
76{
77 auto h2p = new TH2Poly();
78
79 Double_t x1[] = {0, 5, 6};
80 Double_t y1[] = {0, 0, 5};
81 Double_t x2[] = {0, -1, -1, 0};
82 Double_t y2[] = {0, 0, -1, 3};
83 Double_t x3[] = {4, 3, 0, 1, 2.4};
84 Double_t y3[] = {4, 3.7, 1, 3.7, 2.5};
85
86 h2p->AddBin(3, x1, y1);
87 h2p->AddBin(4, x2, y2);
88 h2p->AddBin(5, x3, y3);
89
90 h2p->Fill(0.1, 0.01, 3);
91 h2p->Fill(-0.5, -0.5, 7);
92 h2p->Fill(-0.7, -0.5, 1);
93 h2p->Fill(1, 3, 1.5);
94}
95~~~
97More examples can be found in th2polyBoxes.C, th2polyEurope.C, th2polyHoneycomb.C
98and th2polyUSA.C.
99
100## Partitioning Algorithm
101The partitioning algorithm forms an essential part of the `TH2Poly`
102class. It is implemented to speed up the filling of bins.
104With the brute force approach, the filling is done in the following way: An
105iterator loops over all bins in the `TH2Poly` and invokes the
106method `IsInside()` for each of them.
107This method checks if the input location is in that bin. If the filling
108coordinate is inside, the bin is filled. Looping over all the bin is
109very slow.
110
111The alternative is to divide the histogram into virtual rectangular regions
112called "cells". Each cell stores the pointers of the bins intersecting it.
113When a coordinate is to be filled, the method finds which cell the coordinate
114falls into. Since the cells are rectangular, this can be done very quickly.
115It then only loops over the bins associated with that cell and calls `IsInside()`
116only on that bins. This reduces considerably the number of bins on which `IsInside()`
117is called and therefore speed up by a huge factor the filling compare to the brute force
118approach where `IsInside()` is called for all bins.
119
120The addition of bins to the appropriate cells is done when the bin is added
121to the histogram. To do this, `AddBin()` calls the
122`AddBinToPartition()` method.
123This method adds the input bin to the partitioning matrix.
124
125The number of partition cells per axis can be specified in the constructor.
126If it is not specified, the default value of 25 along each axis will be
127assigned. This value was chosen because it is small enough to avoid slowing
128down AddBin(), while being large enough to enhance Fill() by a considerable
129amount. Regardless of how it is initialized at construction time, it can be
130changed later with the `ChangePartition()` method.
131`ChangePartition()` deletes the
132old partition matrix and generates a new one with the specified number of cells
133on each axis.
134
135The optimum number of partition cells per axis changes with the number of
136times `Fill()` will be called. Although partitioning greatly speeds up
137filling, it also adds a constant time delay into the code. When `Fill()`
138is to be called many times, it is more efficient to divide the histogram into
139a large number cells. However, if the histogram is to be filled only a few
140times, it is better to divide into a small number of cells.
141*/
142
143////////////////////////////////////////////////////////////////////////////////
144/// Default Constructor. No boundaries specified.
145
147{
148 Initialize(0., 0., 0., 0., 25, 25); // automatic axis range calculation
149 SetName("NoName");
150 SetTitle("NoTitle");
151 SetFloat();
152}
153
154////////////////////////////////////////////////////////////////////////////////
155/// Constructor with specified name and boundaries,
156/// but no partition cell number.
157
158TH2Poly::TH2Poly(const char *name,const char *title, Double_t xlow,Double_t xup
159 , Double_t ylow,Double_t yup)
160{
161 Initialize(xlow, xup, ylow, yup, 25, 25);
162 SetName(name);
163 SetTitle(title);
165}
166
167////////////////////////////////////////////////////////////////////////////////
168/// Constructor with specified name and boundaries and partition cell number.
169
170TH2Poly::TH2Poly(const char *name,const char *title,
171 Int_t nX, Double_t xlow, Double_t xup,
172 Int_t nY, Double_t ylow, Double_t yup)
173{
174 Initialize(xlow, xup, ylow, yup, nX, nY);
175 SetName(name);
176 SetTitle(title);
178}
179
180/////////////////////////////////////////////////////////////////////////////////
181/// Copy constructor
182TH2Poly::TH2Poly(const TH2Poly & rhs) : TH2(), fCells(nullptr),
183fIsEmpty(nullptr), fCompletelyInside(nullptr), fBins(nullptr) {
184 rhs.Copy(*this);
185}
186
187////////////////////////////////////////////////////////////////////////////////
188/// Destructor.
189
191{
192 delete[] fCells;
193 delete[] fIsEmpty;
194 delete[] fCompletelyInside;
195 // delete at the end the bin List since it owns the objects
196 delete fBins;
197}
198
199/////////////////////////////////////////////////////////////////////////////////
200/// Assignment operator
202 if (this != &rhs)
203 rhs.Copy(*this);
204 return *this;
205}
206
207////////////////////////////////////////////////////////////////////////////////
208/// Copy function for TH2Poly
209
211{
212 // copy first TH2 information
214 auto & newth2p = dynamic_cast<TH2Poly &>(newobj);
215 newth2p.SetName(GetName());
216 newth2p.SetTitle(GetTitle());
217
218 newth2p.fCellX = fCellX;
219 newth2p.fCellY = fCellY;
220 newth2p.fNCells = fNCells;
221 newth2p.fStepX = fStepX;
222 newth2p.fStepY = fStepY;
223
224 // deallocate previous arrays, if existing
225 delete[] newth2p.fCells;
226 delete[] newth2p.fIsEmpty;
227 delete[] newth2p.fCompletelyInside;
228 // allocate arrays
229 newth2p.fCells = new TList [fNCells];
230 newth2p.fIsEmpty = new Bool_t [fNCells]; // Empty partition
231 newth2p.fCompletelyInside = new Bool_t [fNCells]; // Cell is completely inside bin
232 // Initializes the flags
233 for (int i = 0; i<fNCells; i++) {
234 newth2p.fIsEmpty[i] = fIsEmpty[i];
235 newth2p.fCompletelyInside[i] = fCompletelyInside[i];
236 }
237 // need to use Clone to copy the contained bin list
238 delete newth2p.fBins; // in case there was something before there
239 if (!fBins) {
240 newth2p.fBins = nullptr;
241 }
242 else {
243 newth2p.fBins = dynamic_cast<TList *>(fBins->Clone());
244 if (!newth2p.fBins)
245 Error("Copy","Error cloning the TH2Poly bin list");
246 else {
247 // add bins in the fCells partition. We need to add the TH2PolyBin objects
248 // of the new copied histograms. For this we call AddBinToPartition
249 // we could probably optimize this by implementing a copy of the partition
250 for (auto bin : *(newth2p.fBins)) {
251 newth2p.AddBinToPartition(dynamic_cast<TH2PolyBin*>(bin));
252 }
253 }
254 }
255 // copy overflow contents
256 for(int i = 0; i < kNOverflow; i++ ) {
257 newth2p.fOverflow[i] = fOverflow[i];
258 }
259 // copy other data members
260 newth2p.fFloat = fFloat;
261 newth2p.fNewBinAdded = fNewBinAdded;
262 newth2p.fBinContentChanged = fBinContentChanged;
263}
264
265
266////////////////////////////////////////////////////////////////////////////////
267/// Create appropriate histogram bin.
268/// e.g. TH2Poly creates TH2PolyBin,
269/// TProfile2Poly creates TProfile2PolyBin
270/// This is done so that TH2Poly::AddBin does not have to be duplicated,
271/// but only create needs to be reimplemented for additional histogram types
272
274{
275 if (!poly) return nullptr;
276
277 if (fBins == nullptr) {
278 fBins = new TList();
279 fBins->SetOwner();
280 }
281
282 fNcells++;
284 // if structure fsumw2 is created extend it
285 if (fSumw2.fN) fSumw2.Set(fNcells);
286 return new TH2PolyBin(poly, ibin);
287}
288
289////////////////////////////////////////////////////////////////////////////////
290/// Adds a new bin to the histogram. It can be any object having the method
291/// IsInside(). It returns the bin number in the histogram. It returns 0 if
292/// it failed to add. To allow the histogram limits to expand when a bin
293/// outside the limits is added, call SetFloat() before adding the bin.
294
296{
297 auto *bin = CreateBin(poly);
299 if(!bin) return 0;
300
301 // If the bin lies outside histogram boundaries, then extends the boundaries.
302 // Also changes the partition information accordingly
304 if (fFloat) {
305 if (fXaxis.GetXmin() > bin->GetXMin()) {
306 fXaxis.Set(100, bin->GetXMin(), fXaxis.GetXmax());
307 flag = kTRUE;
308 }
309 if (fXaxis.GetXmax() < bin->GetXMax()) {
310 fXaxis.Set(100, fXaxis.GetXmin(), bin->GetXMax());
311 flag = kTRUE;
312 }
313 if (fYaxis.GetXmin() > bin->GetYMin()) {
314 fYaxis.Set(100, bin->GetYMin(), fYaxis.GetXmax());
315 flag = kTRUE;
316 }
317 if (fYaxis.GetXmax() < bin->GetYMax()) {
318 fYaxis.Set(100, fYaxis.GetXmin(), bin->GetYMax());
319 flag = kTRUE;
320 }
322 } else {
323 /*Implement polygon clipping code here*/
324 }
325
326 fBins->Add((TObject*) bin);
328
329 // Adds the bin to the partition matrix
331
332 return ibin;
333}
334
335////////////////////////////////////////////////////////////////////////////////
336/// Adds a new bin to the histogram. The number of vertices and their (x,y)
337/// coordinates are required as input. It returns the bin number in the
338/// histogram.
339
341{
342 TGraph *g = new TGraph(n, x, y);
343 Int_t bin = AddBin(g);
344 return bin;
345}
346
347////////////////////////////////////////////////////////////////////////////////
348/// Add a new bin to the histogram. The bin shape is a rectangle.
349/// It returns the bin number of the bin in the histogram.
350
352{
353 Double_t x[] = {x1, x1, x2, x2, x1};
354 Double_t y[] = {y1, y2, y2, y1, y1};
355 TGraph *g = new TGraph(5, x, y);
356 Int_t bin = AddBin(g);
357 return bin;
358}
359
360////////////////////////////////////////////////////////////////////////////////
361/// Performs the operation: this = this + c1*h1.
362
364{
365 Int_t bin;
366
367 TH2Poly *h1p = (TH2Poly *)h1;
368
369 // Check if number of bins is the same.
370 if (h1p->GetNumberOfBins() != GetNumberOfBins()) {
371 Error("Add", "Attempt to add histograms with different number of bins");
372 return kFALSE;
373 }
374
375 // Check if the bins are the same.
376 TList *h1pBins = h1p->GetBins();
378 for (bin = 1; bin <= GetNumberOfBins(); bin++) {
379 thisBin = (TH2PolyBin *)fBins->At(bin - 1);
380 h1pBin = (TH2PolyBin *)h1pBins->At(bin - 1);
381 if (thisBin->GetXMin() != h1pBin->GetXMin() ||
382 thisBin->GetXMax() != h1pBin->GetXMax() ||
383 thisBin->GetYMin() != h1pBin->GetYMin() ||
384 thisBin->GetYMax() != h1pBin->GetYMax()) {
385 Error("Add", "Attempt to add histograms with different bin limits");
386 return kFALSE;
387 }
388 }
389
390
391 // Create Sumw2 if h1p has Sumw2 set
392 if (fSumw2.fN == 0 && h1p->GetSumw2N() != 0) Sumw2();
393
394 // statistics can be preserved only in case of positive coefficients
395 // otherwise with negative c1 (histogram subtraction) one risks to get negative variances
396 Bool_t resetStats = (c1 < 0);
397 Double_t s1[kNstat] = {0};
398 Double_t s2[kNstat] = {0};
399 if (!resetStats) {
400 // need to initialize to zero s1 and s2 since
401 // GetStats fills only used elements depending on dimension and type
402 GetStats(s1);
403 h1->GetStats(s2);
404 }
405 // get number of entries now because afterwards UpdateBinContent will change it
407
408
409 // Perform the Add.
410 Double_t factor = 1;
411 if (h1p->GetNormFactor() != 0)
412 factor = h1p->GetNormFactor() / h1p->GetSumOfWeights();
413 for (bin = 0; bin < fNcells; bin++) {
414 Double_t y = this->RetrieveBinContent(bin) + c1 * h1p->RetrieveBinContent(bin);
415 UpdateBinContent(bin, y);
416 if (fSumw2.fN) {
417 Double_t esq = factor * factor * h1p->GetBinErrorSqUnchecked(bin);
418 fSumw2.fArray[bin] += c1 * c1 * factor * factor * esq;
419 }
420 }
421
422 // update statistics (do here to avoid changes by SetBinContent)
423 if (resetStats) {
424 // statistics need to be reset in case coefficient are negative
425 ResetStats();
426 } else {
427 for (Int_t i = 0; i < kNstat; i++) {
428 if (i == 1) s1[i] += c1 * c1 * s2[i];
429 else s1[i] += c1 * s2[i];
430 }
431 PutStats(s1);
433 }
434 return kTRUE;
435}
436
437////////////////////////////////////////////////////////////////////////////////
438/// Adds the input bin into the partition cell matrix. This method is called
439/// in AddBin() and ChangePartition().
440
442{
443 // Cell Info
444 Int_t nl, nr, mb, mt; // Max/min indices of the cells that contain the bin
445 Double_t xclipl, xclipr, yclipb, yclipt; // x and y coordinates of a cell
446 Double_t binXmax, binXmin, binYmax, binYmin; // The max/min bin coordinates
447
448 binXmax = bin->GetXMax();
449 binXmin = bin->GetXMin();
450 binYmax = bin->GetYMax();
451 binYmin = bin->GetYMin();
452 nl = (Int_t)(floor((binXmin - fXaxis.GetXmin())/fStepX));
453 nr = (Int_t)(floor((binXmax - fXaxis.GetXmin())/fStepX));
454 mb = (Int_t)(floor((binYmin - fYaxis.GetXmin())/fStepY));
455 mt = (Int_t)(floor((binYmax - fYaxis.GetXmin())/fStepY));
456
457 // Make sure the array indices are correct.
458 if (nr>=fCellX) nr = fCellX-1;
459 if (mt>=fCellY) mt = fCellY-1;
460 if (nl<0) nl = 0;
461 if (mb<0) mb = 0;
462
463 // number of cells in the grid
464 //N.B. not to be confused with fNcells (the number of bins) !
466
467 // Loop over all cells
468 for (int i = nl; i <= nr; i++) {
469 xclipl = fXaxis.GetXmin() + i*fStepX;
470 xclipr = xclipl + fStepX;
471 for (int j = mb; j <= mt; j++) {
473 yclipt = yclipb + fStepY;
474
475 // If the bin is completely inside the cell,
476 // add that bin to the cell then return
477 if ((binXmin >= xclipl) && (binXmax <= xclipr) &&
478 (binYmax <= yclipt) && (binYmin >= yclipb)){
479 fCells[i + j*fCellX].Add((TObject*) bin);
480 fIsEmpty[i + j*fCellX] = kFALSE; // Makes the cell non-empty
481 return;
482 }
483
484 // If any of the sides of the cell intersect with any side of the bin,
485 // add that bin then continue
487 fCells[i + j*fCellX].Add((TObject*) bin);
488 fIsEmpty[i + j*fCellX] = kFALSE; // Makes the cell non-empty
489 continue;
490 }
491 // If a corner of the cell is inside the bin and since there is no
492 // intersection, then that cell completely inside the bin.
493 if((bin->IsInside(xclipl,yclipb)) || (bin->IsInside(xclipl,yclipt))){
494 fCells[i + j*fCellX].Add((TObject*) bin);
495 fIsEmpty[i + j*fCellX] = kFALSE; // Makes the cell non-empty
497 continue;
498 }
499 if((bin->IsInside(xclipr,yclipb)) || (bin->IsInside(xclipr,yclipt))){
500 fCells[i + j*fCellX].Add((TObject*) bin);
501 fIsEmpty[i + j*fCellX] = kFALSE; // Makes the cell non-empty
503 continue;
504 }
505 }
506 }
507}
508
509////////////////////////////////////////////////////////////////////////////////
510/// Changes the number of partition cells in the histogram.
511/// Deletes the old partition and constructs a new one.
512
514{
515 fCellX = n; // Set the number of cells
516 fCellY = m; // Set the number of cells
517
518 delete [] fCells; // Deletes the old partition
519
520 // number of cells in the grid
521 //N.B. not to be confused with fNcells (the number of bins) !
523 fCells = new TList [fNCells]; // Sets an empty partition
524
527
528 delete [] fIsEmpty;
529 delete [] fCompletelyInside;
530 fIsEmpty = new Bool_t [fNCells];
532
533 // Initializes the flags
534 for (int i = 0; i<fNCells; i++) {
535 fIsEmpty[i] = kTRUE;
537 }
538
539 // TList iterator
540 TIter next(fBins);
541 TObject *obj;
542
543 while((obj = next())){ // Loop over bins and add them to the partition
545 }
546}
547
548////////////////////////////////////////////////////////////////////////////////
549/// Clears the contents of all bins in the histogram.
550
552{
553 TIter next(fBins);
554 TObject *obj;
555 TH2PolyBin *bin;
556
557 // Clears the bin contents
558 while ((obj = next())) {
559 bin = (TH2PolyBin*) obj;
560 bin->ClearContent();
561 }
562
563 // Clears the statistics
564 fTsumw = 0;
565 fTsumw2 = 0;
566 fTsumwx = 0;
567 fTsumwx2 = 0;
568 fTsumwy = 0;
569 fTsumwy2 = 0;
570 fEntries = 0;
571}
572
573////////////////////////////////////////////////////////////////////////////////
574/// Reset this histogram: contents, errors, etc.
575
577{
578 TIter next(fBins);
579 TObject *obj;
580 TH2PolyBin *bin;
581
582 // Clears the bin contents
583 while ((obj = next())) {
584 bin = (TH2PolyBin*) obj;
585 bin->ClearContent();
586 }
587
588 TH2::Reset(opt);
589}
590
591////////////////////////////////////////////////////////////////////////////////
592/// Returns the bin number of the bin at the given coordinate. -1 to -9 are
593/// the overflow and underflow bins. overflow bin -5 is the unbinned areas in
594/// the histogram (also called "the sea"). The third parameter can be left
595/// blank.
596/// The overflow/underflow bins are:
597///~~~ {.cpp}
598/// -1 | -2 | -3
599/// -------------
600/// -4 | -5 | -6
601/// -------------
602/// -7 | -8 | -9
603///~~~
604/// where -5 means is the "sea" bin (i.e. unbinned areas)
605
607{
608
609 // Checks for overflow/underflow
610 Int_t overflow = 0;
611 if (y > fYaxis.GetXmax()) overflow += -1;
612 else if (y > fYaxis.GetXmin()) overflow += -4;
613 else overflow += -7;
614 if (x > fXaxis.GetXmax()) overflow += -2;
615 else if (x > fXaxis.GetXmin()) overflow += -1;
616 if (overflow != -5) return overflow;
617
618 // Finds the cell (x,y) coordinates belong to
619 Int_t n = (Int_t)(floor((x-fXaxis.GetXmin())/fStepX));
620 Int_t m = (Int_t)(floor((y-fYaxis.GetXmin())/fStepY));
621
622 // Make sure the array indices are correct.
623 if (n>=fCellX) n = fCellX-1;
624 if (m>=fCellY) m = fCellY-1;
625 if (n<0) n = 0;
626 if (m<0) m = 0;
627
628 if (fIsEmpty[n+fCellX*m]) return -5;
629
630 TH2PolyBin *bin;
631
632 TIter next(&fCells[n+fCellX*m]);
633 TObject *obj;
634
635 // Search for the bin in the cell
636 while ((obj=next())) {
637 bin = (TH2PolyBin*)obj;
638 if (bin->IsInside(x,y)) return bin->GetBinNumber();
639 }
640
641 // If the search has not returned a bin, the point must be on "the sea"
642 return -5;
643}
644
645////////////////////////////////////////////////////////////////////////////////
646/// Increment the bin containing (x,y) by 1.
647/// Uses the partitioning algorithm.
648
650{
651 return Fill(x, y, 1.0);
652}
653
654////////////////////////////////////////////////////////////////////////////////
655/// Increment the bin containing (x,y) by w.
656/// Uses the partitioning algorithm.
657
659{
660 // see GetBinCOntent for definition of overflow bins
661 // in case of weighted events store weight square in fSumw2.fArray
662 // but with this indexing:
663 // fSumw2.fArray[0:kNOverflow-1] : sum of weight squares for the overflow bins
664 // fSumw2.fArray[kNOverflow:fNcells] : sum of weight squares for the standard bins
665 // where fNcells = kNOverflow + Number of bins. kNOverflow=9
666
667 if (fNcells <= kNOverflow) return 0;
668
669 // create sum of weight square array if weights are different than 1
670 if (!fSumw2.fN && w != 1.0 && !TestBit(TH1::kIsNotW) ) Sumw2();
671
672 Int_t overflow = 0;
673 if (y > fYaxis.GetXmax()) overflow += -1;
674 else if (y > fYaxis.GetXmin()) overflow += -4;
675 else overflow += -7;
676 if (x > fXaxis.GetXmax()) overflow += -2;
677 else if(x > fXaxis.GetXmin()) overflow += -1;
678 if (overflow != -5) {
679 fOverflow[-overflow - 1]+= w;
680 if (fSumw2.fN) fSumw2.fArray[-overflow - 1] += w*w;
681 return overflow;
682 }
683
684 // Finds the cell (x,y) coordinates belong to
685 Int_t n = (Int_t)(floor((x-fXaxis.GetXmin())/fStepX));
686 Int_t m = (Int_t)(floor((y-fYaxis.GetXmin())/fStepY));
687
688 // Make sure the array indices are correct.
689 if (n>=fCellX) n = fCellX-1;
690 if (m>=fCellY) m = fCellY-1;
691 if (n<0) n = 0;
692 if (m<0) m = 0;
693
694 if (fIsEmpty[n+fCellX*m]) {
695 fOverflow[4]+= w;
696 if (fSumw2.fN) fSumw2.fArray[4] += w*w;
697 return -5;
698 }
699
700 TH2PolyBin *bin;
701 Int_t bi;
702
703 TIter next(&fCells[n+fCellX*m]);
704 TObject *obj;
705
706 while ((obj=next())) {
707 bin = (TH2PolyBin*)obj;
708 // needs to account offset in array for overflow bins
709 bi = bin->GetBinNumber()-1+kNOverflow;
710 if (bin->IsInside(x,y)) {
711 bin->Fill(w);
712
713 // Statistics
714 fTsumw = fTsumw + w;
715 fTsumw2 = fTsumw2 + w*w;
716 fTsumwx = fTsumwx + w*x;
717 fTsumwx2 = fTsumwx2 + w*x*x;
718 fTsumwy = fTsumwy + w*y;
719 fTsumwy2 = fTsumwy2 + w*y*y;
720 if (fSumw2.fN) {
721 assert(bi < fSumw2.fN);
722 fSumw2.fArray[bi] += w*w;
723 }
724 fEntries++;
725
727
728 return bin->GetBinNumber();
729 }
730 }
731
732 fOverflow[4]+= w;
733 if (fSumw2.fN) fSumw2.fArray[4] += w*w;
734 return -5;
735}
736
737////////////////////////////////////////////////////////////////////////////////
738/// Increment the bin named "name" by w.
739
741{
743
744 TIter next(fBins);
745 TObject *obj;
746 TH2PolyBin *bin;
747
748 while ((obj = next())) {
749 bin = (TH2PolyBin*) obj;
750 if (!sname.CompareTo(bin->GetPolygon()->GetName())) {
751 bin->Fill(w);
752 fEntries++;
754 return bin->GetBinNumber();
755 }
756 }
757
758 return 0;
759}
760
761////////////////////////////////////////////////////////////////////////////////
762/// Fills a 2-D histogram with an array of values and weights.
763///
764/// \param [in] ntimes: number of entries in arrays x and w
765/// (array size must be ntimes*stride)
766/// \param [in] x: array of x values to be histogrammed
767/// \param [in] y: array of y values to be histogrammed
768/// \param [in] w: array of weights
769/// \param [in] stride: step size through arrays x, y and w
770
772 const Double_t* w, Int_t stride)
773{
774 for (int i = 0; i < ntimes; i += stride) {
775 Fill(x[i], y[i], w[i]);
776 }
777}
778
779////////////////////////////////////////////////////////////////////////////////
780/// Returns the integral of bin contents.
781/// By default the integral is computed as the sum of bin contents.
782/// If option "width" or "area" is specified, the integral is the sum of
783/// the bin contents multiplied by the area of the bin.
784
786{
787 TString opt = option;
788 opt.ToLower();
789
790 Double_t w;
791 Double_t integral = 0.;
792
793 TIter next(fBins);
794 TObject *obj;
795 TH2PolyBin *bin;
796 if ((opt.Contains("width")) || (opt.Contains("area"))) {
797 while ((obj = next())) {
798 bin = (TH2PolyBin *)obj;
799 w = bin->GetArea();
800 integral += w * (bin->GetContent());
801 }
802 } else {
803 // need to recompute integral in case SetBinContent was called.
804 // fTsumw cannot be used since it is not updated in that case
805 while ((obj = next())) {
806 bin = (TH2PolyBin *)obj;
807 integral += (bin->GetContent());
808 }
809 }
810 return integral;
811}
812
813////////////////////////////////////////////////////////////////////////////////
814/// Returns the content of the input bin
815/// Bin numbers are from [1,nbins] and
816/// for the overflow/underflow/sea bins the range is [-9,-1]:
817///~~~ {.cpp}
818/// -1 | -2 | -3
819/// ---+----+----
820/// -4 | -5 | -6
821/// ---+----+----
822/// -7 | -8 | -9
823///~~~
824/// where -5 is the "sea" bin (i.e. unbinned areas)
825
827{
828 if (bin > GetNumberOfBins() || bin == 0 || bin < -kNOverflow) return 0;
829 if (bin<0) return fOverflow[-bin - 1];
830 return ((TH2PolyBin*) fBins->At(bin-1))->GetContent();
831}
832
833////////////////////////////////////////////////////////////////////////////////
834/// Returns the value of error associated to bin number bin.
835/// If the sum of squares of weights has been defined (via Sumw2),
836/// this function returns the sqrt(sum of w2).
837/// otherwise it returns the sqrt(contents) for this bin.
838/// Bins are in range [1:nbins] and for bin < 0 in range [-9:-1] it returns errors for overflow bins.
839/// See also TH2Poly::GetBinContent
840
842{
843 if (bin == 0 || bin > GetNumberOfBins() || bin < - kNOverflow) return 0;
844 if (fBuffer) ((TH1*)this)->BufferEmpty();
845 // in case of weighted events the sum of the weights are stored in a different way than
846 // a normal histogram
847 // fSumw2.fArray[0:kNOverflow-1] : sum of weight squares for the overflow bins (
848 // fSumw2.fArray[kNOverflow:fNcells] : sum of weight squares for the standard bins
849 // fNcells = kNOverflow (9) + Number of bins
850 if (fSumw2.fN) {
851 Int_t binIndex = (bin > 0) ? bin+kNOverflow-1 : -(bin+1);
853 return TMath::Sqrt(err2);
854 }
856 return TMath::Sqrt(error2);
857}
858
859////////////////////////////////////////////////////////////////////////////////
860/// Return the number of bins :
861/// it should be the size of the bin list
864 if (nbins != (fBins ? fBins->GetSize() : 0))
865 Fatal("GetNumberOfBins","Object has an invalid number of bins");
866 return nbins;
867}
868
869////////////////////////////////////////////////////////////////////////////////
870/// Set the bin Error.
871/// Re-implementation for TH2Poly given the different bin indexing in the
872/// stored squared error array.
873/// See also notes in TH1::SetBinError
874///
875/// Bins are in range [1:nbins] and for bin < 0 in the range [-9:-1] the errors is set for the overflow bins
876
877
879{
880 if (bin == 0 || bin > GetNumberOfBins() || bin < - kNOverflow) return;
881 if (!fSumw2.fN) Sumw2();
883 // see comment in GetBinError for special convention of bin index in fSumw2 array
884 Int_t binIndex = (bin > 0) ? bin+kNOverflow-1 : -(bin+1);
885 fSumw2.fArray[binIndex] = error * error;
886}
887
888
889
890////////////////////////////////////////////////////////////////////////////////
891/// Returns the bin name.
892
893const char *TH2Poly::GetBinName(Int_t bin) const
894{
895 if (bin > GetNumberOfBins()) return "";
896 if (bin <= 0) return "";
897 return ((TH2PolyBin*) fBins->At(bin-1))->GetPolygon()->GetName();
898}
899
900////////////////////////////////////////////////////////////////////////////////
901/// Returns the bin title.
902
903const char *TH2Poly::GetBinTitle(Int_t bin) const
904{
905 if (bin > GetNumberOfBins()) return "";
906 if (bin <= 0) return "";
907 return ((TH2PolyBin*) fBins->At(bin-1))->GetPolygon()->GetTitle();
908}
909
910////////////////////////////////////////////////////////////////////////////////
911/// Returns the maximum value of the histogram.
912
914{
915 if (fNcells <= kNOverflow) return 0;
916 if (fMaximum != -1111) return fMaximum;
917
918 TH2PolyBin *b;
919
920 TIter next(fBins);
921 TObject *obj;
922 Double_t max,c;
923
924 max = ((TH2PolyBin*) next())->GetContent();
925
926 while ((obj=next())) {
927 b = (TH2PolyBin*)obj;
928 c = b->GetContent();
929 if (c>max) max = c;
930 }
931 return max;
932}
933
934////////////////////////////////////////////////////////////////////////////////
935/// Returns the maximum value of the histogram that is less than maxval.
936
938{
939 if (fNcells <= kNOverflow) return 0;
940 if (fMaximum != -1111) return fMaximum;
941
942 TH2PolyBin *b;
943
944 TIter next(fBins);
945 TObject *obj;
946 Double_t max,c;
947
948 max = ((TH2PolyBin*) next())->GetContent();
949
950 while ((obj=next())) {
951 b = (TH2PolyBin*)obj;
952 c = b->GetContent();
953 if (c>max && c<maxval) max=c;
954 }
955 return max;
956}
957
958////////////////////////////////////////////////////////////////////////////////
959/// Returns the minimum value of the histogram.
960
962{
963 if (fNcells <= kNOverflow) return 0;
964 if (fMinimum != -1111) return fMinimum;
965
966 TH2PolyBin *b;
967
968 TIter next(fBins);
969 TObject *obj;
970 Double_t min,c;
971
972 min = ((TH2PolyBin*) next())->GetContent();
973
974 while ((obj=next())) {
975 b = (TH2PolyBin*)obj;
976 c = b->GetContent();
977 if (c<min) min=c;
978 }
979 return min;
980}
981
982////////////////////////////////////////////////////////////////////////////////
983/// Returns the minimum value of the histogram that is greater than minval.
984
986{
987 if (fNcells <= kNOverflow) return 0;
988 if (fMinimum != -1111) return fMinimum;
989
990 TH2PolyBin *b;
991
992 TIter next(fBins);
993 TObject *obj;
994 Double_t min,c;
995
996 min = ((TH2PolyBin*) next())->GetContent();
997
998 while ((obj=next())) {
999 b = (TH2PolyBin*)obj;
1000 c = b->GetContent();
1001 if (c<min && c>minval) min=c;
1002 }
1003 return min;
1004}
1005
1006////////////////////////////////////////////////////////////////////////////////
1007/// Bins the histogram using a honeycomb structure
1008/// If the option "v" is specified, the hexagons are drawn "vertically" (default).
1009/// If the option "h" is selected they are drawn "horizontally".
1010
1012{
1013 TString opt = option;
1014 opt.ToLower();
1016 Double_t x[6], y[6];
1018
1019 // Add the bins
1020 if (opt.Contains("v")) {
1021 yloop = ystart + a / 2.0;
1022 for (int sCounter = 0; sCounter < s; sCounter++) {
1023 xtemp = xloop;
1024 // Determine the number of hexagons in that row
1025 if (sCounter%2 == 0)
1027 else
1029
1031 // Go around the hexagon
1032 x[0] = xtemp;
1033 y[0] = yloop;
1034 x[1] = x[0];
1035 y[1] = y[0] + a;
1036 x[2] = x[1] + a * TMath::Sqrt(3) / 2.0;
1037 y[2] = y[1] + a / 2.0;
1038 x[3] = x[2] + a * TMath::Sqrt(3) / 2.0;
1039 y[3] = y[1];
1040 x[4] = x[3];
1041 y[4] = y[0];
1042 x[5] = x[2];
1043 y[5] = y[4] - a/2.0;
1044 this->AddBin(6, x, y);
1045 // Go right
1046 xtemp += a * TMath::Sqrt(3);
1047 }
1048 // Increment the starting position
1049 if (sCounter%2 == 0)
1050 xloop += a * TMath::Sqrt(3) / 2.0;
1051 else
1052 xloop -= a * TMath::Sqrt(3) / 2.0;
1053 yloop += 1.5 * a;
1054 }
1055 } else if (opt.Contains("h")) {
1056 yloop = ystart + a*TMath::Sqrt(3)/2.0;
1057 for (int sCounter = 0; sCounter < s; sCounter++) {
1058 ytemp = yloop;
1059 // Determine the number of hexagons in that row
1060 if (sCounter%2 == 0)
1062 else
1065 // Go around the hexagon
1066 x[0] = xloop;
1067 y[0] = ytemp;
1068 x[1] = x[0] + a/2.0;
1069 y[1] = y[0] + a * TMath::Sqrt(3) / 2.0;
1070 x[2] = x[1] + a;
1071 y[2] = y[1];
1072 x[3] = x[2] + a/2.0;
1073 y[3] = y[0];
1074 x[4] = x[2];
1075 y[4] = y[3] - a * TMath::Sqrt(3) / 2.0;
1076 x[5] = x[1];
1077 y[5] = y[4];
1078 this->AddBin(6, x, y);
1079 // Go up
1080 ytemp += a * TMath::Sqrt(3);
1081 }
1082 // Increment the starting position
1083 if (sCounter%2 == 0)
1084 yloop += a * TMath::Sqrt(3) / 2.0;
1085 else
1086 yloop -= a * TMath::Sqrt(3) / 2.0;
1087 xloop += 1.5 * a;
1088 }
1089 } else {
1090 Error("Honeycomb", "Unknown option");
1091 }
1092
1093}
1094
1095////////////////////////////////////////////////////////////////////////////////
1096/// Initializes the TH2Poly object. This method is called by the constructor.
1097
1099 Double_t ylow, Double_t yup, Int_t n, Int_t m)
1100{
1101 Int_t i;
1102 fDimension = 2; //The dimension of the histogram
1103
1104 fBins = nullptr;
1106
1107 // Sets the boundaries of the histogram
1108 fXaxis.Set(100, xlow, xup);
1109 fYaxis.Set(100, ylow, yup);
1110
1111 for (i=0; i<9; i++) fOverflow[i] = 0.;
1112
1113 // Statistics
1114 fEntries = 0; // The total number of entries
1115 fTsumw = 0.; // Total amount of content in the histogram
1116 fTsumw2 = 0.; // Sum square of the weights
1117 fTsumwx = 0.; // Weighted sum of x coordinates
1118 fTsumwx2 = 0.; // Weighted sum of the squares of x coordinates
1119 fTsumwy2 = 0.; // Weighted sum of the squares of y coordinates
1120 fTsumwy = 0.; // Weighted sum of y coordinates
1121
1122 fCellX = n; // Set the number of cells to default
1123 fCellY = m; // Set the number of cells to default
1124
1125 // number of cells in the grid
1126 //N.B. not to be confused with fNcells (the number of bins) !
1128 fCells = new TList [fNCells]; // Sets an empty partition
1129 fStepX = (fXaxis.GetXmax() - fXaxis.GetXmin())/fCellX; // Cell width
1130 fStepY = (fYaxis.GetXmax() - fYaxis.GetXmin())/fCellY; // Cell height
1131
1132 fIsEmpty = new Bool_t [fNCells]; // Empty partition
1133 fCompletelyInside = new Bool_t [fNCells]; // Cell is completely inside bin
1134
1135 for (i = 0; i<fNCells; i++) { // Initializes the flags
1136 fIsEmpty[i] = kTRUE;
1138 }
1139
1140 // 3D Painter flags
1143}
1144
1145////////////////////////////////////////////////////////////////////////////////
1146/// Returns kTRUE if the input bin is intersecting with the
1147/// input rectangle (xclipl, xclipr, yclipb, yclipt)
1148
1152{
1153 Int_t gn;
1154 Double_t *gx;
1155 Double_t *gy;
1157 TObject *poly = bin->GetPolygon();
1158
1159 if (poly->IsA() == TGraph::Class()) {
1160 TGraph *g = (TGraph*)poly;
1161 gx = g->GetX();
1162 gy = g->GetY();
1163 gn = g->GetN();
1165 }
1166
1167 if (poly->IsA() == TMultiGraph::Class()) {
1169 TList *gl = mg->GetListOfGraphs();
1170 if (!gl) return inter;
1171 TGraph *g;
1172 TIter next(gl);
1173 while ((g = (TGraph*) next())) {
1174 gx = g->GetX();
1175 gy = g->GetY();
1176 gn = g->GetN();
1178 yclipb, yclipt);
1179 if (inter) return inter;
1180 }
1181 }
1182
1183 return inter;
1184}
1185
1186////////////////////////////////////////////////////////////////////////////////
1187/// Returns kTRUE if the input polygon (bn, x, y) is intersecting with the
1188/// input rectangle (xclipl, xclipr, yclipb, yclipt)
1189
1193{
1194 Bool_t p0R, p0L, p0T, p0B, p0xM, p0yM, p1R, p1L, p1T;
1196
1197 for (int counter = 0; counter < (bn-1); counter++) {
1198 // If both are on the same side, return kFALSE
1199 p0L = x[counter] <= xclipl; // Point 0 is on the left
1200 p1L = x[counter + 1] <= xclipl; // Point 1 is on the left
1201 if (p0L && p1L) continue;
1202 p0R = x[counter] >= xclipr; // Point 0 is on the right
1203 p1R = x[counter + 1] >= xclipr; // Point 1 is on the right
1204 if (p0R && p1R) continue;
1205 p0T = y[counter] >= yclipt; // Point 0 is at the top
1206 p1T = y[counter + 1] >= yclipt; // Point 1 is at the top
1207 if (p0T && p1T) continue;
1208 p0B = y[counter] <= yclipb; // Point 0 is at the bottom
1209 p1B = y[counter + 1] <= yclipb; // Point 1 is at the bottom
1210 if (p0B && p1B) continue;
1211
1212 // Checks to see if any are inside
1213 p0xM = !p0R && !p0L; // Point 0 is inside along x
1214 p0yM = !p0T && !p0B; // Point 1 is inside along x
1215 p1xM = !p1R && !p1L; // Point 0 is inside along y
1216 p1yM = !p1T && !p1B; // Point 1 is inside along y
1217 p0In = p0xM && p0yM; // Point 0 is inside
1218 p1In = p1xM && p1yM; // Point 1 is inside
1219 if (p0In) {
1220 if (p1In) continue;
1221 return kTRUE;
1222 } else {
1223 if (p1In) return kTRUE;
1224 }
1225
1226 // We know by now that the points are not in the same side and not inside.
1227
1228 // Checks to see if they are opposite
1229
1230 if (p0xM && p1xM) return kTRUE;
1231 if (p0yM && p1yM) return kTRUE;
1232
1233 // We now know that the points are in different x and y indices
1234
1235 Double_t xcoord[3], ycoord[3];
1236 xcoord[0] = x[counter];
1237 xcoord[1] = x[counter + 1];
1238 ycoord[0] = y[counter];
1239 ycoord[1] = y[counter + 1];
1240
1241 if (p0L) {
1242 if(p1T){
1243 xcoord[2] = xclipl;
1244 ycoord[2] = yclipb;
1246 (TMath::IsInside(xclipr, yclipb, 3, xcoord, ycoord))) continue;
1247 else return kTRUE;
1248 } else if (p1B) {
1249 xcoord[2] = xclipl;
1250 ycoord[2] = yclipt;
1252 (TMath::IsInside(xclipr, yclipt, 3, xcoord, ycoord))) continue;
1253 else return kTRUE;
1254 } else { // p1yM
1255 if (p0T) {
1256 xcoord[2] = xclipl;
1257 ycoord[2] = yclipb;
1258 if (TMath::IsInside(xclipr, yclipt, 3, xcoord, ycoord)) continue;
1259 else return kTRUE;
1260 }
1261 if (p0B) {
1262 xcoord[2] = xclipl;
1263 ycoord[2] = yclipt;
1264 if (TMath::IsInside(xclipr, yclipb, 3, xcoord, ycoord)) continue;
1265 else return kTRUE;
1266 }
1267 }
1268 } else if (p0R) {
1269 if (p1T) {
1270 xcoord[2] = xclipl;
1271 ycoord[2] = yclipb;
1272 if ((TMath::IsInside(xclipr, yclipb, 3, xcoord, ycoord)) ||
1273 (TMath::IsInside(xclipl, yclipt, 3, xcoord, ycoord))) continue;
1274 else return kTRUE;
1275 } else if (p1B) {
1276 xcoord[2] = xclipl;
1277 ycoord[2] = yclipt;
1278 if ((TMath::IsInside(xclipl, yclipb, 3, xcoord, ycoord)) ||
1279 (TMath::IsInside(xclipr, yclipt, 3, xcoord, ycoord))) continue;
1280 else return kTRUE;
1281 } else{ // p1yM
1282 if (p0T) {
1283 xcoord[2] = xclipr;
1284 ycoord[2] = yclipb;
1285 if (TMath::IsInside(xclipl, yclipt, 3, xcoord, ycoord)) continue;
1286 else return kTRUE;
1287 }
1288 if (p0B) {
1289 xcoord[2] = xclipr;
1290 ycoord[2] = yclipt;
1291 if (TMath::IsInside(xclipl, yclipb, 3, xcoord, ycoord)) continue;
1292 else return kTRUE;
1293 }
1294 }
1295 }
1296 }
1297 return kFALSE;
1298}
1299
1300////////////////////////////////////////////////////////////////////////////////
1301/// Merge TH2Polys
1302/// Given the special nature of the TH2Poly, the merge is implemented in
1303/// terms of subsequent TH2Poly::Add calls.
1305{
1306 for (auto h2pAsObj : *coll) {
1307 if (!Add((TH1*)h2pAsObj, 1.)) {
1308 Warning("Merge", "An issue was encountered during the merge operation.");
1309 return 0L;
1310 }
1311 }
1312 return GetEntries();
1313}
1314
1315////////////////////////////////////////////////////////////////////////////////
1316/// Save primitive as a C++ statement(s) on output stream out
1317
1318void TH2Poly::SavePrimitive(std::ostream &out, Option_t *option)
1319{
1320 // histogram pointer has by default the histogram name.
1321 // however, in case histogram has no directory, it is safer to add a
1322 // incremental suffix
1324
1325 out << " \n";
1326
1327 // Construct the class initialization
1328 out << " " << ClassName() << " *" << hname << " = new " << ClassName() << "(\"" << TString(GetName()).ReplaceSpecialCppChars() << "\", \""
1329 << TString(GetTitle()).ReplaceSpecialCppChars() << "\", " << fCellX << ", " << fXaxis.GetXmin() << ", "
1330 << fXaxis.GetXmax() << ", " << fCellY << ", " << fYaxis.GetXmin() << ", " << fYaxis.GetXmax() << ");\n";
1331
1332 // Save Bins
1333 TIter next(fBins);
1334 while (auto obj = next()) {
1335 auto th2pBin = (TH2PolyBin *)obj;
1336 th2pBin->GetPolygon()->SavePrimitive(out, TString::Format("th2poly%s", hname.Data()));
1337 }
1338
1339 // save bin contents
1340 out << " \n";
1341 for (Int_t bin = 1; bin <= GetNumberOfBins(); bin++) {
1342 Double_t bc = GetBinContent(bin);
1343 if (bc)
1344 out << " " << hname << "->SetBinContent(" << bin << "," << bc << ");\n";
1345 }
1346
1347 // save bin errors
1348 if (fSumw2.fN) {
1349 for (Int_t bin = 1; bin <= GetNumberOfBins(); bin++) {
1350 Double_t be = GetBinError(bin);
1351 if (be)
1352 out << " " << hname << "->SetBinError(" << bin << "," << be << ");\n";
1353 }
1354 }
1355
1357}
1358
1359////////////////////////////////////////////////////////////////////////////////
1360/// Multiply this histogram by a constant c1.
1361
1363{
1364 for( int i = 0; i < this->GetNumberOfBins(); i++ ) {
1365 this->SetBinContent(i+1, c1*this->GetBinContent(i+1));
1366 }
1367 for( int i = 0; i < kNOverflow; i++ ) {
1368 this->SetBinContent(-i-1, c1*this->GetBinContent(-i-1) );
1369 }
1370}
1371
1372////////////////////////////////////////////////////////////////////////////////
1373/// Sets the contents of the input bin to the input content
1374/// Negative values between -1 and -9 are for the overflows and the sea
1375
1377{
1378 if (bin > GetNumberOfBins() || bin == 0 || bin < -9 ) return;
1379 if (bin > 0) {
1380 ((TH2PolyBin*) fBins->At(bin-1))->SetContent(content);
1381 }
1382 else
1383 fOverflow[-bin - 1] = content;
1384
1386 fEntries++;
1387}
1388
1389////////////////////////////////////////////////////////////////////////////////
1390/// When set to kTRUE, allows the histogram to expand if a bin outside the
1391/// limits is added.
1392
1394{
1395 fFloat = flag;
1396}
1397
1398////////////////////////////////////////////////////////////////////////////////
1399/// Return "true" if the point (x,y) is inside the bin of binnr.
1400
1402{
1403 if (!fBins) return false;
1404 TH2PolyBin* bin = (TH2PolyBin*)fBins->At(binnr);
1405 if (!bin) return false;
1406 return bin->IsInside(x,y);
1407}
1408
1409void TH2Poly::GetStats(Double_t *stats) const
1410{
1411 stats[0] = fTsumw;
1412 stats[1] = fTsumw2;
1413 stats[2] = fTsumwx;
1414 stats[3] = fTsumwx2;
1415 stats[4] = fTsumwy;
1416 stats[5] = fTsumwy2;
1417 stats[6] = fTsumwxy;
1418}
1419
1420/** \class TH2PolyBin
1421 \ingroup Histograms
1422Helper class to represent a bin in the TH2Poly histogram
1423*/
1424
1425////////////////////////////////////////////////////////////////////////////////
1426/// Default constructor.
1427
1429{
1430 fPoly = nullptr;
1431 fContent = 0.;
1432 fNumber = 0;
1433 fXmax = -1111;
1434 fXmin = -1111;
1435 fYmax = -1111;
1436 fYmin = -1111;
1437 fArea = 0;
1439}
1440
1441////////////////////////////////////////////////////////////////////////////////
1442/// Normal constructor.
1443
1445{
1446 fContent = 0.;
1448 fArea = 0.;
1449 fPoly = poly;
1450 fXmax = -1111;
1451 fXmin = -1111;
1452 fYmax = -1111;
1453 fYmin = -1111;
1455}
1456
1457////////////////////////////////////////////////////////////////////////////////
1458/// Destructor.
1459
1461{
1462 if (fPoly) delete fPoly;
1463}
1464
1465////////////////////////////////////////////////////////////////////////////////
1466/// Returns the area of the bin.
1467
1469{
1470 Int_t bn;
1471
1472 if (fArea == 0) {
1473 if (fPoly->IsA() == TGraph::Class()) {
1474 TGraph *g = (TGraph*)fPoly;
1475 bn = g->GetN();
1476 fArea = g->Integral(0,bn-1);
1477 }
1478
1479 if (fPoly->IsA() == TMultiGraph::Class()) {
1481 TList *gl = mg->GetListOfGraphs();
1482 if (!gl) return fArea;
1483 TGraph *g;
1484 TIter next(gl);
1485 while ((g = (TGraph*) next())) {
1486 bn = g->GetN();
1487 fArea = fArea + g->Integral(0,bn-1);
1488 }
1489 }
1490 }
1491
1492 return fArea;
1493}
1494
1495////////////////////////////////////////////////////////////////////////////////
1496/// Returns the maximum value for the x coordinates of the bin.
1497
1499{
1500 if (fXmax != -1111) return fXmax;
1501
1502 Int_t bn,i;
1503 Double_t *bx;
1504
1505 if (fPoly->IsA() == TGraph::Class()) {
1506 TGraph *g = (TGraph*)fPoly;
1507 bx = g->GetX();
1508 bn = g->GetN();
1509 fXmax = bx[0];
1510 for (i=1; i<bn; i++) {if (fXmax < bx[i]) fXmax = bx[i];}
1511 }
1512
1513 if (fPoly->IsA() == TMultiGraph::Class()) {
1515 TList *gl = mg->GetListOfGraphs();
1516 if (!gl) return fXmax;
1517 TGraph *g;
1518 TIter next(gl);
1519 Bool_t first = kTRUE;
1520 while ((g = (TGraph*) next())) {
1521 bx = g->GetX();
1522 bn = g->GetN();
1523 if (first) {fXmax = bx[0]; first = kFALSE;}
1524 for (i=0; i<bn; i++) {if (fXmax < bx[i]) fXmax = bx[i];}
1525 }
1526 }
1527
1528 return fXmax;
1529}
1530
1531////////////////////////////////////////////////////////////////////////////////
1532/// Returns the minimum value for the x coordinates of the bin.
1533
1535{
1536 if (fXmin != -1111) return fXmin;
1537
1538 Int_t bn,i;
1539 Double_t *bx;
1540
1541 if (fPoly->IsA() == TGraph::Class()) {
1542 TGraph *g = (TGraph*)fPoly;
1543 bx = g->GetX();
1544 bn = g->GetN();
1545 fXmin = bx[0];
1546 for (i=1; i<bn; i++) {if (fXmin > bx[i]) fXmin = bx[i];}
1547 }
1548
1549 if (fPoly->IsA() == TMultiGraph::Class()) {
1551 TList *gl = mg->GetListOfGraphs();
1552 if (!gl) return fXmin;
1553 TGraph *g;
1554 TIter next(gl);
1555 Bool_t first = kTRUE;
1556 while ((g = (TGraph*) next())) {
1557 bx = g->GetX();
1558 bn = g->GetN();
1559 if (first) {fXmin = bx[0]; first = kFALSE;}
1560 for (i=0; i<bn; i++) {if (fXmin > bx[i]) fXmin = bx[i];}
1561 }
1562 }
1563
1564 return fXmin;
1565}
1566
1567////////////////////////////////////////////////////////////////////////////////
1568/// Returns the maximum value for the y coordinates of the bin.
1569
1571{
1572 if (fYmax != -1111) return fYmax;
1573
1574 Int_t bn,i;
1575 Double_t *by;
1576
1577 if (fPoly->IsA() == TGraph::Class()) {
1578 TGraph *g = (TGraph*)fPoly;
1579 by = g->GetY();
1580 bn = g->GetN();
1581 fYmax = by[0];
1582 for (i=1; i<bn; i++) {if (fYmax < by[i]) fYmax = by[i];}
1583 }
1584
1585 if (fPoly->IsA() == TMultiGraph::Class()) {
1587 TList *gl = mg->GetListOfGraphs();
1588 if (!gl) return fYmax;
1589 TGraph *g;
1590 TIter next(gl);
1591 Bool_t first = kTRUE;
1592 while ((g = (TGraph*) next())) {
1593 by = g->GetY();
1594 bn = g->GetN();
1595 if (first) {fYmax = by[0]; first = kFALSE;}
1596 for (i=0; i<bn; i++) {if (fYmax < by[i]) fYmax = by[i];}
1597 }
1598 }
1599
1600 return fYmax;
1601}
1602
1603////////////////////////////////////////////////////////////////////////////////
1604/// Returns the minimum value for the y coordinates of the bin.
1605
1607{
1608 if (fYmin != -1111) return fYmin;
1609
1610 Int_t bn,i;
1611 Double_t *by;
1612
1613 if (fPoly->IsA() == TGraph::Class()) {
1614 TGraph *g = (TGraph*)fPoly;
1615 by = g->GetY();
1616 bn = g->GetN();
1617 fYmin = by[0];
1618 for (i=1; i<bn; i++) {if (fYmin > by[i]) fYmin = by[i];}
1619 }
1620
1621 if (fPoly->IsA() == TMultiGraph::Class()) {
1623 TList *gl = mg->GetListOfGraphs();
1624 if (!gl) return fYmin;
1625 TGraph *g;
1626 TIter next(gl);
1627 Bool_t first = kTRUE;
1628 while ((g = (TGraph*) next())) {
1629 by = g->GetY();
1630 bn = g->GetN();
1631 if (first) {fYmin = by[0]; first = kFALSE;}
1632 for (i=0; i<bn; i++) {if (fYmin > by[i]) fYmin = by[i];}
1633 }
1634 }
1635
1636 return fYmin;
1637}
1638
1639////////////////////////////////////////////////////////////////////////////////
1640/// Return "true" if the point (x,y) is inside the bin.
1641
1643{
1644 Int_t in=0;
1645
1646 if (fPoly->IsA() == TGraph::Class()) {
1647 TGraph *g = (TGraph*)fPoly;
1648 in = g->IsInside(x, y);
1649 }
1650
1651 if (fPoly->IsA() == TMultiGraph::Class()) {
1653 in = mg->IsInside(x, y);
1654 }
1655
1656 return in;
1657}
1658
1659////////////////////////////////////////////////////////////////////////////////
1660// RE-implement dummy functions to avoid users calling the
1661// corresponding implementations in TH1 or TH2
1662////////////////////////////////////////////////////////////////////////////////
1663
1664////////////////////////////////////////////////////////////////////////////////
1665/// NOT IMPLEMENTED for TH2Poly
1667{
1668 Error("Add", "Not implemented for TH2Poly");
1669 return kFALSE;
1670}
1671
1672////////////////////////////////////////////////////////////////////////////////
1673/// NOT IMPLEMENTED for TH2Poly
1675{
1676 Error("Add", "Not implemented for TH2Poly");
1677 return kFALSE;
1678}
1679
1680////////////////////////////////////////////////////////////////////////////////
1681/// NOT IMPLEMENTED for TH2Poly
1683{
1684 Error("Divide", "Not implemented for TH2Poly");
1685 return kFALSE;
1686}
1687
1688////////////////////////////////////////////////////////////////////////////////
1689/// NOT IMPLEMENTED for TH2Poly
1691{
1692 Error("Multiply", "Not implemented for TH2Poly");
1693 return kFALSE;
1694}
1695////////////////////////////////////////////////////////////////////////////////
1696/// NOT IMPLEMENTED for TH2Poly
1698{
1699 Error("ComputeIntegral", "Not implemented for TH2Poly");
1700 return TMath::QuietNaN();
1701}
1702////////////////////////////////////////////////////////////////////////////////
1703/// NOT IMPLEMENTED for TH2Poly
1705{
1706 Error("FFT", "Not implemented for TH2Poly");
1707 return nullptr;
1708}
1709////////////////////////////////////////////////////////////////////////////////
1710/// NOT IMPLEMENTED for TH2Poly
1712{
1713 Error("GetAsymmetry", "Not implemented for TH2Poly");
1714 return nullptr;
1715}
1716////////////////////////////////////////////////////////////////////////////////
1717/// NOT IMPLEMENTED for TH2Poly
1719{
1720 Error("Interpolate", "Not implemented for TH2Poly");
1721 return TMath::QuietNaN();
1722}
1723////////////////////////////////////////////////////////////////////////////////
1724/// NOT IMPLEMENTED for TH2Poly
1726{
1727 Error("AddBinContent", "Not implemented for TH2Poly");
1728}
1729////////////////////////////////////////////////////////////////////////////////
1730/// NOT IMPLEMENTED for TH2Poly
1732{
1733 Error("AddBinContent", "Not implemented for TH2Poly");
1734}
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define g(i)
Definition RSha256.hxx:105
#define a(i)
Definition RSha256.hxx:99
#define s1(x)
Definition RSha256.hxx:91
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kCounter
Definition TDataType.h:34
Option_t Option_t option
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:142
Double_t * fArray
Definition TArrayD.h:30
void Set(Int_t n) override
Set size of this array to n doubles.
Definition TArrayD.cxx:105
Int_t fN
Definition TArray.h:38
Double_t GetXmax() const
Definition TAxis.h:142
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
Definition TAxis.cxx:790
Double_t GetXmin() const
Definition TAxis.h:141
Collection abstract base class.
Definition TCollection.h:65
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
TObject * Clone(const char *newname="") const override
Make a clone of an collection using the Streamer facility.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
1-Dim function class
Definition TF1.h:182
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
static TClass * Class()
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:109
Double_t * fBuffer
[fBufferSize] entry buffer
Definition TH1.h:169
Int_t fNcells
Number of bins(1D), cells (2D) +U/Overflows.
Definition TH1.h:150
virtual void GetStats(Double_t *stats) const
fill the array stats from the contents of this histogram The array stats must be correctly dimensione...
Definition TH1.cxx:8042
void SetTitle(const char *title) override
Change/set the title.
Definition TH1.cxx:6932
Double_t fTsumw
Total Sum of weights.
Definition TH1.h:157
Double_t fTsumw2
Total Sum of squares of weights.
Definition TH1.h:158
Double_t fTsumwx2
Total Sum of weight*X*X.
Definition TH1.h:160
@ kIsNotW
Histogram is forced to be not weighted even when the histogram is filled with weighted.
Definition TH1.h:410
Double_t fMaximum
Maximum value for plotting.
Definition TH1.h:161
TString ProvideSaveName(Option_t *option, Bool_t testfdir=kFALSE)
Provide variable name for histogram for saving as primitive Histogram pointer has by default the hist...
Definition TH1.cxx:7463
Int_t fDimension
! Histogram dimension (1, 2 or 3 dim)
Definition TH1.h:171
virtual void SetContent(const Double_t *content)
Replace bin contents by the contents of array content.
Definition TH1.cxx:8627
virtual void SavePrimitiveHelp(std::ostream &out, const char *hname, Option_t *option="")
Helper function for the SavePrimitive functions from TH1 or classes derived from TH1,...
Definition TH1.cxx:7590
Double_t fMinimum
Minimum value for plotting.
Definition TH1.h:162
@ kNstat
Size of statistics data (up to TProfile3D)
Definition TH1.h:422
virtual Double_t GetEntries() const
Return the current number of entries.
Definition TH1.cxx:4574
void SetName(const char *name) override
Change the name of this histogram.
Definition TH1.cxx:9193
virtual void ResetStats()
Reset the statistics including the number of entries and replace with values calculated from bin cont...
Definition TH1.cxx:8111
virtual void SetBinErrorOption(EBinErrorOpt type)
Definition TH1.h:629
Double_t fEntries
Number of entries.
Definition TH1.h:156
@ kNormal
Errors with Normal (Wald) approximation: errorUp=errorLow= sqrt(N)
Definition TH1.h:115
TAxis fXaxis
X axis descriptor.
Definition TH1.h:151
TArrayD fSumw2
Array of sum of squares of weights.
Definition TH1.h:165
TAxis fYaxis
Y axis descriptor.
Definition TH1.h:152
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
Definition TH1.cxx:9253
virtual void SetEntries(Double_t n)
Definition TH1.h:639
Double_t fTsumwx
Total Sum of weight*X.
Definition TH1.h:159
Helper class to represent a bin in the TH2Poly histogram.
Definition TH2Poly.h:25
Double_t GetXMin()
Returns the minimum value for the x coordinates of the bin.
Definition TH2Poly.cxx:1534
~TH2PolyBin() override
Destructor.
Definition TH2Poly.cxx:1460
Double_t GetYMax()
Returns the maximum value for the y coordinates of the bin.
Definition TH2Poly.cxx:1570
Double_t GetArea()
Returns the area of the bin.
Definition TH2Poly.cxx:1468
void ClearContent()
Definition TH2Poly.h:32
void Fill(Double_t w)
Definition TH2Poly.h:33
Double_t GetYMin()
Returns the minimum value for the y coordinates of the bin.
Definition TH2Poly.cxx:1606
Double_t fArea
Bin area.
Definition TH2Poly.h:51
Double_t fContent
Bin content.
Definition TH2Poly.h:52
Bool_t IsInside(Double_t x, Double_t y) const
Return "true" if the point (x,y) is inside the bin.
Definition TH2Poly.cxx:1642
Double_t fXmax
X maximum value.
Definition TH2Poly.h:55
Int_t fNumber
Bin number of the bin in TH2Poly.
Definition TH2Poly.h:49
TH2PolyBin()
Default constructor.
Definition TH2Poly.cxx:1428
Double_t fYmax
Y maximum value.
Definition TH2Poly.h:56
Double_t GetXMax()
Returns the maximum value for the x coordinates of the bin.
Definition TH2Poly.cxx:1498
Double_t GetContent() const
Definition TH2Poly.h:35
Double_t fYmin
Y minimum value.
Definition TH2Poly.h:54
void SetChanged(Bool_t flag)
Definition TH2Poly.h:44
Int_t GetBinNumber() const
Definition TH2Poly.h:37
Double_t fXmin
X minimum value.
Definition TH2Poly.h:53
TObject * GetPolygon() const
Definition TH2Poly.h:38
TObject * fPoly
Object holding the polygon definition.
Definition TH2Poly.h:50
2D Histogram with Polygonal Bins
Definition TH2Poly.h:66
Bool_t Multiply(TF1 *, Double_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.cxx:1690
void UpdateBinContent(Int_t bin, Double_t content) override
Raw update of bin content on internal data structure see convention for numbering bins in TH1::GetBin...
Definition TH2Poly.h:182
TH2Poly & operator=(const TH2Poly &rhs)
Assignment operator.
Definition TH2Poly.cxx:201
void ClearBinContents()
Clears the contents of all bins in the histogram.
Definition TH2Poly.cxx:551
Double_t fOverflow[kNOverflow]
Overflow bins.
Definition TH2Poly.h:161
Bool_t fFloat
When set to kTRUE, allows the histogram to expand if a bin outside the limits is added.
Definition TH2Poly.h:169
Bool_t IsIntersecting(TH2PolyBin *bin, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt)
Returns kTRUE if the input bin is intersecting with the input rectangle (xclipl, xclipr,...
Definition TH2Poly.cxx:1149
void SetFloat(Bool_t flag=true)
When set to kTRUE, allows the histogram to expand if a bin outside the limits is added.
Definition TH2Poly.cxx:1393
Double_t Integral(Option_t *option="") const override
Returns the integral of bin contents.
Definition TH2Poly.cxx:785
virtual TH2PolyBin * CreateBin(TObject *poly)
Create appropriate histogram bin.
Definition TH2Poly.cxx:273
Double_t GetBinContent(Int_t bin) const override
Returns the content of the input bin Bin numbers are from [1,nbins] and for the overflow/underflow/se...
Definition TH2Poly.cxx:826
Bool_t * fIsEmpty
[fNCells] The array that returns true if the cell at the given coordinate is empty
Definition TH2Poly.h:167
Double_t RetrieveBinContent(Int_t bin) const override
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
Definition TH2Poly.h:179
TList * fBins
List of bins. The list owns the contained objects.
Definition TH2Poly.h:172
void AddBinToPartition(TH2PolyBin *bin)
Adds the input bin into the partition cell matrix.
Definition TH2Poly.cxx:441
Bool_t fBinContentChanged
!For the 3D Painter
Definition TH2Poly.h:171
Int_t Fill(Double_t x, Double_t y) override
Increment the bin containing (x,y) by 1.
Definition TH2Poly.cxx:649
Int_t GetNumberOfBins() const
Return the number of bins : it should be the size of the bin list.
Definition TH2Poly.cxx:862
void SetBinContentChanged(Bool_t flag)
Definition TH2Poly.h:121
void GetStats(Double_t *stats) const override
Fill the array stats from the contents of this histogram The array stats must be correctly dimensione...
Definition TH2Poly.cxx:1409
Bool_t * fCompletelyInside
[fNCells] The array that returns true if the cell at the given coordinate is completely inside a bin
Definition TH2Poly.h:168
TH2Poly()
Default Constructor. No boundaries specified.
Definition TH2Poly.cxx:146
Bool_t IsInsideBin(Int_t binnr, Double_t x, Double_t y)
Return "true" if the point (x,y) is inside the bin of binnr.
Definition TH2Poly.cxx:1401
Bool_t fNewBinAdded
!For the 3D Painter
Definition TH2Poly.h:170
void Copy(TObject &newth2p) const override
Copy function for TH2Poly.
Definition TH2Poly.cxx:210
void AddBinContent(Int_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.cxx:1725
void SetBinError(Int_t bin, Double_t error) override
Set the bin Error.
Definition TH2Poly.cxx:878
const char * GetBinTitle(Int_t bin) const
Returns the bin title.
Definition TH2Poly.cxx:903
void SetNewBinAdded(Bool_t flag)
Definition TH2Poly.h:123
void Scale(Double_t c1=1, Option_t *option="") override
Multiply this histogram by a constant c1.
Definition TH2Poly.cxx:1362
void ChangePartition(Int_t n, Int_t m)
Changes the number of partition cells in the histogram.
Definition TH2Poly.cxx:513
virtual Double_t Interpolate(Double_t, Double_t)
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.cxx:1718
Double_t GetMinimum() const
Returns the minimum value of the histogram.
Definition TH2Poly.cxx:961
const char * GetBinName(Int_t bin) const
Returns the bin name.
Definition TH2Poly.cxx:893
Double_t fStepX
Definition TH2Poly.h:166
void FillN(Int_t ntimes, const Double_t *x, const Double_t *y, const Double_t *w, Int_t stride=1) override
Fills a 2-D histogram with an array of values and weights.
Definition TH2Poly.cxx:771
Int_t fNCells
Number of partition cells: fCellX*fCellY.
Definition TH2Poly.h:164
Int_t FindBin(Double_t x, Double_t y, Double_t z=0) override
Returns the bin number of the bin at the given coordinate.
Definition TH2Poly.cxx:606
Bool_t Divide(TF1 *, Double_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.cxx:1682
void Initialize(Double_t xlow, Double_t xup, Double_t ylow, Double_t yup, Int_t n, Int_t m)
Initializes the TH2Poly object. This method is called by the constructor.
Definition TH2Poly.cxx:1098
Int_t fCellX
Number of partition cells in the x-direction of the histogram.
Definition TH2Poly.h:162
~TH2Poly() override
Destructor.
Definition TH2Poly.cxx:190
virtual Int_t AddBin(TObject *poly)
Adds a new bin to the histogram.
Definition TH2Poly.cxx:295
Double_t GetBinError(Int_t bin) const override
Returns the value of error associated to bin number bin.
Definition TH2Poly.cxx:841
Bool_t IsIntersectingPolygon(Int_t bn, Double_t *x, Double_t *y, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt)
Returns kTRUE if the input polygon (bn, x, y) is intersecting with the input rectangle (xclipl,...
Definition TH2Poly.cxx:1190
Bool_t Add(const TH1 *h1, Double_t c1) override
Performs the operation: this = this + c1*h1.
Definition TH2Poly.cxx:363
virtual TH1 * GetAsymmetry(TH1 *, Double_t, Double_t)
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.cxx:1711
void Honeycomb(Double_t xstart, Double_t ystart, Double_t a, Int_t k, Int_t s, Option_t *option="v")
Bins the histogram using a honeycomb structure If the option "v" is specified, the hexagons are drawn...
Definition TH2Poly.cxx:1011
Long64_t Merge(TCollection *) override
Merge TH2Polys Given the special nature of the TH2Poly, the merge is implemented in terms of subseque...
Definition TH2Poly.cxx:1304
void SetBinContent(Int_t bin, Double_t content) override
Sets the contents of the input bin to the input content Negative values between -1 and -9 are for the...
Definition TH2Poly.cxx:1376
Double_t GetMaximum() const
Returns the maximum value of the histogram.
Definition TH2Poly.cxx:913
void Reset(Option_t *option) override
Reset this histogram: contents, errors, etc.
Definition TH2Poly.cxx:576
@ kNOverflow
Definition TH2Poly.h:159
Double_t fStepY
Dimensions of a partition cell.
Definition TH2Poly.h:166
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TH2Poly.cxx:1318
TH1 * FFT(TH1 *, Option_t *) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.cxx:1704
Double_t ComputeIntegral(Bool_t, Option_t *) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.cxx:1697
TList * fCells
[fNCells] The array of TLists that store the bins that intersect with each cell. List do not own the ...
Definition TH2Poly.h:165
Int_t fCellY
Number of partition cells in the y-direction of the histogram.
Definition TH2Poly.h:163
Service class for 2-D histogram classes.
Definition TH2.h:30
void Copy(TObject &hnew) const override
Copy.
Definition TH2.cxx:355
Double_t fTsumwxy
Total Sum of weight*X*Y.
Definition TH2.h:36
void Reset(Option_t *option="") override
Reset this histogram: contents, errors, etc.
Definition TH2.cxx:2568
Double_t fTsumwy2
Total Sum of weight*Y*Y.
Definition TH2.h:35
Double_t fTsumwy
Total Sum of weight*Y.
Definition TH2.h:34
void PutStats(Double_t *stats) override
Replace current statistics with the values in array stats.
Definition TH2.cxx:2453
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:81
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:487
A TMultiGraph is a collection of TGraph (or derived) objects.
Definition TMultiGraph.h:34
TList * GetListOfGraphs() const
Definition TMultiGraph.h:70
static TClass * Class()
virtual Int_t IsInside(Double_t x, Double_t y) const
Return 1 if the point (x,y) is inside one of the graphs 0 otherwise.
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
Mother of all ROOT objects.
Definition TObject.h:42
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:461
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1082
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1124
virtual TClass * IsA() const
Definition TObject.h:248
Basic string class.
Definition TString.h:137
void ToLower()
Change string to lower-case.
Definition TString.cxx:1190
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1122
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:2460
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:642
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
TH1F * h1
Definition legend1.C:5
Bool_t IsInside(T xp, T yp, Int_t np, T *x, T *y)
Function which returns kTRUE if point xp,yp lies inside the polygon defined by the np points in array...
Definition TMath.h:1326
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754.
Definition TMath.h:915
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:675
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122
TMarker m
Definition textangle.C:8