AmpTools
FitResults.h
Go to the documentation of this file.
1 #ifndef FITRESULTS
2 #define FITRESULTS
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 
41 #include <vector>
42 #include <string>
43 #include <map>
44 #include <complex>
45 
47 class ParameterManager;
49 class IntensityManager;
50 class NormIntInterface;
51 class ConfigurationInfo;
52 
53 using namespace std;
54 
71 {
72 
73 public:
74 
93  FitResults( ConfigurationInfo* cfgInfo,
94  vector< IntensityManager* > intenManVec,
95  map< string, LikelihoodCalculator* > likCalcMap,
96  map< string, NormIntInterface* > normIntMap,
97  MinuitMinimizationManager* minManager,
98  ParameterManager* parManager );
99 
109  FitResults( const string& inFile );
110 
118  ~FitResults();
119 
126  bool valid() const { return m_isValid; }
127 
134  const NormIntInterface* normInt( const string& reactionName ) const;
135 
140  const ConfigurationInfo* configInfo() const { return m_cfgInfo; }
141 
145  double likelihood() const { return m_likelihoodTotal; }
146 
153  double likelihood( const string& reactionName ) const;
154 
163  pair< double, double > intensity( bool accCorrected = true ) const;
164 
178  pair< double, double > intensity( const vector< string >& amplitudes,
179  bool accCorrected = true ) const;
180 
189  pair< double, double > phaseDiff( const string& amp1, const string& amp2 ) const;
190 
197  string realProdParName( const string& amplitude ) const;
198 
205  string imagProdParName( const string& amplitude ) const;
206 
212  string ampScaleName( const string& amplitude ) const;
213 
219  double parValue( const string& parName ) const;
220 
226  double parError( const string& parName ) const;
227 
234  double covariance( const string& par1, const string& par2 ) const;
235 
240  map< string, complex< double > > ampProdParMap() const;
241 
246  map< string, double > ampScaleParMap() const;
247 
252  map< string, double > ampParMap() const;
253 
260  complex< double > productionParameter( const string& ampName ) const;
261 
269  complex< double > scaledProductionParameter( const string& ampName ) const;
270 
279  double ampScale( const string& ampName ) const;
280 
293  int eMatrixStatus() const { return m_eMatrixStatus; }
294 
311  int lastMinuitCommandStatus() const { return m_lastCommandStatus; }
312 
325  int lastMinuitCommand() const { return m_lastCommand; }
326 
336  double minuitPrecision() const { return m_precision; }
337 
344  int minuitStrategy() const { return m_strategy; }
345 
349  double estDistToMinimum() const { return m_estDistToMin; }
350 
354  double bestMinimum() const { return m_bestMin; }
355 
365  const vector< string >& parNameList() const { return m_parNames; }
366 
373  const vector< double >& parValueList() const { return m_parValues; }
374 
381  const vector< vector< double > >& errorMatrix() const { return m_covMatrix; }
382 
386  const vector< string >& reactionList() const { return m_reactionNames; }
387 
391  vector< string > ampList() const;
392 
398  vector< string > ampList( const string& reaction ) const;
399 
406  void saveResults();
407 
414  void writeResults( const string& fileName ) const;
415 
423  void writeSeed( const string& fileName ) const;
424 
432  void loadResults( const string& fileName );
433 
442  void rotateResults();
443  void writeFitResults( const string& fileName );
444 
445 protected:
446 
453  FitResults( const FitResults& fitResults );
454 
460  FitResults();
461 
466  FitResults& operator=( const FitResults& results );
467 
468 private:
469 
470  vector< string > stringSplit(const string& str, const string& delimiters ) const;
471 
472  void recordAmpSetup();
473  void recordLikelihood();
474  void recordFitStats();
475  void recordParameters();
476 
477  // amplitude manager info
478 
479  int m_numReactions;
480  vector< string > m_reactionNames;
481  vector< int > m_numAmps;
482  vector< vector< string > > m_ampNames;
483  vector< vector< string > > m_ampScaleNames;
484  vector< vector< double > > m_ampScaleValues;
485 
486  map< string, int > m_reacIndex;
487  vector< map< string, int > > m_ampIndex;
488 
489  // likelihood info
490 
491  map< string, double > m_likelihoodMap;
492  double m_likelihoodTotal;
493 
494  // info from the fitter
495 
496  int m_eMatrixStatus;
497  int m_lastCommandStatus;
498  int m_lastCommand;
499  double m_precision;
500  int m_strategy;
501  double m_estDistToMin;
502  double m_bestMin;
503 
504  // info about the parameters
505 
506  vector< string > m_parNames;
507  vector< double > m_parValues;
508  vector< vector< double > > m_covMatrix;
509 
510  map< string, int > m_parIndex;
511 
512  // hold pointers to the classes that are needed to fetch the results
513 
514  ConfigurationInfo* m_cfgInfo;
515  vector< IntensityManager* > m_intenManVec;
516  map< string, LikelihoodCalculator* > m_likCalcMap;
517  map< string, NormIntInterface* > m_normIntMap;
518  MinuitMinimizationManager* m_minManager;
519  ParameterManager* m_parManager;
520 
521  bool m_createdFromFile;
522  mutable bool m_warnedAboutFreeParams;
523  bool m_isValid;
524 };
525 
526 
527 #endif
const vector< string > & reactionList() const
Definition: FitResults.h:386
bool valid() const
Definition: FitResults.h:126
int lastMinuitCommand() const
Definition: FitResults.h:325
double estDistToMinimum() const
Definition: FitResults.h:349
const vector< double > & parValueList() const
Definition: FitResults.h:373
const vector< string > & parNameList() const
Definition: FitResults.h:365
double bestMinimum() const
Definition: FitResults.h:354
double likelihood() const
Definition: FitResults.h:145
int minuitStrategy() const
Definition: FitResults.h:344
int lastMinuitCommandStatus() const
Definition: FitResults.h:311
int eMatrixStatus() const
Definition: FitResults.h:293
const vector< vector< double > > & errorMatrix() const
Definition: FitResults.h:381
double minuitPrecision() const
Definition: FitResults.h:336
const ConfigurationInfo * configInfo() const
Definition: FitResults.h:140