1-
2-
31#include " IOMC/EventVertexGenerators/interface/FlatEvtVtxGenerator.h"
42#include " FWCore/Utilities/interface/Exception.h"
53
1210
1311using CLHEP ::cm;
1412using CLHEP ::ns;
13+ using CLHEP ::radian;
1514
1615FlatEvtVtxGenerator::FlatEvtVtxGenerator (const edm::ParameterSet& p) : BaseEvtVtxGenerator(p) {
17- fMinX = p.getParameter <double >(" MinX" ) * cm;
18- fMinY = p.getParameter <double >(" MinY" ) * cm;
19- fMinZ = p.getParameter <double >(" MinZ" ) * cm;
20- fMaxX = p.getParameter <double >(" MaxX" ) * cm;
21- fMaxY = p.getParameter <double >(" MaxY" ) * cm;
16+ fFixedR = p.getParameter <bool >(" FixedR" );
17+ if (fFixedR ) {
18+ fMaxR = p.getParameter <double >(" MaxR" ) * cm;
19+ fMinR = p.getParameter <double >(" MinR" ) * cm;
20+ fMaxPhi = p.getParameter <double >(" MaxPhi" ) * radian;
21+ fMinPhi = p.getParameter <double >(" MinPhi" ) * radian;
22+ } else {
23+ fMinX = p.getParameter <double >(" MinX" ) * cm;
24+ fMaxX = p.getParameter <double >(" MaxX" ) * cm;
25+ fMinY = p.getParameter <double >(" MinY" ) * cm;
26+ fMaxY = p.getParameter <double >(" MaxY" ) * cm;
27+ }
2228 fMaxZ = p.getParameter <double >(" MaxZ" ) * cm;
29+ fMinZ = p.getParameter <double >(" MinZ" ) * cm;
2330 fMinT = p.getParameter <double >(" MinT" ) * ns * c_light;
2431 fMaxT = p.getParameter <double >(" MaxT" ) * ns * c_light;
2532
@@ -39,6 +46,14 @@ FlatEvtVtxGenerator::FlatEvtVtxGenerator(const edm::ParameterSet& p) : BaseEvtVt
3946 throw cms::Exception (" Configuration" ) << " Error in FlatEvtVtxGenerator: "
4047 << " MinT is greater than MaxT" ;
4148 }
49+ if (fMinR > fMaxR ) {
50+ throw cms::Exception (" Configuration" ) << " Error in FlatEvtVtxGenerator: "
51+ << " MinR is greater than MaxR" ;
52+ }
53+ if (fMinPhi > fMaxPhi ) {
54+ throw cms::Exception (" Configuration" ) << " Error in FlatEvtVtxGenerator: "
55+ << " MinPhi is greater than MaxPhi" ;
56+ }
4257 edm::LogVerbatim (" FlatEvtVtx" ) << " FlatEvtVtxGenerator Initialized with x[" << fMinX << " :" << fMaxX << " ] cm; y["
4358 << fMinY << " :" << fMaxY << " ] cm; z[" << fMinZ << " :" << fMaxZ << " ] cm; t[" << fMinT
4459 << " :" << fMaxT << " ]" ;
@@ -48,8 +63,15 @@ FlatEvtVtxGenerator::~FlatEvtVtxGenerator() {}
4863
4964ROOT ::Math::XYZTVector FlatEvtVtxGenerator::vertexShift (CLHEP ::HepRandomEngine* engine) const {
5065 double aX, aY, aZ, aT;
51- aX = CLHEP::RandFlat::shoot (engine, fMinX , fMaxX );
52- aY = CLHEP::RandFlat::shoot (engine, fMinY , fMaxY );
66+ if (fFixedR ) {
67+ double aR = CLHEP::RandFlat::shoot (engine, fMinR , fMaxR );
68+ double aPhi = CLHEP::RandFlat::shoot (engine, fMinPhi , fMaxPhi );
69+ aX = aR * std::cos (aPhi);
70+ aY = aR * std::sin (aPhi);
71+ } else {
72+ aX = CLHEP::RandFlat::shoot (engine, fMinX , fMaxX );
73+ aY = CLHEP::RandFlat::shoot (engine, fMinY , fMaxY );
74+ }
5375 aZ = CLHEP::RandFlat::shoot (engine, fMinZ , fMaxZ );
5476 aT = CLHEP::RandFlat::shoot (engine, fMinT , fMaxT );
5577
@@ -59,14 +81,22 @@ ROOT::Math::XYZTVector FlatEvtVtxGenerator::vertexShift(CLHEP::HepRandomEngine*
5981 return ROOT::Math::XYZTVector (aX, aY, aZ, aT);
6082}
6183
62- void FlatEvtVtxGenerator::minX (double min) { fMinX = min; }
63-
64- void FlatEvtVtxGenerator::minY (double min) { fMinY = min; }
65-
66- void FlatEvtVtxGenerator::minZ (double min) { fMinZ = min; }
67-
68- void FlatEvtVtxGenerator::maxX (double max) { fMaxX = max; }
69-
70- void FlatEvtVtxGenerator::maxY (double max) { fMaxY = max; }
71-
72- void FlatEvtVtxGenerator::maxZ (double max) { fMaxZ = max; }
84+ void FlatEvtVtxGenerator::fillDescriptions (edm::ConfigurationDescriptions& descriptions) {
85+ edm::ParameterSetDescription desc;
86+ desc.add <double >(" MinX" , 0.0 )->setComment (" in cm" );
87+ desc.add <double >(" MaxX" , 0.001 )->setComment (" in cm" );
88+ desc.add <double >(" MinY" , 0.0 )->setComment (" in cm" );
89+ desc.add <double >(" MaxY" , 0.001 )->setComment (" in cm" );
90+ desc.add <double >(" MinZ" , 0.0 )->setComment (" in cm" );
91+ desc.add <double >(" MaxZ" , 0.001 )->setComment (" in cm" );
92+ desc.add <double >(" MinT" , 0.0 )->setComment (" in ns" );
93+ desc.add <double >(" MaxT" , 0.001 )->setComment (" in ns" );
94+ desc.add <bool >(" FixedR" , false );
95+ desc.add <double >(" MinR" , 0.0 )->setComment (" in cm" );
96+ desc.add <double >(" MaxR" , 0.001 )->setComment (" in cm" );
97+ desc.add <double >(" MinPhi" , -3.14159265359 )->setComment (" in radians" );
98+ desc.add <double >(" MaxPhi" , 3.14159265359 )->setComment (" in radians" );
99+ desc.add <edm::InputTag>(" src" );
100+ desc.add <bool >(" readDB" );
101+ descriptions.add (" FlatEvtVtxGenerator" , desc);
102+ }
0 commit comments