CMS 3D CMS Logo

FlatEvtVtxGenerator.cc
Go to the documentation of this file.
1 
2 
5 
8 
9 #include "CLHEP/Random/RandFlat.h"
10 #include "CLHEP/Units/GlobalSystemOfUnits.h"
11 #include "CLHEP/Units/GlobalPhysicalConstants.h"
12 //#include "CLHEP/Vector/ThreeVector.h"
13 #include "HepMC/SimpleVector.h"
14 
16  fMinX = p.getParameter<double>("MinX") * cm;
17  fMinY = p.getParameter<double>("MinY") * cm;
18  fMinZ = p.getParameter<double>("MinZ") * cm;
19  fMaxX = p.getParameter<double>("MaxX") * cm;
20  fMaxY = p.getParameter<double>("MaxY") * cm;
21  fMaxZ = p.getParameter<double>("MaxZ") * cm;
22  fMinT = p.getParameter<double>("MinT") * ns * c_light;
23  fMaxT = p.getParameter<double>("MaxT") * ns * c_light;
24 
25  if (fMinX > fMaxX) {
26  throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
27  << "MinX is greater than MaxX";
28  }
29  if (fMinY > fMaxY) {
30  throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
31  << "MinY is greater than MaxY";
32  }
33  if (fMinZ > fMaxZ) {
34  throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
35  << "MinZ is greater than MaxZ";
36  }
37  if (fMinT > fMaxT) {
38  throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
39  << "MinT is greater than MaxT";
40  }
41  edm::LogVerbatim("FlatEvtVtx") << "FlatEvtVtxGenerator Initialized with x[" << fMinX << ":" << fMaxX << "] cm; y["
42  << fMinY << ":" << fMaxY << "] cm; z[" << fMinZ << ":" << fMaxZ << "] cm; t[" << fMinT
43  << ":" << fMaxT << "]";
44 }
45 
47 
48 //Hep3Vector * FlatEvtVtxGenerator::newVertex() {
49 HepMC::FourVector FlatEvtVtxGenerator::newVertex(CLHEP::HepRandomEngine* engine) const {
50  double aX, aY, aZ, aT;
51  aX = CLHEP::RandFlat::shoot(engine, fMinX, fMaxX);
52  aY = CLHEP::RandFlat::shoot(engine, fMinY, fMaxY);
53  aZ = CLHEP::RandFlat::shoot(engine, fMinZ, fMaxZ);
54  aT = CLHEP::RandFlat::shoot(engine, fMinT, fMaxT);
55 
56  edm::LogVerbatim("FlatEvtVtx") << "FlatEvtVtxGenerator Vertex at [" << aX << ", " << aY << ", " << aZ << ", " << aT
57  << "]";
58 
59  return HepMC::FourVector(aX, aY, aZ, aT);
60 }
61 
63 
65 
67 
69 
71 
Log< level::Info, true > LogVerbatim
void minZ(double m=0.0)
set min in Z in cm
HepMC::FourVector newVertex(CLHEP::HepRandomEngine *) const override
return a new event vertex
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