00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "DaqXml/DaqXmlStream.h"
00010
00011 #include "CbltReadoutFormat/CbltBody.h"
00012 #include "CbltReadoutFormat/CbltFoot.h"
00013 #include "CbltReadoutFormat/CbltHead.h"
00014 #include "CbltReadoutFormat/CbltReadout.h"
00015 #include "CbltReadoutFormat/CbltTraits.h"
00016 #include "FadcReadoutFormat/FadcFoot.h"
00017 #include "FadcReadoutFormat/FadcData.h"
00018 #include "FadcReadoutFormat/FadcHead.h"
00019 #include "FadcReadoutFormat/FadcReadout.h"
00020 #include "FadcReadoutFormat/FadcTraits.h"
00021 #include "FeeReadoutFormat/FeeFoot.h"
00022 #include "FeeReadoutFormat/FeeHead.h"
00023 #include "FeeReadoutFormat/FeeHit.h"
00024 #include "FeeReadoutFormat/FeeReadout.h"
00025 #include "FeeReadoutFormat/FeeTraits.h"
00026 #include "LtbReadoutFormat/LtbFoot.h"
00027 #include "LtbReadoutFormat/LtbFrame.h"
00028 #include "LtbReadoutFormat/LtbHead.h"
00029 #include "LtbReadoutFormat/LtbReadout.h"
00030 #include "LtbReadoutFormat/LtbTraits.h"
00031 #include "EventReadoutFormat/EventReadout.h"
00032 #include "EventReadoutFormat/EventHeader.h"
00033 #include "EventReadoutFormat/EventTraits.h"
00034 #include "DaqReadoutFormat/RomData.h"
00035 #include "EventReadoutFormat/RomFragment.h"
00036 #include "EventReadoutFormat/RomHeader.h"
00037 #include "FileReadoutFormat/CalibrationParametersRecord.h"
00038 #include "FileReadoutFormat/DataSeparatorRecord.h"
00039 #include "FileReadoutFormat/FileEndRecord.h"
00040 #include "FileReadoutFormat/FileNameStrings.h"
00041 #include "FileReadoutFormat/FileBuffer.h"
00042 #include "FileReadoutFormat/FileStartRecord.h"
00043 #include "FileReadoutFormat/FileTraits.h"
00044 #include "FileReadoutFormat/MetadataStrings.h"
00045 #include "FileReadoutFormat/RunParametersRecord.h"
00046
00047 using namespace DybDaq;
00048 using std::endl;
00049 using std::string;
00050
00051 static const string emptyString("");
00052
00053 DaqXmlStream::DaqXmlStream(std::ostream& output,
00054 const string& indent,
00055 bool strict) :
00056 m_output(&output),
00057 m_indent(new string(indent)),
00058 m_strict(strict) {
00059 }
00060
00061 DaqXmlStream::~DaqXmlStream() {
00062 if ( 0 != m_indent) {
00063 delete m_indent;
00064 }
00065 }
00066
00067 void DaqXmlStream::dumpElement(const FadcData& data) const {
00068 dumpElement(data,
00069 emptyString);
00070 }
00071
00072 void DaqXmlStream::dumpElement(const FadcData& data,
00073 const string& indent) const {
00074 string nestedIndent = indent + (*m_indent);
00075 (*m_output) << indent << "<fadc_data>" << endl;
00076 (*m_output) << nestedIndent << "<channel>" << data.channelId() << "</channel>" << endl;
00077 (*m_output) << nestedIndent << "<high_byte>" << ((unsigned int)data.highDataByte()) << "</high_byte>" << endl;
00078 (*m_output) << nestedIndent << "<middle_byte>" << ((unsigned int)data.middleDataByte()) << "</middle_byte>" << endl;
00079 (*m_output) << nestedIndent << "<low_byte>" << ((unsigned int)data.lowDataByte()) << "</low_byte>" << endl;
00080 (*m_output) << indent << "</fadc_data>" << endl;
00081 }
00082
00083 void DaqXmlStream::dumpElement(const FadcFoot& foot) const {
00084 dumpElement(foot,
00085 emptyString);
00086 }
00087
00088 void DaqXmlStream::dumpElement(const FadcFoot& foot,
00089 const string& indent) const {
00090 string nestedIndent = indent + (*m_indent);
00091 (*m_output) << indent << "<fadc_foot";
00092 if (m_strict) {
00093 (*m_output) << " length=\"" << foot.dataLength() << "\"";
00094 }
00095 (*m_output) << ">" << endl;
00096 (*m_output) << nestedIndent << "<trigger_number>" << foot.triggerNumber() << "</trigger_number>" << endl;
00097 (*m_output) << indent << "</fadc_foot>" << endl;
00098 }
00099
00100 void DaqXmlStream::dumpElement(const FadcHead& head) const {
00101 dumpElement(head,
00102 emptyString);
00103 }
00104
00105 void DaqXmlStream::dumpElement(const FadcHead& head,
00106 const string& indent) const {
00107 const FadcTraits& traits = head.fadcTraits();
00108 string nestedIndent = indent + (*m_indent);
00109 (*m_output) << indent << "<fadc_head format=\"" << head.version() << "\">" << endl;
00110 (*m_output) << nestedIndent << "<trigger_type>" << traits.triggerTypeAsString(head.triggerType()) << "</trigger_type>" << endl;
00111 (*m_output) << nestedIndent << "<no_data>" << traits.boolAsString(head.noData()) << "</no_data>" << endl;
00112 (*m_output) << nestedIndent << "<trigger_number>" << head.triggerNumber() << "</trigger_number>" << endl;
00113 (*m_output) << indent << "</fadc_head>" << endl;
00114 }
00115
00116 void DaqXmlStream::dumpElement(const FadcReadout& readout) const {
00117 dumpElement(readout,
00118 emptyString);
00119 }
00120
00121 void DaqXmlStream::dumpElement(const FadcReadout& readout,
00122 const string& indent) const {
00123 dumpElement(readout.head(),
00124 indent);
00125 const FadcReadout::FadcDataPtrList& data = readout.fadcData();
00126 FadcReadout::FadcDataPtrList::const_iterator entry;
00127 for (entry = data.begin() ;
00128 entry != data.end() ;
00129 ++entry) {
00130 dumpElement(**entry,
00131 indent);
00132 }
00133 dumpElement(readout.foot(),
00134 indent);
00135 }
00136
00137 void DaqXmlStream::dumpElement(const FeeHit& hit) const {
00138 dumpElement(hit,
00139 emptyString);
00140 }
00141
00142 void DaqXmlStream::dumpElement(const FeeHit& hit,
00143 const string& indent) const {
00144 string nestedIndent = indent + (*m_indent);
00145 string doubleIndent = nestedIndent + (*m_indent);
00146 (*m_output) << indent << "<fee_hit>" << endl;
00147 (*m_output) << nestedIndent << "<fee_charge>" << endl;
00148 (*m_output) << doubleIndent << "<channel>" << hit.adcChannelId() << "</channel>" << endl;
00149 (*m_output) << doubleIndent << "<peak>" << hit.peakCycle() << "</peak>" << endl;
00150 const char* range;
00151 if (hit.isHighRangeAdc()) {
00152 range = "high";
00153 } else {
00154 range = "low";
00155 }
00156 (*m_output) << doubleIndent << "<range>" << range << "</range>" << endl;
00157 (*m_output) << doubleIndent << "<value>" << hit.adc() << "</value>" << endl;
00158 (*m_output) << nestedIndent << "</fee_charge>" << endl;
00159 (*m_output) << nestedIndent << "<fee_time>" << endl;
00160 (*m_output) << doubleIndent << "<channel>" << hit.tdcChannelId() << "</channel>" << endl;
00161 (*m_output) << doubleIndent << "<hit_number>" << hit.hitNumber() << "</hit_number>" << endl;
00162 (*m_output) << doubleIndent << "<value>" << hit.tdc() << "</value>" << endl;
00163 (*m_output) << nestedIndent << "</fee_time>" << endl;
00164 (*m_output) << indent << "</fee_hit>" << endl;
00165 }
00166
00167 void DaqXmlStream::dumpElement(const FeeFoot& foot) const {
00168 dumpElement(foot,
00169 emptyString);
00170 }
00171
00172 void DaqXmlStream::dumpElement(const FeeFoot& foot,
00173 const string& indent) const {
00174 string nestedIndent = indent + (*m_indent);
00175 (*m_output) << indent << "<fee_foot";
00176 if (m_strict) {
00177 (*m_output) << " length=\"" << foot.dataLength() << "\"";
00178 }
00179 (*m_output) << ">" << endl;
00180 (*m_output) << nestedIndent << "<trigger_number>" << foot.triggerNumber() << "</trigger_number>" << endl;
00181 (*m_output) << indent << "</fee_foot>" << endl;
00182 }
00183
00184 void DaqXmlStream::dumpElement(const FeeHead& head) const {
00185 dumpElement(head,
00186 emptyString);
00187 }
00188
00189 void DaqXmlStream::dumpElement(const FeeHead& head,
00190 const string& indent) const {
00191 const FeeTraits& traits = head.feeTraits();
00192 string nestedIndent = indent + (*m_indent);
00193 (*m_output) << indent << "<fee_head format=\"" << head.version() << "\">" << endl;
00194 (*m_output) << nestedIndent << "<trigger_type>" << traits.triggerTypeAsString(head.triggerType()) << "</trigger_type>" << endl;
00195 (*m_output) << nestedIndent << "<checked>" << traits.boolAsString(head.checked()) << "</checked>" << endl;
00196 (*m_output) << nestedIndent << "<error>" << traits.boolAsString(head.error()) << "</error>" << endl;
00197 (*m_output) << nestedIndent << "<trigger_number>" << head.triggerNumber() << "</trigger_number>" << endl;
00198 (*m_output) << indent << "</fee_head>" << endl;
00199 }
00200
00201 void DaqXmlStream::dumpElement(const FeeReadout& readout) const {
00202 dumpElement(readout,
00203 emptyString);
00204 }
00205
00206 void DaqXmlStream::dumpElement(const FeeReadout& readout,
00207 const string& indent) const {
00208 dumpElement(readout.head(),
00209 indent);
00210 const FeeReadout::FeeHitPtrList& hits = readout.feeHits();
00211 FeeReadout::FeeHitPtrList::const_iterator hit;
00212 for (hit = hits.begin() ; hit != hits.end() ; ++hit) {
00213 dumpElement(**hit,
00214 indent);
00215 }
00216 dumpElement(readout.foot(),
00217 indent);
00218 }
00219
00220 void DaqXmlStream::dumpElement(const LtbFrame& frame) const {
00221 dumpElement(frame,
00222 emptyString);
00223 }
00224
00225 void DaqXmlStream::dumpElement(const LtbFrame& frame,
00226 const string& indent) const {
00227 const LtbTraits& traits = frame.ltbTraits();
00228 string nestedIndent = indent + (*m_indent);
00229 string doubleIndent = nestedIndent + (*m_indent);
00230 (*m_output) << indent << "<ltb_frame>" << endl;
00231 const LtbTraits::TriggerLines* lines = traits.triggerLines(frame.triggerMask());
00232 if (lines->empty()) {
00233 (*m_output) << nestedIndent << "<trigger_mask/>" << endl;
00234 } else {
00235 (*m_output) << nestedIndent << "<trigger_mask>" << endl;
00236 LtbTraits::TriggerLines::const_iterator line;
00237 for (line = lines->begin() ; line != lines->end() ; ++line) {
00238 (*m_output) << doubleIndent << "<" << *line << "/>" << endl;
00239 }
00240 (*m_output) << nestedIndent << "</trigger_mask>" << endl;
00241 }
00242 delete lines;
00243 (*m_output) << nestedIndent << "<time>" << traits.dateTimeAsString(frame.dateTime()) << "</time>" << endl;
00244 (*m_output) << nestedIndent << "<ticks>" << frame.ticks() << "</ticks>" << endl;
00245 (*m_output) << nestedIndent << "<hit_sum>" << frame.hitSum() << "</hit_sum>" << endl;
00246 if (frame.totalEsum() || frame.totalEsum() || frame.totalEsum()) {
00247 (*m_output) << nestedIndent << "<energy_comparators>" << endl;
00248 if (frame.totalEsum()) {
00249 (*m_output) << doubleIndent << "<Total_ESUM_comp/>" << endl;
00250 }
00251 if (frame.highEsum()) {
00252 (*m_output) << doubleIndent << "<High_ESUM_comp/>" << endl;
00253 }
00254 if (frame.lowEsum()) {
00255 (*m_output) << doubleIndent << "<Low_ESUM_comp/>" << endl;
00256 }
00257 (*m_output) << nestedIndent << "</energy_comparators>" << endl;
00258 } else {
00259 (*m_output) << nestedIndent << "<energy_comparators/>" << endl;
00260 }
00261 (*m_output) << nestedIndent << "<energy_sum>" << frame.energySum() << "</energy_sum>" << endl;
00262 (*m_output) << nestedIndent << "<cross_trigger_source>" << frame.crossTriggerSource() << "</cross_trigger_source>" << endl;
00263 (*m_output) << nestedIndent << "<frame_number>" << frame.frameNumber() << "</frame_number>" << endl;
00264 (*m_output) << nestedIndent << "<blocked_trigger_count>" << frame.blockedTriggerCount() << "</blocked_trigger_count>" << endl;
00265 (*m_output) << indent << "</ltb_frame>" << endl;
00266 }
00267
00268 void DaqXmlStream::dumpElement(const LtbFoot& foot) const {
00269 dumpElement(foot,
00270 emptyString);
00271 }
00272
00273 void DaqXmlStream::dumpElement(const LtbFoot& foot,
00274 const string& indent) const {
00275 string nestedIndent = indent + (*m_indent);
00276 (*m_output) << indent << "<ltb_foot";
00277 if (m_strict) {
00278 (*m_output) << " length=\"" << foot.dataLength() << "\"";
00279 }
00280 (*m_output) << "/>" << endl;
00281 }
00282
00283 void DaqXmlStream::dumpElement(const LtbHead& head) const {
00284 dumpElement(head,
00285 emptyString);
00286 }
00287
00288 void DaqXmlStream::dumpElement(const LtbHead& head,
00289 const string& indent) const {
00290 string nestedIndent = indent + (*m_indent);
00291 (*m_output) << indent << "<ltb_head";
00292 if (m_strict) {
00293 (*m_output) << " frame_count=\"" << head.rawTriggersSaved() << "\"";
00294 }
00295 (*m_output) << " format=\"" << head.version() << "\">" << endl;
00296 (*m_output) << nestedIndent << "<trigger_number>" << head.localTriggerNumber() << "</trigger_number>" << endl;
00297 (*m_output) << nestedIndent << "<internal_trigger_count>" << head.rawTriggerTotal() << "</internal_trigger_count>" << endl;
00298 (*m_output) << nestedIndent << "<status>" << head.ltbStatus() << "</status>" << endl;
00299 (*m_output) << indent << "</ltb_head>" << endl;
00300 }
00301
00302 void DaqXmlStream::dumpElement(const LtbReadout& readout) const {
00303 dumpElement(readout,
00304 emptyString);
00305 }
00306
00307 void DaqXmlStream::dumpElement(const LtbReadout& readout,
00308 const string& indent) const {
00309 dumpElement(readout.head(),
00310 indent);
00311 const LtbReadout::LtbFramePtrList& frames = readout.ltbFrames();
00312 LtbReadout::LtbFramePtrList::const_iterator frame;
00313 for (frame = frames.begin() ; frame != frames.end() ; ++frame) {
00314 dumpElement(**frame,
00315 indent);
00316 }
00317 dumpElement(readout.foot(),
00318 indent);
00319 }
00320
00321 void DaqXmlStream::dumpElement(const CbltBody& body) const {
00322 dumpElement(body,
00323 emptyString);
00324 }
00325
00326 void DaqXmlStream::dumpElement(const CbltBody& body,
00327 const string& indent) const {
00328 string nestedIndent = indent + (*m_indent);
00329 (*m_output) << indent << "<cblt_body>" << endl;
00330 const RomData& romData = body.data();
00331 const FadcReadout* fadcReadout;
00332 const FeeReadout* feeReadout;
00333 const LtbReadout* ltbReadout;
00334 if (0 != (fadcReadout = dynamic_cast<const FadcReadout*>(&romData))) {
00335 dumpElement(*fadcReadout,
00336 nestedIndent);
00337 } else if (0 != (feeReadout = dynamic_cast<const FeeReadout*>(&romData))) {
00338 dumpElement(*feeReadout,
00339 nestedIndent);
00340 } else if (0 != (ltbReadout = dynamic_cast<const LtbReadout*>(&romData))) {
00341 dumpElement(*ltbReadout,
00342 nestedIndent);
00343 } else {
00344 (*m_output) << nestedIndent << "<undefined/>" << endl;
00345 }
00346 (*m_output) << indent << "</cblt_body>" << endl;
00347 }
00348
00349 void DaqXmlStream::dumpElement(const CbltFoot& foot) const {
00350 dumpElement(foot,
00351 emptyString);
00352 }
00353
00354 void DaqXmlStream::dumpElement(const CbltFoot& foot,
00355 const string& indent) const {
00356 string nestedIndent = indent + (*m_indent);
00357 (*m_output) << indent << "<cblt_foot";
00358 if (m_strict) {
00359 (*m_output) << " length=\"" << foot.dataLength() << "\"";
00360 }
00361 (*m_output) << ">" << endl;
00362 (*m_output) << nestedIndent << "<module_address>" << foot.moduleAddress() << "</module_address>" << endl;
00363 (*m_output) << indent << "</cblt_foot>" << endl;
00364 }
00365
00366 void DaqXmlStream::dumpElement(const CbltHead& head) const {
00367 dumpElement(head,
00368 emptyString);
00369 }
00370
00371 void DaqXmlStream::dumpElement(const CbltHead& head,
00372 const string& indent) const {
00373 const CbltTraits& traits = head.cbltTraits();
00374 string nestedIndent = indent + (*m_indent);
00375 (*m_output) << indent << "<cblt_head>" << endl;
00376 (*m_output) << nestedIndent << "<module_type>" << traits.moduleTypeAsString(head.moduleType()) << "</module_type>" << endl;
00377 (*m_output) << nestedIndent << "<module_address>" << head.moduleAddress() << "</module_address>" << endl;
00378 (*m_output) << indent << "</cblt_head>" << endl;
00379 }
00380
00381 void DaqXmlStream::dumpElement(const CbltReadout& readout) const {
00382 dumpElement(readout,
00383 emptyString);
00384 }
00385
00386 void DaqXmlStream::dumpElement(const CbltReadout& readout,
00387 const string& indent) const {
00388 dumpElement(readout.head(),
00389 indent);
00390 dumpElement(readout.body(),
00391 indent);
00392 dumpElement(readout.foot(),
00393 indent);
00394 }
00395
00396 void DaqXmlStream::dumpElement(const RomHeader& header) const {
00397 dumpElement(header,
00398 emptyString);
00399 }
00400
00401 void DaqXmlStream::dumpElement(const RomHeader& header,
00402 const string& indent) const {
00403 const EventTraits& traits = header.eventTraits();
00404 string nestedIndent = indent + (*m_indent);
00405 (*m_output) << indent << "<rom_header";
00406 if (m_strict) {
00407 (*m_output) << " total_size=\"" << header.totalSize();
00408 (*m_output) << "\" header_size=\"" << header.headerSize() << "\"";
00409 }
00410 (*m_output) << ">" << endl;
00411 (*m_output) << nestedIndent << "<site>" << traits.siteAsString(header.site()) << "</site>" << endl;
00412 (*m_output) << nestedIndent << "<detector>" << traits.detectorAsString(header.detector()) << "</detector>" << endl;
00413 (*m_output) << nestedIndent << "<module_type>" << traits.moduleTypeAsString(header.moduleType()) << "</module_type>" << endl;
00414 (*m_output) << nestedIndent << "<slot>" << header.slot() << "</slot>" << endl;
00415 (*m_output) << indent << "</rom_header>" << endl;
00416 }
00417
00418 void DaqXmlStream::dumpElement(const RomFragment& fragment) const {
00419 dumpElement(fragment,
00420 emptyString);
00421 }
00422
00423 void DaqXmlStream::dumpElement(const RomFragment& fragment,
00424 const string& indent) const {
00425 string nestedIndent = indent + (*m_indent);
00426 string doubleIndent = nestedIndent + (*m_indent);
00427 (*m_output) << indent << "<rom_fragment>" << endl;
00428 dumpElement(fragment.header(),
00429 nestedIndent);
00430
00431 (*m_output) << nestedIndent << "<rom_data>" << endl;
00432 const RomData& romData = fragment.data();
00433 const CbltReadout* cbltReadout;
00434 const FadcReadout* fadcReadout;
00435 const FeeReadout* feeReadout;
00436 const LtbReadout* ltbReadout;
00437 if (0 != (cbltReadout = dynamic_cast<const CbltReadout*>(&romData))) {
00438 dumpElement(*cbltReadout,
00439 doubleIndent);
00440 } else if (0 != (fadcReadout = dynamic_cast<const FadcReadout*>(&romData))) {
00441 dumpElement(*fadcReadout,
00442 doubleIndent);
00443 } else if (0 != (feeReadout = dynamic_cast<const FeeReadout*>(&romData))) {
00444 dumpElement(*feeReadout,
00445 doubleIndent);
00446 } else if (0 != (ltbReadout = dynamic_cast<const LtbReadout*>(&romData))) {
00447 dumpElement(*ltbReadout,
00448 doubleIndent);
00449 } else {
00450 (*m_output) << doubleIndent << "<undefined/>" << endl;
00451 }
00452 (*m_output) << nestedIndent << "</rom_data>" << endl;
00453 (*m_output) << indent << "</rom_fragment>" << endl;
00454 }
00455
00456 void DaqXmlStream::dumpElement(const EventHeader& header) const {
00457 dumpElement(header,
00458 emptyString);
00459 }
00460
00461 void DaqXmlStream::dumpElement(const EventHeader& header,
00462 const string& indent) const {
00463 const EventTraits& traits = header.eventTraits();
00464 string nestedIndent = indent + (*m_indent);
00465 (*m_output) << indent << "<event_header";
00466 if (m_strict) {
00467 (*m_output) << " total_size=\"" << header.totalSize();
00468 (*m_output) << "\" header_size=\"" << header.headerSize() << "\"";
00469 }
00470 (*m_output) << " format=\"" << header.majorVersion() << "." << header.minorVersion() << "\">" << endl;
00471 (*m_output) << nestedIndent << "<site>" << traits.siteAsString(header.site()) << "</site>" << endl;
00472 (*m_output) << nestedIndent << "<detector>" << traits.detectorAsString(header.detector()) << "</detector>" << endl;
00473 (*m_output) << nestedIndent << "<run>" << header.run() << "</run>" << endl;
00474 (*m_output) << nestedIndent << "<event>" << header.event() << "</event>" << endl;
00475 (*m_output) << nestedIndent << "<data_type>" << traits.dataTypeAsString(header.dataType()) << "</data_type>" << endl;
00476 if (header.cbltWrapping() || m_strict) {
00477 (*m_output) << nestedIndent << "<cblt_wrapping>" << traits.boolAsString(header.cbltWrapping()) << "</cblt_wrapping>" << endl;
00478 }
00479 if (header.rawCblt() || m_strict) {
00480 (*m_output) << nestedIndent << "<raw_cblt>" << traits.boolAsString(header.rawCblt()) << "</raw_cblt>" << endl;
00481 }
00482 if (header.triggerMismatch() || m_strict) {
00483 (*m_output) << nestedIndent << "<trigger_mismatch>" << traits.boolAsString(header.triggerMismatch()) << "</trigger_mismatch>" << endl;
00484 }
00485 if (header.invalidData() || m_strict) {
00486 (*m_output) << nestedIndent << "<invalid_data>" << traits.boolAsString(header.invalidData()) << "</invalid_data>" << endl;
00487 }
00488 (*m_output) << indent << "</event_header>" << endl;
00489 }
00490
00491 void DaqXmlStream::dumpElement(const EventReadout& readout) const {
00492 dumpElement(readout,
00493 emptyString);
00494 }
00495
00496 void DaqXmlStream::dumpElement(const EventReadout& readout,
00497 const string& indent) const {
00498 string nestedIndent = indent + (*m_indent);
00499 (*m_output) << indent << "<event>" << endl;
00500 dumpElement(readout.header(),
00501 nestedIndent);
00502 const EventReadout::RomFragmentPtrList& fragments = readout.romFragments();
00503 for (EventReadout::RomFragmentPtrList::const_iterator fragment = fragments.begin();
00504 fragment != fragments.end();
00505 ++fragment) {
00506 dumpElement(*(*fragment),
00507 nestedIndent);
00508 }
00509 (*m_output) << indent << "</event>" << endl;
00510 }
00511
00512 void DaqXmlStream::dumpElement(const FileEndRecord& record) const {
00513 dumpElement(record,
00514 emptyString);
00515 }
00516
00517 void DaqXmlStream::dumpElement(const FileEndRecord& record,
00518 const string& indent) const {
00519 const FileTraits& traits = record.fileTraits();
00520 string nestedIndent = indent + (*m_indent);
00521 (*m_output) << indent << "<file_end_record";
00522 if (m_strict) {
00523 const char* last;
00524 if (record.endMarkerFound()) {
00525 last = "true";
00526 } else {
00527 last = "false";
00528 }
00529 (*m_output) << " last=\"" << last << "\" size=\"" << record.size() << "\"";
00530 }
00531 (*m_output) << ">" << endl;
00532 (*m_output) << nestedIndent << "<time>" << traits.dateTimeAsString(record.dateTime()) << "</time>" << endl;
00533 (*m_output) << nestedIndent << "<file_event_count>" << record.fileEventCount() << "</file_event_count>" << endl;
00534 (*m_output) << nestedIndent << "<file_payload_size>" << record.filePayloadSize() << "</file_payload_size>" << endl;
00535 (*m_output) << nestedIndent << "<run_event_count>" << record.runEventCount() << "</run_event_count>" << endl;
00536 (*m_output) << nestedIndent << "<run_payload_size>" << record.runPayloadSize() << "</run_payload__size>" << endl;
00537 (*m_output) << nestedIndent << "<status>" << record.status() << "</status>" << endl;
00538 (*m_output) << indent << "</file_end_record>" << endl;
00539 }
00540
00541 void DaqXmlStream::dumpElement(const DataSeparatorRecord& record) const {
00542 dumpElement(record,
00543 emptyString);
00544 }
00545
00546 void DaqXmlStream::dumpElement(const DataSeparatorRecord& record,
00547 const string& indent) const {
00548 if (m_strict) {
00549 string nestedIndent = indent + (*m_indent);
00550 (*m_output) << indent << "<data_separator_record block_number=\"" << record.blockNumber();
00551 (*m_output) << "\" block_length=\"" << record.blockLength();
00552 (*m_output) << "\" size=\"" << record.size() << "\">" << endl;
00553 }
00554 }
00555
00556 void DaqXmlStream::dumpElement(const CalibrationParametersRecord& record) const {
00557 dumpElement(record,
00558 emptyString);
00559 }
00560
00561 void DaqXmlStream::dumpElement(const CalibrationParametersRecord& record,
00562 const string& indent) const {
00563 string nestedIndent = indent + (*m_indent);
00564 (*m_output) << indent << "<calibration_parameters_record>" << endl;
00565 (*m_output) << nestedIndent << "<detector>" << record.detector() << "</detector>" << endl;
00566 (*m_output) << nestedIndent << "<axis>" << record.axis() << "</axis>" << endl;
00567 (*m_output) << nestedIndent << "<source>" << record.source() << "</source>" << endl;
00568 (*m_output) << nestedIndent << "<z_position>" << record.zPosition() << "</z_position>" << endl;
00569 (*m_output) << nestedIndent << "<duration>" << record.duration() << "</duration>" << endl;
00570 (*m_output) << nestedIndent << "<led_frequency>" << record.ledFrequency() << "</led_frequency>" << endl;
00571 (*m_output) << nestedIndent << "<ltb_mode>" << record.ltbMode() << "</ltb_mode>" << endl;
00572 (*m_output) << indent << "</calibration_parameters_record>" << endl;
00573 }
00574
00575 void DaqXmlStream::dumpElement(const RunParametersRecord& record) const {
00576 dumpElement(record,
00577 emptyString);
00578 }
00579
00580 void DaqXmlStream::dumpElement(const RunParametersRecord& record,
00581 const string& indent) const {
00582 const FileTraits& traits = record.fileTraits();
00583 string nestedIndent = indent + (*m_indent);
00584 string doubleIndent = nestedIndent + (*m_indent);
00585 (*m_output) << indent << "<run_parameters_record";
00586 if (m_strict) {
00587 (*m_output) << " size=\"" << record.size() << "\"";
00588 }
00589 (*m_output) << ">" << endl;
00590 (*m_output) << nestedIndent << "<run>" << record.runNumber() << "</run>" << endl;
00591 (*m_output) << nestedIndent << "<record_enabled>" << record.recordEnabled() << "</record_enabled>" << endl;
00592 const LtbTraits::TriggerLines* detectors = traits.detectorList(record.detectorMask());
00593 if (detectors->empty()) {
00594 (*m_output) << nestedIndent << "<detector_mask/>" << endl;
00595 } else {
00596 (*m_output) << nestedIndent << "<detector_mask>" << endl;
00597 LtbTraits::TriggerLines::const_iterator detector;
00598 for (detector = detectors->begin() ; detector != detectors->end() ; ++detector) {
00599 (*m_output) << doubleIndent << "<" << *detector << "/>" << endl;
00600 }
00601 (*m_output) << nestedIndent << "</detector_mask>" << endl;
00602 }
00603 delete detectors;
00604 (*m_output) << indent << "</run_parameters_record>" << endl;
00605 }
00606
00607 void DaqXmlStream::dumpElement(const MetadataStrings& record) const {
00608 dumpElement(record,
00609 emptyString);
00610 }
00611
00612 void DaqXmlStream::dumpElement(const MetadataStrings& record,
00613 const string& indent) const {
00614 string nestedIndent = indent + (*m_indent);
00615 const MetadataStrings::MetadataStringPtrList& strings = record.metadataStrings();
00616 (*m_output) << indent << "<metadata_strings";
00617 if (m_strict) {
00618 (*m_output) << " size=\"" << record.size() << "\"";
00619 (*m_output) << " string_count=\"" << strings.size() << "\"";
00620 }
00621 (*m_output) << ">" << endl;
00622 MetadataStrings::MetadataStringPtrList::const_iterator entry;
00623 for (entry = strings.begin();
00624 entry != strings.end();
00625 ++entry) {
00626 (*m_output) << nestedIndent << "<tag>" << (*entry)->first << "</tag>" << endl;
00627 (*m_output) << nestedIndent << "<value>" << (*entry)->second << "</value>" << endl;
00628 }
00629 (*m_output) << indent << "</metadata_strings>" << endl;
00630 }
00631
00632 void DaqXmlStream::dumpElement(const FileNameStrings& record) const {
00633 dumpElement(record,
00634 emptyString);
00635 }
00636
00637 void DaqXmlStream::dumpElement(const FileNameStrings& record,
00638 const string& indent) const {
00639 string nestedIndent = indent + (*m_indent);
00640 (*m_output) << indent << "<file_name_strings";
00641 if (m_strict) {
00642 (*m_output) << " size=\"" << record.size() << "\"";
00643 }
00644 (*m_output) << ">" << endl;
00645 (*m_output) << nestedIndent << "<application>" << record.application() << "</application>" << endl;
00646 (*m_output) << nestedIndent << "<file_base>" << record.fileBase() << "</file_base>" << endl;
00647 (*m_output) << indent << "</file_name_strings>" << endl;
00648 }
00649
00650 void DaqXmlStream::dumpElement(const FileStartRecord& record) const {
00651 dumpElement(record,
00652 emptyString);
00653 }
00654
00655 void DaqXmlStream::dumpElement(const FileStartRecord& record,
00656 const string& indent) const {
00657 const FileTraits& traits = record.fileTraits();
00658 string nestedIndent = indent + (*m_indent);
00659 (*m_output) << indent << "<file_start_record format=\"" << record.majorVersion() << "." << record.minorVersion();
00660 if (m_strict) {
00661 (*m_output) << "\" size=\"" << record.size();
00662 }
00663 (*m_output) << "\">" << endl;
00664 (*m_output) << nestedIndent << "<file_number>" << record.fileNumber() << "</file_number>" << endl;
00665 (*m_output) << nestedIndent << "<time>" << traits.dateTimeAsString(record.dateTime()) << "</time>" << endl;
00666 (*m_output) << nestedIndent << "<data_block_limit>" << record.dataBlockLimit() << "</data_block_limit>" << endl;
00667 (*m_output) << nestedIndent << "<megabyte_limit>" << record.megabyteLimit() << "</megabyte_limit>" << endl;
00668 (*m_output) << indent << "</file_start_record>" << endl;
00669 }
00670
00671 void DaqXmlStream::dumpElement(const FileBuffer& record) const {
00672 dumpElement(record,
00673 emptyString);
00674 }
00675
00676 void DaqXmlStream::dumpElement(const FileBuffer& record,
00677 const string& indent) const {
00678 if (record.isMarked(FileTraits::kFileStartRecord)) {
00679 const FileStartRecord* fileStartRecord = dynamic_cast<const FileStartRecord*>(&record);
00680 dumpElement(*fileStartRecord,
00681 indent);
00682 } else if (record.isMarked(FileTraits::kFileNameStrings)) {
00683 const FileNameStrings* fileNameStrings = dynamic_cast<const FileNameStrings*>(&record);
00684 dumpElement(*fileNameStrings,
00685 indent);
00686 } else if (record.isMarked(FileTraits::kMetadataStrings)) {
00687 const MetadataStrings* metadataStrings = dynamic_cast<const MetadataStrings*>(&record);
00688 dumpElement(*metadataStrings,
00689 indent);
00690 } else if (record.isMarked(FileTraits::kRunParametersRecord)) {
00691 const RunParametersRecord* runParametersRecord = dynamic_cast<const RunParametersRecord*>(&record);
00692 dumpElement(*runParametersRecord,
00693 indent);
00694 } else if (record.isMarked(FileTraits::kCalibrationParametersRecord)) {
00695 const CalibrationParametersRecord* calibrationParametersRecord = dynamic_cast<const CalibrationParametersRecord*>(&record);
00696 dumpElement(*calibrationParametersRecord,
00697 indent);
00698 } else if (record.isMarked(FileTraits::kDataSeparatorRecord)) {
00699 const DataSeparatorRecord* dataSeparatorRecord = dynamic_cast<const DataSeparatorRecord*>(&record);
00700 dumpElement(*dataSeparatorRecord,
00701 indent);
00702 } else if (record.isMarked(FileTraits::kFileEndRecord)) {
00703 const FileEndRecord* fileEndRecord = dynamic_cast<const FileEndRecord*>(&record);
00704 dumpElement(*fileEndRecord,
00705 indent);
00706 }
00707 }