CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
BeamProfileVtxGenerator Class Reference

#include <BeamProfileVtxGenerator.h>

Inheritance diagram for BeamProfileVtxGenerator:
BaseEvtVtxGenerator edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

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...
 
virtual TMatrixD * GetInvLorentzBoost ()
 
void meanX (double m=0)
 set mean in X in cm More...
 
void meanY (double m=0)
 set mean in Y in cm More...
 
virtual HepMC::FourVector * newVertex ()
 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...
 
virtual ~BeamProfileVtxGenerator ()
 
- Public Member Functions inherited from BaseEvtVtxGenerator
 BaseEvtVtxGenerator (const edm::ParameterSet &)
 
virtual void beginRun (edm::Run &, const edm::EventSetup &)
 
virtual HepMC::FourVector * lastVertex ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
virtual ~BaseEvtVtxGenerator ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from BaseEvtVtxGenerator
CLHEP::HepRandomEngine & getEngine ()
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 
- Protected Attributes inherited from BaseEvtVtxGenerator
TMatrixD * boost_
 
double fTimeOffset
 
HepMC::FourVector * fVertex
 

Detailed Description

Definition at line 21 of file BeamProfileVtxGenerator.h.

Constructor & Destructor Documentation

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

Definition at line 20 of file BeamProfileVtxGenerator.cc.

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

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

Definition at line 85 of file BeamProfileVtxGenerator.cc.

References fRandom.

85  {
86  delete fRandom;
87 }
BeamProfileVtxGenerator::BeamProfileVtxGenerator ( const BeamProfileVtxGenerator p)
private

Copy constructor

Member Function Documentation

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

set mean in Z in cm

Definition at line 46 of file BeamProfileVtxGenerator.h.

References fMeanZ, and m.

Referenced by BeamProfileVtxGenerator().

void BeamProfileVtxGenerator::eta ( double  m = 0)
virtual TMatrixD* BeamProfileVtxGenerator::GetInvLorentzBoost ( )
inlinevirtual

Implements BaseEvtVtxGenerator.

Definition at line 31 of file BeamProfileVtxGenerator.h.

31  {
32  return 0;
33  }
void BeamProfileVtxGenerator::meanX ( double  m = 0)
inline

set mean in X in cm

Definition at line 42 of file BeamProfileVtxGenerator.h.

References fMeanX, and m.

Referenced by BeamProfileVtxGenerator().

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

set mean in Y in cm

Definition at line 44 of file BeamProfileVtxGenerator.h.

References fMeanY, and m.

Referenced by BeamProfileVtxGenerator().

HepMC::FourVector * BeamProfileVtxGenerator::newVertex ( )
virtual

return a new event vertex

Implements BaseEvtVtxGenerator.

Definition at line 91 of file BeamProfileVtxGenerator.cc.

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

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

Copy assignment operator

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

set phi in radian

Definition at line 51 of file BeamProfileVtxGenerator.h.

References fPhi, and m.

Referenced by BeamProfileVtxGenerator().

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

set psi in radian

Definition at line 53 of file BeamProfileVtxGenerator.h.

References fPsi, and m.

Referenced by BeamProfileVtxGenerator().

void BeamProfileVtxGenerator::setType ( bool  m = true)

set type

Definition at line 202 of file BeamProfileVtxGenerator.cc.

References fRandom, fType, BaseEvtVtxGenerator::getEngine(), and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

202  {
203 
204  fType = s;
205  delete fRandom;
206 
207  if (fType == true)
208  fRandom = new CLHEP::RandGaussQ(getEngine());
209  else
210  fRandom = new CLHEP::RandFlat(getEngine());
211 }
CLHEP::HepRandomEngine & getEngine()
void BeamProfileVtxGenerator::sigmaX ( double  s = 1.0)

set resolution in X in cm

Definition at line 173 of file BeamProfileVtxGenerator.cc.

References fSigmaX, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

173  {
174 
175  if (s>=0) {
176  fSigmaX = s;
177  } else {
178  edm::LogWarning("VertexGenerator") << "Warning BeamProfileVtxGenerator:"
179  << " Illegal resolution in X " << s
180  << "- set to default value 0 cm";
181  fSigmaX = 0;
182  }
183 }
void BeamProfileVtxGenerator::sigmaY ( double  s = 1.0)

set resolution in Y in cm

Definition at line 185 of file BeamProfileVtxGenerator.cc.

References fSigmaY, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

185  {
186 
187  if (s>=0) {
188  fSigmaY = s;
189  } else {
190  edm::LogWarning("VertexGenerator") << "Warning BeamProfileVtxGenerator:"
191  << " Illegal resolution in Y " << s
192  << "- set to default value 0 cm";
193  fSigmaY = 0;
194  }
195 }

Member Data Documentation

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

Definition at line 71 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

double BeamProfileVtxGenerator::fEta
private

Definition at line 65 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and eta().

bool BeamProfileVtxGenerator::ffile
private

Definition at line 69 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

double BeamProfileVtxGenerator::fMeanX
private

Definition at line 64 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fMeanY
private

Definition at line 64 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fMeanZ
private

Definition at line 64 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fPhi
private

Definition at line 65 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fPsi
private

Definition at line 67 of file BeamProfileVtxGenerator.h.

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

CLHEP::HepRandom* BeamProfileVtxGenerator::fRandom
private

Definition at line 72 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fSigmaX
private

Definition at line 63 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fSigmaY
private

Definition at line 63 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fTheta
private

Definition at line 65 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fTimeOffset
private

Definition at line 73 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

bool BeamProfileVtxGenerator::fType
private

Definition at line 69 of file BeamProfileVtxGenerator.h.

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

int BeamProfileVtxGenerator::nBinx
private

Definition at line 70 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

int BeamProfileVtxGenerator::nBiny
private

Definition at line 70 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().