-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathGaussEvtVtxGenerator.cc
74 lines (62 loc) · 2.6 KB
/
GaussEvtVtxGenerator.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "IOMC/EventVertexGenerators/interface/GaussEvtVtxGenerator.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "CLHEP/Random/RandGaussQ.h"
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include "CLHEP/Units/GlobalPhysicalConstants.h"
//#include "CLHEP/Vector/ThreeVector.h"
#include "HepMC/SimpleVector.h"
GaussEvtVtxGenerator::GaussEvtVtxGenerator(const edm::ParameterSet& p) : BaseEvtVtxGenerator(p) {
fMeanX = p.getParameter<double>("MeanX") * cm;
fMeanY = p.getParameter<double>("MeanY") * cm;
fMeanZ = p.getParameter<double>("MeanZ") * cm;
fSigmaX = p.getParameter<double>("SigmaX") * cm;
fSigmaY = p.getParameter<double>("SigmaY") * cm;
fSigmaZ = p.getParameter<double>("SigmaZ") * cm;
fTimeOffset = p.getParameter<double>("TimeOffset") * ns * c_light;
if (fSigmaX < 0) {
throw cms::Exception("Configuration") << "Error in GaussEvtVtxGenerator: "
<< "Illegal resolution in X (SigmaX is negative)";
}
if (fSigmaY < 0) {
throw cms::Exception("Configuration") << "Error in GaussEvtVtxGenerator: "
<< "Illegal resolution in Y (SigmaY is negative)";
}
if (fSigmaZ < 0) {
throw cms::Exception("Configuration") << "Error in GaussEvtVtxGenerator: "
<< "Illegal resolution in Z (SigmaZ is negative)";
}
}
GaussEvtVtxGenerator::~GaussEvtVtxGenerator() {}
HepMC::FourVector GaussEvtVtxGenerator::newVertex(CLHEP::HepRandomEngine* engine) const {
double X, Y, Z, T;
X = CLHEP::RandGaussQ::shoot(engine, fMeanX, fSigmaX);
Y = CLHEP::RandGaussQ::shoot(engine, fMeanY, fSigmaY);
Z = CLHEP::RandGaussQ::shoot(engine, fMeanZ, fSigmaZ);
T = CLHEP::RandGaussQ::shoot(engine, fTimeOffset, fSigmaZ);
return HepMC::FourVector(X, Y, Z, T);
}
void GaussEvtVtxGenerator::sigmaX(double s) {
if (s >= 0) {
fSigmaX = s;
} else {
throw cms::Exception("LogicError") << "Error in GaussEvtVtxGenerator::sigmaX: "
<< "Illegal resolution in X (negative)";
}
}
void GaussEvtVtxGenerator::sigmaY(double s) {
if (s >= 0) {
fSigmaY = s;
} else {
throw cms::Exception("LogicError") << "Error in GaussEvtVtxGenerator::sigmaY: "
<< "Illegal resolution in Y (negative)";
}
}
void GaussEvtVtxGenerator::sigmaZ(double s) {
if (s >= 0) {
fSigmaZ = s;
} else {
throw cms::Exception("LogicError") << "Error in GaussEvtVtxGenerator::sigmaZ: "
<< "Illegal resolution in Z (negative)";
}
}