AmpTools
PlotGenerator.h
Go to the documentation of this file.
1 #if !(defined PLOTGENERATOR)
2 #define PLOTGENERATOR
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 <vector>
41 #include <map>
42 #include <string>
43 #include <complex>
44 #include <utility>
45 
46 #include "IUAmpTools/Histogram.h"
47 #include "IUAmpTools/Histogram1D.h"
48 #include "IUAmpTools/Histogram2D.h"
53 
54 class AmpToolsInterface;
55 class FitResults;
56 
57 using namespace std;
58 
60 {
61 
62 public:
63 
64  enum { kData = 0, kGenMC, kAccMC, kNumTypes };
65 
66  PlotGenerator( const FitResults& fitResults );
67 
68  virtual ~PlotGenerator();
69 
70  // get intensity for all amplitudes that are turned on
71  pair< double, double > intensity( bool accCorrected = true ) const;
72 
73  bool haveAmp( const string& amp ) const;
74 
75  const ConfigurationInfo* cfgInfo() const { return m_cfgInfo; }
76 
77  const vector< string >& availablePlots() const { return m_histTitles; }
78 
79  // the list with reactions and sums
80  const vector< string >& fullAmplitudes() const { return m_fullAmplitudes; }
81  // the list of unique amplitudes
82  const vector< string >& uniqueAmplitudes() const { return m_uniqueAmplitudes; }
83  // the list of unique sums
84  const vector< string >& uniqueSums() const { return m_uniqueSums; }
85 
86  // the reactions themselves
87  vector< string > reactions() const;
88 
89  Histogram* projection( unsigned int projectionIndex, string fsName,
90  unsigned int type );
91 
92  void disableReaction( const string& fsName );
93  void enableReaction( const string& fsName );
94 
95  // these args are the index in the list of unique amplitudes and sums
96  void disableAmp( unsigned int uniqueAmpIndex );
97  void enableAmp( unsigned int uniqueAmpIndex );
98  void disableSum( unsigned int uniqueSumIndex );
99  void enableSum( unsigned int uniqueSumIndex );
100 
101  bool isReactionEnabled( const string& reactName ) const;
102  bool isAmpEnabled( unsigned int uniqueAmpIndex ) const;
103  bool isSumEnabled( unsigned int uniqueSumIndex ) const;
104 
105 protected:
106 
107  // this function maintained to support older code
108  void bookHistogram( int index, const string& title, Histogram* hist );
109  void bookHistogram( int index, Histogram* hist );
110 
111  void fillHistogram( int index, double value );
112  void fillHistogram( int index, double valueX,double valueY );
113  void fillHistogram( int index, vector <double> &data, double weight = 1);
114 
115  unsigned int getAmpIndex( const string& ampName ) const;
116 
117 private:
118 
119  // this function should be overridden by the derived class
120  // that is written by the user
121  virtual void projectEvent( Kinematics* kin ) = 0;
122 
123  void clearHistograms();
124  void fillProjections( const string& reactName, unsigned int type );
125 
126  void recordConfiguration();
127  void buildUniqueAmplitudes();
128 
129  vector< string >
130  stringSplit(const string& str, const string& delimiters = " ") const;
131 
132  const FitResults& m_fitResults;
133  AmpToolsInterface m_ati;
134  const ConfigurationInfo* m_cfgInfo;
135 
136  map< string, NormIntInterface* > m_normIntMap;
137  map< string, IntensityManager* > m_intenManagerMap;
138 
139  // dimension of these vectors is the number of amplitudes (constrained + free)
140  vector< complex< double > > m_fitProdAmps;
141  vector< complex< double > > m_zeroProdAmps;
142  vector< complex< double > > m_prodAmps;
143 
144  // a vector of amplitude parameters
145  map< string, double > m_ampParameters;
146 
147  // these amplitudes include reaction name separated by a '::'
148  vector< string > m_fullAmplitudes;
149 
150  // these lists are independent of reaction
151  vector< string > m_uniqueAmplitudes;
152  vector< string > m_uniqueSums;
153 
154  // index of production parameter for a particular (full) amplitude
155  map< string, unsigned int > m_ampIndex;
156 
157  // index of a particular reaction
158  map< string, unsigned int > m_reactIndex;
159 
160  // keep track of which amplitudes and final states are enabled
161  map< string, bool > m_ampEnabled;
162  map< string, bool > m_sumEnabled;
163  map< string, bool > m_reactEnabled;
164 
165  // a map from ampConfiguration -> final state -> histogram cache
166  mutable map< string, map< string, vector< Histogram* > > > m_accMCHistCache;
167  mutable map< string, map< string, vector< Histogram* > > > m_genMCHistCache;
168  // note that for data the ampConfiguration is useless, but keep the
169  // same structure for ease of coding -- bypass first string
170  // in the code that fetches projections
171  mutable map< string, map< string, vector< Histogram* > > > m_dataHistCache;
172 
173  vector< string > m_histTitles;
174  mutable vector< Histogram*> m_histVect,m_histVect_clone;
175  mutable double m_currentEventWeight;
176 
177  string m_currentConfiguration;
178 };
179 
180 #endif
const vector< string > & uniqueSums() const
Definition: PlotGenerator.h:84
const vector< string > & uniqueAmplitudes() const
Definition: PlotGenerator.h:82
const vector< string > & availablePlots() const
Definition: PlotGenerator.h:77
const ConfigurationInfo * cfgInfo() const
Definition: PlotGenerator.h:75
const vector< string > & fullAmplitudes() const
Definition: PlotGenerator.h:80