CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Public Attributes
PPSFastLocalSimulation::Distribution Struct Reference

Public Types

enum  Type { dtBox, dtGauss, dtGaussLimit }
 

Public Member Functions

 Distribution (const edm::ParameterSet &)
 
void Generate (CLHEP::HepRandomEngine &rndEng, double &x, double &y)
 

Public Attributes

enum PPSFastLocalSimulation::Distribution::Type type_
 
double x_max_
 
double x_mean_
 
double x_min_
 
double x_width_
 
double y_max_
 
double y_mean_
 
double y_min_
 
double y_width_
 

Detailed Description

Definition at line 82 of file PPSFastLocalSimulation.cc.

Member Enumeration Documentation

◆ Type

Enumerator
dtBox 
dtGauss 
dtGaussLimit 

Definition at line 83 of file PPSFastLocalSimulation.cc.

Constructor & Destructor Documentation

◆ Distribution()

PPSFastLocalSimulation::Distribution::Distribution ( const edm::ParameterSet ps)

Definition at line 125 of file PPSFastLocalSimulation.cc.

125  {
126  // get type
127  string typeName = ps.getParameter<string>("type");
128  if (!typeName.compare("box"))
129  type_ = dtBox;
130  else if (!typeName.compare("gauss"))
131  type_ = dtGauss;
132  else if (!typeName.compare("gauss-limit"))
134  else
135  throw cms::Exception("PPS") << "Unknown distribution type `" << typeName << "'.";
136 
137  x_mean_ = ps.getParameter<double>("x_mean");
138  x_width_ = ps.getParameter<double>("x_width");
139  x_min_ = ps.getParameter<double>("x_min");
140  x_max_ = ps.getParameter<double>("x_max");
141 
142  y_mean_ = ps.getParameter<double>("y_mean");
143  y_width_ = ps.getParameter<double>("y_width");
144  y_min_ = ps.getParameter<double>("y_min");
145  y_max_ = ps.getParameter<double>("y_max");
146 }

References Exception, edm::ParameterSet::getParameter(), and dqmiodumpindices::typeName.

Member Function Documentation

◆ Generate()

void PPSFastLocalSimulation::Distribution::Generate ( CLHEP::HepRandomEngine &  rndEng,
double &  x,
double &  y 
)

Definition at line 150 of file PPSFastLocalSimulation.cc.

150  {
151  switch (type_) {
152  case dtBox:
153  x = x_mean_ + x_width_ * (rndEng.flat() - 0.5);
154  y = y_mean_ + y_width_ * (rndEng.flat() - 0.5);
155  break;
156 
157  case dtGauss:
158  x = x_mean_ + RandGauss::shoot(&rndEng) * x_width_;
159  y = y_mean_ + RandGauss::shoot(&rndEng) * y_width_;
160  break;
161 
162  case dtGaussLimit: {
163  const double u_x = rndEng.flat(), u_y = rndEng.flat();
164 
165  const double cdf_x_min = (1. + TMath::Erf((x_min_ - x_mean_) / x_width_ / sqrt(2.))) / 2.;
166  const double cdf_x_max = (1. + TMath::Erf((x_max_ - x_mean_) / x_width_ / sqrt(2.))) / 2.;
167  const double a_x = cdf_x_max - cdf_x_min, b_x = cdf_x_min;
168 
169  const double cdf_y_min = (1. + TMath::Erf((y_min_ - y_mean_) / y_width_ / sqrt(2.))) / 2.;
170  const double cdf_y_max = (1. + TMath::Erf((y_max_ - y_mean_) / y_width_ / sqrt(2.))) / 2.;
171  const double a_y = cdf_y_max - cdf_y_min, b_y = cdf_y_min;
172 
173  x = x_mean_ + x_width_ * sqrt(2.) * TMath::ErfInverse(2. * (a_x * u_x + b_x) - 1.);
174  y = y_mean_ + y_width_ * sqrt(2.) * TMath::ErfInverse(2. * (a_y * u_y + b_y) - 1.);
175  }
176 
177  break;
178 
179  default:
180  x = y = 0.;
181  }
182 }

References mathSSE::sqrt().

Referenced by PPSFastLocalSimulation::GenerateTrack().

Member Data Documentation

◆ type_

enum PPSFastLocalSimulation::Distribution::Type PPSFastLocalSimulation::Distribution::type_

◆ x_max_

double PPSFastLocalSimulation::Distribution::x_max_

Definition at line 84 of file PPSFastLocalSimulation.cc.

◆ x_mean_

double PPSFastLocalSimulation::Distribution::x_mean_

Definition at line 84 of file PPSFastLocalSimulation.cc.

◆ x_min_

double PPSFastLocalSimulation::Distribution::x_min_

Definition at line 84 of file PPSFastLocalSimulation.cc.

◆ x_width_

double PPSFastLocalSimulation::Distribution::x_width_

Definition at line 84 of file PPSFastLocalSimulation.cc.

◆ y_max_

double PPSFastLocalSimulation::Distribution::y_max_

Definition at line 85 of file PPSFastLocalSimulation.cc.

◆ y_mean_

double PPSFastLocalSimulation::Distribution::y_mean_

Definition at line 85 of file PPSFastLocalSimulation.cc.

◆ y_min_

double PPSFastLocalSimulation::Distribution::y_min_

Definition at line 85 of file PPSFastLocalSimulation.cc.

◆ y_width_

double PPSFastLocalSimulation::Distribution::y_width_

Definition at line 85 of file PPSFastLocalSimulation.cc.

DDAxes::y
PPSFastLocalSimulation::Distribution::x_width_
double x_width_
Definition: PPSFastLocalSimulation.cc:84
PPSFastLocalSimulation::Distribution::y_max_
double y_max_
Definition: PPSFastLocalSimulation.cc:85
PPSFastLocalSimulation::Distribution::dtGaussLimit
Definition: PPSFastLocalSimulation.cc:83
PPSFastLocalSimulation::Distribution::x_max_
double x_max_
Definition: PPSFastLocalSimulation.cc:84
DDAxes::x
PPSFastLocalSimulation::Distribution::y_min_
double y_min_
Definition: PPSFastLocalSimulation.cc:85
PPSFastLocalSimulation::Distribution::type_
enum PPSFastLocalSimulation::Distribution::Type type_
PPSFastLocalSimulation::Distribution::x_min_
double x_min_
Definition: PPSFastLocalSimulation.cc:84
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
PPSFastLocalSimulation::Distribution::x_mean_
double x_mean_
Definition: PPSFastLocalSimulation.cc:84
dqmiodumpindices.typeName
typeName
Definition: dqmiodumpindices.py:33
PPSFastLocalSimulation::Distribution::dtGauss
Definition: PPSFastLocalSimulation.cc:83
PPSFastLocalSimulation::Distribution::y_mean_
double y_mean_
Definition: PPSFastLocalSimulation.cc:85
Exception
Definition: hltDiff.cc:246
PPSFastLocalSimulation::Distribution::dtBox
Definition: PPSFastLocalSimulation.cc:83
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PPSFastLocalSimulation::Distribution::y_width_
double y_width_
Definition: PPSFastLocalSimulation.cc:85