CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/FastSimulation/Event/src/BetaFuncPrimaryVertexGenerator.cc

Go to the documentation of this file.
00001 //Framework Headers
00002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00003 
00004 //Famos Headers
00005 #include "FastSimulation/Event/interface/BetaFuncPrimaryVertexGenerator.h"
00006 #include "FastSimulation/Utilities/interface/RandomEngine.h"
00007 
00008 BetaFuncPrimaryVertexGenerator::BetaFuncPrimaryVertexGenerator(
00009   const edm::ParameterSet& vtx, const RandomEngine* engine) : 
00010   PrimaryVertexGenerator(engine),
00011   fX0(vtx.getParameter<double>("X0")),
00012   fY0(vtx.getParameter<double>("Y0")),
00013   fZ0(vtx.getParameter<double>("Z0")),
00014   fSigmaZ(vtx.getParameter<double>("SigmaZ")),
00015   alpha_(vtx.getParameter<double>("Alpha")),
00016   phi_(vtx.getParameter<double>("Phi")),
00017   fbetastar(vtx.getParameter<double>("BetaStar")),
00018   femittance(vtx.getParameter<double>("Emittance"))
00019 {
00020 
00021   this->setBoost(inverseLorentzBoost());
00022   beamSpot_ = math::XYZPoint(fX0,fY0,fZ0);
00023 
00024 } 
00025   
00026 
00027 void BetaFuncPrimaryVertexGenerator::generate() {       
00028   
00029   double tmp_sigz = random->gaussShoot(0., fSigmaZ);
00030   this->SetZ(tmp_sigz + fZ0);
00031 
00032   double tmp_sigx = BetaFunction(tmp_sigz,fZ0); 
00033   // need to divide by sqrt(2) for beamspot width relative to single beam width
00034   tmp_sigx *= 0.707107;
00035   this->SetX(random->gaussShoot(fX0,tmp_sigx));
00036 
00037   double tmp_sigy = BetaFunction(tmp_sigz,fZ0);
00038   // need to divide by sqrt(2) for beamspot width relative to single beam width
00039   tmp_sigy *= 0.707107;
00040   this->SetY(random->gaussShoot(fY0,tmp_sigy));
00041 
00042 }
00043 
00044 double BetaFuncPrimaryVertexGenerator::BetaFunction(double z, double z0)
00045 {
00046   return sqrt(femittance*(fbetastar+(((z-z0)*(z-z0))/fbetastar)));
00047 
00048 }
00049 
00050 
00051 TMatrixD* 
00052 BetaFuncPrimaryVertexGenerator::inverseLorentzBoost() {
00053   
00054   TMatrixD* aBoost = 0;
00055   if ( fabs(alpha_) < 1E-12 && fabs(phi_) < 1E-12 ) return aBoost;
00056  
00057   TMatrixD tmpboost(4,4);
00058   
00059   // Lorentz boost to frame where the collision is head-on
00060   // phi is the half crossing angle in the plane ZS
00061   // alpha is the angle to the S axis from the X axis in the XY plane
00062 
00063   double calpha = std::cos(alpha_);
00064   double salpha = std::sin(alpha_);
00065   double cphi = std::cos(phi_);
00066   double sphi = std::sin(phi_);
00067   double tphi = sphi/cphi;
00068   tmpboost(0,0) = 1./cphi;
00069   tmpboost(0,1) = - calpha*sphi;
00070   tmpboost(0,2) = - tphi*sphi;
00071   tmpboost(0,3) = - salpha*sphi;
00072   tmpboost(1,0) = - calpha*tphi;
00073   tmpboost(1,1) = 1.;
00074   tmpboost(1,2) = calpha*tphi;
00075   tmpboost(1,3) = 0.;
00076   tmpboost(2,0) = 0.;
00077   tmpboost(2,1) = -calpha*sphi;
00078   tmpboost(2,2) = cphi;
00079   tmpboost(2,3) = - salpha*sphi;
00080   tmpboost(3,0) = - salpha*tphi;
00081   tmpboost(3,1) = 0.;
00082   tmpboost(3,2) = salpha*tphi;
00083   tmpboost(3,3) = 1.;
00084   
00085   tmpboost.Invert();
00086   aBoost = new TMatrixD(tmpboost);
00087 
00088   return aBoost;
00089 
00090 }