laura is hosted by Hepforge, IPPP Durham
Laura++  v2r0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
Lau2DAbsHistDP.cc
Go to the documentation of this file.
1 
2 // Copyright University of Warwick 2004 - 2013.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 // Authors:
7 // Thomas Latham
8 // John Back
9 // Paul Harrison
10 
15 #include <iostream>
16 
17 #include "TAxis.h"
18 #include "TH2.h"
19 #include "TRandom.h"
20 #include "TSystem.h"
21 
22 #include "Lau2DAbsHistDP.hh"
23 #include "LauDaughters.hh"
24 #include "LauKinematics.hh"
25 #include "LauRandom.hh"
26 
27 ClassImp(Lau2DAbsHistDP)
28 
29 
30 Lau2DAbsHistDP::Lau2DAbsHistDP(const LauDaughters* daughters, Bool_t useUpperHalfOnly, Bool_t squareDP) :
31  kinematics_( (daughters!=0) ? daughters->getKinematics() : 0 ),
32  upperHalf_(useUpperHalfOnly),
33  squareDP_(squareDP)
34 {
35 }
36 
38 {
39 }
40 
42 {
43  TRandom* random = LauRandom::zeroSeedRandom();
44 
45  Int_t nBinsX = static_cast<Int_t>(hist->GetNbinsX());
46  Int_t nBinsY = static_cast<Int_t>(hist->GetNbinsY());
47 
48  for (Int_t i(0); i<nBinsX; ++i) {
49  for (Int_t j(0); j<nBinsY; ++j) {
50  Double_t currentContent = hist->GetBinContent(i+1,j+1);
51  Double_t currentError = hist->GetBinError(i+1,j+1);
52  Double_t newContent = random->Gaus(currentContent,currentError);
53  if (newContent<0.0) {
54  hist->SetBinContent(i+1,j+1,0.0);
55  } else {
56  hist->SetBinContent(i+1,j+1,newContent);
57  }
58  }
59  }
60 }
61 
62 void Lau2DAbsHistDP::raiseOrLowerBins(TH2* hist, Double_t avEff, Double_t avEffError)
63 {
64  TRandom* random = LauRandom::zeroSeedRandom();
65 
66  Double_t curAvg = this->computeAverageContents(hist);
67  Double_t newAvg = random->Gaus(avEff,avEffError);
68 
69  hist->Scale( newAvg / curAvg );
70 }
71 
72 Double_t Lau2DAbsHistDP::computeAverageContents(TH2 const * const hist) const
73 {
74  Double_t totalContent(0.0);
75  Int_t binsWithinDPBoundary(0);
76 
77  Int_t nBinsX = static_cast<Int_t>(hist->GetNbinsX());
78  Int_t nBinsY = static_cast<Int_t>(hist->GetNbinsY());
79 
80  // Loop through the bins and include any that have their centre or any
81  // of the four corners within the kinematic boundary
82  for ( Int_t i(0); i<nBinsX; ++i ) {
83  Double_t binXCentre = hist->GetXaxis()->GetBinCenter(i+1);
84  Double_t binXLowerEdge = hist->GetXaxis()->GetBinLowEdge(i+1);
85  Double_t binXUpperEdge = hist->GetXaxis()->GetBinUpEdge(i+1);
86 
87  for ( Int_t j(0); j<nBinsY; ++j ) {
88  Double_t binYCentre = hist->GetYaxis()->GetBinCenter(i+1);
89  Double_t binYLowerEdge = hist->GetYaxis()->GetBinLowEdge(i+1);
90  Double_t binYUpperEdge = hist->GetYaxis()->GetBinUpEdge(i+1);
91 
92  if ( withinDPBoundaries( binXCentre, binYCentre ) ||
93  withinDPBoundaries( binXLowerEdge, binYLowerEdge ) ||
94  withinDPBoundaries( binXUpperEdge, binYUpperEdge ) ||
95  withinDPBoundaries( binXLowerEdge, binYUpperEdge ) ||
96  withinDPBoundaries( binXUpperEdge, binYLowerEdge ) ) {
97 
98  totalContent += hist->GetBinContent(i+1, j+1);
99  ++binsWithinDPBoundary;
100  }
101  }
102  }
103 
104  return totalContent/binsWithinDPBoundary;
105 }
106 
107 Bool_t Lau2DAbsHistDP::withinDPBoundaries(Double_t x, Double_t y) const
108 {
110 }
111 
112 void Lau2DAbsHistDP::getUpperHalf(Double_t& x, Double_t& y) const
113 {
114  if ( upperHalf_ == kTRUE ) {
115  if ( squareDP_ == kFALSE && x > y ) {
116  Double_t temp = y;
117  y = x;
118  x = temp;
119  } else if ( squareDP_ == kTRUE && y > 0.5 ) {
120  y = 1.0 - y;
121  }
122  }
123 }
TRandom * zeroSeedRandom()
Access the singleton random number generator with seed set from machine clock time (within +-1 sec)...
Definition: LauRandom.cc:30
Double_t computeAverageContents(TH2 const *const hist) const
Compute the average bin content for bins within the kinematic boundary.
void doBinFluctuation(TH2 *hist)
Fluctuate the contents of each histogram bin independently, in accordance with their errors...
Class that defines the particular 3-body decay under study.
Definition: LauDaughters.hh:33
File containing declaration of LauDaughters class.
File containing declaration of LauKinematics class.
Abstract base class for defining a variation across a 2D DP based on a histogram. ...
Bool_t withinSqDPLimits(Double_t mPrime, Double_t thetaPrime) const
Check whether a given (m&#39;,theta&#39;) point is within the kinematic limits of the Dalitz plot...
Bool_t withinDPBoundaries(Double_t x, Double_t y) const
Check whether the given co-ordinates are within the kinematic boundary.
virtual ~Lau2DAbsHistDP()
Copy constructor.
Bool_t withinDPLimits(Double_t m13Sq, Double_t m23Sq) const
Check whether a given (m13Sq,m23Sq) point is within the kinematic limits of the Dalitz plot...
File containing LauRandom namespace.
void raiseOrLowerBins(TH2 *hist, Double_t avEff, Double_t avEffError)
Rescale the histogram bin contents based on the desired average efficiency and its uncertainty...
Bool_t squareDP_
Boolean for using square DP variables.
const LauKinematics * kinematics_
Kinematics used to check events are within DP boundary.
File containing declaration of Lau2DAbsHistDP class.
Bool_t upperHalf_
Boolean for using the upper half of DP.
void getUpperHalf(Double_t &x, Double_t &y) const
If only using the upper half of the (symmetric) DP then transform into the correct half...