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 &)
 
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 ()
 
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 ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) 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
 
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 edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- 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 50 of file BetaBoostEvtVtxGenerator.cc.

Constructor & Destructor Documentation

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

Definition at line 116 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_.

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

References boost_, fRandom, and fVertex.

157 {
158  delete fVertex ;
159  if (boost_ != 0 ) delete boost_;
160  delete fRandom;
161 }
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 75 of file BetaBoostEvtVtxGenerator.cc.

References m.

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

Definition at line 76 of file BetaBoostEvtVtxGenerator.cc.

References m.

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

beta function

Definition at line 196 of file BetaBoostEvtVtxGenerator.cc.

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

Referenced by newVertex().

197 {
198  return sqrt(femittance*(fbetastar+(((z-z0)*(z-z0))/fbetastar)));
199 
200 }
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 79 of file BetaBoostEvtVtxGenerator.cc.

References m.

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

emittance (no the normalized)

Definition at line 81 of file BetaBoostEvtVtxGenerator.cc.

References m.

CLHEP::HepRandomEngine & BetaBoostEvtVtxGenerator::getEngine ( )

Definition at line 163 of file BetaBoostEvtVtxGenerator.cc.

References fEngine.

Referenced by BetaBoostEvtVtxGenerator().

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

Definition at line 215 of file BetaBoostEvtVtxGenerator.cc.

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

Referenced by produce().

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

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

Referenced by produce().

169  {
170 
171 
172  double X,Y,Z;
173 
174  double tmp_sigz = fRandom->fire(0., fSigmaZ);
175  Z = tmp_sigz + fZ0;
176 
177  double tmp_sigx = BetaFunction(Z,fZ0);
178  // need sqrt(2) for beamspot width relative to single beam width
179  tmp_sigx /= sqrt(2.0);
180  X = fRandom->fire(0.,tmp_sigx) + fX0; // + Z*fdxdz ;
181 
182  double tmp_sigy = BetaFunction(Z,fZ0);
183  // need sqrt(2) for beamspot width relative to single beam width
184  tmp_sigy /= sqrt(2.0);
185  Y = fRandom->fire(0.,tmp_sigy) + fY0; // + Z*fdydz;
186 
187  double tmp_sigt = fRandom->fire(0., fSigmaZ);
188  double T = tmp_sigt + fTimeOffset;
189 
190  if ( fVertex == 0 ) fVertex = new HepMC::FourVector();
191  fVertex->set(X,Y,Z,T);
192 
193  return fVertex;
194 }
const double Z[kNumberCalorimeter]
#define X(str)
Definition: MuonsGrabber.cc:49
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 73 of file BetaBoostEvtVtxGenerator.cc.

References m.

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

Implements edm::EDProducer.

Definition at line 279 of file BetaBoostEvtVtxGenerator.cc.

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

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

set resolution in Z in cm

Definition at line 203 of file BetaBoostEvtVtxGenerator.cc.

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

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

set mean in X in cm

Definition at line 66 of file BetaBoostEvtVtxGenerator.cc.

References m.

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

set mean in Y in cm

Definition at line 68 of file BetaBoostEvtVtxGenerator.cc.

References m.

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

set mean in Z in cm

Definition at line 70 of file BetaBoostEvtVtxGenerator.cc.

References m.

Member Data Documentation

double BetaBoostEvtVtxGenerator::alpha_
private

Definition at line 93 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and GetInvLorentzBoost().

double BetaBoostEvtVtxGenerator::beta_
private

Definition at line 95 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and GetInvLorentzBoost().

TMatrixD* BetaBoostEvtVtxGenerator::boost_
private

Definition at line 103 of file BetaBoostEvtVtxGenerator.cc.

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

double BetaBoostEvtVtxGenerator::falpha
private

Definition at line 100 of file BetaBoostEvtVtxGenerator.cc.

double BetaBoostEvtVtxGenerator::fbetastar
private

Definition at line 99 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and BetaFunction().

double BetaBoostEvtVtxGenerator::femittance
private

Definition at line 99 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and BetaFunction().

CLHEP::HepRandomEngine* BetaBoostEvtVtxGenerator::fEngine
private

Definition at line 106 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and getEngine().

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

Definition at line 97 of file BetaBoostEvtVtxGenerator.cc.

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

double BetaBoostEvtVtxGenerator::fTimeOffset
private

Definition at line 104 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

HepMC::FourVector* BetaBoostEvtVtxGenerator::fVertex
private

Definition at line 102 of file BetaBoostEvtVtxGenerator.cc.

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

double BetaBoostEvtVtxGenerator::fX0
private

Definition at line 96 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

double BetaBoostEvtVtxGenerator::fY0
private

Definition at line 96 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

double BetaBoostEvtVtxGenerator::fZ0
private

Definition at line 96 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

double BetaBoostEvtVtxGenerator::phi_
private

Definition at line 93 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and GetInvLorentzBoost().

edm::InputTag BetaBoostEvtVtxGenerator::sourceLabel
private

Definition at line 107 of file BetaBoostEvtVtxGenerator.cc.

Referenced by produce().

bool BetaBoostEvtVtxGenerator::verbosity_
private

Definition at line 111 of file BetaBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().