AmpTools
LikelihoodCalculator.h
Go to the documentation of this file.
1 #if !defined(LIKELIHOODCALCULATOR)
2 #define LIKELIHOODCALCULATOR
3 
4 //******************************************************************************
5 // This file is part of AmpTools, a package for performing Amplitude Analysis
6 //
7 // Copyright Trustees of Indiana University 2010, all rights reserved
8 //
9 // This software written by Matthew Shepherd, Ryan Mitchell, and
10 // Hrayr Matevosyan at Indiana University, Bloomington
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions
14 // are met:
15 // 1. Redistributions of source code must retain the above copyright
16 // notice and author attribution, this list of conditions and the
17 // following disclaimer.
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice and author attribution, this list of conditions and the
20 // following disclaimer in the documentation and/or other materials
21 // provided with the distribution.
22 // 3. Neither the name of the University nor the names of its contributors
23 // may be used to endorse or promote products derived from this software
24 // without specific prior written permission.
25 //
26 // Creation of derivative forms of this software for commercial
27 // utilization may be subject to restriction; written permission may be
28 // obtained from the Trustees of Indiana University.
29 //
30 // INDIANA UNIVERSITY AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES,
31 // EXPRESS OR IMPLIED. By way of example, but not limitation, INDIANA
32 // UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCANTABILITY OR
33 // FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THIS SOFTWARE OR
34 // DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS,
35 // OR OTHER RIGHTS. Neither Indiana University nor the authors shall be
36 // held liable for any liability with respect to any claim by the user or
37 // any other party arising from use of the program.
38 //******************************************************************************
39 
40 #include <string>
41 
42 #include "IUAmpTools/AmpVecs.h"
44 
46 
47 class NormIntInterface;
48 class ParameterManager;
49 class DataReader;
51 class MinuitParameter;
52 
67 using namespace std;
68 
70 {
71 
72 public:
73 
74  LikelihoodCalculator( const IntensityManager& intenManager,
75  const NormIntInterface& normInt,
76  DataReader* dataReaderSignal,
77  DataReader* dataReaderBkgnd,
78  const ParameterManager& parManager );
79 
80  virtual ~LikelihoodCalculator();
81 
82  string reactionName() const { return m_intenManager.reactionName(); }
83 
84  // this method delivers the likelihood
85  double operator()();
86 
87 protected:
88 
89  // helper functions -- also useful for pulling parts of the
90  // likelihood calculation in parallel implementations
91  double dataTerm();
92  double normIntTerm();
93 
94  // these are useful for MPI implementations since there are a
95  // few sums that must be maintained across all processes to properly
96  // compute the normalization integral terms of the likelihood
97 
98  double sumBkgWeights() const { return m_sumBkgWeights; }
99  double numBkgEvents() const { return m_numBkgEvents; }
100  double numDataEvents() const { return m_numDataEvents; }
101 
102  void setSumBkgWeights( double sum ) { m_sumBkgWeights = sum; }
103  void setNumBkgEvents ( double num ) { m_numBkgEvents = num; }
104  void setNumDataEvents( double num ) { m_numDataEvents = num; }
105 
106 private:
107 
108  bool m_hasBackground;
109 
110  const IntensityManager& m_intenManager;
111  const NormIntInterface& m_normInt;
112 
113  DataReader* m_dataReaderSignal;
114  DataReader* m_dataReaderBkgnd;
115 
116  bool m_firstNormIntCalc;
117  bool m_firstDataCalc;
118 
119  double* m_prodFactorArray;
120  const double* m_normIntArray;
121  const double* m_ampIntArray;
122 
123  // The flat array of kinematics and amplitudes
124  AmpVecs m_ampVecsSignal;
125  AmpVecs m_ampVecsBkgnd;
126 
127  double m_sumBkgWeights;
128  double m_numBkgEvents;
129  double m_numDataEvents;
130 };
131 
132 #endif
void setNumBkgEvents(double num)
void setSumBkgWeights(double sum)
void setNumDataEvents(double num)
double sumBkgWeights() const