AmpTools
MIFunctionContribution.cc
Go to the documentation of this file.
1 
2 // This file is a part of MinuitInterface - a front end for the Minuit minimization
3 // package (Minuit itself was authored by Fred James, of CERN)
4 //
5 //
6 // Copyright Cornell University 1993, 1996, All Rights Reserved.
7 //
8 // This software written by Lawrence Gibbons, Cornell University.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions
12 // are met:
13 // 1. Redistributions of source code must retain the above copyright
14 // notice and author attribution, this list of conditions and the
15 // following disclaimer.
16 // 2. Redistributions in binary form must reproduce the above copyright
17 // notice and author attribution, this list of conditions and the
18 // following disclaimer in the documentation and/or other materials
19 // provided with the distribution.
20 // 3. Neither the name of the University nor the names of its contributors
21 // may be used to endorse or promote products derived from this software
22 // without specific prior written permission.
23 //
24 // Creation of derivative forms of this software for commercial
25 // utilization may be subject to restriction; written permission may be
26 // obtained from Cornell University.
27 //
28 // CORNELL MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. By way
29 // of example, but not limitation, CORNELL MAKES NO REPRESENTATIONS OR
30 // WARRANTIES OF MERCANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
31 // THE USE OF THIS SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS,
32 // COPYRIGHTS, TRADEMARKS, OR OTHER RIGHTS. Cornell University shall not be
33 // held liable for any liability with respect to any claim by the user or any
34 // other party arising from use of the program.
35 //
36 
39 
41  MIObserver(),
42  m_manager( aManager ),
43  m_functionEvaluated( false ),
44  m_contribution( 0 ),
45  m_contributing( true )
46 {
47  if( m_manager != NULL ) m_manager->attach( this );
48 }
49 
51 
52  if( m_manager != NULL ) m_manager->detach( this );
53 }
54 
55 void
56 MIFunctionContribution::update( const MISubject* callingSubject ) {
57  m_contribution = operator()();
58  m_functionEvaluated = true;
59 }
60 
61 double
63  if ( ! m_functionEvaluated ) {update(m_manager);}
64  return m_contribution;
65 }
66 
67 // default unkown derviative -- can be overriden by user
68 double
70 
71  return kUnknownDerivative;
72 }
73 
74 
75 // this value is the same as fUndefi in the URMinuit class
76 // when derivatives cannot be computed it should be returned
77 const double MIFunctionContribution::kUnknownDerivative = -54321;
virtual void update(const MISubject *)
#define NULL
Definition: URtypes.h:72
virtual double derivative(const MinuitParameter &par)
static const double kUnknownDerivative
void attach(MIObserver *)
Definition: MISubject.cc:48
void detach(MIObserver *)
Definition: MISubject.cc:54
virtual double operator()()=0
MIFunctionContribution(MinuitMinimizationManager *)