OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
LossDataSink Class Reference

#include <LossDataSink.h>

Collaboration diagram for LossDataSink:
Collaboration graph

Public Member Functions

 LossDataSink ()=default
 
 LossDataSink (std::string outfn, bool hdf5Save, CollectionType=CollectionType::TEMPORAL)
 
 LossDataSink (const LossDataSink &rsh)
 
 ~LossDataSink () noexcept(false)
 
bool inH5Mode () const
 
void save (unsigned int numSets=1, OpalData::OpenMode openMode=OpalData::OpenMode::UNDEFINED)
 
void addReferenceParticle (const Vector_t< double, 3 > &x, const Vector_t< double, 3 > &p, double time, double spos, long long globalTrackStep)
 
void addParticle (const OpalParticle &, const std::optional< std::pair< int, short int > > &turnBunchNumPair=std::nullopt)
 
size_t size () const
 
std::set< SetStatisticscomputeStatistics (unsigned int numSets)
 

Private Member Functions

void writeFileAttribString (const char *attribute, const char *value)
 
void writeStepAttribFloat64 (const char *attribute, const h5_float64_t *value, h5_int64_t size)
 
void writeStepAttribInt64 (const char *attribute, const h5_int64_t *value, h5_int64_t size)
 
void writeDataFloat64 (const char *name, const h5_float64_t *value)
 
void writeDataInt64 (const char *name, const h5_int64_t *value)
 
void setStep ()
 
void getNumSteps ()
 
void setNumParticles (h5_int64_t num)
 
void openFile (const char *fname, h5_int32_t mode, h5_prop_t props)
 
void closeFile ()
 
void openASCII ()
 
void openH5 (h5_int32_t mode=H5_O_WRONLY)
 
void appendASCII ()
 
void writeHeaderASCII ()
 
void writeHeaderH5 ()
 
void saveASCII ()
 
void saveH5 (unsigned int setIdx)
 
void closeASCII ()
 
bool hasNoParticlesToDump () const
 
bool hasTurnInformations () const
 
void splitSets (unsigned int numSets)
 
SetStatistics computeSetStatistics (unsigned int setIdx)
 

Private Attributes

std::string fileName_m
 
bool h5hut_mode_m = false
 
std::ofstream os_m
 
h5_file_t H5file_m = 0
 used to write out data in H5hut mode
 
std::string outputName_m
 
h5_int64_t H5call_m = 0
 Current record, or time step, of H5 file.
 
std::vector< OpalParticleparticles_m
 
std::vector< size_t > bunchNumber_m
 
std::vector< size_t > turnNumber_m
 
std::vector< Vector_t< double, 3 > > RefPartR_m
 
std::vector< Vector_t< double, 3 > > RefPartP_m
 
std::vector< h5_int64_t > globalTrackStep_m
 
std::vector< double > refTime_m
 
std::vector< double > spos_m
 
std::vector< unsigned long > startSet_m
 
CollectionType collectionType_m = CollectionType::SPATIAL
 

Detailed Description

Definition at line 94 of file LossDataSink.h.

Constructor & Destructor Documentation

◆ LossDataSink() [1/3]

LossDataSink::LossDataSink ( )
default

◆ LossDataSink() [2/3]

LossDataSink::LossDataSink ( std::string  outfn,
bool  hdf5Save,
CollectionType  collectionType = CollectionType::TEMPORAL 
)

◆ LossDataSink() [3/3]

LossDataSink::LossDataSink ( const LossDataSink rsh)

Definition at line 491 of file LossDataSink.cpp.

References bunchNumber_m, particles_m, and turnNumber_m.

◆ ~LossDataSink()

LossDataSink::~LossDataSink ( )

Definition at line 507 of file LossDataSink.cpp.

References closeFile(), and H5file_m.

Here is the call graph for this function:

Member Function Documentation

◆ addParticle()

void LossDataSink::addParticle ( const OpalParticle ,
const std::optional< std::pair< int, short int > > &  turnBunchNumPair = std::nullopt 
)

Definition at line 606 of file LossDataSink.cpp.

References bunchNumber_m, particles_m, and turnNumber_m.

◆ addReferenceParticle()

void LossDataSink::addReferenceParticle ( const Vector_t< double, 3 > &  x,
const Vector_t< double, 3 > &  p,
double  time,
double  spos,
long long  globalTrackStep 
)

Definition at line 596 of file LossDataSink.cpp.

References globalTrackStep_m, RefPartP_m, RefPartR_m, refTime_m, and spos_m.

◆ appendASCII()

void LossDataSink::appendASCII ( )
inlineprivate

Definition at line 141 of file LossDataSink.h.

References fileName_m, and os_m.

Referenced by save().

◆ closeASCII()

void LossDataSink::closeASCII ( )
inlineprivate

Definition at line 153 of file LossDataSink.h.

References os_m.

Referenced by save().

◆ closeFile()

void LossDataSink::closeFile ( )
private

Definition at line 133 of file LossDataSink.cpp.

References fileName_m, and H5file_m.

Referenced by save(), and ~LossDataSink().

◆ computeSetStatistics()

◆ computeStatistics()

std::set< SetStatistics > LossDataSink::computeStatistics ( unsigned int  numSets)
inline

Definition at line 199 of file LossDataSink.h.

References computeSetStatistics(), and splitSets().

Here is the call graph for this function:

◆ getNumSteps()

void LossDataSink::getNumSteps ( )
private

Definition at line 102 of file LossDataSink.cpp.

References fileName_m, H5call_m, and H5file_m.

Referenced by save().

◆ hasNoParticlesToDump()

bool LossDataSink::hasNoParticlesToDump ( ) const
private

Definition at line 688 of file LossDataSink.cpp.

References particles_m.

Referenced by save().

◆ hasTurnInformations()

bool LossDataSink::hasTurnInformations ( ) const
private

Definition at line 697 of file LossDataSink.cpp.

References turnNumber_m.

Referenced by saveASCII(), saveH5(), and writeHeaderASCII().

◆ inH5Mode()

bool LossDataSink::inH5Mode ( ) const
inline

Definition at line 103 of file LossDataSink.h.

References h5hut_mode_m.

◆ openASCII()

void LossDataSink::openASCII ( )
inlineprivate

Definition at line 134 of file LossDataSink.h.

References fileName_m, and os_m.

Referenced by save().

◆ openFile()

void LossDataSink::openFile ( const char *  fname,
h5_int32_t  mode,
h5_prop_t  props 
)
private

Definition at line 123 of file LossDataSink.cpp.

References fileName_m, and H5file_m.

Referenced by openH5().

◆ openH5()

void LossDataSink::openH5 ( h5_int32_t  mode = H5_O_WRONLY)
private

Definition at line 517 of file LossDataSink.cpp.

References fileName_m, and openFile().

Referenced by save().

Here is the call graph for this function:

◆ save()

◆ saveASCII()

void LossDataSink::saveASCII ( )
private

◆ saveH5()

◆ setNumParticles()

void LossDataSink::setNumParticles ( h5_int64_t  num)
private

Definition at line 112 of file LossDataSink.cpp.

References fileName_m, H5call_m, and H5file_m.

Referenced by saveH5().

◆ setStep()

void LossDataSink::setStep ( )
private

Definition at line 92 of file LossDataSink.cpp.

References fileName_m, H5call_m, and H5file_m.

Referenced by saveH5().

◆ size()

size_t LossDataSink::size ( ) const
inline

Definition at line 197 of file LossDataSink.h.

References particles_m.

Referenced by saveASCII(), writeStepAttribFloat64(), and writeStepAttribInt64().

◆ splitSets()

void LossDataSink::splitSets ( unsigned int  numSets)
private

In Opal-T monitors can be traversed several times. We know how many times the bunch passes because we register the passage of the reference particle. This code tries to determine to which bunch (same bunch but different times) a particle belongs. For this we could use algorithms from data science such as k-means or dbscan. But they are an overkill for this application because the bunches are well separated.

In a first step we a assign to each bunch the same number of particles and compute the mean time of passage and with it a time range. Of course this is only an approximation. So we reassign the particles to the bunches using the time ranges compute a better approximation. Two iterations should be sufficient for Opal-T where the temporal separation is large.

Parameters
numSetsnumber of passes of the reference particle

Definition at line 1045 of file LossDataSink.cpp.

References particles_m, and startSet_m.

Referenced by computeStatistics(), and save().

◆ writeDataFloat64()

void LossDataSink::writeDataFloat64 ( const char *  name,
const h5_float64_t *  value 
)
private

Definition at line 72 of file LossDataSink.cpp.

References fileName_m, and H5file_m.

Referenced by saveH5().

◆ writeDataInt64()

void LossDataSink::writeDataInt64 ( const char *  name,
const h5_int64_t *  value 
)
private

Definition at line 82 of file LossDataSink.cpp.

References fileName_m, and H5file_m.

Referenced by saveH5().

◆ writeFileAttribString()

void LossDataSink::writeFileAttribString ( const char *  attribute,
const char *  value 
)
private

Definition at line 40 of file LossDataSink.cpp.

References fileName_m, and H5file_m.

Referenced by writeHeaderH5().

◆ writeHeaderASCII()

void LossDataSink::writeHeaderASCII ( )
private

Definition at line 585 of file LossDataSink.cpp.

References hasTurnInformations(), and os_m.

Referenced by save().

Here is the call graph for this function:

◆ writeHeaderH5()

void LossDataSink::writeHeaderH5 ( )
private

Definition at line 525 of file LossDataSink.cpp.

References collectionType_m, Options::computePercentiles, Util::getGitRevision(), TEMPORAL, and writeFileAttribString().

Referenced by save().

Here is the call graph for this function:

◆ writeStepAttribFloat64()

void LossDataSink::writeStepAttribFloat64 ( const char *  attribute,
const h5_float64_t *  value,
h5_int64_t  size 
)
private

Definition at line 50 of file LossDataSink.cpp.

References fileName_m, H5file_m, and size().

Referenced by saveH5().

Here is the call graph for this function:

◆ writeStepAttribInt64()

void LossDataSink::writeStepAttribInt64 ( const char *  attribute,
const h5_int64_t *  value,
h5_int64_t  size 
)
private

Definition at line 61 of file LossDataSink.cpp.

References fileName_m, H5file_m, and size().

Referenced by saveH5().

Here is the call graph for this function:

Member Data Documentation

◆ bunchNumber_m

std::vector<size_t> LossDataSink::bunchNumber_m
private

Definition at line 183 of file LossDataSink.h.

Referenced by addParticle(), LossDataSink(), LossDataSink(), save(), saveASCII(), and saveH5().

◆ collectionType_m

CollectionType LossDataSink::collectionType_m = CollectionType::SPATIAL
private

Definition at line 194 of file LossDataSink.h.

Referenced by writeHeaderH5().

◆ fileName_m

◆ globalTrackStep_m

std::vector<h5_int64_t> LossDataSink::globalTrackStep_m
private

Definition at line 188 of file LossDataSink.h.

Referenced by addReferenceParticle(), save(), and saveH5().

◆ H5call_m

h5_int64_t LossDataSink::H5call_m = 0
private

Current record, or time step, of H5 file.

Definition at line 180 of file LossDataSink.h.

Referenced by getNumSteps(), saveH5(), setNumParticles(), and setStep().

◆ H5file_m

h5_file_t LossDataSink::H5file_m = 0
private

◆ h5hut_mode_m

bool LossDataSink::h5hut_mode_m = false
private

Definition at line 169 of file LossDataSink.h.

Referenced by inH5Mode(), LossDataSink(), and save().

◆ os_m

std::ofstream LossDataSink::os_m
private

Definition at line 172 of file LossDataSink.h.

Referenced by appendASCII(), closeASCII(), openASCII(), saveASCII(), and writeHeaderASCII().

◆ outputName_m

std::string LossDataSink::outputName_m
private

Definition at line 177 of file LossDataSink.h.

Referenced by computeSetStatistics(), LossDataSink(), and save().

◆ particles_m

std::vector<OpalParticle> LossDataSink::particles_m
private

◆ RefPartP_m

std::vector<Vector_t<double, 3> > LossDataSink::RefPartP_m
private

Definition at line 187 of file LossDataSink.h.

Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().

◆ RefPartR_m

std::vector<Vector_t<double, 3> > LossDataSink::RefPartR_m
private

Definition at line 186 of file LossDataSink.h.

Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().

◆ refTime_m

std::vector<double> LossDataSink::refTime_m
private

Definition at line 189 of file LossDataSink.h.

Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().

◆ spos_m

std::vector<double> LossDataSink::spos_m
private

Definition at line 190 of file LossDataSink.h.

Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().

◆ startSet_m

std::vector<unsigned long> LossDataSink::startSet_m
private

Definition at line 192 of file LossDataSink.h.

Referenced by computeSetStatistics(), save(), saveH5(), and splitSets().

◆ turnNumber_m

std::vector<size_t> LossDataSink::turnNumber_m
private

The documentation for this class was generated from the following files: