From a074f8017862b38f0b6b9420120cf14bf32724b6 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger <Andreas.Salzburger@cern.ch> Date: Wed, 3 Jul 2019 10:30:49 +0200 Subject: [PATCH] removing Txt plugin --- .../Common/ACTFW/Options/CommonOptions.cpp | 5 +- Examples/Fatras/CMakeLists.txt | 1 - .../src/detail/FatrasDigitizationBase.hpp | 14 --- Plugins/CMakeLists.txt | 1 - Plugins/Txt/CMakeLists.txt | 9 -- .../ACTFW/Plugins/Txt/TxtParticleWriter.hpp | 76 ------------ .../Plugins/Txt/TxtPlanarClusterWriter.hpp | 63 ---------- .../ACTFW/Plugins/Txt/TxtWriterOptions.hpp | 37 ------ Plugins/Txt/src/TxtParticleWriter.cpp | 100 --------------- Plugins/Txt/src/TxtPlanarClusterWriter.cpp | 117 ------------------ 10 files changed, 1 insertion(+), 422 deletions(-) delete mode 100644 Plugins/Txt/CMakeLists.txt delete mode 100644 Plugins/Txt/include/ACTFW/Plugins/Txt/TxtParticleWriter.hpp delete mode 100644 Plugins/Txt/include/ACTFW/Plugins/Txt/TxtPlanarClusterWriter.hpp delete mode 100644 Plugins/Txt/include/ACTFW/Plugins/Txt/TxtWriterOptions.hpp delete mode 100644 Plugins/Txt/src/TxtParticleWriter.cpp delete mode 100644 Plugins/Txt/src/TxtPlanarClusterWriter.cpp diff --git a/Examples/Common/ACTFW/Options/CommonOptions.cpp b/Examples/Common/ACTFW/Options/CommonOptions.cpp index 795da1e0..8ad2632b 100644 --- a/Examples/Common/ACTFW/Options/CommonOptions.cpp +++ b/Examples/Common/ACTFW/Options/CommonOptions.cpp @@ -80,10 +80,7 @@ FW::Options::addOutputOptions(boost::program_options::options_description& opt) "Switch on to write '.obj' ouput file(s).")( "output-json", value<bool>()->default_value(false), - "Switch on to write '.json' ouput file(s).")( - "output-txt", - value<bool>()->default_value(false), - "Switch on to write '.txt' ouput file(s)."); + "Switch on to write '.json' ouput file(s)."); } boost::program_options::variables_map diff --git a/Examples/Fatras/CMakeLists.txt b/Examples/Fatras/CMakeLists.txt index 1c598a23..eb335fdd 100644 --- a/Examples/Fatras/CMakeLists.txt +++ b/Examples/Fatras/CMakeLists.txt @@ -9,7 +9,6 @@ set(_common_libraries ACTFWFatras ACTFWObjPlugin ACTFWRootPlugin - ACTFWTxtPlugin ActsFrameworkGenerators ActsFrameworkPythia8) diff --git a/Examples/Fatras/src/detail/FatrasDigitizationBase.hpp b/Examples/Fatras/src/detail/FatrasDigitizationBase.hpp index 76ac55a6..adb5bb94 100644 --- a/Examples/Fatras/src/detail/FatrasDigitizationBase.hpp +++ b/Examples/Fatras/src/detail/FatrasDigitizationBase.hpp @@ -16,7 +16,6 @@ #include "ACTFW/Plugins/Csv/CsvPlanarClusterWriter.hpp" #include "ACTFW/Plugins/Obj/ObjSpacePointWriter.hpp" #include "ACTFW/Plugins/Root/RootPlanarClusterWriter.hpp" -#include "ACTFW/Plugins/Txt/TxtPlanarClusterWriter.hpp" #include "ACTFW/Random/RandomNumbersSvc.hpp" #include "Acts/Plugins/Digitization/PlanarModuleStepper.hpp" @@ -76,19 +75,6 @@ setupDigitization(vmap_t& vm, sequencer.addWriter(clusteWriterCsv); } - // Write digitsation output as Txt files - if (vm["output-txt"].template as<bool>()) { - // clusters as root - FW::Txt::TxtPlanarClusterWriter::Config clusterWriterTxtConfig; - clusterWriterTxtConfig.collection = digiConfig.clusterCollection; - clusterWriterTxtConfig.outputDir = outputDir; - clusterWriterTxtConfig.barcodeSvc = barcodeSvc; - auto clusteWriterTxt = std::make_shared<FW::Txt::TxtPlanarClusterWriter>( - clusterWriterTxtConfig); - // Add to the sequencer - sequencer.addWriter(clusteWriterTxt); - } - // Write digitsation output as OBJ files if (vm["output-root"].template as<bool>()) { // clusters as root diff --git a/Plugins/CMakeLists.txt b/Plugins/CMakeLists.txt index 7132d855..6b1965c6 100644 --- a/Plugins/CMakeLists.txt +++ b/Plugins/CMakeLists.txt @@ -7,4 +7,3 @@ add_subdirectory(Obj) add_subdirectory_if(Pythia8 USE_PYTHIA8) add_subdirectory(Root) add_subdirectory_if(HepMC USE_HEPMC3) -add_subdirectory(Txt) diff --git a/Plugins/Txt/CMakeLists.txt b/Plugins/Txt/CMakeLists.txt deleted file mode 100644 index 41f6d1b0..00000000 --- a/Plugins/Txt/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -file(GLOB_RECURSE src_files "src/*.cpp" "include/*.*pp") - -add_library(ACTFWTxtPlugin SHARED ${src_files}) -target_include_directories(ACTFWTxtPlugin PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/> $<INSTALL_INTERFACE:include>) -target_link_libraries(ACTFWTxtPlugin PRIVATE ACTFramework ActsCore ActsDigitizationPlugin IdentificationPlugin) -target_link_libraries(ACTFWTxtPlugin PRIVATE Threads::Threads) - -install(TARGETS ACTFWTxtPlugin LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install(DIRECTORY include/ACTFW DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/Plugins/Txt/include/ACTFW/Plugins/Txt/TxtParticleWriter.hpp b/Plugins/Txt/include/ACTFW/Plugins/Txt/TxtParticleWriter.hpp deleted file mode 100644 index 2197b8b1..00000000 --- a/Plugins/Txt/include/ACTFW/Plugins/Txt/TxtParticleWriter.hpp +++ /dev/null @@ -1,76 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2017-2018 Acts project team -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#pragma once - -#include <vector> -#include "ACTFW/Barcode/BarcodeSvc.hpp" -#include "ACTFW/EventData/SimParticle.hpp" -#include "ACTFW/EventData/SimVertex.hpp" -#include "ACTFW/Framework/WriterT.hpp" -#include "Acts/Utilities/Logger.hpp" - -namespace FW { -namespace Txt { - - using SimVertex = Data::SimVertex<Data::SimParticle>; - using ParticleWriter = WriterT<std::vector<Data::SimVertex<>>>; - - /// Write out a the particles associated to a list of process vertices, - /// the particles are in comma-separated-value format. - /// - /// This writer is restricted to outgoing particles, it is designed for - /// generated particle information. - /// - /// This writes one file per event into the configured output directory. By - /// default it writes to the current working directory. - /// Files are named using the following schema - /// - /// event000000001-particles.csv - /// event000000002-particles.csv - /// - /// and each line in the file corresponds to one particle. - class TxtParticleWriter : public ParticleWriter - { - public: - struct Config - { - std::string collection; ///< which collection to write - std::string outputDir; ///< where to place output files - std::string outputTrkFileName; ///< output file name Tracks - std::string outputVtxFileName; ///< output file name Vertices - size_t outputPrecision = 6; ///< floating point precision - - /// the BarcodeSvc to decode - std::shared_ptr<BarcodeSvc> barcodeSvc = nullptr; - - /// try to get the hits per particle map - std::string hitsPerParticleCollection = ""; - }; - - /// constructor - /// @param cfg is the configuration object - /// @parm level is the output logging level - TxtParticleWriter(const Config& cfg, - Acts::Logging::Level level = Acts::Logging::INFO); - - protected: - /// @brief Write method called by the base class - /// @param [in] ctx is the algorithm context for consistency - /// @param [in] vertices is the process vertex collection for the - /// particles to be attached - ProcessCode - writeT(const FW::AlgorithmContext& ctx, - const std::vector<Data::SimVertex<>>& vertices) final override; - - private: - Config m_cfg; //!< Nested configuration struct - }; - -} // namespace Txt -} // namespace FW diff --git a/Plugins/Txt/include/ACTFW/Plugins/Txt/TxtPlanarClusterWriter.hpp b/Plugins/Txt/include/ACTFW/Plugins/Txt/TxtPlanarClusterWriter.hpp deleted file mode 100644 index f8a8f6bd..00000000 --- a/Plugins/Txt/include/ACTFW/Plugins/Txt/TxtPlanarClusterWriter.hpp +++ /dev/null @@ -1,63 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2017-2018 Acts project team -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#pragma once - -#include <Acts/Plugins/Digitization/PlanarModuleCluster.hpp> -#include "ACTFW/Barcode/BarcodeSvc.hpp" -#include "ACTFW/EventData/DataContainers.hpp" -#include "ACTFW/Framework/WriterT.hpp" - -namespace FW { -namespace Txt { - - /// Write out a planar cluster collection in comma-separated-value format. - /// - /// This writes one file per event into the configured output directory. By - /// default it writes to the current working directory. Files are named - /// using the following schema - /// - /// event000000001-hits.csv - /// event000000002-hits.csv - /// - /// and each line in the file corresponds to one hit/cluster. - class TxtPlanarClusterWriter - : public WriterT<DetectorData<geo_id_value, Acts::PlanarModuleCluster>> - { - public: - using Base = WriterT<DetectorData<geo_id_value, Acts::PlanarModuleCluster>>; - - struct Config - { - std::string collection; ///< which collection to write - std::string outputDir; ///< where to place output files - size_t outputPrecision = 6; ///< floating point precision - - /// the BarcodeSvc to decode - std::shared_ptr<BarcodeSvc> barcodeSvc = nullptr; - }; - - /// Constructor with - /// @param cfg configuration struct - /// @param output logging level - TxtPlanarClusterWriter(const Config& cfg, - Acts::Logging::Level level = Acts::Logging::INFO); - - protected: - /// This implementation holds the actual writing method - /// and is called by the WriterT<>::write interface - ProcessCode - writeT(const AlgorithmContext& ctx, - const DetectorData<geo_id_value, Acts::PlanarModuleCluster>& - clusters) final override; - - private: - Config m_cfg; - }; -} // namespace Txt -} // namespace FW diff --git a/Plugins/Txt/include/ACTFW/Plugins/Txt/TxtWriterOptions.hpp b/Plugins/Txt/include/ACTFW/Plugins/Txt/TxtWriterOptions.hpp deleted file mode 100644 index c4049bb0..00000000 --- a/Plugins/Txt/include/ACTFW/Plugins/Txt/TxtWriterOptions.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2017 Acts project team -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#pragma once - -#include <iostream> -#include "ACTFW/Plugins/Txt/TxtSurfaceWriter.hpp" -#include "ACTFW/Plugins/Txt/TxtTrackingGeometryWriter.hpp" -#include "ACTFW/Utilities/Options.hpp" - -namespace po = boost::program_options; - -namespace FW { - -namespace Options { - - // Common Txt writer option - /// - /// @tparam aopt_t Type of the options object (from BOOST) - /// - /// @param opt The options object, where string based options are attached - template <typename aopt_t> - void - addTxtWriterOptions(aopt_t& opt) - { - opt.add_options()("txt-hit-outputPrecission", - po::value<int>()->default_value(6), - "Floating number output precission."); - } - -} // namespace Options -} // namespace FW diff --git a/Plugins/Txt/src/TxtParticleWriter.cpp b/Plugins/Txt/src/TxtParticleWriter.cpp deleted file mode 100644 index 99289625..00000000 --- a/Plugins/Txt/src/TxtParticleWriter.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2017 Acts project team -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include "ACTFW/Plugins/Txt/TxtParticleWriter.hpp" -#include <fstream> -#include <ios> -#include <stdexcept> -#include "ACTFW/Barcode/Barcode.hpp" -#include "ACTFW/Framework/WhiteBoard.hpp" -#include "ACTFW/Utilities/Paths.hpp" - -FW::Txt::TxtParticleWriter::TxtParticleWriter( - const FW::Txt::TxtParticleWriter::Config& cfg, - Acts::Logging::Level level) - : ParticleWriter(cfg.collection, "TxtParticleWriter", level), m_cfg(cfg) -{ - if (m_cfg.collection.empty()) { - throw std::invalid_argument("Missing input collection"); - } -} - -FW::ProcessCode -FW::Txt::TxtParticleWriter::writeT( - const FW::AlgorithmContext& ctx, - const std::vector<Data::SimVertex<>>& vertices) -{ - std::string pathOsTrack = perEventFilepath( - m_cfg.outputDir, m_cfg.outputTrkFileName, ctx.eventNumber); - std::ofstream osTrack(pathOsTrack, std::ofstream::out | std::ofstream::trunc); - if (!osTrack) { - throw std::ios_base::failure("Could not open '" + pathOsTrack - + "' to write"); - } - - std::string pathOsVertex = perEventFilepath( - m_cfg.outputDir, m_cfg.outputVtxFileName, ctx.eventNumber); - std::ofstream osVertex(pathOsVertex, - std::ofstream::out | std::ofstream::trunc); - if (!osVertex) { - throw std::ios_base::failure("Could not open '" + pathOsVertex - + "' to write"); - } - - // write csv header - osTrack << std::setw(4) << "trk"; - osTrack << std::setw(4) << "v"; - osTrack << std::setw(9) << "phi"; - osTrack << std::setw(9) << "theta"; - osTrack << std::setw(9) << "pT"; - osTrack << std::setw(4) << "q"; - osTrack << '\n'; - - // write csv header - osVertex << std::setw(4) << "v"; - osVertex << std::setw(9) << "x"; - osVertex << std::setw(9) << "y"; - osVertex << std::setw(9) << "z"; - osVertex << '\n'; - - // write one line per particle - osTrack << std::setprecision(m_cfg.outputPrecision); - for (auto& vertex : vertices) { - bool writeVertex = true; - for (auto& particle : vertex.outgoing()) { - // particle barcode - auto particleBarcode = particle.barcode(); - auto vertexNr = m_cfg.barcodeSvc->vertex(particleBarcode); - if (writeVertex) { - if (abs(vertex.position.z()) < 500.) { - osVertex << std::setw(4) << vertexNr; - osVertex << std::setw(9) << std::setprecision(3) << std::fixed - << vertex.position.x(); - osVertex << std::setw(9) << std::setprecision(3) << std::fixed - << vertex.position.y(); - osVertex << std::setw(9) << std::setprecision(3) << std::fixed - << vertex.position.z(); - osVertex << '\n'; - } - writeVertex = false; - } - auto particleNr = m_cfg.barcodeSvc->primary(particleBarcode); - osTrack << std::setw(4) << particleNr; - osTrack << std::setw(4) << vertexNr; - osTrack << std::setw(9) << std::setprecision(3) << std::fixed - << Acts::VectorHelpers::phi(particle.momentum()); - osTrack << std::setw(9) << std::setprecision(3) << std::fixed - << Acts::VectorHelpers::theta(particle.momentum()); - osTrack << std::setw(9) << std::setprecision(3) << std::fixed - << particle.pT(); - osTrack << std::setw(4) << int(particle.q()); - osTrack << '\n'; - } - } - return ProcessCode::SUCCESS; -} diff --git a/Plugins/Txt/src/TxtPlanarClusterWriter.cpp b/Plugins/Txt/src/TxtPlanarClusterWriter.cpp deleted file mode 100644 index c05672a5..00000000 --- a/Plugins/Txt/src/TxtPlanarClusterWriter.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2017 Acts project team -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include <fstream> -#include <ios> -#include <stdexcept> - -#include <Acts/Plugins/Digitization/PlanarModuleCluster.hpp> -#include "ACTFW/EventData/DataContainers.hpp" -#include "ACTFW/EventData/SimIdentifier.hpp" -#include "ACTFW/EventData/SimParticle.hpp" -#include "ACTFW/EventData/SimVertex.hpp" -#include "ACTFW/Framework/WhiteBoard.hpp" -#include "ACTFW/Plugins/Txt/TxtPlanarClusterWriter.hpp" -#include "ACTFW/Utilities/Paths.hpp" - -FW::Txt::TxtPlanarClusterWriter::TxtPlanarClusterWriter( - const FW::Txt::TxtPlanarClusterWriter::Config& cfg, - Acts::Logging::Level level) - : Base(cfg.collection, "TxtPlanarClusterWriter", level), m_cfg(cfg) -{ - if (m_cfg.collection.empty()) { - throw std::invalid_argument("Missing input collection"); - } -} - -FW::ProcessCode -FW::Txt::TxtPlanarClusterWriter::writeT( - const AlgorithmContext& context, - const FW::DetectorData<geo_id_value, Acts::PlanarModuleCluster>& clusters) -{ - // open per-event hits file - std::string pathHits - = perEventFilepath(m_cfg.outputDir, "hits.txt", context.eventNumber); - std::ofstream osHits(pathHits, std::ofstream::out | std::ofstream::trunc); - if (!osHits) { - throw std::ios_base::failure("Could not open '" + pathHits + "' to write"); - } - - // open per-event truth file - std::string pathTruth - = perEventFilepath(m_cfg.outputDir, "truth.txt", context.eventNumber); - std::ofstream osTruth(pathTruth, std::ofstream::out | std::ofstream::trunc); - if (!osTruth) { - throw std::ios_base::failure("Could not open '" + pathTruth + "' to write"); - } - - auto geoContext = context.geoContext; - - osHits << std::setw(10) << "h"; - osHits << std::setw(10) << "x"; - osHits << std::setw(10) << "y"; - osHits << std::setw(10) << "z"; - osHits << std::setw(5) << "lay"; - osHits << std::setw(5) << "vol"; - osHits << std::setw(6) << "trk"; - osHits << std::setw(9) << "pT"; - osHits << std::setw(4) << "q"; - osHits << std::setw(4) << "v"; // number of hits per track to be added - osHits << '\n'; - - osHits << std::setprecision(3); - - std::map<int, std::map<int, bool>> layerVolumeMap; - - size_t hitId = 0; - for (auto& volumeData : clusters) { - for (auto& layerData : volumeData.second) { - for (auto& moduleData : layerData.second) { - for (auto& cluster : moduleData.second) { - // local cluster information - auto parameters = cluster.parameters(); - Acts::Vector2D local(parameters[Acts::ParDef::eLOC_0], - parameters[Acts::ParDef::eLOC_1]); - Acts::Vector3D pos(0, 0, 0); - Acts::Vector3D mom(1, 1, 1); - // transform local into global position information - cluster.referenceSurface().localToGlobal(geoContext, local, mom, pos); - - // write hit information - osHits << std::setw(10) << std::setprecision(3) << std::fixed - << hitId++; - osHits << std::setw(10) << std::setprecision(3) << std::fixed - << pos.x(); - osHits << std::setw(10) << std::setprecision(3) << std::fixed - << pos.y(); - osHits << std::setw(10) << std::setprecision(3) << std::fixed - << pos.z(); - osHits << std::setw(5) << layerData.first; - osHits << std::setw(5) << volumeData.first; - - /// Hit identifier - auto hitIdentifier = cluster.sourceLink(); - // write hit-particle truth association - // each hit can have multiple particles, e.g. in a dense environment - for (auto& sPartilce : hitIdentifier.truthParticles()) { - auto particleBarcode = sPartilce->barcode(); - osHits << std::setw(6) - << m_cfg.barcodeSvc->primary(particleBarcode); - osHits << std::setw(9) << std::setprecision(3) << std::fixed - << sPartilce->pT(); - osHits << std::setw(4) << int(sPartilce->q()); - osHits << std::setw(4) << m_cfg.barcodeSvc->vertex(particleBarcode); - } - osHits << '\n'; - } - } - } - } - - return FW::ProcessCode::SUCCESS; -} -- GitLab