CHROMA
inline_spectrumQll.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline construction of heavy-light baryon spectrum
3  * (infinitely heavy)
4  *
5  * Spectrum (Qll) calculations
6  */
7 
8 #error "DEPRECATED - TAKEN OUT OF MAKEFILE"
9 
12 #include "meas/glue/mesplq.h"
13 #include "meas/smear/ape_smear.h"
14 #include "meas/smear/sink_smear2.h"
15 #include "util/ft/sftmom.h"
16 #include "util/info/proginfo.h"
17 #include "io/param_io.h"
18 #include "io/qprop_io.h"
19 #include "meas/hadron/barQll_w.h"
20 #include "meas/hadron/mesQl_w.h"
22 #include "meas/glue/mesfield.h"
23 #include "util/gauge/taproj.h"
25 
27 
28 namespace Chroma
29 {
30  namespace InlineSpectrumQllEnv
31  {
32  namespace
33  {
34  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
35  const std::string& path)
36  {
37  return new InlineSpectrumQll(InlineSpectrumQllParams(xml_in, path));
38  }
39 
40  //! Local registration flag
41  bool registered = false;
42  }
43 
44  const std::string name = "SPECTRUM_QLL";
45 
46  //! Register all the factories
47  bool registerAll()
48  {
49  bool success = true;
50  if (! registered)
51  {
52  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
53  registered = true;
54  }
55  return success;
56  }
57  }
58 
59 
60 
61  //! Reader for parameters
62  void read(XMLReader& xml, const std::string& path, InlineSpectrumQllParams::Param_t& param)
63  {
64  XMLReader paramtop(xml, path);
65 
66  int version;
67  read(paramtop, "version", version);
68 
69  param.link_smear_fact = 0;
70  param.link_smear_num = 0;
71 
72  switch (version)
73  {
74  case 1:
75  param.Wl_snk = false;
76  break;
77 
78  case 2:
79  read(paramtop, "Wl_snk", param.Wl_snk);
80  break;
81 
82  case 3:
83  read(paramtop, "Wl_snk", param.Wl_snk);
84  read(paramtop, "link_smear_fact", param.link_smear_fact);
85  read(paramtop, "link_smear_num", param.link_smear_num);
86  break;
87 
88  default:
89  QDPIO::cerr << "Input parameter version " << version << " unsupported." << std::endl;
90  QDP_abort(1);
91  }
92 
93  read(paramtop, "Pt_snk", param.Pt_snk);
94  read(paramtop, "Sl_snk", param.Sl_snk);
95 
96  read(paramtop, "wvf_kind", param.wvf_kind);
97  read(paramtop, "wvf_param", param.wvf_param);
98  read(paramtop, "wvfIntPar", param.wvfIntPar);
99 
100  if (param.wvf_param.size() != param.wvfIntPar.size())
101  {
102  QDPIO::cerr << "wvf_param size inconsistent with wvfintpar size" << std::endl;
103  QDP_abort(1);
104  }
105 
106  read(paramtop, "Qsrc_coord", param.Qsrc_coord);
107 
108  }
109 
110 
111  //! Writer for parameters
112  void write(XMLWriter& xml, const std::string& path, const InlineSpectrumQllParams::Param_t& param)
113  {
114  push(xml, path);
115 
116  int version = 3;
117  write(xml, "version", version);
118 
119  write(xml, "Pt_snk", param.Pt_snk);
120  write(xml, "Sl_snk", param.Sl_snk);
121  write(xml, "Wl_snk", param.Wl_snk);
122 
123  write(xml, "wvf_kind", param.wvf_kind);
124  write(xml, "wvf_param", param.wvf_param);
125  write(xml, "wvfIntPar", param.wvfIntPar);
126 
127  write(xml, "link_smear_fact", param.link_smear_fact);
128  write(xml, "link_smear_num", param.link_smear_num);
129 
130  write(xml, "Qsrc_coord", param.Qsrc_coord);
131  write(xml, "nrow", Layout::lattSize());
132 
133  pop(xml);
134  }
135 
136 
137  //! Propagator input
138  void read(XMLReader& xml, const std::string& path, InlineSpectrumQllParams::NamedObject_t& input)
139  {
140  XMLReader inputtop(xml, path);
141 
142  read(inputtop, "gauge_id", input.gauge_id);
143  read(inputtop, "prop_ids", input.prop_ids);
144  }
145 
146  //! Propagator output
147  void write(XMLWriter& xml, const std::string& path, const InlineSpectrumQllParams::NamedObject_t& input)
148  {
149  push(xml, path);
150 
151  write(xml, "gauge_id", input.gauge_id);
152  write(xml, "prop_ids", input.prop_ids);
153 
154  pop(xml);
155  }
156 
157 
158  // Param stuff
160 
162  {
163  try
164  {
165  XMLReader paramtop(xml_in, path);
166 
167  if (paramtop.count("Frequency") == 1)
168  read(paramtop, "Frequency", frequency);
169  else
170  frequency = 1;
171 
172  // Parameters for source construction
173  read(paramtop, "Param", param);
174 
175  // Read in the output propagator/source configuration info
176  read(paramtop, "NamedObject", named_obj);
177 
178  // Possible alternate XML file pattern
179  if (paramtop.count("xml_file") != 0)
180  {
181  read(paramtop, "xml_file", xml_file);
182  }
183  }
184  catch(const std::string& e)
185  {
186  QDPIO::cerr << __func__ << ": Caught Exception reading XML: " << e << std::endl;
187  QDP_abort(1);
188  }
189  }
190 
191 
192  void
193  InlineSpectrumQllParams::write(XMLWriter& xml_out, const std::string& path)
194  {
195  push(xml_out, path);
196 
197  Chroma::write(xml_out, "Param", param);
198  Chroma::write(xml_out, "NamedObject", named_obj);
199  QDP::write(xml_out, "xml_file", xml_file);
200 
201  pop(xml_out);
202  }
203 
204 
205  // Function call
206  void
207  InlineSpectrumQll::operator()(unsigned long update_no,
208  XMLWriter& xml_out)
209  {
210  // If xml file not empty, then use alternate
211  if (params.xml_file != "")
212  {
213  std::string xml_file = makeXMLFileName(params.xml_file, update_no);
214 
215  push(xml_out, "spectrumQll_w");
216  write(xml_out, "update_no", update_no);
217  write(xml_out, "xml_file", xml_file);
218  pop(xml_out);
219 
220  XMLFileWriter xml(xml_file);
221  func(update_no, xml);
222  }
223  else
224  {
225  func(update_no, xml_out);
226  }
227  }
228 
229 
230  // Real work done here
231  void
232  InlineSpectrumQll::func(unsigned long update_no,
233  XMLWriter& xml_out)
234  {
235  START_CODE();
236 
237  StopWatch snoop;
238  snoop.reset();
239  snoop.start();
240 
241  // Test and grab a reference to the gauge field
242  XMLBufferWriter gauge_xml;
243  try
244  {
245  TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
246  TheNamedObjMap::Instance().get(params.named_obj.gauge_id).getRecordXML(gauge_xml);
247  }
248  catch( std::bad_cast )
249  {
250  QDPIO::cerr << InlineSpectrumQllEnv::name << ": caught dynamic cast error"
251  << std::endl;
252  QDP_abort(1);
253  }
254  catch (const std::string& e)
255  {
256  QDPIO::cerr << InlineSpectrumQllEnv::name << ": std::map call failed: " << e
257  << std::endl;
258  QDP_abort(1);
259  }
260  const multi1d<LatticeColorMatrix>& u =
261  TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
262 
263  push(xml_out, "spectrumQll_w");
264  write(xml_out, "update_no", update_no);
265 
266  QDPIO::cout << InlineSpectrumQllEnv::name << ": Spectroscopy for Wilson-like fermions" << std::endl;
267 
268  /*
269  * Sanity checks
270  */
271  if (params.param.wvf_param.size() != params.named_obj.prop_ids.size())
272  {
273  QDPIO::cerr << "wvf_param size inconsistent with prop_ids size" << std::endl;
274  QDP_abort(1);
275  }
276 
277  QDPIO::cout << std::endl << " Gauge group: SU(" << Nc << ")" << std::endl;
278 
279  QDPIO::cout << " volume: " << Layout::lattSize()[0];
280  for (int i=1; i<Nd; ++i) {
281  QDPIO::cout << " x " << Layout::lattSize()[i];
282  }
283  QDPIO::cout << std::endl;
284 
285  proginfo(xml_out); // Print out basic program info
286 
287  // Write out the input
288  params.write(xml_out, "Input");
289 
290  // Write out the config info
291  write(xml_out, "Config_info", gauge_xml);
292 
293  push(xml_out, "Output_version");
294  write(xml_out, "out_version", 2);
295  pop(xml_out);
296 
297 
298  // First calculate some gauge invariant observables just for info.
299  MesPlq(xml_out, "Observables", u);
300 
301  // Keep an array of all the xml output buffers
302  XMLArrayWriter xml_array(xml_out,params.named_obj.prop_ids.size());
303  push(xml_array, "Wilson_hadron_measurements");
304 
305 
306  // Now loop over the various fermion masses
307  for (int loop=0; loop < params.named_obj.prop_ids.size(); ++loop)
308  {
309  // Read the quark propagator and extract headers
311  PropSourceConst_t source_header;
312  QDPIO::cout << "Attempt to read propagator info" << std::endl;
313  try
314  {
315  // Try the cast to see if this is a valid source
316  LatticePropagator& prop_tmp =
317  TheNamedObjMap::Instance().getData<LatticePropagator>(params.named_obj.prop_ids[loop]);
318 
319  // Snarf the source info. This is will throw if the source_id is not there
320  XMLReader prop_file_xml, prop_record_xml;
321  TheNamedObjMap::Instance().get(params.named_obj.prop_ids[loop]).getFileXML(prop_file_xml);
322  TheNamedObjMap::Instance().get(params.named_obj.prop_ids[loop]).getRecordXML(prop_record_xml);
323 
324  // Try to invert this record XML into a ChromaProp struct
325  // Also pull out the id of this source
326  {
327  read(prop_record_xml, "/Propagator/ForwardProp", prop_header);
328  read(prop_record_xml, "/Propagator/PropSource", source_header);
329  }
330  }
331  catch (std::bad_cast)
332  {
333  QDPIO::cerr << InlineSpectrumQllEnv::name << ": caught dynamic cast error"
334  << std::endl;
335  QDP_abort(1);
336  }
337  catch (const std::string& e)
338  {
339  QDPIO::cerr << InlineSpectrumQllEnv::name << ": error extracting prop_header: " << e << std::endl;
340  QDP_abort(1);
341  }
342 
343  // Should be a valid cast now
344  const LatticePropagator& quark_propagator =
345  TheNamedObjMap::Instance().getData<LatticePropagator>(params.named_obj.prop_ids[loop]);
346 
347  QDPIO::cout << "Propagator successfully read and parsed" << std::endl;
348 
349  // Derived from input prop
350  int j_decay = source_header.j_decay;
351  int t0 = source_header.t_source;
352  multi1d<int> boundary = getFermActBoundary(prop_header.fermact);
353 
354  // Hunt around to find the mass
355  // NOTE: this may be problematic in the future if actions are used with no
356  // clear def. of a Mass
357  QDPIO::cout << "Try action and mass" << std::endl;
358  Real Mass = getMass(prop_header.fermact);
359 
360  QDPIO::cout << "FermAct = " << prop_header.fermact.id << std::endl;
361  QDPIO::cout << "Mass = " << Mass << std::endl;
362 
363  // Flags
364  int bc_spec = boundary[j_decay];
365 
366  // Initialize the slow Fourier transform phases with NO momenta
367  SftMom phases(0, true, j_decay);
368 
369  // Next array element - name auto-written
370  push(xml_array);
371  write(xml_array, "loop", loop);
372  write(xml_array, "Mass_mes", Mass);
373  write(xml_array, "t0", t0);
374 
375  // Save prop input
376  write(xml_array, "ForwardProp", prop_header);
377  write(xml_array, "PropSource", source_header);
378 
379  // Sanity check - write out the norm2 of the forward prop in the j_decay direction
380  // Use this for any possible verification
381  {
382  multi1d<Double> forward_prop_corr = sumMulti(localNorm2(quark_propagator),
383  phases.getSet());
384 
385  push(xml_array, "Forward_prop_correlator");
386  write(xml_array, "forward_prop_corr", forward_prop_corr);
387  pop(xml_array);
388  }
389 
390  // Determine what kind of source to use
391  bool Pt_src = false;
392  bool Sl_src = false;
393  bool Wl_src = false;
394 
395  if (source_header.source.id == "POINT_SOURCE")
396  Pt_src = true;
397  else if (source_header.source.id == "SHELL_SOURCE")
398  Sl_src = true;
399  else if (source_header.source.id == "WALL_SOURCE")
400  Wl_src = true;
401  else
402  {
403  QDPIO::cerr << "Unsupported source type" << std::endl;
404  QDP_abort(1);
405  }
406 
407 
408  /*
409  * Smear the gauge field if needed
410  */
411  multi1d<LatticeColorMatrix> u_link_smr(Nd);
412  u_link_smr = u;
413 
415  {
416  int BlkMax = 100; // Maximum number of blocking/smearing iterations
417  Real BlkAccu = 1.0e-5; // Blocking/smearing accuracy
418 
419  for(int i=0; i < params.param.link_smear_num; ++i)
420  {
421  multi1d<LatticeColorMatrix> u_tmp(Nd);
422 
423  for(int mu = 0; mu < Nd; ++mu)
424  if ( mu != j_decay )
425  APE_Smear(u_link_smr, u_tmp[mu], mu, 0,
426  params.param.link_smear_fact, BlkAccu, BlkMax,
427  j_decay);
428  else
429  u_tmp[mu] = u_link_smr[mu];
430 
431  u_link_smr = u_tmp;
432  }
433  QDPIO::cout << "Gauge field APE-smeared!" << std::endl;
434  }
435 
436 
437  // Construct {Point|Shell}-Point, if desired
438  if (params.param.Pt_snk)
439  {
440  if (Pt_src){
441  Qll(u_link_smr,quark_propagator,params.param.Qsrc_coord, phases,xml_array, "Point_Point_Wilson_QllBaryons");
442  Qlbar(u_link_smr,quark_propagator,params.param.Qsrc_coord, phases,xml_array, "Point_Point_Wilson_Qlmeson");
443  }
444  if (Sl_src){
445  Qll(u_link_smr,quark_propagator,params.param.Qsrc_coord, phases,xml_array, "Shell_Point_Wilson_QllBaryons");
446  Qlbar(u_link_smr,quark_propagator,params.param.Qsrc_coord, phases,xml_array, "Shell_Point_Wilson_Qlmeson");
447  }
448  if (Wl_src){
449  Qll(u_link_smr,quark_propagator,params.param.Qsrc_coord, phases,xml_array, "Wall_Point_Wilson_QllBaryons");
450  Qlbar(u_link_smr,quark_propagator,params.param.Qsrc_coord, phases,xml_array, "Wall_Point_Wilson_Qlmeson");
451  }
452  } // end if (Pt_snk)
453 
454  // Convolute the quark propagator with the sink smearing function.
455  // Make a copy of the quark propagator and then overwrite it with
456  // the convolution.
457  if (params.param.Sl_snk)
458  {
459  LatticePropagator quark_prop_smr;
460  quark_prop_smr = quark_propagator;
461  sink_smear2(u_link_smr, quark_prop_smr,
463  params.param.wvf_param[loop],
464  params.param.wvfIntPar[loop],
465  j_decay);
466  {
467  if (Pt_src){
468  Qll(u_link_smr,quark_prop_smr,params.param.Qsrc_coord, phases,xml_array, "Point_Shell_Wilson_QllBaryons");
469  Qlbar(u_link_smr,quark_prop_smr,params.param.Qsrc_coord, phases,xml_array, "Point_Shell_Wilson_Qlmeson");
470  }
471  if (Sl_src){
472  Qll(u_link_smr,quark_prop_smr,params.param.Qsrc_coord, phases,xml_array, "Shell_Shell_Wilson_QllBaryons");
473  Qlbar(u_link_smr,quark_prop_smr,params.param.Qsrc_coord, phases,xml_array, "Shell_Shell_Wilson_Qlmeson");
474  }
475  if (Wl_src){
476  Qll(u_link_smr,quark_prop_smr,params.param.Qsrc_coord, phases,xml_array, "Wall_Shell_Wilson_QllBaryons");
477  Qlbar(u_link_smr,quark_prop_smr,params.param.Qsrc_coord, phases,xml_array, "Wall_Shell_Wilson_Qlmeson");
478  }
479  }
480  } // end if (Sl_snk)
481 
482  // Wall sink
483  if (params.param.Wl_snk)
484  {
485  LatticePropagator wall_quark_prop;
486  wall_qprop(wall_quark_prop, quark_propagator, phases);
487  if (Pt_src){
488  Qll(u_link_smr,wall_quark_prop,params.param.Qsrc_coord, phases,xml_array, "Point_Wall_Wilson_QllBaryons");
489  Qlbar(u_link_smr,wall_quark_prop,params.param.Qsrc_coord, phases,xml_array, "Point_Wall_Wilson_Qlmeson");
490  }
491  if (Sl_src){
492  Qll(u_link_smr,wall_quark_prop,params.param.Qsrc_coord, phases,xml_array, "Shell_Wall_Wilson_QllBaryons");
493  Qlbar(u_link_smr,wall_quark_prop,params.param.Qsrc_coord, phases,xml_array, "Shell_Wall_Wilson_Qlmeson");
494  }
495  if (Wl_src){
496  Qll(u_link_smr,wall_quark_prop,params.param.Qsrc_coord, phases,xml_array, "Wall_Wall_Wilson_QllBaryons");
497  Qlbar(u_link_smr,wall_quark_prop,params.param.Qsrc_coord, phases,xml_array, "Wall_Wall_Wilson_Qlmeson");
498  }
499  } // end if (Wl_snk)
500 
501 
502  pop(xml_array); // array element
503 
504  } // end for(loop)
505 
506  pop(xml_array); // Wilson_spectroscopy
507  pop(xml_out); // spectrumQll_w
508 
509  snoop.stop();
510  QDPIO::cout << InlineSpectrumQllEnv::name << ": total time = "
511  << snoop.getTimeInSeconds()
512  << " secs" << std::endl;
513 
514  QDPIO::cout << InlineSpectrumQllEnv::name << ": ran successfully" << std::endl;
515 
516  END_CODE();
517  }
518 
519 }; // end namespace Chroma
520 
Inline measurement factory.
Heavy Baryon (Qll) 2-pt function : Orginos and Savage.
Inline measurement of static-light-light spectrum.
InlineSpectrumQllParams params
void operator()(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
void func(const unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
Fourier transform phase factor support.
Definition: sftmom.h:35
const Set & getSet() const
The set to be used in sumMulti.
Definition: sftmom.h:57
static T & Instance()
Definition: singleton.h:432
int mu
Definition: cool.cc:24
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.
void wall_qprop(LatticePropagator &wall_quark_prop, const LatticePropagator &quark_propagator, const SftMom &phases)
Construct a wall-sink propagator:
Definition: wall_qprop_w.cc:25
void Qll(const multi1d< LatticeColorMatrix > &u, const LatticePropagator &quark_prop1, const LatticePropagator &quark_prop2, const multi1d< int > &src_coord, const SftMom &phases, XMLWriter &xml, const std::string &xml_group)
Lambdaq and SigmaQ 2-pt functions.
Definition: barQll_w.cc:33
void Qlbar(const multi1d< LatticeColorMatrix > &u, const LatticePropagator &quark_propagator, const multi1d< int > &src_coord, const SftMom &phases, XMLWriter &xml, const std::string &xml_group, const int bc)
Heavy-light meson 2-pt function.
Definition: mesQl_w.cc:32
void proginfo(XMLWriter &xml)
Print out basic information about this program.
Definition: proginfo.cc:24
std::string makeXMLFileName(std::string xml_file, unsigned long update_no)
Return a xml file name for inline measurements.
void APE_Smear(const multi1d< LatticeColorMatrix > &u, LatticeColorMatrix &u_smear, int mu, int bl_level, const Real &sm_fact, const Real &BlkAccu, int BlkMax, int j_decay)
Construct APE smeared links from:
Definition: ape_smear.cc:44
int bc_spec
ForwardProp_t prop_header
Inline spectrum calculations.
Make xml file writer.
Heavy light meson (Qlbar) 2-pt function : Orginos and Savage.
Calculates the antihermitian field strength tensor iF(mu,nu)
int j_decay
Definition: meslate.cc:22
Nd
Definition: meslate.cc:74
Named object function std::map.
static bool registered
Local registration flag.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
Real getMass(const GroupXML_t &fermact)
Given a fermion action in std::string form, return the Mass.
Definition: qprop_io.cc:16
static multi1d< LatticeColorMatrix > u
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > & Mass
Definition: pbg5p_w.cc:29
push(xml_out,"Condensates")
int i
Definition: pbg5p_w.cc:55
void write(XMLWriter &xml, const std::string &path, const InlineSpectrumQllParams::NamedObject_t &input)
Propagator output.
multi1d< int > getFermActBoundary(const GroupXML_t &fermact)
Given a fermion action in std::string form, return the boundary.
Definition: qprop_io.cc:61
pop(xml_out)
void MesPlq(const multi1d< LatticeColorMatrixF3 > &u, multi2d< Double > &plane_plaq, Double &link)
Definition: mesplq.cc:83
START_CODE()
::std::string string
Definition: gtest.h:1979
Various parameter structs and reader/writers.
Print out basic info about this program.
Routines associated with Chroma propagator IO.
Fourier transform phase factor support.
Propagator parameters.
Definition: qprop_io.h:75
void write(XMLWriter &xml_out, const std::string &path)
struct Chroma::InlineSpectrumQllParams::NamedObject_t named_obj
struct Chroma::InlineSpectrumQllParams::Param_t param
Propagator source construction parameters.
Definition: qprop_io.h:27
Take the traceless antihermitian projection of a color matrix.
Construct a wall-sink propagator.