Belle II Software  release-05-02-19
MilleData.h
1 #pragma once
2 
3 #include <calibration/core/MergeableNamed.h>
4 
5 #include <genfit/MilleBinary.h>
6 #include <genfit/GblTrajectory.h>
7 
8 #include <string>
9 #include <vector>
10 
11 namespace Belle2 {
16  class MilleData : public MergeableNamed {
18  public:
20  MilleData(bool doublePrecision = false, bool absFilePaths = false) : MergeableNamed(), m_doublePrecision(doublePrecision),
21  m_absFilePaths(absFilePaths) {};
23  virtual ~MilleData() { close(); }
24 
26  virtual void merge(const MergeableNamed* other) override;
28  virtual void clear() override { m_files.clear(); m_numRecords = 0; }
30  void open(std::string filename);
32  bool isOpen() { return !!m_binary; }
34  void fill(gbl::GblTrajectory& trajectory);
36  void close();
38  const std::vector<std::string>& getFiles() const { return m_files; }
40  MilleData& operator=(const MilleData& other);
44  m_binary(nullptr),
45  m_numRecords(other.m_numRecords) {}
46 
48  virtual MilleData* Clone(const char* newname = "") const override;
49 
51  int getNumRecords() {return m_numRecords;}
54 
56  void addFile(const std::string& path)
57  {
58  m_files.push_back(path);
59  }
60 
61  private:
63  bool m_doublePrecision{false};
68  bool m_absFilePaths{false};
69  std::vector<std::string> m_files{};
70  gbl::MilleBinary* m_binary{nullptr};
72  int m_numRecords{0};
74 
75  ClassDefOverride(MilleData, 2)
76  };
78 }
Belle2::MilleData::m_absFilePaths
bool m_absFilePaths
Use absolute file paths to binary files Default is False - so you have to move the binaries to workin...
Definition: MilleData.h:68
Belle2::MergeableNamed
Abstract base class for objects that can be merged but also named.
Definition: MergeableNamed.h:32
Belle2::MilleData::open
void open(std::string filename)
Open a new file and remember it. Filename should encode also process id!
Definition: MilleData.cc:65
Belle2::MilleData::hasDoublePrecision
bool hasDoublePrecision()
Are files written with double precision?
Definition: MilleData.h:53
Belle2::MilleData::m_numRecords
int m_numRecords
Pointer to opened binary file (not streamed)
Definition: MilleData.h:73
Belle2::MilleData::m_doublePrecision
bool m_doublePrecision
Use double-precision for binary files.
Definition: MilleData.h:63
Belle2::MilleData::fill
void fill(gbl::GblTrajectory &trajectory)
Write a GBL trajectory to the binary file.
Definition: MilleData.cc:57
Belle2::MilleData::isOpen
bool isOpen()
Is some file already open?
Definition: MilleData.h:32
Belle2::MilleData::clear
virtual void clear() override
Implementation of clearing.
Definition: MilleData.h:28
Belle2::MilleData::addFile
void addFile(const std::string &path)
Add a filename (path) to the file list manually.
Definition: MilleData.h:56
gbl::GblTrajectory
GBL trajectory.
Definition: GblTrajectory.h:48
Belle2::MilleData::close
void close()
Close current mille binary if opened.
Definition: MilleData.cc:49
Belle2::MilleData
Mergeable class holding list of so far opened mille binaries and providing the binaries.
Definition: MilleData.h:17
Belle2::MilleData::m_files
std::vector< std::string > m_files
List of already created file names.
Definition: MilleData.h:69
Belle2::MilleData::operator=
MilleData & operator=(const MilleData &other)
Copy by assignment (if some file on LHS is opened, it is closed during this operation; file pointers ...
Definition: MilleData.cc:39
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::MilleData::merge
virtual void merge(const MergeableNamed *other) override
Implementation of merging.
Definition: MilleData.cc:12
Belle2::MilleData::getFiles
const std::vector< std::string > & getFiles() const
Get the list of all created files.
Definition: MilleData.h:38
Belle2::MilleData::m_binary
gbl::MilleBinary * m_binary
Pointer to current binary file.
Definition: MilleData.h:71
Belle2::MilleData::Clone
virtual MilleData * Clone(const char *newname="") const override
Clone object (with optionally a new name)
Definition: MilleData.cc:30
Belle2::MilleData::MilleData
MilleData(bool doublePrecision=false, bool absFilePaths=false)
Constructor. Set doublePrecision to true to write binary files with doubles instead of floats.
Definition: MilleData.h:20
Belle2::MilleData::~MilleData
virtual ~MilleData()
Destructor.
Definition: MilleData.h:23
Belle2::MilleData::getNumRecords
int getNumRecords()
Get number of records (trajectories) written to binary files.
Definition: MilleData.h:51
gbl::MilleBinary
Millepede-II (binary) record.
Definition: MilleBinary.h:68
Belle2::MilleData::MilleData
MilleData(const MilleData &other)
Construct from other object (pointer to binary file is not transfered - new file has to be opened by ...
Definition: MilleData.h:42