17 #include <sys/types.h>
20 #include <xercesc/parsers/XercesDOMParser.hpp>
21 #include <xercesc/dom/DOM.hpp>
22 #include <xercesc/sax/HandlerBase.hpp>
23 #include <xercesc/util/XMLString.hpp>
25 #include <xercesc/dom/DOMNode.hpp>
26 #include <xercesc/framework/StdOutFormatTarget.hpp>
27 #include <xercesc/framework/LocalFileFormatTarget.hpp>
36 XERCES_CPP_NAMESPACE_USE
59 extention_table_name =
"HCAL_TRIG_PRIM_LOOKUP_TABLES";
60 name =
"HCAL trigger primitive lookup table";
68 tag_name =
"dummy tag";
69 detector_name =
"HCAL";
70 comment_description =
"empty comment";
78 created_by_user = getpwuid( getuid() ) -> pw_name;
84 DOMDocument * loader = result -> getDocument();
87 loader -> getElementsByTagName( _toXMLCh(
"NAME" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh(
"HCAL LMAP for HB, HE, HF" ) );
96 DOMDocument * loader = doc -> getDocument();
97 DOMElement *
root = loader -> getDocumentElement();
100 DOMDocument * dataSet = dataSetDoc . getDocument();
103 dataSet -> getElementsByTagName( _toXMLCh(
"SIDE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> side ) );
104 dataSet -> getElementsByTagName( _toXMLCh(
"ETA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row ->
eta) );
105 dataSet -> getElementsByTagName( _toXMLCh(
"PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row ->
phi ) );
106 dataSet -> getElementsByTagName( _toXMLCh(
"DELTA_PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> dphi ) );
108 dataSet -> getElementsByTagName( _toXMLCh(
"DEPTH" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> depth ) );
109 dataSet -> getElementsByTagName( _toXMLCh(
"SUBDETECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> det ) );
110 dataSet -> getElementsByTagName( _toXMLCh(
"RBX_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rbx ) );
111 dataSet -> getElementsByTagName( _toXMLCh(
"WEDGE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> wedge ) );
113 dataSet -> getElementsByTagName( _toXMLCh(
"RM_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row ->
rm ) );
114 dataSet -> getElementsByTagName( _toXMLCh(
"HPD_PIXEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> pixel ) );
115 dataSet -> getElementsByTagName( _toXMLCh(
"QIE_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> qie ) );
116 dataSet -> getElementsByTagName( _toXMLCh(
"ADC" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row ->
adc ) );
117 dataSet -> getElementsByTagName( _toXMLCh(
"RM_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rm_fi ) );
119 dataSet -> getElementsByTagName( _toXMLCh(
"FIBER_CHANNEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> fi_ch));
120 dataSet -> getElementsByTagName( _toXMLCh(
"CRATE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> crate ) );
121 dataSet -> getElementsByTagName( _toXMLCh(
"HTR_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> htr ) );
122 dataSet -> getElementsByTagName( _toXMLCh(
"HTR_FPGA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> fpga ) );
124 dataSet -> getElementsByTagName( _toXMLCh(
"HTR_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> htr_fi ));
125 dataSet -> getElementsByTagName( _toXMLCh(
"DCC_SL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> dcc_sl ) );
126 dataSet -> getElementsByTagName( _toXMLCh(
"SPIGOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> spigo ) );
127 dataSet -> getElementsByTagName( _toXMLCh(
"DCC_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> dcc ) );
128 dataSet -> getElementsByTagName( _toXMLCh(
"SLB_SITE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row ->
slb ) );
129 dataSet -> getElementsByTagName( _toXMLCh(
"SLB_CHANNEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> slbin ));
130 dataSet -> getElementsByTagName( _toXMLCh(
"SLB_CHANNEL2" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> slbin2));
132 dataSet -> getElementsByTagName( _toXMLCh(
"SLB_CABLE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> slnam ) );
133 dataSet -> getElementsByTagName( _toXMLCh(
"RCT_CRATE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rctcra ) );
134 dataSet -> getElementsByTagName( _toXMLCh(
"RCT_CARD" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rctcar ) );
135 dataSet -> getElementsByTagName( _toXMLCh(
"RCT_CONNECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row ->rctcon));
136 dataSet -> getElementsByTagName( _toXMLCh(
"RCT_NAME" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rctnam ) );
137 dataSet -> getElementsByTagName( _toXMLCh(
"FED_ID" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> fedid ) );
141 DOMNode * cloneDataSet = loader -> importNode( dataSet -> getDocumentElement(),
true );
142 root -> appendChild( cloneDataSet );
150 DOMDocument * loader = result -> getDocument();
153 loader -> getElementsByTagName( _toXMLCh(
"NAME" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh(
"HCAL LMAP for HO" ) );
162 DOMDocument * loader = doc -> getDocument();
163 DOMElement *
root = loader -> getDocumentElement();
166 DOMDocument * dataSet = dataSetDoc . getDocument();
169 dataSet -> getElementsByTagName( _toXMLCh(
"SIDE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> sideO ) );
170 dataSet -> getElementsByTagName( _toXMLCh(
"ETA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> etaO ) );
171 dataSet -> getElementsByTagName( _toXMLCh(
"PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> phiO ) );
172 dataSet -> getElementsByTagName( _toXMLCh(
"DELTA_PHI" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> dphiO ) );
174 dataSet -> getElementsByTagName( _toXMLCh(
"DEPTH" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> depthO ) );
175 dataSet -> getElementsByTagName( _toXMLCh(
"SUBDETECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> detO ) );
176 dataSet -> getElementsByTagName( _toXMLCh(
"RBX_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rbxO ) );
177 dataSet -> getElementsByTagName( _toXMLCh(
"SECTOR" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> sectorO ) );
179 dataSet -> getElementsByTagName( _toXMLCh(
"RM_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rmO ) );
180 dataSet -> getElementsByTagName( _toXMLCh(
"HPD_PIXEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> pixelO ) );
181 dataSet -> getElementsByTagName( _toXMLCh(
"QIE_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> qieO ) );
182 dataSet -> getElementsByTagName( _toXMLCh(
"ADC" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> adcO ) );
183 dataSet -> getElementsByTagName( _toXMLCh(
"RM_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> rm_fiO ) );
184 dataSet -> getElementsByTagName( _toXMLCh(
"FIBER_CHANNEL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row ->fi_chO));
186 dataSet -> getElementsByTagName( _toXMLCh(
"LETTER_CODE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh(row ->let_codeO));
187 dataSet -> getElementsByTagName( _toXMLCh(
"CRATE" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> crateO ) );
188 dataSet -> getElementsByTagName( _toXMLCh(
"HTR_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> htrO ) );
189 dataSet -> getElementsByTagName( _toXMLCh(
"HTR_FPGA" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> fpgaO ) );
191 dataSet -> getElementsByTagName( _toXMLCh(
"HTR_FIBER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> htr_fiO ) );
192 dataSet -> getElementsByTagName( _toXMLCh(
"DCC_SL" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> dcc_slO ) );
193 dataSet -> getElementsByTagName( _toXMLCh(
"SPIGOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> spigoO ) );
194 dataSet -> getElementsByTagName( _toXMLCh(
"DCC_SLOT" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> dccO ) );
195 dataSet -> getElementsByTagName( _toXMLCh(
"FED_ID" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh( row -> fedidO ) );
199 DOMNode * cloneDataSet = loader -> importNode( dataSet -> getDocumentElement(),
true );
200 root -> appendChild( cloneDataSet );
207 DOMDocument * loader = doc -> getDocument();
211 _t = serializeDOM( loader, target );
221 XMLDOMBlock dataBlock(
"HCAL_TRIG_PRIM_LOOKUP_TABLE.datablock.template" );
223 DOMDocument * dataBlockDocument = dataBlock . getDocument();
225 std::cout <<
"===> Tag length: " << dataBlockDocument -> getElementsByTagName( _toXMLCh(
"CREATED_BY_USER" ) ) -> getLength() << std::endl;
226 std::cout <<
"===> Tag name: " << XMLString::transcode( dataBlockDocument -> getElementsByTagName( _toXMLCh(
"CREATED_BY_USER" ) ) -> item(0) -> getNodeName() ) << std::endl;
227 dataBlockDocument -> getElementsByTagName( _toXMLCh(
"CREATED_BY_USER" ) ) -> item(0) -> getFirstChild() -> setNodeValue( _toXMLCh(
"kukarzev test" ) );
230 _t = serializeDOM( dataBlockDocument );
241 XMLString::transcode(
"LS", tempStr, 99);
242 DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
243 DOMWriter* theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();
245 if (theSerializer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent,
true))
246 theSerializer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent,
true);
248 if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true))
249 theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
251 XMLFormatTarget * myFormTarget = 0;
253 if ( target ==
"stdout" || target ==
"string" )
255 myFormTarget =
new StdOutFormatTarget();
263 myFormTarget =
new LocalFileFormatTarget( _toXMLCh( target ) );
267 if ( target ==
"string" ){
268 _string = theSerializer->writeToString( *node );
271 theSerializer->writeNode(myFormTarget, *node);
274 catch (
const XMLException& toCatch) {
275 char*
message = XMLString::transcode(toCatch.getMessage());
281 catch (
const DOMException& toCatch) {
282 char*
message = XMLString::transcode(toCatch.msg);
293 theSerializer->release();
294 if ( myFormTarget )
delete myFormTarget;
308 catch (
const XMLException& toCatch) {
309 std::cout <<
" FAILED! Exiting..." << std::endl;
int adc(sample_type sample)
get the ADC sample (12 bits)
XMLDOMBlock * createLMapHBEFXMLBase(std::string templateFileName)
static int slb(const HcalTriggerPrimitiveSample &theSample)
int addLMapHBEFDataset(XMLDOMBlock *doc, LMapRowHBEF *row, std::string templateFileName)
int addLMapHODataset(XMLDOMBlock *doc, LMapRowHO *row, std::string templateFileName)
XMLDOMBlock * createLMapHOXMLBase(std::string templateFileName)
int write(XMLDOMBlock *doc, std::string target="stdout")
static XMLProcessor * instance
XMLCh * serializeDOM(DOMNode *node, std::string target="stdout")
string root
initialization