Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "IOMC/EventVertexGenerators/interface/BetafuncEvtVtxGenerator.h"
00023 #include "FWCore/Utilities/interface/Exception.h"
00024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00025
00026 #include "CLHEP/Random/RandGaussQ.h"
00027 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00028 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00029
00030 #include "HepMC/SimpleVector.h"
00031
00032 #include <iostream>
00033
00034
00035
00036 BetafuncEvtVtxGenerator::BetafuncEvtVtxGenerator(const edm::ParameterSet & p )
00037 : BaseEvtVtxGenerator(p)
00038 {
00039
00040 fRandom = new CLHEP::RandGaussQ(getEngine());
00041
00042 fX0 = p.getParameter<double>("X0")*cm;
00043 fY0 = p.getParameter<double>("Y0")*cm;
00044 fZ0 = p.getParameter<double>("Z0")*cm;
00045 fSigmaZ = p.getParameter<double>("SigmaZ")*cm;
00046 alpha_ = p.getParameter<double>("Alpha")*radian;
00047 phi_ = p.getParameter<double>("Phi")*radian;
00048 fbetastar = p.getParameter<double>("BetaStar")*cm;
00049 femittance = p.getParameter<double>("Emittance")*cm;
00050 fTimeOffset = p.getParameter<double>("TimeOffset")*ns*c_light;
00051
00052 if (fSigmaZ <= 0) {
00053 throw cms::Exception("Configuration")
00054 << "Error in BetafuncEvtVtxGenerator: "
00055 << "Illegal resolution in Z (SigmaZ is negative)";
00056 }
00057
00058
00059 }
00060
00061 BetafuncEvtVtxGenerator::~BetafuncEvtVtxGenerator()
00062 {
00063 delete fRandom;
00064 }
00065
00066
00067
00068 HepMC::FourVector* BetafuncEvtVtxGenerator::newVertex() {
00069
00070
00071 double X,Y,Z;
00072
00073 double tmp_sigz = fRandom->fire(0., fSigmaZ);
00074 Z = tmp_sigz + fZ0;
00075
00076 double tmp_sigx = BetaFunction(Z,fZ0);
00077
00078 tmp_sigx /= sqrt(2.0);
00079 X = fRandom->fire(0.,tmp_sigx) + fX0;
00080
00081 double tmp_sigy = BetaFunction(Z,fZ0);
00082
00083 tmp_sigy /= sqrt(2.0);
00084 Y = fRandom->fire(0.,tmp_sigy) + fY0;
00085
00086 double tmp_sigt = fRandom->fire(0., fSigmaZ);
00087 double T = tmp_sigt + fTimeOffset;
00088
00089 if ( fVertex == 0 ) fVertex = new HepMC::FourVector();
00090 fVertex->set(X,Y,Z,T);
00091
00092 return fVertex;
00093 }
00094
00095 double BetafuncEvtVtxGenerator::BetaFunction(double z, double z0)
00096 {
00097 return sqrt(femittance*(fbetastar+(((z-z0)*(z-z0))/fbetastar)));
00098
00099 }
00100
00101
00102 void BetafuncEvtVtxGenerator::sigmaZ(double s)
00103 {
00104 if (s>=0 ) {
00105 fSigmaZ=s;
00106 }
00107 else {
00108 throw cms::Exception("LogicError")
00109 << "Error in BetafuncEvtVtxGenerator::sigmaZ: "
00110 << "Illegal resolution in Z (negative)";
00111 }
00112 }
00113
00114 TMatrixD* BetafuncEvtVtxGenerator::GetInvLorentzBoost() {
00115
00116
00117
00118
00119 if (boost_ != 0 ) return boost_;
00120
00121
00122
00123 TMatrixD tmpboost(4,4);
00124
00125
00126
00127
00128
00129
00130
00131 tmpboost(0,0) = 1./cos(phi_);
00132 tmpboost(0,1) = - cos(alpha_)*sin(phi_);
00133 tmpboost(0,2) = - tan(phi_)*sin(phi_);
00134 tmpboost(0,3) = - sin(alpha_)*sin(phi_);
00135 tmpboost(1,0) = - cos(alpha_)*tan(phi_);
00136 tmpboost(1,1) = 1.;
00137 tmpboost(1,2) = cos(alpha_)*tan(phi_);
00138 tmpboost(1,3) = 0.;
00139 tmpboost(2,0) = 0.;
00140 tmpboost(2,1) = - cos(alpha_)*sin(phi_);
00141 tmpboost(2,2) = cos(phi_);
00142 tmpboost(2,3) = - sin(alpha_)*sin(phi_);
00143 tmpboost(3,0) = - sin(alpha_)*tan(phi_);
00144 tmpboost(3,1) = 0.;
00145 tmpboost(3,2) = sin(alpha_)*tan(phi_);
00146 tmpboost(3,3) = 1.;
00147
00148 tmpboost.Invert();
00149 boost_ = new TMatrixD(tmpboost);
00150
00151
00152 return boost_;
00153 }