test
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 (CLHEP::HepRandomEngine *)
 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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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
 
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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 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 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, 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.

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

Copy constructor

Member Function Documentation

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

Implements BaseEvtVtxGenerator.

Definition at line 29 of file BeamProfileVtxGenerator.h.

29  {
30  return 0;
31  }
void BeamProfileVtxGenerator::meanX ( double  m = 0)
inline
void BeamProfileVtxGenerator::meanY ( double  m = 0)
inline
HepMC::FourVector * BeamProfileVtxGenerator::newVertex ( CLHEP::HepRandomEngine *  engine)
virtual

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, BaseEvtVtxGenerator::fVertex, 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  //if (fVertex == 0) fVertex = new CLHEP::Hep3Vector;
161  //fVertex->set(xp, yp, zp);
162  if (fVertex == 0 ) fVertex = new HepMC::FourVector() ;
163  fVertex->set(xp, yp, zp, fTimeOffset );
164 
165  LogDebug("VertexGenerator") << "BeamProfileVtxGenerator: Vertex created "
166  << "at (" << xp << ", " << yp << ", "
167  << zp << ", " << fTimeOffset << ")";
168  return fVertex;
169 }
#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
BeamProfileVtxGenerator& BeamProfileVtxGenerator::operator= ( const BeamProfileVtxGenerator rhs)
private

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

References fType, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

200  {
201  fType = s;
202 }
void BeamProfileVtxGenerator::sigmaX ( double  s = 1.0)

set resolution in X in cm

Definition at line 171 of file BeamProfileVtxGenerator.cc.

References fSigmaX, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

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

set resolution in Y in cm

Definition at line 183 of file BeamProfileVtxGenerator.cc.

References fSigmaY, and alignCSCRings::s.

Referenced by BeamProfileVtxGenerator().

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

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(), meanX(), and newVertex().

double BeamProfileVtxGenerator::fMeanY
private

Definition at line 62 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fMeanZ
private

Definition at line 62 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fPhi
private

Definition at line 63 of file BeamProfileVtxGenerator.h.

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

double BeamProfileVtxGenerator::fPsi
private

Definition at line 65 of file BeamProfileVtxGenerator.h.

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

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