diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a1de471b55ca91c4c33703bacd8acd6047bb6d9..8664418f3e865f0fa17c83603dbdee6a4b800ea9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -420,30 +420,32 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") string(APPEND CMAKE_CXX_FLAGS " -Wno-gnu-zero-variadic-macro-arguments") endif() -#Detect target CPU architecture -include(TargetArch) -set(TARGET_CPU_ARCHITECTURE "") -target_architecture(TARGET_CPU_ARCHITECTURE) -message(STATUS "Detected CPU architecture: ${TARGET_CPU_ARCHITECTURE}") - -#Specific optimizations for different architectures -if(TARGET_CPU_ARCHITECTURE STREQUAL "x86_64" OR TARGET_CPU_ARCHITECTURE STREQUAL "i386" +if(STANDALONE) + #Detect target CPU architecture + include(TargetArch) + set(TARGET_CPU_ARCHITECTURE "") + target_architecture(TARGET_CPU_ARCHITECTURE) + message(STATUS "Detected CPU architecture: ${TARGET_CPU_ARCHITECTURE}") + + #Specific optimizations for different architectures + if(TARGET_CPU_ARCHITECTURE STREQUAL "x86_64" OR TARGET_CPU_ARCHITECTURE STREQUAL "i386" OR TARGET_CPU_ARCHITECTURE STREQUAL "ia64") -#x86 family - string(APPEND CMAKE_CXX_FLAGS " -march=${CPU_ARCH}") -elseif(TARGET_CPU_ARCHITECTURE STREQUAL "ppc" OR TARGET_CPU_ARCHITECTURE STREQUAL "ppc64") -#PowerPC family -#More options on : https: // developer.ibm.com/linuxonpower/compiler-options-table/ - string(APPEND CMAKE_CXX_FLAGS " -mcpu=${CPU_ARCH}") -elseif(TARGET_CPU_ARCHITECTURE STREQUAL "arm" OR TARGET_CPU_ARCHITECTURE STREQUAL "armv5" + #x86 family + string(APPEND CMAKE_CXX_FLAGS " -march=${CPU_ARCH}") + elseif(TARGET_CPU_ARCHITECTURE STREQUAL "ppc" OR TARGET_CPU_ARCHITECTURE STREQUAL "ppc64") + #PowerPC family + #More options on : https: // developer.ibm.com/linuxonpower/compiler-options-table/ + string(APPEND CMAKE_CXX_FLAGS " -mcpu=${CPU_ARCH}") + elseif(TARGET_CPU_ARCHITECTURE STREQUAL "arm" OR TARGET_CPU_ARCHITECTURE STREQUAL "armv5" OR TARGET_CPU_ARCHITECTURE STREQUAL "armv6" OR TARGET_CPU_ARCHITECTURE STREQUAL "armv7") -#ARM family - string(APPEND CMAKE_CXX_FLAGS " -march=${CPU_ARCH}") -elseif(TARGET_CPU_ARCHITECTURE STREQUAL "aarch64") -#ARM64 family -#Options from : http: // www.prace-ri.eu/IMG/pdf/Best-Practice-Guide-ARM64.pdf - string(APPEND CMAKE_CXX_FLAGS " -march=${CPU_ARCH} -floop-optimize \ --falign-loops -falign-labels -falign-functions -falign-jumps -fomit-frame-pointer") + #ARM family + string(APPEND CMAKE_CXX_FLAGS " -march=${CPU_ARCH}") + elseif(TARGET_CPU_ARCHITECTURE STREQUAL "aarch64") + #ARM64 family + #Options from : http: // www.prace-ri.eu/IMG/pdf/Best-Practice-Guide-ARM64.pdf + string(APPEND CMAKE_CXX_FLAGS " -march=${CPU_ARCH} -floop-optimize \ + -falign-loops -falign-labels -falign-functions -falign-jumps -fomit-frame-pointer") + endif() endif() find_package(ZLIB REQUIRED) diff --git a/Dumpers/BinaryDumpers/options/dump.py b/Dumpers/BinaryDumpers/options/dump.py index aa6b45c32090fc3a9ab94afc470ba810be970fff..66c628c27d12cd07c0b7358e584d234eca7ab74f 100644 --- a/Dumpers/BinaryDumpers/options/dump.py +++ b/Dumpers/BinaryDumpers/options/dump.py @@ -20,10 +20,10 @@ from Configurables import (DumpUTGeometry, DumpFTGeometry, DumpMuonTable, DumpVPGeometry) from Configurables import RootHistCnv__PersSvc from Configurables import IODataManager -from Configurables import (VPClus, createODIN, DumpRawBanks, DumpUTHits, +from Configurables import (VPClus, createODIN, TransposeRawBanks, DumpRawBanks, DumpFTHits, DumpMuonCoords, DumpMuonCommonHits, DumpMagneticField, DumpBeamline, MuonRec, - PrepareMuonHits) + PrepareMuonHits, DumpUTHits) from Configurables import TestMuonTable app = LHCbApp( @@ -63,7 +63,9 @@ ApplicationMgr().ExtSvc += [ ] # Dump raw banks and UT, FT and muon hits -dump_banks = DumpRawBanks(BankTypes=["VP", "UT", "FTCluster", "Muon"]) +transpose_banks = TransposeRawBanks(BankTypes=["VP", "UT", "FTCluster", + "Muon", "ODIN"]) +dump_banks = DumpRawBanks() dump_ut = DumpUTHits() dump_ft = DumpFTHits() dump_muon_coords = DumpMuonCoords() @@ -71,8 +73,8 @@ dump_muon_hits = DumpMuonCommonHits() dump_seq = GaudiSequencer("DumpSeq") dump_seq.Members += [ - dump_banks, dump_ut, dump_ft, dump_muon_coords, dump_muon_hits, - TestMuonTable() + transpose_banks, dump_banks, dump_ut, dump_ft, + dump_muon_coords, dump_muon_hits, TestMuonTable() ] ApplicationMgr().TopAlg = [dec_seq, dump_seq] diff --git a/Dumpers/BinaryDumpers/options/dump_banks.py b/Dumpers/BinaryDumpers/options/dump_banks.py index 95f37bd13da7c9bd402706b9ddb06d4594d8ad3f..1106de77dd950b0b4b40a45f498c60516856e990 100644 --- a/Dumpers/BinaryDumpers/options/dump_banks.py +++ b/Dumpers/BinaryDumpers/options/dump_banks.py @@ -19,7 +19,7 @@ from Configurables import DumpUTGeometry from Configurables import RootHistCnv__PersSvc from Configurables import (VPClus, createODIN, DumpRawBanks, DumpUTHits, DumpFTHits, DumpMuonCoords, DumpMuonCommonHits, - MuonRec, PrepareMuonHits) + MuonRec, PrepareMuonHits, TransposeRawBanks) # new MC in tmp/ #DDDBtag = "dddb-20171010" @@ -59,14 +59,12 @@ dec_seq.Members = [ ApplicationMgr().ExtSvc += [DumpUTGeometry()] # Dump raw banks and UT, FT and muon hits -dump_banks = DumpRawBanks(BankTypes=["VP", "UT", "FTCluster", "Muon"]) -#dump_banks.OutputDirectory = "/eos/lhcb/wg/rta/WP6/Allen/binary_input_2019-07/minbias/mag_down/banks" -dump_muon_coords = DumpMuonCoords() -#dump_muon_coords.OutputDirectory = "/eos/lhcb/wg/rta/WP6/Allen/binary_input_2019-07/minbias/mag_down/muon_coords" -dump_muon_hits = DumpMuonCommonHits() -#dump_muon_hits.OutputDirectory = "/eos/lhcb/wg/rta/WP6/Allen/binary_input_2019-07/minbias/mag_down/muon_common_hits" +transpose_banks = TransposeRawBanks( + BankTypes=["VP", "UT", "FTCluster", "Muon", "ODIN"], + RawEventLocations=["DAQ/RawEvent"]) +dump_banks = DumpRawBanks() dump_seq = GaudiSequencer("DumpSeq") -dump_seq.Members += [dump_banks] +dump_seq.Members += [transpose_banks, dump_banks] ApplicationMgr().TopAlg = [dec_seq, dump_seq] diff --git a/Dumpers/BinaryDumpers/src/DumpGeometry.h b/Dumpers/BinaryDumpers/src/DumpGeometry.h index 094ce736bbcd8830667bad1153c9ca944000e8fa..8272c486db32e517fb3fec73dd8503d68f18b944 100644 --- a/Dumpers/BinaryDumpers/src/DumpGeometry.h +++ b/Dumpers/BinaryDumpers/src/DumpGeometry.h @@ -243,7 +243,7 @@ StatusCode DumpGeometry::initialize() } }); } - + return sc; } diff --git a/Dumpers/BinaryDumpers/src/DumpRawBanks.cpp b/Dumpers/BinaryDumpers/src/DumpRawBanks.cpp index b46c2bc82e32b12563c0603c65541fbcea381b40..9b21d2571364325eadfcd60f9a1c047d3e8537c7 100644 --- a/Dumpers/BinaryDumpers/src/DumpRawBanks.cpp +++ b/Dumpers/BinaryDumpers/src/DumpRawBanks.cpp @@ -8,17 +8,20 @@ * granted to it by virtue of its status as an Intergovernmental Organization * * or submit itself to any jurisdiction. * \*****************************************************************************/ -#include +#include +#include +#include +#include +#include #include -#include - +#include +#include #include -#include -#include +#include +#include -#include "DumpRawBanks.h" #include "Utils.h" namespace { @@ -27,152 +30,78 @@ namespace { namespace fs = boost::filesystem; } // namespace -// Parsers are in namespace LHCb for ADL to work. -namespace LHCb { - - StatusCode parse(std::set& s, const std::string& in) - { - std::set ss; - using Gaudi::Parsers::parse; - auto sc = parse(ss, in); - if (!sc) return sc; - s.clear(); - try { - std::transform(begin(ss), end(ss), std::inserter(s, begin(s)), [](const std::string& s) { - RawBank::BankType t {}; - auto sc = parse(t, s); - if (!sc) throw GaudiException("Bad Parse", "", sc); - return t; - }); - } catch (const GaudiException& ge) { - return ge.code(); - } - return StatusCode::SUCCESS; - } - - StatusCode parse(RawBank::BankType& result, const std::string& in) - { - static std::unordered_map types; - if (types.empty()) { - for (int t = 0; t < RawBank::LastType; ++t) { - auto bt = static_cast(t); - types.emplace(RawBank::typeName(bt), bt); - } - } - - // This takes care of quoting - std::string input; - using Gaudi::Parsers::parse; - auto sc = parse(input, in); - if (!sc) return sc; - - auto it = types.find(input); - if (it != end(types)) { - result = it->second; - return StatusCode::SUCCESS; - } - else { - return StatusCode::FAILURE; - } - } - - inline std::ostream& toStream(const RawBank::BankType& bt, std::ostream& s) - { - return s << "'" << RawBank::typeName(bt) << "'"; - } -} // namespace LHCb - -// Declaration of the Algorithm Factory -DECLARE_COMPONENT(DumpRawBanks) - -DumpRawBanks::DumpRawBanks(const std::string& name, ISvcLocator* pSvcLocator) : - Transformer( - name, - pSvcLocator, - // Inputs - {KeyValue {"RawEventLocation", LHCb::RawEventLocation::Default}, - KeyValue {"ODINLocation", LHCb::ODINLocation::Default}}, - // Output - KeyValue {"AllenRawInput", "Allen/Raw/Input"}) -{} - -StatusCode DumpRawBanks::initialize() -{ - info() << "Dumping RawBank Types:"; - for (const auto bankType : m_bankTypes) { - auto tn = LHCb::RawBank::typeName(bankType); - info() << " " << tn; - if (!DumpUtils::createDirectory(outputDirectory(bankType))) { - error() << "Failed to create directory " << m_outputDirectory.value() << endmsg; - return StatusCode::FAILURE; - } - m_histos[tn] = book1D(tn, -0.5, 603.5, 151); - } - info() << endmsg; - return StatusCode::SUCCESS; -} - -std::array, LHCb::RawBank::LastType> DumpRawBanks::operator()( - const LHCb::RawEvent& rawEvent, - const LHCb::ODIN& odin) const -{ +/** @class DumpRawBanks DumpRawBanks.h + * Algorithm that dumps raw banks to binary files. + * + * @author Roel Aaij + * @date 2018-08-27 + */ +class DumpRawBanks : public Gaudi::Functional::Consumer, LHCb::RawBank::LastType> const&, LHCb::ODIN const& )> { +public: + /// Standard constructor + DumpRawBanks( const std::string& name, ISvcLocator* pSvcLocator ); - std::array, LHCb::RawBank::LastType> output; + StatusCode initialize() override; - for (const auto bankType : m_bankTypes) { - auto tBanks = rawEvent.banks(bankType); - const uint32_t number_of_rawbanks = tBanks.size(); - uint32_t offset = 0; + void operator()( std::array, LHCb::RawBank::LastType> const& banks, + LHCb::ODIN const& odin ) const override; - std::vector bankOffsets; - std::vector bankData; - bankOffsets.push_back(0); +private: + std::string outputDirectory( LHCb::RawBank::BankType bankType ) const; - for (auto& bank : tBanks) { - const uint32_t sourceID = static_cast(bank->sourceID()); - bankData.push_back(sourceID); + mutable bool m_createdDirectories{false}; + mutable std::mutex m_dirMutex; - offset++; + Gaudi::Property m_outputDirectory{this, "OutputDirectory", "banks"}; +}; - auto bStart = bank->begin(); - auto bEnd = bank->end(); +DumpRawBanks::DumpRawBanks( const std::string& name, ISvcLocator* pSvcLocator ) + : Consumer( + name, pSvcLocator, + // Inputs + {KeyValue{"BanksLocation", "Allen/Raw/Input"}, KeyValue{"ODINLocation", LHCb::ODINLocation::Default}} ) {} - // Debug/testing histogram with the sizes of the binary data per bank - auto tn = LHCb::RawBank::typeName(bankType); - auto hit = m_histos.find(tn); - if (UNLIKELY(hit == end(m_histos))) { - warning() << "No histogram booked for bank type " << tn << endmsg; - } - else { - hit->second->fill((bEnd - bStart) * sizeof(uint32_t)); - } - - while (bStart != bEnd) { - const uint32_t raw_data = *(bStart); - bankData.push_back(raw_data); +StatusCode DumpRawBanks::initialize() { + debug() << endmsg; + return StatusCode::SUCCESS; +} - bStart++; - offset++; +void DumpRawBanks::operator()( std::array, LHCb::RawBank::LastType> const& banks, + LHCb::ODIN const& odin ) const { + if ( !m_createdDirectories ) { + std::lock_guard{m_dirMutex}; + if ( !m_createdDirectories ) { + for ( int bt = 0; bt != LHCb::RawBank::LastType; ++bt ) { + auto bankType = static_cast( bt ); + if ( !banks[bankType].empty() ) { + auto tn = LHCb::RawBank::typeName( bankType ); + if ( !DumpUtils::createDirectory( outputDirectory( bankType ) ) ) { + throw GaudiException{"Failed to create directory " + m_outputDirectory.value(), name(), + StatusCode::FAILURE}; + } + } } - bankOffsets.push_back(offset * sizeof(uint32_t)); + m_createdDirectories = true; } + } - // Dumping number_of_rawbanks + 1 offsets! - DumpUtils::Writer bank_buffer; - bank_buffer.write(number_of_rawbanks, bankOffsets, bankData); - output[bankType] = bank_buffer.buffer(); - if (m_dumpToFile) { - DumpUtils::FileWriter outfile = - outputDirectory(bankType) + "/" + to_string(odin.runNumber()) + "_" + to_string(odin.eventNumber()) + ".bin"; - outfile.write(bank_buffer.buffer()); + for ( int bt = 0; bt != LHCb::RawBank::LastType; ++bt ) { + auto bankType = static_cast( bt ); + auto const& rawBanks = banks[bankType]; + if ( !rawBanks.empty() ) { + DumpUtils::FileWriter outfile = outputDirectory( bankType ) + "/" + to_string( odin.runNumber() ) + "_" + + to_string( odin.eventNumber() ) + ".bin"; + outfile.write( rawBanks ); } } - return output; } -std::string DumpRawBanks::outputDirectory(LHCb::RawBank::BankType bankType) const -{ - auto tn = LHCb::RawBank::typeName(bankType); - auto dir = fs::path {m_outputDirectory.value()} / tn; +std::string DumpRawBanks::outputDirectory( LHCb::RawBank::BankType bankType ) const { + auto tn = LHCb::RawBank::typeName( bankType ); + auto dir = fs::path{m_outputDirectory.value()} / tn; return dir.string(); } + +// Declaration of the Algorithm Factory +DECLARE_COMPONENT( DumpRawBanks ) diff --git a/Dumpers/BinaryDumpers/src/DumpRawBanks.h b/Dumpers/BinaryDumpers/src/DumpRawBanks.h deleted file mode 100644 index e1b3b0b3d87c133838de8daefdb66b54e9b59825..0000000000000000000000000000000000000000 --- a/Dumpers/BinaryDumpers/src/DumpRawBanks.h +++ /dev/null @@ -1,84 +0,0 @@ -/*****************************************************************************\ -* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -* * -* This software is distributed under the terms of the GNU General Public * -* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * -* * -* In applying this licence, CERN does not waive the privileges and immunities * -* granted to it by virtue of its status as an Intergovernmental Organization * -* or submit itself to any jurisdiction. * -\*****************************************************************************/ -#ifndef DUMPRAWBANKS_H -#define DUMPRAWBANKS_H 1 - -#include -#include -#include -#include -#include - -// Include files -#include "GaudiAlg/Transformer.h" -#include -#include -#include -#include -#include - -// Parsers for the bank type property are put in namespace LHCb for -// ADL to work. -namespace LHCb { - - StatusCode parse(RawBank::BankType& result, const std::string& in); - StatusCode parse(std::set& s, const std::string& in); -} // namespace LHCb - -// Raw bank format: -// ----------------------------------------------------------------------------- -// name | type | size [bytes] | array_size -// ============================================================================= -// Once -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// number_of_rawbanks | uint32_t | 4 -// ----------------------------------------------------------------------------- -// raw_bank_offset | uint32_t | number_of_rawbanks * 4 -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// for each raw bank: -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// sourceID | uint32_t | 4 | -// ------------------------------------------------------------------------------ -// bank_data | char | variable -// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -/** @class DumpRawBanks DumpRawBanks.h - * Algorithm that dumps raw banks to binary files. - * - * @author Roel Aaij - * @date 2018-08-27 - */ -class DumpRawBanks : public Gaudi::Functional::Transformer< - std::array, LHCb::RawBank::LastType>(const LHCb::RawEvent&, const LHCb::ODIN&), - Gaudi::Functional::Traits::BaseClass_t> { -public: - /// Standard constructor - DumpRawBanks(const std::string& name, ISvcLocator* pSvcLocator); - - StatusCode initialize() override; - - std::array, LHCb::RawBank::LastType> operator()( - const LHCb::RawEvent& rawEvent, - const LHCb::ODIN& odin) const override; - -private: - std::string outputDirectory(LHCb::RawBank::BankType bankType) const; - - Gaudi::Property m_outputDirectory {this, "OutputDirectory", "banks"}; - Gaudi::Property> m_bankTypes { - this, - "BankTypes", - {LHCb::RawBank::VP, LHCb::RawBank::UT, LHCb::RawBank::FTCluster, LHCb::RawBank::Muon, LHCb::RawBank::ODIN}}; - Gaudi::Property m_dumpToFile {this, "DumpToFile", true}; - - std::unordered_map m_histos; -}; -#endif // DUMPRAWBANKS_H diff --git a/Dumpers/BinaryDumpers/src/TransposeRawBanks.cpp b/Dumpers/BinaryDumpers/src/TransposeRawBanks.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7547c71ad8f30915ffc58e5abdf923422e2a561f --- /dev/null +++ b/Dumpers/BinaryDumpers/src/TransposeRawBanks.cpp @@ -0,0 +1,211 @@ +/*****************************************************************************\ +* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * +* * +* This software is distributed under the terms of the GNU General Public * +* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". * +* * +* In applying this licence, CERN does not waive the privileges and immunities * +* granted to it by virtue of its status as an Intergovernmental Organization * +* or submit itself to any jurisdiction. * +\*****************************************************************************/ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "Utils.h" + +// Parsers are in namespace LHCb for ADL to work. +namespace LHCb { + + StatusCode parse(RawBank::BankType& result, const std::string& in) + { + static std::unordered_map types; + if (types.empty()) { + for (int t = 0; t < RawBank::LastType; ++t) { + auto bt = static_cast(t); + types.emplace(RawBank::typeName(bt), bt); + } + } + + // This takes care of quoting + std::string input; + using Gaudi::Parsers::parse; + auto sc = parse(input, in); + if (!sc) return sc; + + auto it = types.find(input); + if (it != end(types)) { + result = it->second; + return StatusCode::SUCCESS; + } + else { + return StatusCode::FAILURE; + } + } + + StatusCode parse(std::set& s, const std::string& in) + { + std::set ss; + using Gaudi::Parsers::parse; + auto sc = parse(ss, in); + if (!sc) return sc; + s.clear(); + try { + std::transform(begin(ss), end(ss), std::inserter(s, begin(s)), [](const std::string& s) { + RawBank::BankType t {}; + auto sc = parse(t, s); + if (!sc) throw GaudiException("Bad Parse", "", sc); + return t; + }); + } catch (const GaudiException& ge) { + return ge.code(); + } + return StatusCode::SUCCESS; + } + + + inline std::ostream& toStream(const RawBank::BankType& bt, std::ostream& s) + { + return s << "'" << RawBank::typeName(bt) << "'"; + } +} // namespace LHCb + +template +using VOC = Gaudi::Functional::vector_of_const_; + +// Raw bank format: +// ----------------------------------------------------------------------------- +// name | type | size [bytes] | array_size +// ============================================================================= +// Once +// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// number_of_rawbanks | uint32_t | 4 +// ----------------------------------------------------------------------------- +// raw_bank_offset | uint32_t | number_of_rawbanks * 4 +// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// for each raw bank: +// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// sourceID | uint32_t | 4 | +// ------------------------------------------------------------------------------ +// bank_data | char | variable +// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +/** @class TransposeRawBanks TransposeRawBanks.h + * Algorithm that dumps raw banks to binary files. + * + * @author Roel Aaij + * @date 2018-08-27 + */ +class TransposeRawBanks : public Gaudi::Functional::MergingTransformer< + std::array, LHCb::RawBank::LastType>(VOC const&), + Gaudi::Functional::Traits::BaseClass_t> { +public: + /// Standard constructor + TransposeRawBanks(const std::string& name, ISvcLocator* pSvcLocator); + + StatusCode initialize() override; + + std::array, LHCb::RawBank::LastType> operator()( + VOC const& rawEvents) const override; + +private: + Gaudi::Property> m_bankTypes { + this, + "BankTypes", + {LHCb::RawBank::VP, LHCb::RawBank::UT, LHCb::RawBank::FTCluster, LHCb::RawBank::Muon, LHCb::RawBank::ODIN}}; + + std::unordered_map m_histos; +}; + +TransposeRawBanks::TransposeRawBanks(const std::string& name, ISvcLocator* pSvcLocator) : + MergingTransformer( + name, + pSvcLocator, + // Inputs + KeyValues {"RawEventLocations", {LHCb::RawEventLocation::Default}}, + // Output + KeyValue {"AllenRawInput", "Allen/Raw/Input"}) +{} + +StatusCode TransposeRawBanks::initialize() +{ + for (const auto bankType : m_bankTypes) { + auto tn = LHCb::RawBank::typeName(bankType); + m_histos[tn] = book1D(tn, -0.5, 603.5, 151); + } + return StatusCode::SUCCESS; +} + +std::array, LHCb::RawBank::LastType> TransposeRawBanks::operator()( + VOC const& rawEvents) const +{ + + std::array, LHCb::RawBank::LastType> output; + + std::unordered_map> rawBanks; + + for (auto const* rawEvent : rawEvents) { + std::for_each(m_bankTypes.begin(), m_bankTypes.end(), [rawEvent, &rawBanks] (auto bt) { + auto banks = rawEvent->banks(bt); + if (!banks.empty()) { + rawBanks.emplace(bt, std::move(banks)); + }}); + } + + for (auto const& [bankType, banks] : rawBanks) { + const uint32_t number_of_rawbanks = banks.size(); + uint32_t offset = 0; + + std::vector bankOffsets; + std::vector bankData; + bankOffsets.push_back(0); + + for (auto& bank : banks) { + const uint32_t sourceID = static_cast(bank->sourceID()); + bankData.push_back(sourceID); + + offset++; + + auto bStart = bank->begin(); + auto bEnd = bank->end(); + + // Debug/testing histogram with the sizes of the binary data per bank + auto tn = LHCb::RawBank::typeName(bankType); + auto hit = m_histos.find(tn); + if (UNLIKELY(hit == end(m_histos))) { + warning() << "No histogram booked for bank type " << tn << endmsg; + } + else { + hit->second->fill((bEnd - bStart) * sizeof(uint32_t)); + } + + while (bStart != bEnd) { + const uint32_t raw_data = *(bStart); + bankData.push_back(raw_data); + + bStart++; + offset++; + } + bankOffsets.push_back(offset * sizeof(uint32_t)); + } + + // Dumping number_of_rawbanks + 1 offsets! + DumpUtils::Writer bank_buffer; + bank_buffer.write(number_of_rawbanks, bankOffsets, bankData); + output[bankType] = bank_buffer.buffer(); + } + return output; +} + +// Declaration of the Algorithm Factory +DECLARE_COMPONENT(TransposeRawBanks) diff --git a/Rec/Allen/options/run_allen_in_gaudi.py b/Rec/Allen/options/run_allen_in_gaudi.py index 28c002df1ddc07a87ece552e967adba8f3cda0c4..bb670a34ed9004a46a03db91f124547e1c776dd8 100644 --- a/Rec/Allen/options/run_allen_in_gaudi.py +++ b/Rec/Allen/options/run_allen_in_gaudi.py @@ -15,7 +15,7 @@ from Configurables import (TrackSys, GaudiSequencer) from Configurables import FTRawBankDecoder from Configurables import NTupleSvc from Gaudi.Configuration import appendPostConfigAction -from Configurables import (VPClus, createODIN, DumpRawBanks, DumpUTHits, +from Configurables import (VPClus, createODIN, TransposeRawBanks, DumpUTHits, DumpFTHits, DumpMuonCoords, DumpMuonCommonHits, MuonRec, PrepareMuonHits) from Configurables import RunAllen, AllenUpdater, AllenForwardToV2Tracks, AllenVeloToV2Tracks, AllenUTToV2Tracks @@ -33,8 +33,7 @@ from Configurables import HltDecReportsDecoder, HltANNSvc, AllenDecReportsToTES import json import os -conf_path = os.path.expandvars( - "$ALLEN_PROJECT_ROOT/configuration/constants/DefaultSequence.json") +conf_path = os.path.expandvars("$ALLEN_INSTALL_DIR/constants/Sequence.json") lines = [] with open(conf_path, 'r') as f: j = json.load(f) @@ -156,12 +155,11 @@ NTupleSvc().Output = ["FILE1 DATAFILE='velo_states.root' TYP='ROOT' OPT='NEW'"] # Save raw banks in Allen format on the TES outputdirectory = "dump/" -dump_banks = DumpRawBanks( +transpose_banks = TransposeRawBanks( BankTypes=["VP", "UT", "FTCluster", "Muon", "ODIN"], - DumpToFile=False, - OutputDirectory=outputdirectory + "banks") + RawEventLocations=["DAQ/RawEvent"]) dump_seq = GaudiSequencer("RecoAllenPrepareSeq") -dump_seq.Members += [dump_banks] +dump_seq.Members += [transpose_banks] # call Allen allen_seq = GaudiSequencer("RecoAllenSeq") @@ -264,7 +262,7 @@ def addPrCheckerCutsAndPlots(): allenReports = AllenDecReportsToTES() reports = HltDecReportsDecoder() - reports.RawEventLocations = "Allen/Out/DecReports" + reports.RawEventLocations = "Allen/Out/RawDecReports" reports.SourceID = 1 GaudiSequencer("CheckAllenReportsSeq", Members=[allenReports, reports]) ProcessPhase("Check").DetectorList += ["AllenReports"] diff --git a/main/include/TESProvider.h b/main/include/TESProvider.h index e0c63878e0f6e8dc958aa1238529567df8683723..73e90b7d4ff7f4d237ab3e6987ebd6b8d90ff376 100644 --- a/main/include/TESProvider.h +++ b/main/include/TESProvider.h @@ -60,8 +60,9 @@ public: // bank content using data_span = gsl::span; - auto data_size = static_cast(banks[bank].size()); - span b {banks[bank].data(), data_size}; + auto data_size = banks[bank].size(); + auto span_size = static_cast(data_size); + span b {banks[bank].data(), span_size}; m_banks_and_offsets[allen_bank_index] = {{std::move(b)}, static_cast(data_size), std::move(offsets)}; }