File indexing completed on 2024-12-10 02:31:54
0001
0002
0003 #include "IOMC/EventVertexGenerators/interface/FlatEvtVtxGenerator.h"
0004 #include "FWCore/Utilities/interface/Exception.h"
0005
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008
0009 #include <CLHEP/Random/RandFlat.h>
0010 #include <CLHEP/Units/SystemOfUnits.h>
0011 #include <CLHEP/Units/GlobalPhysicalConstants.h>
0012
0013 using CLHEP::cm;
0014 using CLHEP::ns;
0015
0016 FlatEvtVtxGenerator::FlatEvtVtxGenerator(const edm::ParameterSet& p) : BaseEvtVtxGenerator(p) {
0017 fMinX = p.getParameter<double>("MinX") * cm;
0018 fMinY = p.getParameter<double>("MinY") * cm;
0019 fMinZ = p.getParameter<double>("MinZ") * cm;
0020 fMaxX = p.getParameter<double>("MaxX") * cm;
0021 fMaxY = p.getParameter<double>("MaxY") * cm;
0022 fMaxZ = p.getParameter<double>("MaxZ") * cm;
0023 fMinT = p.getParameter<double>("MinT") * ns * c_light;
0024 fMaxT = p.getParameter<double>("MaxT") * ns * c_light;
0025
0026 if (fMinX > fMaxX) {
0027 throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
0028 << "MinX is greater than MaxX";
0029 }
0030 if (fMinY > fMaxY) {
0031 throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
0032 << "MinY is greater than MaxY";
0033 }
0034 if (fMinZ > fMaxZ) {
0035 throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
0036 << "MinZ is greater than MaxZ";
0037 }
0038 if (fMinT > fMaxT) {
0039 throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
0040 << "MinT is greater than MaxT";
0041 }
0042 edm::LogVerbatim("FlatEvtVtx") << "FlatEvtVtxGenerator Initialized with x[" << fMinX << ":" << fMaxX << "] cm; y["
0043 << fMinY << ":" << fMaxY << "] cm; z[" << fMinZ << ":" << fMaxZ << "] cm; t[" << fMinT
0044 << ":" << fMaxT << "]";
0045 }
0046
0047 FlatEvtVtxGenerator::~FlatEvtVtxGenerator() {}
0048
0049 ROOT::Math::XYZTVector FlatEvtVtxGenerator::vertexShift(CLHEP::HepRandomEngine* engine) const {
0050 double aX, aY, aZ, aT;
0051 aX = CLHEP::RandFlat::shoot(engine, fMinX, fMaxX);
0052 aY = CLHEP::RandFlat::shoot(engine, fMinY, fMaxY);
0053 aZ = CLHEP::RandFlat::shoot(engine, fMinZ, fMaxZ);
0054 aT = CLHEP::RandFlat::shoot(engine, fMinT, fMaxT);
0055
0056 edm::LogVerbatim("FlatEvtVtx") << "FlatEvtVtxGenerator Vertex at [" << aX << ", " << aY << ", " << aZ << ", " << aT
0057 << "]";
0058
0059 return ROOT::Math::XYZTVector(aX, aY, aZ, aT);
0060 }
0061
0062 void FlatEvtVtxGenerator::minX(double min) { fMinX = min; }
0063
0064 void FlatEvtVtxGenerator::minY(double min) { fMinY = min; }
0065
0066 void FlatEvtVtxGenerator::minZ(double min) { fMinZ = min; }
0067
0068 void FlatEvtVtxGenerator::maxX(double max) { fMaxX = max; }
0069
0070 void FlatEvtVtxGenerator::maxY(double max) { fMaxY = max; }
0071
0072 void FlatEvtVtxGenerator::maxZ(double max) { fMaxZ = max; }