ATLAS Offline Software
Loading...
Searching...
No Matches
BeamHaloParticleBuffer.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef BEAMHALOPARTICLEBUFFER_H
6#define BEAMHALOPARTICLEBUFFER_H
7
8#include <fstream>
9#include <vector>
10#include <map>
11
13namespace CLHEP {
14 class HepRandomEngine;
15}
16
18 public:
20 const std::vector<double>& intervalUpperBinEdges);
21 BinnedInterval(const BinnedInterval& binnedInterval);
23
26 {
27 if ( this != &rhs ) // Fix Coverity SELF_ASSIGN
28 {
30 std::vector<double>* tmp = new std::vector<double>(*(rhs.m_intervalUpperBinEdges));
33 }
34 return *this;
35 }
36
37 double upperBinEdge() const { return m_upperBinEdge; }
38 const std::vector<double>* intervalUpperBinEdges() const { return m_intervalUpperBinEdges; }
39
40 private:
42 std::vector<double>* m_intervalUpperBinEdges;
43};
44
46 public:
47 BeamHaloParticleBuffer(const std::string& fileName);
49 int openForWriting();
50 int openForReading();
51 int close();
52
54 int writeParticle(BeamHaloParticle *particle);
55
57 BeamHaloParticle* readRandomParticle(CLHEP::HepRandomEngine* engine);
58
59 private:
60
64
66 std::string m_fileName;
67
69 std::ofstream m_ofstream;
70
72 std::ifstream m_ifstream;
73
76
79
82
88 std::vector<BinnedInterval> m_binnedIntervals;
89
92
94 std::vector<double> m_intervalUpperBinEdges;
95
98
101};
102
103#endif
double m_intervalUpperBinEdge
The upper bin edge of a bin within a given interval.
BeamHaloParticle * readRandomParticle(CLHEP::HepRandomEngine *engine)
A member function to read a random particle from the binary file.
bool m_writeFlag
A flag to select read or write.
unsigned int m_particlesPerInterval
The number of particles per interval.
int writeParticle(BeamHaloParticle *particle)
A member function to append a particle to the binary file.
BeamHaloParticle * readParticle(void)
A member function to read a particle from the current position in the binary file.
BeamHaloParticleBuffer(const std::string &fileName)
std::ofstream m_ofstream
A data member to store the output file stream.
std::string m_fileName
File name.
~BeamHaloParticleBuffer()=default
double m_upperBinEdge
The upper edge of the bin.
std::vector< double > m_intervalUpperBinEdges
A vector of bin limits for a given interval.
std::vector< BinnedInterval > m_binnedIntervals
A map of the upper bin limits and an vector of bin limits within the given interval.
int m_recordSize
The size of 1 binary data record.
long m_numberOfParticles
The number of particles present within the output or input file.
std::ifstream m_ifstream
A data member to store the input file stream.
A class to describe a generic beam halo particle.
BinnedInterval(double upperBinEdge, const std::vector< double > &intervalUpperBinEdges)
const std::vector< double > * intervalUpperBinEdges() const
std::vector< double > * m_intervalUpperBinEdges
BinnedInterval & operator=(const BinnedInterval &rhs)
Assignment operator.
double upperBinEdge() const