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
BetaBoostEvtVtxGenerator Class Reference
Inheritance diagram for BetaBoostEvtVtxGenerator:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void Alpha (double m=0)
 angle between crossing plane and horizontal plane More...
 
void Beta (double m=0)
 
 BetaBoostEvtVtxGenerator (const edm::ParameterSet &p)
 
double BetaFunction (double z, double z0)
 beta function More...
 
void betastar (double m=0)
 set beta_star More...
 
void emittance (double m=0)
 emittance (no the normalized) More...
 
CLHEP::HepRandomEngine & getEngine ()
 
virtual TMatrixD * GetInvLorentzBoost ()
 
virtual HepMC::FourVector * newVertex ()
 return a new event vertex More...
 
void Phi (double m=0)
 set half crossing angle More...
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 
void sigmaZ (double s=1.0)
 set resolution in Z in cm More...
 
void X0 (double m=0)
 set mean in X in cm More...
 
void Y0 (double m=0)
 set mean in Y in cm More...
 
void Z0 (double m=0)
 set mean in Z in cm More...
 
virtual ~BetaBoostEvtVtxGenerator ()
 
- 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

 BetaBoostEvtVtxGenerator (const BetaBoostEvtVtxGenerator &p)
 
BetaBoostEvtVtxGeneratoroperator= (const BetaBoostEvtVtxGenerator &rhs)
 

Private Attributes

double alpha_
 
double beta_
 
TMatrixD * boost_
 
double falpha
 
double fbetastar
 
double femittance
 
CLHEP::HepRandomEngine * fEngine
 
CLHEP::RandGaussQ * fRandom
 
double fSigmaZ
 
double fTimeOffset
 
HepMC::FourVector * fVertex
 
double fX0
 
double fY0
 
double fZ0
 
double phi_
 
edm::InputTag sourceLabel
 
bool verbosity_
 

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

Detailed Description

Definition at line 49 of file BetaBoostEvtVtxGenerator.cc.

Constructor & Destructor Documentation

BetaBoostEvtVtxGenerator::BetaBoostEvtVtxGenerator ( const edm::ParameterSet p)

Definition at line 115 of file BetaBoostEvtVtxGenerator.cc.

References alpha_, beta_, edm::hlt::Exception, fbetastar, femittance, fEngine, fRandom, fSigmaZ, fTimeOffset, fX0, fY0, fZ0, getEngine(), edm::RandomNumberGenerator::getEngine(), edm::ParameterSet::getParameter(), edm::Service< T >::isAvailable(), and phi_.

115  :
116  fVertex(0), boost_(0), fTimeOffset(0), fEngine(0),
118  verbosity_(p.getUntrackedParameter<bool>("verbosity",false))
119 {
120 
122 
123  if ( ! rng.isAvailable()) {
124 
125  throw cms::Exception("Configuration")
126  << "The BaseEvtVtxGenerator requires the RandomNumberGeneratorService\n"
127  "which is not present in the configuration file. You must add the service\n"
128  "in the configuration file or remove the modules that require it.";
129  }
130 
131  CLHEP::HepRandomEngine& engine = rng->getEngine();
132  fEngine = &engine;
133  fRandom = new CLHEP::RandGaussQ(getEngine());
134 
135  fX0 = p.getParameter<double>("X0")*cm;
136  fY0 = p.getParameter<double>("Y0")*cm;
137  fZ0 = p.getParameter<double>("Z0")*cm;
138  fSigmaZ = p.getParameter<double>("SigmaZ")*cm;
139  alpha_ = p.getParameter<double>("Alpha")*radian;
140  phi_ = p.getParameter<double>("Phi")*radian;
141  fbetastar = p.getParameter<double>("BetaStar")*cm;
142  femittance = p.getParameter<double>("Emittance")*cm; // this is not the normalized emittance
143  fTimeOffset = p.getParameter<double>("TimeOffset")*ns*c_light; // HepMC time units are mm
144  beta_=p.getParameter<double>("Beta");
145  if (fSigmaZ <= 0) {
146  throw cms::Exception("Configuration")
147  << "Error in BetaBoostEvtVtxGenerator: "
148  << "Illegal resolution in Z (SigmaZ is negative)";
149  }
150 
151  produces<bool>();
152 
153 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
CLHEP::HepRandomEngine & getEngine()
bool isAvailable() const
Definition: Service.h:46
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
CLHEP::HepRandomEngine * fEngine
BetaBoostEvtVtxGenerator::~BetaBoostEvtVtxGenerator ( )
virtual

Definition at line 155 of file BetaBoostEvtVtxGenerator.cc.

References boost_, fRandom, and fVertex.

156 {
157  delete fVertex ;
158  if (boost_ != 0 ) delete boost_;
159  delete fRandom;
160 }
BetaBoostEvtVtxGenerator::BetaBoostEvtVtxGenerator ( const BetaBoostEvtVtxGenerator p)
private

Copy constructor

Member Function Documentation

void BetaBoostEvtVtxGenerator::Alpha ( double  m = 0)
inline

angle between crossing plane and horizontal plane

Definition at line 74 of file BetaBoostEvtVtxGenerator.cc.

References m.

void BetaBoostEvtVtxGenerator::Beta ( double  m = 0)
inline

Definition at line 75 of file BetaBoostEvtVtxGenerator.cc.

References m.

double BetaBoostEvtVtxGenerator::BetaFunction ( double  z,
double  z0 
)

beta function

Definition at line 195 of file BetaBoostEvtVtxGenerator.cc.

References fbetastar, femittance, and mathSSE::sqrt().

Referenced by newVertex().

196 {
197  return sqrt(femittance*(fbetastar+(((z-z0)*(z-z0))/fbetastar)));
198 
199 }
float float float z
T sqrt(T t)
Definition: SSEVec.h:48
void BetaBoostEvtVtxGenerator::betastar ( double  m = 0)
inline

set beta_star

Definition at line 78 of file BetaBoostEvtVtxGenerator.cc.

References m.

void BetaBoostEvtVtxGenerator::emittance ( double  m = 0)
inline

emittance (no the normalized)

Definition at line 80 of file BetaBoostEvtVtxGenerator.cc.

References m.

CLHEP::HepRandomEngine & BetaBoostEvtVtxGenerator::getEngine ( )

Definition at line 162 of file BetaBoostEvtVtxGenerator.cc.

References fEngine.

Referenced by BetaBoostEvtVtxGenerator().

162  {
163  return *fEngine;
164 }
CLHEP::HepRandomEngine * fEngine
TMatrixD * BetaBoostEvtVtxGenerator::GetInvLorentzBoost ( )
virtual

Definition at line 214 of file BetaBoostEvtVtxGenerator.cc.

References alpha_, beta_, boost_, funct::cos(), phi_, funct::sin(), mathSSE::sqrt(), funct::tan(), and verbosity_.

Referenced by produce().

214  {
215 
216  //alpha_ = 0;
217  //phi_ = 142.e-6;
218  // if (boost_ != 0 ) return boost_;
219 
220  //boost_.ResizeTo(4,4);
221  //boost_ = new TMatrixD(4,4);
222  TMatrixD tmpboost(4,4);
223  TMatrixD tmpboostZ(4,4);
224  TMatrixD tmpboostXYZ(4,4);
225 
226  //if ( (alpha_ == 0) && (phi_==0) ) { boost_->Zero(); return boost_; }
227 
228  // Lorentz boost to frame where the collision is head-on
229  // phi is the half crossing angle in the plane ZS
230  // alpha is the angle to the S axis from the X axis in the XY plane
231 
232  tmpboost(0,0) = 1./cos(phi_);
233  tmpboost(0,1) = - cos(alpha_)*sin(phi_);
234  tmpboost(0,2) = - tan(phi_)*sin(phi_);
235  tmpboost(0,3) = - sin(alpha_)*sin(phi_);
236  tmpboost(1,0) = - cos(alpha_)*tan(phi_);
237  tmpboost(1,1) = 1.;
238  tmpboost(1,2) = cos(alpha_)*tan(phi_);
239  tmpboost(1,3) = 0.;
240  tmpboost(2,0) = 0.;
241  tmpboost(2,1) = - cos(alpha_)*sin(phi_);
242  tmpboost(2,2) = cos(phi_);
243  tmpboost(2,3) = - sin(alpha_)*sin(phi_);
244  tmpboost(3,0) = - sin(alpha_)*tan(phi_);
245  tmpboost(3,1) = 0.;
246  tmpboost(3,2) = sin(alpha_)*tan(phi_);
247  tmpboost(3,3) = 1.;
248  //cout<<"beta "<<beta_;
249  double gama=1.0/sqrt(1-beta_*beta_);
250  tmpboostZ(0,0)=gama;
251  tmpboostZ(0,1)=0.;
252  tmpboostZ(0,2)=-1.0*beta_*gama;
253  tmpboostZ(0,3)=0.;
254  tmpboostZ(1,0)=0.;
255  tmpboostZ(1,1) = 1.;
256  tmpboostZ(1,2)=0.;
257  tmpboostZ(1,3)=0.;
258  tmpboostZ(2,0)=-1.0*beta_*gama;
259  tmpboostZ(2,1) = 0.;
260  tmpboostZ(2,2)=gama;
261  tmpboostZ(2,3) = 0.;
262  tmpboostZ(3,0)=0.;
263  tmpboostZ(3,1)=0.;
264  tmpboostZ(3,2)=0.;
265  tmpboostZ(3,3) = 1.;
266 
267  tmpboostXYZ=tmpboostZ*tmpboost;
268  tmpboostXYZ.Invert();
269 
270 
271 
272  boost_ = new TMatrixD(tmpboostXYZ);
273  if ( verbosity_ ) { boost_->Print(); }
274 
275  return boost_;
276 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:48
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
HepMC::FourVector * BetaBoostEvtVtxGenerator::newVertex ( )
virtual

return a new event vertex

Definition at line 168 of file BetaBoostEvtVtxGenerator.cc.

References BetaFunction(), fRandom, fSigmaZ, fTimeOffset, fVertex, fX0, fY0, fZ0, mathSSE::sqrt(), X, and Gflash::Z.

Referenced by produce().

168  {
169 
170 
171  double X,Y,Z;
172 
173  double tmp_sigz = fRandom->fire(0., fSigmaZ);
174  Z = tmp_sigz + fZ0;
175 
176  double tmp_sigx = BetaFunction(Z,fZ0);
177  // need sqrt(2) for beamspot width relative to single beam width
178  tmp_sigx /= sqrt(2.0);
179  X = fRandom->fire(0.,tmp_sigx) + fX0; // + Z*fdxdz ;
180 
181  double tmp_sigy = BetaFunction(Z,fZ0);
182  // need sqrt(2) for beamspot width relative to single beam width
183  tmp_sigy /= sqrt(2.0);
184  Y = fRandom->fire(0.,tmp_sigy) + fY0; // + Z*fdydz;
185 
186  double tmp_sigt = fRandom->fire(0., fSigmaZ);
187  double T = tmp_sigt + fTimeOffset;
188 
189  if ( fVertex == 0 ) fVertex = new HepMC::FourVector();
190  fVertex->set(X,Y,Z,T);
191 
192  return fVertex;
193 }
const double Z[kNumberCalorimeter]
#define X(str)
Definition: MuonsGrabber.cc:48
T sqrt(T t)
Definition: SSEVec.h:48
double BetaFunction(double z, double z0)
beta function
long double T
BetaBoostEvtVtxGenerator& BetaBoostEvtVtxGenerator::operator= ( const BetaBoostEvtVtxGenerator rhs)
private

Copy assignment operator

void BetaBoostEvtVtxGenerator::Phi ( double  m = 0)
inline

set half crossing angle

Definition at line 72 of file BetaBoostEvtVtxGenerator.cc.

References m.

void BetaBoostEvtVtxGenerator::produce ( edm::Event evt,
const edm::EventSetup  
)
overridevirtual

Implements edm::EDProducer.

Definition at line 278 of file BetaBoostEvtVtxGenerator.cc.

References edm::Event::getByLabel(), GetInvLorentzBoost(), newVertex(), edm::Event::put(), reco::return(), and sourceLabel.

279 {
280 
281 
282  Handle<HepMCProduct> HepMCEvt ;
283  evt.getByLabel( sourceLabel, HepMCEvt ) ;
284 
285  // generate new vertex & apply the shift
286  //
287  HepMCEvt->applyVtxGen( newVertex() ) ;
288 
289  //HepMCEvt->LorentzBoost( 0., 142.e-6 );
290  HepMCEvt->boostToLab( GetInvLorentzBoost(), "vertex" );
291  HepMCEvt->boostToLab( GetInvLorentzBoost(), "momentum" );
292  // OK, create a (pseudo)product and put in into edm::Event
293  //
294  auto_ptr<bool> NewProduct(new bool(true)) ;
295  evt.put( NewProduct ) ;
296  return ;
297 }
virtual HepMC::FourVector * newVertex()
return a new event vertex
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
return(e1-e2)*(e1-e2)+dp *dp
virtual TMatrixD * GetInvLorentzBoost()
void BetaBoostEvtVtxGenerator::sigmaZ ( double  s = 1.0)

set resolution in Z in cm

Definition at line 202 of file BetaBoostEvtVtxGenerator.cc.

References edm::hlt::Exception, fSigmaZ, and alignCSCRings::s.

203 {
204  if (s>=0 ) {
205  fSigmaZ=s;
206  }
207  else {
208  throw cms::Exception("LogicError")
209  << "Error in BetaBoostEvtVtxGenerator::sigmaZ: "
210  << "Illegal resolution in Z (negative)";
211  }
212 }
void BetaBoostEvtVtxGenerator::X0 ( double  m = 0)
inline

set mean in X in cm

Definition at line 65 of file BetaBoostEvtVtxGenerator.cc.

References m.

void BetaBoostEvtVtxGenerator::Y0 ( double  m = 0)
inline

set mean in Y in cm

Definition at line 67 of file BetaBoostEvtVtxGenerator.cc.

References m.

void BetaBoostEvtVtxGenerator::Z0 ( double  m = 0)
inline

set mean in Z in cm

Definition at line 69 of file BetaBoostEvtVtxGenerator.cc.

References m.

Member Data Documentation

double BetaBoostEvtVtxGenerator::alpha_
private

Definition at line 92 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and GetInvLorentzBoost().

double BetaBoostEvtVtxGenerator::beta_
private

Definition at line 94 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and GetInvLorentzBoost().

TMatrixD* BetaBoostEvtVtxGenerator::boost_
private

Definition at line 102 of file BetaBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost(), and ~BetaBoostEvtVtxGenerator().

double BetaBoostEvtVtxGenerator::falpha
private

Definition at line 99 of file BetaBoostEvtVtxGenerator.cc.

double BetaBoostEvtVtxGenerator::fbetastar
private

Definition at line 98 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and BetaFunction().

double BetaBoostEvtVtxGenerator::femittance
private

Definition at line 98 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and BetaFunction().

CLHEP::HepRandomEngine* BetaBoostEvtVtxGenerator::fEngine
private

Definition at line 105 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and getEngine().

CLHEP::RandGaussQ* BetaBoostEvtVtxGenerator::fRandom
private
double BetaBoostEvtVtxGenerator::fSigmaZ
private

Definition at line 96 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), newVertex(), and sigmaZ().

double BetaBoostEvtVtxGenerator::fTimeOffset
private

Definition at line 103 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

HepMC::FourVector* BetaBoostEvtVtxGenerator::fVertex
private

Definition at line 101 of file BetaBoostEvtVtxGenerator.cc.

Referenced by newVertex(), and ~BetaBoostEvtVtxGenerator().

double BetaBoostEvtVtxGenerator::fX0
private

Definition at line 95 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

double BetaBoostEvtVtxGenerator::fY0
private

Definition at line 95 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

double BetaBoostEvtVtxGenerator::fZ0
private

Definition at line 95 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

double BetaBoostEvtVtxGenerator::phi_
private

Definition at line 92 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and GetInvLorentzBoost().

edm::InputTag BetaBoostEvtVtxGenerator::sourceLabel
private

Definition at line 106 of file BetaBoostEvtVtxGenerator.cc.

Referenced by produce().

bool BetaBoostEvtVtxGenerator::verbosity_
private

Definition at line 110 of file BetaBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().