File indexing completed on 2023-03-17 11:10:13
0001
0002
0003 #include "IOMC/EventVertexGenerators/interface/GaussEvtVtxGenerator.h"
0004 #include "FWCore/Utilities/interface/Exception.h"
0005
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007
0008 #include "CLHEP/Random/RandGaussQ.h"
0009 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0010 #include "CLHEP/Units/GlobalPhysicalConstants.h"
0011
0012 #include "HepMC/SimpleVector.h"
0013
0014 GaussEvtVtxGenerator::GaussEvtVtxGenerator(const edm::ParameterSet& p) : BaseEvtVtxGenerator(p) {
0015 fMeanX = p.getParameter<double>("MeanX") * cm;
0016 fMeanY = p.getParameter<double>("MeanY") * cm;
0017 fMeanZ = p.getParameter<double>("MeanZ") * cm;
0018 fSigmaX = p.getParameter<double>("SigmaX") * cm;
0019 fSigmaY = p.getParameter<double>("SigmaY") * cm;
0020 fSigmaZ = p.getParameter<double>("SigmaZ") * cm;
0021 fTimeOffset = p.getParameter<double>("TimeOffset") * ns * c_light;
0022
0023 if (fSigmaX < 0) {
0024 throw cms::Exception("Configuration") << "Error in GaussEvtVtxGenerator: "
0025 << "Illegal resolution in X (SigmaX is negative)";
0026 }
0027 if (fSigmaY < 0) {
0028 throw cms::Exception("Configuration") << "Error in GaussEvtVtxGenerator: "
0029 << "Illegal resolution in Y (SigmaY is negative)";
0030 }
0031 if (fSigmaZ < 0) {
0032 throw cms::Exception("Configuration") << "Error in GaussEvtVtxGenerator: "
0033 << "Illegal resolution in Z (SigmaZ is negative)";
0034 }
0035 }
0036
0037 GaussEvtVtxGenerator::~GaussEvtVtxGenerator() {}
0038
0039 HepMC::FourVector GaussEvtVtxGenerator::newVertex(CLHEP::HepRandomEngine* engine) const {
0040 double X, Y, Z, T;
0041 X = CLHEP::RandGaussQ::shoot(engine, fMeanX, fSigmaX);
0042 Y = CLHEP::RandGaussQ::shoot(engine, fMeanY, fSigmaY);
0043 Z = CLHEP::RandGaussQ::shoot(engine, fMeanZ, fSigmaZ);
0044 T = CLHEP::RandGaussQ::shoot(engine, fTimeOffset, fSigmaZ);
0045
0046 return HepMC::FourVector(X, Y, Z, T);
0047 }
0048
0049 void GaussEvtVtxGenerator::sigmaX(double s) {
0050 if (s >= 0) {
0051 fSigmaX = s;
0052 } else {
0053 throw cms::Exception("LogicError") << "Error in GaussEvtVtxGenerator::sigmaX: "
0054 << "Illegal resolution in X (negative)";
0055 }
0056 }
0057
0058 void GaussEvtVtxGenerator::sigmaY(double s) {
0059 if (s >= 0) {
0060 fSigmaY = s;
0061 } else {
0062 throw cms::Exception("LogicError") << "Error in GaussEvtVtxGenerator::sigmaY: "
0063 << "Illegal resolution in Y (negative)";
0064 }
0065 }
0066
0067 void GaussEvtVtxGenerator::sigmaZ(double s) {
0068 if (s >= 0) {
0069 fSigmaZ = s;
0070 } else {
0071 throw cms::Exception("LogicError") << "Error in GaussEvtVtxGenerator::sigmaZ: "
0072 << "Illegal resolution in Z (negative)";
0073 }
0074 }