diff --git a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuCalStreamerTool.cxx b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuCalStreamerTool.cxx index 7d2c1685bbbe2546225213adf607abab9d3b9921..dc9e83e0c8a56eec3b48561c637abfba4ac0fb43 100644 --- a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuCalStreamerTool.cxx +++ b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuCalStreamerTool.cxx @@ -33,11 +33,6 @@ StatusCode TrigL2MuonSA::MuCalStreamerTool::initialize () ATH_CHECK( m_regSel_MDT.retrieve() ); ATH_CHECK( m_regSel_TGC.retrieve() ); - - m_localBuffer.clear(); - - m_localBufferSize = 0; - ATH_CHECK(m_tgcRdoKey.initialize()); ATH_CHECK(m_readKey.initialize()); ATH_CHECK(m_eventInfoKey.initialize()); @@ -113,21 +108,17 @@ bool TrigL2MuonSA::MuCalStreamerTool::isStreamOpen() {return m_circ!=nullptr;} TrigL2MuonSA::MdtHits& mdtHits, TrigL2MuonSA::RpcHits& rpcHits, TrigL2MuonSA::TgcHits& tgcHits, - // int calBufferSize, - bool doDataScouting, - bool &updateTriggerElement, const EventContext& ctx) const + std::vector<uint32_t>& localBuffer, // Add localBuffer parameter + bool doDataScouting, + const EventContext& ctx) const { - // create the fragment - // ( dummy input for now ) - ATH_MSG_DEBUG("Data scouting is set to"<<doDataScouting); // skip the event if it's a noise burst unsigned int totalHits = mdtHits.size()+rpcHits.size()+tgcHits.size(); if ( totalHits > 500 ) { ATH_MSG_DEBUG("Too many hits: skip the RoI"); - updateTriggerElement=false; return StatusCode::SUCCESS; } @@ -232,6 +223,40 @@ bool TrigL2MuonSA::MuCalStreamerTool::isStreamOpen() {return m_circ!=nullptr;} m_circ->dumpToCirc (event); } + + if (doDataScouting) { + // Perform data scouting specific operations + uint16_t eventSize_ds = event.size(); + if (eventSize_ds>1000) return StatusCode::SUCCESS; + + std::unique_ptr<uint8_t[]> buff_ds = std::make_unique<uint8_t[]>(eventSize_ds); + + // encode the event + uint16_t eventSize8bits = eventSize_ds; + uint16_t eventSize32bits = eventSize8bits/4; + event.dumpWords(buff_ds.get(),eventSize_ds); + + // fill the local buffer + // dump the words also in the local buffer + // dump the encoded event to the screen + ATH_MSG_DEBUG("Size of the DATASCOUTING buffer in 32 bits words: " << eventSize32bits); + for ( uint16_t words = 0 ; words != eventSize32bits ; words++) { + uint32_t byte1 = buff_ds[words*4]; + uint32_t byte2 = buff_ds[words*4 + 1]; + uint32_t byte3 = buff_ds[words*4 + 2]; + uint32_t byte4 = buff_ds[words*4 + 3]; + + // encoding in big-endian for now ( revert order for little-endian ) + uint32_t dataWord = (byte4 << 24) + (byte3 << 16) + (byte2 << 8) + byte1 ; + // std::cout << "Number of data words: " << words << std::endl; + ATH_MSG_DEBUG("Data word " << words << " = " << std::hex << "0x" << dataWord << std::dec); + + localBuffer.push_back(dataWord); + } + + ATH_MSG_DEBUG("Local buffer size = " << localBuffer.size()); + + } return StatusCode::SUCCESS; } diff --git a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuCalStreamerTool.h b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuCalStreamerTool.h index fb615f289c747078c396bdfea010b950c308f2fa..201d6e554bdaf74b3a6c586e124978a7c6f5f93f 100644 --- a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuCalStreamerTool.h +++ b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuCalStreamerTool.h @@ -67,11 +67,6 @@ namespace TrigL2MuonSA { // set the properties void setBufferName(const std::string& buffName) {m_calBufferName=buffName;} - std::vector<int>* getLocalBuffer() {return &m_localBuffer;} - int getLocalBufferSize() const {return m_localBuffer.size();} - /* void clearLocalBuffer(); */ - - // // initialize the stream StatusCode openStream(int calBufferSize); @@ -88,9 +83,9 @@ namespace TrigL2MuonSA { TrigL2MuonSA::MdtHits& mdtHits, TrigL2MuonSA::RpcHits& rpcHits, TrigL2MuonSA::TgcHits& tgcHits, - //int calBufferSize, + std::vector<uint32_t>& localBuffer, // Add localBuffer parameter bool doDataScouting, - bool& updateTriggerElement, const EventContext& ctx) const; + const EventContext& ctx) const; private: @@ -107,40 +102,25 @@ namespace TrigL2MuonSA { // output file std::ofstream m_outputFile; - - // the region selector ToolHandle<IRegSelTool> m_regSel_MDT{this, "RegSel_MDT", "RegSelTool/RegSelTool_MDT", "MDT Region Selector Tool"}; ToolHandle<IRegSelTool> m_regSel_TGC{this, "RegSel_TGC", "RegSelTool/RegSelTool_TGC", "TGC Region Selector Tool"}; - - SG::ReadCondHandleKey<RpcCablingCondData> m_readKey{this, "ReadKey", "RpcCablingCondData", "Key of RpcCablingCondData"}; - - - // local buffer for the TrigComposite object - int m_localBufferSize = 0; - std::vector<int> m_localBuffer; - - // // create the MDT fragment StatusCode createMdtFragment(TrigL2MuonSA::MdtHits& mdtHits, LVL2_MUON_CALIBRATION::MdtCalibFragment& mdtFragment, float phi) const; - // // create the RPC fragment StatusCode createRpcFragment(const xAOD::MuonRoI* roi, - LVL2_MUON_CALIBRATION::RpcCalibFragment& rpcFragment, const EventContext& ctx) const; + LVL2_MUON_CALIBRATION::RpcCalibFragment& rpcFragment, const EventContext& ctx) const; - // // create the TGC fragment StatusCode createTgcFragment(std::vector<uint32_t>& tgcRobIdList, LVL2_MUON_CALIBRATION::TgcCalibFragment& tgcFragment) const; - - TrigL2MuonSA::MuCalCircClient *m_circ = nullptr; }; diff --git a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuFastSteering.cxx b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuFastSteering.cxx index c8ac2c04a734f6fc7c965c15d87592e24c36abac..48331d764a4a271cdf1dbfddb3f9e0d76752dc7e 100644 --- a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuFastSteering.cxx +++ b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuFastSteering.cxx @@ -353,7 +353,7 @@ StatusCode MuFastSteering::execute(const EventContext& ctx) const else { // to StatusCode findMuonSignature() ATH_CHECK(findMuonSignature(internalRoI, recRoIVector, - *muFastContainer, *muIdContainer, *muMsContainer, dynamicDeltaRpc, ctx)); + *muFastContainer, *muCompositeContainer, *muIdContainer, *muMsContainer, dynamicDeltaRpc, ctx)); } if (msgLvl(MSG::DEBUG)) { @@ -820,6 +820,7 @@ StatusCode MuFastSteering::findMuonSignature(const std::vector<const TrigRoiDesc StatusCode MuFastSteering::findMuonSignature(const std::vector<const TrigRoiDescriptor*>& roids, const std::vector<const xAOD::MuonRoI*>& muonRoIs, DataVector<xAOD::L2StandAloneMuon>& outputTracks, + xAOD::TrigCompositeContainer& outputMuonCal, TrigRoiDescriptorCollection& outputID, TrigRoiDescriptorCollection& outputMS, const bool dynamicDeltaRpc, @@ -1106,18 +1107,34 @@ StatusCode MuFastSteering::findMuonSignature(const std::vector<const TrigRoiDesc //--------------------------- if (m_doCalStream && trackPatterns.size()>0 ) { TrigL2MuonSA::TrackPattern tp = trackPatterns[0]; - bool updateTriggerElement = false; - //int calBS = m_calBufferSize; - bool calDS = m_calDataScouting; + std::vector<uint32_t> localBuffer; // init localBuffer parameter sc = m_calStreamer->createRoiFragment(*p_roi,tp,mdtHits_normal, rpcHits, tgcHits, - //calBS, - calDS, - updateTriggerElement,ctx); + localBuffer, + m_calDataScouting, + ctx); if (sc != StatusCode::SUCCESS ) { ATH_MSG_WARNING("Calibration streamer: create Roi Fragment failed"); } + // if it's a data scouting chain + if ( m_calDataScouting ) { + + ATH_MSG_DEBUG("Retrieved the buffer, with size: " << localBuffer.size()); + + // create the TrigCompositeContainer to store the calibration buffer + // add the trigcomposite object to the container outputMuonCal + xAOD::TrigComposite* tc = new xAOD::TrigComposite(); + outputMuonCal.push_back(tc); + + ATH_MSG_DEBUG("The size of the TrigCompositeContainer is: " << outputMuonCal.size() ); + + // set the detail of the trigcomposite object + tc->setDetail("MuonCalibrationStream", localBuffer ); + + } + + } diff --git a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuFastSteering.h b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuFastSteering.h index 0cee20fa6a676a2a36732e2a0892d20b2a1137ac..5873810959259b1e3a5c549884b652126baa4f8f 100644 --- a/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuFastSteering.h +++ b/Trigger/TrigAlgorithms/TrigL2MuonSA/src/MuFastSteering.h @@ -78,7 +78,8 @@ class MuFastSteering : public AthReentrantAlgorithm , public IIncidentListener StatusCode findMuonSignature(const std::vector<const TrigRoiDescriptor*>& roi, const std::vector<const xAOD::MuonRoI*>& muonRoIs, - DataVector<xAOD::L2StandAloneMuon>& outputTracks, + DataVector<xAOD::L2StandAloneMuon>& outputTracks, + xAOD::TrigCompositeContainer& outputMuonCal, TrigRoiDescriptorCollection& outputID, TrigRoiDescriptorCollection& outputMS, const bool dynamicDeltaRpc,