ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Trk::ElectronCombinedMaterialEffects Class Reference

#include <ElectronCombinedMaterialEffects.h>

Collaboration diagram for Trk::ElectronCombinedMaterialEffects:

Classes

struct  ComponentValues
 Helper Struct for multiple Gaussian components. More...
 

Public Types

using MixtureParameters = std::array< ComponentValues, GSFConstants::maxNumberofMatComponents >
 
using Polynomial = std::array< double, GSFConstants::polynomialCoefficients >
 

Public Member Functions

 ElectronCombinedMaterialEffects (const std::string &parameterisationFileName, const std::string &parameterisationFileNameHighX0)
 
 ElectronCombinedMaterialEffects ()=default
 
 ElectronCombinedMaterialEffects (const ElectronCombinedMaterialEffects &)=default
 
 ElectronCombinedMaterialEffects (ElectronCombinedMaterialEffects &&)=default
 
ElectronCombinedMaterialEffectsoperator= (const ElectronCombinedMaterialEffects &)=default
 
ElectronCombinedMaterialEffectsoperator= (ElectronCombinedMaterialEffects &&)=default
 
 ~ElectronCombinedMaterialEffects ()=default
 
void compute (GsfMaterial::Combined &, const Trk::ComponentParameters &, const Trk::MaterialProperties &, double, Trk::PropDirection=anyDirection) const
 

Private Member Functions

void BetheHeitler (GsfMaterial::EnergyLoss &cache, const ComponentParameters &componentParameters, const MaterialProperties &materialProperties, double pathLenght, PropDirection direction=anyDirection) const
 

Private Attributes

int m_BHnumberOfComponents {}
 
int m_BHtransformationCode {}
 
int m_BHnumberOfComponentsHighX0 {}
 
int m_BHtransformationCodeHighX0 {}
 
std::array< Polynomial, GSFConstants::maxNumberofMatComponentsm_BHpolynomialWeights {}
 
std::array< Polynomial, GSFConstants::maxNumberofMatComponentsm_BHpolynomialMeans {}
 
std::array< Polynomial, GSFConstants::maxNumberofMatComponentsm_BHpolynomialVariances {}
 
std::array< Polynomial, GSFConstants::maxNumberofMatComponentsm_BHpolynomialWeightsHighX0 {}
 
std::array< Polynomial, GSFConstants::maxNumberofMatComponentsm_BHpolynomialMeansHighX0 {}
 
std::array< Polynomial, GSFConstants::maxNumberofMatComponentsm_BHpolynomialVariancesHighX0 {}
 

Detailed Description

Definition at line 25 of file ElectronCombinedMaterialEffects.h.

Member Typedef Documentation

◆ MixtureParameters

Definition at line 35 of file ElectronCombinedMaterialEffects.h.

◆ Polynomial

Definition at line 38 of file ElectronCombinedMaterialEffects.h.

Constructor & Destructor Documentation

◆ ElectronCombinedMaterialEffects() [1/4]

Trk::ElectronCombinedMaterialEffects::ElectronCombinedMaterialEffects ( const std::string &  parameterisationFileName,
const std::string &  parameterisationFileNameHighX0 
)

Definition at line 198 of file ElectronCombinedMaterialEffects.cxx.

201 {
202  // The following is a bit repetitive code
203  // we could consider refactoring
204  // The low X0 polynomials
205  {
206  std::string resolvedFileName =
207  PathResolver::find_file(parameterisationFileName, "DATAPATH");
208  if (resolvedFileName.empty()) {
209  std::ostringstream ss;
210  ss << "Parameterisation file : " << parameterisationFileName
211  << " not found";
212  throw std::logic_error(ss.str());
213  }
214 
215  const char* filename = resolvedFileName.c_str();
216  std::ifstream fin(filename);
217  if (fin.bad()) {
218  std::ostringstream ss;
219  ss << "Error opening file: " << resolvedFileName;
220  throw std::logic_error(ss.str());
221  }
222 
224  int orderPolynomial = 0;
225  fin >> orderPolynomial;
227  if (not inRange(
229  std::ostringstream ss;
230  ss << "numberOfComponents Parameter out of range 0- "
233  throw std::logic_error(ss.str());
234  }
235  if (orderPolynomial != (GSFConstants::polynomialCoefficients - 1)) {
236  std::ostringstream ss;
237  ss << "orderPolynomial order != "
239  throw std::logic_error(ss.str());
240  }
241  if (not inRange(m_BHtransformationCode, 0, 1)) {
242  std::ostringstream ss;
243  ss << "transformationCode Parameter out of range 0-1: "
245  throw std::logic_error(ss.str());
246  }
247  if (!fin) {
248  std::ostringstream ss;
249  ss << "Error while reading file : " << resolvedFileName;
250  throw std::logic_error(ss.str());
251  }
252  // Fill the polynomials
253  int componentIndex = 0;
254  for (; componentIndex < m_BHnumberOfComponents; ++componentIndex) {
255  m_BHpolynomialWeights[componentIndex] = readPolynomial(fin);
256  m_BHpolynomialMeans[componentIndex] = readPolynomial(fin);
257  m_BHpolynomialVariances[componentIndex] = readPolynomial(fin);
258  }
259  }
260  // Read the high X0 polynomials
261  {
262  std::string resolvedFileName =
263  PathResolver::find_file(parameterisationFileNameHighX0, "DATAPATH");
264  if (resolvedFileName.empty()) {
265  std::ostringstream ss;
266  ss << "Parameterisation file : " << parameterisationFileNameHighX0
267  << " not found";
268  throw std::logic_error(ss.str());
269  }
270 
271  const char* filename = resolvedFileName.c_str();
272  std::ifstream fin(filename);
273  if (fin.bad()) {
274  std::ostringstream ss;
275  ss << "Error opening file: " << resolvedFileName;
276  throw std::logic_error(ss.str());
277  }
279  int orderPolynomial = 0;
280  fin >> orderPolynomial;
282  //
284  0,
286  std::ostringstream ss;
287  ss << "numberOfComponentsHighX0 Parameter out of range 0- "
290  throw std::logic_error(ss.str());
291  }
293  std::ostringstream ss;
294  ss << " numberOfComponentsHighX0 != numberOfComponents";
295  throw std::logic_error(ss.str());
296  }
297  if (orderPolynomial != (GSFConstants::polynomialCoefficients - 1)) {
298  std::ostringstream ss;
299  ss << "orderPolynomial order != "
301  throw std::logic_error(ss.str());
302  }
303  if (not inRange(m_BHtransformationCodeHighX0, 0, 1)) {
304  std::ostringstream ss;
305  ss << "transformationCode Parameter out of range "
306  "0-1: "
308  throw std::logic_error(ss.str());
309  }
310 
311  // Fill the polynomials
312  int componentIndex = 0;
313  for (; componentIndex < m_BHnumberOfComponentsHighX0; ++componentIndex) {
314  m_BHpolynomialWeightsHighX0[componentIndex] = readPolynomial(fin);
315  m_BHpolynomialMeansHighX0[componentIndex] = readPolynomial(fin);
316  m_BHpolynomialVariancesHighX0[componentIndex] = readPolynomial(fin);
317  }
318  }
319 }

◆ ElectronCombinedMaterialEffects() [2/4]

Trk::ElectronCombinedMaterialEffects::ElectronCombinedMaterialEffects ( )
default

◆ ElectronCombinedMaterialEffects() [3/4]

Trk::ElectronCombinedMaterialEffects::ElectronCombinedMaterialEffects ( const ElectronCombinedMaterialEffects )
default

◆ ElectronCombinedMaterialEffects() [4/4]

Trk::ElectronCombinedMaterialEffects::ElectronCombinedMaterialEffects ( ElectronCombinedMaterialEffects &&  )
default

◆ ~ElectronCombinedMaterialEffects()

Trk::ElectronCombinedMaterialEffects::~ElectronCombinedMaterialEffects ( )
default

Member Function Documentation

◆ BetheHeitler()

void Trk::ElectronCombinedMaterialEffects::BetheHeitler ( GsfMaterial::EnergyLoss cache,
const ComponentParameters componentParameters,
const MaterialProperties materialProperties,
double  pathLenght,
Trk::PropDirection  direction = anyDirection 
) const
private

Definition at line 385 of file ElectronCombinedMaterialEffects.cxx.

391 {
392  cache.numElements = 0;
393 
394  const Trk::TrackParameters* trackParameters = componentParameters.params.get();
395  const Amg::Vector3D& globalMomentum = trackParameters->momentum();
396 
397  const double radiationLength = materialProperties.x0();
398  const double momentum = globalMomentum.mag();
399  double pathlengthInX0 = pathLength / radiationLength;
400 
401  if (pathlengthInX0 < s_singleGaussianRange) {
402  cache.elements[0] = { 1., 0., 0. };
403  cache.numElements = 1;
404  return;
405  }
406 
407  // If the amount of material is between 0.0001 and 0.01 return the gaussian
408  // approximation to the Bethe-Heitler distribution
409  if (pathlengthInX0 < s_lowerRange) {
410  const double meanZ = std::exp(-1. * pathlengthInX0);
411  const double sign = (direction == Trk::oppositeMomentum) ? 1. : -1.;
412  const double varZ =
413  std::exp(-1. * pathlengthInX0 * std::log(3.) / std::log(2.)) -
414  std::exp(-2. * pathlengthInX0);
415  double deltaP(0.);
416  double varQoverP(0.);
417  if (direction == Trk::alongMomentum) {
418  deltaP = sign * momentum * (1. - meanZ);
419  varQoverP = 1. / (meanZ * meanZ * momentum * momentum) * varZ;
420  } else {
421  deltaP = sign * momentum * (1. / meanZ - 1.);
422  varQoverP = varZ / (momentum * momentum);
423  }
424  cache.elements[0] = { 1., deltaP, varQoverP };
425  cache.numElements = 1;
426  return;
427  }
428 
429  // Now we do the full calculation
430  if (pathlengthInX0 > s_upperRange) {
431  pathlengthInX0 = s_upperRange;
432  }
433 
434  // Get proper mixture parameters
435  MixtureParameters mixture;
436  if (pathlengthInX0 > s_xOverRange) {
438  mixture = getTransformedMixtureParameters(m_BHpolynomialWeightsHighX0,
441  pathlengthInX0,
443  } else {
444  mixture = getMixtureParameters(m_BHpolynomialWeightsHighX0,
447  pathlengthInX0,
449  }
450  } else {
452  mixture = getTransformedMixtureParameters(m_BHpolynomialWeights,
455  pathlengthInX0,
457  } else {
458  mixture = getMixtureParameters(m_BHpolynomialWeights,
461  pathlengthInX0,
463  }
464  }
465  // Correct the mixture
466  correctWeights(mixture, m_BHnumberOfComponents);
467  int componentIndex = 0;
468  double weightToBeRemoved(0.);
469  int componentWithHighestMean(0);
470  for (; componentIndex < m_BHnumberOfComponents; ++componentIndex) {
471  if (mixture[componentIndex].mean > mixture[componentWithHighestMean].mean) {
472  componentWithHighestMean = componentIndex;
473  }
474  if (mixture[componentIndex].mean >= s_componentMeanCut) {
475  continue;
476  }
477  weightToBeRemoved += mixture[componentIndex].weight;
478  }
479  // Fill the cache to be returned
480  componentIndex = 0;
481  for (; componentIndex < m_BHnumberOfComponents; ++componentIndex) {
482  double varianceInverseMomentum = 0;
483  // This is not mathematically correct but it does stabilize the GSF
484  if (mixture[componentIndex].mean < s_componentMeanCut) {
485  continue;
486  }
487  double weight = mixture[componentIndex].weight;
488  if (componentIndex == componentWithHighestMean) {
489  weight += weightToBeRemoved;
490  }
491  double deltaP(0.);
492  if (direction == alongMomentum) {
493  // For forward propagation
494  deltaP = momentum * (mixture[componentIndex].mean - 1.);
495  const double f = 1. / (momentum * mixture[componentIndex].mean);
496  varianceInverseMomentum = f * f * mixture[componentIndex].variance;
497  } // end forward propagation if clause
498  else {
499  // For backwards propagation
500  deltaP = momentum * (1. / mixture[componentIndex].mean - 1.);
501  varianceInverseMomentum =
502  mixture[componentIndex].variance / (momentum * momentum);
503  } // end backwards propagation if clause
504 
505  // set in the cache and increase the elements
506  cache.elements[cache.numElements] = { weight,
507  deltaP,
508  varianceInverseMomentum };
509  ++cache.numElements;
510  } // end for loop over all components
511 }

◆ compute()

void Trk::ElectronCombinedMaterialEffects::compute ( GsfMaterial::Combined cache,
const Trk::ComponentParameters componentParameters,
const Trk::MaterialProperties materialProperties,
double  pathLength,
Trk::PropDirection  direction = anyDirection 
) const

Definition at line 322 of file ElectronCombinedMaterialEffects.cxx.

328 {
329  const AmgSymMatrix(5)* measuredCov = componentParameters.params->covariance();
330  /*
331  * 1. Retrieve multiple scattering corrections
332  */
333  GsfMaterial::Scattering cache_multipleScatter;
334  scattering(
335  cache_multipleScatter, componentParameters, materialProperties, pathLength);
336  /*
337  * 2. Retrieve energy loss corrections
338  */
339  GsfMaterial::EnergyLoss cache_energyLoss;
340  this->BetheHeitler(cache_energyLoss,
341  componentParameters,
342  materialProperties,
343  pathLength,
344  direction);
345  // Protect if there are no new energy loss
346  // components
347  // we want at least on dummy to "combine"
348  // with scattering
349  if (cache_energyLoss.numElements == 0) {
350  cache_energyLoss.elements[0] = { 1, 0, 0 };
351  cache_energyLoss.numElements = 1;
352  }
353  /*
354  * 3. Combine the multiple scattering with each of the energy loss components
355  */
356  // Cache is to be filled so 0 entries here
357  cache.numEntries = 0;
358  for (int i = 0; i < cache_energyLoss.numElements; ++i) {
359  double combinedWeight = cache_energyLoss.elements[i].weight;
360  double combinedDeltaP = cache_energyLoss.elements[i].deltaP;
361  cache.weights[i] = combinedWeight;
362  cache.deltaPs[i] = combinedDeltaP;
363  if (measuredCov) {
364  // Create the covariance
365  const double covPhi = cache_multipleScatter.deltaPhiCov;
366  const double covTheta = cache_multipleScatter.deltaThetaCov;
367  const double covQoverP = cache_energyLoss.elements[i].deltaQOvePCov;
368  cache.deltaCovariances[i] << 0, 0, 0, 0, 0, // 5
369  0, 0, 0, 0, 0, // 10
370  0, 0, covPhi, 0, 0, // 15
371  0, 0, 0, covTheta, 0, // 20
372  0, 0, 0, 0, covQoverP;
373  } else {
374  cache.deltaCovariances[i].setZero();
375  }
376  ++cache.numEntries;
377  } // end for loop over energy loss components
378 }

◆ operator=() [1/2]

ElectronCombinedMaterialEffects& Trk::ElectronCombinedMaterialEffects::operator= ( const ElectronCombinedMaterialEffects )
default

◆ operator=() [2/2]

ElectronCombinedMaterialEffects& Trk::ElectronCombinedMaterialEffects::operator= ( ElectronCombinedMaterialEffects &&  )
default

Member Data Documentation

◆ m_BHnumberOfComponents

int Trk::ElectronCombinedMaterialEffects::m_BHnumberOfComponents {}
private

Definition at line 70 of file ElectronCombinedMaterialEffects.h.

◆ m_BHnumberOfComponentsHighX0

int Trk::ElectronCombinedMaterialEffects::m_BHnumberOfComponentsHighX0 {}
private

Definition at line 72 of file ElectronCombinedMaterialEffects.h.

◆ m_BHpolynomialMeans

std::array<Polynomial, GSFConstants::maxNumberofMatComponents> Trk::ElectronCombinedMaterialEffects::m_BHpolynomialMeans {}
private

Definition at line 78 of file ElectronCombinedMaterialEffects.h.

◆ m_BHpolynomialMeansHighX0

std::array<Polynomial, GSFConstants::maxNumberofMatComponents> Trk::ElectronCombinedMaterialEffects::m_BHpolynomialMeansHighX0 {}
private

Definition at line 84 of file ElectronCombinedMaterialEffects.h.

◆ m_BHpolynomialVariances

std::array<Polynomial, GSFConstants::maxNumberofMatComponents> Trk::ElectronCombinedMaterialEffects::m_BHpolynomialVariances {}
private

Definition at line 80 of file ElectronCombinedMaterialEffects.h.

◆ m_BHpolynomialVariancesHighX0

std::array<Polynomial, GSFConstants::maxNumberofMatComponents> Trk::ElectronCombinedMaterialEffects::m_BHpolynomialVariancesHighX0 {}
private

Definition at line 86 of file ElectronCombinedMaterialEffects.h.

◆ m_BHpolynomialWeights

std::array<Polynomial, GSFConstants::maxNumberofMatComponents> Trk::ElectronCombinedMaterialEffects::m_BHpolynomialWeights {}
private

Definition at line 76 of file ElectronCombinedMaterialEffects.h.

◆ m_BHpolynomialWeightsHighX0

std::array<Polynomial, GSFConstants::maxNumberofMatComponents> Trk::ElectronCombinedMaterialEffects::m_BHpolynomialWeightsHighX0 {}
private

Definition at line 82 of file ElectronCombinedMaterialEffects.h.

◆ m_BHtransformationCode

int Trk::ElectronCombinedMaterialEffects::m_BHtransformationCode {}
private

Definition at line 71 of file ElectronCombinedMaterialEffects.h.

◆ m_BHtransformationCodeHighX0

int Trk::ElectronCombinedMaterialEffects::m_BHtransformationCodeHighX0 {}
private

Definition at line 73 of file ElectronCombinedMaterialEffects.h.


The documentation for this class was generated from the following files:
Trk::ElectronCombinedMaterialEffects::m_BHpolynomialWeightsHighX0
std::array< Polynomial, GSFConstants::maxNumberofMatComponents > m_BHpolynomialWeightsHighX0
Definition: ElectronCombinedMaterialEffects.h:82
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:254
GsfMaterial::Combined::weights
std::array< double, GSFConstants::maxNumberofMatComponents > weights
Definition: GsfMaterial.h:49
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
GsfMaterial::Scattering
Helper struct for multiple scattering effects single component description.
Definition: GsfMaterial.h:36
Trk::ElectronCombinedMaterialEffects::BetheHeitler
void BetheHeitler(GsfMaterial::EnergyLoss &cache, const ComponentParameters &componentParameters, const MaterialProperties &materialProperties, double pathLenght, PropDirection direction=anyDirection) const
Definition: ElectronCombinedMaterialEffects.cxx:385
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
GsfMaterial::EnergyLoss::elements
std::array< element, GSFConstants::maxNumberofMatComponents > elements
Definition: GsfMaterial.h:30
GsfMaterial::EnergyLoss
Helper struct for energy loss effects, multicomponent description.
Definition: GsfMaterial.h:23
Trk::ElectronCombinedMaterialEffects::m_BHtransformationCode
int m_BHtransformationCode
Definition: ElectronCombinedMaterialEffects.h:71
Trk::oppositeMomentum
@ oppositeMomentum
Definition: PropDirection.h:21
Trk::ElectronCombinedMaterialEffects::m_BHnumberOfComponents
int m_BHnumberOfComponents
Definition: ElectronCombinedMaterialEffects.h:70
GsfMaterial::Combined::deltaCovariances
std::array< AmgSymMatrix(5), GSFConstants::maxNumberofMatComponents > deltaCovariances
Definition: GsfMaterial.h:56
Trk::alongMomentum
@ alongMomentum
Definition: PropDirection.h:20
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
GsfMaterial::Scattering::deltaPhiCov
double deltaPhiCov
Definition: GsfMaterial.h:38
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
Trk::ElectronCombinedMaterialEffects::MixtureParameters
std::array< ComponentValues, GSFConstants::maxNumberofMatComponents > MixtureParameters
Definition: ElectronCombinedMaterialEffects.h:36
Trk::AmgSymMatrix
AmgSymMatrix(5) &GXFTrackState
Definition: GXFTrackState.h:156
GsfMaterial::Combined::numEntries
size_t numEntries
Definition: GsfMaterial.h:58
GSFConstants::maxNumberofMatComponents
constexpr int8_t maxNumberofMatComponents
Maximum number of Gaussian components for the material effects description.
Definition: GsfConstants.h:50
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::ElectronCombinedMaterialEffects::m_BHpolynomialVariances
std::array< Polynomial, GSFConstants::maxNumberofMatComponents > m_BHpolynomialVariances
Definition: ElectronCombinedMaterialEffects.h:80
Trk::ElectronCombinedMaterialEffects::m_BHpolynomialMeansHighX0
std::array< Polynomial, GSFConstants::maxNumberofMatComponents > m_BHpolynomialMeansHighX0
Definition: ElectronCombinedMaterialEffects.h:84
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
GsfMaterial::Scattering::deltaThetaCov
double deltaThetaCov
Definition: GsfMaterial.h:37
hist_file_dump.f
f
Definition: hist_file_dump.py:135
Trk::ParametersBase
Definition: ParametersBase.h:55
inRange
bool inRange(const double *boundaries, const double value, const double tolerance=0.02)
Definition: LArSCIdVsIdTest.cxx:5
GsfMaterial::Combined::deltaPs
std::array< double, GSFConstants::maxNumberofMatComponents > deltaPs
Definition: GsfMaterial.h:50
Trk::ElectronCombinedMaterialEffects::m_BHtransformationCodeHighX0
int m_BHtransformationCodeHighX0
Definition: ElectronCombinedMaterialEffects.h:73
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
GSFConstants::polynomialCoefficients
constexpr int8_t polynomialCoefficients
Number of coefficients for the polynomials, parametrizing the mean,variace, weights of the Gaussian c...
Definition: GsfConstants.h:54
Trk::ParametersBase::momentum
const Amg::Vector3D & momentum() const
Access method for the momentum.
Trk::ElectronCombinedMaterialEffects::m_BHnumberOfComponentsHighX0
int m_BHnumberOfComponentsHighX0
Definition: ElectronCombinedMaterialEffects.h:72
Trk::ElectronCombinedMaterialEffects::m_BHpolynomialVariancesHighX0
std::array< Polynomial, GSFConstants::maxNumberofMatComponents > m_BHpolynomialVariancesHighX0
Definition: ElectronCombinedMaterialEffects.h:86
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
GsfMaterial::EnergyLoss::numElements
int numElements
Definition: GsfMaterial.h:31
Trk::ElectronCombinedMaterialEffects::m_BHpolynomialWeights
std::array< Polynomial, GSFConstants::maxNumberofMatComponents > m_BHpolynomialWeights
Definition: ElectronCombinedMaterialEffects.h:76
compute_lumi.fin
fin
Definition: compute_lumi.py:19
Trk::ElectronCombinedMaterialEffects::m_BHpolynomialMeans
std::array< Polynomial, GSFConstants::maxNumberofMatComponents > m_BHpolynomialMeans
Definition: ElectronCombinedMaterialEffects.h:78
Trk::ComponentParameters::params
std::unique_ptr< Trk::TrackParameters > params
Definition: ComponentParameters.h:23