ATLAS Offline Software
Loading...
Searching...
No Matches
IdDictParserNS::RegionFactory Class Reference
Inheritance diagram for IdDictParserNS::RegionFactory:
Collaboration diagram for IdDictParserNS::RegionFactory:

Public Member Functions

void idd_start (IdDictParser &parser, const XMLCoreNode &node)
void idd_end (IdDictParser &parser, const XMLCoreNode &node)
void do_start (XMLCoreParser &parser, const XMLCoreNode &node)
void do_end (XMLCoreParser &parser, const XMLCoreNode &node)
void start (XMLCoreParser &parser, const XMLCoreNode &node)
void end (XMLCoreParser &parser, const XMLCoreNode &node)
void comment (XMLCoreParser &parser, const std::string &comment)
virtual void do_comment (XMLCoreParser &parser, const std::string &comment)
std::string get_name (const XMLCoreNode &node)
int sibling_number (const XMLCoreNode &node)

Static Public Member Functions

static std::string get_name (const XMLCoreNode &node, int index)
static int attribute_number (const XMLCoreNode &node)
static bool has_attribute (const XMLCoreNode &node, const std::string &name)
static int get_int (const XMLCoreNode &node, const std::string &name)
static double get_double (const XMLCoreNode &node, const std::string &name)
static bool get_boolean (const XMLCoreNode &node, const std::string &name)
static std::string get_ID (const XMLCoreNode &node, const std::string &name)
static std::string get_value (const XMLCoreNode &node, const std::string &name)
static std::string get_token (const XMLCoreNode &node, const std::string &name)
static bool check_int (const int n, const XMLCoreNode &node, const std::string &name)
static bool check_double (const int n, const XMLCoreNode &node, const std::string &name)

Protected Attributes

std::string m_xmlelementname

Detailed Description

Definition at line 80 of file IdDictParser.cxx.

Member Function Documentation

◆ attribute_number()

int XMLCoreFactory::attribute_number ( const XMLCoreNode & node)
staticinherited

Definition at line 111 of file XMLCoreParser.cxx.

111 {
112 const CoreParser::DOMNamedNodeMap& attrs = node.get_node ().get_attributes();
113 return (attrs.size ());
114}
std::map< std::string, std::string > DOMNamedNodeMap
Definition DOMNode.h:16

◆ check_double()

bool XMLCoreFactory::check_double ( const int n,
const XMLCoreNode & node,
const std::string & name )
staticinherited

Definition at line 239 of file XMLCoreParser.cxx.

239 {
240 std::string checkstring = get_value (node, name);
241 int counter = 0;
242 //
243 // concatenate two times same string to
244 // check the last number of the string
245 // explicitly!
246 //
247 std::string t = checkstring + " " + checkstring;
248 std::istringstream tmpstr (t.c_str());
249 while (tmpstr.good ()) {
250 double ii{};
251 counter++;
252 tmpstr >> ii;
253 }
254 if (counter/2 != n) {
255 std::cerr << "XMLCoreFactory::check_double error: (" << counter << ") no " << n
256 << " doubles in \"" << checkstring << "\" for attribute " <<
257 name << ". exit." << std::endl;
258 std::string name1 = get_value (node, "name");
259 std::string volume = get_value (node, "volume");
260 if (name1 != "" ) std::cerr << "for name=" << name << std::endl;
261 if (volume != "" ) std::cerr << "for volume=" << volume << std::endl;
262 std::abort();
263 }
264 return true;
265}
static std::string get_value(const XMLCoreNode &node, const std::string &name)

◆ check_int()

bool XMLCoreFactory::check_int ( const int n,
const XMLCoreNode & node,
const std::string & name )
staticinherited

Definition at line 207 of file XMLCoreParser.cxx.

207 {
208 std::string checkstring = get_value (node, name);
209 int counter = 0;
210 //
211 // concatenate two times same string to
212 // check the last number of the string
213 // explicitly!
214 //
215 std::string t = checkstring + " " + checkstring;
216 std::istringstream tmpstr (t.c_str());
217 while (tmpstr.good ()) {
218 int ii;
219 counter++;
220 tmpstr >> ii;
221 }
222 if (counter/2 != n) {
223 std::cerr << "XMLCoreFactory::check_int error: no " << n
224 << " ints in \"" << checkstring << "\" for attribute " <<
225 name << ". exit." << std::endl;
226
227 std::string nodename = get_value (node, "name");
228 std::string volume = get_value (node, "volume");
229
230 if (nodename != "" ) std::cerr << "for name=" << nodename << std::endl;
231 if (volume != "" ) std::cerr << "for volume=" << volume << std::endl;
232
233 std::abort();
234 }
235 return true;
236}

◆ comment()

void XMLCoreFactory::comment ( XMLCoreParser & parser,
const std::string & comment )
inherited

Definition at line 82 of file XMLCoreParser.cxx.

82 {
83 if (XMLCoreParserDebugger::debug ()){
84 std::cout << "XMLCoreFactory::comment>" << std::endl;
85 }
86 do_comment (parser,comment);
87}
virtual void do_comment(XMLCoreParser &parser, const std::string &comment)
void comment(XMLCoreParser &parser, const std::string &comment)

◆ do_comment()

void XMLCoreFactory::do_comment ( XMLCoreParser & parser,
const std::string & comment )
virtualinherited

Definition at line 104 of file XMLCoreParser.cxx.

104 {
105 if (XMLCoreParserDebugger::debug ()){
106 std::cout << "XMLCoreFactory::do_comment>" << std::endl;
107 }
108}

◆ do_end()

void IdDictBaseFactory::do_end ( XMLCoreParser & parser,
const XMLCoreNode & node )
virtualinherited

Reimplemented from XMLCoreFactory.

Definition at line 157 of file IdDictParser.cxx.

157 {
158 idd_end (static_cast<IdDictParser&>(parser), node);
159 parser.down ();
160}
virtual void idd_end(IdDictParser &parser, const XMLCoreNode &node)

◆ do_start()

void IdDictBaseFactory::do_start ( XMLCoreParser & parser,
const XMLCoreNode & node )
virtualinherited

Reimplemented from XMLCoreFactory.

Definition at line 150 of file IdDictParser.cxx.

151 {
152 parser.up ();
153 idd_start (static_cast<IdDictParser&>(parser), node);
154}
virtual void idd_start(IdDictParser &parser, const XMLCoreNode &node)

◆ end()

void XMLCoreFactory::end ( XMLCoreParser & parser,
const XMLCoreNode & node )
inherited

Definition at line 74 of file XMLCoreParser.cxx.

74 {
75 if (XMLCoreParserDebugger::debug ()){
76 std::cout << "XMLCoreFactory::end>" << std::endl;
77 }
78 do_end (parser, node);
79}
virtual void do_end(XMLCoreParser &parser, const XMLCoreNode &node)

◆ get_boolean()

bool XMLCoreFactory::get_boolean ( const XMLCoreNode & node,
const std::string & name )
staticinherited

Definition at line 141 of file XMLCoreParser.cxx.

141 {
142 bool result = false;
143 std::string s = get_token (node, name);
144 if (s == "TRUE") result = true;
145 return (result);
146}
static std::string get_token(const XMLCoreNode &node, const std::string &name)

◆ get_double()

double XMLCoreFactory::get_double ( const XMLCoreNode & node,
const std::string & name )
staticinherited

Definition at line 133 of file XMLCoreParser.cxx.

133 {
134 double result = 0;
135 std::string s = get_value (node, name);
136 sscanf (s.c_str (), "%80lg", &result);
137 return (result);
138}

◆ get_ID()

std::string XMLCoreFactory::get_ID ( const XMLCoreNode & node,
const std::string & name )
staticinherited

Definition at line 148 of file XMLCoreParser.cxx.

148 {
149 std::string result = get_value (node, name);
150 return (result);
151}

◆ get_int()

int XMLCoreFactory::get_int ( const XMLCoreNode & node,
const std::string & name )
staticinherited

Definition at line 125 of file XMLCoreParser.cxx.

125 {
126 int result = 0;
127 std::string s = get_value (node, name);
128 sscanf (s.c_str (), "%80d", &result);
129 return (result);
130}

◆ get_name() [1/2]

std::string XMLCoreFactory::get_name ( const XMLCoreNode & node)
inherited

Definition at line 169 of file XMLCoreParser.cxx.

169 {
170 return node.get_node().get_name ();
171}

◆ get_name() [2/2]

std::string XMLCoreFactory::get_name ( const XMLCoreNode & node,
int index )
staticinherited

Definition at line 179 of file XMLCoreParser.cxx.

179 {
180 const CoreParser::DOMNamedNodeMap& attrs = node.get_node ().get_attributes();
181 CoreParser::DOMNamedNodeMap::const_iterator it;
182 for (it = attrs.begin (); (index > 0) && (it != attrs.end ()); ++it){
183 --index;
184 }
185 if (it == attrs.end ()) return ("");
186 return it->first;
187}
str index
Definition DeMoScan.py:362

◆ get_token()

std::string XMLCoreFactory::get_token ( const XMLCoreNode & node,
const std::string & name )
staticinherited

Definition at line 190 of file XMLCoreParser.cxx.

190 {
191 std::string result = get_value (node, name);
192 // trim the value
193 while ((result.length () > 0) &&
194 (result.at(0) == ' ')) result.erase (0, 1);
195
196 while ((result.length () > 0) &&
197 (result.at(result.length () - 1) == ' ')) result.erase (result.length () - 1, 1);
198 // Convert to upper case
199 for (std::string::size_type i = 0; i < result.length (); ++i){
200 result[i] = std::toupper (result[i]);
201 }
202 return (result);
203}

◆ get_value()

std::string XMLCoreFactory::get_value ( const XMLCoreNode & node,
const std::string & name )
staticinherited

Definition at line 154 of file XMLCoreParser.cxx.

154 {
155 if (XMLCoreParserDebugger::debug ()){
156 std::cout << "XMLCoreFactory::get_value> name=" << name << std::endl;
157 }
158 const CoreParser::DOMNamedNodeMap& attrs = node.get_node ().get_attributes();
159 CoreParser::DOMNamedNodeMap::const_iterator it = attrs.find (name);
160 if (it == attrs.end ()) return ("");
161 std::string result = (*it).second;
162 if (XMLCoreParserDebugger::debug ()) {
163 std::cout << "XMLCoreFactory::get_value>2 value=" << result << std::endl;
164 }
165 return (result);
166}

◆ has_attribute()

bool XMLCoreFactory::has_attribute ( const XMLCoreNode & node,
const std::string & name )
staticinherited

Definition at line 117 of file XMLCoreParser.cxx.

117 {
118 const CoreParser::DOMNamedNodeMap& attrs = node.get_node ().get_attributes();
119 CoreParser::DOMNamedNodeMap::const_iterator it = attrs.find (name);
120 if (it == attrs.end ()) return (false);
121 return (true);
122}

◆ idd_end()

void RegionFactory::idd_end ( IdDictParser & parser,
const XMLCoreNode & node )
virtual

Reimplemented from IdDictParserNS::IdDictBaseFactory.

Definition at line 427 of file IdDictParser.cxx.

427 {
428 if (Debugger::debug ()){
429 Debugger::tab (parser.level());
430 std::cout << "RegionFactory::idd_end>" << std::endl;
431 }
432 if (parser.m_region != 0){
433 if (parser.m_dictionary != 0) parser.m_dictionary->add_region (parser.m_region.get());
434 // Check whether region is empty, i.e. no region entries have
435 // been found and added
436 if (parser.m_region->n_entries() == 0) {
437 parser.m_region->set_is_empty();
438 }
439
440 if (parser.m_altregions != 0) {
441 parser.m_altregions->add_region (std::move(parser.m_region));
442 } else if (parser.m_dictionary != 0) {
443 parser.m_dictionary->add_dictentry (std::move(parser.m_region));
444 } else {
445 parser.m_region.reset();
446 }
447 }
448}
static void tab(int n)

◆ idd_start()

void RegionFactory::idd_start ( IdDictParser & parser,
const XMLCoreNode & node )
virtual

Reimplemented from IdDictParserNS::IdDictBaseFactory.

Definition at line 295 of file IdDictParser.cxx.

295 {
296 if (Debugger::debug ()) {
297 Debugger::tab (parser.level());
298 std::cout << "RegionFactory::idd_start>" << std::endl;
299 }
300
301 parser.m_region = std::make_unique<IdDictRegion> (get_value (node, "name"),
302 get_value (node, "group"),
303 get_value (node, "tag"));
304
305 // check for next region in absolute eta
306 if (has_attribute (node, "next_abs_eta")) {
307 parser.m_region->set_next_abs_eta_name (get_value (node, "next_abs_eta"));
308 }
309
310 // Look for regions in the previous sampling
311 if (has_attribute (node, "prev_samp")) {
312 std::string names = get_value (node, "prev_samp");
313 std::string::size_type pos = 0;
314 for (;;) {
315 std::string::size_type next;
316 next = names.find_first_not_of (" ", pos);
317 if (next == std::string::npos) break;
318 pos = next;
319 next = names.find_first_of (" ", pos);
320 std::string name;
321 name = names.substr (pos, next - pos);
322 parser.m_region->add_prev_samp_name (name);
323 if (next == std::string::npos) {
324 break;
325 } else {
326 pos = next;
327 }
328 }
329 }
330 // Look for regions in the next sampling
331 if (has_attribute (node, "next_samp")) {
332 std::string names = get_value (node, "next_samp");
333 std::string::size_type pos = 0;
334 for (;;) {
335 std::string::size_type next;
336
337 next = names.find_first_not_of (" ", pos);
338 if (next == std::string::npos) break;
339 pos = next;
340 next = names.find_first_of (" ", pos);
341
342 std::string name;
343 name = names.substr (pos, next - pos);
344 parser.m_region->add_next_samp_name (name);
345
346 if (next == std::string::npos) {
347 break;
348 } else {
349 pos = next;
350 }
351 }
352 }
353 // Look for regions in the prev subdet
354 if (has_attribute (node, "prev_subdet")) {
355 std::string names = get_value (node, "prev_subdet");
356 std::string::size_type pos = 0;
357 for (;;) {
358 std::string::size_type prev;
359 prev = names.find_first_not_of (" ", pos);
360 if (prev == std::string::npos) break;
361 pos = prev;
362 prev = names.find_first_of (" ", pos);
363 std::string name;
364 name = names.substr (pos, prev - pos);
365 parser.m_region->add_prev_subdet_name (name);
366 if (prev == std::string::npos) {
367 break;
368 } else {
369 pos = prev;
370 }
371 }
372 }
373 // Look for regions in the next subdet
374 if (has_attribute (node, "next_subdet")) {
375 std::string names = get_value (node, "next_subdet");
376 std::string::size_type pos = 0;
377 for (;;) {
378 std::string::size_type next;
379 next = names.find_first_not_of (" ", pos);
380 if (next == std::string::npos) break;
381 pos = next;
382 next = names.find_first_of (" ", pos);
383 std::string name;
384 name = names.substr (pos, next - pos);
385 parser.m_region->add_next_subdet_name (name);
386 if (next == std::string::npos) {
387 break;
388 } else {
389 pos = next;
390 }
391 }
392 }
393
394 parser.m_region->set_etaphi (get_double (node, "eta0"),
395 get_double (node, "deta"),
396 get_double (node, "phi0"),
397 get_double (node, "dphi"));
398
399 if (Debugger::debug ()) {
400 Debugger::tab (parser.level());
401 std::cout << "RegionFactory::idd_start> name, group, tag, next eta, prev/next samp, prev/next subdet "
402 << parser.m_region->name() << " "
403 << parser.m_region->group_name() << " "
404 << parser.m_region->tag() << " "
405 << parser.m_region->next_abs_eta() << " ";
406 for (const std::string& s : parser.m_region->prev_samp_names()) {
407 std::cout << s << " ";
408 }
409 for (const std::string& s : parser.m_region->next_samp_names()) {
410 std::cout << s << " ";
411 }
412 for (const std::string& s : parser.m_region->prev_subdet_names()) {
413 std::cout << s << " ";
414 }
415 for (const std::string& s : parser.m_region->next_subdet_names()) {
416 std::cout << s << " ";
417 }
418 std::cout << parser.m_region->eta0() << " "
419 << parser.m_region->deta() << " "
420 << parser.m_region->phi0() << " "
421 << parser.m_region->dphi() << " "
422 << std::endl;
423 }
424}
static bool has_attribute(const XMLCoreNode &node, const std::string &name)
static double get_double(const XMLCoreNode &node, const std::string &name)

◆ sibling_number()

int XMLCoreFactory::sibling_number ( const XMLCoreNode & node)
inherited

Definition at line 174 of file XMLCoreParser.cxx.

174 {
175 return node.get_node ().sibling_number ();
176}

◆ start()

void XMLCoreFactory::start ( XMLCoreParser & parser,
const XMLCoreNode & node )
inherited

Definition at line 66 of file XMLCoreParser.cxx.

66 {
67 if (XMLCoreParserDebugger::debug ()){
68 std::cout << "XMLCoreFactory::start> factory=" << this << std::endl;
69 }
70 do_start (parser, node);
71}
virtual void do_start(XMLCoreParser &parser, const XMLCoreNode &node)

Member Data Documentation

◆ m_xmlelementname

std::string XMLCoreFactory::m_xmlelementname
protectedinherited

Definition at line 94 of file XMLCoreParser.h.


The documentation for this class was generated from the following file: