AmpTools
ParameterManager.h
Go to the documentation of this file.
1 #if !defined( PARAMETERMANAGER )
2 #define PARAMETERMANAGER
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 <map>
41 #include <vector>
42 #include <string>
43 
50 
51 class ConfigurationInfo;
52 class ParameterInfo;
53 
55 {
56 
57 public:
58 
59  // any negative integer -- used note fixed parameters
60  // in an array of indices
61  enum { kFixedIndex = -1 };
62 
64  IntensityManager* intenManager );
65 
67  const vector<IntensityManager*>& intenManagers );
68 
70 
71  MinuitMinimizationManager* fitManager() const { return m_minuitManager; }
72 
74 
75  // these functions provide a list of all known parameters, including those that are
76  // constrained to other parameters in addition to a covariance matrix that
77  // incorporates those constraints
78 
79  vector< double > parameterValues() const { return m_parValues; }
80  vector< string > parameterList() const { return m_parList; }
81  map< string, int > parameterIndex() const { return m_parIndex; }
82  vector< vector< double > > covarianceMatrix() const { return m_covMatrix; }
83 
84  bool hasConstraints(const string& ampName) const;
85  bool hasParameter(const string& ampName) const;
86 
87  // this gets called whenever an amplitude parameter changes
88  void update( const MISubject* parPtr );
89 
90 protected:
91 
92  // MPI implementations on the worker nodes need to be able
93  // to create a ParameterManager without attaching it to
94  // a MinuitMinimizationManager - no one else should be using
95  // these constructors. Use of these constructors requires
96  // overriding the other functions below to avoid dereferencing
97  // a null pointer to the MinuitMinimizationManager.
98 
99  ParameterManager( IntensityManager* intenManager );
100  ParameterManager( const vector<IntensityManager*>& intenManager );
101 
102  // these functions need to be virtual so that parallel implementations
103  // can override their functionality correctly since they are called
104  // from within setupFromConfigurationInfo
105 
106  virtual void addProductionParameter( const string& ampName, bool real = false, bool fixed = false );
107  virtual void addAmplitudeParameter( const string& ampName, const ParameterInfo* parInfo );
108 
109  // useful for MPI implementations of ParameterManager
110  complex< double >* getProdParPtr( const string& ampName );
111  double* getAmpParPtr( const string& parName );
112 
113  virtual void update( const string& parName );
114 
115  private:
116 
117  // stop default and copy
120 
121  ComplexParameter* findParameter(const string& ampName) const;
122  void updateParCovariance();
123 
124  MinuitMinimizationManager* m_minuitManager;
125 
126  vector< IntensityManager* > m_intenManagers;
127 
128  vector< double > m_parValues;
129  vector< string > m_parList;
130  map< string, int > m_parIndex;
131  vector< vector< double > > m_covMatrix;
132 
133  map< string, ComplexParameter* > m_prodParams;
134  vector< ComplexParameter* > m_prodPtrCache;
135 
136  map< string, MinuitParameter* > m_ampParams;
137  vector< MinuitParameter* > m_ampPtrCache;
138 
139  vector< GaussianBound* > m_boundPtrCache;
140 
141  map <string, vector<string> > m_constraintMap;
142 };
143 
144 #endif
double * getAmpParPtr(const string &parName)
void setupFromConfigurationInfo(ConfigurationInfo *cfgInfo)
bool hasConstraints(const string &ampName) const
vector< vector< double > > covarianceMatrix() const
MinuitMinimizationManager * fitManager() const
map< string, int > parameterIndex() const
virtual void addAmplitudeParameter(const string &ampName, const ParameterInfo *parInfo)
vector< double > parameterValues() const
void update(const MISubject *parPtr)
virtual void addProductionParameter(const string &ampName, bool real=false, bool fixed=false)
complex< double > * getProdParPtr(const string &ampName)
bool hasParameter(const string &ampName) const
vector< string > parameterList() const