laura is hosted by Hepforge, IPPP Durham
Laura++  3.6.0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauWeightedSumEffModel.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 
30 
31 #include "Lau2DHistDP.hh"
32 #include "Lau2DSplineDP.hh"
33 #include "LauDaughters.hh"
34 #include "LauKinematics.hh"
35 #include "LauVetoes.hh"
36 
37 #include "TSystem.h"
38 
39 #include <cstdlib>
40 #include <iostream>
41 
43  daughters_( daughters ),
44  effModel_( 0 ),
45  fluctuateEffHisto_( kFALSE ),
46  lowBinWarningIssued_( kFALSE ),
47  highBinWarningIssued_( kFALSE )
48 {
49  if ( daughters_ == 0 ) {
50  std::cerr << "ERROR in LauWeightedSumEffModel Constructor : invalid pointer to daughters object supplied."
51  << std::endl;
52  gSystem->Exit( EXIT_FAILURE );
53  }
54 }
55 
56 void LauWeightedSumEffModel::addEffModel( const LauAbsEffModel* effModel, Double_t coeff )
57 {
58  const LauDaughters* otherDaughters = effModel->getDaughters();
59  if ( otherDaughters->getTypeDaug1() != daughters_->getTypeDaug1() ||
60  otherDaughters->getTypeDaug2() != daughters_->getTypeDaug2() ||
61  otherDaughters->getTypeDaug3() != daughters_->getTypeDaug3() ||
62  otherDaughters->getTypeParent() != daughters_->getTypeParent() ) {
63  std::cerr << "ERROR in LauWeightedSumEffModel::addEffModel : daughters of provided efficiency model do not match those expected."
64  << std::endl;
65  gSystem->Exit( EXIT_FAILURE );
66  }
67 
68  effModel_.push_back( effModel );
69  coeff_.push_back( coeff );
70 
71  if ( effModel->fluctuateEffHisto() ) {
72  fluctuateEffHisto_ = kTRUE;
73  }
74 }
75 
76 Double_t LauWeightedSumEffModel::calcEfficiency( const LauKinematics* kinematics ) const
77 {
78  // Routine to calculate the efficiency for the given event/point in
79  // the Dalitz plot. This routine uses the models set by the
80  // addEffModel() function.
81  Double_t eff( 0.0 );
82 
83  std::vector<const LauAbsEffModel*>::const_iterator it = effModel_.begin();
84  std::vector<const LauAbsEffModel*>::const_iterator end = effModel_.end();
85 
86  std::vector<Double_t>::const_iterator coeffIt = coeff_.begin();
87 
88  for ( ; it != end; ++it ) {
89  eff += ( *coeffIt ) * ( *it )->calcEfficiency( kinematics );
90  ++coeffIt;
91  }
92 
93  // Check that the efficiency is in the allowed range (0-1)
94  // Out of range efficiencies could be caused by incorrect coefficients.
95  if ( eff < 0.0 ) {
96  if ( ! lowBinWarningIssued_ ) {
97  std::cerr << "WARNING in LauWeightedSumEffModel::calcEfficiency : Efficiency " << eff
98  << " is less than 0 - setting to 0. You may want to check your coefficients!"
99  << std::endl
100  << " : Further warnings will be suppressed."
101  << std::endl;
102  lowBinWarningIssued_ = kTRUE;
103  }
104  eff = 0.0;
105  } else if ( eff > 1.0 ) {
106  if ( ! highBinWarningIssued_ ) {
107  std::cerr << "WARNING in LauWeightedSumEffModel::calcEfficiency : Efficiency " << eff
108  << " is greater than 1 - setting to 1. You may want to check your coefficients!"
109  << std::endl
110  << " : Further warnings will be suppressed."
111  << std::endl;
112  highBinWarningIssued_ = kTRUE;
113  }
114  eff = 1.0;
115  }
116 
117  return eff;
118 }
119 
120 Bool_t LauWeightedSumEffModel::passVeto( const LauKinematics* kinematics ) const
121 {
122  std::vector<const LauAbsEffModel*>::const_iterator it = effModel_.begin();
123  std::vector<const LauAbsEffModel*>::const_iterator end = effModel_.end();
124 
125  for ( ; it != end; ++it ) {
126  if ( ! ( *it )->passVeto( kinematics ) )
127  return kFALSE;
128  }
129  return kTRUE;
130 }
std::vector< Double_t > coeff_
The efficiency model objects.
virtual const LauDaughters * getDaughters() const =0
Return the daughters object.
virtual Bool_t fluctuateEffHisto() const =0
Determine whether the efficiency histogram has had its bins fluctuated within their errors.
Int_t getTypeDaug2() const
Get PDG code of the second daughter particle.
File containing declaration of Lau2DHistDP class.
Int_t getTypeParent() const
Get PDG code of the parent particle.
LauWeightedSumEffModel(const LauDaughters *daughters)
Constructor.
Bool_t highBinWarningIssued_
Flag to track whether a warning has been issued for bin values greater than one.
Bool_t fluctuateEffHisto_
Fluctuate histogram within the error.
std::vector< const LauAbsEffModel * > effModel_
The efficiency model objects.
File containing declaration of LauDaughters class.
Bool_t lowBinWarningIssued_
Flag to track whether a warning has been issued for bin values less than zero.
Double_t calcEfficiency(const LauKinematics *kinematics) const
Determine the efficiency for a given point in the Dalitz plot.
void addEffModel(const LauAbsEffModel *effModel, Double_t coeff)
Add an efficiency variation across the phase space using a predetermined LauAbsEffModel object.
Bool_t passVeto(const LauKinematics *kinematics) const
Determine whether the given DP position is outside the vetoes.
const LauDaughters * daughters_
The daughters object.
File containing declaration of Lau2DSplineDP class.
Class for calculating 3-body kinematic quantities.
Pure abstract base class for defining the efficiency description across the signal Dalitz plot.
File containing declaration of LauVetoes class.
Int_t getTypeDaug1() const
Get PDG code of the first daughter particle.
Class that defines the particular 3-body decay under study.
Definition: LauDaughters.hh:47
File containing declaration of LauWeightedSumEffModel class.
Int_t getTypeDaug3() const
Get PDG code of the third daughter particle.
File containing declaration of LauKinematics class.