laura is hosted by Hepforge, IPPP Durham
Laura++  3.6.0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
Lau2DAbsHistDPPdf.cc
Go to the documentation of this file.
1 
2 /*
3 Copyright 2014 University of Warwick
4 
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 */
17 
18 /*
19 Laura++ package authors:
20 John Back
21 Paul Harrison
22 Thomas Latham
23 */
24 
29 #include "Lau2DAbsHistDPPdf.hh"
30 
31 #include "LauKinematics.hh"
32 #include "LauRandom.hh"
33 #include "LauVetoes.hh"
34 
35 #include "TAxis.h"
36 #include "TH2.h"
37 #include "TRandom.h"
38 
39 #include <iostream>
40 
42  const LauVetoes* vetoes,
43  Bool_t useUpperHalfOnly,
44  Bool_t squareDP ) :
45  kinematics_( kinematics ),
46  vetoes_( vetoes ),
47  upperHalf_( useUpperHalfOnly ),
48  squareDP_( squareDP )
49 {
50  if ( squareDP && ! kinematics->squareDP() ) {
51  // The histogram provided is defined in the square DP but the
52  // kinematics object has calculation of the square DP
53  // co-ordinates disabled, so need to enable it,
54  std::cerr << "WARNING in Lau2DAbsHistDPPdf constructor : forcing kinematics to calculate the required square DP co-ordinates"
55  << std::endl;
56  kinematics->squareDP( kTRUE );
57  }
58 }
59 
61 {
62 }
63 
65 {
66  // Get the maximum height of the 2D histogram
67  maxHeight_ = 1.0;
68  if ( hist ) {
69  Int_t maxBin = hist->GetMaximumBin();
70  maxHeight_ = hist->GetBinContent( maxBin );
71  }
72 
73  std::cout << "INFO in Lau2DAbsHistDPPdf::calcMaxHeight : Max height = " << maxHeight_
74  << std::endl;
75 }
76 
78 {
79  if ( ! hist ) {
80  return;
81  }
82 
83  TRandom* random = LauRandom::randomFun();
84 
85  Int_t nBinsX = static_cast<Int_t>( hist->GetNbinsX() );
86  Int_t nBinsY = static_cast<Int_t>( hist->GetNbinsY() );
87 
88  for ( Int_t i( 0 ); i < nBinsX; i++ ) {
89  for ( Int_t j( 0 ); j < nBinsY; j++ ) {
90  Double_t currentContent = hist->GetBinContent( i + 1, j + 1 );
91  Double_t currentError = hist->GetBinError( i + 1, j + 1 );
92  Double_t newContent = random->Gaus( currentContent, currentError );
93  if ( newContent < 0.0 ) {
94  hist->SetBinContent( i + 1, j + 1, 0.0 );
95  } else {
96  hist->SetBinContent( i + 1, j + 1, newContent );
97  }
98  }
99  }
100 }
101 
102 Bool_t Lau2DAbsHistDPPdf::withinDPBoundaries( Double_t x, Double_t y ) const
103 {
104  return squareDP_ ? kinematics_->withinSqDPLimits( x, y ) : kinematics_->withinDPLimits( x, y );
105 }
106 
107 void Lau2DAbsHistDPPdf::getUpperHalf( Double_t& x, Double_t& y ) const
108 {
109  if ( upperHalf_ == kTRUE ) {
110  if ( squareDP_ == kFALSE && x > y ) {
111  Double_t temp = y;
112  y = x;
113  x = temp;
114  } else if ( squareDP_ == kTRUE && y > 0.5 ) {
115  y = 1.0 - y;
116  }
117  }
118 }
119 
120 void Lau2DAbsHistDPPdf::updateKinematics( Double_t x, Double_t y ) const
121 {
122  if ( squareDP_ == kTRUE ) {
124  } else {
125  kinematics_->updateKinematics( x, y );
126  }
127 }
File containing LauRandom namespace.
void doBinFluctuation(TH2 *hist)
Fluctuate the histogram bin contents in accordance with their errors.
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.
Double_t maxHeight_
The maximum height of 2D histogram.
void updateKinematics(const Double_t m13Sq, const Double_t m23Sq)
Update all kinematic quantities based on the DP co-ordinates m13Sq and m23Sq.
Bool_t withinDPLimits(const Double_t m13Sq, const Double_t m23Sq) const
Check whether a given (m13Sq,m23Sq) point is within the kinematic limits of the Dalitz plot.
Bool_t squareDP_
Boolean for using square DP variables.
void squareDP(const Bool_t calcSquareDPCoords)
Enable/disable the calculation of square Dalitz plot co-ordinates.
TRandom * randomFun()
Access the singleton random number generator with a particular seed.
Definition: LauRandom.cc:33
Bool_t withinDPBoundaries(Double_t x, Double_t y) const
Check whether the given co-ordinates are within the kinematic boundary.
LauKinematics * kinematics_
DP kinematics.
Lau2DAbsHistDPPdf(LauKinematics *kinematics, const LauVetoes *vetoes, Bool_t useUpperHalfOnly=kFALSE, Bool_t squareDP=kFALSE)
Constructor.
void updateSqDPKinematics(const Double_t mPrime, const Double_t thetaPrime)
Update all kinematic quantities based on the square DP co-ordinates m' and theta'.
Bool_t upperHalf_
Boolean for using the upper half of DP.
Class for defining vetoes within the Dalitz plot.
Definition: LauVetoes.hh:49
virtual ~Lau2DAbsHistDPPdf()
Destructor.
Class for calculating 3-body kinematic quantities.
File containing declaration of LauVetoes class.
void updateKinematics(Double_t x, Double_t y) const
Update the current co-ordinates in the kinematic space.
File containing declaration of LauKinematics class.
void calcMaxHeight(TH2 *hist)
Calculate maximum height.
File containing declaration of Lau2DAbsHistDPPdf class.
Bool_t withinSqDPLimits(const Double_t mPrime, const Double_t thetaPrime) const
Check whether a given (m',theta') point is within the kinematic limits of the Dalitz plot.