15 inline float logisticFunction (
const float x) {
return 1./(1.+unsafe_expf<4>(-
x));}
17 inline float BetheHeitlerMean (
const float rl) {
18 return unsafe_expf<4>(-rl);
21 inline float BetheHeitlerVariance (
const float rl)
24 float mean = BetheHeitlerMean(rl);
25 return unsafe_expf<4>(-rl*l3ol2) - mean*mean;
47 const int correctionFlag) :
50 theCorrectionFlag(correctionFlag)
52 if ( theCorrectionFlag==1 )
53 edm::LogInfo(
"GsfBetheHeitlerUpdator") <<
"1st moment of mixture will be corrected";
54 if ( theCorrectionFlag>=2 )
56 <<
"1st and 2nd moments of mixture will be corrected";
58 readParameters(fileName);
59 assert(theNrComponents<=6);
60 resize(theNrComponents);
63 void GsfBetheHeitlerUpdator::readParameters (
const std::string fileName)
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());
74 ifs >> theNrComponents;
77 ifs >> theTransformationCode;
79 assert(orderP<MaxOrder);
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);
88 GsfBetheHeitlerUpdator::Polynomial
89 GsfBetheHeitlerUpdator::readPolynomial (std::ifstream& aStream,
91 float coeffs[order+1];
92 for (
int i=0; i<(order+1); ++i ) aStream >> coeffs[
i];
93 return Polynomial(coeffs,order+1);
122 if ( rl<0.01
f ) rl = 0.01f;
123 if ( rl>0.20
f ) rl = 0.20f;
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);
133 for (
int i=0;
i<theNrComponents;
i++ ) {
135 effects[
i].weight*=mixture[
i].first;
141 effects[
i].deltaP +=
p*(mixture[
i].second-1);
144 float f = 1./
p/mixture[
i].second;
145 varPinv = f*f*mixture[
i].third;
152 effects[
i].deltaP +=
p*(1/mixture[
i].second-1);
153 varPinv = mixture[
i].third/
p/
p;
155 using namespace materialEffect;
156 effects[
i].deltaCov[
elos] += varPinv;
164 GsfBetheHeitlerUpdator::getMixtureParameters (
const float rl,
165 GSContainer mixture[])
const
168 for (
int i=0;
i<theNrComponents;
i++ ) {
170 float weight = thePolyWeights[
i](rl);
171 if ( theTransformationCode ) weight = logisticFunction(weight);
173 float z = thePolyMeans[
i](rl);
174 if ( theTransformationCode ) z = logisticFunction(z);
176 float vz = thePolyVars[
i](rl);
177 if ( theTransformationCode )
178 vz = unsafe_expf<4>(vz);
189 GsfBetheHeitlerUpdator::correctWeights (GSContainer mixture[])
const
195 for (
int i=0;
i<theNrComponents;
i++ )
200 for (
int i=0;
i<theNrComponents;
i++ )
207 GsfBetheHeitlerUpdator::correctedFirstMean (
const float rl,
208 const GSContainer mixture[])
const
213 float mean = BetheHeitlerMean(rl);
214 for (
int i=1;
i<theNrComponents;
i++ )
225 GsfBetheHeitlerUpdator::correctedFirstVar (
const float rl,
226 const GSContainer mixture[])
const
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++ )
LocalVector localMomentum() const
U second(std::pair< T, U > const &p)
const SurfaceType & surface() const
const T & max(const T &a, const T &b)
const MediumProperties & mediumProperties() const