|
OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
|
#include <LossDataSink.h>

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< SetStatistics > | computeStatistics (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< OpalParticle > | particles_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 |
Definition at line 94 of file LossDataSink.h.
|
default |
| LossDataSink::LossDataSink | ( | std::string | outfn, |
| bool | hdf5Save, | ||
| CollectionType | collectionType = CollectionType::TEMPORAL |
||
| ) |
Definition at line 467 of file LossDataSink.cpp.
References OpalData::APPEND, bunchNumber_m, OpalData::checkAndAddOutputFileName(), Options::enableHDF5, OpalData::getInstance(), h5hut_mode_m, outputName_m, particles_m, OpalData::setOpenMode(), and turnNumber_m.

| LossDataSink::LossDataSink | ( | const LossDataSink & | rsh | ) |
Definition at line 491 of file LossDataSink.cpp.
References bunchNumber_m, particles_m, and turnNumber_m.
| LossDataSink::~LossDataSink | ( | ) |
Definition at line 507 of file LossDataSink.cpp.
References closeFile(), and H5file_m.

| 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.
| 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.
|
inlineprivate |
Definition at line 141 of file LossDataSink.h.
References fileName_m, and os_m.
Referenced by save().
|
inlineprivate |
|
private |
Definition at line 133 of file LossDataSink.cpp.
References fileName_m, and H5file_m.
Referenced by save(), and ~LossDataSink().
|
private |
Definition at line 1120 of file LossDataSink.cpp.
References SetStatistics::eps2_m, SetStatistics::eps_norm_m, SetStatistics::fac_m, SetStatistics::geomEmit_m, OpalParticle::getCharge(), Util::getGamma(), Util::getKineticEnergy(), OpalParticle::getMass(), OpalParticle::getP(), OpalParticle::getPx(), OpalParticle::getPy(), OpalParticle::getPz(), OpalParticle::getTime(), OpalParticle::getX(), OpalParticle::getY(), OpalParticle::getZ(), SetStatistics::maxR_m, SetStatistics::meanGamma_m, SetStatistics::meanKineticEnergy_m, SetStatistics::nTotal_m, SetStatistics::outputName_m, outputName_m, particles_m, SetStatistics::pmean_m, SetStatistics::prms_m, SetStatistics::psqsum_m, SetStatistics::RefPartP_m, RefPartP_m, SetStatistics::RefPartR_m, RefPartR_m, SetStatistics::refTime_m, refTime_m, SetStatistics::rmax_m, SetStatistics::rmean_m, SetStatistics::rmin_m, SetStatistics::rprms_m, SetStatistics::rpsum_m, SetStatistics::rrms_m, SetStatistics::rsqsum_m, SetStatistics::spos_m, spos_m, startSet_m, SetStatistics::stdKineticEnergy_m, Util::KahanAccumulation::sum, SetStatistics::tmean_m, SetStatistics::totalCharge_m, SetStatistics::totalMass_m, and SetStatistics::trms_m.
Referenced by computeStatistics(), and saveH5().

|
inline |
Definition at line 199 of file LossDataSink.h.
References computeSetStatistics(), and splitSets().

|
private |
Definition at line 102 of file LossDataSink.cpp.
References fileName_m, H5call_m, and H5file_m.
Referenced by save().
|
private |
|
private |
Definition at line 697 of file LossDataSink.cpp.
References turnNumber_m.
Referenced by saveASCII(), saveH5(), and writeHeaderASCII().
|
inline |
Definition at line 103 of file LossDataSink.h.
References h5hut_mode_m.
|
inlineprivate |
Definition at line 134 of file LossDataSink.h.
References fileName_m, and os_m.
Referenced by save().
|
private |
Definition at line 123 of file LossDataSink.cpp.
References fileName_m, and H5file_m.
Referenced by openH5().
|
private |
Definition at line 517 of file LossDataSink.cpp.
References fileName_m, and openFile().
Referenced by save().

| void LossDataSink::save | ( | unsigned int | numSets = 1, |
| OpalData::OpenMode | openMode = OpalData::OpenMode::UNDEFINED |
||
| ) |
Definition at line 630 of file LossDataSink.cpp.
References appendASCII(), bunchNumber_m, closeASCII(), closeFile(), fileName_m, OpalData::getInstance(), getNumSteps(), OpalData::getOpenMode(), globalTrackStep_m, gmsg, h5hut_mode_m, hasNoParticlesToDump(), openASCII(), openH5(), outputName_m, particles_m, RefPartP_m, RefPartR_m, refTime_m, saveASCII(), saveH5(), splitSets(), spos_m, startSet_m, turnNumber_m, OpalData::UNDEFINED, OpalData::WRITE, writeHeaderASCII(), and writeHeaderH5().
Referenced by Ring::finalise().

|
private |
Definition at line 896 of file LossDataSink.cpp.
References bunchNumber_m, OpalParticle::getId(), OpalParticle::getPx(), OpalParticle::getPy(), OpalParticle::getPz(), OpalParticle::getTime(), OpalParticle::getX(), OpalParticle::getY(), OpalParticle::getZ(), hasTurnInformations(), os_m, particles_m, size(), and turnNumber_m.
Referenced by save().

|
private |
Set current record/time step.
Definition at line 705 of file LossDataSink.cpp.
References bunchNumber_m, Options::computePercentiles, computeSetStatistics(), SetStatistics::eps_norm_m, SetStatistics::geomEmit_m, OpalParticle::getCharge(), OpalParticle::getId(), OpalParticle::getMass(), OpalParticle::getPx(), OpalParticle::getPy(), OpalParticle::getPz(), OpalParticle::getTime(), OpalParticle::getX(), OpalParticle::getY(), OpalParticle::getZ(), globalTrackStep_m, H5call_m, hasTurnInformations(), SetStatistics::maxR_m, SetStatistics::meanKineticEnergy_m, SetStatistics::ninetyFivePercentile_m, SetStatistics::ninetyNine_NinetyNinePercentile_m, SetStatistics::ninetyNinePercentile_m, SetStatistics::normalizedEps68Percentile_m, SetStatistics::normalizedEps95Percentile_m, SetStatistics::normalizedEps99_99Percentile_m, SetStatistics::normalizedEps99Percentile_m, SetStatistics::nTotal_m, particles_m, SetStatistics::pmean_m, SetStatistics::prms_m, RefPartP_m, RefPartR_m, refTime_m, SetStatistics::rmean_m, SetStatistics::rrms_m, setNumParticles(), setStep(), SetStatistics::sixtyEightPercentile_m, spos_m, startSet_m, SetStatistics::stdKineticEnergy_m, SetStatistics::tmean_m, SetStatistics::totalCharge_m, SetStatistics::totalMass_m, SetStatistics::trms_m, turnNumber_m, writeDataFloat64(), writeDataInt64(), writeStepAttribFloat64(), and writeStepAttribInt64().
Referenced by save().

|
private |
Definition at line 112 of file LossDataSink.cpp.
References fileName_m, H5call_m, and H5file_m.
Referenced by saveH5().
|
private |
Definition at line 92 of file LossDataSink.cpp.
References fileName_m, H5call_m, and H5file_m.
Referenced by saveH5().
|
inline |
Definition at line 197 of file LossDataSink.h.
References particles_m.
Referenced by saveASCII(), writeStepAttribFloat64(), and writeStepAttribInt64().
|
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.
| numSets | number 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().
|
private |
Definition at line 72 of file LossDataSink.cpp.
References fileName_m, and H5file_m.
Referenced by saveH5().
|
private |
Definition at line 82 of file LossDataSink.cpp.
References fileName_m, and H5file_m.
Referenced by saveH5().
|
private |
Definition at line 40 of file LossDataSink.cpp.
References fileName_m, and H5file_m.
Referenced by writeHeaderH5().
|
private |
Definition at line 585 of file LossDataSink.cpp.
References hasTurnInformations(), and os_m.
Referenced by save().

|
private |
Definition at line 525 of file LossDataSink.cpp.
References collectionType_m, Options::computePercentiles, Util::getGitRevision(), TEMPORAL, and writeFileAttribString().
Referenced by save().

|
private |
Definition at line 50 of file LossDataSink.cpp.
References fileName_m, H5file_m, and size().
Referenced by saveH5().

|
private |
Definition at line 61 of file LossDataSink.cpp.
References fileName_m, H5file_m, and size().
Referenced by saveH5().

|
private |
Definition at line 183 of file LossDataSink.h.
Referenced by addParticle(), LossDataSink(), LossDataSink(), save(), saveASCII(), and saveH5().
|
private |
Definition at line 194 of file LossDataSink.h.
Referenced by writeHeaderH5().
|
private |
Definition at line 166 of file LossDataSink.h.
Referenced by appendASCII(), closeFile(), getNumSteps(), openASCII(), openFile(), openH5(), save(), setNumParticles(), setStep(), writeDataFloat64(), writeDataInt64(), writeFileAttribString(), writeStepAttribFloat64(), and writeStepAttribInt64().
|
private |
Definition at line 188 of file LossDataSink.h.
Referenced by addReferenceParticle(), save(), and saveH5().
|
private |
Current record, or time step, of H5 file.
Definition at line 180 of file LossDataSink.h.
Referenced by getNumSteps(), saveH5(), setNumParticles(), and setStep().
|
private |
used to write out data in H5hut mode
Definition at line 175 of file LossDataSink.h.
Referenced by closeFile(), getNumSteps(), openFile(), setNumParticles(), setStep(), writeDataFloat64(), writeDataInt64(), writeFileAttribString(), writeStepAttribFloat64(), writeStepAttribInt64(), and ~LossDataSink().
|
private |
Definition at line 169 of file LossDataSink.h.
Referenced by inH5Mode(), LossDataSink(), and save().
|
private |
Definition at line 172 of file LossDataSink.h.
Referenced by appendASCII(), closeASCII(), openASCII(), saveASCII(), and writeHeaderASCII().
|
private |
Definition at line 177 of file LossDataSink.h.
Referenced by computeSetStatistics(), LossDataSink(), and save().
|
private |
Definition at line 182 of file LossDataSink.h.
Referenced by addParticle(), computeSetStatistics(), hasNoParticlesToDump(), LossDataSink(), LossDataSink(), save(), saveASCII(), saveH5(), size(), and splitSets().
|
private |
Definition at line 187 of file LossDataSink.h.
Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().
|
private |
Definition at line 186 of file LossDataSink.h.
Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().
|
private |
Definition at line 189 of file LossDataSink.h.
Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().
|
private |
Definition at line 190 of file LossDataSink.h.
Referenced by addReferenceParticle(), computeSetStatistics(), save(), and saveH5().
|
private |
Definition at line 192 of file LossDataSink.h.
Referenced by computeSetStatistics(), save(), saveH5(), and splitSets().
|
private |
Definition at line 184 of file LossDataSink.h.
Referenced by addParticle(), hasTurnInformations(), LossDataSink(), LossDataSink(), save(), saveASCII(), and saveH5().