CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
GsfBetheHeitlerUpdator Class Reference

#include <GsfBetheHeitlerUpdator.h>

Inheritance diagram for GsfBetheHeitlerUpdator:
GsfMaterialEffectsUpdator

Classes

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

virtual GsfBetheHeitlerUpdatorclone () const
 
 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 Types

typedef Triplet< float, float,
float > 
GSContainer
 

Private Member Functions

virtual void compute (const TrajectoryStateOnSurface &, const PropagationDirection, Effect[]) const
 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 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 int MaxOrder =6
 
static 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 26 of file GsfBetheHeitlerUpdator.h.

Member Typedef Documentation

typedef Triplet<float,float,float> GsfBetheHeitlerUpdator::GSContainer
private

Definition at line 72 of file GsfBetheHeitlerUpdator.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

constructor with explicit filename and correction flag

Definition at line 46 of file GsfBetheHeitlerUpdator.cc.

References readParameters(), GsfMaterialEffectsUpdator::resize(), theCorrectionFlag, and theNrComponents.

Referenced by clone().

47  :
48  GsfMaterialEffectsUpdator(0.000511,6),
49  theNrComponents(0),
50  theCorrectionFlag(correctionFlag)
51 {
52  if ( theCorrectionFlag==1 )
53  edm::LogInfo("GsfBetheHeitlerUpdator") << "1st moment of mixture will be corrected";
54  if ( theCorrectionFlag>=2 )
55  edm::LogInfo("GsfBetheHeitlerUpdator")
56  << "1st and 2nd moments of mixture will be corrected";
57 
59  assert(theNrComponents<=6);
61 }
GsfMaterialEffectsUpdator(float mass, uint32_t is)
int theCorrectionFlag
values to be transformed by logistic / exp. function?
void readParameters(const std::string)
Read parametrization from file.

Member Function Documentation

virtual GsfBetheHeitlerUpdator* GsfBetheHeitlerUpdator::clone ( void  ) const
inlinevirtual

Implements GsfMaterialEffectsUpdator.

Definition at line 62 of file GsfBetheHeitlerUpdator.h.

References GsfBetheHeitlerUpdator().

63  {
64  return new GsfBetheHeitlerUpdator(*this);
65  }
GsfBetheHeitlerUpdator(const std::string fileName, const int correctionFlag)
constructor with explicit filename and correction flag
void GsfBetheHeitlerUpdator::compute ( const TrajectoryStateOnSurface TSoS,
const PropagationDirection  propDir,
Effect  effects[] 
) const
privatevirtual

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

Implements GsfMaterialEffectsUpdator.

Definition at line 97 of file GsfBetheHeitlerUpdator.cc.

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

99 {
100  //
101  // Get surface and check presence of medium properties
102  //
103  const Surface& surface = TSoS.surface();
104  //
105  // calculate components: first check associated material constants
106  //
107  float rl(0.f);
108  float p(0.f);
109  if ( surface.mediumProperties().isValid() ) {
110  LocalVector pvec = TSoS.localMomentum();
111  p = pvec.mag();
112  rl = surface.mediumProperties().radLen()/fabs(pvec.z())*p;
113  }
114  //
115  // produce multi-state only in case of x/X0>0
116  //
117  if ( rl>0.0001f ) {
118  //
119  // limit x/x0 to valid range for parametrisation
120  // should be done in a more elegant way ...
121  //
122  if ( rl<0.01f ) rl = 0.01f;
123  if ( rl>0.20f ) rl = 0.20f;
124 
125  #if __clang__
126  std::vector<GSContainer> mixtureHolder(theNrComponents);
127  GSContainer *mixture = mixtureHolder.data();
128  #else
129  GSContainer mixture[theNrComponents];
130  #endif
131  getMixtureParameters(rl,mixture);
132  correctWeights(mixture);
133  if ( theCorrectionFlag>=1 )
134  mixture[0].second = correctedFirstMean(rl,mixture);
135  if ( theCorrectionFlag>=2 )
136  mixture[0].third = correctedFirstVar(rl,mixture);
137 
138  for ( int i=0; i<theNrComponents; i++ ) {
139  float varPinv;
140  effects[i].weight*=mixture[i].first;
141  if ( propDir==alongMomentum ) {
142  //
143  // for forward propagation: calculate in p (linear in 1/z=p_inside/p_outside),
144  // then convert sig(p) to sig(1/p).
145  //
146  effects[i].deltaP += p*(mixture[i].second-1);
147  // float f = 1./p/mixture[i].second/mixture[i].second;
148  // patch to ensure consistency between for- and backward propagation
149  float f = 1./p/mixture[i].second;
150  varPinv = f*f*mixture[i].third;
151  }
152  else {
153  //
154  // for backward propagation: delta(1/p) is linear in z=p_outside/p_inside
155  // convert to obtain equivalent delta(p)
156  //
157  effects[i].deltaP += p*(1/mixture[i].second-1);
158  varPinv = mixture[i].third/p/p;
159  }
160  using namespace materialEffect;
161  effects[i].deltaCov[elos] += varPinv;
162  }
163  }
164 }
int i
Definition: DBlmapReader.cc:9
float radLen() const
LocalVector localMomentum() const
void getMixtureParameters(const float, GSContainer[]) const
Filling of mixture (in terms of z=E/E0)
const SurfaceType & surface() const
T mag() const
Definition: PV3DBase.h:67
T z() const
Definition: PV3DBase.h:64
void correctWeights(GSContainer[]) const
Correction for weight of component 1.
double f[11][100]
float correctedFirstVar(const float, const GSContainer[]) const
Correction for variance of component 1.
int theCorrectionFlag
values to be transformed by logistic / exp. function?
Triplet< float, float, float > GSContainer
bool isValid() const
const MediumProperties & mediumProperties() const
Definition: Surface.h:120
float correctedFirstMean(const float, const GSContainer[]) const
Correction for mean of component 1.
float GsfBetheHeitlerUpdator::correctedFirstMean ( const float  rl,
const GSContainer  mixture[] 
) const
private

Correction for mean of component 1.

Definition at line 212 of file GsfBetheHeitlerUpdator.cc.

References f, first, i, bookConverter::max, timingPdfMaker::mean, min(), edm::second(), and theNrComponents.

Referenced by compute().

214 {
215  //
216  // calculate difference true mean - weighted sum
217  //
218  float mean = BetheHeitlerMean(rl);
219  for ( int i=1; i<theNrComponents; i++ )
220  mean -= mixture[i].first*mixture[i].second;
221  //
222  // return corrected mean for first component
223  //
224  return std::max(std::min(mean/mixture[0].first,1.f),0.f);
225 }
int i
Definition: DBlmapReader.cc:9
U second(std::pair< T, U > const &p)
double f[11][100]
T min(T a, T b)
Definition: MathUtil.h:58
bool first
Definition: L1TdeRCT.cc:75
float GsfBetheHeitlerUpdator::correctedFirstVar ( const float  rl,
const GSContainer  mixture[] 
) const
private

Correction for variance of component 1.

Definition at line 230 of file GsfBetheHeitlerUpdator.cc.

References f, Triplet< T1, T2, T3 >::first, first, i, bookConverter::max, Triplet< T1, T2, T3 >::second, edm::second(), theNrComponents, and MetTreeProducer::var().

Referenced by compute().

232 {
233  //
234  // calculate difference true variance - weighted sum
235  //
236  float var = BetheHeitlerVariance(rl) +
237  BetheHeitlerMean(rl)*BetheHeitlerMean(rl) -
238  mixture[0].first*mixture[0].second*mixture[0].second;
239  for ( int i=1; i<theNrComponents; i++ )
240  var -= mixture[i].first*(mixture[i].second*mixture[i].second+mixture[i].third);
241  //
242  // return corrected variance for first component
243  //
244  return std::max(var/mixture[0].first,0.f);
245 }
int i
Definition: DBlmapReader.cc:9
U second(std::pair< T, U > const &p)
double f[11][100]
bool first
Definition: L1TdeRCT.cc:75
void GsfBetheHeitlerUpdator::correctWeights ( GSContainer  mixture[]) const
private

Correction for weight of component 1.

Definition at line 194 of file GsfBetheHeitlerUpdator.cc.

References first, i, and theNrComponents.

Referenced by compute().

195 {
196  //
197  // get sum of weights
198  //
199  float wsum(0);
200  for ( int i=0; i<theNrComponents; i++ )
201  wsum += mixture[i].first;
202  //
203  // rescale to obtain 1
204  //
205  for ( int i=0; i<theNrComponents; i++ )
206  mixture[i].first /= wsum;
207 }
int i
Definition: DBlmapReader.cc:9
bool first
Definition: L1TdeRCT.cc:75
void GsfBetheHeitlerUpdator::getMixtureParameters ( const float  rl,
GSContainer  mixture[] 
) const
private

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

Definition at line 169 of file GsfBetheHeitlerUpdator.cc.

References i, theNrComponents, thePolyMeans, thePolyVars, thePolyWeights, theTransformationCode, histoStyle::weight, and detailsBasic3DVector::z.

Referenced by compute().

171 {
172 
173  for ( int i=0; i<theNrComponents; i++ ) {
174 
175  float weight = thePolyWeights[i](rl);
176  if ( theTransformationCode ) weight = logisticFunction(weight);
177 
178  float z = thePolyMeans[i](rl);
179  if ( theTransformationCode ) z = logisticFunction(z);
180 
181  float vz = thePolyVars[i](rl);
182  if ( theTransformationCode )
183  vz = unsafe_expf<4>(vz);
184  else vz = vz*vz;
185 
186  mixture[i]=Triplet<float,float,float>(weight,z,vz);
187  }
188 }
int i
Definition: DBlmapReader.cc:9
Definition: Triplet.h:9
Polynomial thePolyWeights[MaxSize]
correction of 1st or 1st&amp;2nd moments
float float float z
int theTransformationCode
number of components used for parameterisation
Polynomial thePolyVars[MaxSize]
parametrisation of mean for each componentP
Polynomial thePolyMeans[MaxSize]
parametrisation of weight for each component
int weight
Definition: histoStyle.py:50
void GsfBetheHeitlerUpdator::readParameters ( const std::string  fileName)
private

Read parametrization from file.

Definition at line 63 of file GsfBetheHeitlerUpdator.cc.

References convertXMLtoSQLite_cfg::fileName, edm::FileInPath::fullPath(), MaxOrder, mergeVDriftHistosByStation::name, readPolynomial(), AlCaHLTBitMon_QueryRunRegistry::string, theNrComponents, thePolyMeans, thePolyVars, thePolyWeights, and theTransformationCode.

Referenced by GsfBetheHeitlerUpdator().

64 {
65  std::string name = "TrackingTools/GsfTracking/data/";
66  name += fileName;
67 
68  edm::FileInPath parFile(name);
69  edm::LogInfo("GsfBetheHeitlerUpdator") << "Reading GSF parameterization "
70  << "of Bethe-Heitler energy loss from "
71  << 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 }
Polynomial readPolynomial(std::ifstream &, const int)
Read coefficients of one polynomial from file.
Polynomial thePolyWeights[MaxSize]
correction of 1st or 1st&amp;2nd moments
int theTransformationCode
number of components used for parameterisation
Polynomial thePolyVars[MaxSize]
parametrisation of mean for each componentP
Polynomial thePolyMeans[MaxSize]
parametrisation of weight for each component
GsfBetheHeitlerUpdator::Polynomial GsfBetheHeitlerUpdator::readPolynomial ( std::ifstream &  aStream,
const int  order 
)
private

Read coefficients of one polynomial from file.

Definition at line 89 of file GsfBetheHeitlerUpdator.cc.

References i.

Referenced by readParameters().

90  {
91  float coeffs[order+1];
92  for ( int i=0; i<(order+1); ++i ) aStream >> coeffs[i];
93  return Polynomial(coeffs,order+1);
94 }
int i
Definition: DBlmapReader.cc:9

Member Data Documentation

int GsfBetheHeitlerUpdator::MaxOrder =6
staticprivate

Definition at line 30 of file GsfBetheHeitlerUpdator.h.

Referenced by readParameters().

int GsfBetheHeitlerUpdator::MaxSize =6
staticprivate

Definition at line 29 of file GsfBetheHeitlerUpdator.h.

int GsfBetheHeitlerUpdator::theCorrectionFlag
private

values to be transformed by logistic / exp. function?

Definition at line 98 of file GsfBetheHeitlerUpdator.h.

Referenced by compute(), and GsfBetheHeitlerUpdator().

int GsfBetheHeitlerUpdator::theNrComponents
private
Polynomial GsfBetheHeitlerUpdator::thePolyMeans[MaxSize]
private

parametrisation of weight for each component

Definition at line 101 of file GsfBetheHeitlerUpdator.h.

Referenced by getMixtureParameters(), and readParameters().

Polynomial GsfBetheHeitlerUpdator::thePolyVars[MaxSize]
private

parametrisation of mean for each componentP

Definition at line 102 of file GsfBetheHeitlerUpdator.h.

Referenced by getMixtureParameters(), and readParameters().

Polynomial GsfBetheHeitlerUpdator::thePolyWeights[MaxSize]
private

correction of 1st or 1st&2nd moments

Definition at line 100 of file GsfBetheHeitlerUpdator.h.

Referenced by getMixtureParameters(), and readParameters().

int GsfBetheHeitlerUpdator::theTransformationCode
private

number of components used for parameterisation

Definition at line 97 of file GsfBetheHeitlerUpdator.h.

Referenced by getMixtureParameters(), and readParameters().