CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
GsfBetheHeitlerUpdator Class Referencefinal

#include <GsfBetheHeitlerUpdator.h>

Inheritance diagram for GsfBetheHeitlerUpdator:
GsfMaterialEffectsUpdator

Classes

struct  GSContainer
 
class  Polynomial
 

Public Types

enum  CorrectionFlag { NoCorrection = 0, MeanCorrection = 1, FullCorrection = 2 }
 
- Public Types inherited from GsfMaterialEffectsUpdator
typedef materialEffect::Covariance Covariance
 
typedef materialEffect::CovIndex CovIndex
 
typedef materialEffect::Effect Effect
 

Public Member Functions

GsfBetheHeitlerUpdatorclone () const override
 
 GsfBetheHeitlerUpdator (const std::string fileName, const int correctionFlag)
 constructor with explicit filename and correction flag More...
 
- Public Member Functions inherited from GsfMaterialEffectsUpdator
 GsfMaterialEffectsUpdator (float mass, uint32_t is)
 
float mass () const
 
size_t size () const
 
virtual TrajectoryStateOnSurface updateState (const TrajectoryStateOnSurface &TSoS, const PropagationDirection propDir) const
 
virtual ~GsfMaterialEffectsUpdator ()
 

Private Member Functions

void compute (const TrajectoryStateOnSurface &, const PropagationDirection, Effect[]) const override
 Computation: generates vectors of weights, means and standard deviations. More...
 
float correctedFirstMean (const float, const GSContainer &) const
 Correction for mean of component 1. More...
 
float correctedFirstVar (const float, const GSContainer &) const
 Correction for variance of component 1. More...
 
void correctWeights (GSContainer &) const
 Correction for weight of component 1. More...
 
void getMixtureParameters (const float, GSContainer &) const
 Filling of mixture (in terms of z=E/E0) More...
 
void readParameters (const std::string)
 Read parametrization from file. More...
 
Polynomial readPolynomial (std::ifstream &, const unsigned int)
 Read coefficients of one polynomial from file. More...
 

Private Attributes

int theCorrectionFlag
 values to be transformed by logistic / exp. function? More...
 
int theNrComponents
 
Polynomial thePolyMeans [MaxSize]
 parametrisation of weight for each component More...
 
Polynomial thePolyVars [MaxSize]
 parametrisation of mean for each componentP More...
 
Polynomial thePolyWeights [MaxSize]
 correction of 1st or 1st&2nd moments More...
 
int theTransformationCode
 number of components used for parameterisation More...
 

Static Private Attributes

static constexpr int MaxOrder = 6
 
static constexpr int MaxSize = 6
 

Additional Inherited Members

- Protected Member Functions inherited from GsfMaterialEffectsUpdator
void resize (size_t is)
 

Detailed Description

Description of electron energy loss according to Bethe-Heitler as a sum of Gaussian components. The weights and parameters of the Gaussians as a function of x/X0 are parametrized as polynomials. The coefficients of these polynomials are read from a file at construction time.

Definition at line 20 of file GsfBetheHeitlerUpdator.h.

Member Enumeration Documentation

◆ CorrectionFlag

Enumerator
NoCorrection 
MeanCorrection 
FullCorrection 

Definition at line 52 of file GsfBetheHeitlerUpdator.h.

Constructor & Destructor Documentation

◆ GsfBetheHeitlerUpdator()

GsfBetheHeitlerUpdator::GsfBetheHeitlerUpdator ( const std::string  fileName,
const int  correctionFlag 
)

constructor with explicit filename and correction flag

Definition at line 53 of file GsfBetheHeitlerUpdator.cc.

54  : GsfMaterialEffectsUpdator(0.000511, 6), theNrComponents(0), theCorrectionFlag(correctionFlag) {
55  if (theCorrectionFlag == 1)
56  edm::LogInfo("GsfBetheHeitlerUpdator") << "1st moment of mixture will be corrected";
57  if (theCorrectionFlag >= 2)
58  edm::LogInfo("GsfBetheHeitlerUpdator") << "1st and 2nd moments of mixture will be corrected";
59 
61  assert(theNrComponents <= 6);
63 }

References cms::cuda::assert(), MillePedeFileConverter_cfg::fileName, readParameters(), GsfMaterialEffectsUpdator::resize(), theCorrectionFlag, and theNrComponents.

Referenced by clone().

Member Function Documentation

◆ clone()

GsfBetheHeitlerUpdator* GsfBetheHeitlerUpdator::clone ( void  ) const
inlineoverridevirtual

Implements GsfMaterialEffectsUpdator.

Definition at line 55 of file GsfBetheHeitlerUpdator.h.

55 { return new GsfBetheHeitlerUpdator(*this); }

References GsfBetheHeitlerUpdator().

◆ compute()

void GsfBetheHeitlerUpdator::compute ( const TrajectoryStateOnSurface TSoS,
const PropagationDirection  propDir,
Effect  effects[] 
) const
overrideprivatevirtual

Computation: generates vectors of weights, means and standard deviations.

Implements GsfMaterialEffectsUpdator.

Definition at line 96 of file GsfBetheHeitlerUpdator.cc.

98  {
99  //
100  // Get surface and check presence of medium properties
101  //
102  const Surface& surface = TSoS.surface();
103  //
104  // calculate components: first check associated material constants
105  //
106  float rl(0.f);
107  float p(0.f);
108  if (surface.mediumProperties().isValid()) {
109  LocalVector pvec = TSoS.localMomentum();
110  p = pvec.mag();
111  rl = surface.mediumProperties().radLen() / fabs(pvec.z()) * p;
112  }
113  //
114  // produce multi-state only in case of x/X0>0
115  //
116  if (rl > 0.0001f) {
117  //
118  // limit x/x0 to valid range for parametrisation
119  // should be done in a more elegant way ...
120  //
121  if (rl < 0.01f)
122  rl = 0.01f;
123  if (rl > 0.20f)
124  rl = 0.20f;
125 
126  float mixtureData[3][theNrComponents];
127  GSContainer mixture{mixtureData[0], mixtureData[1], mixtureData[2]};
128 
129  getMixtureParameters(rl, mixture);
130  correctWeights(mixture);
131  if (theCorrectionFlag >= 1)
132  mixture.second[0] = correctedFirstMean(rl, mixture);
133  if (theCorrectionFlag >= 2)
134  mixture.third[0] = correctedFirstVar(rl, mixture);
135 
136  for (int i = 0; i < theNrComponents; i++) {
137  float varPinv;
138  effects[i].weight *= mixture.first[i];
139  if (propDir == alongMomentum) {
140  //
141  // for forward propagation: calculate in p (linear in 1/z=p_inside/p_outside),
142  // then convert sig(p) to sig(1/p).
143  //
144  effects[i].deltaP += p * (mixture.second[i] - 1.f);
145  // float f = 1./p/mixture.second[i]/mixture.second[i];
146  // patch to ensure consistency between for- and backward propagation
147  float f = 1.f / (p * mixture.second[i]);
148  varPinv = f * f * mixture.third[i];
149  } else {
150  //
151  // for backward propagation: delta(1/p) is linear in z=p_outside/p_inside
152  // convert to obtain equivalent delta(p)
153  //
154  effects[i].deltaP += p * (1.f / mixture.second[i] - 1.f);
155  varPinv = mixture.third[i] / (p * p);
156  }
157  using namespace materialEffect;
158  effects[i].deltaCov[elos] += varPinv;
159  }
160  }
161 }

References alongMomentum, correctedFirstMean(), correctedFirstVar(), correctWeights(), materialEffect::Effect::deltaCov, materialEffect::Effect::deltaP, materialEffect::elos, f, getMixtureParameters(), mps_fire::i, MediumProperties::isValid(), TrajectoryStateOnSurface::localMomentum(), PV3DBase< T, PVType, FrameType >::mag(), Surface::mediumProperties(), AlCaHLTBitMon_ParallelJobs::p, MediumProperties::radLen(), TrajectoryStateOnSurface::surface(), theCorrectionFlag, theNrComponents, materialEffect::Effect::weight, and PV3DBase< T, PVType, FrameType >::z().

◆ correctedFirstMean()

float GsfBetheHeitlerUpdator::correctedFirstMean ( const float  rl,
const GSContainer mixture 
) const
private

Correction for mean of component 1.

Definition at line 207 of file GsfBetheHeitlerUpdator.cc.

207  {
208  //
209  // calculate difference true mean - weighted sum
210  //
211  float mean = BetheHeitlerMean(rl);
212  for (int i = 1; i < theNrComponents; i++)
213  mean -= mixture.first[i] * mixture.second[i];
214  //
215  // return corrected mean for first component
216  //
217  return std::max(std::min(mean / mixture.first[0], 1.f), 0.f);
218 }

References GsfBetheHeitlerUpdator::GSContainer::first, mps_fire::i, SiStripPI::max, SiStripPI::mean, min(), GsfBetheHeitlerUpdator::GSContainer::second, and theNrComponents.

Referenced by compute().

◆ correctedFirstVar()

float GsfBetheHeitlerUpdator::correctedFirstVar ( const float  rl,
const GSContainer mixture 
) const
private

Correction for variance of component 1.

Definition at line 222 of file GsfBetheHeitlerUpdator.cc.

222  {
223  //
224  // calculate difference true variance - weighted sum
225  //
226  float var = BetheHeitlerVariance(rl) + BetheHeitlerMean(rl) * BetheHeitlerMean(rl) -
227  mixture.first[0] * mixture.second[0] * mixture.second[0];
228  for (int i = 1; i < theNrComponents; i++)
229  var -= mixture.first[i] * (mixture.second[i] * mixture.second[i] + mixture.third[i]);
230  //
231  // return corrected variance for first component
232  //
233  return std::max(var / mixture.first[0], 0.f);
234 }

References GsfBetheHeitlerUpdator::GSContainer::first, mps_fire::i, SiStripPI::max, GsfBetheHeitlerUpdator::GSContainer::second, theNrComponents, GsfBetheHeitlerUpdator::GSContainer::third, and trigObjTnPSource_cfi::var.

Referenced by compute().

◆ correctWeights()

void GsfBetheHeitlerUpdator::correctWeights ( GSContainer mixture) const
private

Correction for weight of component 1.

Definition at line 190 of file GsfBetheHeitlerUpdator.cc.

190  {
191  //
192  // get sum of weights
193  //
194  float wsum(0);
195  for (int i = 0; i < theNrComponents; i++)
196  wsum += mixture.first[i];
197  //
198  // rescale to obtain 1
199  //
200  wsum = 1.f / wsum;
201  for (int i = 0; i < theNrComponents; i++)
202  mixture.first[i] *= wsum;
203 }

References GsfBetheHeitlerUpdator::GSContainer::first, cms::cuda::for(), mps_fire::i, and theNrComponents.

Referenced by compute().

◆ getMixtureParameters()

void GsfBetheHeitlerUpdator::getMixtureParameters ( const float  rl,
GSContainer mixture 
) const
private

Filling of mixture (in terms of z=E/E0)

Definition at line 165 of file GsfBetheHeitlerUpdator.cc.

165  {
167  for (int i = 0; i < theNrComponents; i++) {
168  weight[i] = thePolyWeights[i](rl);
169  z[i] = thePolyMeans[i](rl);
170  vz[i] = thePolyVars[i](rl);
171  }
173  for (int i = 0; i < theNrComponents; i++) {
174  mixture.first[i] = logisticFunction(weight[i]);
175  mixture.second[i] = logisticFunction(z[i]);
176  mixture.third[i] = unsafe_expf<4>(vz[i]);
177  ;
178  }
179  else // theTransformationCode
180  for (int i = 0; i < theNrComponents; i++) {
181  mixture.first[i] = weight[i];
182  mixture.second[i] = z[i];
183  mixture.third[i] = vz[i] * vz[i];
184  }
185 }

References GsfBetheHeitlerUpdator::GSContainer::first, mps_fire::i, GsfBetheHeitlerUpdator::GSContainer::second, theNrComponents, thePolyMeans, thePolyVars, thePolyWeights, theTransformationCode, GsfBetheHeitlerUpdator::GSContainer::third, and z.

Referenced by compute().

◆ readParameters()

void GsfBetheHeitlerUpdator::readParameters ( const std::string  fileName)
private

Read parametrization from file.

Definition at line 65 of file GsfBetheHeitlerUpdator.cc.

65  {
66  std::string name = "TrackingTools/GsfTracking/data/";
67  name += fileName;
68 
69  edm::FileInPath parFile(name);
70  edm::LogInfo("GsfBetheHeitlerUpdator") << "Reading GSF parameterization "
71  << "of Bethe-Heitler energy loss from " << parFile.fullPath();
72  std::ifstream ifs(parFile.fullPath().c_str());
73 
74  ifs >> theNrComponents;
75  int orderP;
76  ifs >> orderP;
77  ifs >> theTransformationCode;
78 
79  assert(orderP < MaxOrder);
80 
81  for (int ic = 0; ic != theNrComponents; ++ic) {
82  thePolyWeights[ic] = readPolynomial(ifs, orderP);
83  thePolyMeans[ic] = readPolynomial(ifs, orderP);
84  thePolyVars[ic] = readPolynomial(ifs, orderP);
85  }
86 }

References cms::cuda::assert(), MillePedeFileConverter_cfg::fileName, edm::FileInPath::fullPath(), MaxOrder, Skims_PA_cff::name, readPolynomial(), AlCaHLTBitMon_QueryRunRegistry::string, theNrComponents, thePolyMeans, thePolyVars, thePolyWeights, and theTransformationCode.

Referenced by GsfBetheHeitlerUpdator().

◆ readPolynomial()

GsfBetheHeitlerUpdator::Polynomial GsfBetheHeitlerUpdator::readPolynomial ( std::ifstream &  aStream,
const unsigned int  order 
)
private

Read coefficients of one polynomial from file.

Definition at line 88 of file GsfBetheHeitlerUpdator.cc.

89  {
90  float coeffs[order + 1];
91  for (unsigned int i = 0; i < (order + 1); ++i)
92  aStream >> coeffs[i];
93  return Polynomial(coeffs, order + 1);
94 }

References mps_fire::i, and eventshapeDQM_cfi::order.

Referenced by readParameters().

Member Data Documentation

◆ MaxOrder

constexpr int GsfBetheHeitlerUpdator::MaxOrder = 6
staticconstexprprivate

Definition at line 23 of file GsfBetheHeitlerUpdator.h.

Referenced by readParameters().

◆ MaxSize

constexpr int GsfBetheHeitlerUpdator::MaxSize = 6
staticconstexprprivate

Definition at line 22 of file GsfBetheHeitlerUpdator.h.

◆ theCorrectionFlag

int GsfBetheHeitlerUpdator::theCorrectionFlag
private

values to be transformed by logistic / exp. function?

Definition at line 87 of file GsfBetheHeitlerUpdator.h.

Referenced by compute(), and GsfBetheHeitlerUpdator().

◆ theNrComponents

int GsfBetheHeitlerUpdator::theNrComponents
private

◆ thePolyMeans

Polynomial GsfBetheHeitlerUpdator::thePolyMeans[MaxSize]
private

parametrisation of weight for each component

Definition at line 90 of file GsfBetheHeitlerUpdator.h.

Referenced by getMixtureParameters(), and readParameters().

◆ thePolyVars

Polynomial GsfBetheHeitlerUpdator::thePolyVars[MaxSize]
private

parametrisation of mean for each componentP

Definition at line 91 of file GsfBetheHeitlerUpdator.h.

Referenced by getMixtureParameters(), and readParameters().

◆ thePolyWeights

Polynomial GsfBetheHeitlerUpdator::thePolyWeights[MaxSize]
private

correction of 1st or 1st&2nd moments

Definition at line 89 of file GsfBetheHeitlerUpdator.h.

Referenced by getMixtureParameters(), and readParameters().

◆ theTransformationCode

int GsfBetheHeitlerUpdator::theTransformationCode
private

number of components used for parameterisation

Definition at line 86 of file GsfBetheHeitlerUpdator.h.

Referenced by getMixtureParameters(), and readParameters().

Vector3DBase< float, LocalTag >
GsfBetheHeitlerUpdator::theNrComponents
int theNrComponents
Definition: GsfBetheHeitlerUpdator.h:85
TrajectoryStateOnSurface::localMomentum
LocalVector localMomentum() const
Definition: TrajectoryStateOnSurface.h:75
mps_fire.i
i
Definition: mps_fire.py:428
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
GsfBetheHeitlerUpdator::correctedFirstMean
float correctedFirstMean(const float, const GSContainer &) const
Correction for mean of component 1.
Definition: GsfBetheHeitlerUpdator.cc:207
min
T min(T a, T b)
Definition: MathUtil.h:58
MediumProperties::radLen
float radLen() const
Definition: MediumProperties.h:20
GsfBetheHeitlerUpdator::correctWeights
void correctWeights(GSContainer &) const
Correction for weight of component 1.
Definition: GsfBetheHeitlerUpdator.cc:190
cms::cuda::assert
assert(be >=bs)
Surface
Definition: Surface.h:36
materialEffect::elos
Definition: MaterialEffectsUpdator.h:19
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
Surface::mediumProperties
const MediumProperties & mediumProperties() const
Definition: Surface.h:83
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
trigObjTnPSource_cfi.var
var
Definition: trigObjTnPSource_cfi.py:21
GsfBetheHeitlerUpdator::readPolynomial
Polynomial readPolynomial(std::ifstream &, const unsigned int)
Read coefficients of one polynomial from file.
Definition: GsfBetheHeitlerUpdator.cc:88
edm::FileInPath
Definition: FileInPath.h:61
materialEffect::Effect::deltaCov
Covariance deltaCov
Definition: MaterialEffectsUpdator.h:45
materialEffect::Effect::weight
float weight
Definition: MaterialEffectsUpdator.h:41
DDAxes::z
GsfBetheHeitlerUpdator::correctedFirstVar
float correctedFirstVar(const float, const GSContainer &) const
Correction for variance of component 1.
Definition: GsfBetheHeitlerUpdator.cc:222
materialEffect
Definition: MaterialEffectsUpdator.h:18
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
GsfBetheHeitlerUpdator::FullCorrection
Definition: GsfBetheHeitlerUpdator.h:52
materialEffect::Effect::deltaP
float deltaP
Definition: MaterialEffectsUpdator.h:43
GsfBetheHeitlerUpdator::readParameters
void readParameters(const std::string)
Read parametrization from file.
Definition: GsfBetheHeitlerUpdator.cc:65
GsfBetheHeitlerUpdator::thePolyMeans
Polynomial thePolyMeans[MaxSize]
parametrisation of weight for each component
Definition: GsfBetheHeitlerUpdator.h:90
eventshapeDQM_cfi.order
order
Definition: eventshapeDQM_cfi.py:8
GsfMaterialEffectsUpdator::resize
void resize(size_t is)
Definition: GsfMaterialEffectsUpdator.h:45
GsfBetheHeitlerUpdator::MeanCorrection
Definition: GsfBetheHeitlerUpdator.h:52
cms::cuda::for
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
Definition: HistoContainer.h:15
GsfBetheHeitlerUpdator::thePolyWeights
Polynomial thePolyWeights[MaxSize]
correction of 1st or 1st&2nd moments
Definition: GsfBetheHeitlerUpdator.h:89
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MediumProperties::isValid
bool isValid() const
Definition: MediumProperties.h:26
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
GsfBetheHeitlerUpdator::NoCorrection
Definition: GsfBetheHeitlerUpdator.h:52
GsfMaterialEffectsUpdator::GsfMaterialEffectsUpdator
GsfMaterialEffectsUpdator(float mass, uint32_t is)
Definition: GsfMaterialEffectsUpdator.h:23
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
TrajectoryStateOnSurface::surface
const SurfaceType & surface() const
Definition: TrajectoryStateOnSurface.h:78
GsfBetheHeitlerUpdator::theTransformationCode
int theTransformationCode
number of components used for parameterisation
Definition: GsfBetheHeitlerUpdator.h:86
GsfBetheHeitlerUpdator::thePolyVars
Polynomial thePolyVars[MaxSize]
parametrisation of mean for each componentP
Definition: GsfBetheHeitlerUpdator.h:91
GsfBetheHeitlerUpdator::getMixtureParameters
void getMixtureParameters(const float, GSContainer &) const
Filling of mixture (in terms of z=E/E0)
Definition: GsfBetheHeitlerUpdator.cc:165
GsfBetheHeitlerUpdator::MaxOrder
static constexpr int MaxOrder
Definition: GsfBetheHeitlerUpdator.h:23
GsfBetheHeitlerUpdator::GsfBetheHeitlerUpdator
GsfBetheHeitlerUpdator(const std::string fileName, const int correctionFlag)
constructor with explicit filename and correction flag
Definition: GsfBetheHeitlerUpdator.cc:53
alongMomentum
Definition: PropagationDirection.h:4
weight
Definition: weight.py:1
GsfBetheHeitlerUpdator::theCorrectionFlag
int theCorrectionFlag
values to be transformed by logistic / exp. function?
Definition: GsfBetheHeitlerUpdator.h:87