CMS 3D CMS Logo

List of all members | Public 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)
 
 BeamProfileVtxGenerator (const BeamProfileVtxGenerator &p)=delete
 
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...
 
BeamProfileVtxGeneratoroperator= (const BeamProfileVtxGenerator &rhs)=delete
 
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 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 23 of file BeamProfileVtxGenerator.cc.

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.

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

◆ BeamProfileVtxGenerator() [2/2]

BeamProfileVtxGenerator::BeamProfileVtxGenerator ( const BeamProfileVtxGenerator p)
delete

Copy constructor

◆ ~BeamProfileVtxGenerator()

BeamProfileVtxGenerator::~BeamProfileVtxGenerator ( )
override

Definition at line 81 of file BeamProfileVtxGenerator.cc.

81 {}

Member Function Documentation

◆ beamPos()

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

◆ eta()

void BeamProfileVtxGenerator::eta ( double  m = 0)

◆ 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 32 of file BeamProfileVtxGenerator.h.

32 { return nullptr; }

◆ meanX()

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

◆ meanY()

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

◆ newVertex()

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

return a new event vertex

Implements BaseEvtVtxGenerator.

Definition at line 84 of file BeamProfileVtxGenerator.cc.

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

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

◆ operator=()

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

Copy assignment operator

◆ phi()

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

◆ psi()

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

◆ setType()

void BeamProfileVtxGenerator::setType ( bool  m = true)

set type

Definition at line 188 of file BeamProfileVtxGenerator.cc.

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 163 of file BeamProfileVtxGenerator.cc.

References fSigmaX, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

163  {
164  if (s >= 0) {
165  fSigmaX = s;
166  } else {
167  edm::LogWarning("VertexGenerator") << "Warning BeamProfileVtxGenerator:"
168  << " Illegal resolution in X " << s << "- set to default value 0 cm";
169  fSigmaX = 0;
170  }
171 }
Log< level::Warning, false > LogWarning

◆ sigmaY()

void BeamProfileVtxGenerator::sigmaY ( double  s = 1.0)

set resolution in Y in cm

Definition at line 173 of file BeamProfileVtxGenerator.cc.

References fSigmaY, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

173  {
174  if (s >= 0) {
175  fSigmaY = s;
176  } else {
177  edm::LogWarning("VertexGenerator") << "Warning BeamProfileVtxGenerator:"
178  << " Illegal resolution in Y " << s << "- set to default value 0 cm";
179  fSigmaY = 0;
180  }
181 }
Log< level::Warning, false > LogWarning

Member Data Documentation

◆ fdistn

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

Definition at line 64 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

◆ fEta

double BeamProfileVtxGenerator::fEta
private

Definition at line 58 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and eta().

◆ ffile

bool BeamProfileVtxGenerator::ffile
private

Definition at line 62 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

◆ fMeanX

double BeamProfileVtxGenerator::fMeanX
private

Definition at line 57 of file BeamProfileVtxGenerator.h.

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

◆ fMeanY

double BeamProfileVtxGenerator::fMeanY
private

Definition at line 57 of file BeamProfileVtxGenerator.h.

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

◆ fMeanZ

double BeamProfileVtxGenerator::fMeanZ
private

Definition at line 57 of file BeamProfileVtxGenerator.h.

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

◆ fPhi

double BeamProfileVtxGenerator::fPhi
private

Definition at line 58 of file BeamProfileVtxGenerator.h.

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

◆ fPsi

double BeamProfileVtxGenerator::fPsi
private

Definition at line 60 of file BeamProfileVtxGenerator.h.

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

◆ fSigmaX

double BeamProfileVtxGenerator::fSigmaX
private

Definition at line 56 of file BeamProfileVtxGenerator.h.

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

◆ fSigmaY

double BeamProfileVtxGenerator::fSigmaY
private

Definition at line 56 of file BeamProfileVtxGenerator.h.

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

◆ fTheta

double BeamProfileVtxGenerator::fTheta
private

Definition at line 58 of file BeamProfileVtxGenerator.h.

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

◆ fTimeOffset

double BeamProfileVtxGenerator::fTimeOffset
private

Definition at line 65 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

◆ fType

bool BeamProfileVtxGenerator::fType
private

Definition at line 62 of file BeamProfileVtxGenerator.h.

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

◆ nBinx

int BeamProfileVtxGenerator::nBinx
private

Definition at line 63 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

◆ nBiny

int BeamProfileVtxGenerator::nBiny
private

Definition at line 63 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().