5#include "xmlBase/Dom.h"
6#include "xmlBase/XmlParser.h"
7#include <xercesc/dom/DOMElement.hpp>
8#include <xercesc/dom/DOMNodeList.hpp>
9#include <xercesc/dom/DOMTreeWalker.hpp>
17#include "calibUtil/ChannelStatusDef.h"
18#include "calibUtil/GenericSrv.h"
19#include "calibUtil/StripSrv.h"
23 using XERCES_CPP_NAMESPACE_QUALIFIER DOMElement;
26 : m_badType( badType ), m_state( BUILDING ) {
34 using XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument;
37 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;
60 for (
unsigned int iTower = 0; iTower < nTower; iTower++ )
63 tower.m_uniplanes.clear();
66 tower.m_row = Dom::getIntAttribute( towers[iTower],
"row" );
67 tower.m_col = Dom::getIntAttribute( towers[iTower],
"col" );
70 std::cerr <<
"From calibUtil::StripSrv::StripSrv" << std::endl
71 << ex.
getMsg() << std::endl;
78 std::string attValue = Dom::getAttribute( towers[iTower],
"nOnbdCalib" );
80 attValue = Dom::getAttribute( towers[iTower],
"nOnbdTrig" );
82 attValue = Dom::getAttribute( towers[iTower],
"nOnbdData" );
91 DOMElement* uniElt = Dom::getFirstChildElement( towers[iTower] );
97 fillUni( uniElt, &uni );
100 tower.m_uniplanes.push_back( uni );
101 uniElt = Dom::getSiblingElement( uniElt );
105 m_towers.push_back( tower );
118 std::vector<Tower>::const_iterator it = m_towers.begin();
119 while ( it != m_towers.end() )
123 towerRCs.reserve( m_towers.size() );
126 towerRCs.push_back( trc );
151 std::vector<Tower>::const_iterator iTower = m_towers.begin();
154 while ( iTower != m_towers.end() )
156 if ( iTower->m_allBad )
158 ret = client->
badTower( iTower->m_row, iTower->m_col, iTower->m_howBad );
159 if ( ret !=
CONT )
return ret;
164 std::vector<Uniplane>::const_iterator iUni = ( iTower->m_uniplanes ).begin();
165 while ( iUni != ( iTower->m_uniplanes ).end() )
167 ret = client->
badPlane( iTower->m_row, iTower->m_col, iUni->m_tray, iUni->m_top,
168 iUni->m_howBad, iUni->m_allBad, ( iUni->m_strips ) );
169 if ( ret !=
CONT )
return ret;
182 void StripSrv::fillUni(
const DOMElement* uniElt, Uniplane* uni ) {
185 std::string attValue;
187 attValue = Dom::getAttribute( uniElt,
"allBad" );
188 uni->m_allBad = ( attValue.compare(
"true" ) == 0 );
190 attValue = Dom::getAttribute( uniElt,
"nOnbdCalib" );
192 attValue = Dom::getAttribute( uniElt,
"nOnbdTrig" );
194 attValue = Dom::getAttribute( uniElt,
"nOnbdData" );
197 attValue = Dom::getAttribute( uniElt,
"tray" );
198 uni->m_tray = atoi( attValue.c_str() );
200 attValue = Dom::getAttribute( uniElt,
"which" );
201 if ( attValue.compare(
"top" ) == 0 ) uni->m_top =
true;
202 else if ( attValue.compare(
"bot" ) == 0 ) uni->m_top =
false;
205 if ( !uni->m_allBad )
207 fillStrips( uniElt, uni->m_strips );
211 void StripSrv::fillStrips(
const DOMElement* badElt,
StripCol& list ) {
214 DOMElement* childElt = Dom::getFirstChildElement( badElt );
216 while ( childElt != 0 )
219 if ( Dom::checkTagName( childElt,
"stripList" ) )
221 std::string xmlList = Dom::getAttribute( childElt,
"strips" );
222 strToNum( xmlList, list );
224 else if ( Dom::checkTagName( childElt,
"stripSpan" ) )
226 unsigned short first, last;
230 first = Dom::getIntAttribute( childElt,
"first" );
231 last = Dom::getIntAttribute( childElt,
"last" );
232 }
catch ( xmlBase::DomException ex )
234 std::cerr <<
"From calibUtil::StripSrv::fillStrips" << std::endl
235 << ex.
getMsg() << std::endl;
242 list.reserve( list.size() + last + 1 - first );
243 for (
unsigned short int i = first; i <= last; i++ ) { list.push_back( i ); }
246 childElt = Dom::getSiblingElement( childElt );
250 void StripSrv::strToNum( std::string
s, std::vector<unsigned short int>&
v ) {
252 std::string::iterator it =
s.begin();
258 while ( ( it !=
s.end() ) && ( *it ==
' ' ) ) it++;
261 while ( ( it !=
s.end() ) && ( *it >=
'0' ) && ( *it <=
'9' ) )
267 while ( ( it !=
s.end() ) && ( *it >=
'0' ) && ( *it <=
'9' ) )
274 while ( ( it !=
s.end() ) && ( *it ==
' ' ) ) it++;
277 v.push_back( atoi( tempStr.c_str() ) );
281 StripSrv::Tower* StripSrv::findTower( towerRC& towerId ) {
282 std::vector<Tower>::iterator it = m_towers.begin();
283 while ( it != m_towers.end() )
285 if ( ( it->m_row == towerId.row ) && ( it->m_col == towerId.col ) )
286 {
return ( &( *it ) ); }
292 const StripSrv::Tower* StripSrv::findTower(
const towerRC& towerId )
const {
293 std::vector<Tower>::const_iterator it = m_towers.begin();
294 while ( it != m_towers.end() )
296 if ( ( it->m_row == towerId.row ) && ( it->m_col == towerId.col ) )
297 {
return ( &( *it ) ); }
#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
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
struct calibUtil::StripSrv::stowerRC towerRC
Clients should use as return values for readData.
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