CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
SurveyPxbDicer Class Reference

#include <SurveyPxbDicer.h>

Classes

struct  findParByName
 Function object for searching for a parameter in the VPSet. More...
 

Public Types

typedef SurveyPxbImage::coord_t coord_t
 
typedef unsigned int count_t
 
typedef std::vector< coord_tfidpoint_t
 
typedef SurveyPxbImage::id_t id_t
 
typedef std::pair< id_t, id_tidPair_t
 
typedef double value_t
 

Public Member Functions

std::string doDice (const fidpoint_t &fidpointvec, const idPair_t &id, const bool rotate=false)
 
void doDice (const fidpoint_t &fidpointvec, const idPair_t &id, std::ofstream &outfile, const bool rotate=false)
 
 SurveyPxbDicer ()
 
 SurveyPxbDicer (const std::vector< edm::ParameterSet > &pars, unsigned int seed)
 

Private Member Functions

value_t getParByName (const std::string &name, const std::string &par, const std::vector< edm::ParameterSet > &pars)
 
value_t ranGauss (value_t mean, value_t sigma)
 
coord_t transform (const coord_t &x, const value_t &a0, const value_t &a1, const value_t &a2, const value_t &a3)
 

Private Attributes

value_t mean_a0
 
value_t mean_a1
 
value_t mean_phi
 
value_t mean_scale
 
value_t mean_x
 
value_t mean_y
 
value_t sigma_a0
 
value_t sigma_a1
 
value_t sigma_phi
 
value_t sigma_scale
 
value_t sigma_x
 
value_t sigma_y
 

Detailed Description

Class to dice a picture from a given set of fiducial points This class has its use for toy MC simulations to validate the PXB survey

Definition at line 21 of file SurveyPxbDicer.h.

Member Typedef Documentation

◆ coord_t

Definition at line 23 of file SurveyPxbDicer.h.

◆ count_t

typedef unsigned int SurveyPxbDicer::count_t

Definition at line 26 of file SurveyPxbDicer.h.

◆ fidpoint_t

typedef std::vector<coord_t> SurveyPxbDicer::fidpoint_t

Definition at line 25 of file SurveyPxbDicer.h.

◆ id_t

Definition at line 27 of file SurveyPxbDicer.h.

◆ idPair_t

typedef std::pair<id_t, id_t> SurveyPxbDicer::idPair_t

Definition at line 28 of file SurveyPxbDicer.h.

◆ value_t

typedef double SurveyPxbDicer::value_t

Definition at line 24 of file SurveyPxbDicer.h.

Constructor & Destructor Documentation

◆ SurveyPxbDicer() [1/2]

SurveyPxbDicer::SurveyPxbDicer ( )
inline

Definition at line 31 of file SurveyPxbDicer.h.

31 {};

◆ SurveyPxbDicer() [2/2]

SurveyPxbDicer::SurveyPxbDicer ( const std::vector< edm::ParameterSet > &  pars,
unsigned int  seed 
)

Definition at line 21 of file SurveyPxbDicer.cc.

21  {
22  CLHEP::HepRandom::setTheSeed(seed);
23  mean_a0 = getParByName("a0", "mean", pars);
24  sigma_a0 = getParByName("a0", "sigma", pars);
25  mean_a1 = getParByName("a1", "mean", pars);
26  sigma_a1 = getParByName("a1", "sigma", pars);
27  mean_scale = getParByName("scale", "mean", pars);
28  sigma_scale = getParByName("scale", "sigma", pars);
29  mean_phi = getParByName("phi", "mean", pars);
30  sigma_phi = getParByName("phi", "sigma", pars);
31  mean_x = getParByName("x", "mean", pars);
32  sigma_x = getParByName("x", "sigma", pars);
33  mean_y = getParByName("y", "mean", pars);
34  sigma_y = getParByName("y", "sigma", pars);
35 }

References getParByName(), mean_a0, mean_a1, mean_phi, mean_scale, mean_x, mean_y, fileCollector::seed, sigma_a0, sigma_a1, sigma_phi, sigma_scale, sigma_x, and sigma_y.

Member Function Documentation

◆ doDice() [1/2]

std::string SurveyPxbDicer::doDice ( const fidpoint_t fidpointvec,
const idPair_t id,
const bool  rotate = false 
)

Invoke the dicer

Parameters
fidpointvecvector with fiducial points where values need to be diced for and transformed to the photo fram
idPairpair of the id values

Definition at line 37 of file SurveyPxbDicer.cc.

37  {
38  // Dice the local parameters
40  const value_t a1 = ranGauss(mean_a1, sigma_a1);
43  const value_t a2 = scale * cos(phi);
44  const value_t a3 = scale * sin(phi);
45  const coord_t p0 = transform(fidpointvec[0], a0, a1, a2, a3);
46  const coord_t p1 = transform(fidpointvec[1], a0, a1, a2, a3);
47  const coord_t p2 = transform(fidpointvec[2], a0, a1, a2, a3);
48  const coord_t p3 = transform(fidpointvec[3], a0, a1, a2, a3);
49  const value_t sign = rotate ? -1 : 1;
50  std::ostringstream oss;
51  oss << id.first << " " << sign * ranGauss(p0.x(), sigma_x) << " " << -sign * ranGauss(p0.y(), sigma_y) << " "
52  << sign * ranGauss(p1.x(), sigma_x) << " " << -sign * ranGauss(p1.y(), sigma_y) << " " << id.second << " "
53  << sign * ranGauss(p2.x(), sigma_x) << " " << -sign * ranGauss(p2.y(), sigma_y) << " "
54  << sign * ranGauss(p3.x(), sigma_x) << " " << -sign * ranGauss(p3.y(), sigma_y) << " " << sigma_x << " "
55  << sigma_y << " " << rotate << " # MC-truth:"
56  << " a0-a3: " << a0 << " " << a1 << " " << a2 << " " << a3 << " S: " << scale << " phi: " << phi
57  << " x0: " << fidpointvec[0].x() << " " << fidpointvec[0].y() << " x1: " << fidpointvec[1].x() << " "
58  << fidpointvec[1].y() << " x2: " << fidpointvec[2].x() << " " << fidpointvec[2].y()
59  << " x3: " << fidpointvec[3].x() << " " << fidpointvec[3].y() << std::endl;
60  return oss.str();
61 }

References a0, testProducerWithPsetDescEmpty_cfi::a2, funct::cos(), mean_a0, mean_a1, mean_phi, mean_scale, p1, p2, p3, phi, ranGauss(), svgfig::rotate(), L1EGammaCrystalsEmulatorProducer_cfi::scale, edm::second(), sigma_a0, sigma_a1, sigma_phi, sigma_scale, sigma_x, sigma_y, Validation_hcalonly_cfi::sign, funct::sin(), transform(), x, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by MillePedeAlignmentAlgorithm::addPxbSurvey(), and doDice().

◆ doDice() [2/2]

void SurveyPxbDicer::doDice ( const fidpoint_t fidpointvec,
const idPair_t id,
std::ofstream &  outfile,
const bool  rotate = false 
)

Definition at line 63 of file SurveyPxbDicer.cc.

66  {
67  outfile << doDice(fidpointvec, id, rotate);
68 }

References doDice(), timingPdfMaker::outfile, and svgfig::rotate().

◆ getParByName()

SurveyPxbDicer::value_t SurveyPxbDicer::getParByName ( const std::string &  name,
const std::string &  par,
const std::vector< edm::ParameterSet > &  pars 
)
private

Gets parameter by name from the VPSet

Parameters
namename of the parameter to be searched for in field 'name' of the VPSet
parselects the value, i.e. mean or sigma
parsreference to VPSet

Definition at line 75 of file SurveyPxbDicer.cc.

77  {
78  std::vector<edm::ParameterSet>::const_iterator it;
79  it = std::find_if(pars.begin(), pars.end(), [&name](auto const &c) { return findParByName()(name, c); });
80  if (it == pars.end()) {
81  throw std::runtime_error("Parameter not found in SurveyPxbDicer::getParByName");
82  }
83  return (*it).getParameter<value_t>(par);
84 }

References c, and Skims_PA_cff::name.

Referenced by SurveyPxbDicer().

◆ ranGauss()

value_t SurveyPxbDicer::ranGauss ( value_t  mean,
value_t  sigma 
)
inlineprivate

invoke the RNG to geat a gaussian smeared value

Parameters
meanmean value
sigma

Definition at line 45 of file SurveyPxbDicer.h.

45 { return CLHEP::RandGauss::shoot(mean, sigma); };

Referenced by doDice().

◆ transform()

SurveyPxbDicer::coord_t SurveyPxbDicer::transform ( const coord_t x,
const value_t a0,
const value_t a1,
const value_t a2,
const value_t a3 
)
private

Transform the diced values to the frame of a toy photograph

Parameters
xcoordinate to be transformed from local frame to photo frame
a0Transformation parameter, shift in x
a1Transformation parameter, shift in y
a2Transformation parameter, scale*cos(phi)
a3Transformation parameter, scale*sin(phi)

Definition at line 70 of file SurveyPxbDicer.cc.

71  {
72  return coord_t(a0 + a2 * x.x() + a3 * x.y(), a1 - a3 * x.x() + a2 * x.y());
73 }

References a0, testProducerWithPsetDescEmpty_cfi::a2, and x.

Referenced by doDice().

Member Data Documentation

◆ mean_a0

value_t SurveyPxbDicer::mean_a0
private

Definition at line 45 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

◆ mean_a1

value_t SurveyPxbDicer::mean_a1
private

Definition at line 48 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

◆ mean_phi

value_t SurveyPxbDicer::mean_phi
private

Definition at line 50 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

◆ mean_scale

value_t SurveyPxbDicer::mean_scale
private

Definition at line 49 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

◆ mean_x

value_t SurveyPxbDicer::mean_x
private

Definition at line 51 of file SurveyPxbDicer.h.

Referenced by SurveyPxbDicer().

◆ mean_y

value_t SurveyPxbDicer::mean_y
private

Definition at line 52 of file SurveyPxbDicer.h.

Referenced by SurveyPxbDicer().

◆ sigma_a0

value_t SurveyPxbDicer::sigma_a0
private

Definition at line 45 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

◆ sigma_a1

value_t SurveyPxbDicer::sigma_a1
private

Definition at line 48 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

◆ sigma_phi

value_t SurveyPxbDicer::sigma_phi
private

Definition at line 50 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

◆ sigma_scale

value_t SurveyPxbDicer::sigma_scale
private

Definition at line 49 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

◆ sigma_x

value_t SurveyPxbDicer::sigma_x
private

Definition at line 51 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

◆ sigma_y

value_t SurveyPxbDicer::sigma_y
private

Definition at line 52 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

SurveyPxbDicer::mean_a0
value_t mean_a0
Definition: SurveyPxbDicer.h:45
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
SurveyPxbDicer::mean_x
value_t mean_x
Definition: SurveyPxbDicer.h:51
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
SurveyPxbDicer::sigma_phi
value_t sigma_phi
Definition: SurveyPxbDicer.h:50
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DDAxes::x
SurveyPxbDicer::transform
coord_t transform(const coord_t &x, const value_t &a0, const value_t &a1, const value_t &a2, const value_t &a3)
Definition: SurveyPxbDicer.cc:70
svgfig.rotate
def rotate(angle, cx=0, cy=0)
Definition: svgfig.py:705
SurveyPxbDicer::doDice
std::string doDice(const fidpoint_t &fidpointvec, const idPair_t &id, const bool rotate=false)
Definition: SurveyPxbDicer.cc:37
testProducerWithPsetDescEmpty_cfi.a2
a2
Definition: testProducerWithPsetDescEmpty_cfi.py:35
SurveyPxbDicer::mean_a1
value_t mean_a1
Definition: SurveyPxbDicer.h:48
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
SurveyPxbDicer::sigma_y
value_t sigma_y
Definition: SurveyPxbDicer.h:52
fileCollector.seed
seed
Definition: fileCollector.py:127
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
p2
double p2[4]
Definition: TauolaWrapper.h:90
SurveyPxbDicer::sigma_x
value_t sigma_x
Definition: SurveyPxbDicer.h:51
SurveyPxbDicer::mean_scale
value_t mean_scale
Definition: SurveyPxbDicer.h:49
SurveyPxbDicer::coord_t
SurveyPxbImage::coord_t coord_t
Definition: SurveyPxbDicer.h:23
SurveyPxbDicer::sigma_a1
value_t sigma_a1
Definition: SurveyPxbDicer.h:48
SurveyPxbDicer::ranGauss
value_t ranGauss(value_t mean, value_t sigma)
Definition: SurveyPxbDicer.h:45
SurveyPxbDicer::mean_phi
value_t mean_phi
Definition: SurveyPxbDicer.h:50
p1
double p1[4]
Definition: TauolaWrapper.h:89
DDAxes::phi
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
p3
double p3[4]
Definition: TauolaWrapper.h:91
timingPdfMaker.outfile
outfile
Definition: timingPdfMaker.py:351
SurveyPxbDicer::sigma_a0
value_t sigma_a0
Definition: SurveyPxbDicer.h:45
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
SurveyPxbDicer::sigma_scale
value_t sigma_scale
Definition: SurveyPxbDicer.h:49
a0
static constexpr float a0
Definition: L1EGammaCrystalsEmulatorProducer.cc:82
SurveyPxbDicer::mean_y
value_t mean_y
Definition: SurveyPxbDicer.h:52
SurveyPxbDicer::getParByName
value_t getParByName(const std::string &name, const std::string &par, const std::vector< edm::ParameterSet > &pars)
Definition: SurveyPxbDicer.cc:75
SurveyPxbDicer::value_t
double value_t
Definition: SurveyPxbDicer.h:24