test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
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 //Hep3Vector* GaussEvtVtxGenerator::newVertex() {
48 HepMC::FourVector* GaussEvtVtxGenerator::newVertex(CLHEP::HepRandomEngine* engine) {
49  double X,Y,Z,T;
50  X = CLHEP::RandGaussQ::shoot(engine, fMeanX, fSigmaX);
51  Y = CLHEP::RandGaussQ::shoot(engine, fMeanY, fSigmaY);
52  Z = CLHEP::RandGaussQ::shoot(engine, fMeanZ, fSigmaZ);
53  T = CLHEP::RandGaussQ::shoot(engine, fTimeOffset, fSigmaZ);
54 
55  //if (fVertex == 0) fVertex = new CLHEP::Hep3Vector;
56  if ( fVertex == 0 ) fVertex = new HepMC::FourVector() ;
57  fVertex->set( X, Y, Z, T);
58 
59  return fVertex;
60 }
61 
63 {
64  if (s>=0 ) {
65  fSigmaX=s;
66  }
67  else {
68  throw cms::Exception("LogicError")
69  << "Error in GaussEvtVtxGenerator::sigmaX: "
70  << "Illegal resolution in X (negative)";
71  }
72 }
73 
75 {
76  if (s>=0 ) {
77  fSigmaY=s;
78  }
79  else {
80  throw cms::Exception("LogicError")
81  << "Error in GaussEvtVtxGenerator::sigmaY: "
82  << "Illegal resolution in Y (negative)";
83  }
84 }
85 
87 {
88  if (s>=0 ) {
89  fSigmaZ=s;
90  }
91  else {
92  throw cms::Exception("LogicError")
93  << "Error in GaussEvtVtxGenerator::sigmaZ: "
94  << "Illegal resolution in Z (negative)";
95  }
96 }
const double Z[kNumberCalorimeter]
T getParameter(std::string const &) const
void sigmaY(double s=1.0)
set resolution in Y in cm
HepMC::FourVector * fVertex
#define X(str)
Definition: MuonsGrabber.cc:48
void sigmaX(double s=1.0)
set resolution in X in cm
virtual HepMC::FourVector * newVertex(CLHEP::HepRandomEngine *)
return a new event vertex
GaussEvtVtxGenerator(const edm::ParameterSet &p)
void sigmaZ(double s=1.0)
set resolution in Z in cm
long double T