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)
 
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_BHnumberOfComponentsHighX0 {}
 
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 36 of file ElectronCombinedMaterialEffects.h.

Constructor & Destructor Documentation

◆ ElectronCombinedMaterialEffects()

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

Definition at line 221 of file ElectronCombinedMaterialEffects.cxx.

223  {
224  // Read the std polynomials
225  {
226  const std::string resolvedFileName =
227  PathResolver::find_file(parameterisationFileName, "DATAPATH");
228  if (resolvedFileName.empty()) {
229  std::ostringstream ss;
230  ss << "Parameterisation file : " << parameterisationFileName
231  << " not found";
232  throw std::logic_error(ss.str());
233  }
234 
235  readPolys readin = fillFromFile(resolvedFileName);
236  m_BHnumberOfComponents = readin.numberOfComponents;
237  m_BHpolynomialWeights = readin.weights;
238  m_BHpolynomialMeans = readin.means;
239  m_BHpolynomialVariances = readin.variances;
240  }
241  // Read the high X0 polynomials
242  {
243  const std::string resolvedFileName =
244  PathResolver::find_file(parameterisationFileNameHighX0, "DATAPATH");
245  if (resolvedFileName.empty()) {
246  std::ostringstream ss;
247  ss << "Parameterisation file : " << parameterisationFileNameHighX0
248  << " not found";
249  throw std::logic_error(ss.str());
250  }
251  readPolys readin = fillFromFile(resolvedFileName);
252  m_BHnumberOfComponentsHighX0 = readin.numberOfComponents;
253  m_BHpolynomialWeightsHighX0 = readin.weights;
254  m_BHpolynomialMeansHighX0 = readin.means;
255  m_BHpolynomialVariancesHighX0 = readin.variances;
256  }
258  std::ostringstream ss;
259  ss << " numberOfComponentsHighX0 != numberOfComponents";
260  throw std::logic_error(ss.str());
261  }
262 }

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 325 of file ElectronCombinedMaterialEffects.cxx.

331 {
332  cache.numElements = 0;
333 
334  const Trk::TrackParameters* trackParameters = componentParameters.params.get();
335  const Amg::Vector3D& globalMomentum = trackParameters->momentum();
336 
337  const double radiationLength = materialProperties.x0();
338  const double momentum = globalMomentum.mag();
339  double pathlengthInX0 = pathLength / radiationLength;
340 
341  if (pathlengthInX0 < s_singleGaussianRange) {
342  cache.elements[0] = { 1., 0., 0. };
343  cache.numElements = 1;
344  return;
345  }
346 
347  // If the amount of material is between 0.0001 and 0.01 in x0 return the gaussian
348  // approximation to the Bethe-Heitler distribution
349  if (pathlengthInX0 < s_lowerRange) {
350  const double meanZ = std::exp(-1. * pathlengthInX0);
351  const double sign = (direction == Trk::oppositeMomentum) ? 1. : -1.;
352  const double varZ =
353  std::exp(-1. * pathlengthInX0 * std::log(3.) / std::log(2.)) -
354  std::exp(-2. * pathlengthInX0);
355  double deltaP(0.);
356  double varQoverP(0.);
357  if (direction == Trk::alongMomentum) {
358  deltaP = sign * momentum * (1. - meanZ);
359  varQoverP = 1. / (meanZ * meanZ * momentum * momentum) * varZ;
360  } else {
361  deltaP = sign * momentum * (1. / meanZ - 1.);
362  varQoverP = varZ / (momentum * momentum);
363  }
364  cache.elements[0] = { 1., deltaP, varQoverP };
365  cache.numElements = 1;
366  return;
367  }
368  //clip to upper range
369  if (pathlengthInX0 > s_upperRange) {
370  pathlengthInX0 = s_upperRange;
371  }
372 
373  // Get proper mixture parameters
374  MixtureParameters mixture;
375  if (pathlengthInX0 > s_xOverRange) {
376  mixture = getTransformedMixtureParameters(m_BHpolynomialWeightsHighX0,
379  pathlengthInX0,
381  } else {
382  mixture = getTransformedMixtureParameters(m_BHpolynomialWeights,
385  pathlengthInX0,
387  }
388  // Correct the mixture
389  correctWeights(mixture, m_BHnumberOfComponents);
390  int componentIndex = 0;
391  double weightToBeRemoved(0.);
392  int componentWithHighestMean(0);
393 
394  for (; componentIndex < m_BHnumberOfComponents; ++componentIndex) {
395  if (mixture[componentIndex].mean > mixture[componentWithHighestMean].mean) {
396  componentWithHighestMean = componentIndex;
397  }
398  if (mixture[componentIndex].mean >= s_componentMeanCut) {
399  continue;
400  }
401  weightToBeRemoved += mixture[componentIndex].weight;
402  }
403  // Fill the cache to be returned
404  componentIndex = 0;
405  for (; componentIndex < m_BHnumberOfComponents; ++componentIndex) {
406  double varianceInverseMomentum = 0;
407 
408  // This is not mathematically correct but it does stabilize the GSF
409  if (mixture[componentIndex].mean < s_componentMeanCut) {
410  continue;
411  }
412 
413  double weight = mixture[componentIndex].weight;
414  if (componentIndex == componentWithHighestMean) {
415  weight += weightToBeRemoved;
416  }
417 
418  double deltaP(0.);
419  if (direction == alongMomentum) { // For forward propagation
420  deltaP = momentum * (mixture[componentIndex].mean - 1.);
421  const double f = 1. / (momentum * mixture[componentIndex].mean);
422  varianceInverseMomentum = f * f * mixture[componentIndex].variance;
423  } else { // For backwards propagation
424  deltaP = momentum * (1. / mixture[componentIndex].mean - 1.);
425  varianceInverseMomentum = mixture[componentIndex].variance / (momentum * momentum);
426  }
427 
428  // set in the cache and increase the elements
429  cache.elements[cache.numElements] = { weight,
430  deltaP,
431  varianceInverseMomentum };
432  ++cache.numElements;
433  } // end for loop over all components
434 }

◆ 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 265 of file ElectronCombinedMaterialEffects.cxx.

271 {
272  const AmgSymMatrix(5)* measuredCov = componentParameters.params->covariance();
273  /*
274  * 1. Retrieve multiple scattering corrections
275  */
276  GsfMaterial::Scattering cache_multipleScatter;
277  scattering(cache_multipleScatter, componentParameters, materialProperties, pathLength);
278  /*
279  * 2. Retrieve energy loss corrections
280  * This for electrons comes from the Bethe-Heitler
281  */
282  GsfMaterial::EnergyLoss cache_energyLoss;
283  this->BetheHeitler(cache_energyLoss,
284  componentParameters,
285  materialProperties,
286  pathLength,
287  direction);
288  // Protect if there are no new energy loss
289  // components.
290  if (cache_energyLoss.numElements == 0) {
291  cache_energyLoss.elements[0] = { 1, 0, 0 };
292  cache_energyLoss.numElements = 1;
293  }
294  /*
295  * 3. Combine the multiple scattering with each of the energy loss components
296  */
297  cache.numEntries = 0; //cahce to be filled
298  for (int i = 0; i < cache_energyLoss.numElements; ++i) {
299  cache.weights[i] = cache_energyLoss.elements[i].weight;
300  cache.deltaPs[i] = cache_energyLoss.elements[i].deltaP;
301  if (measuredCov) {
302  // Create the covariance
303  const double covPhi = cache_multipleScatter.deltaPhiCov;
304  const double covTheta = cache_multipleScatter.deltaThetaCov;
305  const double covQoverP = cache_energyLoss.elements[i].deltaQOvePCov;
306  //Here set the "delta" for the covariance
307  //due to material effects
308  cache.covariances[i] << 0, 0, 0, 0, 0, // 5
309  0, 0, 0, 0, 0, // 10
310  0, 0, covPhi, 0, 0, // 15
311  0, 0, 0, covTheta, 0, // 20
312  0, 0, 0, 0, covQoverP;
313  } else {
314  cache.covariances[i].setZero();
315  }
316  ++cache.numEntries;
317  } // end for loop over energy loss components
318 }

Member Data Documentation

◆ m_BHnumberOfComponents

int Trk::ElectronCombinedMaterialEffects::m_BHnumberOfComponents {}
private

Definition at line 58 of file ElectronCombinedMaterialEffects.h.

◆ m_BHnumberOfComponentsHighX0

int Trk::ElectronCombinedMaterialEffects::m_BHnumberOfComponentsHighX0 {}
private

Definition at line 59 of file ElectronCombinedMaterialEffects.h.

◆ m_BHpolynomialMeans

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

Definition at line 62 of file ElectronCombinedMaterialEffects.h.

◆ m_BHpolynomialMeansHighX0

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

Definition at line 65 of file ElectronCombinedMaterialEffects.h.

◆ m_BHpolynomialVariances

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

Definition at line 63 of file ElectronCombinedMaterialEffects.h.

◆ m_BHpolynomialVariancesHighX0

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

Definition at line 66 of file ElectronCombinedMaterialEffects.h.

◆ m_BHpolynomialWeights

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

Definition at line 61 of file ElectronCombinedMaterialEffects.h.

◆ m_BHpolynomialWeightsHighX0

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

Definition at line 64 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:64
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:51
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:37
Trk::ElectronCombinedMaterialEffects::BetheHeitler
void BetheHeitler(GsfMaterial::EnergyLoss &cache, const ComponentParameters &componentParameters, const MaterialProperties &materialProperties, double pathLenght, PropDirection direction=anyDirection) const
Definition: ElectronCombinedMaterialEffects.cxx:325
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::oppositeMomentum
@ oppositeMomentum
Definition: PropDirection.h:21
Trk::ElectronCombinedMaterialEffects::m_BHnumberOfComponents
int m_BHnumberOfComponents
Definition: ElectronCombinedMaterialEffects.h:58
Trk::alongMomentum
@ alongMomentum
Definition: PropDirection.h:20
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
GsfMaterial::Scattering::deltaPhiCov
double deltaPhiCov
Definition: GsfMaterial.h:39
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:190
Trk::ElectronCombinedMaterialEffects::MixtureParameters
std::array< ComponentValues, GSFConstants::maxNumberofMatComponents > MixtureParameters
Definition: ElectronCombinedMaterialEffects.h:35
Trk::AmgSymMatrix
AmgSymMatrix(5) &GXFTrackState
Definition: GXFTrackState.h:156
GsfMaterial::Combined::numEntries
size_t numEntries
Definition: GsfMaterial.h:62
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:63
Trk::ElectronCombinedMaterialEffects::m_BHpolynomialMeansHighX0
std::array< Polynomial, GSFConstants::maxNumberofMatComponents > m_BHpolynomialMeansHighX0
Definition: ElectronCombinedMaterialEffects.h:65
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
GsfMaterial::Scattering::deltaThetaCov
double deltaThetaCov
Definition: GsfMaterial.h:38
hist_file_dump.f
f
Definition: hist_file_dump.py:140
Trk::ParametersBase
Definition: ParametersBase.h:55
GsfMaterial::Combined::deltaPs
std::array< double, GSFConstants::maxNumberofMatComponents > deltaPs
Definition: GsfMaterial.h:53
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::ParametersBase::momentum
const Amg::Vector3D & momentum() const
Access method for the momentum.
Trk::ElectronCombinedMaterialEffects::m_BHnumberOfComponentsHighX0
int m_BHnumberOfComponentsHighX0
Definition: ElectronCombinedMaterialEffects.h:59
Trk::ElectronCombinedMaterialEffects::m_BHpolynomialVariancesHighX0
std::array< Polynomial, GSFConstants::maxNumberofMatComponents > m_BHpolynomialVariancesHighX0
Definition: ElectronCombinedMaterialEffects.h:66
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
Definition: PathResolver.cxx:183
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
GsfMaterial::Combined::covariances
std::array< AmgSymMatrix(5), GSFConstants::maxNumberofMatComponents > covariances
Definition: GsfMaterial.h:60
GsfMaterial::EnergyLoss::numElements
int numElements
Definition: GsfMaterial.h:32
Trk::ElectronCombinedMaterialEffects::m_BHpolynomialWeights
std::array< Polynomial, GSFConstants::maxNumberofMatComponents > m_BHpolynomialWeights
Definition: ElectronCombinedMaterialEffects.h:61
Trk::ElectronCombinedMaterialEffects::m_BHpolynomialMeans
std::array< Polynomial, GSFConstants::maxNumberofMatComponents > m_BHpolynomialMeans
Definition: ElectronCombinedMaterialEffects.h:62
Trk::ComponentParameters::params
std::unique_ptr< Trk::TrackParameters > params
Definition: ComponentParameters.h:23