CHROMA
inline_qnaive.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Inline naive topological charge
3  *
4  * Author: Christian Hagen
5  */
6 
9 #include "meas/glue/qnaive.h"
11 
14 
15 
16 namespace Chroma
17 {
18 
19  namespace InlineQTopEnv
20  {
21  namespace
22  {
23  AbsInlineMeasurement* createMeasurement(XMLReader& xml_in,
24  const std::string& path)
25  {
26  Params p(xml_in, path);
27  return new InlineMeas(p);
28  }
29 
30  //! Local registration flag
31  bool registered = false;
32 
33  const std::string name = "QTOP_NAIVE";
34  }
35 
36  //! Register all the factories
37  bool registerAll()
38  {
39  bool success = true;
40  if (! registered)
41  {
43  success &= TheInlineMeasurementFactory::Instance().registerObject(name, createMeasurement);
44  registered = true;
45  }
46  return success;
47  }
48 
49 
50  //! QTop input
51  void read(XMLReader& xml, const std::string& path, Params::Param_t& param)
52  {
53  XMLReader paramtop(xml, path);
54 
55  int version;
56  read(paramtop, "version", version);
57 
58  switch (version)
59  {
60  case 1:
61  if (paramtop.count("GaugeState") != 0)
62  param.cgs = readXMLGroup(paramtop, "GaugeState", "Name");
63  else
65  break;
66 
67  default:
68  QDPIO::cerr << "Params::Param_t: " << version
69  << " unsupported." << std::endl;
70  QDP_abort(1);
71  }
72 
73  read(paramtop, "k5", param.k5);
74  }
75 
76  //! QTop output
77  void write(XMLWriter& xml, const std::string& path, const Params::Param_t& param)
78  {
79  push(xml, path);
80 
81  int version = 1;
82  write(xml, "version", version);
83  xml << param.cgs.xml;
84  write(xml, "k5", param.k5);
85 
86  pop(xml);
87  }
88 
89 
90  //! QTop input
91  void read(XMLReader& xml, const std::string& path, Params::NamedObject_t& input)
92  {
93  XMLReader inputtop(xml, path);
94 
95  read(inputtop, "gauge_id", input.gauge_id);
96  }
97 
98  //! QTop output
99  void write(XMLWriter& xml, const std::string& path, const Params::NamedObject_t& input)
100  {
101  push(xml, path);
102 
103  write(xml, "gauge_id", input.gauge_id);
104 
105  pop(xml);
106  }
107 
108 
109  // Params
111  {
112  frequency = 0;
114  }
115 
116  Params::Params(XMLReader& xml_in, const std::string& path)
117  {
118  try
119  {
120  XMLReader paramtop(xml_in, path);
121 
122  if (paramtop.count("Frequency") == 1)
123  read(paramtop, "Frequency", frequency);
124  else
125  frequency = 1;
126 
127  // Params
128  read(paramtop, "Param", param);
129 
130  // Ids
131  read(paramtop, "NamedObject", named_obj);
132  }
133  catch(const std::string& e)
134  {
135  QDPIO::cerr << "Caught Exception reading XML: " << e << std::endl;
136  QDP_abort(1);
137  }
138  }
139 
140  //NEEDS CHANGES
141  void
142  InlineMeas::operator()(unsigned long update_no,
143  XMLWriter& xml_out)
144  {
145  START_CODE();
146 
147  // Grab the object
148  const multi1d<LatticeColorMatrix>& u =
149  TheNamedObjMap::Instance().getData< multi1d<LatticeColorMatrix> >(params.named_obj.gauge_id);
150 
151  push(xml_out, "QTop");
152  write(xml_out, "update_no", update_no);
153  write(xml_out, "k5", params.param.k5);
154 
155  Double qtop;
157 
158  write(xml_out, "qtop", qtop);
159 
160  pop(xml_out); // pop("QTop");
161 
162  END_CODE();
163  }
164 
165  }
166 
167 }
Inline measurement factory.
void operator()(unsigned long update_no, XMLWriter &xml_out)
Do the measurement.
static T & Instance()
Definition: singleton.h:432
All gauge create-state method.
Gauge create state factory.
void qtop_naive(const multi1d< LatticeColorMatrix > &u, const Real k5, Double &qtop)
Compute topological charge.
Definition: qnaive.cc:24
GroupXML_t readXMLGroup(XMLReader &xml_in, const std::string &path, const std::string &type_name)
Read group and return as a std::string.
Inline naive topological charge.
Double qtop
Definition: meslate.cc:24
Named object function std::map.
static bool registered
Local registration flag.
const std::string name
Name to be used.
bool registerAll()
Register all the factories.
GroupXML_t nullXMLGroup()
Returns a simple createstate group.
bool registerAll()
Register all the factories.
void read(XMLReader &xml, const std::string &path, Params::Param_t &param)
QTop input.
void write(XMLWriter &xml, const std::string &path, const Params::Param_t &param)
QTop output.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
push(xml_out,"Condensates")
pop(xml_out)
START_CODE()
FloatingPoint< double > Double
Definition: gtest.h:7351
::std::string string
Definition: gtest.h:1979
Calculate the topological charge from the gluonic definition.
struct Chroma::InlineQTopEnv::Params::Param_t param
struct Chroma::InlineQTopEnv::Params::NamedObject_t named_obj