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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 19 of file BeamProfileVtxGenerator.h.

Constructor & Destructor Documentation

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

Definition at line 19 of file BeamProfileVtxGenerator.cc.

References beamPos(), HTMLExport::elem(), eta(), fdistn, fEta, ffile, FrontierConditions_GlobalTag_cff::file, fMeanX, fMeanY, fMeanZ, fPhi, fPsi, fSigmaX, fSigmaY, fTheta, fTimeOffset, fType, edm::ParameterSet::getParameter(), mps_fire::i, recoMuon::in, plotBeamSpotDB::last, meanX(), meanY(), nBinx, nBiny, phi(), psi(), setType(), sigmaX(), sigmaY(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 84 of file BeamProfileVtxGenerator.cc.

84  {
85 }
BeamProfileVtxGenerator::BeamProfileVtxGenerator ( const BeamProfileVtxGenerator p)
privatedelete

Copy constructor

Member Function Documentation

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

set mean in Z in cm

Definition at line 44 of file BeamProfileVtxGenerator.h.

References PVValHelper::eta, and funct::m.

Referenced by BeamProfileVtxGenerator().

void BeamProfileVtxGenerator::eta ( double  m = 0)
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 29 of file BeamProfileVtxGenerator.h.

References alignCSCRings::s, fftjetvertexadder_cfi::sigmaX, and fftjetvertexadder_cfi::sigmaY.

29  {
30  return nullptr;
31  }
void BeamProfileVtxGenerator::meanX ( double  m = 0)
inline

set mean in X in cm

Definition at line 40 of file BeamProfileVtxGenerator.h.

References funct::m.

Referenced by BeamProfileVtxGenerator().

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

set mean in Y in cm

Definition at line 42 of file BeamProfileVtxGenerator.h.

References funct::m.

Referenced by BeamProfileVtxGenerator().

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

return a new event vertex

Implements BaseEvtVtxGenerator.

Definition at line 89 of file BeamProfileVtxGenerator.cc.

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().

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

Copy assignment operator

void BeamProfileVtxGenerator::phi ( double  m = 0)
inline
void BeamProfileVtxGenerator::psi ( double  m = 999)
inline
void BeamProfileVtxGenerator::setType ( bool  m = true)

set type

Definition at line 196 of file BeamProfileVtxGenerator.cc.

References fType, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

void BeamProfileVtxGenerator::sigmaX ( double  s = 1.0)

set resolution in X in cm

Definition at line 167 of file BeamProfileVtxGenerator.cc.

References fSigmaX, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

167  {
168 
169  if (s>=0) {
170  fSigmaX = s;
171  } else {
172  edm::LogWarning("VertexGenerator") << "Warning BeamProfileVtxGenerator:"
173  << " Illegal resolution in X " << s
174  << "- set to default value 0 cm";
175  fSigmaX = 0;
176  }
177 }
void BeamProfileVtxGenerator::sigmaY ( double  s = 1.0)

set resolution in Y in cm

Definition at line 179 of file BeamProfileVtxGenerator.cc.

References fSigmaY, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

179  {
180 
181  if (s>=0) {
182  fSigmaY = s;
183  } else {
184  edm::LogWarning("VertexGenerator") << "Warning BeamProfileVtxGenerator:"
185  << " Illegal resolution in Y " << s
186  << "- set to default value 0 cm";
187  fSigmaY = 0;
188  }
189 }

Member Data Documentation

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

Definition at line 69 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

double BeamProfileVtxGenerator::fEta
private

Definition at line 63 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and eta().

bool BeamProfileVtxGenerator::ffile
private

Definition at line 67 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

double BeamProfileVtxGenerator::fMeanX
private

Definition at line 62 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

double BeamProfileVtxGenerator::fMeanY
private

Definition at line 62 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

double BeamProfileVtxGenerator::fMeanZ
private

Definition at line 62 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

double BeamProfileVtxGenerator::fPhi
private

Definition at line 63 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

double BeamProfileVtxGenerator::fPsi
private

Definition at line 65 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

double BeamProfileVtxGenerator::fSigmaX
private

Definition at line 61 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fSigmaY
private

Definition at line 61 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fTheta
private

Definition at line 63 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fTimeOffset
private

Definition at line 70 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

bool BeamProfileVtxGenerator::fType
private

Definition at line 67 of file BeamProfileVtxGenerator.h.

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

int BeamProfileVtxGenerator::nBinx
private

Definition at line 68 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

int BeamProfileVtxGenerator::nBiny
private

Definition at line 68 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().