Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:07

0001 
0002 
0003 #include "IOMC/EventVertexGenerators/interface/FlatEvtVtxGenerator.h"
0004 #include "FWCore/Utilities/interface/Exception.h"
0005 
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 
0008 #include "CLHEP/Random/RandFlat.h"
0009 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0010 #include "CLHEP/Units/GlobalPhysicalConstants.h"
0011 //#include "CLHEP/Vector/ThreeVector.h"
0012 #include "HepMC/SimpleVector.h"
0013 
0014 FlatEvtVtxGenerator::FlatEvtVtxGenerator(const edm::ParameterSet& p) : BaseEvtVtxGenerator(p) {
0015   fMinX = p.getParameter<double>("MinX") * cm;
0016   fMinY = p.getParameter<double>("MinY") * cm;
0017   fMinZ = p.getParameter<double>("MinZ") * cm;
0018   fMaxX = p.getParameter<double>("MaxX") * cm;
0019   fMaxY = p.getParameter<double>("MaxY") * cm;
0020   fMaxZ = p.getParameter<double>("MaxZ") * cm;
0021   fMinT = p.getParameter<double>("MinT") * ns * c_light;
0022   fMaxT = p.getParameter<double>("MaxT") * ns * c_light;
0023 
0024   if (fMinX > fMaxX) {
0025     throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
0026                                           << "MinX is greater than MaxX";
0027   }
0028   if (fMinY > fMaxY) {
0029     throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
0030                                           << "MinY is greater than MaxY";
0031   }
0032   if (fMinZ > fMaxZ) {
0033     throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
0034                                           << "MinZ is greater than MaxZ";
0035   }
0036   if (fMinT > fMaxT) {
0037     throw cms::Exception("Configuration") << "Error in FlatEvtVtxGenerator: "
0038                                           << "MinT is greater than MaxT";
0039   }
0040 }
0041 
0042 FlatEvtVtxGenerator::~FlatEvtVtxGenerator() {}
0043 
0044 //Hep3Vector * FlatEvtVtxGenerator::newVertex() {
0045 HepMC::FourVector FlatEvtVtxGenerator::newVertex(CLHEP::HepRandomEngine* engine) const {
0046   double aX, aY, aZ, aT;
0047   aX = CLHEP::RandFlat::shoot(engine, fMinX, fMaxX);
0048   aY = CLHEP::RandFlat::shoot(engine, fMinY, fMaxY);
0049   aZ = CLHEP::RandFlat::shoot(engine, fMinZ, fMaxZ);
0050   aT = CLHEP::RandFlat::shoot(engine, fMinT, fMaxT);
0051 
0052   return HepMC::FourVector(aX, aY, aZ, aT);
0053 }
0054 
0055 void FlatEvtVtxGenerator::minX(double min) { fMinX = min; }
0056 
0057 void FlatEvtVtxGenerator::minY(double min) { fMinY = min; }
0058 
0059 void FlatEvtVtxGenerator::minZ(double min) { fMinZ = min; }
0060 
0061 void FlatEvtVtxGenerator::maxX(double max) { fMaxX = max; }
0062 
0063 void FlatEvtVtxGenerator::maxY(double max) { fMaxY = max; }
0064 
0065 void FlatEvtVtxGenerator::maxZ(double max) { fMaxZ = max; }