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  GSContainer mixture[theNrComponents];
126  getMixtureParameters(rl,mixture);
127  correctWeights(mixture);
128  if ( theCorrectionFlag>=1 )
129  mixture[0].second = correctedFirstMean(rl,mixture);
130  if ( theCorrectionFlag>=2 )
131  mixture[0].third = correctedFirstVar(rl,mixture);
132 
133  for ( int i=0; i<theNrComponents; i++ ) {
134  float varPinv;
135  effects[i].weight*=mixture[i].first;
136  if ( propDir==alongMomentum ) {
137  //
138  // for forward propagation: calculate in p (linear in 1/z=p_inside/p_outside),
139  // then convert sig(p) to sig(1/p).
140  //
141  effects[i].deltaP += p*(mixture[i].second-1);
142  // float f = 1./p/mixture[i].second/mixture[i].second;
143  // patch to ensure consistency between for- and backward propagation
144  float f = 1./p/mixture[i].second;
145  varPinv = f*f*mixture[i].third;
146  }
147  else {
148  //
149  // for backward propagation: delta(1/p) is linear in z=p_outside/p_inside
150  // convert to obtain equivalent delta(p)
151  //
152  effects[i].deltaP += p*(1/mixture[i].second-1);
153  varPinv = mixture[i].third/p/p;
154  }
155  using namespace materialEffect;
156  effects[i].deltaCov[elos] += varPinv;
157  }
158  }
159 }
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 207 of file GsfBetheHeitlerUpdator.cc.

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

Referenced by compute().

209 {
210  //
211  // calculate difference true mean - weighted sum
212  //
213  float mean = BetheHeitlerMean(rl);
214  for ( int i=1; i<theNrComponents; i++ )
215  mean -= mixture[i].first*mixture[i].second;
216  //
217  // return corrected mean for first component
218  //
219  return std::max(std::min(mean/mixture[0].first,1.f),0.f);
220 }
int i
Definition: DBlmapReader.cc:9
U second(std::pair< T, U > const &p)
const T & max(const T &a, const T &b)
double f[11][100]
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 225 of file GsfBetheHeitlerUpdator.cc.

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

Referenced by compute().

227 {
228  //
229  // calculate difference true variance - weighted sum
230  //
231  float var = BetheHeitlerVariance(rl) +
232  BetheHeitlerMean(rl)*BetheHeitlerMean(rl) -
233  mixture[0].first*mixture[0].second*mixture[0].second;
234  for ( int i=1; i<theNrComponents; i++ )
235  var -= mixture[i].first*(mixture[i].second*mixture[i].second+mixture[i].third);
236  //
237  // return corrected variance for first component
238  //
239  return std::max(var/mixture[0].first,0.f);
240 }
int i
Definition: DBlmapReader.cc:9
U second(std::pair< T, U > const &p)
const T & max(const T &a, const T &b)
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 189 of file GsfBetheHeitlerUpdator.cc.

References first, i, and theNrComponents.

Referenced by compute().

190 {
191  //
192  // get sum of weights
193  //
194  float wsum(0);
195  for ( int i=0; i<theNrComponents; i++ )
196  wsum += mixture[i].first;
197  //
198  // rescale to obtain 1
199  //
200  for ( int i=0; i<theNrComponents; i++ )
201  mixture[i].first /= wsum;
202 }
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 164 of file GsfBetheHeitlerUpdator.cc.

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

Referenced by compute().

166 {
167 
168  for ( int i=0; i<theNrComponents; i++ ) {
169 
170  float weight = thePolyWeights[i](rl);
171  if ( theTransformationCode ) weight = logisticFunction(weight);
172 
173  float z = thePolyMeans[i](rl);
174  if ( theTransformationCode ) z = logisticFunction(z);
175 
176  float vz = thePolyVars[i](rl);
177  if ( theTransformationCode )
178  vz = unsafe_expf<4>(vz);
179  else vz = vz*vz;
180 
181  mixture[i]=Triplet<float,float,float>(weight,z,vz);
182  }
183 }
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().