AmpTools
ConfigurationInfo.h
Go to the documentation of this file.
1 #if !defined(CONFIGURATIONINFO)
2 #define CONFIGURATIONINFO
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 <iostream>
42 #include <utility>
43 #include <string>
44 #include <vector>
45 #include <map>
46 #include <complex>
47 #include <fstream>
48 
49 using namespace std;
50 
51 class ConfigurationInfo;
52 class ReactionInfo;
53 class CoherentSumInfo;
54 class AmplitudeInfo;
55 class ParameterInfo;
56 
57 
112 {
113 public:
114 
118  ConfigurationInfo(const string& fitName) { m_fitName = fitName; }
120 
124  string fitName() const { return m_fitName; }
125 
126 
130  string fitOutputFileName() const { return m_fitName + ".fit"; }
131 
132 
140  vector< string > userKeywords() const;
141 
150  vector< vector<string> > userKeywordArguments(const string& userKeyword) const;
151 
152 
153  // Return lists of reactions, sums, amplitudes, or parameters.
154  // (If an argument to the call is empty, it is treated as
155  // a wildcard. For example, reactionList("") returns all
156  // reactions.)
157 
169  vector<ReactionInfo*> reactionList (const string& reactionName="") const;
170 
182  vector<CoherentSumInfo*> coherentSumList (const string& reactionName="",
183  const string& sumName="") const;
184 
197  vector<AmplitudeInfo*> amplitudeList (const string& reactionName="",
198  const string& sumName="",
199  const string& ampName="") const;
200 
215  vector<ParameterInfo*> parameterList (const string& reactionName="",
216  const string& sumName="",
217  const string& ampName="",
218  const string& parName="") const;
219 
220 
221  // Return a specific reaction, sum, amplitude, or parameter.
222 
232  ReactionInfo* reaction (const string& reactionName) const;
233 
244  CoherentSumInfo* coherentSum (const string& reactionName,
245  const string& sumName) const;
246 
258  AmplitudeInfo* amplitude (const string& reactionName,
259  const string& sumName,
260  const string& ampName) const;
261 
271  ParameterInfo* parameter (const string& parName) const;
272 
273 
274 
275  // Create a new reaction, sum, amplitude or parameter.
276  // (If the object already exists, the old is replaced and
277  // its contents are cleared.)
278 
291  ReactionInfo* createReaction (const string& reactionName,
292  const vector<string>& particleList);
293 
306  CoherentSumInfo* createCoherentSum (const string& reactionName,
307  const string& sumName);
308 
323  AmplitudeInfo* createAmplitude (const string& reactionName,
324  const string& sumName,
325  const string& ampName);
326 
337  ParameterInfo* createParameter (const string& parName,
338  double value);
339 
340 
341  // Remove reactions, sums, amplitudes, or parameters.
342  // (Blank arguments are treated like wildcards.
343  // This also removes associated objects -- for example,
344  // removeReaction("") removes all reactions but also all sums
345  // and amplitudes associated with those reactions.
346 
357  void removeReaction (const string& reactionName="");
358 
370  void removeCoherentSum (const string& reactionName="",
371  const string& sumName="");
372 
385  void removeAmplitude (const string& reactionName="",
386  const string& sumName="",
387  const string& ampName="");
388 
399  void removeParameter (const string& parName="");
400 
401 
405  void setFitName (const string& fitName) { m_fitName = fitName; }
406 
407 
416  void addUserKeyword(const string& uesrKeyword, const vector<string>& arguments);
417 
418 
427  void removeUserKeyword(const string& userKeyword="");
428 
439  void display(string fileName = "", bool append = false) const;
440  void display(string fileName = "", bool append = false);
441 
442 
450  void write( const string& fileName ) const;
451  ostream& write( ostream& output ) const;
452 
459  map< string, vector< string > > constraintMap() const;
460 
461 private:
462 
463  string m_fitName;
464  vector<ReactionInfo*> m_reactions;
465  vector<CoherentSumInfo*> m_sums;
466  vector<AmplitudeInfo*> m_amplitudes;
467  vector<ParameterInfo*> m_parameters;
468  map<string, vector< vector<string> > > m_userKeywordMap;
469 
470 };
471 
472 
473 inline ostream& operator<<( ostream& output, const ConfigurationInfo& cfgInfo ){
474 
475  return cfgInfo.write( output );
476 }
477 
478 
490 {
491 public:
492 
499  ReactionInfo(const string& reactionName,
500  const vector<string>& particleList):
501  m_reactionName(reactionName),
502  m_particleList(particleList) {clear();};
503 
504 
505  // Every reaction has a reactionName and a particleList
506 
510  string reactionName() const {return m_reactionName;}
511 
517  const vector<string>& particleList() const {return m_particleList;}
518 
519 
520  // Return information about data and MC associated with this reaction
521 
528  const pair< string, vector<string> >& data() const {return m_data;}
529 
536  const pair< string, vector<string> >& bkgnd() const {return m_bkgnd;}
537 
544  const pair< string, vector<string> >& genMC() const {return m_genMC;}
545 
552  const pair< string, vector<string> >& accMC() const {return m_accMC;}
553 
560  string normIntFile() const {return m_normIntFile;}
561 
568  bool normIntFileInput() const {return m_normIntFileInput;}
569 
570 
571  // Display or clear information for this reaction
572 
581  void display(string fileName = "", bool append = true);
582 
586  void clear();
587 
588 
589  // Use these methods to add new information to this reaction
590 
598  void setParticleList (const vector<string>& particleList) {m_particleList = particleList;}
599 
609  void setData (const string& classname, const vector<string>& args)
610  { m_data = pair<string, vector<string> >(classname,args); }
611 
621  void setBkgnd (const string& classname, const vector<string>& args)
622  { m_bkgnd = pair<string, vector<string> >(classname,args); }
623 
633  void setGenMC (const string& classname, const vector<string>& args)
634  { m_genMC = pair<string, vector<string> >(classname,args); }
635 
645  void setAccMC (const string& classname, const vector<string>& args)
646  { m_accMC = pair<string, vector<string> >(classname,args); }
647 
656  void setNormIntFile (const string& normIntFile, bool input = false)
657  { m_normIntFile = normIntFile;
658  m_normIntFileInput = input; }
659 
660 
661 private:
662 
663  string m_reactionName;
664  vector<string> m_particleList;
665  pair< string, vector<string> > m_data;
666  pair< string, vector<string> > m_bkgnd;
667  pair< string, vector<string> > m_genMC;
668  pair< string, vector<string> > m_accMC;
669  string m_normIntFile;
670  bool m_normIntFileInput;
671 
672 };
673 
674 
691 {
692 public:
693 
700  CoherentSumInfo(const string& reactionName,
701  const string& sumName):
702  m_reactionName(reactionName),
703  m_sumName(sumName) {clear();};
704 
705 
706  // Every sum is associated with a reaction and has a sumName
707 
711  string reactionName() const {return m_reactionName;}
712 
716  string sumName() const {return m_sumName;}
717 
724  string fullName() const {return (m_reactionName + "::" +
725  m_sumName);}
726 
727  // Display information for this sum
728 
737  void display(string fileName = "", bool append = true);
738 
743  void clear() {}
744 
745 private:
746 
747  string m_reactionName;
748  string m_sumName;
749 
750 };
751 
752 
766 {
767 public:
768 
778  AmplitudeInfo(const string& reactionName,
779  const string& sumName,
780  const string& ampName):
781  m_reactionName(reactionName),
782  m_sumName(sumName),
783  m_ampName(ampName) {clear();};
784 
785 
786  // Every amplitude is identified by a reaction, a sum, and an ampName
787 
791  string reactionName() const {return m_reactionName;}
792 
796  string sumName() const {return m_sumName;}
797 
801  string ampName() const {return m_ampName;}
802 
808  string fullName() const {return (m_reactionName + "::" +
809  m_sumName + "::" +
810  m_ampName);}
811 
812  // Return the amplitude factors for this reaction.
813  // Each factor has the form: <amplitude class name> (arg1) (arg2) ...
814 
828  const vector< vector<string> >& factors() const {return m_factors;}
829 
830 
831  // Return a list of different particle permuations.
832  // (For example, if there are 5 particles in this reaction, specifying
833  // a permutation of 01243 will permute the fourth and fifth particles and the
834  // amplitude becomes A(01234) + A(01243).)
835 
844  const vector< vector<int> >& permutations() const {return m_permutations;}
845 
846 
847  // Return a list of amplitudes that are constrained to have the same
848  // production parameters as this amplitude.
849 
855  const vector< AmplitudeInfo* >& constraints() const {return m_constraints;}
856 
857 
863  bool hasConstraint(AmplitudeInfo* constraint) const;
864 
865 
866  // Return information about the production parameter for this amplitude.
867 
871  complex< double > value() const {return m_value;}
872 
873  bool real() const {return m_real;}
874  bool fixed() const {return m_fixed;}
875 
876  string scale() const {return m_scale;}
877 
878 
879  // Return a list of parameters (other than the production parameter)
880  // associated with this amplitude.
881 
886  const vector < ParameterInfo* >& parameters() const {return m_parameters;}
887 
888 
889  // Display or clear information for this amplitude
890 
899  void display(string fileName = "", bool append = true);
900 
905  void clear();
906 
907 
908  // Use these methods to set up this ampltiude
909 
921  void addFactor (const vector<string>& factor) {m_factors.push_back(factor);}
922 
929  void addPermutation (const vector<int>& permutation) {m_permutations.push_back(permutation);}
930 
941  void addConstraint (AmplitudeInfo* constraint);
942 
949  void setValue (complex<double> value) {m_value = value;}
950 
951  void setReal (bool real) {m_real = real;}
952  void setFixed (bool fixed) {m_fixed = fixed;}
953 
954  void setScale (string scale) {m_scale = scale;}
955 
956 
963  void addParameter (ParameterInfo* parameter);
964 
965 
966  // Use these methods to remove information associated with this amplitude
967 
976  void removeConstraint (AmplitudeInfo* constraint);
977 
984  void removeParameter (ParameterInfo* parameter);
985 
986 private:
987 
988  string m_reactionName;
989  string m_sumName;
990  string m_ampName;
991  vector< vector<string> > m_factors;
992  vector< vector<int> > m_permutations;
993  vector< AmplitudeInfo* > m_constraints;
994  complex< double > m_value;
995  bool m_real;
996  bool m_fixed;
997  string m_scale;
998  vector< ParameterInfo* > m_parameters;
999 
1000 };
1001 
1002 
1003 
1004 
1005 
1007 {
1008 public:
1009 
1010  ParameterInfo(const string& parName,
1011  double value):
1012  m_parName(parName),
1013  m_value(value) {clear();};
1014 
1015 
1016  // Every parameter has a parameter name and an initial value
1017 
1018  string parName() const {return m_parName;}
1019  double value() const {return m_value;}
1020 
1021 
1022  // If true, the parameter is fixed to its initial value.
1023 
1024  bool fixed() const {return m_fixed;}
1025 
1026 
1027  // If the parameter is bounded, it is bounded between its
1028  // lowerBound and upperBound.
1029 
1030  bool bounded() const {return m_bounded;}
1031  double lowerBound() const {return m_lowerBound;}
1032  double upperBound() const {return m_upperBound;}
1033 
1034 
1035  // If the parameter is "gaussianBounded," an additional likelihood
1036  // factor is created based on the parameter's position within a
1037  // a gaussian distribution with mean centralValue and error
1038  // gaussianError.
1039 
1040  bool gaussianBounded() const {return m_gaussianBounded;}
1041  double centralValue() const {return m_centralValue;}
1042  double gaussianError() const {return m_gaussianError;}
1043 
1044 
1045  // Display or clear inforamtion for this parameter
1046 
1047  void display(string fileName = "", bool append = true);
1048  void clear();
1049 
1050 
1051  // Use these methods to set up this parameter
1052 
1053  void setValue (double value) {m_value = value;}
1054  void setFixed (bool fixed) {m_fixed = fixed;}
1055  void setBounded (bool bounded) {m_bounded = bounded;}
1056  void setLowerBound (double lowerBound) {m_lowerBound = lowerBound;}
1057  void setUpperBound (double upperBound) {m_upperBound = upperBound;}
1058  void setGaussianBounded (bool gaussianBounded) {m_gaussianBounded = gaussianBounded;}
1059  void setCentralValue (double centralValue) {m_centralValue = centralValue;}
1060  void setGaussianError (double gaussianError) {m_gaussianError = gaussianError;}
1061 
1062 
1063 private:
1064 
1065  string m_parName;
1066  double m_value;
1067  bool m_fixed;
1068  bool m_bounded;
1069  double m_lowerBound;
1070  double m_upperBound;
1071  bool m_gaussianBounded;
1072  double m_centralValue;
1073  double m_gaussianError;
1074 
1075 };
1076 
1077 
1078 
1079 
1080 #endif
void setLowerBound(double lowerBound)
void setFixed(bool fixed)
bool fixed() const
void setCentralValue(double centralValue)
double gaussianError() const
void addFactor(const vector< string > &factor)
const pair< string, vector< string > > & accMC() const
bool gaussianBounded() const
void setAccMC(const string &classname, const vector< string > &args)
complex< double > value() const
CoherentSumInfo(const string &reactionName, const string &sumName)
void setFitName(const string &fitName)
void setFixed(bool fixed)
bool real() const
void setBkgnd(const string &classname, const vector< string > &args)
ParameterInfo(const string &parName, double value)
const vector< string > & particleList() const
const vector< vector< int > > & permutations() const
bool bounded() const
void setData(const string &classname, const vector< string > &args)
AmplitudeInfo(const string &reactionName, const string &sumName, const string &ampName)
double upperBound() const
double value() const
string sumName() const
string scale() const
void setBounded(bool bounded)
void setValue(double value)
void write(const string &fileName) const
const vector< AmplitudeInfo *> & constraints() const
const pair< string, vector< string > > & genMC() const
void setUpperBound(double upperBound)
string reactionName() const
void setReal(bool real)
void setGaussianError(double gaussianError)
void setGenMC(const string &classname, const vector< string > &args)
ReactionInfo(const string &reactionName, const vector< string > &particleList)
const pair< string, vector< string > > & data() const
void setGaussianBounded(bool gaussianBounded)
void setNormIntFile(const string &normIntFile, bool input=false)
void setScale(string scale)
const vector< vector< string > > & factors() const
double lowerBound() const
ostream & operator<<(ostream &output, const ConfigurationInfo &cfgInfo)
void setValue(complex< double > value)
string fitName() const
void setParticleList(const vector< string > &particleList)
string fullName() const
bool normIntFileInput() const
string parName() const
bool fixed() const
void addPermutation(const vector< int > &permutation)
string sumName() const
string reactionName() const
double centralValue() const
string fullName() const
string fitOutputFileName() const
const vector< ParameterInfo *> & parameters() const
ConfigurationInfo(const string &fitName)
string reactionName() const
const pair< string, vector< string > > & bkgnd() const
string ampName() const
string normIntFile() const