CHROMA
inline_barspec_db_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline construction of hadron spectrum
3  *
4  * Spectrum calculations
5  */
6 
7 
8 #include "util/ferm/key_val_db.h"
10 
11 #include "inline_barspec_db_w.h"
13 #include "meas/glue/mesplq.h"
14 #include "util/ft/sftmom.h"
15 #include "util/info/proginfo.h"
16 #include "io/param_io.h"
17 #include "io/qprop_io.h"
18 #include "meas/hadron/mesons2_w.h"
19 #include "meas/hadron/barhqlq_w.h"
20 #include "meas/hadron/curcor2_w.h"
24 
25 #include <sstream>
26 
27 
28 namespace Chroma
29 {
30  namespace InlineBarSpecEnv
31  {
32  namespace
33  {
34  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
35  const std::string& path)
36  {
37  return new InlineMeas(Params(xml_in, path));
38  }
39 
40  //! Local registration flag
41  bool registered = false;
42 
43  const std::string name = "BARYON_DB_SPECTRUM";
44  }
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  void read(XMLReader& xml, const std::string& path, Params::SpinTerms_t& ter){
61  XMLReader paramtop(xml, path);
62  read(paramtop, "spin" ,ter.spin );
63  read(paramtop, "weight" ,ter.weight );
64  }
65 
66  void write(XMLWriter& xml, const std::string& path, const Params::SpinTerms_t& ter){
67  push(xml, path);
68  write(xml, "spin" ,ter.spin );
69  write(xml, "weight" ,ter.weight );
70  pop(xml);
71  }
72 
73  void read(XMLReader& xml, const std::string& path, Params::SpinWF_t& spWF){
74  XMLReader paramtop(xml, path);
75  read(paramtop, "norm" ,spWF.norm );
76  read(paramtop, "terms" ,spWF.terms );
77  }
78 
79 
80  void write(XMLWriter& xml,const std::string& path, const Params::SpinWF_t& spWF){
81  push(xml, path);
82  write(xml, "norm" ,spWF.norm );
83  write(xml, "terms" ,spWF.terms );
84  pop(xml);
85  }
86 
87 
88  void read(XMLReader& xml, const std::string& path, Params::Operators_t& op){
89  XMLReader paramtop(xml, path);
90  //QDPIO::cout<<"Reading Operators: "<<path<<std::endl ;
91  //xml.print(std::cout);
92  read(paramtop, "name" ,op.name );
93  read(paramtop, "spinWF" ,op.spinWF );
94  }
95 
96  void write(XMLWriter& xml, const std::string& path, const Params::Operators_t& op){
97  push(xml, path);
98  write(xml, "name" ,op.name );
99  write(xml, "spinWF" ,op.spinWF );
100  pop(xml);
101  }
102 
103  void read(XMLReader& xml,const std::string& path, Params::State_t& s){
104  XMLReader paramtop(xml, path);
105  //QDPIO::cout<<"Reading Operators: "<<path<<std::endl ;
106  //xml.print(std::cout);
107  read(paramtop, "name" ,s.name );
108  read(paramtop, "flavor" ,s.flavor );
109  read(paramtop, "db" ,s.db );
110  read(paramtop, "spin" ,s.spin );
111  read(paramtop, "Operators" ,s.ops );
112  }
113 
114  void write(XMLWriter& xml, const std::string& path, const Params::State_t& s){
115  push(xml, path);
116  write(xml, "name" ,s.name );
117  write(xml, "flavor" ,s.flavor );
118  write(xml, "db" ,s.db );
119  write(xml, "spin" ,s.spin );
120  write(xml, "Operators" ,s.ops );
121  pop(xml);
122  }
123 
124 
125 
126  //! Reader for parameters
127  void read(XMLReader& xml, const std::string& path, Params::Param_t& param)
128  {
129  XMLReader paramtop(xml, path);
130 
131  int version;
132  read(paramtop, "version", version);
133 
134  switch (version)
135  {
136  case 1:
137  break;
138 
139  default:
140  QDPIO::cerr << "Input parameter version " << version << " unsupported." << std::endl;
141  QDP_abort(1);
142  }
143 
144  //read(paramtop, "MesonP", param.MesonP);
145  //read(paramtop, "CurrentP", param.CurrentP);
146  //read(paramtop, "BaryonP", param.BaryonP);
147 
148  read(paramtop, "time_rev", param.time_rev);
149  read(paramtop, "mom2_max", param.mom2_max);
150  read(paramtop, "avg_equiv_mom", param.avg_equiv_mom);
151  read(paramtop, "ensemble", param.ensemble);
152  read(paramtop, "States", param.states);
153  }
154 
155 
156  //! Writer for parameters
157  void write(XMLWriter& xml, const std::string& path, const Params::Param_t& param)
158  {
159  push(xml, path);
160 
161  int version = 1;
162  write(xml, "version", version);
163 
164  //write(xml, "MesonP", param.MesonP);
165  //write(xml, "CurrentP", param.CurrentP);
166  //write(xml, "BaryonP", param.BaryonP);
167 
168  write(xml, "time_rev", param.time_rev);
169 
170  write(xml, "mom2_max", param.mom2_max);
171  write(xml, "avg_equiv_mom", param.avg_equiv_mom);
172  write(xml, "ensemble", param.ensemble);
173  write(xml, "States", param.states);
174 
175  pop(xml);
176  }
177 
178 
179 
180  //! Propagator input
181  void read(XMLReader& xml, const std::string& path, Params::NamedObject_t::Props_t& input)
182  {
183  XMLReader inputtop(xml, path);
184 
185  read(inputtop, "up_id", input.up_id);
186  if(inputtop.count("down_id")!=0)
187  read(inputtop, "down_id", input.down_id);
188  else
189  input.down_id = "NULL";
190  if(inputtop.count("strange_id")!=0)
191  read(inputtop, "strange_id", input.strange_id);
192  else
193  input.strange_id = "NULL";
194  if(inputtop.count("charm_id")!=0)
195  read(inputtop, "charm_id", input.charm_id);
196  else
197  input.charm_id = "NULL";
198  }
199 
200  //! Propagator output
201  void write(XMLWriter& xml, const std::string& path, const Params::NamedObject_t::Props_t& input)
202  {
203  push(xml, path);
204 
205  write(xml, "up_id", input.up_id);
206  write(xml, "down_id", input.down_id);
207  write(xml, "strange_id", input.strange_id);
208  write(xml, "charm_id", input.charm_id);
209 
210  pop(xml);
211  }
212 
213 
214  //! Propagator input
215  void read(XMLReader& xml, const std::string& path, Params::NamedObject_t& input)
216  {
217  XMLReader inputtop(xml, path);
218 
219  read(inputtop, "gauge_id" , input.gauge_id);
220  read(inputtop, "props" , input.props);
221  }
222 
223  //! Propagator output
224  void write(XMLWriter& xml, const std::string& path, const Params::NamedObject_t& input)
225  {
226  push(xml, path);
227  write(xml, "gauge_id" , input.gauge_id);
228  write(xml, "props" , input.props);
229  pop(xml);
230  }
231 
232 
233  // Param stuff
235  {
236  frequency = 0;
237  }
238 
239  Params::Params(XMLReader& xml_in, const std::string& path)
240  {
241  try
242  {
243  XMLReader paramtop(xml_in, path);
244 
245  if (paramtop.count("Frequency") == 1)
246  read(paramtop, "Frequency", frequency);
247  else
248  frequency = 1;
249 
250  // Parameters for source construction
251  read(paramtop, "Param", param);
252 
253  // Read in the output propagator/source configuration info
254  read(paramtop, "NamedObject", named_obj);
255 
256  // Possible alternate XML file pattern
257  if (paramtop.count("xml_file") != 0)
258  {
259  read(paramtop, "xml_file", xml_file);
260  }
261  }
262  catch(const std::string& e)
263  {
264  QDPIO::cerr << __func__ << ": Caught Exception reading XML: " << e << std::endl;
265  QDP_abort(1);
266  }
267  }
268 
269 
270  void
271  Params::writeXML(XMLWriter& xml_out, const std::string& path)
272  {
273  push(xml_out, path);
274 
275  write(xml_out, "Param", param);
276  write(xml_out, "NamedObject", named_obj);
277  write(xml_out, "xml_file", xml_file);
278 
279  pop(xml_out);
280  }
281 
282 
283  void epsilon_contract(LatticeComplex& res,
284  const multi2d<LatticeComplex>& l,
285  const multi2d<LatticeComplex>& m,
286  const multi2d<LatticeComplex>& r){
287  //LatticeComplex res = 0.0;
288 
289  //generated by : make_epsilon_contr.pl | sort
290 
291  res = l(0,0)*m(1,1)*r(2,2);
292  res -= l(0,0)*m(1,2)*r(2,1);
293  res -= l(0,0)*m(2,1)*r(1,2);
294  res += l(0,0)*m(2,2)*r(1,1);
295  res -= l(0,1)*m(1,0)*r(2,2);
296  res += l(0,1)*m(1,2)*r(2,0);
297  res += l(0,1)*m(2,0)*r(1,2);
298  res -= l(0,1)*m(2,2)*r(1,0);
299  res += l(0,2)*m(1,0)*r(2,1);
300  res -= l(0,2)*m(1,1)*r(2,0);
301  res -= l(0,2)*m(2,0)*r(1,1);
302  res += l(0,2)*m(2,1)*r(1,0);
303  res -= l(1,0)*m(0,1)*r(2,2);
304  res += l(1,0)*m(0,2)*r(2,1);
305  res += l(1,0)*m(2,1)*r(0,2);
306  res -= l(1,0)*m(2,2)*r(0,1);
307  res += l(1,1)*m(0,0)*r(2,2);
308  res -= l(1,1)*m(0,2)*r(2,0);
309  res -= l(1,1)*m(2,0)*r(0,2);
310  res += l(1,1)*m(2,2)*r(0,0);
311  res -= l(1,2)*m(0,0)*r(2,1);
312  res += l(1,2)*m(0,1)*r(2,0);
313  res += l(1,2)*m(2,0)*r(0,1);
314  res -= l(1,2)*m(2,1)*r(0,0);
315  res += l(2,0)*m(0,1)*r(1,2);
316  res -= l(2,0)*m(0,2)*r(1,1);
317  res -= l(2,0)*m(1,1)*r(0,2);
318  res += l(2,0)*m(1,2)*r(0,1);
319  res -= l(2,1)*m(0,0)*r(1,2);
320  res += l(2,1)*m(0,2)*r(1,0);
321  res += l(2,1)*m(1,0)*r(0,2);
322  res -= l(2,1)*m(1,2)*r(0,0);
323  res += l(2,2)*m(0,0)*r(1,1);
324  res -= l(2,2)*m(0,1)*r(1,0);
325  res -= l(2,2)*m(1,0)*r(0,1);
326  res += l(2,2)*m(1,1)*r(0,0);
327 
328  //return res ;
329  }
330 
331  // Anonymous namespace
332  namespace
333  {
334  //! Useful structure holding sink props
335  class SinkPropContainer_t{
336  public:
337  ForwardProp_t prop_header;
339  Real Mass;
340 
341  bool exists ;
342 
343  multi1d<int> bc;
344 
349 
350  SinkPropContainer_t(){
351  exists=false ;
352  }
353  //! Read a sink prop
354  void readSinkProp(const std::string& id)
355  {
356  if(id=="NULL"){
357  return ;
358  }
359  try
360  {
361  // Try a cast to see if it succeeds
362  const LatticePropagator& foo =
363  TheNamedObjMap::Instance().getData<LatticePropagator>(id);
364 
365  // Snarf the data into a copy
366  quark_propagator_id = id;
367 
368  exists = true ;
369  // Snarf the prop info. This is will throw if the prop_id is not there
370  XMLReader prop_file_xml, prop_record_xml;
371  TheNamedObjMap::Instance().get(id).getFileXML(prop_file_xml);
372  TheNamedObjMap::Instance().get(id).getRecordXML(prop_record_xml);
373 
374  // Try to invert this record XML into a ChromaProp struct
375  // Also pull out the id of this source
376  {
377  std::string xpath;
378  read(prop_record_xml, "/SinkSmear", prop_header);
379 
380  read(prop_record_xml, "/SinkSmear/PropSource/Source/SourceType", source_type);
381  xpath = "/SinkSmear/PropSource/Source/Displacement/DisplacementType";
382  if (prop_record_xml.count(xpath) != 0)
383  read(prop_record_xml, xpath, source_disp_type);
384  else
386 
387  read(prop_record_xml, "/SinkSmear/PropSink/Sink/SinkType", sink_type);
388  xpath = "/SinkSmear/PropSink/Sink/Displacement/DisplacementType";
389  if (prop_record_xml.count(xpath) != 0)
390  read(prop_record_xml, xpath, sink_disp_type);
391  else
393  }
394  }
395  catch( std::bad_cast )
396  {
397  QDPIO::cerr << name << ": caught dynamic cast error"
398  << std::endl;
399  QDP_abort(1);
400  }
401  catch (const std::string& e)
402  {
403  QDPIO::cerr << name << ": error message: " << e
404  << std::endl;
405  QDP_abort(1);
406  }
407 
408 
409  // Derived from input prop
410  // Hunt around to find the mass
411  // NOTE: this may be problematic in the future if actions are used with no
412  // clear def. of a Mass
413  QDPIO::cout << "Try action and mass" << std::endl;
414  Mass = getMass(prop_header.prop_header.fermact);
415 
416  // Only baryons care about boundaries
417  // Try to find them. If not present, assume dirichlet.
418  // This turns off any attempt to time reverse which is the
419  // only thing that the BC are affecting.
420  bc.resize(Nd);
421  bc = 0;
422 
423  try
424  {
425  bc = getFermActBoundary(prop_header.prop_header.fermact);
426  }
427  catch (const std::string& e)
428  {
429  QDPIO::cerr << name
430  << ": caught exception. No BC found in these headers. Will assume dirichlet: " << e
431  << std::endl;
432  }
433 
434  QDPIO::cout << "FermAct = " << prop_header.prop_header.fermact.id << std::endl;
435  QDPIO::cout << "Mass = " << Mass << std::endl;
436  }
437 
438  };
439 
440 
441 
442 
443 
444  void sanity_check_props(const SinkPropContainer_t& p1,
445  const SinkPropContainer_t& p2){
446 
447  int j_decay = p1.prop_header.source_header.j_decay;
448  if (p2.prop_header.source_header.j_decay !=
449  p1.prop_header.source_header.j_decay){
450  QDPIO::cerr << "Error!! j_decay must be the same for all propagators " << std::endl;
451  QDP_abort(1);
452  }
453  if (p2.prop_header.source_header.t_source !=
454  p1.prop_header.source_header.t_source)
455  {
456  QDPIO::cerr << "Error!! t_source must be the same for all propagators " << std::endl;
457  QDP_abort(1);
458  }
459  if (p1.source_type != p2.source_type)
460  {
461  QDPIO::cerr << "Error!! source_type must be the same in a pair " << std::endl;
462  QDP_abort(1);
463  }
464  if (p1.sink_type != p2.sink_type)
465  {
466  QDPIO::cerr << "Error!! source_type must be the same in a pair " << std::endl;
467  QDP_abort(1);
468  }
469 
470  if (p2.bc[j_decay] != p1.bc[j_decay])
471  {
472  QDPIO::cerr << "Error!! bc must be the same for all propagators " << std::endl;
473  QDP_abort(1);
474  }
475  }
476 
477 
478 
479 
480  //! Useful structure holding sink props
481  struct AllSinkProps_t
482  {
483  int j_decay;
484  int t0 ;
485  multi1d<int> t_srce ;
486  int bc_spec ;
487  std::map<std::string,SinkPropContainer_t> prop;
488  std::map<std::string,BarSpec::RPropagator> rprop;
489 
490  //! Read all sinks
491  AllSinkProps_t(const Params::NamedObject_t::Props_t& p){
492 
493  QDPIO::cout<<"Attempt to parse forward propagator= "<<p.up_id<<std::endl;
494  prop["up"].readSinkProp(p.up_id);
495  rprop[p.up_id].ConvertProp(TheNamedObjMap::Instance().getData<LatticePropagator>(p.up_id));
496  QDPIO::cout<<"up quark propagator successfully parsed" << std::endl;
497  j_decay = prop["up"].prop_header.source_header.j_decay;
498  t0 = prop["up"].prop_header.source_header.t_source;
499  t_srce = prop["up"].prop_header.source_header.getTSrce();
500  bc_spec = prop["up"].bc[j_decay];
501 
502  QDPIO::cout<<"Attempt to parse forward propagator= " <<p.down_id<<std::endl;
503  //Always need a down quark
504  prop["down"].readSinkProp(p.down_id);
505  QDPIO::cout << "down quark propagator successfully parsed" << std::endl;
506  if(rprop.find(p.down_id) == rprop.end()){
507  QDPIO::cout<<__func__<<": Need to convert prop id: "
508  <<p.down_id<<std::endl;
509  rprop[p.down_id].ConvertProp(TheNamedObjMap::Instance().getData<LatticePropagator>(p.down_id));
510  }
511  QDPIO::cout<<"Attempt to parse forward propagator= "<<p.strange_id<<std::endl;
512  prop["strange"].readSinkProp(p.strange_id);
513  if(p.strange_id != "NULL"){
514  QDPIO::cout <<"strange quark propagator successfully parsed" << std::endl;
515  if(rprop.find(p.strange_id) == rprop.end()){
516  QDPIO::cout<<__func__<<": Need to convert prop id: "
517  <<p.strange_id<<std::endl;
518  rprop[p.strange_id].ConvertProp(TheNamedObjMap::Instance().getData<LatticePropagator>(p.strange_id));
519  }
520  }
521 
522  QDPIO::cout<<"Attempt to parse forward propagator= "<<p.charm_id<<std::endl;
523  prop["charm"].readSinkProp(p.charm_id);
524  if(p.charm_id != "NULL"){
525  QDPIO::cout << "charm quark propagator successfully parsed" << std::endl;
526  if(rprop.find(p.charm_id) == rprop.end()){
527  QDPIO::cout<<__func__<<": Need to convert prop id: "
528  <<p.charm_id<<std::endl;
529  rprop[p.charm_id].ConvertProp(TheNamedObjMap::Instance().getData<LatticePropagator>(p.charm_id));
530  }
531  }
532 
533 
534  sanity_check_props(prop["up"], prop["down"]) ;
535  if(prop["strange"].exists)
536  sanity_check_props(prop["up"], prop["strange"]) ;
537  if(prop["charm"].exists)
538  sanity_check_props(prop["up"], prop["charm"]) ;
539 
540  }
541 
542 
543  std::string sink(const std::string& flavor){
544  return prop[flavor].sink_type ;
545  }
546 
547  std::string source(const std::string& flavor){
548  return prop[flavor].source_type ;
549  }
550 
551  const BarSpec::RPropagator& prop_ref(const std::string& flavor){
552 
553  return rprop[prop[flavor].quark_propagator_id] ;
554 
555  }
556 
557 
558  };
559 
560 
561 
562 
563  void xml_print_prop_info(XMLWriter& xml_out,
564  const SinkPropContainer_t& p,
565  const Set& s){
566 
567  // Sanity check - write out the norm2 of the forward prop
568  // Use this for any possible verification
569  if(p.exists){
570  push(xml_out, p.quark_propagator_id);
571  {
572  const LatticePropagator& prop =
573  TheNamedObjMap::Instance().getData<LatticePropagator>(p.quark_propagator_id);
574 
575  QDPIO::cout << "propagator_id = " << p.quark_propagator_id << std::endl;
576  QDPIO::cout << "Source_type = " << p.source_type << std::endl;
577  QDPIO::cout << "Sink_type = " << p.sink_type << std::endl;
578 
579  write(xml_out, "correlator",sumMulti(localNorm2(prop),s));
580  write(xml_out, "source_type", p.source_type);
581  write(xml_out, "source_disp_type", p.source_disp_type);
582  write(xml_out, "sink_type", p.sink_type);
583  write(xml_out, "sink_disp_type", p.sink_disp_type);
584  write(xml_out, "Mass", p.Mass);
585 
586  }
587  pop(xml_out);
588  }
589  }
590 
591 
592 
593  } // namespace anonymous
594 
595  namespace BarSpec{
596 
597  std::vector<int> permutation(int k, const std::vector<int>& s){
598  std::vector<int> p = s ;
599  int ss ;
600  int jj ;
601  for(int j(2); j<=s.size(); j++){
602  jj=k%j ;
603  ss=p[jj]; p[jj]=p[j-1]; p[j-1]=ss;
604  k=k/j ;
605  }
606  return p ;
607  }
608 
609  int permutation_sign(int k, int n){
610  int jj ;
611  int sign_(1) ;
612  for(int j(2); j<=n; j++){
613  jj=k%j ;
614  if(jj!=(j-1))
615  sign_ *= (-1) ;
616  k=k/j ;
617  }
618  return sign_ ;
619  }
620 
621  void contract(LatticeComplex& latC,
622  const RPropagator& q1,
623  const RPropagator& q2,
624  const RPropagator& q3,
625  const SpinWF_t& snk,
626  const SpinWF_t& src){
627  LatticeComplex cc ;
628  latC = 0.0;
629  for(int s(0);s<src.terms.size();s++)
630  for(int ss(0);ss<snk.terms.size();ss++){
631  epsilon_contract(cc,
632  q1.p(snk.terms[ss].spin[0],src.terms[s].spin[0]),
633  q2.p(snk.terms[ss].spin[1],src.terms[s].spin[1]),
634  q3.p(snk.terms[ss].spin[2],src.terms[s].spin[2]) );
635  latC += (snk.terms[ss].weight*src.terms[s].weight)*cc ;
636  }// loop over source sink wavefunction components
637  latC *= (snk.norm*src.norm) ;
638  }
639  }//barspec name space
640 
641 
642  // Function call
643  void
644  InlineMeas::operator()(unsigned long update_no,
645  XMLWriter& xml_out)
646  {
647  // If xml file not empty, then use alternate
648  if (params.xml_file != "")
649  {
650  std::string xml_file = makeXMLFileName(params.xml_file, update_no);
651 
652  push(xml_out, "barspec");
653  write(xml_out, "update_no", update_no);
654  write(xml_out, "xml_file", xml_file);
655  pop(xml_out);
656 
657  XMLFileWriter xml(xml_file);
658  func(update_no, xml);
659  }
660  else
661  {
662  func(update_no, xml_out);
663  }
664  }
665 
666 
667  // Real work done here
668  void
669  InlineMeas::func(unsigned long update_no,
670  XMLWriter& xml_out)
671  {
672  START_CODE();
673 
674  StopWatch snoop;
675  snoop.reset();
676  snoop.start();
677 
678  // Test and grab a reference to the gauge field
679  XMLBufferWriter gauge_xml;
680  try
681  {
682  TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
683  TheNamedObjMap::Instance().get(params.named_obj.gauge_id).getRecordXML(gauge_xml);
684  }
685  catch( std::bad_cast )
686  {
687  QDPIO::cerr << name << ": caught dynamic cast error"
688  << std::endl;
689  QDP_abort(1);
690  }
691  catch (const std::string& e)
692  {
693  QDPIO::cerr << name << ": std::map call failed: " << e
694  << std::endl;
695  QDP_abort(1);
696  }
697  const multi1d<LatticeColorMatrix>& u =
698  TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
699 
700  push(xml_out, "barspec");
701  write(xml_out, "update_no", update_no);
702 
703  QDPIO::cout << " BARSPEC: Spectroscopy for Wilson-like fermions" << std::endl;
704  QDPIO::cout << std::endl << " Gauge group: SU(" << Nc << ")" << std::endl;
705  QDPIO::cout << " volume: " << Layout::lattSize()[0];
706  for (int i=1; i<Nd; ++i) {
707  QDPIO::cout << " x " << Layout::lattSize()[i];
708  }
709  QDPIO::cout << std::endl;
710 
711  proginfo(xml_out); // Print out basic program info
712 
713  // Write out the input
714  params.writeXML(xml_out, "Input");
715 
716  // Write out the config info
717  write(xml_out, "Config_info", gauge_xml);
718 
719  push(xml_out, "Output_version");
720  write(xml_out, "out_version", 1);
721  pop(xml_out);
722 
723 
724  // First calculate some gauge invariant observables just for info.
725  MesPlq(xml_out, "Observables", u);
726 
727  //open the database
728  //
729  BinaryStoreDB< SerialDBKey<KeyHadron2PtCorr_t>, SerialDBData<multi1d<ComplexD> > > qdp_db;
730 
731 
732  // Now loop over the various fermion pairs
733  for(int p=0; p < params.named_obj.props.size(); ++p)
734  {
736 
737  push(xml_out, "elem");
738 
739  AllSinkProps_t all_sinks(params.named_obj.props[p]);
740 
741  // Derived from input prop
742  const multi1d<int>& t_srce = all_sinks.t_srce ;
743  const int& j_decay = all_sinks.j_decay ;
744  const int& t0 = all_sinks.t0 ;
745 
746  const int& bc_spec = all_sinks.bc_spec ;
747 
748 
749  // Initialize the slow Fourier transform phases
751  j_decay);
752 
753  // Keep a copy of the phases with NO momenta
754  SftMom phases_nomom(0, true, j_decay);
755 
756  write(xml_out, "t0", t0);
757 
758  // Save prop input
759  push(xml_out, "Forward_prop_headers");
760  write(xml_out, "up_prop", all_sinks.prop["up"].prop_header);
761  write(xml_out, "down_prop", all_sinks.prop["down"].prop_header);
762  if(all_sinks.prop["strange"].exists)
763  write(xml_out, "strange_prop", all_sinks.prop["strange"].prop_header);
764  if(all_sinks.prop["charm"].exists)
765  write(xml_out, "charm_prop", all_sinks.prop["charm"].prop_header);
766 
767  pop(xml_out);
768 
769  push(xml_out, "Forward_Propagator_Properties" );
770  std::map<std::string,SinkPropContainer_t>::iterator it;
771  for(it=all_sinks.prop.begin();it!=all_sinks.prop.end();it++)
772  xml_print_prop_info(xml_out, it->second , phases.getSet() );
773 
774  pop(xml_out);
775 
776  int Nt = Layout::lattSize()[j_decay];
777 
778  LatticeComplex latC ;
779  StopWatch tictoc;
780  tictoc.reset();
781  tictoc.start();
782  for(int s(0);s<params.param.states.size();s++){
783  QDPIO::cout<<"Doing state "<<params.param.states[s].name<<std::endl;
784  QDPIO::cout<<" Flavor structure: " ;
785  for(int k(0);k<params.param.states[s].flavor.size();k++)
786  QDPIO::cout<<" "<<params.param.states[s].flavor[k] ;
787  QDPIO::cout<<std::endl;
788  multi1d<std::string> prop_id(params.param.states[s].flavor.size()) ;
789  for(int k(0);k<params.param.states[s].flavor.size();k++){
790  prop_id[k] = params.param.states[s].flavor[k] ;
791  }
792  // Open the file, and write the meta-data and the binary for this state
793  if (! qdp_db.fileExists(params.param.states[s].db)){
794  XMLBufferWriter file_xml;
795 
796  push(file_xml, "DBMetaData");
797  write(file_xml, "id", std::string("hadron2Pt"));
798  write(file_xml, "lattSize", QDP::Layout::lattSize());
799  write(file_xml, "decay_dir", j_decay);
800  write(file_xml, "State", params.param.states[s].name);
801  proginfo(file_xml); // Print out basic program info
802  write(file_xml, "Params", params.param);
803  write(file_xml, "Config_info", gauge_xml);
804  pop(file_xml);
805 
806  std::string file_str(file_xml.str());
807  qdp_db.setMaxUserInfoLen(file_str.size());
808  qdp_db.open(params.param.states[s].db, O_RDWR | O_CREAT, 0664);
809  qdp_db.insertUserdata(file_str);
810  }
811  else
812  {
813  qdp_db.open(params.param.states[s].db, O_RDWR, 0664);
814  }
815 
816 
817  // References for use later
818  const BarSpec::RPropagator& q1 = all_sinks.prop_ref(prop_id[0]) ;
819  const BarSpec::RPropagator& q2 = all_sinks.prop_ref(prop_id[1]) ;
820  const BarSpec::RPropagator& q3 = all_sinks.prop_ref(prop_id[2]) ;
821 
822  KeyHadron2PtCorr_t key ;
823 
824  std::ostringstream os ;
825  os<<all_sinks.prop[prop_id[0]].Mass<<" ";
826  os<<all_sinks.prop[prop_id[1]].Mass<<" ";
827  os<<all_sinks.prop[prop_id[2]].Mass ;
828  key.mass = os.str();
830  key.num_vecs = Nc; /*!< Number of color vectors */
831 
832  key.src_smear = all_sinks.source(prop_id[0])+" ";
833  key.src_smear += all_sinks.source(prop_id[1])+" ";
834  key.src_smear += all_sinks.source(prop_id[2]) ;
835  key.src_spin = params.param.states[s].spin ;
836  key.src_lorentz.resize(0);
837  //key.src_lorentz = key.src_spin ;
838 
839  key.snk_smear = all_sinks.sink(prop_id[0])+" ";
840  key.snk_smear += all_sinks.sink(prop_id[1])+" ";
841  key.snk_smear += all_sinks.sink(prop_id[2]) ;
842  key.snk_spin = params.param.states[s].spin ;
843  key.snk_lorentz.resize(0);
844  //key.snk_lorentz = key.snk_spin ;
845 
846  //loop over momenta goes here
847  for(int oi(0);oi<params.param.states[s].ops.size();oi++){ //sink
848  BarSpec::SpinWF_t snk(params.param.states[s].ops[oi].spinWF);
849  snk.permutations(prop_id);
850  for(int oj(0);oj<params.param.states[s].ops.size();oj++){//source
851 
852  BarSpec::SpinWF_t src(params.param.states[s].ops[oj].spinWF);
853 
854  key.src_name = params.param.states[s].ops[oj].name;
855  key.snk_name = params.param.states[s].ops[oi].name;
856 
857  BarSpec::contract(latC,q1,q2,q3,snk,src);
858 
859  multi2d<ComplexD> hsum;
860  hsum = phases.sft(latC) ;
861 
862  for(int mom(0);mom<phases.numMom();mom++){
863  key.mom = phases.numToMom(mom); /*<! Momentum */
865  K.key() = key ;
867  V.data().resize(Nt);
868  for(int t(0);t<Nt;t++){
869  int t_eff = (t - t0 + Nt) % Nt;
870  if ( bc_spec < 0 && (t_eff+t0) >= Nt)
871  V.data()[t_eff] = -hsum[mom][t];
872  else
873  V.data()[t_eff] = hsum[mom][t];
874  }//loop over time
875  qdp_db.insert(K,V);
876  }// loop over momenta
877 
878  }// loop over source ops
879  }// loop over sink ops
880  qdp_db.close() ;
881  }// loop over states
882  tictoc.stop();
883  QDPIO::cout << name << ": contraction time = "
884  << tictoc.getTimeInSeconds()
885  << " secs" << std::endl;
886 
887  pop(xml_out); //elem
888  }// loop over propagator groups
889  pop(xml_out); // barspec
890 
891  snoop.stop();
892  QDPIO::cout << name << ": total time = "
893  << snoop.getTimeInSeconds()
894  << " secs" << std::endl;
895 
896  QDPIO::cout << name << ": ran successfully" << std::endl;
897 
898  END_CODE();
899  }
900 
901  }
902 
903 }
Inline measurement factory.
Heavy-light baryon 2-pt functions.
void permutations(const multi1d< std::string > &flavor)
std::vector< Params::SpinTerms_t > terms
Inline measurement of hadron spectrum.
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.
Serializable value harness.
Definition: key_val_db.h:69
D & data()
Setter.
Definition: key_val_db.h:78
Serializable key harness.
Definition: key_val_db.h:21
Fourier transform phase factor support.
Definition: sftmom.h:35
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
const Set & getSet() const
The set to be used in sumMulti.
Definition: sftmom.h:57
static T & Instance()
Definition: singleton.h:432
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.
std::string source_disp_type
int bc_spec
int j_decay
multi1d< int > bc
std::string source_type
bool exists
std::string quark_propagator_id
std::map< std::string, BarSpec::RPropagator > rprop
std::map< std::string, SinkPropContainer_t > prop
multi1d< int > t_srce
std::string sink_type
ForwardProp_t prop_header
std::string sink_disp_type
Inline hadron spectrum calculations.
Hadron 2pt correlators.
Key and values for DB.
unsigned j
Definition: ldumul_w.cc:35
unsigned n
Definition: ldumul_w.cc:36
static int m[4]
Definition: make_seeds.cc:16
Make xml file writer.
int it
Definition: meslate.cc:33
int t
Definition: meslate.cc:37
Nd
Definition: meslate.cc:74
Meson 2-pt functions.
Named object function std::map.
static bool registered
Local registration flag.
const std::string name
Name to be used.
std::vector< int > permutation(int k, const std::vector< int > &s)
void contract(LatticeComplex &latC, const RPropagator &q1, const RPropagator &q2, const RPropagator &q3, const SpinWF_t &snk, const SpinWF_t &src)
bool registerAll()
Register all the factories.
void write(XMLWriter &xml, const std::string &path, const Params::SpinTerms_t &ter)
void read(XMLReader &xml, const std::string &path, Params::SpinTerms_t &ter)
void epsilon_contract(LatticeComplex &res, const multi2d< LatticeComplex > &l, const multi2d< LatticeComplex > &m, const multi2d< LatticeComplex > &r)
std::string getName()
Return the name.
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
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()
int k
Definition: invbicg.cc:119
multi1d< LatticeFermion > s(Ncb)
::std::string string
Definition: gtest.h:1979
No quark displacement.
int l
Definition: pade_trln_w.cc:111
Various parameter structs and reader/writers.
Print out basic info about this program.
Routines associated with Chroma propagator IO.
Fourier transform phase factor support.
void writeXML(XMLWriter &xml_out, const std::string &path)
struct Chroma::InlineBarSpecEnv::Params::Param_t param
struct Chroma::InlineBarSpecEnv::Params::NamedObject_t named_obj
Key for Hadron 2pt corr.
static INTERNAL_PRECISION K