CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PixelDigitizerAlgorithm::TimewalkModel Class Reference

Public Member Functions

double operator() (double q_in, double q_threshold) const
 
 TimewalkModel (const edm::ParameterSet &pset)
 

Private Member Functions

std::size_t find_closest_index (const std::vector< double > &vec, double value) const
 

Private Attributes

std::vector< TimewalkCurvecurves
 
std::vector< double > threshold_values
 

Detailed Description

Definition at line 29 of file PixelDigitizerAlgorithm.h.

Constructor & Destructor Documentation

PixelDigitizerAlgorithm::TimewalkModel::TimewalkModel ( const edm::ParameterSet pset)

Definition at line 199 of file PixelDigitizerAlgorithm.cc.

References edm::ParameterSet::getParameter().

199  {
200  threshold_values = pset.getParameter<std::vector<double>>("ThresholdValues");
201  const auto& curve_psetvec = pset.getParameter<std::vector<edm::ParameterSet>>("Curves");
202  if (threshold_values.size() != curve_psetvec.size())
203  throw cms::Exception("Configuration")
204  << "Timewalk model error: the number of threshold values does not match the number of curves.";
205  for (const auto& curve_pset : curve_psetvec)
206  curves.emplace_back(curve_pset);
207 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303

Member Function Documentation

std::size_t PixelDigitizerAlgorithm::TimewalkModel::find_closest_index ( const std::vector< double > &  vec,
double  value 
) const
private

Definition at line 214 of file PixelDigitizerAlgorithm.cc.

References HLT_FULL_cff::distance, cuda_std::lower_bound(), and relativeConstraints::value.

215  {
216  auto it = std::lower_bound(vec.begin(), vec.end(), value);
217  if (it == vec.begin())
218  return 0;
219  else if (it == vec.end())
220  return vec.size() - 1;
221  else {
222  auto it_upper = it;
223  auto it_lower = --it;
224  auto closest = (value - *it_lower > *it_upper - value) ? it_upper : it_lower;
225  return std::distance(vec.begin(), closest);
226  }
227 }
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
double PixelDigitizerAlgorithm::TimewalkModel::operator() ( double  q_in,
double  q_threshold 
) const

Definition at line 209 of file PixelDigitizerAlgorithm.cc.

209  {
210  auto index = find_closest_index(threshold_values, q_threshold);
211  return curves[index](q_in);
212 }
std::size_t find_closest_index(const std::vector< double > &vec, double value) const

Member Data Documentation

std::vector<TimewalkCurve> PixelDigitizerAlgorithm::TimewalkModel::curves
private

Definition at line 40 of file PixelDigitizerAlgorithm.h.

std::vector<double> PixelDigitizerAlgorithm::TimewalkModel::threshold_values
private

Definition at line 39 of file PixelDigitizerAlgorithm.h.