6#include <xercesc/dom/DOMElement.hpp>
7#include <xercesc/dom/DOMNodeList.hpp>
8#include <xercesc/dom/DOMTreeWalker.hpp>
22 using XERCES_CPP_NAMESPACE_QUALIFIER DOMElement;
25 : m_badType(badType), m_state(BUILDING) {
35 using XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument;
38 DOMDocument* doc = parser->
parse(xmlFileName.c_str());
41 std::cerr <<
"Error parsing document" << xmlFileName << std::endl;
45 DOMElement* docElt = doc->getDocumentElement();
48 std::vector<DOMElement *> towers;
50 Dom::getDescendantsByTagName(docElt,
"tower", towers);
51 unsigned nTower = towers.size();
53 m_towers.reserve(nTower);
55 std::string bString = Dom::getAttribute(docElt,
"badType");
56 if (!bString.compare(
"hot")) m_badType =
HOT;
57 else if (!bString.compare(
"dead")) m_badType =
DEAD;
61 for (
unsigned int iTower = 0; iTower < nTower; iTower++) {
63 tower.m_uniplanes.clear();
65 tower.m_row = Dom::getIntAttribute(towers[iTower],
"row");
66 tower.m_col = Dom::getIntAttribute(towers[iTower],
"col");
69 std::cerr <<
"From calibUtil::StripSrv::StripSrv" << std::endl
70 << ex.
getMsg() << std::endl;
77 std::string attValue = Dom::getAttribute(towers[iTower],
"nOnbdCalib");
78 if (attValue.compare(
"true") == 0) {
81 attValue = Dom::getAttribute(towers[iTower],
"nOnbdTrig");
82 if (attValue.compare(
"true") == 0) {
85 attValue = Dom::getAttribute(towers[iTower],
"nOnbdData");
86 if (attValue.compare(
"true") == 0) {
95 DOMElement* uniElt = Dom::getFirstChildElement(towers[iTower]);
100 fillUni(uniElt, &uni);
103 tower.m_uniplanes.push_back(uni);
104 uniElt = Dom::getSiblingElement(uniElt);
108 m_towers.push_back(tower);
126 std::vector<Tower>::const_iterator it = m_towers.begin();
127 while(it != m_towers.end() ) {
130 towerRCs.reserve(m_towers.size());
133 towerRCs.push_back(trc);
167 std::vector<Tower>::const_iterator iTower = m_towers.begin();
170 while (iTower != m_towers.end() ) {
171 if (iTower->m_allBad) {
172 ret = client->
badTower(iTower->m_row, iTower->m_col, iTower->m_howBad);
173 if (ret !=
CONT)
return ret;
177 std::vector<Uniplane>::const_iterator iUni =
178 (iTower->m_uniplanes).begin();
179 while (iUni != (iTower->m_uniplanes).end() ) {
180 ret = client->
badPlane(iTower->m_row, iTower->m_col,
181 iUni->m_tray, iUni->m_top,
182 iUni->m_howBad, iUni->m_allBad,
184 if (ret !=
CONT)
return ret;
197 void StripSrv::fillUni(
const DOMElement* uniElt, Uniplane *uni) {
200 std::string attValue;
202 attValue = Dom::getAttribute(uniElt,
"allBad");
203 uni->m_allBad = (attValue.compare(
"true") == 0);
205 attValue = Dom::getAttribute(uniElt,
"nOnbdCalib");
206 if (attValue.compare(
"true") == 0) {
209 attValue = Dom::getAttribute(uniElt,
"nOnbdTrig");
210 if (attValue.compare(
"true") == 0) {
213 attValue = Dom::getAttribute(uniElt,
"nOnbdData");
214 if (attValue.compare(
"true") == 0) {
218 attValue = Dom::getAttribute(uniElt,
"tray");
219 uni->m_tray = atoi(attValue.c_str());
221 attValue = Dom::getAttribute(uniElt,
"which");
222 if (attValue.compare(
"top") == 0) uni->m_top =
true;
223 else if (attValue.compare(
"bot") == 0) uni->m_top =
false;
226 if (!uni->m_allBad) {
227 fillStrips(uniElt, uni->m_strips);
232 void StripSrv::fillStrips(
const DOMElement* badElt,
StripCol& list) {
235 DOMElement* childElt = Dom::getFirstChildElement(badElt);
237 while (childElt != 0 ) {
239 if (Dom::checkTagName(childElt,
"stripList")) {
240 std::string xmlList = Dom::getAttribute(childElt,
"strips");
241 strToNum(xmlList, list);
243 else if (Dom::checkTagName(childElt,
"stripSpan")) {
244 unsigned short first, last;
247 first = Dom::getIntAttribute(childElt,
"first");
248 last = Dom::getIntAttribute(childElt,
"last");
251 std::cerr <<
"From calibUtil::StripSrv::fillStrips" << std::endl
252 << ex.
getMsg() << std::endl;
258 list.reserve(list.size() + last + 1 - first);
259 for (
unsigned short int i = first; i <= last; i++) {
264 childElt = Dom::getSiblingElement(childElt);
268 void StripSrv::strToNum(std::string
s, std::vector<unsigned short int> &
v){
270 std::string::iterator it =
s.begin();
276 while((it !=
s.end()) && (*it ==
' ')) it++;
279 while ((it !=
s.end()) && (*it >=
'0') && (*it <=
'9')) {
284 while((it !=
s.end()) && (*it >=
'0') && (*it <=
'9')){
290 while((it !=
s.end()) && (*it ==
' ')) it++;
293 v.push_back(atoi(tempStr.c_str()));
298 StripSrv::Tower* StripSrv::findTower(towerRC& towerId) {
299 std::vector<Tower>::iterator it = m_towers.begin();
300 while(it != m_towers.end() ) {
301 if ((it->m_row == towerId.row) && (it->m_col == towerId.col)) {
309 const StripSrv::Tower* StripSrv::findTower(
const towerRC& towerId)
const {
310 std::vector<Tower>::const_iterator it = m_towers.begin();
311 while(it != m_towers.end() ) {
312 if ((it->m_row == towerId.row) && (it->m_col == towerId.col)) {
#define vCALIBUTIL_nOnbdCalib
#define vCALIBUTIL_nOnbdData
#define vCALIBUTIL_nOnbdTrig
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
virtual eVisitorRet badTower(unsigned int row, unsigned int col, int badness)=0
virtual eVisitorRet badPlane(unsigned int row, unsigned int col, unsigned int tray, bool top, int badness, bool allBad, const StripCol &strips)=0
std::string getFmtVer()
Get format Version.
std::string getInst()
Get instrument name.
std::string getCalType()
Get calibration type.
std::string getTimestamp()
Get timestamp.
eVisitorRet writeXml(std::ostream *out)
eBadType getBadType() const
returns the status (Hot or Dead) of the strip
StripSrv(std::string xmlFileName)
std::string getInst() const
methods giving access to generic data
std::string getCalType() const
Get calibration type.
eVisitorRet traverseInfo(ClientObject *client) const
call back method for client to access large data
std::string getTimestamp() const
Get timestamp.
~StripSrv()
destructor. Deallocates memory
void getBadTowers(std::vector< towerRC > &towerIds) const
lists all towers with bad strips
std::string getFmtVer() const
Get format Version.
Base exception class for Dom.
virtual std::string getMsg()
DOMDocument * parse(const char *const filename, const std::string &docType=std::string(""))
Parse an xml file, returning document node if successful.
Module implements methods for clients to get generic services.
std::vector< unsigned short int > StripCol
Clients should use as return values for readData.