ATLAS Offline Software
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 
12 class BeamHaloParticle;
13 namespace 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 
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 
78  unsigned int m_particlesPerInterval;
79 
82 
88  std::vector<BinnedInterval> m_binnedIntervals;
89 
92 
94  std::vector<double> m_intervalUpperBinEdges;
95 
98 
101 };
102 
103 #endif
BeamHaloParticle
A class to describe a generic beam halo particle.
Definition: BeamHaloParticle.h:22
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
BeamHaloParticleBuffer::m_particlesPerInterval
unsigned int m_particlesPerInterval
The number of particles per interval.
Definition: BeamHaloParticleBuffer.h:78
BeamHaloParticleBuffer::m_numberOfParticles
long m_numberOfParticles
The number of particles present within the output or input file.
Definition: BeamHaloParticleBuffer.h:81
BinnedInterval::m_upperBinEdge
double m_upperBinEdge
Definition: BeamHaloParticleBuffer.h:41
BeamHaloParticleBuffer::openForReading
int openForReading()
Definition: BeamHaloParticleBuffer.cxx:65
BeamHaloParticleBuffer::writeParticle
int writeParticle(BeamHaloParticle *particle)
A member function to append a particle to the binary file.
Definition: BeamHaloParticleBuffer.cxx:109
BinnedInterval::~BinnedInterval
~BinnedInterval()
Definition: BeamHaloParticleBuffer.cxx:26
BeamHaloParticleBuffer::m_recordSize
int m_recordSize
The size of 1 binary data record.
Definition: BeamHaloParticleBuffer.h:75
BinnedInterval::m_intervalUpperBinEdges
std::vector< double > * m_intervalUpperBinEdges
Definition: BeamHaloParticleBuffer.h:42
BeamHaloParticleBuffer::BeamHaloParticleBuffer
BeamHaloParticleBuffer(const std::string &fileName)
Definition: BeamHaloParticleBuffer.cxx:32
BeamHaloParticleBuffer::m_fileName
std::string m_fileName
File name.
Definition: BeamHaloParticleBuffer.h:66
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
BeamHaloParticleBuffer::close
int close()
Definition: BeamHaloParticleBuffer.cxx:84
CLHEP
STD'S.
Definition: IAtRndmGenSvc.h:19
BeamHaloParticleBuffer::~BeamHaloParticleBuffer
~BeamHaloParticleBuffer()=default
BeamHaloParticleBuffer::readParticle
BeamHaloParticle * readParticle(void)
A member function to read a particle from the current position in the binary file.
Definition: BeamHaloParticleBuffer.cxx:264
BeamHaloParticleBuffer::readRandomParticle
BeamHaloParticle * readRandomParticle(CLHEP::HepRandomEngine *engine)
A member function to read a random particle from the binary file.
Definition: BeamHaloParticleBuffer.cxx:171
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
BinnedInterval::operator=
BinnedInterval & operator=(const BinnedInterval &rhs)
Assignment operator.
Definition: BeamHaloParticleBuffer.h:25
BeamHaloParticleBuffer::m_binnedIntervals
std::vector< BinnedInterval > m_binnedIntervals
A map of the upper bin limits and an vector of bin limits within the given interval.
Definition: BeamHaloParticleBuffer.h:88
BeamHaloParticleBuffer
Definition: BeamHaloParticleBuffer.h:45
BeamHaloParticleBuffer::m_ofstream
std::ofstream m_ofstream
A data member to store the output file stream.
Definition: BeamHaloParticleBuffer.h:69
BeamHaloParticleBuffer::m_intervalUpperBinEdge
double m_intervalUpperBinEdge
The upper bin edge of a bin within a given interval.
Definition: BeamHaloParticleBuffer.h:97
BeamHaloParticleBuffer::m_ifstream
std::ifstream m_ifstream
A data member to store the input file stream.
Definition: BeamHaloParticleBuffer.h:72
BinnedInterval::BinnedInterval
BinnedInterval(double upperBinEdge, const std::vector< double > &intervalUpperBinEdges)
Definition: BeamHaloParticleBuffer.cxx:12
BinnedInterval::upperBinEdge
double upperBinEdge() const
Definition: BeamHaloParticleBuffer.h:37
BinnedInterval
Definition: BeamHaloParticleBuffer.h:17
BeamHaloParticleBuffer::openForWriting
int openForWriting()
Definition: BeamHaloParticleBuffer.cxx:48
BeamHaloParticleBuffer::m_upperBinEdge
double m_upperBinEdge
The upper edge of the bin.
Definition: BeamHaloParticleBuffer.h:91
BinnedInterval::intervalUpperBinEdges
const std::vector< double > * intervalUpperBinEdges() const
Definition: BeamHaloParticleBuffer.h:38
BeamHaloParticleBuffer::m_intervalUpperBinEdges
std::vector< double > m_intervalUpperBinEdges
A vector of bin limits for a given interval.
Definition: BeamHaloParticleBuffer.h:94
BeamHaloParticleBuffer::m_writeFlag
bool m_writeFlag
A flag to select read or write.
Definition: BeamHaloParticleBuffer.h:100