test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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) {
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  //if (fVertex == 0) fVertex = new CLHEP::Hep3Vector;
55  //fVertex->set(aX,aY,aZ);
56  if ( fVertex == 0 ) fVertex = new HepMC::FourVector() ;
57  fVertex->set(aX,aY,aZ,aT+fTimeOffset);
58 
59  return fVertex;
60 }
61 
63 {
64  fMinX = min;
65 }
66 
68 {
69  fMinY = min;
70 }
71 
73 {
74  fMinZ = min;
75 }
76 
78 {
79  fMaxX = max;
80 }
81 
83 {
84  fMaxY = max;
85 }
86 
88 {
89  fMaxZ = max;
90 }
T getParameter(std::string const &) const
HepMC::FourVector * fVertex
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
virtual HepMC::FourVector * newVertex(CLHEP::HepRandomEngine *)
return a new event vertex
void maxY(double m=0)
set max in Y in cm