CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
15  fMeanX = p.getParameter<double>("MeanX") * cm;
16  fMeanY = p.getParameter<double>("MeanY") * cm;
17  fMeanZ = p.getParameter<double>("MeanZ") * cm;
18  fSigmaX = p.getParameter<double>("SigmaX") * cm;
19  fSigmaY = p.getParameter<double>("SigmaY") * cm;
20  fSigmaZ = p.getParameter<double>("SigmaZ") * cm;
21  fTimeOffset = p.getParameter<double>("TimeOffset") * ns * c_light;
22 
23  if (fSigmaX < 0) {
24  throw cms::Exception("Configuration") << "Error in GaussEvtVtxGenerator: "
25  << "Illegal resolution in X (SigmaX is negative)";
26  }
27  if (fSigmaY < 0) {
28  throw cms::Exception("Configuration") << "Error in GaussEvtVtxGenerator: "
29  << "Illegal resolution in Y (SigmaY is negative)";
30  }
31  if (fSigmaZ < 0) {
32  throw cms::Exception("Configuration") << "Error in GaussEvtVtxGenerator: "
33  << "Illegal resolution in Z (SigmaZ is negative)";
34  }
35 }
36 
38 
39 HepMC::FourVector GaussEvtVtxGenerator::newVertex(CLHEP::HepRandomEngine* engine) const {
40  double X, Y, Z, T;
41  X = CLHEP::RandGaussQ::shoot(engine, fMeanX, fSigmaX);
42  Y = CLHEP::RandGaussQ::shoot(engine, fMeanY, fSigmaY);
43  Z = CLHEP::RandGaussQ::shoot(engine, fMeanZ, fSigmaZ);
44  T = CLHEP::RandGaussQ::shoot(engine, fTimeOffset, fSigmaZ);
45 
46  return HepMC::FourVector(X, Y, Z, T);
47 }
48 
50  if (s >= 0) {
51  fSigmaX = s;
52  } else {
53  throw cms::Exception("LogicError") << "Error in GaussEvtVtxGenerator::sigmaX: "
54  << "Illegal resolution in X (negative)";
55  }
56 }
57 
59  if (s >= 0) {
60  fSigmaY = s;
61  } else {
62  throw cms::Exception("LogicError") << "Error in GaussEvtVtxGenerator::sigmaY: "
63  << "Illegal resolution in Y (negative)";
64  }
65 }
66 
68  if (s >= 0) {
69  fSigmaZ = s;
70  } else {
71  throw cms::Exception("LogicError") << "Error in GaussEvtVtxGenerator::sigmaZ: "
72  << "Illegal resolution in Z (negative)";
73  }
74 }
void sigmaY(double s=1.0)
set resolution in Y in cm
#define X(str)
Definition: MuonsGrabber.cc:38
void sigmaX(double s=1.0)
set resolution in X in cm
GaussEvtVtxGenerator(const edm::ParameterSet &p)
HepMC::FourVector newVertex(CLHEP::HepRandomEngine *) const override
return a new event vertex
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void sigmaZ(double s=1.0)
set resolution in Z in cm
long double T