CHROMA
meson_spec_2pt_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Construct meson 2pt correlators leaving all spin indices open
3  */
4 
5 #error "STILL WORKING ON THIS"
6 
9 
11 
12 namespace Chroma
13 {
14 
15  // Read parameters
16  void read(XMLReader& xml, const std::string& path, MesonSpec2PtEnv::Params& param)
17  {
18  MesonSpec2PtEnv::Params tmp(xml, path);
19  param = tmp;
20  }
21 
22  // Writer
23  void write(XMLWriter& xml, const std::string& path, const MesonSpec2PtEnv::Params& param)
24  {
25  param.writeXML(xml, path);
26  }
27 
28 
29  //! Meson correlators
30  /*!
31  * \ingroup hadron
32  *
33  * @{
34  */
35  namespace MesonSpec2PtEnv
36  {
37  //! Anonymous namespace
38  namespace
39  {
40  //! Construct the correlator
41  LatticeComplex mesXCorr(const LatticePropagator& quark_prop_1,
42  const LatticePropagator& quark_prop_2,
43  int gamma_value)
44  {
45  // Construct the anti-quark propagator from quark_prop_2
46  int G5 = Ns*Ns-1;
47  LatticePropagator anti_quark_prop = Gamma(G5) * quark_prop_2 * Gamma(G5);
48 
49  return LatticeComplex(trace(adj(anti_quark_prop) * (Gamma(gamma_value) *
50  quark_prop_1 * Gamma(gamma_value))));
51  }
52 
53 
54  //-------------------- callback functions ---------------------------------------
55 
56  //! Construct pion correlator
57  HadronContract* mesDiagGammaCorrs(XMLReader& xml_in,
58  const std::string& path)
59  {
60  return new MesonSpecCorrs(Params(xml_in, path)); // all gammas
61  }
62 
63 
64  //! Local registration flag
65  bool registered = false;
66 
67  } // end anonymous namespace
68 
69 
70  //! Initialize
72  {
73  }
74 
75 
76  //! Read parameters
77  Params::Params(XMLReader& xml, const std::string& path)
78  {
79  XMLReader paramtop(xml, path);
80 
81  int version;
82  read(paramtop, "version", version);
83 
84  switch (version)
85  {
86  case 1:
87  break;
88 
89  default:
90  QDPIO::cerr << __func__ << ": parameter version " << version
91  << " unsupported." << std::endl;
92  QDP_abort(1);
93  }
94 
95  read(paramtop, "mom2_max", mom2_max);
96  read(paramtop, "avg_equiv_mom", avg_equiv_mom);
97  read(paramtop, "mom_origin", mom_origin);
98  read(paramtop, "first_id", first_id);
99  read(paramtop, "second_id", second_id);
100  }
101 
102 
103  // Writer
104  void Params::writeXML(XMLWriter& xml, const std::string& path) const
105  {
106  push(xml, path);
107 
108  int version = 1;
109  write(xml, "version", version);
110 
111  write(xml, "mom2_max", mom2_max);
112  write(xml, "avg_equiv_mom", avg_equiv_mom);
113  write(xml, "mom_origin", mom_origin);
114 
115  write(xml, "first_id", first_id);
116  write(xml, "second_id", second_id);
117 
118  pop(xml);
119  }
120 
121 
122  //! Do a SFT and serialize the output
123  void serializeSFT(BinaryWriter& bin, const SftMom& phases, const LatticeComplex& prop)
124  {
125  multi2d<DComplex> hsum(phases.sft(prop));
126  int length = phases.numSubsets();
127 
128  write(bin, phases.numMom());
129 
130  for(int sink_mom_num=0; sink_mom_num < phases.numMom(); ++sink_mom_num)
131  {
132  multi1d<DComplex> corr(length); /*!< Momentum projected correlator */
133  for (int t=0; t < length; ++t)
134  {
135 // int t_eff = (t - t0 + length) % length; // NOTE: no longer shifting source
136  corr[t] = hsum[sink_mom_num][t];
137  }
138 
139  write(bin, phases.numToMom(sink_mom_num));
140  write(bin, corr);
141  }
142  }
143 
144 
145  //! Meson data
147  {
148  LatticePropagator quark_prop1;
149  LatticePropagator quark_prop2;
151  };
152 
153  //! Do some initialization
154  void init(MesonSpecData_t& data,
155  XMLWriter& xml, const std::string& path, const std::string& id_tag,
156  const Params& params)
157  {
158  MesonSpecData_t data;
159 
160  multi1d<ForwardProp_t> forward_headers(2);
161  forward_headers[0] = readForwardPropHeader(params.first_id);
162  forward_headers[1] = readForwardPropHeader(params.second_id);
163 
164  push(xml, path);
165  write(xml, id_tag, "meson_spec");
166  write(xml, "PropHeaders", forward_headers);
167  pop(xml);
168 
169  multi1d<int> t_srce = getTSrce(forward_headers);
170  int decay_dir = getDecayDir(forward_headers);
171 
172  // Get references to the props
173  data.quark_prop1 = TheNamedObjMap::Instance().getData<LatticePropagator>(params.first_id);
174  data.quark_prop2 = TheNamedObjMap::Instance().getData<LatticePropagator>(params.second_id);
175 
176  // Parameters needed for the momentum projection
177  SftMomParams_t sft_params;
178  sft_params.mom2_max = params.mom2_max;
179  sft_params.origin_offset = t_srce;
180  sft_params.mom_offset = params.mom_origin;
181  sft_params.avg_equiv_mom = params.avg_equiv_mom;
182  sft_params.decay_dir = decay_dir;
183 
184  data.phases(new SftMom(sft_params));
185  }
186 
187 
188  // Construct all the correlators
189  std::list< Handle<HadronContractResult_t> >
190  MesonSpecCorrs::operator()(const multi1d<LatticeColorMatrix>& u,
191  const std::string& xml_group,
192  const std::string& id_tag)
193  {
194  START_CODE();
195 
196  QDPIO::cout << "Hadron2Pt: diagonal_gamma_mesons" << std::endl;
197 
199  MesonSpecData_t data;
200  init(data, corr->bin, xml_group, id_tag, params);
201 
202  // Length of lattice in decay direction
203  int length = data.phases->numSubsets();
204  int G5 = Ns*Ns-1;
205 
206  LatticePropagator antiquark_1 = adj(Gamma(G5) * data.quark_prop1 * Gamma(G5));
207  LatticeComplex m_prop;
208 
209  for(int sf_2=0; sf_2 < Ns; ++sf_2) // sf_2
210  for(int sf_1=0; sf_1 < Ns; ++sf_1) // sf_1
211  for(int si_2=0; si_2 < Ns; ++si_2) // si_2
212  for(int si_1=0; si_1 < Ns; ++si_1) // si_1
213  {
214  write(bin, si_1);
215  write(bin, sf_1);
216  write(bin, si_2);
217  write(bin, sf_2);
218 
219  // Contract over color indices with antisym tensors
220  m_prop =
221  traceColor(peekSpin(antiquark_1,
222  sf_1,si_1) // (sf_1,si_1)
223  * peekSpin(quark_prop2,
224  sf_2,si_2)); // (sf_2,si_2)
225 
226  serializeSFT(corr->bin, *(data.phases), m_prop);
227  }
228 
229  std::list< Handle<HadronContractResult_t> > corrs;
230  corrs.push_back(corr);
231 
232  END_CODE();
233 
234  return corrs;
235  }
236 
237 
238  //! Register all the factories
239  bool registerAll()
240  {
241  bool success = true;
242  if (! registered)
243  {
244  //! Register all the factories
245  success &= Chroma::TheHadronContractFactory::Instance().registerObject(std::string("meson_spec"),
246  mesDiagGammaCorrs);
247 
248  registered = true;
249  }
250  return success;
251  }
252 
253  } // end namespace MesonSpec2PtEnv
254 
255  /*! @} */ // end of group io
256 
257 } // end namespace Chroma
258 
259 
260 
Construct hadron correlators.
Class for counted reference semantics.
Definition: handle.h:33
2pt-mesons but with all 4 spin indices open
std::list< Handle< HadronContractResult_t > > operator()(const multi1d< LatticeColorMatrix > &u, const std::string &xml_group, const std::string &id_tag)
Construct the correlators.
Fourier transform phase factor support.
Definition: sftmom.h:35
int numSubsets() const
Number of subsets - length in decay direction.
Definition: sftmom.h:63
multi1d< int > numToMom(int mom_num) const
Convert momenta id to actual array of momenta.
Definition: sftmom.h:78
multi2d< DComplex > sft(const LatticeComplex &cf) const
Do a sumMulti(cf*phases,getSet())
Definition: sftmom.cc:524
int numMom() const
Number of momenta.
Definition: sftmom.h:60
static T & Instance()
Definition: singleton.h:432
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
Factory for producing hadron correlator objects.
std::map< std::string, SinkPropContainer_t > prop
multi1d< int > t_srce
Params params
int t
Definition: meslate.cc:37
Construct meson 2pt correlators leaving all spin indices open.
Named object function std::map.
static bool registered
Local registration flag.
void init(MesonSpecData_t &data, XMLWriter &xml, const std::string &path, const std::string &id_tag, const Params &params)
Do some initialization.
bool registerAll()
Register all the factories.
void serializeSFT(BinaryWriter &bin, const SftMom &phases, const LatticeComplex &prop)
Do a SFT and serialize the output.
multi1d< ForwardProp_t > & forward_headers
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
int G5
Definition: pbg5p_w.cc:57
static multi1d< LatticeColorMatrix > u
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
push(xml_out,"Condensates")
pop(xml_out)
START_CODE()
::std::string string
Definition: gtest.h:1979
The result of hadron contractions.
Simple meson 2pt parameters.
void writeXML(XMLWriter &in, const std::string &path) const
Param struct for SftMom.
Definition: sftmom.h:20