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/SystemOfUnits.h>
11 #include <CLHEP/Units/GlobalPhysicalConstants.h>
12 //#include "CLHEP/Vector/ThreeVector.h"
13 #include "HepMC/SimpleVector.h"
14 
15 using CLHEP::cm;
16 using CLHEP::ns;
17 
19  fMinX = p.getParameter<double>("MinX") * cm;
20  fMinY = p.getParameter<double>("MinY") * cm;
21  fMinZ = p.getParameter<double>("MinZ") * cm;
22  fMaxX = p.getParameter<double>("MaxX") * cm;
23  fMaxY = p.getParameter<double>("MaxY") * cm;
24  fMaxZ = p.getParameter<double>("MaxZ") * cm;
25  fMinT = p.getParameter<double>("MinT") * ns * c_light;
26  fMaxT = p.getParameter<double>("MaxT") * ns * c_light;
27 
28  if (fMinX > fMaxX) {
29  throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
30  << "MinX is greater than MaxX";
31  }
32  if (fMinY > fMaxY) {
33  throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
34  << "MinY is greater than MaxY";
35  }
36  if (fMinZ > fMaxZ) {
37  throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
38  << "MinZ is greater than MaxZ";
39  }
40  if (fMinT > fMaxT) {
41  throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
42  << "MinT is greater than MaxT";
43  }
44  edm::LogVerbatim("FlatEvtVtx") << "FlatEvtVtxGenerator Initialized with x[" << fMinX << ":" << fMaxX << "] cm; y["
45  << fMinY << ":" << fMaxY << "] cm; z[" << fMinZ << ":" << fMaxZ << "] cm; t[" << fMinT
46  << ":" << fMaxT << "]";
47 }
48 
50 
51 //Hep3Vector * FlatEvtVtxGenerator::newVertex() {
52 HepMC::FourVector FlatEvtVtxGenerator::newVertex(CLHEP::HepRandomEngine* engine) const {
53  double aX, aY, aZ, aT;
54  aX = CLHEP::RandFlat::shoot(engine, fMinX, fMaxX);
55  aY = CLHEP::RandFlat::shoot(engine, fMinY, fMaxY);
56  aZ = CLHEP::RandFlat::shoot(engine, fMinZ, fMaxZ);
57  aT = CLHEP::RandFlat::shoot(engine, fMinT, fMaxT);
58 
59  edm::LogVerbatim("FlatEvtVtx") << "FlatEvtVtxGenerator Vertex at [" << aX << ", " << aY << ", " << aZ << ", " << aT
60  << "]";
61 
62  return HepMC::FourVector(aX, aY, aZ, aT);
63 }
64 
66 
68 
70 
72 
74 
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