CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes

SurveyPxbDicer Class Reference

#include <SurveyPxbDicer.h>

List of all members.

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

Definition at line 24 of file SurveyPxbDicer.h.

typedef unsigned int SurveyPxbDicer::count_t

Definition at line 27 of file SurveyPxbDicer.h.

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

Definition at line 26 of file SurveyPxbDicer.h.

Definition at line 28 of file SurveyPxbDicer.h.

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

Definition at line 29 of file SurveyPxbDicer.h.

typedef double SurveyPxbDicer::value_t

Definition at line 25 of file SurveyPxbDicer.h.


Constructor & Destructor Documentation

SurveyPxbDicer::SurveyPxbDicer ( ) [inline]

Definition at line 32 of file SurveyPxbDicer.h.

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

Definition at line 21 of file SurveyPxbDicer.cc.

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

{
        CLHEP::HepRandom::setTheSeed( seed );
        mean_a0 = getParByName("a0", "mean", pars);
        sigma_a0 = getParByName("a0", "sigma", pars);
        mean_a1 = getParByName("a1", "mean", pars);
        sigma_a1 = getParByName("a1", "sigma", pars);
        mean_scale = getParByName("scale", "mean", pars);
        sigma_scale = getParByName("scale", "sigma", pars);
        mean_phi = getParByName("phi", "mean", pars);
        sigma_phi = getParByName("phi", "sigma", pars);
        mean_x = getParByName("x", "mean", pars);
        sigma_x = getParByName("x", "sigma", pars);
        mean_y = getParByName("y", "mean", pars);
        sigma_y = getParByName("y", "sigma", pars);
}

Member Function Documentation

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 38 of file SurveyPxbDicer.cc.

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

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

{
        // Dice the local parameters
        const value_t a0 = ranGauss(mean_a0, sigma_a0);
        const value_t a1 = ranGauss(mean_a1, sigma_a1);
        const value_t scale = ranGauss(mean_scale, sigma_scale);
        const value_t phi = ranGauss(mean_phi, sigma_phi);
        const value_t a2 = scale * cos(phi);
        const value_t a3 = scale * sin(phi);
        const coord_t p0 = transform(fidpointvec[0],a0,a1,a2,a3);
        const coord_t p1 = transform(fidpointvec[1],a0,a1,a2,a3);
        const coord_t p2 = transform(fidpointvec[2],a0,a1,a2,a3);
        const coord_t p3 = transform(fidpointvec[3],a0,a1,a2,a3);
        const value_t sign = rotate ? -1 : 1;
        std::ostringstream oss;
        oss << id.first << " " 
                 << sign*ranGauss(p0.x(),sigma_x) << " " << -sign*ranGauss(p0.y(),sigma_y) << " "
                 << sign*ranGauss(p1.x(),sigma_x) << " " << -sign*ranGauss(p1.y(),sigma_y) << " "
                 << id.second << " "
                 << sign*ranGauss(p2.x(),sigma_x) << " " << -sign*ranGauss(p2.y(),sigma_y) << " "
                 << sign*ranGauss(p3.x(),sigma_x) << " " << -sign*ranGauss(p3.y(),sigma_y) << " "
                 << sigma_x << " " << sigma_y << " "
                 << rotate
                 << " # MC-truth:"
                 << " a0-a3: " << a0 << " " << a1 << " " << a2 << " " << a3
                 << " S: " << scale
                 << " phi: " << phi
                 << " x0: " << fidpointvec[0].x() << " " << fidpointvec[0].y()
                 << " x1: " << fidpointvec[1].x() << " " << fidpointvec[1].y()
                 << " x2: " << fidpointvec[2].x() << " " << fidpointvec[2].y()
                 << " x3: " << fidpointvec[3].x() << " " << fidpointvec[3].y()
                 << std::endl;
        return oss.str();
}
void SurveyPxbDicer::doDice ( const fidpoint_t fidpointvec,
const idPair_t id,
std::ofstream &  outfile,
const bool  rotate = false 
)

Definition at line 73 of file SurveyPxbDicer.cc.

References doDice().

{
        outfile << doDice(fidpointvec, id, rotate);
}
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 83 of file SurveyPxbDicer.cc.

Referenced by SurveyPxbDicer().

{
        std::vector<edm::ParameterSet>::const_iterator it;
        it = std::find_if(pars.begin(), pars.end(), std::bind1st(findParByName(),name));
        if (it == pars.end()) { throw std::runtime_error("Parameter not found in SurveyPxbDicer::getParByName"); }
        return (*it).getParameter<value_t>(par);
}
value_t SurveyPxbDicer::ranGauss ( value_t  mean,
value_t  sigma 
) [inline, private]

invoke the RNG to geat a gaussian smeared value

Parameters:
meanmean value
sigma

Definition at line 46 of file SurveyPxbDicer.h.

Referenced by doDice().

{return CLHEP::RandGauss::shoot(mean,sigma);};
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 78 of file SurveyPxbDicer.cc.

References PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by doDice().

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

Member Data Documentation

Definition at line 46 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

Definition at line 49 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

Definition at line 51 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

Definition at line 50 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

Definition at line 52 of file SurveyPxbDicer.h.

Referenced by SurveyPxbDicer().

Definition at line 53 of file SurveyPxbDicer.h.

Referenced by SurveyPxbDicer().

Definition at line 46 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

Definition at line 49 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

Definition at line 51 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

Definition at line 50 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

Definition at line 52 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().

Definition at line 53 of file SurveyPxbDicer.h.

Referenced by doDice(), and SurveyPxbDicer().