ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ObjSurfaceWriter.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ObjSurfaceWriter.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
13 #include <fstream>
14 #include <iostream>
15 #include <mutex>
16 
20 
21 namespace FW {
22 namespace Obj {
23 
29  public:
30  // @class Config
31  //
32  // The nested config class for the Surface writer
33  class Config {
34  public:
36  std::shared_ptr<const Acts::Logger> logger;
38  std::string name;
40  unsigned int outputPhiSegemnts = 72;
42  double outputThickness = 2.;
44  bool outputSensitive = true;
46  bool outputLayerSurface = true;
48  double outputScalor = 1.;
50  unsigned int outputPrecision = 6;
52  std::string filePrefix = "";
55  std::string planarPrefix = "";
56  std::string cylinderPrefix = "";
57  std::string diskPrefix = "";
59  std::shared_ptr<std::ofstream> outputStream = nullptr;
60 
61  Config(const std::string& lname = "ObjSurfaceWriter",
63  : logger(Acts::getDefaultLogger(lname, lvl)), name(lname) {}
64  };
65 
69  ObjSurfaceWriter(const Config& cfg);
70 
72  std::string name() const;
73 
78  const Acts::Surface& surface);
79 
82  FW::ProcessCode write(const std::string& sinfo);
83 
84  private:
88 
90  const Acts::Logger& logger() const { return *m_cfg.logger; }
91 };
92 
93 inline FW::ProcessCode ObjSurfaceWriter::write(const std::string& sinfo) {
94  // lock the mutex for writing
95  std::lock_guard<std::mutex> lock(m_write_mutex);
96  // and write
97  (*m_cfg.outputStream) << sinfo;
99 }
100 
101 } // namespace Obj
102 } // namespace FW