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  fTimeOffset = p.getParameter<double>("TimeOffset")*ns*c_light;
24 
25  if (fMinX > fMaxX) {
26  throw cms::Exception("Configuration")
27  << "Error in FlatEvtVtxGenerator: "
28  << "MinX is greater than MaxX";
29  }
30  if (fMinY > fMaxY) {
31  throw cms::Exception("Configuration")
32  << "Error in FlatEvtVtxGenerator: "
33  << "MinY is greater than MaxY";
34  }
35  if (fMinZ > fMaxZ) {
36  throw cms::Exception("Configuration")
37  << "Error in FlatEvtVtxGenerator: "
38  << "MinZ is greater than MaxZ";
39  }
40 }
41 
43 {
44 }
45 
46 //Hep3Vector * FlatEvtVtxGenerator::newVertex() {
47 HepMC::FourVector FlatEvtVtxGenerator::newVertex(CLHEP::HepRandomEngine* engine) const {
48  double aX,aY,aZ,aT;
49  aX = CLHEP::RandFlat::shoot(engine, fMinX, fMaxX);
50  aY = CLHEP::RandFlat::shoot(engine, fMinY, fMaxY);
51  aZ = CLHEP::RandFlat::shoot(engine, fMinZ, fMaxZ);
52  aT = CLHEP::RandFlat::shoot(engine, fMinZ, fMaxZ);
53 
54  return HepMC::FourVector(aX,aY,aZ,aT+fTimeOffset);
55 }
56 
58 {
59  fMinX = min;
60 }
61 
63 {
64  fMinY = min;
65 }
66 
68 {
69  fMinZ = min;
70 }
71 
73 {
74  fMaxX = max;
75 }
76 
78 {
79  fMaxY = max;
80 }
81 
83 {
84  fMaxZ = max;
85 }
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
virtual HepMC::FourVector newVertex(CLHEP::HepRandomEngine *) const override
return a new event vertex