Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:34:42

0001 #ifndef GUARD_surveypxbdicer_h
0002 #define GUARD_surveypxbdicer_h
0003 
0004 #include <vector>
0005 #include <functional>
0006 #include <utility>
0007 #include <fstream>
0008 #include "DataFormats/GeometryVector/interface/Point3DBase.h"
0009 #include "Alignment/SurveyAnalysis/interface/SurveyPxbImage.h"
0010 #include "Math/SMatrix.h"
0011 #include "Math/SVector.h"
0012 #include "CLHEP/Random/RandGauss.h"
0013 #include "CLHEP/Random/Random.h"
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 
0016 #include <iostream>
0017 #include <stdexcept>
0018 
0019 //! Class to dice a picture from a given set of fiducial points
0020 //! This class has its use for toy MC simulations to validate the PXB survey
0021 class SurveyPxbDicer {
0022 public:
0023   typedef SurveyPxbImage::coord_t coord_t;
0024   typedef double value_t;
0025   typedef std::vector<coord_t> fidpoint_t;
0026   typedef unsigned int count_t;
0027   typedef SurveyPxbImage::id_t id_t;
0028   typedef std::pair<id_t, id_t> idPair_t;
0029 
0030   // Constructors
0031   SurveyPxbDicer() {}
0032   // Constructor from VPSet
0033   SurveyPxbDicer(const std::vector<edm::ParameterSet> &pars, unsigned int seed);
0034 
0035   //! Invoke the dicer
0036   //! \param fidpointvec vector with fiducial points where values need to be diced for and transformed to the photo fram
0037   //! \param idPair pair of the id values
0038   std::string doDice(const fidpoint_t &fidpointvec, const idPair_t &id, const bool rotate = false);
0039   void doDice(const fidpoint_t &fidpointvec, const idPair_t &id, std::ofstream &outfile, const bool rotate = false);
0040 
0041 private:
0042   //! invoke the RNG to geat a gaussian smeared value
0043   //! \param mean mean value
0044   //! \param sigma
0045   value_t ranGauss(value_t mean, value_t sigma) { return CLHEP::RandGauss::shoot(mean, sigma); };
0046 
0047   value_t mean_a0, sigma_a0;
0048   value_t mean_a1, sigma_a1;
0049   value_t mean_scale, sigma_scale;
0050   value_t mean_phi, sigma_phi;
0051   value_t mean_x, sigma_x;
0052   value_t mean_y, sigma_y;
0053 
0054   //! Gets parameter by name from the VPSet
0055   //! \param name name of the parameter to be searched for in field 'name' of the VPSet
0056   //! \param par selects the value, i.e. mean or sigma
0057   //! \param pars reference to VPSet
0058   value_t getParByName(const std::string &name, const std::string &par, const std::vector<edm::ParameterSet> &pars);
0059 
0060   //! Transform the diced values to the frame of a toy photograph
0061   //! \param x coordinate to be transformed from local frame to photo frame
0062   //! \param a0 Transformation parameter, shift in x
0063   //! \param a1 Transformation parameter, shift in y
0064   //! \param a2 Transformation parameter, scale*cos(phi)
0065   //! \param a3 Transformation parameter, scale*sin(phi)
0066   coord_t transform(const coord_t &x, const value_t &a0, const value_t &a1, const value_t &a2, const value_t &a3);
0067 
0068   //! Function object for searching for a parameter in the VPSet
0069   struct findParByName {
0070     bool operator()(const std::string &name, const edm::ParameterSet &parset) const {
0071       return (parset.getParameter<std::string>("name") == name);
0072     }
0073   };
0074 };
0075 
0076 #endif