ATLAS Offline Software
MuctpiXMLParser.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // libraries
12 
13 
14 // cpp libraries
15 #include <iostream>
16 #include <vector>
17 #include <string>
18 #include <stdlib.h>
19 #include <boost/lexical_cast.hpp>
20 
21 using namespace std;
23 
24 namespace pt = boost::property_tree;
25 
26 
28  TrigConf::TrigConfMessaging("MuctpiXMLParser")
29 {}
30 
31 
32 void
34  cout << "************************** MuctpiXMLParser **********************" << endl;
35  m_muctpi.print();
36  cout << "*****************************************************************" << endl;
37 }
38 
39 
40 void
42 {
43  // populate the ptree m_configuration with the structure of the xml input file
45  read_xml(inputfile, inputTree); // 3 --> trim_whitespace
46 
47  m_muctpiPT = inputTree.get_child("MuCTPiGeometry");
48 
49  TRG_MSG_INFO("Read " << inputfile << " successfully!");
50 }
51 
52 
54 {
55 
56  // iterate through elements of topomenu
57  for(const boost::property_tree::ptree::value_type &x: m_muctpiPT) {
58 
59  string menuElementName = x.first;
60  if (menuElementName=="<xmlattr>" || menuElementName=="<xmlcomment>") continue;
61  ptree menuElement = x.second;
62 
63  // get branch attributes
64  if( menuElementName=="MIOCT" ) {
65 
66  MioctGeometry octant;
67  setOctant(menuElement, octant);
68  m_muctpi.addOctant(octant);
69 
70  } else if( menuElementName=="PtEncoding" ) {
71 
72  L1MuonPtEncoding ptEncoding;
73  setPtEncoding(menuElement, ptEncoding);
74  m_muctpi.setPtEncoding(ptEncoding);
75 
76  } else {
77  // TRG_MSG_FATAL("Unknown element" << menuElementName); // validation is checked by the dtd
78  }
79  }
80 
81 
82  TRG_MSG_INFO("Parsing Successful!");
83 
84  // m_muctpi.print();
85 
86 }
87 
88 
90 {
91 
92  for(const auto & x : menuElement ) {
93 
94  if( x.first == "PtCodeElement" ) {
95 
96  unsigned int idx = m_xmlHelper.getUIntAttribute(x.second, "pt") - 1;
97  unsigned int ptCode = m_xmlHelper.getUIntAttribute(x.second, "code");
98  unsigned int thresholdValue = m_xmlHelper.getUIntAttribute(x.second, "value");
99 
100  ptEncoding.setCodingInfo(idx, ptCode, thresholdValue);
101 
102  }
103  }
104 }
105 
106 
108 {
109  octant.setMioctId( m_xmlHelper.getUIntAttribute(menuElement,"id"));
110  octant.setSlot( m_xmlHelper.getUIntAttribute(menuElement,"slot"));
111 
112  // <Sector>'s
113  //unsigned int counter = 0;
114  for(const boost::property_tree::ptree::value_type &x:menuElement ) {
115  //cout << "reading "<< counter<< " octant\n"; counter++;
116  string menuElementNameO = x.first;
117  if (menuElementNameO=="<xmlattr>" || menuElementNameO=="<xmlcomment>") continue;
118  ptree menuElementO = x.second;
119  // get branch attributes
120 
121  if( menuElementNameO== "Sector" ){
122  MioctSectorGeometry sector;
123  setSector(menuElementO, sector);
124  octant.addSector(sector);
125  }
126  // Decode/TopoCell
127  else if( menuElementNameO == "Decode" ){
128  for(const boost::property_tree::ptree::value_type &y: menuElementO) {
129  string menuElementName1 = y.first;
130  if (menuElementName1=="<xmlattr>" || menuElementName1=="<xmlcomment>") continue;
131  ptree menuElement1 = y.second;
132  MioctTopoCellGeometry tcell;
133  setTopoCell(menuElement1, tcell);
134  octant.addTopoCell(tcell);
135  }
136  } // end of decode
137  }// end of menuEleement loop
138 }
139 
140 
142 {
143  sector.setConnector(m_xmlHelper.getUIntAttribute(menuElement,"connector") );
144  sector.setName(m_xmlHelper.getAttribute(menuElement,"name") );
145 
146  //unsigned int counter = 0;
147  for(const boost::property_tree::ptree::value_type &x:menuElement ) {
148 
149  string menuElementNameO = x.first;
150  if (menuElementNameO=="<xmlattr>" || menuElementNameO=="<xmlcomment>") continue;
151  ptree menuElementO = x.second;
152  // get branch attributes
153 
154  if( menuElementNameO== "ROI" ){
155  //cout << "reading "<< counter<<" ROI\n"; counter++;
156  MioctROIGeometry roi;
157  setROI(menuElementO, roi);
158  sector.addROI(roi);
159  }
160  }
161 }
162 
164 {
165  unsigned int x = 0;
166  std::stringstream ss; ss << std::hex ;
167 
168  data.setEtamin(m_xmlHelper.getFloatAttribute(menuElement, "etamin"));
169  data.setEtamax(m_xmlHelper.getFloatAttribute(menuElement, "etamax"));
170  data.setEta(m_xmlHelper.getFloatAttribute(menuElement, "eta"));
171  data.setPhimin(m_xmlHelper.getFloatAttribute(menuElement, "phimin"));
172  data.setPhimax(m_xmlHelper.getFloatAttribute(menuElement, "phimax"));
173  data.setPhi(m_xmlHelper.getFloatAttribute(menuElement, "phi"));
174  data.setRoiid(m_xmlHelper.getUIntAttribute(menuElement, "roiid"));
175 
176  ss<< m_xmlHelper.getAttribute(menuElement, "etacode");
177  ss>> x;
178  data.setEtacode( x );
179  ss.clear();
180  ss<< m_xmlHelper.getAttribute(menuElement, "phicode");
181  ss>> x;
182  data.setPhicode( x );
183  //data.print(" ");
184 }
185 
187 {
188  unsigned int x = 0;
189  std::stringstream ss; ss << std::hex ;
190  data.setEtamin(m_xmlHelper.getFloatAttribute(menuElement, "etamin"));
191  data.setEtamax(m_xmlHelper.getFloatAttribute(menuElement, "etamax"));
192  data.setEta(m_xmlHelper.getFloatAttribute(menuElement, "eta"));
193 
194  data.setPhimin(m_xmlHelper.getFloatAttribute(menuElement, "phimin"));
195  data.setPhimax(m_xmlHelper.getFloatAttribute(menuElement, "phimax"));
196  data.setPhi(m_xmlHelper.getFloatAttribute(menuElement, "phi"));
197  data.setIEta(m_xmlHelper.getIntAttribute(menuElement, "ieta"));
198  data.setIPhi(m_xmlHelper.getIntAttribute(menuElement, "iphi"));
199 
200  ss<< m_xmlHelper.getAttribute(menuElement, "etacode");
201  ss>> x; ss.clear();
202  data.setEtacode( x );
203  ss<< m_xmlHelper.getAttribute(menuElement, "phicode");
204  ss>> x;
205  data.setPhicode( x );
206  //data.print(" ");
207 }
208 
209 
MuCTPiGeometry::addOctant
void addOctant(const MioctGeometry &octant)
Definition: MuCTPiGeometry.h:25
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
MuctpiXMLHelper::getAttribute
std::string getAttribute(const boost::property_tree::ptree &tree, const std::string &attr)
Definition: MuctpiXMLHelper.cxx:67
MioctGeometry.h
L1MuonPtEncoding::setCodingInfo
void setCodingInfo(unsigned int idx, unsigned int ptCode, unsigned int thresholdValue)
Definition: L1MuonPtEncoding.cxx:13
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
checkNSWValTree.inputTree
inputTree
Definition: checkNSWValTree.py:27
MuctpiXMLParser::m_muctpi
MuCTPiGeometry m_muctpi
Definition: MuctpiXMLParser.h:79
MioctSectorGeometry::setName
void setName(const std::string &name)
Definition: MioctSectorGeometry.h:32
MuctpiXMLHelper::getUIntAttribute
unsigned int getUIntAttribute(const boost::property_tree::ptree &tree, const std::string &attr)
Definition: MuctpiXMLHelper.cxx:116
test_pyathena.pt
pt
Definition: test_pyathena.py:11
MuctpiXMLParser::readConfiguration
void readConfiguration(const std::string &inputfile)
Definition: MuctpiXMLParser.cxx:41
x
#define x
MuctpiXMLParser::setPtEncoding
void setPtEncoding(boost::property_tree::ptree menuElement, L1MuonPtEncoding &ptEncoding)
Definition: MuctpiXMLParser.cxx:89
MioctGeometry::addTopoCell
void addTopoCell(const MioctTopoCellGeometry &topocell)
Definition: MioctGeometry.h:30
MuctpiXMLParser::setOctant
void setOctant(boost::property_tree::ptree menuElement, MioctGeometry &octant)
Definition: MuctpiXMLParser.cxx:107
L1MuonPtEncoding
Definition: L1MuonPtEncoding.h:10
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
MioctROIGeometry
Definition: MioctROIGeometry.h:22
MuctpiXMLParser::MuctpiXMLParser
MuctpiXMLParser()
Definition: MuctpiXMLParser.cxx:27
MioctTopoCellGeometry.h
MioctSectorGeometry::addROI
void addROI(MioctROIGeometry roi)
Definition: MioctSectorGeometry.h:31
MuctpiXMLParser::setROI
void setROI(boost::property_tree::ptree menuElement, MioctROIGeometry &roi)
Definition: MuctpiXMLParser.cxx:163
MioctGeometry::addSector
void addSector(const MioctSectorGeometry &sector)
Definition: MioctGeometry.h:29
MuctpiXMLParser::parseConfiguration
void parseConfiguration()
Definition: MuctpiXMLParser.cxx:53
MuCTPiGeometry::print
virtual void print(const std::string &indent="", unsigned int detail=1) const
Definition: MuCTPiGeometry.cxx:19
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
MioctGeometry::setMioctId
void setMioctId(unsigned int id)
Definition: MioctGeometry.h:27
MuctpiXMLParser::setTopoCell
void setTopoCell(boost::property_tree::ptree menuElement, MioctTopoCellGeometry &topocell)
Definition: MuctpiXMLParser.cxx:186
ptree
boost::property_tree::ptree ptree
Definition: JsonFileLoader.cxx:16
MuctpiXMLParser::m_muctpiPT
boost::property_tree::ptree m_muctpiPT
Definition: MuctpiXMLParser.h:78
MuctpiXMLHelper::getIntAttribute
int getIntAttribute(const boost::property_tree::ptree &tree, const std::string &attr)
Definition: MuctpiXMLHelper.cxx:84
MioctROIGeometry.h
MioctGeometry::setSlot
void setSlot(int m)
Definition: MioctGeometry.h:28
MuctpiXMLParser::m_xmlHelper
MuctpiXMLHelper m_xmlHelper
Definition: MuctpiXMLParser.h:80
MuctpiXMLParser.h
MuctpiXMLParser::setSector
void setSector(boost::property_tree::ptree menuElement, MioctSectorGeometry &sector)
Definition: MuctpiXMLParser.cxx:141
MioctSectorGeometry::setConnector
void setConnector(unsigned int id)
Definition: MioctSectorGeometry.h:33
y
#define y
MioctSectorGeometry
Definition: MioctSectorGeometry.h:19
MioctSectorGeometry.h
MioctTopoCellGeometry
Definition: MioctTopoCellGeometry.h:15
MuCTPiGeometry.h
FullCPAlgorithmsTest_CA.inputfile
dictionary inputfile
Definition: FullCPAlgorithmsTest_CA.py:59
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
MioctGeometry
Definition: MioctGeometry.h:15
MuctpiXMLHelper::getFloatAttribute
float getFloatAttribute(const boost::property_tree::ptree &tree, const std::string &attr)
Definition: MuctpiXMLHelper.cxx:140
MuctpiXMLParser::printConfiguration
void printConfiguration() const
Definition: MuctpiXMLParser.cxx:33
MuCTPiGeometry::setPtEncoding
void setPtEncoding(const L1MuonPtEncoding &ptEncoding)
Definition: MuCTPiGeometry.h:26