ATLAS Offline Software
DiffStruct.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "boost/lexical_cast.hpp"
8 
9 #include <iostream>
10 #include <fstream>
11 
12 using namespace std;
13 
14 TrigConf::DiffStruct::DiffStruct(const std::string& tagname, const std::string& name) :
16  name(name)
17 {}
18 
20  for(DiffStruct* d : subs)
21  delete d;
22 }
23 
24 
25 void
26 TrigConf::DiffStruct::check(const std::string& attname, const std::string& lval, const std::string& rval) {
27  if(lval!=rval) attdiffs.push_back(AttDiff(attname, lval, rval));
28 }
29 
30 void
31 TrigConf::DiffStruct::check(const std::string& attname, int lval, int rval) {
32  if(lval!=rval)
33  attdiffs.push_back(AttDiff(attname, boost::lexical_cast<string,int>(lval), boost::lexical_cast<string,int>(rval) ));
34 }
35 
36 void
37 TrigConf::DiffStruct::check(const std::string& attname, unsigned int lval, unsigned int rval) {
38  if(lval!=rval)
39  attdiffs.push_back(AttDiff(attname, boost::lexical_cast<string,unsigned int>(lval), boost::lexical_cast<string,unsigned int>(rval) ));
40 }
41 
42 void
43 TrigConf::DiffStruct::check(const std::string& attname, float lval, float rval) {
44  if(lval!=rval)
45  attdiffs.push_back(AttDiff(attname, boost::lexical_cast<string,float>(lval), boost::lexical_cast<string,float>(rval) ));
46 }
47 
48 void
49 TrigConf::DiffStruct::check(const std::string& attname, bool lval, bool rval) {
50  if(lval!=rval)
51  attdiffs.push_back(AttDiff(attname, boost::lexical_cast<string,bool>(lval), boost::lexical_cast<string,bool>(rval) ));
52 }
53 
54 void
56  if(sub) subs.push_back(sub);
57 }
58 
59 void
60 TrigConf::DiffStruct::addRightOnlySub(const string& tagname, const string& name) {
61  rightonly.insert( std::pair<string,string>(tagname, name) );
62 }
63 
64 void
65 TrigConf::DiffStruct::addLeftOnlySub(const string& tagname, const string& name) {
66  leftonly.insert( std::pair<string,string>(tagname, name) );
67 }
68 
69 bool
71  return attdiffs.size()==0 && subs.size()==0;
72 }
73 
74 
75 void
76 TrigConf::DiffStruct::writeXML(ofstream & xmlfile, const std::string& prefix) const {
77  if(empty()) return;
78  xmlfile << prefix << "<" << tagname;
79  if(name!="")
80  xmlfile << " name=\"" << name << "\"";
81  for(const AttDiff& d : attdiffs)
82  xmlfile << " " << d.attname << "_l=\"" << d.lval << "\" " << d.attname << "_r=\"" << d.rval << "\"";
83  if(subs.size()==0 && rightonly.size()==0 && leftonly.size()==0) {
84  xmlfile << "/>" << endl;
85  } else {
86  xmlfile << ">" << endl;
87  for(DiffStruct *d : subs)
88  d->writeXML(xmlfile, prefix+" ");
89  if(leftonly.size()>0) {
90  xmlfile << prefix << " <LEFT_ONLY>" << endl;
91  for(OnlyMap_t::value_type tag_name : leftonly)
92  xmlfile << prefix << " <" << tag_name.first << " name=\"" << tag_name.second << "\"/>" << endl;
93  xmlfile << prefix << " </LEFT_ONLY>" << endl;
94  }
95  if(rightonly.size()>0) {
96  xmlfile << prefix << " <RIGHT_ONLY>" << endl;
97  for(OnlyMap_t::value_type tag_name : rightonly)
98  xmlfile << prefix << " <" << tag_name.first << " name=\"" << tag_name.second << "\"/>" << endl;
99  xmlfile << prefix << " </RIGHT_ONLY>" << endl;
100  }
101  xmlfile << prefix << "</" << tagname << ">" << endl;
102  }
103 }
TrigConf::DiffStruct::AttDiff
Definition: DiffStruct.h:33
TrigConf::DiffStruct::writeXML
void writeXML(std::ofstream &xmlfile, const std::string &prefix="") const
Definition: DiffStruct.cxx:76
TrigConf::DiffStruct::DiffStruct
DiffStruct(const std::string &tagname, const std::string &name="")
Definition: DiffStruct.cxx:14
hist_file_dump.d
d
Definition: hist_file_dump.py:137
TrigConf::DiffStruct
Definition: DiffStruct.h:14
TrigConf::DiffStruct::addRightOnlySub
void addRightOnlySub(const std::string &tagname, const std::string &name)
Definition: DiffStruct.cxx:60
DiffStruct.h
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
TrigConf::DiffStruct::check
void check(const std::string &attname, const std::string &lval, const std::string &rval)
Definition: DiffStruct.cxx:26
defineDB.tagname
string tagname
Definition: JetTagCalibration/share/defineDB.py:19
TrigConf::DiffStruct::~DiffStruct
~DiffStruct()
Definition: DiffStruct.cxx:19
TrigConf::DiffStruct::addSub
void addSub(DiffStruct *sub)
Definition: DiffStruct.cxx:55
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
TrigConf::name
Definition: HLTChainList.h:35
TrigConf::DiffStruct::empty
bool empty() const
Definition: DiffStruct.cxx:70
tagname
Definition: tagname.h:29
TrigConf::DiffStruct::addLeftOnlySub
void addLeftOnlySub(const std::string &tagname, const std::string &name)
Definition: DiffStruct.cxx:65