File indexing completed on 2023-03-17 11:12:54
0001
0002
0003
0004
0005
0006
0007
0008 #include "DataFormats/Provenance/interface/EventID.h"
0009 #include "FWCore/Common/interface/EventBase.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OmtfName.h"
0012 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinput.h"
0013 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLEventWriter.h"
0014
0015 XMLEventWriter::XMLEventWriter(const OMTFConfiguration* aOMTFConfig, std::string fName)
0016 : omtfConfig(aOMTFConfig), xmlWriter(aOMTFConfig), currentElement(nullptr), fName(fName) {
0017
0018 xmlWriter.initialiseXMLDocument("OMTF");
0019 eventNum = 0;
0020 };
0021
0022 XMLEventWriter::~XMLEventWriter() {}
0023
0024 void XMLEventWriter::observeProcesorEmulation(unsigned int iProcessor,
0025 l1t::tftype mtfType,
0026 const std::shared_ptr<OMTFinput>& input,
0027 const AlgoMuons& algoCandidates,
0028 const AlgoMuons& gbCandidates,
0029 const std::vector<l1t::RegionalMuonCand>& candMuons) {
0030 if (eventNum > 5000)
0031 return;
0032
0033 int endcap = (mtfType == l1t::omtf_neg) ? -1 : ((mtfType == l1t::omtf_pos) ? +1 : 0);
0034 OmtfName board(iProcessor, endcap);
0035
0036 if (candMuons.empty())
0037 return;
0038
0039
0040
0041
0042 xercesc::DOMElement* aProcElement = xmlWriter.writeEventData(currentElement, board, *(input.get()));
0043
0044 for (auto& algoCand : algoCandidates) {
0045
0046 if (algoCand->isValid()) {
0047 xmlWriter.writeAlgoMuon(aProcElement, *algoCand);
0048
0049
0050
0051
0052 }
0053 }
0054
0055 for (auto& candMuon : candMuons)
0056 xmlWriter.writeCandMuon(aProcElement, candMuon);
0057 }
0058
0059 void XMLEventWriter::observeEventBegin(const edm::Event& iEvent) {
0060 eventNum++;
0061 if (eventNum > 5000)
0062
0063 return;
0064
0065 eventId = iEvent.id().event();
0066 currentElement = xmlWriter.writeEventHeader(eventId);
0067 }
0068
0069 void XMLEventWriter::observeEventEnd(const edm::Event& iEvent,
0070 std::unique_ptr<l1t::RegionalMuonCandBxCollection>& finalCandidates) {
0071 currentElement = nullptr;
0072 }
0073
0074 void XMLEventWriter::endJob() { xmlWriter.finaliseXMLDocument(fName); }