CMS 3D CMS Logo

FlatEvtVtxGenerator.cc
Go to the documentation of this file.
1 
2 
5 
7 
8 #include "CLHEP/Random/RandFlat.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  fMinX = p.getParameter<double>("MinX")*cm;
18  fMinY = p.getParameter<double>("MinY")*cm;
19  fMinZ = p.getParameter<double>("MinZ")*cm;
20  fMaxX = p.getParameter<double>("MaxX")*cm;
21  fMaxY = p.getParameter<double>("MaxY")*cm;
22  fMaxZ = p.getParameter<double>("MaxZ")*cm;
23  fMinT = p.getParameter<double>("MinT")*ns*c_light;
24  fMaxT = p.getParameter<double>("MaxT")*ns*c_light;
25 
26  if (fMinX > fMaxX) {
27  throw cms::Exception("Configuration")
28  << "Error in FlatEvtVtxGenerator: "
29  << "MinX is greater than MaxX";
30  }
31  if (fMinY > fMaxY) {
32  throw cms::Exception("Configuration")
33  << "Error in FlatEvtVtxGenerator: "
34  << "MinY is greater than MaxY";
35  }
36  if (fMinZ > fMaxZ) {
37  throw cms::Exception("Configuration")
38  << "Error in FlatEvtVtxGenerator: "
39  << "MinZ is greater than MaxZ";
40  }
41  if (fMinT > fMaxT) {
42  throw cms::Exception("Configuration")
43  << "Error in FlatEvtVtxGenerator: "
44  << "MinT is greater than MaxT";
45  }
46 }
47 
49 {
50 }
51 
52 //Hep3Vector * FlatEvtVtxGenerator::newVertex() {
53 HepMC::FourVector FlatEvtVtxGenerator::newVertex(CLHEP::HepRandomEngine* engine) const {
54  double aX,aY,aZ,aT;
55  aX = CLHEP::RandFlat::shoot(engine, fMinX, fMaxX);
56  aY = CLHEP::RandFlat::shoot(engine, fMinY, fMaxY);
57  aZ = CLHEP::RandFlat::shoot(engine, fMinZ, fMaxZ);
58  aT = CLHEP::RandFlat::shoot(engine, fMinT, fMaxT);
59 
60  return HepMC::FourVector(aX,aY,aZ,aT);
61 }
62 
64 {
65  fMinX = min;
66 }
67 
69 {
70  fMinY = min;
71 }
72 
74 {
75  fMinZ = min;
76 }
77 
79 {
80  fMaxX = max;
81 }
82 
84 {
85  fMaxY = max;
86 }
87 
89 {
90  fMaxZ = max;
91 }
T getParameter(std::string const &) const
void minZ(double m=0.0)
set min in Z in cm
T min(T a, T b)
Definition: MathUtil.h:58
void maxZ(double m=0)
set max in Z in cm
FlatEvtVtxGenerator(const edm::ParameterSet &p)
void minX(double m=0.0)
set min in X in cm
void minY(double m=0.0)
set min in Y in cm
void maxX(double m=0)
set max in X in cm
void maxY(double m=0)
set max in Y in cm
HepMC::FourVector newVertex(CLHEP::HepRandomEngine *) const override
return a new event vertex