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::EDConsumerBase 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 HepMC::FourVector * lastVertex ()
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 
virtual ~BaseEvtVtxGenerator ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- Protected Attributes inherited from BaseEvtVtxGenerator
TMatrixD * boost_
 
double fTimeOffset
 
HepMC::FourVector * fVertex
 

Detailed Description

Definition at line 20 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, 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(), 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
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 84 of file BeamProfileVtxGenerator.cc.

References fRandom.

84  {
85  delete fRandom;
86 }
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 45 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 30 of file BeamProfileVtxGenerator.h.

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

set mean in X in cm

Definition at line 41 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 43 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 90 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().

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

References fPsi, and m.

Referenced by BeamProfileVtxGenerator().

void BeamProfileVtxGenerator::setType ( bool  m = true)

set type

Definition at line 201 of file BeamProfileVtxGenerator.cc.

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

Referenced by BeamProfileVtxGenerator().

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

set resolution in X in cm

Definition at line 172 of file BeamProfileVtxGenerator.cc.

References fSigmaX, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

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

set resolution in Y in cm

Definition at line 184 of file BeamProfileVtxGenerator.cc.

References fSigmaY, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

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

Member Data Documentation

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

Definition at line 70 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

double BeamProfileVtxGenerator::fEta
private

Definition at line 64 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and eta().

bool BeamProfileVtxGenerator::ffile
private

Definition at line 68 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

double BeamProfileVtxGenerator::fMeanX
private

Definition at line 63 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fMeanY
private

Definition at line 63 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fMeanZ
private

Definition at line 63 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fPhi
private

Definition at line 64 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fPsi
private

Definition at line 66 of file BeamProfileVtxGenerator.h.

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

CLHEP::HepRandom* BeamProfileVtxGenerator::fRandom
private

Definition at line 71 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fSigmaX
private

Definition at line 62 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fSigmaY
private

Definition at line 62 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fTheta
private

Definition at line 64 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fTimeOffset
private

Definition at line 72 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

bool BeamProfileVtxGenerator::fType
private

Definition at line 68 of file BeamProfileVtxGenerator.h.

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

int BeamProfileVtxGenerator::nBinx
private

Definition at line 69 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().

int BeamProfileVtxGenerator::nBiny
private

Definition at line 69 of file BeamProfileVtxGenerator.h.

Referenced by BeamProfileVtxGenerator(), and newVertex().