ATLAS Offline Software
Loading...
Searching...
No Matches
DataDumperHelpers.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef FPTRACKER_DATADUMPERHELPERS_H
6#define FPTRACKER_DATADUMPERHELPERS_H
7#include <sstream>
8#include <cstddef>
9#include <algorithm>
10
11namespace FPTracker{
13 public:
14 LineFormater(int numPerLine): m_numPerLine(0), m_maxPerLine(numPerLine) {}
15 template<class T>
16 void operator()(T t){
18 m_numPerLine = 0;
19 m_ost<<'\n';
20 }
21 m_ost<<t<<" ";
23 }
24 std::string toString() const {return m_ost.str();}
25 private:
28 std::ostringstream m_ost;
29 };
30
31 template<class Array1D>
32 std::string array1DToString(const Array1D& arr){
33
34 std::ostringstream dump;
35 LineFormater lf = std::for_each(arr.begin(), arr.end(), LineFormater(10));
36 dump<<lf.toString()+'\n';
37 return dump.str();
38 }
39
40
41
42 template<class Array2D>
43 std::string array2DToString(const Array2D& arr){
44
45 std::ostringstream dump;
46 for(std::size_t is=0; is<arr.size(); ++is){
47 dump << "side "<<is<<'\n';
48
49 LineFormater lf = std::for_each(arr[is].begin(), arr[is].end(), LineFormater(10));
50 dump<<lf.toString()+'\n';
51 }
52 return dump.str();
53 }
54
55 template<class Array3D>
56 std::string array3DToString(const Array3D& arr){
57
58 std::ostringstream dump;
59 for(std::size_t is=0; is<arr.size(); ++is){
60 dump << "side "<<is<<'\n';
61 for (std::size_t ig=0; ig<arr[is].size(); ++ig){
62
63 dump << "geom "<<ig<<'\n';
64 LineFormater lf = std::for_each(arr[is][ig].begin(), arr[is][ig].end(), LineFormater(10));
65 dump<<lf.toString()+'\n';
66
67 }
68 }
69 return dump.str();
70 }
71}
72
73#endif
std::ostringstream m_ost
std::string toString() const
std::string array2DToString(const Array2D &arr)
std::string array3DToString(const Array3D &arr)
std::string array1DToString(const Array1D &arr)
-event-from-file