Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:04

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 
0013 #include <fstream>
0014 
0015 namespace ActsFatras {
0016 
0017 /// Helper to write out Digitization tesbed into csv files.
0018 struct DigitizationCsvOutput {
0019   /// Helper method to format the output of a line into csv
0020   ///
0021   /// @param outf The output stream
0022   /// @param p0 The start point
0023   /// @param p1 The end point
0024   void writeLine(std::ostream& outf, const Acts::Vector2& p0,
0025                  const Acts::Vector2& p1) const {
0026     outf << "l," << p0.x() << "," << p0.y() << "," << p1.x() << "," << p1.y()
0027          << "\n";
0028   };
0029 
0030   /// Helper method to write an arc into csv
0031   ///
0032   /// @param outf The output stream
0033   /// @param r The radius of the arc
0034   /// @param phiMin The minimum phi
0035   /// @param phiMin The maximum phi
0036   void writeArc(std::ostream& outf, double r, double phiMin,
0037                 double phiMax) const {
0038     outf << "a," << r << "," << r << "," << phiMin << "," << phiMax << "\n";
0039   };
0040 
0041   /// Helper method to write a polygon
0042   ///
0043   /// @param outf The output stream
0044   /// @param vertices The vertices of the polygon
0045   void writePolygon(std::ostream& outf,
0046                     const std::vector<Acts::Vector2>& vertices,
0047                     const Acts::Vector2& shift = Acts::Vector2(0., 0.)) const {
0048     auto nvertices = vertices.size();
0049     for (unsigned long iv = 1; iv < nvertices; ++iv) {
0050       writeLine(outf, vertices[iv - 1] + shift, vertices[iv] + shift);
0051     }
0052     writeLine(outf, vertices[nvertices - 1] + shift, vertices[0] + shift);
0053   };
0054 };
0055 
0056 }  // namespace ActsFatras