CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
BeamProfileVtxGenerator Class Reference

#include <BeamProfileVtxGenerator.h>

Inheritance diagram for BeamProfileVtxGenerator:
BaseEvtVtxGenerator edm::stream::EDProducer<>

Public Member Functions

void beamPos (double m=0)
 set mean in Z in cm More...
 
 BeamProfileVtxGenerator (const edm::ParameterSet &p)
 
void eta (double m=0)
 set eta More...
 
TMatrixD const * GetInvLorentzBoost () const override
 
void meanX (double m=0)
 set mean in X in cm More...
 
void meanY (double m=0)
 set mean in Y in cm More...
 
HepMC::FourVector newVertex (CLHEP::HepRandomEngine *) const override
 return a new event vertex More...
 
void phi (double m=0)
 set phi in radian More...
 
void psi (double m=999)
 set psi in radian More...
 
void setType (bool m=true)
 set type More...
 
void sigmaX (double s=1.0)
 set resolution in X in cm More...
 
void sigmaY (double s=1.0)
 set resolution in Y in cm More...
 
 ~BeamProfileVtxGenerator () override
 
- Public Member Functions inherited from BaseEvtVtxGenerator
 BaseEvtVtxGenerator (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~BaseEvtVtxGenerator () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

 BeamProfileVtxGenerator (const BeamProfileVtxGenerator &p)=delete
 
BeamProfileVtxGeneratoroperator= (const BeamProfileVtxGenerator &rhs)=delete
 

Private Attributes

std::vector< double > fdistn
 
double fEta
 
bool ffile
 
double fMeanX
 
double fMeanY
 
double fMeanZ
 
double fPhi
 
double fPsi
 
double fSigmaX
 
double fSigmaY
 
double fTheta
 
double fTimeOffset
 
bool fType
 
int nBinx
 
int nBiny
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 19 of file BeamProfileVtxGenerator.h.

Constructor & Destructor Documentation

◆ BeamProfileVtxGenerator() [1/2]

BeamProfileVtxGenerator::BeamProfileVtxGenerator ( const edm::ParameterSet p)

Definition at line 19 of file BeamProfileVtxGenerator.cc.

20  meanX(p.getParameter<double>("BeamMeanX") * cm);
21  meanY(p.getParameter<double>("BeamMeanY") * cm);
22  beamPos(p.getParameter<double>("BeamPosition") * cm);
23  sigmaX(p.getParameter<double>("BeamSigmaX") * cm);
24  sigmaY(p.getParameter<double>("BeamSigmaY") * cm);
25  double fMinEta = p.getParameter<double>("MinEta");
26  double fMaxEta = p.getParameter<double>("MaxEta");
27  double fMinPhi = p.getParameter<double>("MinPhi");
28  double fMaxPhi = p.getParameter<double>("MaxPhi");
29  eta(0.5 * (fMinEta + fMaxEta));
30  phi(0.5 * (fMinPhi + fMaxPhi));
31  psi(p.getParameter<double>("Psi"));
32  nBinx = p.getParameter<int>("BinX");
33  nBiny = p.getParameter<int>("BinY");
34  ffile = p.getParameter<bool>("UseFile");
35  fTimeOffset = p.getParameter<double>("TimeOffset") * ns * c_light;
36 
37  if (ffile) {
38  std::string file = p.getParameter<std::string>("File");
39  std::ifstream is(file.c_str(), std::ios::in);
40  if (is) {
41  double elem, sum = 0;
42  while (!is.eof()) {
43  is >> elem;
44  fdistn.push_back(elem);
45  sum += elem;
46  }
47  if (((int)(fdistn.size())) >= nBinx * nBiny) {
48  double last = 0;
49  for (unsigned int i = 0; i < fdistn.size(); i++) {
50  fdistn[i] /= sum;
51  fdistn[i] += last;
52  last = fdistn[i];
53  }
54  setType(false);
55  } else {
56  ffile = false;
57  }
58  } else {
59  ffile = false;
60  }
61  }
62  if (!ffile) {
63  setType(p.getParameter<bool>("GaussianProfile"));
64  }
65 
66  edm::LogInfo("VertexGenerator") << "BeamProfileVtxGenerator: with "
67  << "beam along eta = " << fEta << " (Theta = " << fTheta / deg
68  << ") phi = " << fPhi / deg << ") psi = " << fPsi / deg << " centred at (" << fMeanX
69  << ", " << fMeanY << ", " << fMeanZ << ") "
70  << "and spread (" << fSigmaX << ", " << fSigmaY << ") of type Gaussian = " << fType
71  << " use file " << ffile;
72  if (ffile)
73  edm::LogInfo("VertexGenerator") << "With " << nBinx << " bins "
74  << " along X and " << nBiny << " bins along Y";
75 }

References beamPos(), eta(), fdistn, fEta, ffile, geometryDiff::file, fMeanX, fMeanY, fMeanZ, fPhi, fPsi, fSigmaX, fSigmaY, fTheta, fTimeOffset, fType, mps_fire::i, recoMuon::in, dqmdumpme::last, meanX(), meanY(), nBinx, nBiny, AlCaHLTBitMon_ParallelJobs::p, phi(), psi(), setType(), sigmaX(), sigmaY(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~BeamProfileVtxGenerator()

BeamProfileVtxGenerator::~BeamProfileVtxGenerator ( )
override

Definition at line 77 of file BeamProfileVtxGenerator.cc.

77 {}

◆ BeamProfileVtxGenerator() [2/2]

BeamProfileVtxGenerator::BeamProfileVtxGenerator ( const BeamProfileVtxGenerator p)
privatedelete

Copy constructor

Member Function Documentation

◆ beamPos()

void BeamProfileVtxGenerator::beamPos ( double  m = 0)
inline

set mean in Z in cm

Definition at line 40 of file BeamProfileVtxGenerator.h.

40 { fMeanZ = m; }

References fMeanZ, and visualization-live-secondInstance_cfg::m.

Referenced by BeamProfileVtxGenerator().

◆ eta()

void BeamProfileVtxGenerator::eta ( double  m = 0)

set eta

Definition at line 179 of file BeamProfileVtxGenerator.cc.

179  {
180  fEta = s;
181  fTheta = 2.0 * atan(exp(-fEta));
182 }

References JetChargeProducer_cfi::exp, fEta, fTheta, and alignCSCRings::s.

Referenced by Particle.Particle::__str__(), BeamProfileVtxGenerator(), Jet.Jet::jetID(), and Jet.Jet::puJetId().

◆ GetInvLorentzBoost()

TMatrixD const* BeamProfileVtxGenerator::GetInvLorentzBoost ( ) const
inlineoverridevirtual

This method - and the comment - is a left-over from COBRA-OSCAR time : return the last generated event vertex. If no vertex has been generated yet, a NULL pointer is returned.

Implements BaseEvtVtxGenerator.

Definition at line 28 of file BeamProfileVtxGenerator.h.

28 { return nullptr; }

◆ meanX()

void BeamProfileVtxGenerator::meanX ( double  m = 0)
inline

set mean in X in cm

Definition at line 36 of file BeamProfileVtxGenerator.h.

36 { fMeanX = m; }

References fMeanX, and visualization-live-secondInstance_cfg::m.

Referenced by BeamProfileVtxGenerator().

◆ meanY()

void BeamProfileVtxGenerator::meanY ( double  m = 0)
inline

set mean in Y in cm

Definition at line 38 of file BeamProfileVtxGenerator.h.

38 { fMeanY = m; }

References fMeanY, and visualization-live-secondInstance_cfg::m.

Referenced by BeamProfileVtxGenerator().

◆ newVertex()

HepMC::FourVector BeamProfileVtxGenerator::newVertex ( CLHEP::HepRandomEngine *  engine) const
overridevirtual

return a new event vertex

Implements BaseEvtVtxGenerator.

Definition at line 80 of file BeamProfileVtxGenerator.cc.

80  {
81  double aX, aY;
82  if (ffile) {
83  double r1 = engine->flat();
84  int ixy = 0, ix, iy;
85  for (unsigned int i = 0; i < fdistn.size(); i++) {
86  if (r1 > fdistn[i])
87  ixy = i + 1;
88  }
89  if (ixy >= nBinx * nBiny) {
90  ix = nBinx - 1;
91  iy = nBiny - 1;
92  } else {
93  ix = ixy % nBinx;
94  iy = (ixy - ix) / nBinx;
95  }
96  aX = 0.5 * (2 * ix - nBinx + 2 * engine->flat()) * fSigmaX + fMeanX;
97  aY = 0.5 * (2 * iy - nBiny + 2 * engine->flat()) * fSigmaY + fMeanY;
98  } else {
99  if (fType) {
100  aX = fSigmaX * CLHEP::RandGaussQ::shoot(engine) + fMeanX;
101  aY = fSigmaY * CLHEP::RandGaussQ::shoot(engine) + fMeanY;
102  } else {
103  aX = CLHEP::RandFlat::shoot(engine, -0.5 * fSigmaX, 0.5 * fSigmaX) + fMeanX;
104  aY = CLHEP::RandFlat::shoot(engine, -0.5 * fSigmaY, 0.5 * fSigmaY) + fMeanY;
105  }
106  }
107 
108  double xp, yp, zp;
109  if (2. * M_PI < fabs(fPsi)) {
110  xp = -aX * cos(fTheta) * cos(fPhi) + aY * sin(fPhi) + fMeanZ * sin(fTheta) * cos(fPhi);
111  yp = -aX * cos(fTheta) * sin(fPhi) - aY * cos(fPhi) + fMeanZ * sin(fTheta) * sin(fPhi);
112  zp = aX * sin(fTheta) + fMeanZ * cos(fTheta);
113  } else // for endcap testbeam, use 3rd angle psi
114  {
115  const HepGeom::Vector3D<double> av(aX, aY, fMeanZ);
116 
117  /*
118  static const double kRadToDeg ( 180./M_PI ) ;
119  std::cout<<"theta = "<<std::setw(7) << std::setiosflags( std::ios::fixed ) << std::setprecision(5)
120  <<fTheta*kRadToDeg<<", phi="<<std::setw(7) << std::setiosflags( std::ios::fixed ) << std::setprecision(5)
121  << fPhi*kRadToDeg <<", PSI="<<std::setw(7) << std::setiosflags( std::ios::fixed ) << std::setprecision(5)
122  <<fPsi*kRadToDeg<<std::endl ;
123 */
124  const HepGeom::RotateZ3D R1(fPhi - M_PI);
125  const HepGeom::Point3D<double> xUnit(0, 1, 0);
126  const HepGeom::Point3D<double> zUnit(0, 0, 1);
127  const HepGeom::Transform3D RXRZ(HepGeom::Rotate3D(-fTheta, R1 * xUnit) * R1);
128  const HepGeom::Transform3D TRF(HepGeom::Rotate3D(fPsi, RXRZ * zUnit) * RXRZ);
129  /*
130  std::cout<<"\n\n$$$$$$$$$$$Transform="
131  <<" thetaZ = "<<std::setw(7) << std::setiosflags( std::ios::fixed ) << std::setprecision(5)
132  <<TRF.getRotation().thetaZ()*kRadToDeg
133  <<", phiZ = "<<std::setw(7) << std::setiosflags( std::ios::fixed ) << std::setprecision(5)
134  <<TRF.getRotation().phiZ()*kRadToDeg
135  <<", thetaY = "<<std::setw(7) << std::setiosflags( std::ios::fixed ) << std::setprecision(5)
136  <<TRF.getRotation().thetaY()*kRadToDeg
137  <<", phiY = "<<std::setw(7) << std::setiosflags( std::ios::fixed ) << std::setprecision(5)
138  <<TRF.getRotation().phiY()*kRadToDeg
139  <<", thetaX = "<<std::setw(7) << std::setiosflags( std::ios::fixed ) << std::setprecision(5)
140  <<TRF.getRotation().thetaX()*kRadToDeg
141  <<", phiX = "<<std::setw(7) << std::setiosflags( std::ios::fixed ) << std::setprecision(5)
142  <<TRF.getRotation().phiX()*kRadToDeg
143  <<std::setw(7) << std::setiosflags( std::ios::fixed ) << std::setprecision(5)
144  <<TRF.getTranslation()<<std::endl ;
145 */
146  const HepGeom::Vector3D<double> pv(TRF * av);
147 
148  xp = pv.x();
149  yp = pv.y();
150  zp = pv.z();
151  }
152 
153  LogDebug("VertexGenerator") << "BeamProfileVtxGenerator: Vertex created "
154  << "at (" << xp << ", " << yp << ", " << zp << ", " << fTimeOffset << ")";
155  return HepMC::FourVector(xp, yp, zp, fTimeOffset);
156  ;
157 }

References funct::cos(), fdistn, ffile, fMeanX, fMeanY, fMeanZ, fPhi, fPsi, fSigmaX, fSigmaY, fTheta, fTimeOffset, fType, mps_fire::i, LogDebug, M_PI, nBinx, nBiny, MetAnalyzer::pv(), diffTwoXMLs::r1, and funct::sin().

◆ operator=()

BeamProfileVtxGenerator& BeamProfileVtxGenerator::operator= ( const BeamProfileVtxGenerator rhs)
privatedelete

Copy assignment operator

◆ phi()

void BeamProfileVtxGenerator::phi ( double  m = 0)
inline

◆ psi()

void BeamProfileVtxGenerator::psi ( double  m = 999)
inline

set psi in radian

Definition at line 47 of file BeamProfileVtxGenerator.h.

47 { fPsi = m; }

References fPsi, and visualization-live-secondInstance_cfg::m.

Referenced by BeamProfileVtxGenerator().

◆ setType()

void BeamProfileVtxGenerator::setType ( bool  m = true)

set type

Definition at line 184 of file BeamProfileVtxGenerator.cc.

184 { fType = s; }

References fType, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

◆ sigmaX()

void BeamProfileVtxGenerator::sigmaX ( double  s = 1.0)

set resolution in X in cm

Definition at line 159 of file BeamProfileVtxGenerator.cc.

159  {
160  if (s >= 0) {
161  fSigmaX = s;
162  } else {
163  edm::LogWarning("VertexGenerator") << "Warning BeamProfileVtxGenerator:"
164  << " Illegal resolution in X " << s << "- set to default value 0 cm";
165  fSigmaX = 0;
166  }
167 }

References fSigmaX, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

◆ sigmaY()

void BeamProfileVtxGenerator::sigmaY ( double  s = 1.0)

set resolution in Y in cm

Definition at line 169 of file BeamProfileVtxGenerator.cc.

169  {
170  if (s >= 0) {
171  fSigmaY = s;
172  } else {
173  edm::LogWarning("VertexGenerator") << "Warning BeamProfileVtxGenerator:"
174  << " Illegal resolution in Y " << s << "- set to default value 0 cm";
175  fSigmaY = 0;
176  }
177 }

References fSigmaY, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

Member Data Documentation

◆ fdistn

std::vector<double> BeamProfileVtxGenerator::fdistn
private

Definition at line 66 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

◆ fEta

double BeamProfileVtxGenerator::fEta
private

Definition at line 60 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and eta().

◆ ffile

bool BeamProfileVtxGenerator::ffile
private

Definition at line 64 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

◆ fMeanX

double BeamProfileVtxGenerator::fMeanX
private

Definition at line 59 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), meanX(), and newVertex().

◆ fMeanY

double BeamProfileVtxGenerator::fMeanY
private

Definition at line 59 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), meanY(), and newVertex().

◆ fMeanZ

double BeamProfileVtxGenerator::fMeanZ
private

Definition at line 59 of file BeamProfileVtxGenerator.h.

Referenced by beamPos(), BeamProfileVtxGenerator(), and newVertex().

◆ fPhi

double BeamProfileVtxGenerator::fPhi
private

Definition at line 60 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), newVertex(), and phi().

◆ fPsi

double BeamProfileVtxGenerator::fPsi
private

Definition at line 62 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), newVertex(), and psi().

◆ fSigmaX

double BeamProfileVtxGenerator::fSigmaX
private

Definition at line 58 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), newVertex(), and sigmaX().

◆ fSigmaY

double BeamProfileVtxGenerator::fSigmaY
private

Definition at line 58 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), newVertex(), and sigmaY().

◆ fTheta

double BeamProfileVtxGenerator::fTheta
private

Definition at line 60 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), eta(), and newVertex().

◆ fTimeOffset

double BeamProfileVtxGenerator::fTimeOffset
private

Definition at line 67 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

◆ fType

bool BeamProfileVtxGenerator::fType
private

Definition at line 64 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), newVertex(), and setType().

◆ nBinx

int BeamProfileVtxGenerator::nBinx
private

Definition at line 65 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

◆ nBiny

int BeamProfileVtxGenerator::nBiny
private

Definition at line 65 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

mps_fire.i
i
Definition: mps_fire.py:428
BeamProfileVtxGenerator::psi
void psi(double m=999)
set psi in radian
Definition: BeamProfileVtxGenerator.h:47
BeamProfileVtxGenerator::eta
void eta(double m=0)
set eta
Definition: BeamProfileVtxGenerator.cc:179
BeamProfileVtxGenerator::fType
bool fType
Definition: BeamProfileVtxGenerator.h:64
BeamProfileVtxGenerator::fTheta
double fTheta
Definition: BeamProfileVtxGenerator.h:60
BeamProfileVtxGenerator::fMeanZ
double fMeanZ
Definition: BeamProfileVtxGenerator.h:59
BeamProfileVtxGenerator::fTimeOffset
double fTimeOffset
Definition: BeamProfileVtxGenerator.h:67
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
BeamProfileVtxGenerator::nBinx
int nBinx
Definition: BeamProfileVtxGenerator.h:65
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
BeamProfileVtxGenerator::beamPos
void beamPos(double m=0)
set mean in Z in cm
Definition: BeamProfileVtxGenerator.h:40
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
alignCSCRings.s
s
Definition: alignCSCRings.py:92
BeamProfileVtxGenerator::fdistn
std::vector< double > fdistn
Definition: BeamProfileVtxGenerator.h:66
dqmdumpme.last
last
Definition: dqmdumpme.py:56
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
BeamProfileVtxGenerator::fMeanY
double fMeanY
Definition: BeamProfileVtxGenerator.h:59
BeamProfileVtxGenerator::nBiny
int nBiny
Definition: BeamProfileVtxGenerator.h:65
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:78
BeamProfileVtxGenerator::sigmaY
void sigmaY(double s=1.0)
set resolution in Y in cm
Definition: BeamProfileVtxGenerator.cc:169
BeamProfileVtxGenerator::phi
void phi(double m=0)
set phi in radian
Definition: BeamProfileVtxGenerator.h:45
geometryDiff.file
file
Definition: geometryDiff.py:13
BaseEvtVtxGenerator::BaseEvtVtxGenerator
BaseEvtVtxGenerator(const edm::ParameterSet &)
Definition: BaseEvtVtxGenerator.cc:29
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
BeamProfileVtxGenerator::meanY
void meanY(double m=0)
set mean in Y in cm
Definition: BeamProfileVtxGenerator.h:38
recoMuon::in
Definition: RecoMuonEnumerators.h:6
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
BeamProfileVtxGenerator::fEta
double fEta
Definition: BeamProfileVtxGenerator.h:60
BeamProfileVtxGenerator::setType
void setType(bool m=true)
set type
Definition: BeamProfileVtxGenerator.cc:184
BeamProfileVtxGenerator::fSigmaY
double fSigmaY
Definition: BeamProfileVtxGenerator.h:58
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BeamProfileVtxGenerator::fPhi
double fPhi
Definition: BeamProfileVtxGenerator.h:60
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
BeamProfileVtxGenerator::fSigmaX
double fSigmaX
Definition: BeamProfileVtxGenerator.h:58
BeamProfileVtxGenerator::sigmaX
void sigmaX(double s=1.0)
set resolution in X in cm
Definition: BeamProfileVtxGenerator.cc:159
BeamProfileVtxGenerator::ffile
bool ffile
Definition: BeamProfileVtxGenerator.h:64
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
BeamProfileVtxGenerator::fPsi
double fPsi
Definition: BeamProfileVtxGenerator.h:62
BeamProfileVtxGenerator::fMeanX
double fMeanX
Definition: BeamProfileVtxGenerator.h:59
BeamProfileVtxGenerator::meanX
void meanX(double m=0)
set mean in X in cm
Definition: BeamProfileVtxGenerator.h:36