CMS 3D CMS Logo

GaussEvtVtxGenerator.cc
Go to the documentation of this file.
1 
2 
5 
7 
8 #include "CLHEP/Random/RandGaussQ.h"
9 #include "CLHEP/Units/GlobalSystemOfUnits.h"
10 #include "CLHEP/Units/GlobalPhysicalConstants.h"
11 //#include "CLHEP/Vector/ThreeVector.h"
12 #include "HepMC/SimpleVector.h"
13 
16 {
17  fMeanX = p.getParameter<double>("MeanX")*cm;
18  fMeanY = p.getParameter<double>("MeanY")*cm;
19  fMeanZ = p.getParameter<double>("MeanZ")*cm;
20  fSigmaX = p.getParameter<double>("SigmaX")*cm;
21  fSigmaY = p.getParameter<double>("SigmaY")*cm;
22  fSigmaZ = p.getParameter<double>("SigmaZ")*cm;
23  fTimeOffset = p.getParameter<double>("TimeOffset")*ns*c_light;
24 
25  if (fSigmaX < 0) {
26  throw cms::Exception("Configuration")
27  << "Error in GaussEvtVtxGenerator: "
28  << "Illegal resolution in X (SigmaX is negative)";
29  }
30  if (fSigmaY < 0) {
31  throw cms::Exception("Configuration")
32  << "Error in GaussEvtVtxGenerator: "
33  << "Illegal resolution in Y (SigmaY is negative)";
34  }
35  if (fSigmaZ < 0) {
36  throw cms::Exception("Configuration")
37  << "Error in GaussEvtVtxGenerator: "
38  << "Illegal resolution in Z (SigmaZ is negative)";
39  }
40 }
41 
43 {
44 }
45 
46 
47 HepMC::FourVector GaussEvtVtxGenerator::newVertex(CLHEP::HepRandomEngine* engine) const {
48  double X,Y,Z,T;
49  X = CLHEP::RandGaussQ::shoot(engine, fMeanX, fSigmaX);
50  Y = CLHEP::RandGaussQ::shoot(engine, fMeanY, fSigmaY);
51  Z = CLHEP::RandGaussQ::shoot(engine, fMeanZ, fSigmaZ);
52  T = CLHEP::RandGaussQ::shoot(engine, fTimeOffset, fSigmaZ);
53 
54  return HepMC::FourVector( X, Y, Z, T);
55 }
56 
58 {
59  if (s>=0 ) {
60  fSigmaX=s;
61  }
62  else {
63  throw cms::Exception("LogicError")
64  << "Error in GaussEvtVtxGenerator::sigmaX: "
65  << "Illegal resolution in X (negative)";
66  }
67 }
68 
70 {
71  if (s>=0 ) {
72  fSigmaY=s;
73  }
74  else {
75  throw cms::Exception("LogicError")
76  << "Error in GaussEvtVtxGenerator::sigmaY: "
77  << "Illegal resolution in Y (negative)";
78  }
79 }
80 
82 {
83  if (s>=0 ) {
84  fSigmaZ=s;
85  }
86  else {
87  throw cms::Exception("LogicError")
88  << "Error in GaussEvtVtxGenerator::sigmaZ: "
89  << "Illegal resolution in Z (negative)";
90  }
91 }
T getParameter(std::string const &) const
void sigmaY(double s=1.0)
set resolution in Y in cm
#define X(str)
Definition: MuonsGrabber.cc:48
void sigmaX(double s=1.0)
set resolution in X in cm
GaussEvtVtxGenerator(const edm::ParameterSet &p)
virtual HepMC::FourVector newVertex(CLHEP::HepRandomEngine *) const override
return a new event vertex
void sigmaZ(double s=1.0)
set resolution in Z in cm
long double T