AmpTools
NormIntInterface.h
Go to the documentation of this file.
1 #if !(defined NORMINTINTERFACE)
2 #define NORMINTINTERFACE
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 <complex>
41 #include <string>
42 #include <map>
43 #include <vector>
44 
46 #include "IUAmpTools/AmpVecs.h"
47 
48 class Kinematics;
49 class IntensityManager;
50 class DataReader;
51 
52 using namespace std;
53 
55 {
56 
57 public:
58 
60  NormIntInterface( const string& normIntFile );
61  NormIntInterface( DataReader* genMCData, DataReader* accMCData,
62  const IntensityManager& ampManager );
63 
64  istream& loadNormIntCache( istream& in );
65  void operator+=( const NormIntInterface& nii );
66 
67  int numGenEvents() const { return m_nGenEvents; }
68  int numAccEvents() const { return m_nAccEvents; }
69 
70  // does this interface have the ability to recalculate integrals?
71  bool hasAccessToMC() const;
72 
73  // this integral folds in detector acceptance
74  virtual complex< double > normInt( string amp, string conjAmp, bool forceUseCache = false ) const;
75  bool hasNormInt( string amp, string conjAmp ) const;
76 
77  // this purely the integral of the amplitude -- perfect acceptance
78  virtual complex< double > ampInt( string amp, string conjAmp, bool forceUseCache = false ) const;
79  bool hasAmpInt( string amp, string conjAmp ) const;
80 
81  // needs to be virtual so parallel implementations can properly
82  // override this function
83  virtual void forceCacheUpdate( bool normIntOnly = false ) const;
84 
85  void exportNormIntCache( const string& fileName, bool renormalize = false ) const;
86  void exportNormIntCache( ostream& output, bool renormalize = false ) const;
87 
88  // allow direct access to raw data matrix in memory, which is useful
89  // for high-speed implementations, but not user friendly
90  const GDouble* ampIntMatrix() const { return m_ampIntCache; }
91  const GDouble* normIntMatrix() const { return m_normIntCache; }
92 
93  void setGenEvents( int events ) { m_nGenEvents = events; }
94  void setAccEvents( int events ) { m_nAccEvents = events; }
95 
96 protected:
97 
98  // protected helper functions for parallel implementations
99 
100  const IntensityManager* intenManager() const { return m_pIntenManager; }
101  inline int cacheSize() const { return m_cacheSize; }
102 
103  void setAmpIntMatrix( const double* input ) const;
104  void setNormIntMatrix( const double* input ) const;
105 
106 private:
107 
108  void initializeCache();
109 
110  const IntensityManager* m_pIntenManager;
111 
112  DataReader* m_accMCReader;
113  DataReader* m_genMCReader;
114 
115  int m_nGenEvents;
116  int m_nAccEvents;
117 
118  vector< string > m_termNames;
119  map< string, int > m_termIndex;
120 
121  mutable bool m_emptyNormIntCache;
122  mutable bool m_emptyAmpIntCache;
123 
124  // needed to cache accepted MC data for NI recalculation
125  mutable AmpVecs m_mcVecs;
126 
127  int m_cacheSize;
128 
129  mutable GDouble* m_normIntCache;
130  mutable GDouble* m_ampIntCache;
131 };
132 
133 inline istream& operator>>( istream& input, NormIntInterface& normInt ){
134 
135  return normInt.loadNormIntCache( input );
136 }
137 
138 #endif
int numAccEvents() const
int cacheSize() const
const IntensityManager * intenManager() const
double GDouble
void setAccEvents(int events)
void setGenEvents(int events)
const GDouble * normIntMatrix() const
const GDouble * ampIntMatrix() const
istream & loadNormIntCache(istream &in)
int numGenEvents() const
istream & operator>>(istream &input, NormIntInterface &normInt)