![]() |
SynAPSE
0.6.0
Synergistic Analysis of Phase Space Evolution
|
Holds a bunch of particles at a specific position along the beam line. More...
#include <Bunch.hh>
Public Member Functions | |
| Bunch () | |
| Default constructor, initilizes everything to 0. More... | |
| Bunch (const BunchMap &samples, const double pos=0, const std::string &name="", const double mass=105.66) | |
| Map constructor, sets the particle sample from maps (no measurement errors) More... | |
| Bunch (const BunchMap &samples, const BunchMap &errors, const double pos=0, const std::string &name="", const double mass=105.66) | |
| Map constructor, sets the particle sample from maps. More... | |
| Bunch (const Bunch &bunch) | |
| Copy constructor. More... | |
| Bunch & | operator= (const Bunch &bunch) |
| Equality operator. More... | |
| ~Bunch () | |
| Destructor. More... | |
| const std::string & | Name () const |
| Returns the name of the bunch. More... | |
| void | SetName (const std::string &name) |
| Sets the name of the bunch. More... | |
| const size_t & | Dimension () const |
| Returns the dimension of space in which the bunch lives. More... | |
| const double & | Position () const |
| Returns the z position at which the bunch was sampled [mm]. More... | |
| const double & | Mass () const |
| Returns the mass of the particles that make up the beam [MeV/c^2]. More... | |
| void | SetPosition (const double &pos) |
| Sets the position of the bunch. More... | |
| const size_t | Size () const |
| Returns the size of the whole sample. More... | |
| const size_t | CoreSize () const |
| Returns the size of the core sample. More... | |
| const std::vector< double > & | Samples (const std::string var) const |
| Returns the array of samples of variable var. More... | |
| const std::vector< double > & | Errors (const std::string var) const |
| Returns the array of errors on the samples of variable var. More... | |
| double | Radius (const size_t i) const |
| Returns the radius of the i^th sample. More... | |
| std::vector< double > | Radii () const |
| Returns the array of radii of the samples. More... | |
| Variable | Mean (const std::string &var) const |
| Returns the mean of the requested quantity. More... | |
| const Matrix< double > & | CovarianceMatrix () const |
| Returns the covariance matrix of the bunch. More... | |
| const Variable & | Alpha () const |
| Returns the Twiss parameter alpha of the bunch. More... | |
| Variable | Alpha (const std::string axis) const |
| Returns the Twiss parameter alpha of the bunch in one 2D projection. More... | |
| const Variable & | Beta () const |
| Returns the Twiss parameter beta of the bunch. More... | |
| Variable | Beta (const std::string axis) const |
| Returns the Twiss parameter beta of the bunch in one 2D projection. More... | |
| const Variable | Gamma () const |
| Returns the Twiss parameter gamma of the bunch. More... | |
| Variable | Gamma (const std::string axis) const |
| Returns the Twiss parameter gamma of the bunch in one 2D projection. More... | |
| const Variable & | MechanicalL () const |
| Returns the mechanical angular momentum of the bunch. More... | |
| const Variable & | Emittance () const |
| Returns the RMS normalised emittance of the bunch. More... | |
| const Variable & | NormEmittance () const |
| Returns the RMS geometric emittance of the bunch. More... | |
| const Variable & | SubEmittance () const |
| Returns the subemittance of the core. More... | |
| const Variable & | FracEmittance () const |
| Returns the volume of the core. More... | |
| const Variable & | AmplitudeQuantile () const |
| Returns the maximum amplitude in the core. More... | |
| Variable | NormEmittanceEstimate (const SumStat &stat) const |
| Returns the estimated normalised emittance from the measured fractional quantity. More... | |
| Variable | SummaryStatistic (const SumStat &stat) const |
| Returns the requested summary statistic. More... | |
| const std::vector< double > & | Amplitudes () const |
| Returns the array of amplitudes of the samples. More... | |
| const std::vector< double > & | VoronoiVolumes () const |
| Returns the array of Voronoi volumes of the samples. More... | |
| void | SetFraction (const double frac) |
| Defines the fraction the core represents (in case of transmission losses) More... | |
| void | SetCoreFraction (const double frac) |
| Defines the fraction of the beam contained in the core. More... | |
| void | SetCoreSize (const size_t size) |
| Assigns a certain amount of core particles. More... | |
| void | SetCoreVolume (const std::string algo="hull", const double norm=1.) |
| Computes the volume of the fraction of the beam contained in the core. More... | |
| void | SetCorrectedAmplitudes () |
| Compute the corrected transverse amplitudes of every particle in the sample by only considering particles of lower amplitudes. More... | |
| void | SetMCDAmplitudes () |
| Compute the MCD transverse amplitude of every particle in the sample by selecting a subsample optimized based on its covariance determinant. More... | |
| void | SetGeneralisedAmplitudes (const double norm=1.) |
| Compute the generalised transverse amplitude of every particle in the sample by basing it on density estimation and contour volume rather than covariance. More... | |
| void | SetVoronoiVolumes () |
| Compute the Voronoi volumes around each particle. More... | |
| TEllipse * | Ellipse (const std::string &vara, const std::string &varb, const double p=.39347) const |
| Returns the n-RMS ellipse of a sample of two variables. More... | |
| TEllipse * | RobustEllipse (const std::string &vara, const std::string &varb, const double p=.39347) const |
| Returns the n-RMS robust ellipse of a sample of two variables. More... | |
| TH1F * | Histogram (const std::string &var, double min=0, double max=0) const |
| Returns the 1D distrubution of the requested variable. More... | |
| TH2F * | Histogram (const std::string &vara, const std::string &varb, double mina=0, double maxa=0, double minb=0, double maxb=0) const |
| Returns the 2D distrubution of the requested variable. More... | |
| ScatterGraph * | AmplitudeScatter (const std::string &vara, const std::string &varb) const |
| Returns the 2D scatter plot of particle amplitudes. More... | |
Private Member Functions | |
| void | Initialize (const BunchMap &samples, const BunchMap &errors) |
| Normal initializer, sets the particle sample and bunch variables. More... | |
| bool | Contains (const std::string &var) const |
| Checks if the variable is provided. More... | |
| void | AssertContains (const std::string &var) const |
| Checks if the variable is provided, throws if not. More... | |
| void | Arrays (const std::string &var, std::vector< double > &samples, std::vector< double > &errors) const |
| Returns the value and unertainty arrays corresponding to the requested variable. More... | |
| double | TotalMomentum (const size_t i) const |
| Returns the total momentum of a given sample. More... | |
| std::vector< double > | TotalMomenta () const |
| Returns the total momentum of all the samples. More... | |
| double | TotalMomentumError (const size_t i) const |
| Returns the error on the total momentum of a given sample. More... | |
| std::vector< double > | TotalMomentumErrors () const |
| Returns the error on the total momentum of all the samples. More... | |
| void | SetTwiss () |
| Computes the Twiss parameter alpha of the bunch. More... | |
| double | TwissMError (const std::string &name, std::map< std::string, double > &means, const double &detr, const Matrix< double > &C) const |
| Computes the measurement error on the requested Twiss parameter. More... | |
| double | TwissSError (const double &twiss) const |
| Computes the statistical error on the provided Twiss parameter. More... | |
| void | SetEmittance () |
| Computes the RMS geometric emittance of the bunch. More... | |
| void | SetNormEmittance () |
| Computes the RMS normalised emittance of the bunch. More... | |
| void | SetSubEmittance () |
| Computes the subemittance of the core. More... | |
| void | SetAmplitudeQuantile (const double &qamp) |
| Sets the amplitude quantile and its uncertainty. More... | |
| double | NormEmittanceValue (const Matrix< double > &covmat) const |
| Computes the RMS emittance provided with the covariance matrix. More... | |
| void | SetAmplitudes () |
| Compute the transverse amplitudes of every particle in the sample. More... | |
| double | AmplitudeValue (const Matrix< double > &invcovmat, const std::vector< double > &means, const std::vector< double > &vec, const double &neps) const |
| Compute the transverse amplitude provided with S^-1 and the PS vector. More... | |
Private Attributes | |
| std::string | _name |
| Name of the bunch. More... | |
| size_t | _dim |
| Dimension of the transverse phase space. More... | |
| double | _pos |
| Position at which the bunch was sampled. More... | |
| double | _mass |
| Mass of the particles. More... | |
| double | _fraction |
| Fraction contained in the beam core. More... | |
| BunchData | _data |
| Underlying phase space vectors. More... | |
| BunchData | _core |
| Core fraction of beam. More... | |
| Variable | _alpha |
| Twiss parameter alpha. More... | |
| Variable | _beta |
| Twiss parameter beta. More... | |
| Variable | _gamma |
| Twiss parameter gamma. More... | |
| Variable | _mecl |
| Normalised mechanical angular momentum. More... | |
| Variable | _eps |
| Geometric RMS emittance. More... | |
| Variable | _neps |
| Normalised RMS emittance. More... | |
| Variable | _seps |
| Subemittance. More... | |
| Variable | _feps |
| Fractional emittance. More... | |
| Variable | _qamp |
| Lagest amplitude in the core. More... | |
| std::vector< double > | _amps |
| Amplitudes of the particles. More... | |
| std::vector< double > | _vols |
| Voronoi cell volumes of the particles. More... | |
| DensityEstimator | _de |
| Density estimation of the bunch. More... | |
Holds a bunch of particles at a specific position along the beam line.
Quantities associated with the bunch such as Twiss parameters, amplitudes, emittance, volume, etc. may be computed and stored here. This avoids unnecessarily repeating operations such as computing the particle amplitudes.
It is designed to hold a single species of particles.
| Beam::Bunch::Bunch | ( | ) |
Default constructor, initilizes everything to 0.
| Beam::Bunch::Bunch | ( | const BunchMap & | samples, |
| const double | pos = 0, |
||
| const std::string & | name = "", |
||
| const double | mass = 105.66 |
||
| ) |
Map constructor, sets the particle sample from maps (no measurement errors)
| samples | Dictionary that maps each variable onto a vector of values |
| name | Name of the bunch |
| pos | z position of the bunch [mm] |
| mass | Mass of the particles that compose the bunch |
| Beam::Bunch::Bunch | ( | const BunchMap & | samples, |
| const BunchMap & | errors, | ||
| const double | pos = 0, |
||
| const std::string & | name = "", |
||
| const double | mass = 105.66 |
||
| ) |
Map constructor, sets the particle sample from maps.
| samples | Dictionary that maps each variable onto a vector of values |
| errors | Dictionary that maps each variable onto a vector of uncertainties |
| pos | z position of the bunch [mm] |
| name | Name of the bunch |
| mass | Mass of the particles that compose the bunch |
| Beam::Bunch::Bunch | ( | const Bunch & | bunch | ) |
Copy constructor.
| Beam::Bunch::~Bunch | ( | ) |
Destructor.
|
inline |
Returns the Twiss parameter alpha of the bunch.
| Variable Beam::Bunch::Alpha | ( | const std::string | axis | ) | const |
Returns the Twiss parameter alpha of the bunch in one 2D projection.
|
inline |
Returns the maximum amplitude in the core.
|
inline |
Returns the array of amplitudes of the samples.
| ScatterGraph * Beam::Bunch::AmplitudeScatter | ( | const std::string & | vara, |
| const std::string & | varb | ||
| ) | const |
Returns the 2D scatter plot of particle amplitudes.
| vara | First variable of which to draw the amplitude scatter plot |
| varb | Second variable of which to draw the amplitude scatter plot |
|
private |
Compute the transverse amplitude provided with S^-1 and the PS vector.
| invcovmat | Inverse of the covariance matrix |
| means | Map of the means of each variables |
| vec | Phase space vector of the particle |
| neps | Normalised emittance of the bunch |
|
private |
Returns the value and unertainty arrays corresponding to the requested variable.
| var | Variable of which to return the arrays |
| samples | Array of values |
| errors | Array of uncertainties |
|
inlineprivate |
Checks if the variable is provided, throws if not.
|
inline |
Returns the Twiss parameter beta of the bunch.
| Variable Beam::Bunch::Beta | ( | const std::string | axis | ) | const |
Returns the Twiss parameter beta of the bunch in one 2D projection.
|
inlineprivate |
Checks if the variable is provided.
|
inline |
Returns the size of the core sample.
|
inline |
Returns the covariance matrix of the bunch.
|
inline |
Returns the dimension of space in which the bunch lives.
| TEllipse * Beam::Bunch::Ellipse | ( | const std::string & | vara, |
| const std::string & | varb, | ||
| const double | p = .39347 |
||
| ) | const |
Returns the n-RMS ellipse of a sample of two variables.
The default probability corresponds to the
contour.
| vara | First variable in which to compute the RMS ellipse |
| varb | Second variable in which to compute the RMS ellipse |
| p | P-value of the distribution (probability content) |
|
inline |
Returns the RMS normalised emittance of the bunch.
| const std::vector< double > & Beam::Bunch::Errors | ( | const std::string | var | ) | const |
Returns the array of errors on the samples of variable var.
|
inline |
Returns the volume of the core.
|
inline |
Returns the Twiss parameter gamma of the bunch.
| Variable Beam::Bunch::Gamma | ( | const std::string | axis | ) | const |
Returns the Twiss parameter gamma of the bunch in one 2D projection.
| TH1F * Beam::Bunch::Histogram | ( | const std::string & | var, |
| double | min = 0, |
||
| double | max = 0 |
||
| ) | const |
Returns the 1D distrubution of the requested variable.
| var | Name of the variable of which to draw the distribution |
| min | Minimum of the range of var |
| max | Maximum of the range of var |
| TH2F * Beam::Bunch::Histogram | ( | const std::string & | vara, |
| const std::string & | varb, | ||
| double | mina = 0, |
||
| double | maxa = 0, |
||
| double | minb = 0, |
||
| double | maxb = 0 |
||
| ) | const |
Returns the 2D distrubution of the requested variable.
| vara | First variable of which to draw the distribution |
| varb | Second variable of which to draw the distribution |
| mina | Minimum of the range of vara |
| maxa | Maximum of the range of vara |
| minb | Minimum of the range of varb |
| maxb | Maximum of the range of varb |
Normal initializer, sets the particle sample and bunch variables.
| samples | Dictionary that maps each variable onto a vector of values |
| errors | Dictionary that maps each variable onto a vector of errors |
|
inline |
Returns the mass of the particles that make up the beam [MeV/c^2].
| Variable Beam::Bunch::Mean | ( | const std::string & | var | ) | const |
Returns the mean of the requested quantity.
|
inline |
Returns the mechanical angular momentum of the bunch.
|
inline |
Returns the name of the bunch.
|
inline |
Returns the RMS geometric emittance of the bunch.
Returns the estimated normalised emittance from the measured fractional quantity.
|
private |
Computes the RMS emittance provided with the covariance matrix.
|
inline |
Returns the z position at which the bunch was sampled [mm].
| std::vector< double > Beam::Bunch::Radii | ( | ) | const |
Returns the array of radii of the samples.
| double Beam::Bunch::Radius | ( | const size_t | i | ) | const |
Returns the radius of the i^th sample.
| TEllipse * Beam::Bunch::RobustEllipse | ( | const std::string & | vara, |
| const std::string & | varb, | ||
| const double | p = .39347 |
||
| ) | const |
Returns the n-RMS robust ellipse of a sample of two variables.
| vara | First variable in which to compute the RMS ellipse |
| varb | Second variable in which to compute the RMS ellipse |
| p | P-value of the distribution (probability content) |
| const std::vector< double > & Beam::Bunch::Samples | ( | const std::string | var | ) | const |
Returns the array of samples of variable var.
|
private |
Sets the amplitude quantile and its uncertainty.
|
private |
Compute the transverse amplitudes of every particle in the sample.
| void Beam::Bunch::SetCoreFraction | ( | const double | frac | ) |
Defines the fraction of the beam contained in the core.
| frac | Fraction of the initial bunch to be kept |
| void Beam::Bunch::SetCoreSize | ( | const size_t | size | ) |
Assigns a certain amount of core particles.
| size | Number of particles to be kept |
| void Beam::Bunch::SetCoreVolume | ( | const std::string | algo = "hull", |
| const double | norm = 1. |
||
| ) |
Computes the volume of the fraction of the beam contained in the core.
| algo | Volume reconstruction algorithm |
| norm | Normalisation constant if the bunch has scraped |
| void Beam::Bunch::SetCorrectedAmplitudes | ( | ) |
Compute the corrected transverse amplitudes of every particle in the sample by only considering particles of lower amplitudes.
|
private |
Computes the RMS geometric emittance of the bunch.
|
inline |
Defines the fraction the core represents (in case of transmission losses)
| void Beam::Bunch::SetGeneralisedAmplitudes | ( | const double | norm = 1. | ) |
Compute the generalised transverse amplitude of every particle in the sample by basing it on density estimation and contour volume rather than covariance.
| norm | Normalisation constant (if the distribution is truncated) |
| void Beam::Bunch::SetMCDAmplitudes | ( | ) |
Compute the MCD transverse amplitude of every particle in the sample by selecting a subsample optimized based on its covariance determinant.
|
inline |
Sets the name of the bunch.
|
private |
Computes the RMS normalised emittance of the bunch.
|
inline |
Sets the position of the bunch.
|
private |
Computes the subemittance of the core.
|
private |
Computes the Twiss parameter alpha of the bunch.
| void Beam::Bunch::SetVoronoiVolumes | ( | ) |
Compute the Voronoi volumes around each particle.
This is not done by default as it takes a long time (need to tesselate the 4D space).
Does not do anything if it has already been called.
|
inline |
Returns the size of the whole sample.
|
inline |
Returns the subemittance of the core.
Returns the requested summary statistic.
|
private |
Returns the total momentum of all the samples.
|
private |
Returns the total momentum of a given sample.
|
private |
Returns the error on the total momentum of a given sample.
|
private |
Returns the error on the total momentum of all the samples.
|
private |
Computes the measurement error on the requested Twiss parameter.
| name | Name of the Twiss parameter |
| means | Map of the means for each variables |
| detr | Errors on the determinant of the optical covariance matrix |
| C | Cofactor matrix of the optical covariance matrix |
|
private |
Computes the statistical error on the provided Twiss parameter.
| twiss | Value of the twiss parameter |
|
inline |
Returns the array of Voronoi volumes of the samples.
|
private |
Twiss parameter alpha.
|
private |
Amplitudes of the particles.
|
private |
Twiss parameter beta.
|
private |
Core fraction of beam.
|
private |
Underlying phase space vectors.
|
private |
Density estimation of the bunch.
|
private |
Dimension of the transverse phase space.
|
private |
Geometric RMS emittance.
|
private |
Fractional emittance.
|
private |
Fraction contained in the beam core.
|
private |
Twiss parameter gamma.
|
private |
Mass of the particles.
|
private |
Normalised mechanical angular momentum.
|
private |
Name of the bunch.
|
private |
Normalised RMS emittance.
|
private |
Position at which the bunch was sampled.
|
private |
Lagest amplitude in the core.
|
private |
Subemittance.
|
private |
Voronoi cell volumes of the particles.
1.8.6