Logo ROOT  
Reference Guide
TH2.cxx
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: Rene Brun 26/12/94
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TROOT.h"
13 #include "TBuffer.h"
14 #include "TClass.h"
15 #include "THashList.h"
16 #include "TH2.h"
17 #include "TVirtualPad.h"
18 #include "TF2.h"
19 #include "TProfile.h"
20 #include "TRandom.h"
21 #include "TMatrixFBase.h"
22 #include "TMatrixDBase.h"
23 #include "THLimitsFinder.h"
24 #include "TError.h"
25 #include "TMath.h"
26 #include "TObjString.h"
27 #include "TObjArray.h"
28 #include "TVirtualHistPainter.h"
29 #include "snprintf.h"
30 
31 ClassImp(TH2);
32 
33 /** \addtogroup Hist
34 @{
35 \class TH2C
36 \brief 2-D histogram with a byte per channel (see TH1 documentation)
37 \class TH2S
38 \brief 2-D histogram with a short per channel (see TH1 documentation)
39 \class TH2I
40 \brief 2-D histogram with an int per channel (see TH1 documentation)}
41 \class TH2F
42 \brief 2-D histogram with a float per channel (see TH1 documentation)}
43 \class TH2D
44 \brief 2-D histogram with a double per channel (see TH1 documentation)}
45 @}
46 */
47 
48 /** \class TH2
49  Service class for 2-Dim histogram classes
50 
51 - TH2C a 2-D histogram with one byte per cell (char)
52 - TH2S a 2-D histogram with two bytes per cell (short integer)
53 - TH2I a 2-D histogram with four bytes per cell (32 bits integer)
54 - TH2F a 2-D histogram with four bytes per cell (float)
55 - TH2D a 2-D histogram with eight bytes per cell (double)
56 */
57 
58 
59 ////////////////////////////////////////////////////////////////////////////////
60 /// Constructor.
61 
63 {
64  fDimension = 2;
65  fScalefactor = 1;
66  fTsumwy = fTsumwy2 = fTsumwxy = 0;
67 }
68 
69 
70 ////////////////////////////////////////////////////////////////////////////////
71 /// See comments in the TH1 base class constructors.
72 
73 TH2::TH2(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
74  ,Int_t nbinsy,Double_t ylow,Double_t yup)
75  :TH1(name,title,nbinsx,xlow,xup)
76 {
77  fDimension = 2;
78  fScalefactor = 1;
79  fTsumwy = fTsumwy2 = fTsumwxy = 0;
80  if (nbinsy <= 0) {Warning("TH2","nbinsy is <=0 - set to nbinsy = 1"); nbinsy = 1; }
81  fYaxis.Set(nbinsy,ylow,yup);
82  fNcells = fNcells*(nbinsy+2); // fNCells is set in the TH1 constructor
83 }
84 
85 
86 ////////////////////////////////////////////////////////////////////////////////
87 /// See comments in the TH1 base class constructors.
88 
89 TH2::TH2(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
90  ,Int_t nbinsy,Double_t ylow,Double_t yup)
91  :TH1(name,title,nbinsx,xbins)
92 {
93  fDimension = 2;
94  fScalefactor = 1;
95  fTsumwy = fTsumwy2 = fTsumwxy = 0;
96  if (nbinsy <= 0) {Warning("TH2","nbinsy is <=0 - set to nbinsy = 1"); nbinsy = 1; }
97  fYaxis.Set(nbinsy,ylow,yup);
98  fNcells = fNcells*(nbinsy+2); // fNCells is set in the TH1 constructor
99 }
100 
101 
102 ////////////////////////////////////////////////////////////////////////////////
103 /// See comments in the TH1 base class constructors.
104 
105 TH2::TH2(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
106  ,Int_t nbinsy,const Double_t *ybins)
107  :TH1(name,title,nbinsx,xlow,xup)
108 {
109  fDimension = 2;
110  fScalefactor = 1;
111  fTsumwy = fTsumwy2 = fTsumwxy = 0;
112  if (nbinsy <= 0) {Warning("TH2","nbinsy is <=0 - set to nbinsy = 1"); nbinsy = 1; }
113  if (ybins) fYaxis.Set(nbinsy,ybins);
114  else fYaxis.Set(nbinsy,0,1);
115  fNcells = fNcells*(nbinsy+2); // fNCells is set in the TH1 constructor
116 }
117 
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 /// See comments in the TH1 base class constructors.
121 
122 TH2::TH2(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
123  ,Int_t nbinsy,const Double_t *ybins)
124  :TH1(name,title,nbinsx,xbins)
125 {
126  fDimension = 2;
127  fScalefactor = 1;
128  fTsumwy = fTsumwy2 = fTsumwxy = 0;
129  if (nbinsy <= 0) {Warning("TH2","nbinsy is <=0 - set to nbinsy = 1"); nbinsy = 1; }
130  if (ybins) fYaxis.Set(nbinsy,ybins);
131  else fYaxis.Set(nbinsy,0,1);
132  fNcells = fNcells*(nbinsy+2); // fNCells is set in the TH1 constructor
133 }
134 
135 
136 ////////////////////////////////////////////////////////////////////////////////
137 /// See comments in the TH1 base class constructors.
138 
139 TH2::TH2(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins
140  ,Int_t nbinsy,const Float_t *ybins)
141  :TH1(name,title,nbinsx,xbins)
142 {
143  fDimension = 2;
144  fScalefactor = 1;
145  fTsumwy = fTsumwy2 = fTsumwxy = 0;
146  if (nbinsy <= 0) {Warning("TH2","nbinsy is <=0 - set to nbinsy = 1"); nbinsy = 1; }
147  if (ybins) fYaxis.Set(nbinsy,ybins);
148  else fYaxis.Set(nbinsy,0,1);
149  fNcells = fNcells*(nbinsy+2); // fNCells is set in the TH1 constructor.
150 }
151 
152 
153 ////////////////////////////////////////////////////////////////////////////////
154 /// Copy constructor.
155 /// The list of functions is not copied. (Use Clone if needed)
156 
157 TH2::TH2(const TH2 &h) : TH1()
158 {
159  ((TH2&)h).Copy(*this);
160 }
161 
162 
163 ////////////////////////////////////////////////////////////////////////////////
164 /// Destructor.
165 
167 {
168 }
169 
170 
171 ////////////////////////////////////////////////////////////////////////////////
172 /// Fill histogram with all entries in the buffer.
173 /// - action = -1 histogram is reset and refilled from the buffer (called by THistPainter::Paint)
174 /// - action = 0 histogram is filled from the buffer
175 /// - action = 1 histogram is filled and buffer is deleted
176 /// The buffer is automatically deleted when the number of entries
177 /// in the buffer is greater than the number of entries in the histogram
178 
180 {
181  // do we need to compute the bin size?
182  if (!fBuffer) return 0;
183  Int_t nbentries = (Int_t)fBuffer[0];
184 
185  // nbentries correspond to the number of entries of histogram
186 
187  if (nbentries == 0) return 0;
188  if (nbentries < 0 && action == 0) return 0; // case histogram has been already filled from the buffer
189 
190  Double_t *buffer = fBuffer;
191  if (nbentries < 0) {
192  nbentries = -nbentries;
193  // a reset might call BufferEmpty() giving an infinite loop
194  // Protect it by setting fBuffer = 0
195  fBuffer=0;
196  //do not reset the list of functions
197  Reset("ICES");
198  fBuffer = buffer;
199  }
200 
202  //find min, max of entries in buffer
203  Double_t xmin = fBuffer[2];
204  Double_t xmax = xmin;
205  Double_t ymin = fBuffer[3];
206  Double_t ymax = ymin;
207  for (Int_t i=1;i<nbentries;i++) {
208  Double_t x = fBuffer[3*i+2];
209  if (x < xmin) xmin = x;
210  if (x > xmax) xmax = x;
211  Double_t y = fBuffer[3*i+3];
212  if (y < ymin) ymin = y;
213  if (y > ymax) ymax = y;
214  }
215  if (fXaxis.GetXmax() <= fXaxis.GetXmin() || fYaxis.GetXmax() <= fYaxis.GetXmin()) {
217  } else {
218  fBuffer = 0;
219  Int_t keep = fBufferSize; fBufferSize = 0;
221  if (xmax >= fXaxis.GetXmax()) ExtendAxis(xmax,&fXaxis);
223  if (ymax >= fYaxis.GetXmax()) ExtendAxis(ymax,&fYaxis);
224  fBuffer = buffer;
225  fBufferSize = keep;
226  }
227  }
228 
229  fBuffer = 0;
230  for (Int_t i=0;i<nbentries;i++) {
231  Fill(buffer[3*i+2],buffer[3*i+3],buffer[3*i+1]);
232  }
233  fBuffer = buffer;
234 
235  if (action > 0) { delete [] fBuffer; fBuffer = 0; fBufferSize = 0;}
236  else {
237  if (nbentries == (Int_t)fEntries) fBuffer[0] = -nbentries;
238  else fBuffer[0] = 0;
239  }
240  return nbentries;
241 }
242 
243 
244 ////////////////////////////////////////////////////////////////////////////////
245 /// accumulate arguments in buffer. When buffer is full, empty the buffer
246 /// ~~~ {.cpp}
247 /// fBuffer[0] = number of entries in buffer
248 /// fBuffer[1] = w of first entry
249 /// fBuffer[2] = x of first entry
250 /// fBuffer[3] = y of first entry
251 /// ~~~
252 
254 {
255  if (!fBuffer) return -3;
256  Int_t nbentries = (Int_t)fBuffer[0];
257  if (nbentries < 0) {
258  nbentries = -nbentries;
259  fBuffer[0] = nbentries;
260  if (fEntries > 0) {
261  Double_t *buffer = fBuffer; fBuffer=0;
262  Reset("ICES");
263  fBuffer = buffer;
264  }
265  }
266  if (3*nbentries+3 >= fBufferSize) {
267  BufferEmpty(1);
268  return Fill(x,y,w);
269  }
270  fBuffer[3*nbentries+1] = w;
271  fBuffer[3*nbentries+2] = x;
272  fBuffer[3*nbentries+3] = y;
273  fBuffer[0] += 1;
274  return -3;
275 }
276 
277 
278 ////////////////////////////////////////////////////////////////////////////////
279 /// Copy.
280 
281 void TH2::Copy(TObject &obj) const
282 {
283  TH1::Copy(obj);
284  ((TH2&)obj).fScalefactor = fScalefactor;
285  ((TH2&)obj).fTsumwy = fTsumwy;
286  ((TH2&)obj).fTsumwy2 = fTsumwy2;
287  ((TH2&)obj).fTsumwxy = fTsumwxy;
288 }
289 
290 
291 ////////////////////////////////////////////////////////////////////////////////
292 /// Invalid Fill method.
293 
295 {
296  Error("Fill", "Invalid signature - do nothing");
297  return -1;
298 }
299 
300 
301 ////////////////////////////////////////////////////////////////////////////////
302 /// Increment cell defined by x,y by 1.
303 ///
304 /// - if x or/and y is less than the low-edge of the corresponding axis first bin,
305 /// the Underflow cell is incremented.
306 /// - if x or/and y is equal to or greater than the upper edge of corresponding axis last bin,
307 /// the Overflow cell is incremented.
308 ///
309 /// - If the storage of the sum of squares of weights has been triggered,
310 /// via the function Sumw2, then the sum of the squares of weights is incremented
311 /// by 1 in the cell corresponding to x,y.
312 ///
313 /// The function returns the corresponding global bin number which has its content
314 /// incremented by 1
315 
317 {
318  if (fBuffer) return BufferFill(x,y,1);
319 
320  Int_t binx, biny, bin;
321  fEntries++;
322  binx = fXaxis.FindBin(x);
323  biny = fYaxis.FindBin(y);
324  if (binx <0 || biny <0) return -1;
325  bin = biny*(fXaxis.GetNbins()+2) + binx;
326  AddBinContent(bin);
327  if (fSumw2.fN) ++fSumw2.fArray[bin];
328  if (binx == 0 || binx > fXaxis.GetNbins()) {
329  if (!GetStatOverflowsBehaviour()) return -1;
330  }
331  if (biny == 0 || biny > fYaxis.GetNbins()) {
332  if (!GetStatOverflowsBehaviour()) return -1;
333  }
334  ++fTsumw;
335  ++fTsumw2;
336  fTsumwx += x;
337  fTsumwx2 += x*x;
338  fTsumwy += y;
339  fTsumwy2 += y*y;
340  fTsumwxy += x*y;
341  return bin;
342 }
343 
344 
345 ////////////////////////////////////////////////////////////////////////////////
346 /// Increment cell defined by x,y by a weight w.
347 ///
348 /// - if x or/and y is less than the low-edge of the corresponding axis first bin,
349 /// the Underflow cell is incremented.
350 /// - if x or/and y is equal to or greater than the upper edge of corresponding axis last bin,
351 /// the Overflow cell is incremented.
352 ///
353 /// - If the weight is not equal to 1, the storage of the sum of squares of
354 /// weights is automatically triggered and the sum of the squares of weights is incremented
355 /// by w^2 in the bin corresponding to x,y
356 ///
357 /// The function returns the corresponding global bin number which has its content
358 /// incremented by w
359 
361 {
362  if (fBuffer) return BufferFill(x,y,w);
363 
364  Int_t binx, biny, bin;
365  fEntries++;
366  binx = fXaxis.FindBin(x);
367  biny = fYaxis.FindBin(y);
368  if (binx <0 || biny <0) return -1;
369  bin = biny*(fXaxis.GetNbins()+2) + binx;
370  if (!fSumw2.fN && w != 1.0 && !TestBit(TH1::kIsNotW)) Sumw2(); // must be called before AddBinContent
371  if (fSumw2.fN) fSumw2.fArray[bin] += w*w;
372  AddBinContent(bin,w);
373  if (binx == 0 || binx > fXaxis.GetNbins()) {
374  if (!GetStatOverflowsBehaviour()) return -1;
375  }
376  if (biny == 0 || biny > fYaxis.GetNbins()) {
377  if (!GetStatOverflowsBehaviour()) return -1;
378  }
379  Double_t z= w;
380  fTsumw += z;
381  fTsumw2 += z*z;
382  fTsumwx += z*x;
383  fTsumwx2 += z*x*x;
384  fTsumwy += z*y;
385  fTsumwy2 += z*y*y;
386  fTsumwxy += z*x*y;
387  return bin;
388 }
389 
390 
391 ////////////////////////////////////////////////////////////////////////////////
392 /// Increment cell defined by namex,namey by a weight w
393 ///
394 /// - if x or/and y is less than the low-edge of the corresponding axis first bin,
395 /// the Underflow cell is incremented.
396 /// - if x or/and y is equal to or greater than the upper edge of corresponding axis last bin,
397 /// the Overflow cell is incremented.
398 ///
399 /// - If the weight is not equal to 1, the storage of the sum of squares of
400 /// weights is automatically triggered and the sum of the squares of weights is incremented
401 /// by w^2 in the bin corresponding to namex,namey
402 ///
403 /// The function returns the corresponding global bin number which has its content
404 /// incremented by w
405 
406 Int_t TH2::Fill(const char *namex, const char *namey, Double_t w)
407 {
408  Int_t binx, biny, bin;
409  fEntries++;
410  binx = fXaxis.FindBin(namex);
411  biny = fYaxis.FindBin(namey);
412  if (binx <0 || biny <0) return -1;
413  bin = biny*(fXaxis.GetNbins()+2) + binx;
414  if (!fSumw2.fN && w != 1.0 && !TestBit(TH1::kIsNotW)) Sumw2(); // must be called before AddBinContent
415  if (fSumw2.fN) fSumw2.fArray[bin] += w*w;
416  AddBinContent(bin,w);
417  if (binx == 0 || binx > fXaxis.GetNbins()) return -1;
418  if (biny == 0 || biny > fYaxis.GetNbins()) return -1;
419  Double_t x = fXaxis.GetBinCenter(binx);
420  Double_t y = fYaxis.GetBinCenter(biny);
421  Double_t z= w;
422  fTsumw += z;
423  fTsumw2 += z*z;
424  fTsumwx += z*x;
425  fTsumwx2 += z*x*x;
426  fTsumwy += z*y;
427  fTsumwy2 += z*y*y;
428  fTsumwxy += z*x*y;
429  return bin;
430 }
431 
432 
433 ////////////////////////////////////////////////////////////////////////////////
434 /// Increment cell defined by namex,y by a weight w
435 ///
436 /// - if x or/and y is less than the low-edge of the corresponding axis first bin,
437 /// the Underflow cell is incremented.
438 /// - if x or/and y is equal to or greater than the upper edge of corresponding axis last bin,
439 /// the Overflow cell is incremented.
440 ///
441 /// - If the weight is not equal to 1, the storage of the sum of squares of
442 /// weights is automatically triggered and the sum of the squares of weights is incremented
443 /// by w^2 in the bin corresponding to namex,y
444 ///
445 /// The function returns the corresponding global bin number which has its content
446 /// incremented by w
447 
448 Int_t TH2::Fill(const char *namex, Double_t y, Double_t w)
449 {
450  Int_t binx, biny, bin;
451  fEntries++;
452  binx = fXaxis.FindBin(namex);
453  biny = fYaxis.FindBin(y);
454  if (binx <0 || biny <0) return -1;
455  bin = biny*(fXaxis.GetNbins()+2) + binx;
456  if (!fSumw2.fN && w != 1.0 && !TestBit(TH1::kIsNotW)) Sumw2(); // must be called before AddBinContent
457  if (fSumw2.fN) fSumw2.fArray[bin] += w*w;
458  AddBinContent(bin,w);
459  if (binx == 0 || binx > fXaxis.GetNbins()) return -1;
460  if (biny == 0 || biny > fYaxis.GetNbins()) {
461  if (!GetStatOverflowsBehaviour()) return -1;
462  }
463  Double_t x = fXaxis.GetBinCenter(binx);
464  Double_t z= w; //(w > 0 ? w : -w);
465  fTsumw += z;
466  fTsumw2 += z*z;
467  fTsumwx += z*x;
468  fTsumwx2 += z*x*x;
469  fTsumwy += z*y;
470  fTsumwy2 += z*y*y;
471  fTsumwxy += z*x*y;
472  return bin;
473 }
474 
475 
476 ////////////////////////////////////////////////////////////////////////////////
477 /// Increment cell defined by x,namey by a weight w
478 ///
479 /// - if x or/and y is less than the low-edge of the corresponding axis first bin,
480 /// the Underflow cell is incremented.
481 /// - if x or/and y is equal to or greater than the upper edge of corresponding axis last bin,
482 /// the Overflow cell is incremented.
483 ///
484 /// - If the weight is not equal to 1, the storage of the sum of squares of
485 /// weights is automatically triggered and the sum of the squares of weights is incremented
486 /// by w^2 in the bin corresponding to x,y.
487 ///
488 /// The function returns the corresponding global bin number which has its content
489 /// incremented by w
490 
491 Int_t TH2::Fill(Double_t x, const char *namey, Double_t w)
492 {
493  Int_t binx, biny, bin;
494  fEntries++;
495  binx = fXaxis.FindBin(x);
496  biny = fYaxis.FindBin(namey);
497  if (binx <0 || biny <0) return -1;
498  bin = biny*(fXaxis.GetNbins()+2) + binx;
499  if (!fSumw2.fN && w != 1.0 && !TestBit(TH1::kIsNotW)) Sumw2(); // must be called before AddBinContent
500  if (fSumw2.fN) fSumw2.fArray[bin] += w*w;
501  AddBinContent(bin,w);
502  if (binx == 0 || binx > fXaxis.GetNbins()) {
503  if (!GetStatOverflowsBehaviour()) return -1;
504  }
505  if (biny == 0 || biny > fYaxis.GetNbins()) return -1;
506  Double_t y = fYaxis.GetBinCenter(biny);
507  Double_t z= w; //(w > 0 ? w : -w);
508  fTsumw += z;
509  fTsumw2 += z*z;
510  fTsumwx += z*x;
511  fTsumwx2 += z*x*x;
512  fTsumwy += z*y;
513  fTsumwy2 += z*y*y;
514  fTsumwxy += z*x*y;
515  return bin;
516 }
517 
518 
519 ////////////////////////////////////////////////////////////////////////////////
520 /// Fill a 2-D histogram with an array of values and weights.
521 ///
522 /// - ntimes: number of entries in arrays x and w (array size must be ntimes*stride)
523 /// - x: array of x values to be histogrammed
524 /// - y: array of y values to be histogrammed
525 /// - w: array of weights
526 /// - stride: step size through arrays x, y and w
527 ///
528 /// - If the weight is not equal to 1, the storage of the sum of squares of
529 /// weights is automatically triggered and the sum of the squares of weights is incremented
530 /// by w[i]^2 in the bin corresponding to x[i],y[i].
531 /// - If w is NULL each entry is assumed a weight=1
532 ///
533 /// NB: function only valid for a TH2x object
534 
535 void TH2::FillN(Int_t ntimes, const Double_t *x, const Double_t *y, const Double_t *w, Int_t stride)
536 {
537  Int_t binx, biny, bin, i;
538  ntimes *= stride;
539  Int_t ifirst = 0;
540 
541  //If a buffer is activated, fill buffer
542  // (note that this function must not be called from TH2::BufferEmpty)
543  if (fBuffer) {
544  for (i=0;i<ntimes;i+=stride) {
545  if (!fBuffer) break; // buffer can be deleted in BufferFill when is empty
546  if (w) BufferFill(x[i],y[i],w[i]);
547  else BufferFill(x[i], y[i], 1.);
548  }
549  // fill the remaining entries if the buffer has been deleted
550  if (i < ntimes && fBuffer==0)
551  ifirst = i;
552  else
553  return;
554  }
555 
556  Double_t ww = 1;
557  for (i=ifirst;i<ntimes;i+=stride) {
558  fEntries++;
559  binx = fXaxis.FindBin(x[i]);
560  biny = fYaxis.FindBin(y[i]);
561  if (binx <0 || biny <0) continue;
562  bin = biny*(fXaxis.GetNbins()+2) + binx;
563  if (w) ww = w[i];
564  if (!fSumw2.fN && ww != 1.0 && !TestBit(TH1::kIsNotW)) Sumw2();
565  if (fSumw2.fN) fSumw2.fArray[bin] += ww*ww;
566  AddBinContent(bin,ww);
567  if (binx == 0 || binx > fXaxis.GetNbins()) {
568  if (!GetStatOverflowsBehaviour()) continue;
569  }
570  if (biny == 0 || biny > fYaxis.GetNbins()) {
571  if (!GetStatOverflowsBehaviour()) continue;
572  }
573  Double_t z= ww; //(ww > 0 ? ww : -ww);
574  fTsumw += z;
575  fTsumw2 += z*z;
576  fTsumwx += z*x[i];
577  fTsumwx2 += z*x[i]*x[i];
578  fTsumwy += z*y[i];
579  fTsumwy2 += z*y[i]*y[i];
580  fTsumwxy += z*x[i]*y[i];
581  }
582 }
583 
584 
585 ////////////////////////////////////////////////////////////////////////////////
586 /// Fill histogram following distribution in function fname.
587 ///
588 /// The distribution contained in the function fname (TF2) is integrated
589 /// over the channel contents.
590 /// It is normalized to 1.
591 /// Getting one random number implies:
592 /// - Generating a random number between 0 and 1 (say r1)
593 /// - Look in which bin in the normalized integral r1 corresponds to
594 /// - Fill histogram channel
595 /// ntimes random numbers are generated
596 ///
597 /// One can also call TF2::GetRandom2 to get a random variate from a function.
598 
599 void TH2::FillRandom(const char *fname, Int_t ntimes)
600 {
601  Int_t bin, binx, biny, ibin, loop;
602  Double_t r1, x, y;
603  //*-*- Search for fname in the list of ROOT defined functions
604  TObject *fobj = gROOT->GetFunction(fname);
605  if (!fobj) { Error("FillRandom", "Unknown function: %s",fname); return; }
606  TF2 * f1 = dynamic_cast<TF2*>(fobj);
607  if (!f1) { Error("FillRandom", "Function: %s is not a TF2, is a %s",fname,fobj->IsA()->GetName()); return; }
608 
609 
610  TAxis & xAxis = fXaxis;
611  TAxis & yAxis = fYaxis;
612 
613  // in case axes of histogram are not defined use the function axis
614  if (fXaxis.GetXmax() <= fXaxis.GetXmin() || fYaxis.GetXmax() <= fYaxis.GetXmin()) {
617  Info("FillRandom","Using function axis and range ([%g,%g],[%g,%g])",xmin, xmax,ymin,ymax);
618  xAxis = *(f1->GetHistogram()->GetXaxis());
619  yAxis = *(f1->GetHistogram()->GetYaxis());
620  }
621 
622 
623  // Allocate temporary space to store the integral and compute integral
624  Int_t nbinsx = xAxis.GetNbins();
625  Int_t nbinsy = yAxis.GetNbins();
626  Int_t nbins = nbinsx*nbinsy;
627 
628 
629  Double_t *integral = new Double_t[nbins+1];
630  ibin = 0;
631  integral[ibin] = 0;
632  for (biny=1;biny<=nbinsy;biny++) {
633  for (binx=1;binx<=nbinsx;binx++) {
634  ibin++;
635  Double_t fint = f1->Integral(xAxis.GetBinLowEdge(binx), xAxis.GetBinUpEdge(binx), yAxis.GetBinLowEdge(biny), yAxis.GetBinUpEdge(biny));
636  integral[ibin] = integral[ibin-1] + fint;
637  }
638  }
639 
640  // Normalize integral to 1
641  if (integral[nbins] == 0 ) {
642  delete [] integral;
643  Error("FillRandom", "Integral = zero"); return;
644  }
645  for (bin=1;bin<=nbins;bin++) integral[bin] /= integral[nbins];
646 
647  // Start main loop ntimes
648  for (loop=0;loop<ntimes;loop++) {
649  r1 = gRandom->Rndm();
650  ibin = TMath::BinarySearch(nbins,&integral[0],r1);
651  biny = ibin/nbinsx;
652  binx = 1 + ibin - nbinsx*biny;
653  biny++;
654  x = xAxis.GetBinCenter(binx);
655  y = yAxis.GetBinCenter(biny);
656  Fill(x,y);
657  }
658  delete [] integral;
659 }
660 
661 
662 ////////////////////////////////////////////////////////////////////////////////
663 /// Fill histogram following distribution in histogram h.
664 ///
665 /// The distribution contained in the histogram h (TH2) is integrated
666 /// over the channel contents.
667 /// It is normalized to 1.
668 /// Getting one random number implies:
669 /// - Generating a random number between 0 and 1 (say r1)
670 /// - Look in which bin in the normalized integral r1 corresponds to
671 /// - Fill histogram channel
672 /// ntimes random numbers are generated
673 
674 void TH2::FillRandom(TH1 *h, Int_t ntimes)
675 {
676  if (!h) { Error("FillRandom", "Null histogram"); return; }
677  if (fDimension != h->GetDimension()) {
678  Error("FillRandom", "Histograms with different dimensions"); return;
679  }
680 
681  if (h->ComputeIntegral() == 0) return;
682 
683  Int_t loop;
684  Double_t x,y;
685  TH2 *h2 = (TH2*)h;
686  for (loop=0;loop<ntimes;loop++) {
687  h2->GetRandom2(x,y);
688  Fill(x,y);
689  }
690 }
691 
692 
693 ////////////////////////////////////////////////////////////////////////////////
694 
695 void TH2::DoFitSlices(bool onX,
696  TF1 *f1, Int_t firstbin, Int_t lastbin, Int_t cut, Option_t *option, TObjArray* arr)
697 {
698  TAxis& outerAxis = (onX ? fYaxis : fXaxis);
699  TAxis& innerAxis = (onX ? fXaxis : fYaxis);
700 
701  Int_t nbins = outerAxis.GetNbins();
702  // get correct first last bins for outer axis
703  // when using default values (0,-1) check if an axis range is set in outer axis
704  // do same as in DoProjection for inner axis
705  if ( lastbin < firstbin && outerAxis.TestBit(TAxis::kAxisRange) ) {
706  firstbin = outerAxis.GetFirst();
707  lastbin = outerAxis.GetLast();
708  // For special case of TAxis::SetRange, when first == 1 and last
709  // = N and the range bit has been set, the TAxis will return 0
710  // for both.
711  if (firstbin == 0 && lastbin == 0) {
712  firstbin = 1;
713  lastbin = nbins;
714  }
715  }
716  if (firstbin < 0) firstbin = 0;
717  if (lastbin < 0 || lastbin > nbins + 1) lastbin = nbins + 1;
718  if (lastbin < firstbin) {firstbin = 0; lastbin = nbins + 1;}
719 
720 
721  TString opt = option;
722  TString proj_opt = "e";
723  Int_t i1 = opt.Index("[");
724  Int_t i2 = opt.Index("]");
725  if (i1>=0 && i2>i1) {
726  proj_opt += opt(i1,i2-i1+1);
727  opt.Remove(i1, i2-i1+1);
728  }
729  opt.ToLower();
730  Int_t ngroup = 1;
731  if (opt.Contains("g2")) {ngroup = 2; opt.ReplaceAll("g2","");}
732  if (opt.Contains("g3")) {ngroup = 3; opt.ReplaceAll("g3","");}
733  if (opt.Contains("g4")) {ngroup = 4; opt.ReplaceAll("g4","");}
734  if (opt.Contains("g5")) {ngroup = 5; opt.ReplaceAll("g5","");}
735 
736  // implement option S sliding merge for each bin using in conjunction with a given Gn
737  Int_t nstep = ngroup;
738  if (opt.Contains("s")) nstep = 1;
739 
740  //default is to fit with a gaussian
741  if (f1 == 0) {
742  f1 = (TF1*)gROOT->GetFunction("gaus");
743  if (f1 == 0) f1 = new TF1("gaus","gaus",innerAxis.GetXmin(),innerAxis.GetXmax());
744  else f1->SetRange(innerAxis.GetXmin(),innerAxis.GetXmax());
745  }
746  Int_t npar = f1->GetNpar();
747  if (npar <= 0) return;
748  Double_t *parsave = new Double_t[npar];
749  f1->GetParameters(parsave);
750 
751  if (arr) {
752  arr->SetOwner();
753  arr->Expand(npar + 1);
754  }
755 
756  //Create one histogram for each function parameter
757  Int_t ipar;
758  TH1D **hlist = new TH1D*[npar];
759  char *name = new char[2000];
760  char *title = new char[2000];
761  const TArrayD *bins = outerAxis.GetXbins();
762  // outer axis boudaries used for creating reported histograms are different
763  // than the limits used in the projection loop (firstbin,lastbin)
764  Int_t firstOutBin = outerAxis.TestBit(TAxis::kAxisRange) ? std::max(firstbin,1) : 1;
765  Int_t lastOutBin = outerAxis.TestBit(TAxis::kAxisRange) ? std::min(lastbin,outerAxis.GetNbins() ) : outerAxis.GetNbins();
766  Int_t nOutBins = lastOutBin-firstOutBin+1;
767  // merge bins if use nstep > 1 and fixed bins
768  if (bins->fN == 0) nOutBins /= nstep;
769  for (ipar=0;ipar<npar;ipar++) {
770  snprintf(name,2000,"%s_%d",GetName(),ipar);
771  snprintf(title,2000,"Fitted value of par[%d]=%s",ipar,f1->GetParName(ipar));
772  delete gDirectory->FindObject(name);
773  if (bins->fN == 0) {
774  hlist[ipar] = new TH1D(name,title, nOutBins, outerAxis.GetBinLowEdge(firstOutBin), outerAxis.GetBinUpEdge(lastOutBin));
775  } else {
776  hlist[ipar] = new TH1D(name,title, nOutBins, &bins->fArray[firstOutBin-1]);
777  }
778  hlist[ipar]->GetXaxis()->SetTitle(outerAxis.GetTitle());
779  if (arr)
780  (*arr)[ipar] = hlist[ipar];
781  }
782  snprintf(name,2000,"%s_chi2",GetName());
783  delete gDirectory->FindObject(name);
784  TH1D *hchi2 = 0;
785  if (bins->fN == 0) {
786  hchi2 = new TH1D(name,"chisquare", nOutBins, outerAxis.GetBinLowEdge(firstOutBin), outerAxis.GetBinUpEdge(lastOutBin));
787  } else {
788  hchi2 = new TH1D(name,"chisquare", nOutBins, &bins->fArray[firstOutBin-1]);
789  }
790  hchi2->GetXaxis()->SetTitle(outerAxis.GetTitle());
791  if (arr)
792  (*arr)[npar] = hchi2;
793 
794  //Loop on all bins in Y, generate a projection along X
795  Int_t bin;
796  // in case of sliding merge nstep=1, i.e. do slices starting for every bin
797  // now do not slices case with overflow (makes more sense)
798  // when fitting add the option "N". We don;t want to display and store the function
799  // for the temporary histograms that are created and fitted
800  opt += " n ";
801  TH1D *hp = nullptr;
802  for (bin=firstbin;bin+ngroup-1<=lastbin;bin += nstep) {
803  if (onX)
804  hp= ProjectionX("_temp",bin,bin+ngroup-1,proj_opt);
805  else
806  hp= ProjectionY("_temp",bin,bin+ngroup-1,proj_opt);
807  if (hp == 0) continue;
808  // nentries can be the effective entries and it could be a very small number but not zero!
809  Double_t nentries = hp->GetEntries();
810  if ( nentries <= 0 || nentries < cut) {
811  if (!opt.Contains("Q"))
812  Info("DoFitSlices","Slice %d skipped, the number of entries is zero or smaller than the given cut value, n=%f",bin,nentries);
813  continue;
814  }
815  f1->SetParameters(parsave);
816  Int_t binOn = hlist[0]->FindBin(outerAxis.GetBinCenter(bin+ngroup/2));
817  if (!opt.Contains("Q"))
818  Info("DoFitSlices","Slice fit %d (%f,%f)",binOn,hlist[0]->GetXaxis()->GetBinLowEdge(binOn),hlist[0]->GetXaxis()->GetBinUpEdge(binOn));
819  hp->Fit(f1,opt.Data());
820  Int_t npfits = f1->GetNumberFitPoints();
821  if (npfits > npar && npfits >= cut) {
822  for (ipar=0;ipar<npar;ipar++) {
823  hlist[ipar]->SetBinContent(binOn,f1->GetParameter(ipar));
824  hlist[ipar]->SetBinError(binOn,f1->GetParError(ipar));
825  }
826  hchi2->SetBinContent(binOn,f1->GetChisquare()/(npfits-npar));
827  }
828  else {
829  if (!opt.Contains("Q"))
830  Info("DoFitSlices","Fitted slice %d skipped, the number of fitted points is too small, n=%d",bin,npfits);
831  }
832  // don't need to delete hp. If histogram has the same name it is re-used in TH2::Projection
833  }
834  delete hp;
835  delete [] parsave;
836  delete [] name;
837  delete [] title;
838  delete [] hlist;
839 }
840 
841 
842 ////////////////////////////////////////////////////////////////////////////////
843 /// Project slices along X in case of a 2-D histogram, then fit each slice
844 /// with function f1 and make a histogram for each fit parameter
845 /// Only bins along Y between firstybin and lastybin are considered.
846 /// By default (firstybin == 0, lastybin == -1), all bins in y including
847 /// over- and underflows are taken into account.
848 /// If f1=0, a gaussian is assumed
849 /// Before invoking this function, one can set a subrange to be fitted along X
850 /// via f1->SetRange(xmin,xmax)
851 /// The argument option (default="QNR") can be used to change the fit options.
852 /// - "Q" means Quiet mode
853 /// - "N" means do not show the result of the fit
854 /// - "R" means fit the function in the specified function range
855 /// - "G2" merge 2 consecutive bins along X
856 /// - "G3" merge 3 consecutive bins along X
857 /// - "G4" merge 4 consecutive bins along X
858 /// - "G5" merge 5 consecutive bins along X
859 /// - "S" sliding merge: merge n consecutive bins along X accordingly to what Gn is given.
860 /// It makes sense when used together with a Gn option
861 ///
862 /// The generated histograms are returned by adding them to arr, if arr is not NULL.
863 /// arr's SetOwner() is called, to signal that it is the user's responsibility to
864 /// delete the histograms, possibly by deleting the array.
865 /// ~~~ {.cpp}
866 /// TObjArray aSlices;
867 /// h2->FitSlicesX(func, 0, -1, 0, "QNR", &aSlices);
868 /// ~~~
869 /// will already delete the histograms once aSlice goes out of scope. aSlices will
870 /// contain the histogram for the i-th parameter of the fit function at aSlices[i];
871 /// aSlices[n] (n being the number of parameters) contains the chi2 distribution of
872 /// the fits.
873 ///
874 /// If arr is NULL, the generated histograms are added to the list of objects
875 /// in the current directory. It is the user's responsibility to delete
876 /// these histograms.
877 ///
878 /// Example: Assume a 2-d histogram h2
879 /// ~~~ {.cpp}
880 /// Root > h2->FitSlicesX(); produces 4 TH1D histograms
881 /// with h2_0 containing parameter 0(Constant) for a Gaus fit
882 /// of each bin in Y projected along X
883 /// with h2_1 containing parameter 1(Mean) for a gaus fit
884 /// with h2_2 containing parameter 2(StdDev) for a gaus fit
885 /// with h2_chi2 containing the chisquare/number of degrees of freedom for a gaus fit
886 ///
887 /// Root > h2->FitSlicesX(0,15,22,10);
888 /// same as above, but only for bins 15 to 22 along Y
889 /// and only for bins in Y for which the corresponding projection
890 /// along X has more than cut bins filled.
891 /// ~~~
892 /// NOTE: To access the generated histograms in the current directory, do eg:
893 /// ~~~ {.cpp}
894 /// TH1D *h2_1 = (TH1D*)gDirectory->Get("h2_1");
895 /// ~~~
896 
897 void TH2::FitSlicesX(TF1 *f1, Int_t firstybin, Int_t lastybin, Int_t cut, Option_t *option, TObjArray* arr)
898 {
899  DoFitSlices(true, f1, firstybin, lastybin, cut, option, arr);
900 
901 }
902 
903 
904 ////////////////////////////////////////////////////////////////////////////////
905 /// Project slices along Y in case of a 2-D histogram, then fit each slice
906 /// with function f1 and make a histogram for each fit parameter
907 /// Only bins along X between firstxbin and lastxbin are considered.
908 /// By default (firstxbin == 0, lastxbin == -1), all bins in x including
909 /// over- and underflows are taken into account.
910 /// If f1=0, a gaussian is assumed
911 /// Before invoking this function, one can set a subrange to be fitted along Y
912 /// via f1->SetRange(ymin,ymax)
913 /// The argument option (default="QNR") can be used to change the fit options.
914 /// - "Q" means Quiet mode
915 /// - "N" means do not show the result of the fit
916 /// - "R" means fit the function in the specified function range
917 /// - "G2" merge 2 consecutive bins along Y
918 /// - "G3" merge 3 consecutive bins along Y
919 /// - "G4" merge 4 consecutive bins along Y
920 /// - "G5" merge 5 consecutive bins along Y
921 /// - "S" sliding merge: merge n consecutive bins along Y accordingly to what Gn is given.
922 /// It makes sense when used together with a Gn option
923 ///
924 /// The generated histograms are returned by adding them to arr, if arr is not NULL.
925 /// arr's SetOwner() is called, to signal that it is the user's responsibility to
926 /// delete the histograms, possibly by deleting the array.
927 /// ~~~ {.cpp}
928 /// TObjArray aSlices;
929 /// h2->FitSlicesY(func, 0, -1, 0, "QNR", &aSlices);
930 /// ~~~
931 /// will already delete the histograms once aSlice goes out of scope. aSlices will
932 /// contain the histogram for the i-th parameter of the fit function at aSlices[i];
933 /// aSlices[n] (n being the number of parameters) contains the chi2 distribution of
934 /// the fits.
935 ///
936 /// If arr is NULL, the generated histograms are added to the list of objects
937 /// in the current directory. It is the user's responsibility to delete
938 /// these histograms.
939 ///
940 /// Example: Assume a 2-d histogram h2
941 /// ~~~ {.cpp}
942 /// Root > h2->FitSlicesY(); produces 4 TH1D histograms
943 /// with h2_0 containing parameter 0(Constant) for a Gaus fit
944 /// of each bin in X projected along Y
945 /// with h2_1 containing parameter 1(Mean) for a gaus fit
946 /// with h2_2 containing parameter 2(StdDev) for a gaus fit
947 /// with h2_chi2 containing the chisquare/number of degrees of freedom for a gaus fit
948 ///
949 /// Root > h2->FitSlicesY(0,15,22,10);
950 /// same as above, but only for bins 15 to 22 along X
951 /// and only for bins in X for which the corresponding projection
952 /// along Y has more than cut bins filled.
953 /// ~~~
954 ///
955 /// NOTE: To access the generated histograms in the current directory, do eg:
956 /// ~~~ {.cpp}
957 /// TH1D *h2_1 = (TH1D*)gDirectory->Get("h2_1");
958 /// ~~~
959 ///
960 /// A complete example of this function is given in tutorial:fitslicesy.C.
961 
962 void TH2::FitSlicesY(TF1 *f1, Int_t firstxbin, Int_t lastxbin, Int_t cut, Option_t *option, TObjArray* arr)
963 {
964  DoFitSlices(false, f1, firstxbin, lastxbin, cut, option, arr);
965 }
966 
967 Int_t TH2::GetBin(Int_t binx, Int_t biny, Int_t) const
968 {
969  // See comments in TH1::GetBin
970  Int_t ofy = fYaxis.GetNbins() + 1; // overflow bin
971  if (biny < 0) biny = 0;
972  if (biny > ofy) biny = ofy;
973 
974  return TH1::GetBin(binx) + (fXaxis.GetNbins() + 2) * biny;
975 }
976 
977 
978 ////////////////////////////////////////////////////////////////////////////////
979 /// compute first cell (binx,biny) in the range [firstxbin,lastxbin][firstybin,lastybin] for which
980 /// diff = abs(cell_content-c) <= maxdiff
981 /// In case several cells in the specified range with diff=0 are found
982 /// the first cell found is returned in binx,biny.
983 /// In case several cells in the specified range satisfy diff <=maxdiff
984 /// the cell with the smallest difference is returned in binx,biny.
985 /// In all cases the function returns the smallest difference.
986 ///
987 /// NOTE1: if firstxbin < 0, firstxbin is set to 1
988 /// if (lastxbin < firstxbin then lastxbin is set to the number of bins in X
989 /// ie if firstxbin=1 and lastxbin=0 (default) the search is on all bins in X except
990 /// for X's under- and overflow bins.
991 /// if firstybin < 0, firstybin is set to 1
992 /// if (lastybin < firstybin then lastybin is set to the number of bins in Y
993 /// ie if firstybin=1 and lastybin=0 (default) the search is on all bins in Y except
994 /// for Y's under- and overflow bins.
995 ///
996 /// NOTE2: if maxdiff=0 (default), the first cell with content=c is returned.
997 
998 Double_t TH2::GetBinWithContent2(Double_t c, Int_t &binx, Int_t &biny, Int_t firstxbin, Int_t lastxbin,
999  Int_t firstybin, Int_t lastybin, Double_t maxdiff) const
1000 {
1001  if (fDimension != 2) {
1002  binx = -1;
1003  biny = -1;
1004  Error("GetBinWithContent2","function is only valid for 2-D histograms");
1005  return 0;
1006  }
1007  if (firstxbin < 0) firstxbin = 1;
1008  if (lastxbin < firstxbin) lastxbin = fXaxis.GetNbins();
1009  if (firstybin < 0) firstybin = 1;
1010  if (lastybin < firstybin) lastybin = fYaxis.GetNbins();
1011  Double_t diff, curmax = 1.e240;
1012  for (Int_t j = firstybin; j <= lastybin; j++) {
1013  for (Int_t i = firstxbin; i <= lastxbin; i++) {
1014  diff = TMath::Abs(GetBinContent(i,j)-c);
1015  if (diff <= 0) {binx = i; biny=j; return diff;}
1016  if (diff < curmax && diff <= maxdiff) {curmax = diff, binx=i; biny=j;}
1017  }
1018  }
1019  return curmax;
1020 }
1021 
1022 
1023 ////////////////////////////////////////////////////////////////////////////////
1024 /// Return correlation factor between axis1 and axis2.
1025 
1027 {
1028  if (axis1 < 1 || axis2 < 1 || axis1 > 2 || axis2 > 2) {
1029  Error("GetCorrelationFactor","Wrong parameters");
1030  return 0;
1031  }
1032  if (axis1 == axis2) return 1;
1033  Double_t stddev1 = GetStdDev(axis1);
1034  if (stddev1 == 0) return 0;
1035  Double_t stddev2 = GetStdDev(axis2);
1036  if (stddev2 == 0) return 0;
1037  return GetCovariance(axis1,axis2)/stddev1/stddev2;
1038 }
1039 
1040 
1041 ////////////////////////////////////////////////////////////////////////////////
1042 /// Return covariance between axis1 and axis2.
1043 
1045 {
1046  if (axis1 < 1 || axis2 < 1 || axis1 > 2 || axis2 > 2) {
1047  Error("GetCovariance","Wrong parameters");
1048  return 0;
1049  }
1050  Double_t stats[kNstat];
1051  GetStats(stats);
1052  Double_t sumw = stats[0];
1053  //Double_t sumw2 = stats[1];
1054  Double_t sumwx = stats[2];
1055  Double_t sumwx2 = stats[3];
1056  Double_t sumwy = stats[4];
1057  Double_t sumwy2 = stats[5];
1058  Double_t sumwxy = stats[6];
1059 
1060  if (sumw == 0) return 0;
1061  if (axis1 == 1 && axis2 == 1) {
1062  return TMath::Abs(sumwx2/sumw - sumwx/sumw*sumwx/sumw);
1063  }
1064  if (axis1 == 2 && axis2 == 2) {
1065  return TMath::Abs(sumwy2/sumw - sumwy/sumw*sumwy/sumw);
1066  }
1067  return sumwxy/sumw - sumwx/sumw*sumwy/sumw;
1068 }
1069 
1070 
1071 ////////////////////////////////////////////////////////////////////////////////
1072 /// Return 2 random numbers along axis x and y distributed according
1073 /// the cell-contents of a 2-dim histogram
1074 /// return a NaN if the histogram has a bin with negative content
1075 
1077 {
1078  Int_t nbinsx = GetNbinsX();
1079  Int_t nbinsy = GetNbinsY();
1080  Int_t nbins = nbinsx*nbinsy;
1081  Double_t integral;
1082  // compute integral checking that all bins have positive content (see ROOT-5894)
1083  if (fIntegral) {
1084  if (fIntegral[nbins+1] != fEntries) integral = ComputeIntegral(true);
1085  else integral = fIntegral[nbins];
1086  } else {
1087  integral = ComputeIntegral(true);
1088  }
1089  if (integral == 0 ) { x = 0; y = 0; return;}
1090  // case histogram has negative bins
1091  if (integral == TMath::QuietNaN() ) { x = TMath::QuietNaN(); y = TMath::QuietNaN(); return;}
1092 
1093  Double_t r1 = gRandom->Rndm();
1094  Int_t ibin = TMath::BinarySearch(nbins,fIntegral,(Double_t) r1);
1095  Int_t biny = ibin/nbinsx;
1096  Int_t binx = ibin - nbinsx*biny;
1097  x = fXaxis.GetBinLowEdge(binx+1);
1098  if (r1 > fIntegral[ibin]) x +=
1099  fXaxis.GetBinWidth(binx+1)*(r1-fIntegral[ibin])/(fIntegral[ibin+1] - fIntegral[ibin]);
1100  y = fYaxis.GetBinLowEdge(biny+1) + fYaxis.GetBinWidth(biny+1)*gRandom->Rndm();
1101 }
1102 
1103 
1104 ////////////////////////////////////////////////////////////////////////////////
1105 /// Fill the array stats from the contents of this histogram
1106 /// The array stats must be correctly dimensioned in the calling program.
1107 /// ~~~ {.cpp}
1108 /// stats[0] = sumw
1109 /// stats[1] = sumw2
1110 /// stats[2] = sumwx
1111 /// stats[3] = sumwx2
1112 /// stats[4] = sumwy
1113 /// stats[5] = sumwy2
1114 /// stats[6] = sumwxy
1115 /// ~~~
1116 ///
1117 /// If no axis-subranges are specified (via TAxis::SetRange), the array stats
1118 /// is simply a copy of the statistics quantities computed at filling time.
1119 /// If sub-ranges are specified, the function recomputes these quantities
1120 /// from the bin contents in the current axis ranges.
1121 ///
1122 /// Note that the mean value/StdDev is computed using the bins in the currently
1123 /// defined ranges (see TAxis::SetRange). By default the ranges include
1124 /// all bins from 1 to nbins included, excluding underflows and overflows.
1125 /// To force the underflows and overflows in the computation, one must
1126 /// call the static function TH1::StatOverflows(kTRUE) before filling
1127 /// the histogram.
1128 
1129 void TH2::GetStats(Double_t *stats) const
1130 {
1131  if (fBuffer) ((TH2*)this)->BufferEmpty();
1132 
1134  std::fill(stats, stats + 7, 0);
1135 
1136  Int_t firstBinX = fXaxis.GetFirst();
1137  Int_t lastBinX = fXaxis.GetLast();
1138  Int_t firstBinY = fYaxis.GetFirst();
1139  Int_t lastBinY = fYaxis.GetLast();
1140  // include underflow/overflow if TH1::StatOverflows(kTRUE) in case no range is set on the axis
1141  if (GetStatOverflowsBehaviour()) {
1142  if ( !fXaxis.TestBit(TAxis::kAxisRange) ) {
1143  if (firstBinX == 1) firstBinX = 0;
1144  if (lastBinX == fXaxis.GetNbins() ) lastBinX += 1;
1145  }
1146  if ( !fYaxis.TestBit(TAxis::kAxisRange) ) {
1147  if (firstBinY == 1) firstBinY = 0;
1148  if (lastBinY == fYaxis.GetNbins() ) lastBinY += 1;
1149  }
1150  }
1151  for (Int_t biny = firstBinY; biny <= lastBinY; ++biny) {
1152  Double_t y = fYaxis.GetBinCenter(biny);
1153  for (Int_t binx = firstBinX; binx <= lastBinX; ++binx) {
1154  Double_t x = fXaxis.GetBinCenter(binx);
1155  //w = TMath::Abs(GetBinContent(bin));
1156  Int_t bin = GetBin(binx,biny);
1157  Double_t w = RetrieveBinContent(bin);
1158  Double_t wx = w * x; // avoid some extra multiplications at the expense of some clarity
1159  Double_t wy = w * y;
1160 
1161  stats[0] += w;
1162  stats[1] += GetBinErrorSqUnchecked(bin);
1163  stats[2] += wx;
1164  stats[3] += wx * x;
1165  stats[4] += wy;
1166  stats[5] += wy * y;
1167  stats[6] += wx * y;
1168  }
1169  }
1170  } else {
1171  stats[0] = fTsumw;
1172  stats[1] = fTsumw2;
1173  stats[2] = fTsumwx;
1174  stats[3] = fTsumwx2;
1175  stats[4] = fTsumwy;
1176  stats[5] = fTsumwy2;
1177  stats[6] = fTsumwxy;
1178  }
1179 }
1180 
1181 
1182 ////////////////////////////////////////////////////////////////////////////////
1183 /// Return integral of bin contents. Only bins in the bins range are considered.
1184 /// By default the integral is computed as the sum of bin contents in the range.
1185 /// if option "width" is specified, the integral is the sum of
1186 /// the bin contents multiplied by the bin width in x and in y.
1187 
1189 {
1190  return Integral(fXaxis.GetFirst(),fXaxis.GetLast(),
1191  fYaxis.GetFirst(),fYaxis.GetLast(),option);
1192 }
1193 
1194 
1195 ////////////////////////////////////////////////////////////////////////////////
1196 /// Return integral of bin contents in range [firstxbin,lastxbin],[firstybin,lastybin]
1197 /// for a 2-D histogram
1198 /// By default the integral is computed as the sum of bin contents in the range.
1199 /// if option "width" is specified, the integral is the sum of
1200 /// the bin contents multiplied by the bin width in x and in y.
1201 
1202 Double_t TH2::Integral(Int_t firstxbin, Int_t lastxbin, Int_t firstybin, Int_t lastybin, Option_t *option) const
1203 {
1204  double err = 0;
1205  return DoIntegral(firstxbin,lastxbin,firstybin,lastybin,-1,0,err,option);
1206 }
1207 
1208 ////////////////////////////////////////////////////////////////////////////////
1209 /// Return integral of bin contents in range [firstxbin,lastxbin],[firstybin,lastybin]
1210 /// for a 2-D histogram. Calculates also the integral error using error propagation
1211 /// from the bin errors assuming that all the bins are uncorrelated.
1212 /// By default the integral is computed as the sum of bin contents in the range.
1213 /// if option "width" is specified, the integral is the sum of
1214 /// the bin contents multiplied by the bin width in x and in y.
1215 
1216 Double_t TH2::IntegralAndError(Int_t firstxbin, Int_t lastxbin, Int_t firstybin, Int_t lastybin, Double_t & error, Option_t *option) const
1217 {
1218  return DoIntegral(firstxbin,lastxbin,firstybin,lastybin,-1,0,error,option,kTRUE);
1219 }
1220 
1221 ////////////////////////////////////////////////////////////////////////////////
1222 ///illegal for a TH2
1223 
1225 {
1226  Error("Interpolate","This function must be called with 2 arguments for a TH2");
1227  return 0;
1228 }
1229 
1230 ////////////////////////////////////////////////////////////////////////////////
1231 /// Given a point P(x,y), Interpolate approximates the value via bilinear
1232 /// interpolation based on the four nearest bin centers
1233 /// see Wikipedia, Bilinear Interpolation
1234 /// Andy Mastbaum 10/8/2008
1235 /// vaguely based on R.Raja 6-Sep-2008
1236 
1238 {
1239  Double_t f=0;
1240  Double_t x1=0,x2=0,y1=0,y2=0;
1241  Double_t dx,dy;
1242  Int_t bin_x = fXaxis.FindFixBin(x);
1243  Int_t bin_y = fYaxis.FindFixBin(y);
1244  if(bin_x<1 || bin_x>GetNbinsX() || bin_y<1 || bin_y>GetNbinsY()) {
1245  Error("Interpolate","Cannot interpolate outside histogram domain.");
1246  return 0;
1247  }
1248  Int_t quadrant = 0; // CCW from UR 1,2,3,4
1249  // which quadrant of the bin (bin_P) are we in?
1250  dx = fXaxis.GetBinUpEdge(bin_x)-x;
1251  dy = fYaxis.GetBinUpEdge(bin_y)-y;
1252  if (dx<=fXaxis.GetBinWidth(bin_x)/2 && dy<=fYaxis.GetBinWidth(bin_y)/2)
1253  quadrant = 1; // upper right
1254  if (dx>fXaxis.GetBinWidth(bin_x)/2 && dy<=fYaxis.GetBinWidth(bin_y)/2)
1255  quadrant = 2; // upper left
1256  if (dx>fXaxis.GetBinWidth(bin_x)/2 && dy>fYaxis.GetBinWidth(bin_y)/2)
1257  quadrant = 3; // lower left
1258  if (dx<=fXaxis.GetBinWidth(bin_x)/2 && dy>fYaxis.GetBinWidth(bin_y)/2)
1259  quadrant = 4; // lower right
1260  switch(quadrant) {
1261  case 1:
1262  x1 = fXaxis.GetBinCenter(bin_x);
1263  y1 = fYaxis.GetBinCenter(bin_y);
1264  x2 = fXaxis.GetBinCenter(bin_x+1);
1265  y2 = fYaxis.GetBinCenter(bin_y+1);
1266  break;
1267  case 2:
1268  x1 = fXaxis.GetBinCenter(bin_x-1);
1269  y1 = fYaxis.GetBinCenter(bin_y);
1270  x2 = fXaxis.GetBinCenter(bin_x);
1271  y2 = fYaxis.GetBinCenter(bin_y+1);
1272  break;
1273  case 3:
1274  x1 = fXaxis.GetBinCenter(bin_x-1);
1275  y1 = fYaxis.GetBinCenter(bin_y-1);
1276  x2 = fXaxis.GetBinCenter(bin_x);
1277  y2 = fYaxis.GetBinCenter(bin_y);
1278  break;
1279  case 4:
1280  x1 = fXaxis.GetBinCenter(bin_x);
1281  y1 = fYaxis.GetBinCenter(bin_y-1);
1282  x2 = fXaxis.GetBinCenter(bin_x+1);
1283  y2 = fYaxis.GetBinCenter(bin_y);
1284  break;
1285  }
1286  Int_t bin_x1 = fXaxis.FindFixBin(x1);
1287  if(bin_x1<1) bin_x1=1;
1288  Int_t bin_x2 = fXaxis.FindFixBin(x2);
1289  if(bin_x2>GetNbinsX()) bin_x2=GetNbinsX();
1290  Int_t bin_y1 = fYaxis.FindFixBin(y1);
1291  if(bin_y1<1) bin_y1=1;
1292  Int_t bin_y2 = fYaxis.FindFixBin(y2);
1293  if(bin_y2>GetNbinsY()) bin_y2=GetNbinsY();
1294  Int_t bin_q22 = GetBin(bin_x2,bin_y2);
1295  Int_t bin_q12 = GetBin(bin_x1,bin_y2);
1296  Int_t bin_q11 = GetBin(bin_x1,bin_y1);
1297  Int_t bin_q21 = GetBin(bin_x2,bin_y1);
1298  Double_t q11 = RetrieveBinContent(bin_q11);
1299  Double_t q12 = RetrieveBinContent(bin_q12);
1300  Double_t q21 = RetrieveBinContent(bin_q21);
1301  Double_t q22 = RetrieveBinContent(bin_q22);
1302  Double_t d = 1.0*(x2-x1)*(y2-y1);
1303  f = 1.0*q11/d*(x2-x)*(y2-y)+1.0*q21/d*(x-x1)*(y2-y)+1.0*q12/d*(x2-x)*(y-y1)+1.0*q22/d*(x-x1)*(y-y1);
1304  return f;
1305 }
1306 
1307 
1308 ////////////////////////////////////////////////////////////////////////////////
1309 ///illegal for a TH2
1310 
1312 {
1313  Error("Interpolate","This function must be called with 2 arguments for a TH2");
1314  return 0;
1315 }
1316 
1317 
1318 ////////////////////////////////////////////////////////////////////////////////
1319 /// Statistical test of compatibility in shape between
1320 /// THIS histogram and h2, using Kolmogorov test.
1321 /// Default: Ignore under- and overflow bins in comparison
1322 ///
1323 /// option is a character string to specify options
1324 /// - "U" include Underflows in test
1325 /// - "O" include Overflows
1326 /// - "N" include comparison of normalizations
1327 /// - "D" Put out a line of "Debug" printout
1328 /// - "M" Return the Maximum Kolmogorov distance instead of prob
1329 ///
1330 /// The returned function value is the probability of test
1331 /// (much less than one means NOT compatible)
1332 ///
1333 /// The KS test uses the distance between the pseudo-CDF's obtained
1334 /// from the histogram. Since in 2D the order for generating the pseudo-CDF is
1335 /// arbitrary, two pairs of pseudo-CDF are used, one starting from the x axis the
1336 /// other from the y axis and the maximum distance is the average of the two maximum
1337 /// distances obtained.
1338 ///
1339 /// Code adapted by Rene Brun from original HBOOK routine HDIFF
1340 
1341 Double_t TH2::KolmogorovTest(const TH1 *h2, Option_t *option) const
1342 {
1343  TString opt = option;
1344  opt.ToUpper();
1345 
1346  Double_t prb = 0;
1347  TH1 *h1 = (TH1*)this;
1348  if (h2 == 0) return 0;
1349  const TAxis *xaxis1 = h1->GetXaxis();
1350  const TAxis *xaxis2 = h2->GetXaxis();
1351  const TAxis *yaxis1 = h1->GetYaxis();
1352  const TAxis *yaxis2 = h2->GetYaxis();
1353  Int_t ncx1 = xaxis1->GetNbins();
1354  Int_t ncx2 = xaxis2->GetNbins();
1355  Int_t ncy1 = yaxis1->GetNbins();
1356  Int_t ncy2 = yaxis2->GetNbins();
1357 
1358  // Check consistency of dimensions
1359  if (h1->GetDimension() != 2 || h2->GetDimension() != 2) {
1360  Error("KolmogorovTest","Histograms must be 2-D\n");
1361  return 0;
1362  }
1363 
1364  // Check consistency in number of channels
1365  if (ncx1 != ncx2) {
1366  Error("KolmogorovTest","Number of channels in X is different, %d and %d\n",ncx1,ncx2);
1367  return 0;
1368  }
1369  if (ncy1 != ncy2) {
1370  Error("KolmogorovTest","Number of channels in Y is different, %d and %d\n",ncy1,ncy2);
1371  return 0;
1372  }
1373 
1374  // Check consistency in channel edges
1375  Bool_t afunc1 = kFALSE;
1376  Bool_t afunc2 = kFALSE;
1377  Double_t difprec = 1e-5;
1378  Double_t diff1 = TMath::Abs(xaxis1->GetXmin() - xaxis2->GetXmin());
1379  Double_t diff2 = TMath::Abs(xaxis1->GetXmax() - xaxis2->GetXmax());
1380  if (diff1 > difprec || diff2 > difprec) {
1381  Error("KolmogorovTest","histograms with different binning along X");
1382  return 0;
1383  }
1384  diff1 = TMath::Abs(yaxis1->GetXmin() - yaxis2->GetXmin());
1385  diff2 = TMath::Abs(yaxis1->GetXmax() - yaxis2->GetXmax());
1386  if (diff1 > difprec || diff2 > difprec) {
1387  Error("KolmogorovTest","histograms with different binning along Y");
1388  return 0;
1389  }
1390 
1391  // Should we include Uflows, Oflows?
1392  Int_t ibeg = 1, jbeg = 1;
1393  Int_t iend = ncx1, jend = ncy1;
1394  if (opt.Contains("U")) {ibeg = 0; jbeg = 0;}
1395  if (opt.Contains("O")) {iend = ncx1+1; jend = ncy1+1;}
1396 
1397  Int_t i,j;
1398  Double_t sum1 = 0;
1399  Double_t sum2 = 0;
1400  Double_t w1 = 0;
1401  Double_t w2 = 0;
1402  for (i = ibeg; i <= iend; i++) {
1403  for (j = jbeg; j <= jend; j++) {
1404  sum1 += h1->GetBinContent(i,j);
1405  sum2 += h2->GetBinContent(i,j);
1406  Double_t ew1 = h1->GetBinError(i,j);
1407  Double_t ew2 = h2->GetBinError(i,j);
1408  w1 += ew1*ew1;
1409  w2 += ew2*ew2;
1410 
1411  }
1412  }
1413 
1414  // Check that both scatterplots contain events
1415  if (sum1 == 0) {
1416  Error("KolmogorovTest","Integral is zero for h1=%s\n",h1->GetName());
1417  return 0;
1418  }
1419  if (sum2 == 0) {
1420  Error("KolmogorovTest","Integral is zero for h2=%s\n",h2->GetName());
1421  return 0;
1422  }
1423  // calculate the effective entries.
1424  // the case when errors are zero (w1 == 0 or w2 ==0) are equivalent to
1425  // compare to a function. In that case the rescaling is done only on sqrt(esum2) or sqrt(esum1)
1426  Double_t esum1 = 0, esum2 = 0;
1427  if (w1 > 0)
1428  esum1 = sum1 * sum1 / w1;
1429  else
1430  afunc1 = kTRUE; // use later for calculating z
1431 
1432  if (w2 > 0)
1433  esum2 = sum2 * sum2 / w2;
1434  else
1435  afunc2 = kTRUE; // use later for calculating z
1436 
1437  if (afunc2 && afunc1) {
1438  Error("KolmogorovTest","Errors are zero for both histograms\n");
1439  return 0;
1440  }
1441 
1442  // Find first Kolmogorov distance
1443  Double_t s1 = 1/sum1;
1444  Double_t s2 = 1/sum2;
1445  Double_t dfmax1 = 0;
1446  Double_t rsum1=0, rsum2=0;
1447  for (i=ibeg;i<=iend;i++) {
1448  for (j=jbeg;j<=jend;j++) {
1449  rsum1 += s1*h1->GetBinContent(i,j);
1450  rsum2 += s2*h2->GetBinContent(i,j);
1451  dfmax1 = TMath::Max(dfmax1, TMath::Abs(rsum1-rsum2));
1452  }
1453  }
1454 
1455  // Find second Kolmogorov distance
1456  Double_t dfmax2 = 0;
1457  rsum1=0, rsum2=0;
1458  for (j=jbeg;j<=jend;j++) {
1459  for (i=ibeg;i<=iend;i++) {
1460  rsum1 += s1*h1->GetBinContent(i,j);
1461  rsum2 += s2*h2->GetBinContent(i,j);
1462  dfmax2 = TMath::Max(dfmax2, TMath::Abs(rsum1-rsum2));
1463  }
1464  }
1465 
1466  // Get Kolmogorov probability: use effective entries, esum1 or esum2, for normalizing it
1467  Double_t factnm;
1468  if (afunc1) factnm = TMath::Sqrt(esum2);
1469  else if (afunc2) factnm = TMath::Sqrt(esum1);
1470  else factnm = TMath::Sqrt(esum1*sum2/(esum1+esum2));
1471 
1472  // take average of the two distances
1473  Double_t dfmax = 0.5*(dfmax1+dfmax2);
1474  Double_t z = dfmax*factnm;
1475 
1476  prb = TMath::KolmogorovProb(z);
1477 
1478  Double_t prb1 = 0, prb2 = 0;
1479  // option N to combine normalization makes sense if both afunc1 and afunc2 are false
1480  if (opt.Contains("N") && !(afunc1 || afunc2 ) ) {
1481  // Combine probabilities for shape and normalization
1482  prb1 = prb;
1483  Double_t d12 = esum1-esum2;
1484  Double_t chi2 = d12*d12/(esum1+esum2);
1485  prb2 = TMath::Prob(chi2,1);
1486  // see Eadie et al., section 11.6.2
1487  if (prb > 0 && prb2 > 0) prb = prb*prb2*(1-TMath::Log(prb*prb2));
1488  else prb = 0;
1489  }
1490 
1491  // debug printout
1492  if (opt.Contains("D")) {
1493  printf(" Kolmo Prob h1 = %s, sum1=%g\n",h1->GetName(),sum1);
1494  printf(" Kolmo Prob h2 = %s, sum2=%g\n",h2->GetName(),sum2);
1495  printf(" Kolmo Probabil = %f, Max Dist = %g\n",prb,dfmax);
1496  if (opt.Contains("N"))
1497  printf(" Kolmo Probabil = %f for shape alone, =%f for normalisation alone\n",prb1,prb2);
1498  }
1499  // This numerical error condition should never occur:
1500  if (TMath::Abs(rsum1-1) > 0.002) Warning("KolmogorovTest","Numerical problems with h1=%s\n",h1->GetName());
1501  if (TMath::Abs(rsum2-1) > 0.002) Warning("KolmogorovTest","Numerical problems with h2=%s\n",h2->GetName());
1502 
1503  if(opt.Contains("M")) return dfmax; // return average of max distance
1504 
1505  return prb;
1506 }
1507 
1508 
1509 ////////////////////////////////////////////////////////////////////////////////
1510 /// Rebin only the X axis
1511 /// see Rebin2D
1512 
1513 TH2 *TH2::RebinX(Int_t ngroup, const char *newname)
1514 {
1515  return Rebin2D(ngroup, 1, newname);
1516 }
1517 
1518 
1519 ////////////////////////////////////////////////////////////////////////////////
1520 /// Rebin only the Y axis
1521 /// see Rebin2D
1522 
1523 TH2 *TH2::RebinY(Int_t ngroup, const char *newname)
1524 {
1525  return Rebin2D(1, ngroup, newname);
1526 }
1527 
1528 ////////////////////////////////////////////////////////////////////////////////
1529 /// Override TH1::Rebin as TH2::RebinX
1530 /// Rebinning in variable binning as for TH1 is not allowed
1531 /// If a non-null pointer is given an error is flagged
1532 /// see RebinX and Rebin2D
1533 
1534 TH2 * TH2::Rebin( Int_t ngroup, const char*newname, const Double_t *xbins)
1535 {
1536  if (xbins != nullptr) {
1537  Error("Rebin","Rebinning a 2-d histogram into variable bins is not supported (it is possible only for 1-d histograms). Return a nullptr");
1538  return nullptr;
1539  }
1540  Info("Rebin","Rebinning only the x-axis. Use Rebin2D for rebinning both axes");
1541  return RebinX(ngroup, newname);
1542 }
1543 ////////////////////////////////////////////////////////////////////////////////
1544 /// Rebin this histogram grouping nxgroup/nygroup bins along the xaxis/yaxis together.
1545 ///
1546 /// if newname is not blank a new temporary histogram hnew is created.
1547 /// else the current histogram is modified (default)
1548 /// The parameter nxgroup/nygroup indicate how many bins along the xaxis/yaxis of this
1549 /// have to me merged into one bin of hnew
1550 /// If the original histogram has errors stored (via Sumw2), the resulting
1551 /// histograms has new errors correctly calculated.
1552 ///
1553 /// examples: if hpxpy is an existing TH2 histogram with 40 x 40 bins
1554 /// ~~~ {.cpp}
1555 /// hpxpy->Rebin2D(); // merges two bins along the xaxis and yaxis in one in hpxpy
1556 /// // Carefull: previous contents of hpxpy are lost
1557 /// hpxpy->RebinX(5); //merges five bins along the xaxis in one in hpxpy
1558 /// TH2 *hnew = hpxpy->RebinY(5,"hnew"); // creates a new histogram hnew
1559 /// // merging 5 bins of h1 along the yaxis in one bin
1560 /// ~~~
1561 ///
1562 /// NOTE : If nxgroup/nygroup is not an exact divider of the number of bins,
1563 /// along the xaxis/yaxis the top limit(s) of the rebinned histogram
1564 /// is changed to the upper edge of the xbin=newxbins*nxgroup resp.
1565 /// ybin=newybins*nygroup and the corresponding bins are added to
1566 /// the overflow bin.
1567 /// Statistics will be recomputed from the new bin contents.
1568 
1569 TH2 *TH2::Rebin2D(Int_t nxgroup, Int_t nygroup, const char *newname)
1570 {
1571  Int_t nxbins = fXaxis.GetNbins();
1572  Int_t nybins = fYaxis.GetNbins();
1573  Int_t nx = nxbins + 2; // normal bins + underflow and overflow
1574  Int_t ny = nybins + 2;
1579 
1580  if (GetDimension() != 2) {
1581  Error("Rebin2D", "Histogram must be TH2. This histogram has %d dimensions.", GetDimension());
1582  return 0;
1583  }
1584  if ((nxgroup <= 0) || (nxgroup > nxbins)) {
1585  Error("Rebin2D", "Illegal value of nxgroup=%d",nxgroup);
1586  return 0;
1587  }
1588  if ((nygroup <= 0) || (nygroup > nybins)) {
1589  Error("Rebin2D", "Illegal value of nygroup=%d",nygroup);
1590  return 0;
1591  }
1592 
1593  Int_t newxbins = nxbins / nxgroup;
1594  Int_t newybins = nybins / nygroup;
1595  Int_t newnx = newxbins + 2; // regular bins + overflow / underflow
1596  Int_t newny = newybins + 2; // regular bins + overflow / underflow
1597 
1598  // Save old bin contents into a new array
1599  Double_t *oldBins = new Double_t[fNcells];
1600  for (Int_t i = 0; i < fNcells; ++i) oldBins[i] = RetrieveBinContent(i);
1601 
1602  Double_t* oldErrors = NULL;
1603  if (fSumw2.fN) {
1604  oldErrors = new Double_t[fNcells];
1605  for (Int_t i = 0; i < fNcells; ++i) oldErrors[i] = GetBinErrorSqUnchecked(i);
1606  }
1607 
1608  // create a clone of the old histogram if newname is specified
1609  TH2* hnew = this;
1610  if (newname && strlen(newname)) {
1611  hnew = (TH2*)Clone();
1612  hnew->SetName(newname);
1613  }
1614 
1615  bool resetStat = false;
1616 
1617  // change axis specs and rebuild bin contents array
1618  if(newxbins * nxgroup != nxbins) {
1619  xmax = fXaxis.GetBinUpEdge(newxbins * nxgroup);
1620  resetStat = true; // stats must be reset because top bins will be moved to overflow bin
1621  }
1622  if(newybins * nygroup != nybins) {
1623  ymax = fYaxis.GetBinUpEdge(newybins * nygroup);
1624  resetStat = true; // stats must be reset because top bins will be moved to overflow bin
1625  }
1626 
1627  // save the TAttAxis members (reset by SetBins) for x axis
1628  Int_t nXdivisions = fXaxis.GetNdivisions();
1629  Color_t xAxisColor = fXaxis.GetAxisColor();
1630  Color_t xLabelColor = fXaxis.GetLabelColor();
1631  Style_t xLabelFont = fXaxis.GetLabelFont();
1632  Float_t xLabelOffset = fXaxis.GetLabelOffset();
1633  Float_t xLabelSize = fXaxis.GetLabelSize();
1634  Float_t xTickLength = fXaxis.GetTickLength();
1635  Float_t xTitleOffset = fXaxis.GetTitleOffset();
1636  Float_t xTitleSize = fXaxis.GetTitleSize();
1637  Color_t xTitleColor = fXaxis.GetTitleColor();
1638  Style_t xTitleFont = fXaxis.GetTitleFont();
1639  // save the TAttAxis members (reset by SetBins) for y axis
1640  Int_t nYdivisions = fYaxis.GetNdivisions();
1641  Color_t yAxisColor = fYaxis.GetAxisColor();
1642  Color_t yLabelColor = fYaxis.GetLabelColor();
1643  Style_t yLabelFont = fYaxis.GetLabelFont();
1644  Float_t yLabelOffset = fYaxis.GetLabelOffset();
1645  Float_t yLabelSize = fYaxis.GetLabelSize();
1646  Float_t yTickLength = fYaxis.GetTickLength();
1647  Float_t yTitleOffset = fYaxis.GetTitleOffset();
1648  Float_t yTitleSize = fYaxis.GetTitleSize();
1649  Color_t yTitleColor = fYaxis.GetTitleColor();
1650  Style_t yTitleFont = fYaxis.GetTitleFont();
1651 
1652 
1653  // copy merged bin contents (ignore under/overflows)
1654  if (nxgroup != 1 || nygroup != 1) {
1655  if(fXaxis.GetXbins()->GetSize() > 0 || fYaxis.GetXbins()->GetSize() > 0){
1656  // variable bin sizes in x or y, don't treat both cases separately
1657  Double_t *xbins = new Double_t[newxbins + 1];
1658  for(Int_t i = 0; i <= newxbins; ++i) xbins[i] = fXaxis.GetBinLowEdge(1 + i * nxgroup);
1659  Double_t *ybins = new Double_t[newybins + 1];
1660  for(Int_t i = 0; i <= newybins; ++i) ybins[i] = fYaxis.GetBinLowEdge(1 + i * nygroup);
1661  hnew->SetBins(newxbins, xbins, newybins, ybins); // changes also errors array (if any)
1662  delete [] xbins;
1663  delete [] ybins;
1664  } else {
1665  hnew->SetBins(newxbins, xmin, xmax, newybins, ymin, ymax); //changes also errors array
1666  }
1667 
1668  // (0, 0): x - underflow; y - underflow
1669  hnew->UpdateBinContent(0, oldBins[0]);
1670  if (oldErrors) hnew->fSumw2[0] = 0;
1671 
1672  // (x, 0): x - regular / overflow; y - underflow
1673  for(Int_t binx = 1, oldbinx = 1; binx < newnx; ++binx, oldbinx += nxgroup){
1674  Double_t binContent = 0.0, binErrorSq = 0.0;
1675  for (Int_t i = 0; i < nxgroup && (oldbinx + i) < nx; ++i) {
1676  Int_t bin = oldbinx + i;
1677  binContent += oldBins[bin];
1678  if(oldErrors) binErrorSq += oldErrors[bin];
1679  }
1680  Int_t newbin = binx;
1681  hnew->UpdateBinContent(newbin, binContent);
1682  if (oldErrors) hnew->fSumw2[newbin] = binErrorSq;
1683  }
1684 
1685  // (0, y): x - underflow; y - regular / overflow
1686  for(Int_t biny = 1, oldbiny = 1; biny < newny; ++biny, oldbiny += nygroup){
1687  Double_t binContent = 0.0, binErrorSq = 0.0;
1688  for (Int_t j = 0; j < nygroup && (oldbiny + j) < ny; ++j) {
1689  Int_t bin = (oldbiny + j) * nx;
1690  binContent += oldBins[bin];
1691  if(oldErrors) binErrorSq += oldErrors[bin];
1692  }
1693  Int_t newbin = biny * newnx;
1694  hnew->UpdateBinContent(newbin, binContent);
1695  if (oldErrors) hnew->fSumw2[newbin] = binErrorSq;
1696  }
1697 
1698  // (x, y): x - regular / overflow; y - regular / overflow
1699  for (Int_t binx = 1, oldbinx = 1; binx < newnx; ++binx, oldbinx += nxgroup) {
1700  for (Int_t biny = 1, oldbiny = 1; biny < newny; ++biny, oldbiny += nygroup) {
1701  Double_t binContent = 0.0, binErrorSq = 0.0;
1702  for (Int_t i = 0; i < nxgroup && (oldbinx + i) < nx; ++i) {
1703  for (Int_t j = 0; j < nygroup && (oldbiny + j) < ny; ++j) {
1704  Int_t bin = oldbinx + i + (oldbiny + j) * nx;
1705  binContent += oldBins[bin];
1706  if (oldErrors) binErrorSq += oldErrors[bin];
1707  }
1708  }
1709  Int_t newbin = binx + biny * newnx;
1710  hnew->UpdateBinContent(newbin, binContent);
1711  if (oldErrors) hnew->fSumw2[newbin] = binErrorSq;
1712  }
1713  }
1714  }
1715 
1716  // Restore x axis attributes
1717  fXaxis.SetNdivisions(nXdivisions);
1718  fXaxis.SetAxisColor(xAxisColor);
1719  fXaxis.SetLabelColor(xLabelColor);
1720  fXaxis.SetLabelFont(xLabelFont);
1721  fXaxis.SetLabelOffset(xLabelOffset);
1722  fXaxis.SetLabelSize(xLabelSize);
1723  fXaxis.SetTickLength(xTickLength);
1724  fXaxis.SetTitleOffset(xTitleOffset);
1725  fXaxis.SetTitleSize(xTitleSize);
1726  fXaxis.SetTitleColor(xTitleColor);
1727  fXaxis.SetTitleFont(xTitleFont);
1728  // Restore y axis attributes
1729  fYaxis.SetNdivisions(nYdivisions);
1730  fYaxis.SetAxisColor(yAxisColor);
1731  fYaxis.SetLabelColor(yLabelColor);
1732  fYaxis.SetLabelFont(yLabelFont);
1733  fYaxis.SetLabelOffset(yLabelOffset);
1734  fYaxis.SetLabelSize(yLabelSize);
1735  fYaxis.SetTickLength(yTickLength);
1736  fYaxis.SetTitleOffset(yTitleOffset);
1737  fYaxis.SetTitleSize(yTitleSize);
1738  fYaxis.SetTitleColor(yTitleColor);
1739  fYaxis.SetTitleFont(yTitleFont);
1740 
1741  if (resetStat) hnew->ResetStats();
1742 
1743  delete [] oldBins;
1744  if (oldErrors) delete [] oldErrors;
1745  return hnew;
1746 }
1747 
1748 
1749 ////////////////////////////////////////////////////////////////////////////////
1750 
1751 TProfile *TH2::DoProfile(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const
1752 {
1753  TString opt = option;
1754  // extract cut infor
1755  TString cut;
1756  Int_t i1 = opt.Index("[");
1757  if (i1>=0) {
1758  Int_t i2 = opt.Index("]");
1759  cut = opt(i1,i2-i1+1);
1760  }
1761  opt.ToLower();
1762  bool originalRange = opt.Contains("o");
1763 
1764  const TAxis& outAxis = ( onX ? fXaxis : fYaxis );
1765  const TAxis& inAxis = ( onX ? fYaxis : fXaxis );
1766  Int_t inN = inAxis.GetNbins();
1767  const char *expectedName = ( onX ? "_pfx" : "_pfy" );
1768 
1769  // outer axis cannot be outside original axis (this fixes ROOT-8781)
1770  // and firstOutBin and lastOutBin cannot be both equal to zero
1771  Int_t firstOutBin = std::max(outAxis.GetFirst(),1);
1772  Int_t lastOutBin = std::min(outAxis.GetLast(),outAxis.GetNbins() ) ;
1773 
1774  if ( lastbin < firstbin && inAxis.TestBit(TAxis::kAxisRange) ) {
1775  firstbin = inAxis.GetFirst();
1776  lastbin = inAxis.GetLast();
1777  // For special case of TAxis::SetRange, when first == 1 and last
1778  // = N and the range bit has been set, the TAxis will return 0
1779  // for both.
1780  if (firstbin == 0 && lastbin == 0)
1781  {
1782  firstbin = 1;
1783  lastbin = inAxis.GetNbins();
1784  }
1785  }
1786  if (firstbin < 0) firstbin = 1;
1787  if (lastbin < 0) lastbin = inN;
1788  if (lastbin > inN+1) lastbin = inN;
1789 
1790  // Create the profile histogram
1791  char *pname = (char*)name;
1792  if (name && strcmp(name, expectedName) == 0) {
1793  Int_t nch = strlen(GetName()) + 5;
1794  pname = new char[nch];
1795  snprintf(pname,nch,"%s%s",GetName(),name);
1796  }
1797  TProfile *h1=0;
1798  //check if a profile with identical name exist
1799  // if compatible reset and re-use previous histogram
1800  TObject *h1obj = gROOT->FindObject(pname);
1801  if (h1obj && h1obj->InheritsFrom(TH1::Class())) {
1802  if (h1obj->IsA() != TProfile::Class() ) {
1803  Error("DoProfile","Histogram with name %s must be a TProfile and is a %s",name,h1obj->ClassName());
1804  return 0;
1805  }
1806  h1 = (TProfile*)h1obj;
1807  // reset the existing histogram and set always the new binning for the axis
1808  // This avoid problems when the histogram already exists and the histograms is rebinned or its range has changed
1809  // (see https://savannah.cern.ch/bugs/?94101 or https://savannah.cern.ch/bugs/?95808 )
1810  h1->Reset();
1811  const TArrayD *xbins = outAxis.GetXbins();
1812  if (xbins->fN == 0) {
1813  if ( originalRange )
1814  h1->SetBins(outAxis.GetNbins(),outAxis.GetXmin(),outAxis.GetXmax());
1815  else
1816  h1->SetBins(lastOutBin-firstOutBin+1,outAxis.GetBinLowEdge(firstOutBin),outAxis.GetBinUpEdge(lastOutBin));
1817  } else {
1818  // case variable bins
1819  if (originalRange )
1820  h1->SetBins(outAxis.GetNbins(),xbins->fArray);
1821  else
1822  h1->SetBins(lastOutBin-firstOutBin+1,&xbins->fArray[firstOutBin-1]);
1823  }
1824  }
1825 
1826  Int_t ncuts = 0;
1827  if (opt.Contains("[")) {
1828  ((TH2 *)this)->GetPainter();
1829  if (fPainter) ncuts = fPainter->MakeCuts((char*)cut.Data());
1830  }
1831 
1832  if (!h1) {
1833  const TArrayD *bins = outAxis.GetXbins();
1834  if (bins->fN == 0) {
1835  if ( originalRange )
1836  h1 = new TProfile(pname,GetTitle(),outAxis.GetNbins(),outAxis.GetXmin(),outAxis.GetXmax(),opt);
1837  else
1838  h1 = new TProfile(pname,GetTitle(),lastOutBin-firstOutBin+1,
1839  outAxis.GetBinLowEdge(firstOutBin),
1840  outAxis.GetBinUpEdge(lastOutBin), opt);
1841  } else {
1842  // case variable bins
1843  if (originalRange )
1844  h1 = new TProfile(pname,GetTitle(),outAxis.GetNbins(),bins->fArray,opt);
1845  else
1846  h1 = new TProfile(pname,GetTitle(),lastOutBin-firstOutBin+1,&bins->fArray[firstOutBin-1],opt);
1847  }
1848  }
1849  if (pname != name) delete [] pname;
1850 
1851  // Copy attributes
1852  h1->GetXaxis()->ImportAttributes( &outAxis);
1853  h1->SetLineColor(this->GetLineColor());
1854  h1->SetFillColor(this->GetFillColor());
1855  h1->SetMarkerColor(this->GetMarkerColor());
1856  h1->SetMarkerStyle(this->GetMarkerStyle());
1857 
1858  // check if histogram is weighted
1859  // in case need to store sum of weight square/bin for the profile
1860  TArrayD & binSumw2 = *(h1->GetBinSumw2());
1861  bool useWeights = (GetSumw2N() > 0);
1862  if (useWeights && (binSumw2.fN != h1->GetNcells()) ) h1->Sumw2();
1863  // we need to set this bit because we fill the profile using a single Fill for many entries
1864  // This is needed for the changes applied to make automatically the histogram weighted in ROOT 6 versions
1865  else h1->SetBit(TH1::kIsNotW);
1866 
1867  // Fill the profile histogram
1868  // no entries/bin is available so can fill only using bin content as weight
1869  Double_t totcont = 0;
1870 
1871  // implement filling of projected histogram
1872  // outbin is bin number of outAxis (the projected axis). Loop is done on all bin of TH2 histograms
1873  // inbin is the axis being integrated. Loop is done only on the selected bins
1874  for ( Int_t outbin = 0; outbin <= outAxis.GetNbins() + 1; ++outbin) {
1875  if (outAxis.TestBit(TAxis::kAxisRange) && ( outbin < firstOutBin || outbin > lastOutBin )) continue;
1876 
1877  // find corresponding bin number in h1 for outbin (binOut)
1878  Double_t xOut = outAxis.GetBinCenter(outbin);
1879  Int_t binOut = h1->GetXaxis()->FindBin( xOut );
1880  if (binOut <0) continue;
1881 
1882  for (Int_t inbin = firstbin ; inbin <= lastbin ; ++inbin) {
1883  Int_t binx, biny;
1884  if (onX) { binx = outbin; biny=inbin; }
1885  else { binx = inbin; biny=outbin; }
1886 
1887  if (ncuts) {
1888  if (!fPainter->IsInside(binx,biny)) continue;
1889  }
1890  Int_t bin = GetBin(binx, biny);
1891  Double_t cxy = RetrieveBinContent(bin);
1892 
1893 
1894  if (cxy) {
1895  Double_t tmp = 0;
1896  // the following fill update wrongly the fBinSumw2- need to save it before
1897  if ( useWeights ) tmp = binSumw2.fArray[binOut];
1898  h1->Fill( xOut, inAxis.GetBinCenter(inbin), cxy );
1899  if ( useWeights ) binSumw2.fArray[binOut] = tmp + fSumw2.fArray[bin];
1900  totcont += cxy;
1901  }
1902 
1903  }
1904  }
1905 
1906  // the statistics must be recalculated since by using the Fill method the total sum of weight^2 is
1907  // not computed correctly
1908  // for a profile does not much sense to re-use statistics of original TH2
1909  h1->ResetStats();
1910  // Also we need to set the entries since they have not been correctly calculated during the projection
1911  // we can only set them to the effective entries
1913 
1914 
1915  if (opt.Contains("d")) {
1916  TVirtualPad *padsav = gPad;
1917  TVirtualPad *pad = gROOT->GetSelectedPad();
1918  if (pad) pad->cd();
1919  opt.Remove(opt.First("d"),1);
1920  if (!gPad || !gPad->FindObject(h1)) {
1921  h1->Draw(opt);
1922  } else {
1923  h1->Paint(opt);
1924  }
1925  if (padsav) padsav->cd();
1926  }
1927  return h1;
1928 }
1929 
1930 
1931 ////////////////////////////////////////////////////////////////////////////////
1932 /// Project a 2-D histogram into a profile histogram along X.
1933 ///
1934 /// The projection is made from the channels along the Y axis
1935 /// ranging from firstybin to lastybin included.
1936 /// By default, bins 1 to ny are included
1937 /// When all bins are included, the number of entries in the projection
1938 /// is set to the number of entries of the 2-D histogram, otherwise
1939 /// the number of entries is incremented by 1 for all non empty cells.
1940 ///
1941 /// if option "d" is specified, the profile is drawn in the current pad.
1942 ///
1943 /// if option "o" original axis range of the target axes will be
1944 /// kept, but only bins inside the selected range will be filled.
1945 ///
1946 /// The option can also be used to specify the projected profile error type.
1947 /// Values which can be used are 's', 'i', or 'g'. See TProfile::BuildOptions for details
1948 ///
1949 /// Using a TCutG object, it is possible to select a sub-range of a 2-D histogram.
1950 /// One must create a graphical cut (mouse or C++) and specify the name
1951 /// of the cut between [] in the option.
1952 /// For example, with a TCutG named "cutg", one can call:
1953 /// myhist->ProfileX(" ",firstybin,lastybin,"[cutg]");
1954 /// To invert the cut, it is enough to put a "-" in front of its name:
1955 /// myhist->ProfileX(" ",firstybin,lastybin,"[-cutg]");
1956 /// It is possible to apply several cuts ("," means logical AND):
1957 /// myhist->ProfileX(" ",firstybin,lastybin,"[cutg1,cutg2]");
1958 ///
1959 /// NOTE that if a TProfile named "name" exists in the current directory or pad with
1960 /// a compatible axis the profile is reset and filled again with the projected contents of the TH2.
1961 /// In the case of axis incompatibility an error is reported and a NULL pointer is returned.
1962 ///
1963 /// NOTE that the X axis attributes of the TH2 are copied to the X axis of the profile.
1964 ///
1965 /// NOTE that the default under- / overflow behavior differs from what ProjectionX
1966 /// does! Profiles take the bin center into account, so here the under- and overflow
1967 /// bins are ignored by default.
1968 ///
1969 /// NOTE that the return profile histogram is computed using the Y bin center values instead of
1970 /// the real Y values which are used to fill the 2d histogram. Therefore the obtained profile is just an approximation of the
1971 /// correct profile histogram that would be obtained when filling it directly with the original data (see ROOT-7770)
1972 
1973 
1974 TProfile *TH2::ProfileX(const char *name, Int_t firstybin, Int_t lastybin, Option_t *option) const
1975 {
1976  return DoProfile(true, name, firstybin, lastybin, option);
1977 
1978 }
1979 
1980 
1981 ////////////////////////////////////////////////////////////////////////////////
1982 /// Project a 2-D histogram into a profile histogram along Y.
1983 ///
1984 /// The projection is made from the channels along the X axis
1985 /// ranging from firstxbin to lastxbin included.
1986 /// By default, bins 1 to nx are included
1987 /// When all bins are included, the number of entries in the projection
1988 /// is set to the number of entries of the 2-D histogram, otherwise
1989 /// the number of entries is incremented by 1 for all non empty cells.
1990 ///
1991 /// if option "d" is specified, the profile is drawn in the current pad.
1992 ///
1993 /// if option "o" , the original axis range of the target axis will be
1994 /// kept, but only bins inside the selected range will be filled.
1995 ///
1996 /// The option can also be used to specify the projected profile error type.
1997 /// Values which can be used are 's', 'i', or 'g'. See TProfile::BuildOptions for details
1998 /// Using a TCutG object, it is possible to select a sub-range of a 2-D histogram.
1999 ///
2000 /// One must create a graphical cut (mouse or C++) and specify the name
2001 /// of the cut between [] in the option.
2002 /// For example, with a TCutG named "cutg", one can call:
2003 /// myhist->ProfileY(" ",firstybin,lastybin,"[cutg]");
2004 /// To invert the cut, it is enough to put a "-" in front of its name:
2005 /// myhist->ProfileY(" ",firstybin,lastybin,"[-cutg]");
2006 /// It is possible to apply several cuts:
2007 /// myhist->ProfileY(" ",firstybin,lastybin,"[cutg1,cutg2]");
2008 ///
2009 /// NOTE that if a TProfile named "name" exists in the current directory or pad with
2010 /// a compatible axis the profile is reset and filled again with the projected contents of the TH2.
2011 /// In the case of axis incompatibility an error is reported and a NULL pointer is returned.
2012 ///
2013 /// NOTE that the Y axis attributes of the TH2 are copied to the X axis of the profile.
2014 ///
2015 /// NOTE that the default under- / overflow behavior differs from what ProjectionX
2016 /// does! Profiles take the bin center into account, so here the under- and overflow
2017 /// bins are ignored by default.
2018 ///
2019 /// NOTE that the return profile histogram is computed using the X bin center values instead of
2020 /// the real X values which are used to fill the 2d histogram. Therefore the obtained profile is just an approximation of the
2021 /// correct profile histogram that would be obtained when filling it directly with the original data (see ROOT-7770)
2022 
2023 
2024 TProfile *TH2::ProfileY(const char *name, Int_t firstxbin, Int_t lastxbin, Option_t *option) const
2025 {
2026  return DoProfile(false, name, firstxbin, lastxbin, option);
2027 }
2028 
2029 
2030 ////////////////////////////////////////////////////////////////////////////////
2031 /// Internal (protected) method for performing projection on the X or Y axis
2032 /// called by ProjectionX or ProjectionY
2033 
2034 TH1D *TH2::DoProjection(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const
2035 {
2036  const char *expectedName = 0;
2037  Int_t inNbin;
2038  const TAxis* outAxis;
2039  const TAxis* inAxis;
2040 
2041  TString opt = option;
2042  TString cut;
2043  Int_t i1 = opt.Index("[");
2044  if (i1>=0) {
2045  Int_t i2 = opt.Index("]");
2046  cut = opt(i1,i2-i1+1);
2047  }
2048  opt.ToLower(); //must be called after having parsed the cut name
2049  bool originalRange = opt.Contains("o");
2050 
2051  if ( onX )
2052  {
2053  expectedName = "_px";
2054  inNbin = fYaxis.GetNbins();
2055  outAxis = GetXaxis();
2056  inAxis = GetYaxis();
2057  }
2058  else
2059  {
2060  expectedName = "_py";
2061  inNbin = fXaxis.GetNbins();
2062  outAxis = GetYaxis();
2063  inAxis = GetXaxis();
2064  }
2065 
2066  // outer axis cannot be outside original axis (this fixes ROOT-8781)
2067  // and firstOutBin and lastOutBin cannot be both equal to zero
2068  Int_t firstOutBin = std::max(outAxis->GetFirst(),1);
2069  Int_t lastOutBin = std::min(outAxis->GetLast(),outAxis->GetNbins() ) ;
2070 
2071  if ( lastbin < firstbin && inAxis->TestBit(TAxis::kAxisRange) ) {
2072  firstbin = inAxis->GetFirst();
2073  lastbin = inAxis->GetLast();
2074  // For special case of TAxis::SetRange, when first == 1 and last
2075  // = N and the range bit has been set, the TAxis will return 0
2076  // for both.
2077  if (firstbin == 0 && lastbin == 0)
2078  {
2079  firstbin = 1;
2080  lastbin = inAxis->GetNbins();
2081  }
2082  }
2083  if (firstbin < 0) firstbin = 0;
2084  if (lastbin < 0) lastbin = inNbin + 1;
2085  if (lastbin > inNbin+1) lastbin = inNbin + 1;
2086 
2087  // Create the projection histogram
2088  char *pname = (char*)name;
2089  if (name && strcmp(name,expectedName) == 0) {
2090  Int_t nch = strlen(GetName()) + 4;
2091  pname = new char[nch];
2092  snprintf(pname,nch,"%s%s",GetName(),name);
2093  }
2094  TH1D *h1=0;
2095  //check if histogram with identical name exist
2096  // if compatible reset and re-use previous histogram
2097  // (see https://savannah.cern.ch/bugs/?54340)
2098  TObject *h1obj = gROOT->FindObject(pname);
2099  if (h1obj && h1obj->InheritsFrom(TH1::Class())) {
2100  if (h1obj->IsA() != TH1D::Class() ) {
2101  Error("DoProjection","Histogram with name %s must be a TH1D and is a %s",name,h1obj->ClassName());
2102  return 0;
2103  }
2104  h1 = (TH1D*)h1obj;
2105  // reset the existing histogram and set always the new binning for the axis
2106  // This avoid problems when the histogram already exists and the histograms is rebinned or its range has changed
2107  // (see https://savannah.cern.ch/bugs/?94101 or https://savannah.cern.ch/bugs/?95808 )
2108  h1->Reset();
2109  const TArrayD *xbins = outAxis->GetXbins();
2110  if (xbins->fN == 0) {
2111  if ( originalRange )
2112  h1->SetBins(outAxis->GetNbins(),outAxis->GetXmin(),outAxis->GetXmax());
2113  else
2114  h1->SetBins(lastOutBin-firstOutBin+1,outAxis->GetBinLowEdge(firstOutBin),outAxis->GetBinUpEdge(lastOutBin));
2115  } else {
2116  // case variable bins
2117  if (originalRange )
2118  h1->SetBins(outAxis->GetNbins(),xbins->fArray);
2119  else
2120  h1->SetBins(lastOutBin-firstOutBin+1,&xbins->fArray[firstOutBin-1]);
2121  }
2122  }
2123 
2124  Int_t ncuts = 0;
2125  if (opt.Contains("[")) {
2126  ((TH2 *)this)->GetPainter();
2127  if (fPainter) ncuts = fPainter->MakeCuts((char*)cut.Data());
2128  }
2129 
2130  if (!h1) {
2131  const TArrayD *bins = outAxis->GetXbins();
2132  if (bins->fN == 0) {
2133  if ( originalRange )
2134  h1 = new TH1D(pname,GetTitle(),outAxis->GetNbins(),outAxis->GetXmin(),outAxis->GetXmax());
2135  else
2136  h1 = new TH1D(pname,GetTitle(),lastOutBin-firstOutBin+1,
2137  outAxis->GetBinLowEdge(firstOutBin),outAxis->GetBinUpEdge(lastOutBin));
2138  } else {
2139  // case variable bins
2140  if (originalRange )
2141  h1 = new TH1D(pname,GetTitle(),outAxis->GetNbins(),bins->fArray);
2142  else
2143  h1 = new TH1D(pname,GetTitle(),lastOutBin-firstOutBin+1,&bins->fArray[firstOutBin-1]);
2144  }
2145  if (opt.Contains("e") || GetSumw2N() ) h1->Sumw2();
2146  }
2147  if (pname != name) delete [] pname;
2148 
2149  // Copy the axis attributes and the axis labels if needed.
2150  h1->GetXaxis()->ImportAttributes(outAxis);
2151  THashList* labels=outAxis->GetLabels();
2152  if (labels) {
2153  TIter iL(labels);
2154  TObjString* lb;
2155  Int_t i = 1;
2156  while ((lb=(TObjString*)iL())) {
2157  h1->GetXaxis()->SetBinLabel(i,lb->String().Data());
2158  i++;
2159  }
2160  }
2161 
2162  h1->SetLineColor(this->GetLineColor());
2163  h1->SetFillColor(this->GetFillColor());
2164  h1->SetMarkerColor(this->GetMarkerColor());
2165  h1->SetMarkerStyle(this->GetMarkerStyle());
2166 
2167  // Fill the projected histogram
2168  Double_t cont,err2;
2169  Double_t totcont = 0;
2170  Bool_t computeErrors = h1->GetSumw2N();
2171 
2172  // implement filling of projected histogram
2173  // outbin is bin number of outAxis (the projected axis). Loop is done on all bin of TH2 histograms
2174  // inbin is the axis being integrated. Loop is done only on the selected bins
2175  for ( Int_t outbin = 0; outbin <= outAxis->GetNbins() + 1; ++outbin) {
2176  err2 = 0;
2177  cont = 0;
2178  if (outAxis->TestBit(TAxis::kAxisRange) && ( outbin < firstOutBin || outbin > lastOutBin )) continue;
2179 
2180  for (Int_t inbin = firstbin ; inbin <= lastbin ; ++inbin) {
2181  Int_t binx, biny;
2182  if (onX) { binx = outbin; biny=inbin; }
2183  else { binx = inbin; biny=outbin; }
2184 
2185  if (ncuts) {
2186  if (!fPainter->IsInside(binx,biny)) continue;
2187  }
2188  // sum bin content and error if needed
2189  cont += GetBinContent(binx,biny);
2190  if (computeErrors) {
2191  Double_t exy = GetBinError(binx,biny);
2192  err2 += exy*exy;
2193  }
2194  }
2195  // find corresponding bin number in h1 for outbin
2196  Int_t binOut = h1->GetXaxis()->FindBin( outAxis->GetBinCenter(outbin) );
2197  h1->SetBinContent(binOut ,cont);
2198  if (computeErrors) h1->SetBinError(binOut,TMath::Sqrt(err2));
2199  // sum all content
2200  totcont += cont;
2201  }
2202 
2203  // check if we can re-use the original statistics from the previous histogram
2204  bool reuseStats = false;
2205  if ( ( GetStatOverflowsBehaviour() == false && firstbin == 1 && lastbin == inNbin ) ||
2206  ( GetStatOverflowsBehaviour() == true && firstbin == 0 && lastbin == inNbin + 1 ) )
2207  reuseStats = true;
2208  else {
2209  // also if total content match we can re-use
2210  double eps = 1.E-12;
2211  if (IsA() == TH2F::Class() ) eps = 1.E-6;
2212  if (fTsumw != 0 && TMath::Abs( fTsumw - totcont) < TMath::Abs(fTsumw) * eps)
2213  reuseStats = true;
2214  }
2215  if (ncuts) reuseStats = false;
2216  // retrieve the statistics and set in projected histogram if we can re-use it
2217  bool reuseEntries = reuseStats;
2218  // can re-use entries if underflow/overflow are included
2219  reuseEntries &= (firstbin==0 && lastbin == inNbin+1);
2220  if (reuseStats) {
2221  Double_t stats[kNstat];
2222  GetStats(stats);
2223  if (!onX) { // case of projection on Y
2224  stats[2] = stats[4];
2225  stats[3] = stats[5];
2226  }
2227  h1->PutStats(stats);
2228  }
2229  else {
2230  // the statistics is automatically recalculated since it is reset by the call to SetBinContent
2231  // we just need to set the entries since they have not been correctly calculated during the projection
2232  // we can only set them to the effective entries
2234  }
2235  if (reuseEntries) {
2237  }
2238  else {
2239  // re-compute the entries
2240  // in case of error calculation (i.e. when Sumw2() is set)
2241  // use the effective entries for the entries
2242  // since this is the only way to estimate them
2243  Double_t entries = TMath::Floor( totcont + 0.5); // to avoid numerical rounding
2244  if (h1->GetSumw2N()) entries = h1->GetEffectiveEntries();
2245  h1->SetEntries( entries );
2246  }
2247 
2248  if (opt.Contains("d")) {
2249  TVirtualPad *padsav = gPad;
2250  TVirtualPad *pad = gROOT->GetSelectedPad();
2251  if (pad) pad->cd();
2252  opt.Remove(opt.First("d"),1);
2253  // remove also other options
2254  if (opt.Contains("e")) opt.Remove(opt.First("e"),1);
2255  if (!gPad || !gPad->FindObject(h1)) {
2256  h1->Draw(opt);
2257  } else {
2258  h1->Paint(opt);
2259  }
2260  if (padsav) padsav->cd();
2261  }
2262 
2263  return h1;
2264 }
2265 
2266 
2267 ////////////////////////////////////////////////////////////////////////////////
2268 /// Project a 2-D histogram into a 1-D histogram along X.
2269 ///
2270 /// The projection is always of the type TH1D.
2271 /// The projection is made from the channels along the Y axis
2272 /// ranging from firstybin to lastybin included.
2273 /// By default, all bins including under- and overflow are included.
2274 /// The number of entries in the projection is estimated from the
2275 /// number of effective entries for all the cells included in the projection.
2276 ///
2277 /// To exclude the underflow bins in Y, use firstybin=1.
2278 /// To exclude the overflow bins in Y, use lastybin=nx.
2279 ///
2280 /// if option "e" is specified, the errors are computed.
2281 /// if option "d" is specified, the projection is drawn in the current pad.
2282 /// if option "o" original axis range of the taget axes will be
2283 /// kept, but only bins inside the selected range will be filled.
2284 ///
2285 /// Using a TCutG object, it is possible to select a sub-range of a 2-D histogram.
2286 /// One must create a graphical cut (mouse or C++) and specify the name
2287 /// of the cut between [] in the option.
2288 /// For example, with a TCutG named "cutg", one can call:
2289 /// myhist->ProjectionX(" ",firstybin,lastybin,"[cutg]");
2290 /// To invert the cut, it is enough to put a "-" in front of its name:
2291 /// myhist->ProjectionX(" ",firstybin,lastybin,"[-cutg]");
2292 /// It is possible to apply several cuts:
2293 /// myhist->ProjectionX(" ",firstybin,lastybin,"[cutg1,cutg2]");
2294 ///
2295 /// NOTE that if a TH1D named "name" exists in the current directory or pad
2296 /// the histogram is reset and filled again with the projected contents of the TH2.
2297 ///
2298 /// NOTE that the X axis attributes of the TH2 are copied to the X axis of the projection.
2299 
2300 TH1D *TH2::ProjectionX(const char *name, Int_t firstybin, Int_t lastybin, Option_t *option) const
2301 {
2302  return DoProjection(true, name, firstybin, lastybin, option);
2303 }
2304 
2305 
2306 ////////////////////////////////////////////////////////////////////////////////
2307 /// Project a 2-D histogram into a 1-D histogram along Y.
2308 ///
2309 /// The projection is always of the type TH1D.
2310 /// The projection is made from the channels along the X axis
2311 /// ranging from firstxbin to lastxbin included.
2312 /// By default, all bins including under- and overflow are included.
2313 /// The number of entries in the projection is estimated from the
2314 /// number of effective entries for all the cells included in the projection
2315 ///
2316 /// To exclude the underflow bins in X, use firstxbin=1.
2317 /// To exclude the overflow bins in X, use lastxbin=nx.
2318 ///
2319 /// if option "e" is specified, the errors are computed.
2320 /// if option "d" is specified, the projection is drawn in the current pad.
2321 /// if option "o" original axis range of the taget axes will be
2322 /// kept, but only bins inside the selected range will be filled.
2323 ///
2324 /// Using a TCutG object, it is possible to select a sub-range of a 2-D histogram.
2325 /// One must create a graphical cut (mouse or C++) and specify the name
2326 /// of the cut between [] in the option.
2327 /// For example, with a TCutG named "cutg", one can call:
2328 /// myhist->ProjectionY(" ",firstxbin,lastxbin,"[cutg]");
2329 /// To invert the cut, it is enough to put a "-" in front of its name:
2330 /// myhist->ProjectionY(" ",firstxbin,lastxbin,"[-cutg]");
2331 /// It is possible to apply several cuts:
2332 /// myhist->ProjectionY(" ",firstxbin,lastxbin,"[cutg1,cutg2]");
2333 ///
2334 /// NOTE that if a TH1D named "name" exists in the current directory or pad and having
2335 /// a compatible axis, the histogram is reset and filled again with the projected contents of the TH2.
2336 /// In the case of axis incompatibility, an error is reported and a NULL pointer is returned.
2337 ///
2338 /// NOTE that the Y axis attributes of the TH2 are copied to the X axis of the projection.
2339 
2340 TH1D *TH2::ProjectionY(const char *name, Int_t firstxbin, Int_t lastxbin, Option_t *option) const
2341 {
2342  return DoProjection(false, name, firstxbin, lastxbin, option);
2343 }
2344 
2345 
2346 ////////////////////////////////////////////////////////////////////////////////
2347 /// Replace current statistics with the values in array stats
2348 
2350 {
2351  TH1::PutStats(stats);
2352  fTsumwy = stats[4];
2353  fTsumwy2 = stats[5];
2354  fTsumwxy = stats[6];
2355 }
2356 
2357 
2358 ////////////////////////////////////////////////////////////////////////////////
2359 /// Compute the X distribution of quantiles in the other variable Y
2360 /// name is the name of the returned histogram
2361 /// prob is the probability content for the quantile (0.5 is the default for the median)
2362 /// An approximate error for the quantile is computed assuming that the distribution in
2363 /// the other variable is normal. According to this approximate formula the error on the quantile is
2364 /// estimated as sqrt( p (1-p) / ( n * f(q)^2) ), where p is the probability content of the quantile and
2365 /// n is the number of events used to compute the quantile and f(q) is the probability distribution for the
2366 /// other variable evaluated at the obtained quantile. In the error estimation the probability is then assumed to be
2367 /// a normal distribution.
2368 
2369 TH1D* TH2::QuantilesX( Double_t prob, const char * name) const
2370 {
2371  return DoQuantiles(true, name, prob);
2372 }
2373 
2374 
2375 ////////////////////////////////////////////////////////////////////////////////
2376 /// Compute the Y distribution of quantiles in the other variable X
2377 /// name is the name of the returned histogram
2378 /// prob is the probability content for the quantile (0.5 is the default for the median)
2379 /// An approximate error for the quantile is computed assuming that the distribution in
2380 /// the other variable is normal.
2381 
2382 TH1D* TH2::QuantilesY( Double_t prob, const char * name) const
2383 {
2384  return DoQuantiles(false, name, prob);
2385 }
2386 
2387 
2388 ////////////////////////////////////////////////////////////////////////////////
2389 /// Implementation of quantiles for x or y
2390 
2391 TH1D* TH2::DoQuantiles(bool onX, const char * name, Double_t prob) const
2392 {
2393  const TAxis *outAxis = 0;
2394  if ( onX ) {
2395  outAxis = GetXaxis();
2396  } else {
2397  outAxis = GetYaxis();
2398  }
2399 
2400  // build first name of returned histogram
2401  TString qname = name;
2402  if (qname.IsNull() || qname == "_qx" || qname == "_qy") {
2403  const char * qtype = (onX) ? "qx" : "qy";
2404  qname = TString::Format("%s_%s_%3.2f",GetName(),qtype, prob);
2405  }
2406  // check if the histogram is already existing
2407  TH1D *h1=0;
2408  //check if histogram with identical name exist
2409  TObject *h1obj = gROOT->FindObject(qname);
2410  if (h1obj) {
2411  h1 = dynamic_cast<TH1D*>(h1obj);
2412  if (!h1) {
2413  Error("DoQuantiles","Histogram with name %s must be a TH1D and is a %s",qname.Data(),h1obj->ClassName());
2414  return 0;
2415  }
2416  }
2417  if (h1) {
2418  h1->Reset();
2419  } else {
2420  // create the histogram
2421  h1 = new TH1D(qname, GetTitle(), 1, 0, 1);
2422  }
2423  // set the bin content
2424  Int_t firstOutBin = std::max(outAxis->GetFirst(),1);
2425  Int_t lastOutBin = std::max(outAxis->GetLast(),outAxis->GetNbins());
2426  const TArrayD *xbins = outAxis->GetXbins();
2427  if (xbins->fN == 0)
2428  h1->SetBins(lastOutBin-firstOutBin+1,outAxis->GetBinLowEdge(firstOutBin),outAxis->GetBinUpEdge(lastOutBin));
2429  else
2430  h1->SetBins(lastOutBin-firstOutBin+1,&xbins->fArray[firstOutBin-1]);
2431 
2432  // set the bin content of the histogram
2433  Double_t pp[1];
2434  pp[0] = prob;
2435 
2436  TH1D * slice = 0;
2437  for (int ibin = outAxis->GetFirst() ; ibin <= outAxis->GetLast() ; ++ibin) {
2438  Double_t qq[1];
2439  // do a projection on the opposite axis
2440  slice = DoProjection(!onX, "tmp",ibin,ibin,"");
2441  if (!slice) break;
2442  if (slice->GetSum() == 0) continue;
2443  slice->GetQuantiles(1,qq,pp);
2444  h1->SetBinContent(ibin,qq[0]);
2445  // compute error using normal approximation
2446  // quantile error ~ sqrt (q*(1-q)/ *( n * f(xq)^2 ) from Kendall
2447  // where f(xq) is the p.d.f value at the quantile xq
2448  Double_t n = slice->GetEffectiveEntries();
2449  Double_t f = TMath::Gaus(qq[0], slice->GetMean(), slice->GetStdDev(), kTRUE);
2450  Double_t error = 0;
2451  // set the errors to zero in case of small statistics
2452  if (f > 0 && n > 1)
2453  error = TMath::Sqrt( prob*(1.-prob)/ (n * f * f) );
2454  h1->SetBinError(ibin, error);
2455  }
2456  if (slice) delete slice;
2457  return h1;
2458 }
2459 
2460 
2461 ////////////////////////////////////////////////////////////////////////////////
2462 /// Reset this histogram: contents, errors, etc.
2463 
2464 void TH2::Reset(Option_t *option)
2465 {
2466  TH1::Reset(option);
2467  TString opt = option;
2468  opt.ToUpper();
2469 
2470  if (opt.Contains("ICE") && !opt.Contains("S")) return;
2471  fTsumwy = 0;
2472  fTsumwy2 = 0;
2473  fTsumwxy = 0;
2474 }
2475 
2476 
2477 ////////////////////////////////////////////////////////////////////////////////
2478 /// Set bin content
2479 
2481 {
2482  fEntries++;
2483  fTsumw = 0;
2484  if (bin < 0) return;
2485  if (bin >= fNcells) return;
2486  UpdateBinContent(bin, content);
2487 }
2488 
2489 
2490 ////////////////////////////////////////////////////////////////////////////////
2491 /// When the mouse is moved in a pad containing a 2-d view of this histogram
2492 /// a second canvas shows the projection along X corresponding to the
2493 /// mouse position along Y.
2494 /// To stop the generation of the projections, delete the canvas
2495 /// containing the projection.
2496 
2498 {
2499  GetPainter();
2500 
2501  if (fPainter) fPainter->SetShowProjection("x",nbins);
2502 }
2503 
2504 
2505 ////////////////////////////////////////////////////////////////////////////////
2506 /// When the mouse is moved in a pad containing a 2-d view of this histogram
2507 /// a second canvas shows the projection along Y corresponding to the
2508 /// mouse position along X.
2509 /// To stop the generation of the projections, delete the canvas
2510 /// containing the projection.
2511 
2513 {
2514  GetPainter();
2515 
2516  if (fPainter) fPainter->SetShowProjection("y",nbins);
2517 }
2518 
2519 
2520 ////////////////////////////////////////////////////////////////////////////////
2521 /// This function calculates the background spectrum in this histogram.
2522 /// The background is returned as a histogram.
2523 /// to be implemented (may be)
2524 
2526 {
2527 
2528  return (TH1*)gROOT->ProcessLineFast(Form("TSpectrum2::StaticBackground((TH1*)0x%lx,%d,\"%s\")",
2529  (ULong_t)this, niter, option));
2530 }
2531 
2532 
2533 ////////////////////////////////////////////////////////////////////////////////
2534 ///Interface to TSpectrum2::Search
2535 ///the function finds peaks in this histogram where the width is > sigma
2536 ///and the peak maximum greater than threshold*maximum bin content of this.
2537 ///for more details see TSpectrum::Search.
2538 ///note the difference in the default value for option compared to TSpectrum2::Search
2539 ///option="" by default (instead of "goff")
2540 
2542 {
2543 
2544  return (Int_t)gROOT->ProcessLineFast(Form("TSpectrum2::StaticSearch((TH1*)0x%lx,%g,\"%s\",%g)",
2545  (ULong_t)this, sigma, option, threshold));
2546 }
2547 
2548 
2549 ////////////////////////////////////////////////////////////////////////////////
2550 /// Smooth bin contents of this 2-d histogram using kernel algorithms
2551 /// similar to the ones used in the raster graphics community.
2552 /// Bin contents in the active range are replaced by their smooth values.
2553 /// If Errors are defined via Sumw2, they are also scaled and computed.
2554 /// However, note the resulting errors will be correlated between different-bins, so
2555 /// the errors should not be used blindly to perform any calculation involving several bins,
2556 /// like fitting the histogram. One would need to compute also the bin by bin correlation matrix.
2557 ///
2558 /// 3 kernels are proposed k5a, k5b and k3a.
2559 /// k5a and k5b act on 5x5 cells (i-2,i-1,i,i+1,i+2, and same for j)
2560 /// k5b is a bit more stronger in smoothing
2561 /// k3a acts only on 3x3 cells (i-1,i,i+1, and same for j).
2562 /// By default the kernel "k5a" is used. You can select the kernels "k5b" or "k3a"
2563 /// via the option argument.
2564 /// If TAxis::SetRange has been called on the x or/and y axis, only the bins
2565 /// in the specified range are smoothed.
2566 /// In the current implementation if the first argument is not used (default value=1).
2567 ///
2568 /// implementation by David McKee (dmckee@bama.ua.edu). Extended by Rene Brun
2569 
2570 void TH2::Smooth(Int_t ntimes, Option_t *option)
2571 {
2572  Double_t k5a[5][5] = { { 0, 0, 1, 0, 0 },
2573  { 0, 2, 2, 2, 0 },
2574  { 1, 2, 5, 2, 1 },
2575  { 0, 2, 2, 2, 0 },
2576  { 0, 0, 1, 0, 0 } };
2577  Double_t k5b[5][5] = { { 0, 1, 2, 1, 0 },
2578  { 1, 2, 4, 2, 1 },
2579  { 2, 4, 8, 4, 2 },
2580  { 1, 2, 4, 2, 1 },
2581  { 0, 1, 2, 1, 0 } };
2582  Double_t k3a[3][3] = { { 0, 1, 0 },
2583  { 1, 2, 1 },
2584  { 0, 1, 0 } };
2585 
2586  if (ntimes > 1) {
2587  Warning("Smooth","Currently only ntimes=1 is supported");
2588  }
2589  TString opt = option;
2590  opt.ToLower();
2591  Int_t ksize_x=5;
2592  Int_t ksize_y=5;
2593  Double_t *kernel = &k5a[0][0];
2594  if (opt.Contains("k5b")) kernel = &k5b[0][0];
2595  if (opt.Contains("k3a")) {
2596  kernel = &k3a[0][0];
2597  ksize_x=3;
2598  ksize_y=3;
2599  }
2600 
2601  // find i,j ranges
2602  Int_t ifirst = fXaxis.GetFirst();
2603  Int_t ilast = fXaxis.GetLast();
2604  Int_t jfirst = fYaxis.GetFirst();
2605  Int_t jlast = fYaxis.GetLast();
2606 
2607  // Determine the size of the bin buffer(s) needed
2609  Int_t nx = GetNbinsX();
2610  Int_t ny = GetNbinsY();
2611  Int_t bufSize = (nx+2)*(ny+2);
2612  Double_t *buf = new Double_t[bufSize];
2613  Double_t *ebuf = 0;
2614  if (fSumw2.fN) ebuf = new Double_t[bufSize];
2615 
2616  // Copy all the data to the temporary buffers
2617  Int_t i,j,bin;
2618  for (i=ifirst; i<=ilast; i++){
2619  for (j=jfirst; j<=jlast; j++){
2620  bin = GetBin(i,j);
2621  buf[bin] = RetrieveBinContent(bin);
2622  if (ebuf) ebuf[bin]=GetBinError(bin);
2623  }
2624  }
2625 
2626  // Kernel tail sizes (kernel sizes must be odd for this to work!)
2627  Int_t x_push = (ksize_x-1)/2;
2628  Int_t y_push = (ksize_y-1)/2;
2629 
2630  // main work loop
2631  for (i=ifirst; i<=ilast; i++){
2632  for (j=jfirst; j<=jlast; j++) {
2633  Double_t content = 0.0;
2634  Double_t error = 0.0;
2635  Double_t norm = 0.0;
2636 
2637  for (Int_t n=0; n<ksize_x; n++) {
2638  for (Int_t m=0; m<ksize_y; m++) {
2639  Int_t xb = i+(n-x_push);
2640  Int_t yb = j+(m-y_push);
2641  if ( (xb >= 1) && (xb <= nx) && (yb >= 1) && (yb <= ny) ) {
2642  bin = GetBin(xb,yb);
2643  Double_t k = kernel[n*ksize_y +m];
2644  //if ( (k != 0.0 ) && (buf[bin] != 0.0) ) { // General version probably does not want the second condition
2645  if ( k != 0.0 ) {
2646  norm += k;
2647  content += k*buf[bin];
2648  if (ebuf) error += k*k*ebuf[bin]*ebuf[bin];
2649  }
2650  }
2651  }
2652  }
2653 
2654  if ( norm != 0.0 ) {
2655  SetBinContent(i,j,content/norm);
2656  if (ebuf) {
2657  error /= (norm*norm);
2658  SetBinError(i,j,sqrt(error));
2659  }
2660  }
2661  }
2662  }
2663  fEntries = nentries;
2664 
2665  delete [] buf;
2666  delete [] ebuf;
2667 }
2668 
2669 
2670 ////////////////////////////////////////////////////////////////////////////////
2671 /// Stream an object of class TH2.
2672 
2673 void TH2::Streamer(TBuffer &R__b)
2674 {
2675  if (R__b.IsReading()) {
2676  UInt_t R__s, R__c;
2677  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
2678  if (R__v > 2) {
2679  R__b.ReadClassBuffer(TH2::Class(), this, R__v, R__s, R__c);
2680  return;
2681  }
2682  //====process old versions before automatic schema evolution
2683  TH1::Streamer(R__b);
2684  R__b >> fScalefactor;
2685  R__b >> fTsumwy;
2686  R__b >> fTsumwy2;
2687  R__b >> fTsumwxy;
2688  //====end of old versions
2689 
2690  } else {
2691  R__b.WriteClassBuffer(TH2::Class(),this);
2692  }
2693 }
2694 
2695 
2696 //______________________________________________________________________________
2697 // TH2C methods
2698 // TH2C a 2-D histogram with one byte per cell (char)
2699 //______________________________________________________________________________
2700 
2701 ClassImp(TH2C);
2702 
2703 
2704 ////////////////////////////////////////////////////////////////////////////////
2705 /// Constructor.
2706 
2708 {
2709  SetBinsLength(9);
2710  if (fgDefaultSumw2) Sumw2();
2711 }
2712 
2713 
2714 ////////////////////////////////////////////////////////////////////////////////
2715 /// Destructor.
2716 
2718 {
2719 }
2720 
2721 
2722 ////////////////////////////////////////////////////////////////////////////////
2723 /// Constructor.
2724 
2725 TH2C::TH2C(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
2726  ,Int_t nbinsy,Double_t ylow,Double_t yup)
2727  :TH2(name,title,nbinsx,xlow,xup,nbinsy,ylow,yup)
2728 {
2730  if (fgDefaultSumw2) Sumw2();
2731 
2732  if (xlow >= xup || ylow >= yup) SetBuffer(fgBufferSize);
2733 }
2734 
2735 
2736 ////////////////////////////////////////////////////////////////////////////////
2737 /// Constructor.
2738 
2739 TH2C::TH2C(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
2740  ,Int_t nbinsy,Double_t ylow,Double_t yup)
2741  :TH2(name,title,nbinsx,xbins,nbinsy,ylow,yup)
2742 {
2744  if (fgDefaultSumw2) Sumw2();
2745 }
2746 
2747 
2748 ////////////////////////////////////////////////////////////////////////////////
2749 /// Constructor.
2750 
2751 TH2C::TH2C(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
2752  ,Int_t nbinsy,const Double_t *ybins)
2753  :TH2(name,title,nbinsx,xlow,xup,nbinsy,ybins)
2754 {
2756  if (fgDefaultSumw2) Sumw2();
2757 }
2758 
2759 
2760 ////////////////////////////////////////////////////////////////////////////////
2761 /// Constructor.
2762 
2763 TH2C::TH2C(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
2764  ,Int_t nbinsy,const Double_t *ybins)
2765  :TH2(name,title,nbinsx,xbins,nbinsy,ybins)
2766 {
2768  if (fgDefaultSumw2) Sumw2();
2769 }
2770 
2771 
2772 ////////////////////////////////////////////////////////////////////////////////
2773 /// Constructor.
2774 
2775 TH2C::TH2C(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins
2776  ,Int_t nbinsy,const Float_t *ybins)
2777  :TH2(name,title,nbinsx,xbins,nbinsy,ybins)
2778 {
2780  if (fgDefaultSumw2) Sumw2();
2781 }
2782 
2783 
2784 ////////////////////////////////////////////////////////////////////////////////
2785 /// Copy constructor.
2786 
2787 TH2C::TH2C(const TH2C &h2c) : TH2(), TArrayC()
2788 {
2789  ((TH2C&)h2c).Copy(*this);
2790 }
2791 
2792 
2793 ////////////////////////////////////////////////////////////////////////////////
2794 /// Increment bin content by 1.
2795 
2797 {
2798  if (fArray[bin] < 127) fArray[bin]++;
2799 }
2800 
2801 
2802 ////////////////////////////////////////////////////////////////////////////////
2803 /// Increment bin content by w.
2804 
2806 {
2807  Int_t newval = fArray[bin] + Int_t(w);
2808  if (newval > -128 && newval < 128) {fArray[bin] = Char_t(newval); return;}
2809  if (newval < -127) fArray[bin] = -127;
2810  if (newval > 127) fArray[bin] = 127;
2811 }
2812 
2813 
2814 ////////////////////////////////////////////////////////////////////////////////
2815 /// Copy.
2816 
2817 void TH2C::Copy(TObject &newth2) const
2818 {
2819  TH2::Copy((TH2C&)newth2);
2820 }
2821 
2822 
2823 ////////////////////////////////////////////////////////////////////////////////
2824 /// Reset this histogram: contents, errors, etc.
2825 
2826 void TH2C::Reset(Option_t *option)
2827 {
2828  TH2::Reset(option);
2829  TArrayC::Reset();
2830 }
2831 
2832 
2833 ////////////////////////////////////////////////////////////////////////////////
2834 /// Set total number of bins including under/overflow
2835 /// Reallocate bin contents array
2836 
2838 {
2839  if (n < 0) n = (fXaxis.GetNbins()+2)*(fYaxis.GetNbins()+2);
2840  fNcells = n;
2841  TArrayC::Set(n);
2842 }
2843 
2844 
2845 ////////////////////////////////////////////////////////////////////////////////
2846 /// Stream an object of class TH2C.
2847 
2848 void TH2C::Streamer(TBuffer &R__b)
2849 {
2850  if (R__b.IsReading()) {
2851  UInt_t R__s, R__c;
2852  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
2853  if (R__v > 2) {
2854  R__b.ReadClassBuffer(TH2C::Class(), this, R__v, R__s, R__c);
2855  return;
2856  }
2857  //====process old versions before automatic schema evolution
2858  if (R__v < 2) {
2859  R__b.ReadVersion();
2860  TH1::Streamer(R__b);
2861  TArrayC::Streamer(R__b);
2862  R__b.ReadVersion();
2863  R__b >> fScalefactor;
2864  R__b >> fTsumwy;
2865  R__b >> fTsumwy2;
2866  R__b >> fTsumwxy;
2867  } else {
2868  TH2::Streamer(R__b);
2869  TArrayC::Streamer(R__b);
2870  R__b.CheckByteCount(R__s, R__c, TH2C::IsA());
2871  }
2872  //====end of old versions
2873 
2874  } else {
2875  R__b.WriteClassBuffer(TH2C::Class(),this);
2876  }
2877 }
2878 
2879 
2880 ////////////////////////////////////////////////////////////////////////////////
2881 /// Operator =
2882 
2884 {
2885  if (this != &h1) ((TH2C&)h1).Copy(*this);
2886  return *this;
2887 }
2888 
2889 
2890 ////////////////////////////////////////////////////////////////////////////////
2891 /// Operator *
2892 
2894 {
2895  TH2C hnew = h1;
2896  hnew.Scale(c1);
2897  hnew.SetDirectory(0);
2898  return hnew;
2899 }
2900 
2901 
2902 ////////////////////////////////////////////////////////////////////////////////
2903 /// Operator +
2904 
2906 {
2907  TH2C hnew = h1;
2908  hnew.Add(&h2,1);
2909  hnew.SetDirectory(0);
2910  return hnew;
2911 }
2912 
2913 
2914 ////////////////////////////////////////////////////////////////////////////////
2915 /// Operator -
2916 
2918 {
2919  TH2C hnew = h1;
2920  hnew.Add(&h2,-1);
2921  hnew.SetDirectory(0);
2922  return hnew;
2923 }
2924 
2925 
2926 ////////////////////////////////////////////////////////////////////////////////
2927 /// Operator *
2928 
2930 {
2931  TH2C hnew = h1;
2932  hnew.Multiply(&h2);
2933  hnew.SetDirectory(0);
2934  return hnew;
2935 }
2936 
2937 
2938 ////////////////////////////////////////////////////////////////////////////////
2939 /// Operator /
2940 
2942 {
2943  TH2C hnew = h1;
2944  hnew.Divide(&h2);
2945  hnew.SetDirectory(0);
2946  return hnew;
2947 }
2948 
2949 
2950 //______________________________________________________________________________
2951 // TH2S methods
2952 // TH2S a 2-D histogram with two bytes per cell (short integer)
2953 //______________________________________________________________________________
2954 
2955 ClassImp(TH2S);
2956 
2957 
2958 ////////////////////////////////////////////////////////////////////////////////
2959 /// Constructor.
2960 
2962 {
2963  SetBinsLength(9);
2964  if (fgDefaultSumw2) Sumw2();
2965 }
2966 
2967 
2968 ////////////////////////////////////////////////////////////////////////////////
2969 /// Destructor.
2970 
2972 {
2973 }
2974 
2975 
2976 ////////////////////////////////////////////////////////////////////////////////
2977 /// Constructor.
2978 
2979 TH2S::TH2S(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
2980  ,Int_t nbinsy,Double_t ylow,Double_t yup)
2981  :TH2(name,title,nbinsx,xlow,xup,nbinsy,ylow,yup)
2982 {
2984  if (fgDefaultSumw2) Sumw2();
2985 
2986  if (xlow >= xup || ylow >= yup) SetBuffer(fgBufferSize);
2987 }
2988 
2989 
2990 ////////////////////////////////////////////////////////////////////////////////
2991 /// Constructor.
2992 
2993 TH2S::TH2S(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
2994  ,Int_t nbinsy,Double_t ylow,Double_t yup)
2995  :TH2(name,title,nbinsx,xbins,nbinsy,ylow,yup)
2996 {
2998  if (fgDefaultSumw2) Sumw2();
2999 }
3000 
3001 
3002 ////////////////////////////////////////////////////////////////////////////////
3003 /// Constructor.
3004 
3005 TH2S::TH2S(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
3006  ,Int_t nbinsy,const Double_t *ybins)
3007  :TH2(name,title,nbinsx,xlow,xup,nbinsy,ybins)
3008 {
3010  if (fgDefaultSumw2) Sumw2();
3011 }
3012 
3013 
3014 ////////////////////////////////////////////////////////////////////////////////
3015 /// Constructor.
3016 
3017 TH2S::TH2S(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
3018  ,Int_t nbinsy,const Double_t *ybins)
3019  :TH2(name,title,nbinsx,xbins,nbinsy,ybins)
3020 {
3022  if (fgDefaultSumw2) Sumw2();
3023 }
3024 
3025 
3026 ////////////////////////////////////////////////////////////////////////////////
3027 /// Constructor.
3028 
3029 TH2S::TH2S(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins
3030  ,Int_t nbinsy,const Float_t *ybins)
3031  :TH2(name,title,nbinsx,xbins,nbinsy,ybins)
3032 {
3034  if (fgDefaultSumw2) Sumw2();
3035 }
3036 
3037 
3038 ////////////////////////////////////////////////////////////////////////////////
3039 /// Copy constructor.
3040 
3041 TH2S::TH2S(const TH2S &h2s) : TH2(), TArrayS()
3042 {
3043  ((TH2S&)h2s).Copy(*this);
3044 }
3045 
3046 
3047 ////////////////////////////////////////////////////////////////////////////////
3048 /// Increment bin content by 1.
3049 
3051 {
3052  if (fArray[bin] < 32767) fArray[bin]++;
3053 }
3054 
3055 
3056 ////////////////////////////////////////////////////////////////////////////////
3057 /// Increment bin content by w.
3058 
3060 {
3061  Int_t newval = fArray[bin] + Int_t(w);
3062  if (newval > -32768 && newval < 32768) {fArray[bin] = Short_t(newval); return;}
3063  if (newval < -32767) fArray[bin] = -32767;
3064  if (newval > 32767) fArray[bin] = 32767;
3065 }
3066 
3067 
3068 ////////////////////////////////////////////////////////////////////////////////
3069 /// Copy.
3070 
3071 void TH2S::Copy(TObject &newth2) const
3072 {
3073  TH2::Copy((TH2S&)newth2);
3074 }
3075 
3076 
3077 ////////////////////////////////////////////////////////////////////////////////
3078 /// Reset this histogram: contents, errors, etc.
3079 
3080 void TH2S::Reset(Option_t *option)
3081 {
3082  TH2::Reset(option);
3083  TArrayS::Reset();
3084 }
3085 
3086 
3087 ////////////////////////////////////////////////////////////////////////////////
3088 /// Set total number of bins including under/overflow
3089 /// Reallocate bin contents array
3090 
3092 {
3093  if (n < 0) n = (fXaxis.GetNbins()+2)*(fYaxis.GetNbins()+2);
3094  fNcells = n;
3095  TArrayS::Set(n);
3096 }
3097 
3098 
3099 ////////////////////////////////////////////////////////////////////////////////
3100 /// Stream an object of class TH2S.
3101 
3102 void TH2S::Streamer(TBuffer &R__b)
3103 {
3104  if (R__b.IsReading()) {
3105  UInt_t R__s, R__c;
3106  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
3107  if (R__v > 2) {
3108  R__b.ReadClassBuffer(TH2S::Class(), this, R__v, R__s, R__c);
3109  return;
3110  }
3111  //====process old versions before automatic schema evolution
3112  if (R__v < 2) {
3113  R__b.ReadVersion();
3114  TH1::Streamer(R__b);
3115  TArrayS::Streamer(R__b);
3116  R__b.ReadVersion();
3117  R__b >> fScalefactor;
3118  R__b >> fTsumwy;
3119  R__b >> fTsumwy2;
3120  R__b >> fTsumwxy;
3121  } else {
3122  TH2::Streamer(R__b);
3123  TArrayS::Streamer(R__b);
3124  R__b.CheckByteCount(R__s, R__c, TH2S::IsA());
3125  }
3126  //====end of old versions
3127 
3128  } else {
3129  R__b.WriteClassBuffer(TH2S::Class(),this);
3130  }
3131 }
3132 
3133 
3134 ////////////////////////////////////////////////////////////////////////////////
3135 /// Operator =
3136 
3138 {
3139  if (this != &h1) ((TH2S&)h1).Copy(*this);
3140  return *this;
3141 }
3142 
3143 
3144 ////////////////////////////////////////////////////////////////////////////////
3145 /// Operator *
3146 
3148 {
3149  TH2S hnew = h1;
3150  hnew.Scale(c1);
3151  hnew.SetDirectory(0);
3152  return hnew;
3153 }
3154 
3155 
3156 ////////////////////////////////////////////////////////////////////////////////
3157 /// Operator +
3158 
3160 {
3161  TH2S hnew = h1;
3162  hnew.Add(&h2,1);
3163  hnew.SetDirectory(0);
3164  return hnew;
3165 }
3166 
3167 
3168 ////////////////////////////////////////////////////////////////////////////////
3169 /// Operator -
3170 
3172 {
3173  TH2S hnew = h1;
3174  hnew.Add(&h2,-1);
3175  hnew.SetDirectory(0);
3176  return hnew;
3177 }
3178 
3179 
3180 ////////////////////////////////////////////////////////////////////////////////
3181 /// Operator *
3182 
3184 {
3185  TH2S hnew = h1;
3186  hnew.Multiply(&h2);
3187  hnew.SetDirectory(0);
3188  return hnew;
3189 }
3190 
3191 
3192 ////////////////////////////////////////////////////////////////////////////////
3193 /// Operator /
3194 
3196 {
3197  TH2S hnew = h1;
3198  hnew.Divide(&h2);
3199  hnew.SetDirectory(0);
3200  return hnew;
3201 }
3202 
3203 
3204 //______________________________________________________________________________
3205 // TH2I methods
3206 // TH2I a 2-D histogram with four bytes per cell (32 bits integer)
3207 //______________________________________________________________________________
3208 
3209 ClassImp(TH2I);
3210 
3211 
3212 ////////////////////////////////////////////////////////////////////////////////
3213 /// Constructor.
3214 
3216 {
3217  SetBinsLength(9);
3218  if (fgDefaultSumw2) Sumw2();
3219 }
3220 
3221 
3222 ////////////////////////////////////////////////////////////////////////////////
3223 /// Destructor.
3224 
3226 {
3227 }
3228 
3229 
3230 ////////////////////////////////////////////////////////////////////////////////
3231 /// Constructor.
3232 
3233 TH2I::TH2I(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
3234  ,Int_t nbinsy,Double_t ylow,Double_t yup)
3235  :TH2(name,title,nbinsx,xlow,xup,nbinsy,ylow,yup)
3236 {
3238  if (fgDefaultSumw2) Sumw2();
3239 
3240  if (xlow >= xup || ylow >= yup) SetBuffer(fgBufferSize);
3241 }
3242 
3243 
3244 ////////////////////////////////////////////////////////////////////////////////
3245 /// Constructor.
3246 
3247 TH2I::TH2I(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
3248  ,Int_t nbinsy,Double_t ylow,Double_t yup)
3249  :TH2(name,title,nbinsx,xbins,nbinsy,ylow,yup)
3250 {
3252  if (fgDefaultSumw2) Sumw2();
3253 }
3254 
3255 
3256 ////////////////////////////////////////////////////////////////////////////////
3257 /// Constructor.
3258 
3259 TH2I::TH2I(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
3260  ,Int_t nbinsy,const Double_t *ybins)
3261  :TH2(name,title,nbinsx,xlow,xup,nbinsy,ybins)
3262 {
3264  if (fgDefaultSumw2) Sumw2();
3265 }
3266 
3267 
3268 ////////////////////////////////////////////////////////////////////////////////
3269 /// Constructor.
3270 
3271 TH2I::TH2I(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
3272  ,Int_t nbinsy,const Double_t *ybins)
3273  :TH2(name,title,nbinsx,xbins,nbinsy,ybins)
3274 {
3276  if (fgDefaultSumw2) Sumw2();
3277 }
3278 
3279 
3280 ////////////////////////////////////////////////////////////////////////////////
3281 /// Constructor.
3282 
3283 TH2I::TH2I(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins
3284  ,Int_t nbinsy,const Float_t *ybins)
3285  :TH2(name,title,nbinsx,xbins,nbinsy,ybins)
3286 {
3288  if (fgDefaultSumw2) Sumw2();
3289 }
3290 
3291 
3292 ////////////////////////////////////////////////////////////////////////////////
3293 /// Copy constructor.
3294 
3295 TH2I::TH2I(const TH2I &h2i) : TH2(), TArrayI()
3296 {
3297  ((TH2I&)h2i).Copy(*this);
3298 }
3299 
3300 
3301 ////////////////////////////////////////////////////////////////////////////////
3302 /// Increment bin content by 1.
3303 
3305 {
3306  if (fArray[bin] < 2147483647) fArray[bin]++;
3307 }
3308 
3309 
3310 ////////////////////////////////////////////////////////////////////////////////
3311 /// Increment bin content by w.
3312 
3314 {
3315  Long64_t newval = fArray[bin] + Long64_t(w);
3316  if (newval > -2147483647 && newval < 2147483647) {fArray[bin] = Int_t(newval); return;}
3317  if (newval < -2147483647) fArray[bin] = -2147483647;
3318  if (newval > 2147483647) fArray[bin] = 2147483647;
3319 }
3320 
3321 
3322 ////////////////////////////////////////////////////////////////////////////////
3323 /// Copy.
3324 
3325 void TH2I::Copy(TObject &newth2) const
3326 {
3327  TH2::Copy((TH2I&)newth2);
3328 }
3329 
3330 
3331 ////////////////////////////////////////////////////////////////////////////////
3332 /// Reset this histogram: contents, errors, etc.
3333 
3334 void TH2I::Reset(Option_t *option)
3335 {
3336  TH2::Reset(option);
3337  TArrayI::Reset();
3338 }
3339 
3340 
3341 ////////////////////////////////////////////////////////////////////////////////
3342 /// Set total number of bins including under/overflow
3343 /// Reallocate bin contents array
3344 
3346 {
3347  if (n < 0) n = (fXaxis.GetNbins()+2)*(fYaxis.GetNbins()+2);
3348  fNcells = n;
3349  TArrayI::Set(n);
3350 }
3351 
3352 
3353 ////////////////////////////////////////////////////////////////////////////////
3354 /// Operator =
3355 
3357 {
3358  if (this != &h1) ((TH2I&)h1).Copy(*this);
3359  return *this;
3360 }
3361 
3362 
3363 ////////////////////////////////////////////////////////////////////////////////
3364 /// Operator *
3365 
3367 {
3368  TH2I hnew = h1;
3369  hnew.Scale(c1);
3370  hnew.SetDirectory(0);
3371  return hnew;
3372 }
3373 
3374 
3375 ////////////////////////////////////////////////////////////////////////////////
3376 /// Operator +
3377 
3379 {
3380  TH2I hnew = h1;
3381  hnew.Add(&h2,1);
3382  hnew.SetDirectory(0);
3383  return hnew;
3384 }
3385 
3386 
3387 ////////////////////////////////////////////////////////////////////////////////
3388 /// Operator -
3389 
3391 {
3392  TH2I hnew = h1;
3393  hnew.Add(&h2,-1);
3394  hnew.SetDirectory(0);
3395  return hnew;
3396 }
3397 
3398 
3399 ////////////////////////////////////////////////////////////////////////////////
3400 /// Operator *
3401 
3403 {
3404  TH2I hnew = h1;
3405  hnew.Multiply(&h2);
3406  hnew.SetDirectory(0);
3407  return hnew;
3408 }
3409 
3410 
3411 ////////////////////////////////////////////////////////////////////////////////
3412 /// Operator /
3413 
3415 {
3416  TH2I hnew = h1;
3417  hnew.Divide(&h2);
3418  hnew.SetDirectory(0);
3419  return hnew;
3420 }
3421 
3422 
3423 //______________________________________________________________________________
3424 // TH2F methods
3425 // TH2F a 2-D histogram with four bytes per cell (float)
3426 //______________________________________________________________________________
3427 
3428 ClassImp(TH2F);
3429 
3430 
3431 ////////////////////////////////////////////////////////////////////////////////
3432 /// Constructor.
3433 
3435 {
3436  SetBinsLength(9);
3437  if (fgDefaultSumw2) Sumw2();
3438 }
3439 
3440 
3441 ////////////////////////////////////////////////////////////////////////////////
3442 /// Destructor.
3443 
3445 {
3446 }
3447 
3448 
3449 ////////////////////////////////////////////////////////////////////////////////
3450 /// Constructor.
3451 
3452 TH2F::TH2F(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
3453  ,Int_t nbinsy,Double_t ylow,Double_t yup)
3454  :TH2(name,title,nbinsx,xlow,xup,nbinsy,ylow,yup)
3455 {
3457  if (fgDefaultSumw2) Sumw2();
3458 
3459  if (xlow >= xup || ylow >= yup) SetBuffer(fgBufferSize);
3460 }
3461 
3462 
3463 ////////////////////////////////////////////////////////////////////////////////
3464 /// Constructor.
3465 
3466 TH2F::TH2F(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
3467  ,Int_t nbinsy,Double_t ylow,Double_t yup)
3468  :TH2(name,title,nbinsx,xbins,nbinsy,ylow,yup)
3469 {
3471  if (fgDefaultSumw2) Sumw2();
3472 }
3473 
3474 
3475 ////////////////////////////////////////////////////////////////////////////////
3476 /// Constructor.
3477 
3478 TH2F::TH2F(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
3479  ,Int_t nbinsy,const Double_t *ybins)
3480  :TH2(name,title,nbinsx,xlow,xup,nbinsy,ybins)
3481 {
3483  if (fgDefaultSumw2) Sumw2();
3484 }
3485 
3486 
3487 ////////////////////////////////////////////////////////////////////////////////
3488 /// Constructor.
3489 
3490 TH2F::TH2F(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
3491  ,Int_t nbinsy,const Double_t *ybins)
3492  :TH2(name,title,nbinsx,xbins,nbinsy,ybins)
3493 {
3495  if (fgDefaultSumw2) Sumw2();
3496 }
3497 
3498 
3499 ////////////////////////////////////////////////////////////////////////////////
3500 /// Constructor.
3501 
3502 TH2F::TH2F(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins
3503  ,Int_t nbinsy,const Float_t *ybins)
3504  :TH2(name,title,nbinsx,xbins,nbinsy,ybins)
3505 {
3507  if (fgDefaultSumw2) Sumw2();
3508 }
3509 
3510 
3511 ////////////////////////////////////////////////////////////////////////////////
3512 /// Constructor.
3513 
3515 :TH2("TMatrixFBase","",m.GetNcols(),m.GetColLwb(),1+m.GetColUpb(),m.GetNrows(),m.GetRowLwb(),1+m.GetRowUpb())
3516 {
3518  Int_t ilow = m.GetRowLwb();
3519  Int_t iup = m.GetRowUpb();
3520  Int_t jlow = m.GetColLwb();
3521  Int_t jup = m.GetColUpb();
3522  for (Int_t i=ilow;i<=iup;i++) {
3523  for (Int_t j=jlow;j<=jup;j++) {
3524  SetBinContent(j-jlow+1,i-ilow+1,m(i,j));
3525  }
3526  }
3527 }
3528 
3529 
3530 ////////////////////////////////////////////////////////////////////////////////
3531 /// Copy constructor.
3532 
3533 TH2F::TH2F(const TH2F &h2f) : TH2(), TArrayF()
3534 {
3535  ((TH2F&)h2f).Copy(*this);
3536 }
3537 
3538 
3539 ////////////////////////////////////////////////////////////////////////////////
3540 /// Copy.
3541 
3542 void TH2F::Copy(TObject &newth2) const
3543 {
3544  TH2::Copy((TH2F&)newth2);
3545 }
3546 
3547 
3548 ////////////////////////////////////////////////////////////////////////////////
3549 /// Reset this histogram: contents, errors, etc.
3550 
3551 void TH2F::Reset(Option_t *option)
3552 {
3553  TH2::Reset(option);
3554  TArrayF::Reset();
3555 }
3556 
3557 
3558 ////////////////////////////////////////////////////////////////////////////////
3559 /// Set total number of bins including under/overflow
3560 /// Reallocate bin contents array
3561 
3563 {
3564  if (n < 0) n = (fXaxis.GetNbins()+2)*(fYaxis.GetNbins()+2);
3565  fNcells = n;
3566  TArrayF::Set(n);
3567 }
3568 
3569 
3570 ////////////////////////////////////////////////////////////////////////////////
3571 /// Stream an object of class TH2F.
3572 
3573 void TH2F::Streamer(TBuffer &R__b)
3574 {
3575  if (R__b.IsReading()) {
3576  UInt_t R__s, R__c;
3577  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
3578  if (R__v > 2) {
3579  R__b.ReadClassBuffer(TH2F::Class(), this, R__v, R__s, R__c);
3580  return;
3581  }
3582  //====process old versions before automatic schema evolution
3583  if (R__v < 2) {
3584  R__b.ReadVersion();
3585  TH1::Streamer(R__b);
3586  TArrayF::Streamer(R__b);
3587  R__b.ReadVersion();
3588  R__b >> fScalefactor;
3589  R__b >> fTsumwy;
3590  R__b >> fTsumwy2;
3591  R__b >> fTsumwxy;
3592  } else {
3593  TH2::Streamer(R__b);
3594  TArrayF::Streamer(R__b);
3595  R__b.CheckByteCount(R__s, R__c, TH2F::IsA());
3596  }
3597  //====end of old versions
3598 
3599  } else {
3600  R__b.WriteClassBuffer(TH2F::Class(),this);
3601  }
3602 }
3603 
3604 
3605 ////////////////////////////////////////////////////////////////////////////////
3606 /// Operator =
3607 
3609 {
3610  if (this != &h1) ((TH2F&)h1).Copy(*this);
3611  return *this;
3612 }
3613 
3614 
3615 ////////////////////////////////////////////////////////////////////////////////
3616 /// Operator *
3617 
3619 {
3620  TH2F hnew = h1;
3621  hnew.Scale(c1);
3622  hnew.SetDirectory(0);
3623  return hnew;
3624 }
3625 
3626 
3627 ////////////////////////////////////////////////////////////////////////////////
3628 /// Operator *
3629 
3631 {
3632  TH2F hnew = h1;
3633  hnew.Scale(c1);
3634  hnew.SetDirectory(0);
3635  return hnew;
3636 }
3637 
3638 
3639 ////////////////////////////////////////////////////////////////////////////////
3640 /// Operator +
3641 
3643 {
3644  TH2F hnew = h1;
3645  hnew.Add(&h2,1);
3646  hnew.SetDirectory(0);
3647  return hnew;
3648 }
3649 
3650 
3651 ////////////////////////////////////////////////////////////////////////////////
3652 /// Operator -
3653 
3655 {
3656  TH2F hnew = h1;
3657  hnew.Add(&h2,-1);
3658  hnew.SetDirectory(0);
3659  return hnew;
3660 }
3661 
3662 
3663 ////////////////////////////////////////////////////////////////////////////////
3664 /// Operator *
3665 
3667 {
3668  TH2F hnew = h1;
3669  hnew.Multiply(&h2);
3670  hnew.SetDirectory(0);
3671  return hnew;
3672 }
3673 
3674 
3675 ////////////////////////////////////////////////////////////////////////////////
3676 /// Operator /
3677 
3679 {
3680  TH2F hnew = h1;
3681  hnew.Divide(&h2);
3682  hnew.SetDirectory(0);
3683  return hnew;
3684 }
3685 
3686 
3687 //______________________________________________________________________________
3688 // TH2D methods
3689 // TH2D a 2-D histogram with eight bytes per cell (double)
3690 //______________________________________________________________________________
3691 
3692 ClassImp(TH2D);
3693 
3694 
3695 ////////////////////////////////////////////////////////////////////////////////
3696 /// Constructor.
3697 
3699 {
3700  SetBinsLength(9);
3701  if (fgDefaultSumw2) Sumw2();
3702 }
3703 
3704 
3705 ////////////////////////////////////////////////////////////////////////////////
3706 /// Destructor.
3707 
3709 {
3710 }
3711 
3712 
3713 ////////////////////////////////////////////////////////////////////////////////
3714 /// Constructor.
3715 
3716 TH2D::TH2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
3717  ,Int_t nbinsy,Double_t ylow,Double_t yup)
3718  :TH2(name,title,nbinsx,xlow,xup,nbinsy,ylow,yup)
3719 {
3721  if (fgDefaultSumw2) Sumw2();
3722 
3723  if (xlow >= xup || ylow >= yup) SetBuffer(fgBufferSize);
3724 }
3725 
3726 
3727 ////////////////////////////////////////////////////////////////////////////////
3728 /// Constructor.
3729 
3730 TH2D::TH2D(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
3731  ,Int_t nbinsy,Double_t ylow,Double_t yup)
3732  :TH2(name,title,nbinsx,xbins,nbinsy,ylow,yup)
3733 {
3735  if (fgDefaultSumw2) Sumw2();
3736 }
3737 
3738 
3739 ////////////////////////////////////////////////////////////////////////////////
3740 /// Constructor.
3741 
3742 TH2D::TH2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
3743  ,Int_t nbinsy,const Double_t *ybins)
3744  :TH2(name,title,nbinsx,xlow,xup,nbinsy,ybins)
3745 {
3747  if (fgDefaultSumw2) Sumw2();
3748 }
3749 
3750 
3751 ////////////////////////////////////////////////////////////////////////////////
3752 /// Constructor.
3753 
3754 TH2D::TH2D(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
3755  ,Int_t nbinsy,const Double_t *ybins)
3756  :TH2(name,title,nbinsx,xbins,nbinsy,ybins)
3757 {
3759  if (fgDefaultSumw2) Sumw2();
3760 }
3761 
3762 
3763 ////////////////////////////////////////////////////////////////////////////////
3764 /// Constructor.
3765 
3766 TH2D::TH2D(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins
3767  ,Int_t nbinsy,const Float_t *ybins)
3768  :TH2(name,title,nbinsx,xbins,nbinsy,ybins)
3769 {
3771  if (fgDefaultSumw2) Sumw2();
3772 }
3773 
3774 
3775 ////////////////////////////////////////////////////////////////////////////////
3776 /// Constructor.
3777 
3779 :TH2("TMatrixDBase","",m.GetNcols(),m.GetColLwb(),1+m.GetColUpb(),m.GetNrows(),m.GetRowLwb(),1+m.GetRowUpb())
3780 {
3782  Int_t ilow = m.GetRowLwb();
3783  Int_t iup = m.GetRowUpb();
3784  Int_t jlow = m.GetColLwb();
3785  Int_t jup = m.GetColUpb();
3786  for (Int_t i=ilow;i<=iup;i++) {
3787  for (Int_t j=jlow;j<=jup;j++) {
3788  SetBinContent(j-jlow+1,i-ilow+1,m(i,j));
3789  }
3790  }
3791  if (fgDefaultSumw2) Sumw2();
3792 }
3793 
3794 
3795 ////////////////////////////////////////////////////////////////////////////////
3796 /// Copy constructor.
3797 
3798 TH2D::TH2D(const TH2D &h2d) : TH2(), TArrayD()
3799 {
3800  ((TH2D&)h2d).Copy(*this);
3801 }
3802 
3803 
3804 ////////////////////////////////////////////////////////////////////////////////
3805 /// Copy.
3806 
3807 void TH2D::Copy(TObject &newth2) const
3808 {
3809  TH2::Copy((TH2D&)newth2);
3810 }
3811 
3812 
3813 ////////////////////////////////////////////////////////////////////////////////
3814 /// Reset this histogram: contents, errors, etc.
3815 
3816 void TH2D::Reset(Option_t *option)
3817 {
3818  TH2::Reset(option);
3819  TArrayD::Reset();
3820 }
3821 
3822 
3823 ////////////////////////////////////////////////////////////////////////////////
3824 /// Set total number of bins including under/overflow
3825 /// Reallocate bin contents array
3826 
3828 {
3829  if (n < 0) n = (fXaxis.GetNbins()+2)*(fYaxis.GetNbins()+2);
3830  fNcells = n;
3831  TArrayD::Set(n);
3832 }
3833 
3834 
3835 ////////////////////////////////////////////////////////////////////////////////
3836 /// Stream an object of class TH2D.
3837 
3838 void TH2D::Streamer(TBuffer &R__b)
3839 {
3840  if (R__b.IsReading()) {
3841  UInt_t R__s, R__c;
3842  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
3843  if (R__v > 2) {
3844  R__b.ReadClassBuffer(TH2D::Class(), this, R__v, R__s, R__c);
3845  return;
3846  }
3847  //====process old versions before automatic schema evolution
3848  if (R__v < 2) {
3849  R__b.ReadVersion();
3850  TH1::Streamer(R__b);
3851  TArrayD::Streamer(R__b);
3852  R__b.ReadVersion();
3853  R__b >> fScalefactor;
3854  R__b >> fTsumwy;
3855  R__b >> fTsumwy2;
3856  R__b >> fTsumwxy;
3857  } else {
3858  TH2::Streamer(R__b);
3859  TArrayD::Streamer(R__b);
3860  R__b.CheckByteCount(R__s, R__c, TH2D::IsA());
3861  }
3862  //====end of old versions
3863 
3864  } else {
3865  R__b.WriteClassBuffer(TH2D::Class(),this);
3866  }
3867 }
3868 
3869 
3870 ////////////////////////////////////////////////////////////////////////////////
3871 /// Operator =
3872 
3874 {
3875  if (this != &h1) ((TH2D&)h1).Copy(*this);
3876  return *this;
3877 }
3878 
3879 
3880 
3881 ////////////////////////////////////////////////////////////////////////////////
3882 /// Operator *
3883 
3885 {
3886  TH2D hnew = h1;
3887  hnew.Scale(c1);
3888  hnew.SetDirectory(0);
3889  return hnew;
3890 }
3891 
3892 
3893 ////////////////////////////////////////////////////////////////////////////////
3894 /// Operator +
3895 
3897 {
3898  TH2D hnew = h1;
3899  hnew.Add(&h2,1);
3900  hnew.SetDirectory(0);
3901  return hnew;
3902 }
3903 
3904 
3905 ////////////////////////////////////////////////////////////////////////////////
3906 /// Operator -
3907 
3909 {
3910  TH2D hnew = h1;
3911  hnew.Add(&h2,-1);
3912  hnew.SetDirectory(0);
3913  return hnew;
3914 }
3915 
3916 
3917 ////////////////////////////////////////////////////////////////////////////////
3918 /// Operator *
3919 
3921 {
3922  TH2D hnew = h1;
3923  hnew.Multiply(&h2);
3924  hnew.SetDirectory(0);
3925  return hnew;
3926 }
3927 
3928 
3929 ////////////////////////////////////////////////////////////////////////////////
3930 /// Operator /
3931 
3933 {
3934  TH2D hnew = h1;
3935  hnew.Divide(&h2);
3936  hnew.SetDirectory(0);
3937  return hnew;
3938 }
TArrayF::Copy
void Copy(TArrayF &array) const
Definition: TArrayF.h:48
TH2::GetRandom2
virtual void GetRandom2(Double_t &x, Double_t &y)
Return 2 random numbers along axis x and y distributed according the cell-contents of a 2-dim histogr...
Definition: TH2.cxx:1076
THLimitsFinder::FindGoodLimits
virtual Int_t FindGoodLimits(TH1 *h, Double_t xmin, Double_t xmax)
Compute the best axis limits for the X axis.
Definition: THLimitsFinder.cxx:53
c
#define c(i)
Definition: RSha256.hxx:119
TMatrixFBase.h
TH1::UpdateBinContent
virtual void UpdateBinContent(Int_t bin, Double_t content)
Raw update of bin content on internal data structure see convention for numbering bins in TH1::GetBin...
Definition: TH1.cxx:8905
TF1::GetHistogram
virtual TH1 * GetHistogram() const
Return a pointer to the histogram used to visualise the function.
Definition: TF1.cxx:1585
TVirtualHistPainter::SetShowProjection
virtual void SetShowProjection(const char *option, Int_t nbins)=0
TH1::RetrieveBinContent
virtual Double_t RetrieveBinContent(Int_t bin) const
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
Definition: TH1.cxx:8895
m
auto * m
Definition: textangle.C:8
TH2::Copy
virtual void Copy(TObject &hnew) const
Copy.
Definition: TH2.cxx:281
n
const Int_t n
Definition: legend1.C:16
TH2D::Copy
virtual void Copy(TObject &hnew) const
Copy.
Definition: TH2.cxx:3807
TAxis
Class to manage histogram axis.
Definition: TAxis.h:30
TArrayS
Definition: TArrayS.h:27
fit1_py.fill
fill
Definition: fit1_py.py:6
TH1::GetSumw2N
virtual Int_t GetSumw2N() const
Definition: TH1.h:311
TH1::Copy
virtual void Copy(TObject &hnew) const
Copy this histogram structure to newth1.
Definition: TH1.cxx:2587
TArrayD::GetSum
Stat_t GetSum() const
Definition: TArrayD.h:52
ymax
float ymax
Definition: THbookFile.cxx:95
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
e
#define e(i)
Definition: RSha256.hxx:121
Style_t
short Style_t
Definition: RtypesCore.h:80
TObject::TestBit
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
TH2::ProjectionX
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.
Definition: TH2.cxx:2300
TH2I::operator=
TH2I & operator=(const TH2I &h1)
Operator =.
Definition: TH2.cxx:3356
TAxis::GetBinLowEdge
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition: TAxis.cxx:518
TH1::fYaxis
TAxis fYaxis
Y axis descriptor.
Definition: TH1.h:89
Version_t
short Version_t
Definition: RtypesCore.h:65
TH2I::AddBinContent
virtual void AddBinContent(Int_t bin)
Increment bin content by 1.
Definition: TH2.cxx:3304
snprintf
#define snprintf
Definition: civetweb.c:1540
TAxis::Set
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
Definition: TAxis.cxx:731
TObjArray
Definition: TObjArray.h:37
TH2C::~TH2C
virtual ~TH2C()
Destructor.
Definition: TH2.cxx:2717
TH2::SetShowProjectionX
virtual void SetShowProjectionX(Int_t nbins=1)
When the mouse is moved in a pad containing a 2-d view of this histogram a second canvas shows the pr...
Definition: TH2.cxx:2497
f
#define f(i)
Definition: RSha256.hxx:122
operator+
TH2C operator+(TH2C &h1, TH2C &h2)
Operator +.
Definition: TH2.cxx:2905
TH2::GetStats
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: TH2.cxx:1129
TH2C::operator=
TH2C & operator=(const TH2C &h1)
Operator =.
Definition: TH2.cxx:2883
TMath::Max
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
TH2::fTsumwy2
Double_t fTsumwy2
Definition: TH2.h:35
TH2::ShowPeaks
virtual Int_t ShowPeaks(Double_t sigma=2, Option_t *option="", Double_t threshold=0.05)
Interface to TSpectrum2::Search the function finds peaks in this histogram where the width is > sigma...
Definition: TH2.cxx:2541
TH2C::AddBinContent
virtual void AddBinContent(Int_t bin)
Increment bin content by 1.
Definition: TH2.cxx:2796
TH2::GetCovariance
virtual Double_t GetCovariance(Int_t axis1=1, Int_t axis2=2) const
Return covariance between axis1 and axis2.
Definition: TH2.cxx:1044
TMath::QuietNaN
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754
Definition: TMath.h:903
TH2::Interpolate
virtual Double_t Interpolate(Double_t x) const
illegal for a TH2
Definition: TH2.cxx:1224
TH2::GetBinContent
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH2.h:88
TH2F
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:251
TH2::BufferEmpty
virtual Int_t BufferEmpty(Int_t action=0)
Fill histogram with all entries in the buffer.
Definition: TH2.cxx:179
TF1::Integral
virtual Double_t Integral(Double_t a, Double_t b, Double_t epsrel=1.e-12)
IntegralOneDim or analytical integral.
Definition: TF1.cxx:2523
TF1::GetParameters
virtual Double_t * GetParameters() const
Definition: TF1.h:516
TH1::fEntries
Double_t fEntries
Number of entries.
Definition: TH1.h:93
TMath::KolmogorovProb
Double_t KolmogorovProb(Double_t z)
Calculates the Kolmogorov distribution function,.
Definition: TMath.cxx:656
TString::Data
const char * Data() const
Definition: TString.h:369
TH2D::TH2D
TH2D()
Constructor.
Definition: TH2.cxx:3698
TAttAxis::SetAxisColor
virtual void SetAxisColor(Color_t color=1, Float_t alpha=1.)
Set color of the line axis and tick marks.
Definition: TAttAxis.cxx:162
TH1::Divide
virtual Bool_t Divide(TF1 *f1, Double_t c1=1)
Performs the operation: this = this/(c1*f1) if errors are defined (see TH1::Sumw2),...
Definition: TH1.cxx:2752
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
Form
char * Form(const char *fmt,...)
TNamed::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:54
TObjString.h
TH1::GetPainter
TVirtualHistPainter * GetPainter(Option_t *option="")
Return pointer to painter.
Definition: TH1.cxx:4367
TH2::PutStats
virtual void PutStats(Double_t *stats)
Replace current statistics with the values in array stats.
Definition: TH2.cxx:2349
TH1::SetBuffer
virtual void SetBuffer(Int_t buffersize, Option_t *option="")
Set the maximum number of entries to be kept in the buffer.
Definition: TH1.cxx:7921
TBuffer::ReadClassBuffer
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
TF1::GetNpar
virtual Int_t GetNpar() const
Definition: TF1.h:477
TH1::fTsumw
Double_t fTsumw
Total Sum of weights.
Definition: TH1.h:94
xmax
float xmax
Definition: THbookFile.cxx:95
TAttAxis::SetLabelOffset
virtual void SetLabelOffset(Float_t offset=0.005)
Set distance between the axis and the labels.
Definition: TAttAxis.cxx:192
TObject::Info
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:864
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TMath::Log
Double_t Log(Double_t x)
Definition: TMath.h:762
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:890
TMath::Gaus
Double_t Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE)
Calculate a gaussian function with mean and sigma.
Definition: TMath.cxx:448
TArrayC::Set
void Set(Int_t n)
Set size of this array to n chars.
Definition: TArrayC.cxx:105
TH1::fBufferSize
Int_t fBufferSize
fBuffer size
Definition: TH1.h:105
TMath::Sqrt
Double_t Sqrt(Double_t x)
Definition: TMath.h:693
TCollection::SetOwner
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
Definition: TCollection.cxx:746
TAttAxis::GetLabelSize
virtual Float_t GetLabelSize() const
Definition: TAttAxis.h:47
TH1D
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:615
TH1::SetBins
virtual void SetBins(Int_t nx, Double_t xmin, Double_t xmax)
Redefine x axis parameters.
Definition: TH1.cxx:8222
TH2::ProfileY
TProfile * ProfileY(const char *name="_pfy", Int_t firstxbin=1, Int_t lastxbin=-1, Option_t *option="") const
Project a 2-D histogram into a profile histogram along Y.
Definition: TH2.cxx:2024
TH1::kIsNotW
@ kIsNotW
Histogram is forced to be not weighted even when the histogram is filled with weighted different than...
Definition: TH1.h:168
TAxis::GetFirst
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition: TAxis.cxx:458
TVirtualHistPainter.h
TRandom.h
TH2::QuantilesY
TH1D * QuantilesY(Double_t prob=0.5, const char *name="_qy") const
Compute the Y distribution of quantiles in the other variable X name is the name of the returned hist...
Definition: TH2.cxx:2382
Float_t
float Float_t
Definition: RtypesCore.h:57
TH2::FillN
virtual void FillN(Int_t, const Double_t *, const Double_t *, Int_t)
Fill this histogram with an array x and weights w.
Definition: TH2.h:80
TVirtualPad::cd
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
TH2::GetBinWithContent2
virtual Double_t GetBinWithContent2(Double_t c, Int_t &binx, Int_t &biny, Int_t firstxbin=1, Int_t lastxbin=-1, Int_t firstybin=1, Int_t lastybin=-1, Double_t maxdiff=0) const
compute first cell (binx,biny) in the range [firstxbin,lastxbin][firstybin,lastybin] for which diff =...
Definition: TH2.cxx:998
TF1::GetNumberFitPoints
virtual Int_t GetNumberFitPoints() const
Definition: TF1.h:499
Int_t
int Int_t
Definition: RtypesCore.h:45
TAxis::GetBinCenter
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Definition: TAxis.cxx:478
TH1::GetBinError
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
Definition: TH1.cxx:8518
TH2::DoProjection
virtual TH1D * DoProjection(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const
Internal (protected) method for performing projection on the X or Y axis called by ProjectionX or Pro...
Definition: TH2.cxx:2034
TArrayI::fArray
Int_t * fArray
Definition: TArrayI.h:36
TH1::fBuffer
Double_t * fBuffer
[fBufferSize] entry buffer
Definition: TH1.h:106
TH1::kNstat
@ kNstat
Definition: TH1.h:180
TAxis::GetBinUpEdge
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition: TAxis.cxx:528
TArrayC::fArray
Char_t * fArray
Definition: TArrayC.h:36
TH1::GetEntries
virtual Double_t GetEntries() const
Return the current number of entries.
Definition: TH1.cxx:4301
TString::Contains
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:624
TH2::ProjectionY
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.
Definition: TH2.cxx:2340
TH1::SetBinContent
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
Definition: TH1.cxx:8677
TH2F::~TH2F
virtual ~TH2F()
Destructor.
Definition: TH2.cxx:3444
TArrayS::fArray
Short_t * fArray
Definition: TArrayS.h:36
x
Double_t x[n]
Definition: legend1.C:17
TAttAxis::GetAxisColor
virtual Color_t GetAxisColor() const
Definition: TAttAxis.h:43
TH2::DoFitSlices
virtual void DoFitSlices(bool onX, TF1 *f1, Int_t firstbin, Int_t lastbin, Int_t cut, Option_t *option, TObjArray *arr)
Definition: TH2.cxx:695
TClass.h
nentries
int nentries
Definition: THbookFile.cxx:91
TH2S::~TH2S
virtual ~TH2S()
Destructor.
Definition: TH2.cxx:2971
TH2F::SetBinsLength
virtual void SetBinsLength(Int_t n=-1)
Set total number of bins including under/overflow Reallocate bin contents array.
Definition: TH2.cxx:3562
TH1::Add
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),...
Definition: TH1.cxx:777
TMath::Abs
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
TBuffer
Definition: TBuffer.h:43
TH1::fNcells
Int_t fNcells
number of bins(1D), cells (2D) +U/Overflows
Definition: TH1.h:87
TArray::fN
Int_t fN
Definition: TArray.h:38
TMath::Prob
Double_t Prob(Double_t chi2, Int_t ndf)
Computation of the probability for a certain Chi-squared (chi2) and number of degrees of freedom (ndf...
Definition: TMath.cxx:614
TString::Format
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:2311
TH1::SetName
virtual void SetName(const char *name)
Change the name of this histogram.
Definition: TH1.cxx:8415
TH1::fDimension
Int_t fDimension
!Histogram dimension (1, 2 or 3 dim)
Definition: TH1.h:108
TProfile.h
TH1::ResetStats
virtual void ResetStats()
Reset the statistics including the number of entries and replace with values calculates from bin cont...
Definition: TH1.cxx:7410
TBuffer::CheckByteCount
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
TString
Definition: TString.h:136
TH2I::SetBinsLength
virtual void SetBinsLength(Int_t n=-1)
Set total number of bins including under/overflow Reallocate bin contents array.
Definition: TH2.cxx:3345
TAttAxis::GetLabelOffset
virtual Float_t GetLabelOffset() const
Definition: TAttAxis.h:46
operator-
TH2C operator-(TH2C &h1, TH2C &h2)
Operator -.
Definition: TH2.cxx:2917
TAxis::ImportAttributes
virtual void ImportAttributes(const TAxis *axis)
Copy axis attributes to this.
Definition: TAxis.cxx:631
TH2S
2-D histogram with a short per channel (see TH1 documentation)
Definition: TH2.h:173
TH1::fPainter
TVirtualHistPainter * fPainter
!pointer to histogram painter
Definition: TH1.h:110
TArrayF
Definition: TArrayF.h:27
TH2::~TH2
virtual ~TH2()
Destructor.
Definition: TH2.cxx:166
Color_t
short Color_t
Definition: RtypesCore.h:83
TObject::InheritsFrom
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:445
TH2::ProfileX
TProfile * ProfileX(const char *name="_pfx", Int_t firstybin=1, Int_t lastybin=-1, Option_t *option="") const
Project a 2-D histogram into a profile histogram along X.
Definition: TH2.cxx:1974
h1
TH1F * h1
Definition: legend1.C:5
TH2::Reset
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
Definition: TH2.cxx:2464
TAttAxis::SetTitleColor
virtual void SetTitleColor(Color_t color=1)
Set color of axis title.
Definition: TAttAxis.cxx:312
TH2::Smooth
virtual void Smooth(Int_t ntimes=1, Option_t *option="")
Smooth bin contents of this 2-d histogram using kernel algorithms similar to the ones used in the ras...
Definition: TH2.cxx:2570
bool
TH2D::SetBinsLength
virtual void SetBinsLength(Int_t n=-1)
Set total number of bins including under/overflow Reallocate bin contents array.
Definition: TH2.cxx:3827
TString::ReplaceAll
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
THLimitsFinder.h
TH1::fTsumw2
Double_t fTsumw2
Total Sum of squares of weights.
Definition: TH1.h:95
TAttAxis::SetTitleSize
virtual void SetTitleSize(Float_t size=0.04)
Set size of axis title.
Definition: TAttAxis.cxx:303
TAxis::GetTitle
const char * GetTitle() const
Returns title of object.
Definition: TAxis.h:129
TObjString::String
TString & String()
Definition: TObjString.h:54
x1
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
TF1::GetRange
virtual void GetRange(Double_t *xmin, Double_t *xmax) const
Return range of a generic N-D function.
Definition: TF1.cxx:2284
TArrayI::Reset
void Reset()
Definition: TArrayI.h:53
TH1::GetDimension
virtual Int_t GetDimension() const
Definition: TH1.h:279
TROOT.h
TF1::SetParameters
virtual void SetParameters(const Double_t *params)
Definition: TF1.h:640
TH1::fgDefaultSumw2
static Bool_t fgDefaultSumw2
!flag to call TH1::Sumw2 automatically at histogram creation time
Definition: TH1.h:116
TH1::Clone
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
Definition: TH1.cxx:2664
TString::ToUpper
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1138
TObjString
Definition: TObjString.h:28
TH1::ExtendAxis
virtual void ExtendAxis(Double_t x, TAxis *axis)
Histogram is resized along axis such that x is in the axis range.
Definition: TH1.cxx:6145
TH2::FitSlicesY
virtual void FitSlicesY(TF1 *f1=0, Int_t firstxbin=0, Int_t lastxbin=-1, Int_t cut=0, Option_t *option="QNR", TObjArray *arr=0)
Project slices along Y in case of a 2-D histogram, then fit each slice with function f1 and make a hi...
Definition: TH2.cxx:962
TH2::Rebin
virtual TH2 * Rebin(Int_t ngroup=2, const char *newname="", const Double_t *xbins=0)
Override TH1::Rebin as TH2::RebinX Rebinning in variable binning as for TH1 is not allowed If a non-n...
Definition: TH2.cxx:1534
TObject::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
TH2::Rebin2D
virtual TH2 * Rebin2D(Int_t nxgroup=2, Int_t nygroup=2, const char *newname="")
Rebin this histogram grouping nxgroup/nygroup bins along the xaxis/yaxis together.
Definition: TH2.cxx:1569
TAxis::GetLabels
THashList * GetLabels() const
Definition: TAxis.h:117
TArrayC::Reset
void Reset(Char_t val=0)
Definition: TArrayC.h:53
TH2::fTsumwxy
Double_t fTsumwxy
Definition: TH2.h:36
TH2D::operator=
TH2D & operator=(const TH2D &h1)
Operator =.
Definition: TH2.cxx:3873
TH1::GetMean
virtual Double_t GetMean(Int_t axis=1) const
For axis = 1,2 or 3 returns the mean value of the histogram along X,Y or Z axis.
Definition: TH1.cxx:7085
TAttAxis::SetLabelSize
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels.
Definition: TAttAxis.cxx:203
TH1::PutStats
virtual void PutStats(Double_t *stats)
Replace current statistics with the values in array stats.
Definition: TH1.cxx:7395
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TH2::GetCorrelationFactor
virtual Double_t GetCorrelationFactor(Int_t axis1=1, Int_t axis2=2) const
Return correlation factor between axis1 and axis2.
Definition: TH2.cxx:1026
TH2::BufferFill
virtual Int_t BufferFill(Double_t x, Double_t y, Double_t w)
accumulate arguments in buffer.
Definition: TH2.cxx:253
TF2.h
TH2I::~TH2I
virtual ~TH2I()
Destructor.
Definition: TH2.cxx:3225
TH2::Integral
virtual Double_t Integral(Option_t *option="") const
Return integral of bin contents.
Definition: TH2.cxx:1188
TH2::KolmogorovTest
virtual Double_t KolmogorovTest(const TH1 *h2, Option_t *option="") const
Statistical test of compatibility in shape between THIS histogram and h2, using Kolmogorov test.
Definition: TH2.cxx:1341
TH1::GetBinContent
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH1.cxx:4906
TArrayC::Copy
void Copy(TArrayC &array) const
Definition: TArrayC.h:48
TBuffer.h
TH2I
2-D histogram with an int per channel (see TH1 documentation)}
Definition: TH2.h:212
TAxis::GetXmin
Double_t GetXmin() const
Definition: TAxis.h:133
TH2F::Copy
virtual void Copy(TObject &hnew) const
Copy.
Definition: TH2.cxx:3542
TH1::GetYaxis
TAxis * GetYaxis()
Definition: TH1.h:318
TH2::FillRandom
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
Definition: TH2.cxx:599
xmin
float xmin
Definition: THbookFile.cxx:95
THashList
Definition: THashList.h:34
TAttAxis::GetTitleColor
virtual Color_t GetTitleColor() const
Definition: TAttAxis.h:52
TH1::fIntegral
Double_t * fIntegral
!Integral of bins used by GetRandom
Definition: TH1.h:109
h
#define h(i)
Definition: RSha256.hxx:124
TH1::fgBufferSize
static Int_t fgBufferSize
!default buffer size for automatic histograms
Definition: TH1.h:113
TAttAxis::GetTickLength
virtual Float_t GetTickLength() const
Definition: TAttAxis.h:51
TH1::ComputeIntegral
virtual Double_t ComputeIntegral(Bool_t onlyPositive=false)
Compute integral (cumulative sum of bins) The result stored in fIntegral is used by the GetRandom fun...
Definition: TH1.cxx:2474
TObject::SetBit
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:696
TAxis::kAxisRange
@ kAxisRange
Definition: TAxis.h:61
TH2::QuantilesX
TH1D * QuantilesX(Double_t prob=0.5, const char *name="_qx") const
Compute the X distribution of quantiles in the other variable Y name is the name of the returned hist...
Definition: TH2.cxx:2369
TH1::SetEntries
virtual void SetEntries(Double_t n)
Definition: TH1.h:382
TVirtualHistPainter::IsInside
virtual Bool_t IsInside(Int_t x, Int_t y)=0
TAttAxis::SetTitleFont
virtual void SetTitleFont(Style_t font=62)
Set the title font.
Definition: TAttAxis.cxx:321
TMath::Floor
Double_t Floor(Double_t x)
Definition: TMath.h:705
TH1::DoIntegral
virtual Double_t DoIntegral(Int_t ix1, Int_t ix2, Int_t iy1, Int_t iy2, Int_t iz1, Int_t iz2, Double_t &err, Option_t *opt, Bool_t doerr=kFALSE) const
Internal function compute integral and optionally the error between the limits specified by the bin n...
Definition: TH1.cxx:7485
TAttAxis::GetLabelColor
virtual Color_t GetLabelColor() const
Definition: TAttAxis.h:44
TString::Remove
TString & Remove(Ssiz_t pos)
Definition: TString.h:673
THLimitsFinder::GetLimitsFinder
static THLimitsFinder * GetLimitsFinder()
Return pointer to the current finder.
Definition: THLimitsFinder.cxx:153
TBuffer::WriteClassBuffer
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
TArrayD::Set
void Set(Int_t n)
Set size of this array to n doubles.
Definition: TArrayD.cxx:106
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TF1::GetParName
virtual const char * GetParName(Int_t ipar) const
Definition: TF1.h:525
TArrayD::Copy
void Copy(TArrayD &array) const
Definition: TArrayD.h:48
TH2::ShowBackground
virtual TH1 * ShowBackground(Int_t niter=20, Option_t *option="same")
This function calculates the background spectrum in this histogram.
Definition: TH2.cxx:2525
TMatrixTBase
Definition: TMatrixDBasefwd.h:25
s1
#define s1(x)
Definition: RSha256.hxx:109
TH2D
2-D histogram with a double per channel (see TH1 documentation)}
Definition: TH2.h:292
TH1::GetBin
virtual Int_t GetBin(Int_t binx, Int_t biny=0, Int_t binz=0) const
Return Global bin number corresponding to binx,y,z.
Definition: TH1.cxx:4808
TString::First
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition: TString.cxx:499
TArrayI::Set
void Set(Int_t n)
Set size of this array to n ints.
Definition: TArrayI.cxx:105
TH1::GetNcells
virtual Int_t GetNcells() const
Definition: TH1.h:296
gDirectory
#define gDirectory
Definition: TDirectory.h:236
TArrayF::Reset
void Reset()
Definition: TArrayF.h:53
TH1::Fill
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3274
gRandom
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
TH2S::AddBinContent
virtual void AddBinContent(Int_t bin)
Increment bin content by 1.
Definition: TH2.cxx:3050
TH1::GetBinErrorSqUnchecked
virtual Double_t GetBinErrorSqUnchecked(Int_t bin) const
Definition: TH1.h:440
TArrayI::Copy
void Copy(TArrayI &array) const
Definition: TArrayI.h:48
TH2
Definition: TH2.h:30
TArrayS::Copy
void Copy(TArrayS &array) const
Definition: TArrayS.h:48
TAxis::GetLast
Int_t GetLast() const
Return last bin on the axis i.e.
Definition: TAxis.cxx:469
TH2::DoProfile
virtual TProfile * DoProfile(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const
Definition: TH2.cxx:1751
TH2::RebinY
virtual TH2 * RebinY(Int_t ngroup=2, const char *newname="")
Rebin only the Y axis see Rebin2D.
Definition: TH2.cxx:1523
TH2C::TH2C
TH2C()
Constructor.
Definition: TH2.cxx:2707
TVirtualPad.h
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TH1::SetDirectory
virtual void SetDirectory(TDirectory *dir)
By default when an histogram is created, it is added to the list of histogram objects in the current ...
Definition: TH1.cxx:8392
TH2::GetBin
virtual Int_t GetBin(Int_t binx, Int_t biny, Int_t binz=0) const
Return Global bin number corresponding to binx,y,z.
Definition: TH2.cxx:967
TRandom::Rndm
virtual Double_t Rndm()
Machine independent random number generator.
Definition: TRandom.cxx:541
y
Double_t y[n]
Definition: legend1.C:17
sqrt
double sqrt(double)
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
TH2::TH2
TH2()
Constructor.
Definition: TH2.cxx:62
TH2S::SetBinsLength
virtual void SetBinsLength(Int_t n=-1)
Set total number of bins including under/overflow Reallocate bin contents array.
Definition: TH2.cxx:3091
TH2F::TH2F
TH2F()
Constructor.
Definition: TH2.cxx:3434
Short_t
short Short_t
Definition: RtypesCore.h:39
TH2::SetShowProjectionY
virtual void SetShowProjectionY(Int_t nbins=1)
When the mouse is moved in a pad containing a 2-d view of this histogram a second canvas shows the pr...
Definition: TH2.cxx:2512
TH1::GetStatOverflowsBehaviour
Bool_t GetStatOverflowsBehaviour() const
Definition: TH1.h:149
operator/
TH2C operator/(TH2C &h1, TH2C &h2)
Operator /.
Definition: TH2.cxx:2941
TNamed::SetTitle
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
TH2.h
TVirtualHistPainter::MakeCuts
virtual Int_t MakeCuts(char *cutsopt)=0
TObject::Warning
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:876
TH1::CanExtendAllAxes
virtual Bool_t CanExtendAllAxes() const
Returns true if all axes are extendable.
Definition: TH1.cxx:6277
TBuffer::ReadVersion
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
TH1::Multiply
virtual Bool_t Multiply(TF1 *f1, Double_t c1=1)
Performs the operation:
Definition: TH1.cxx:5661
TH2::FitSlicesX
virtual void FitSlicesX(TF1 *f1=0, Int_t firstybin=0, Int_t lastybin=-1, Int_t cut=0, Option_t *option="QNR", TObjArray *arr=0)
Project slices along X in case of a 2-D histogram, then fit each slice with function f1 and make a hi...
Definition: TH2.cxx:897
TF1::SetRange
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
Definition: TF1.cxx:3540
TH2::Fill
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH2.cxx:294
TH1::GetQuantiles
virtual Int_t GetQuantiles(Int_t nprobSum, Double_t *q, const Double_t *probSum=0)
Compute Quantiles for this histogram Quantile x_q of a probability distribution Function F is defined...
Definition: TH1.cxx:4458
ymin
float ymin
Definition: THbookFile.cxx:95
TF2
Definition: TF2.h:29
TMath::BinarySearch
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Definition: TMathBase.h:278
THashList.h
TArrayC
Definition: TArrayC.h:27
TString::Index
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:639
TH1::GetStdDev
virtual Double_t GetStdDev(Int_t axis=1) const
Returns the Standard Deviation (Sigma).
Definition: TH1.cxx:7139
TProfile
Definition: TProfile.h:32
TH1::GetBinLowEdge
virtual Double_t GetBinLowEdge(Int_t bin) const
Return bin lower edge for 1D histogram.
Definition: TH1.cxx:8607
TH2S::TH2S
TH2S()
Constructor.
Definition: TH2.cxx:2961
TArrayD::Reset
void Reset()
Definition: TArrayD.h:53
TArrayD::fArray
Double_t * fArray
Definition: TArrayD.h:36
sigma
const Double_t sigma
Definition: h1analysisProxy.h:11
TAxis::SetBinLabel
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
Definition: TAxis.cxx:823
TBuffer::IsReading
Bool_t IsReading() const
Definition: TBuffer.h:86
TH2F::operator=
TH2F & operator=(const TH2F &h1)
Operator =.
Definition: TH2.cxx:3608
TAttAxis::SetLabelColor
virtual void SetLabelColor(Color_t color=1, Float_t alpha=1.)
Set color of labels.
Definition: TAttAxis.cxx:172
f1
TF1 * f1
Definition: legend1.C:11
TString::IsNull
Bool_t IsNull() const
Definition: TString.h:407
Double_t
double Double_t
Definition: RtypesCore.h:59
TF1::GetParError
virtual Double_t GetParError(Int_t ipar) const
Return value of parameter number ipar.
Definition: TF1.cxx:1931
TVirtualPad
Definition: TVirtualPad.h:50
TH2D::~TH2D
virtual ~TH2D()
Destructor.
Definition: TH2.cxx:3708
TH2I::TH2I
TH2I()
Constructor.
Definition: TH2.cxx:3215
TObjArray.h
TH1::SetBinError
virtual void SetBinError(Int_t bin, Double_t error)
Set the bin Error Note that this resets the bin eror option to be of Normal Type and for the non-empt...
Definition: TH1.cxx:8661
TH2::DoQuantiles
virtual TH1D * DoQuantiles(bool onX, const char *name, Double_t prob) const
Implementation of quantiles for x or y.
Definition: TH2.cxx:2391
TH1::FindBin
virtual Int_t FindBin(Double_t x, Double_t y=0, Double_t z=0)
Return Global bin number corresponding to x,y,z.
Definition: TH1.cxx:3595
TH2S::operator=
TH2S & operator=(const TH2S &h1)
Operator =.
Definition: TH2.cxx:3137
TH2C
2-D histogram with a byte per channel (see TH1 documentation)
Definition: TH2.h:134
TObjArray::Expand
virtual void Expand(Int_t newSize)
Expand or shrink the array to newSize elements.
Definition: TObjArray.cxx:387
TH1::fSumw2
TArrayD fSumw2
Array of sum of squares of weights.
Definition: TH1.h:102
TAttAxis::GetTitleFont
virtual Style_t GetTitleFont() const
Definition: TAttAxis.h:53
TH1::Sumw2
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
Definition: TH1.cxx:8475
TObject
Definition: TObject.h:37
TH1::fTsumwx2
Double_t fTsumwx2
Total Sum of weight*X*X.
Definition: TH1.h:97
TH1::Reset
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
Definition: TH1.cxx:6735
TH1::AddBinContent
virtual void AddBinContent(Int_t bin)
Increment bin content by 1.
Definition: TH1.cxx:1200
TH1
Definition: TH1.h:57
TH2C::Copy
virtual void Copy(TObject &hnew) const
Copy.
Definition: TH2.cxx:2817
TAttAxis::SetTickLength
virtual void SetTickLength(Float_t length=0.03)
Set tick mark length.
Definition: TAttAxis.cxx:279
name
char name[80]
Definition: TGX11.cxx:110
TH1::fXaxis
TAxis fXaxis
X axis descriptor.
Definition: TH1.h:88
TAxis::FindBin
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
Definition: TAxis.cxx:293
d
#define d(i)
Definition: RSha256.hxx:120
TAttAxis::SetNdivisions
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Definition: TAttAxis.cxx:228
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
gPad
#define gPad
Definition: TVirtualPad.h:287
TIter
Definition: TCollection.h:233
TH1F::Reset
virtual void Reset(Option_t *option="")
Reset.
Definition: TH1.cxx:9561
TAxis::FindFixBin
virtual Int_t FindFixBin(Double_t x) const
Find bin number corresponding to abscissa x.
Definition: TAxis.cxx:419
TArrayS::Set
void Set(Int_t n)
Set size of this array to n shorts.
Definition: TArrayS.cxx:105
TH1::GetNbinsY
virtual Int_t GetNbinsY() const
Definition: TH1.h:294
TH1::Fit
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
Definition: TH1.cxx:3807
TAttAxis::GetLabelFont
virtual Style_t GetLabelFont() const
Definition: TAttAxis.h:45
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:53
TArrayS::Reset
void Reset()
Definition: TArrayS.h:53
TH2::fScalefactor
Double_t fScalefactor
Definition: TH2.h:33
TAxis::GetXmax
Double_t GetXmax() const
Definition: TAxis.h:134
TAttAxis::SetTitleOffset
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
Definition: TAttAxis.cxx:293
TF1
1-Dim function class
Definition: TF1.h:212
TArrayD
Definition: TArrayD.h:27
Class
void Class()
Definition: Class.C:29
TString::ToLower
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1125
TH1::GetXaxis
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:317
TMatrixDBase.h
TH1::fTsumwx
Double_t fTsumwx
Total Sum of weight*X.
Definition: TH1.h:96
TF1::GetParameter
virtual Double_t GetParameter(Int_t ipar) const
Definition: TF1.h:508
TAxis::GetXbins
const TArrayD * GetXbins() const
Definition: TAxis.h:130
TH2I::Copy
virtual void Copy(TObject &hnew) const
Copy.
Definition: TH2.cxx:3325
Char_t
char Char_t
Definition: RtypesCore.h:33
TH2::fTsumwy
Double_t fTsumwy
Definition: TH2.h:34
TAttAxis::SetLabelFont
virtual void SetLabelFont(Style_t font=62)
Set labels' font.
Definition: TAttAxis.cxx:182
TH2S::Copy
virtual void Copy(TObject &hnew) const
Copy.
Definition: TH2.cxx:3071
TObject::ClassName
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:130
TH2C::SetBinsLength
virtual void SetBinsLength(Int_t n=-1)
Set total number of bins including under/overflow Reallocate bin contents array.
Definition: TH2.cxx:2837
TH2::IntegralAndError
virtual Double_t IntegralAndError(Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Double_t &err, Option_t *option="") const
Return integral of bin contents in range [firstxbin,lastxbin],[firstybin,lastybin] for a 2-D histogra...
Definition: TH2.cxx:1216
TF1::GetChisquare
Double_t GetChisquare() const
Definition: TF1.h:440
TH2C::Reset
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
Definition: TH2.cxx:2826
TH2::RebinX
virtual TH2 * RebinX(Int_t ngroup=2, const char *newname="")
Rebin only the X axis see Rebin2D.
Definition: TH2.cxx:1513
TH1::Scale
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
Definition: TH1.cxx:6245
TAttAxis::GetNdivisions
virtual Int_t GetNdivisions() const
Definition: TAttAxis.h:42
TAttAxis::GetTitleSize
virtual Float_t GetTitleSize() const
Definition: TAttAxis.h:50
TAxis::GetNbins
Int_t GetNbins() const
Definition: TAxis.h:121
TH1::GetEffectiveEntries
virtual Double_t GetEffectiveEntries() const
Number of effective entries of the histogram.
Definition: TH1.cxx:4326
TH1::Paint
virtual void Paint(Option_t *option="")
Control routine to paint any kind of histograms.
Definition: TH1.cxx:5836
TH2::SetBinContent
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content.
Definition: TH2.cxx:2480
TAxis::GetBinWidth
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
Definition: TAxis.cxx:540
TArray::GetSize
Int_t GetSize() const
Definition: TArray.h:47
TMath.h
TArrayI
Definition: TArrayI.h:27
TH1::GetNbinsX
virtual Int_t GetNbinsX() const
Definition: TH1.h:293
gROOT
#define gROOT
Definition: TROOT.h:406
int
TH1::Draw
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2997
TError.h
c1
return c1
Definition: legend1.C:41
operator*
TH2C operator*(Float_t c1, TH2C &h1)
Operator *.
Definition: TH2.cxx:2893
TArrayF::Set
void Set(Int_t n)
Set size of this array to n floats.
Definition: TArrayF.cxx:105
TAttAxis::GetTitleOffset
virtual Float_t GetTitleOffset() const
Definition: TAttAxis.h:49