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
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...
 
virtual TMatrixD * GetInvLorentzBoost ()
 
virtual HepMC::FourVector * newVertex (CLHEP::HepRandomEngine *)
 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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector
< edm::ProductResolverIndex >
const & 
indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
double fSigmaZ
 
double fTimeOffset
 
HepMC::FourVector * fVertex
 
double fX0
 
double fY0
 
double fZ0
 
double phi_
 
edm::EDGetTokenT< HepMCProductsourceLabel
 
bool verbosity_
 

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)
 

Detailed Description

Definition at line 52 of file BetaBoostEvtVtxGenerator.cc.

Constructor & Destructor Documentation

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

Definition at line 113 of file BetaBoostEvtVtxGenerator.cc.

References alpha_, beta_, Exception, fbetastar, femittance, fSigmaZ, fTimeOffset, fX0, fY0, fZ0, edm::ParameterSet::getParameter(), and phi_.

113  :
114  fVertex(0), boost_(0), fTimeOffset(0),
115  sourceLabel(consumes<HepMCProduct>(p.getParameter<edm::InputTag>("src"))),
116  verbosity_(p.getUntrackedParameter<bool>("verbosity",false))
117 {
118  fX0 = p.getParameter<double>("X0")*cm;
119  fY0 = p.getParameter<double>("Y0")*cm;
120  fZ0 = p.getParameter<double>("Z0")*cm;
121  fSigmaZ = p.getParameter<double>("SigmaZ")*cm;
122  alpha_ = p.getParameter<double>("Alpha")*radian;
123  phi_ = p.getParameter<double>("Phi")*radian;
124  fbetastar = p.getParameter<double>("BetaStar")*cm;
125  femittance = p.getParameter<double>("Emittance")*cm; // this is not the normalized emittance
126  fTimeOffset = p.getParameter<double>("TimeOffset")*ns*c_light; // HepMC time units are mm
127  beta_=p.getParameter<double>("Beta");
128  if (fSigmaZ <= 0) {
129  throw cms::Exception("Configuration")
130  << "Error in BetaBoostEvtVtxGenerator: "
131  << "Illegal resolution in Z (SigmaZ is negative)";
132  }
133 
134  produces<edm::HepMCProduct>();
135 
136 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< HepMCProduct > sourceLabel
BetaBoostEvtVtxGenerator::~BetaBoostEvtVtxGenerator ( )
virtual

Definition at line 138 of file BetaBoostEvtVtxGenerator.cc.

References boost_, and fVertex.

139 {
140  delete fVertex ;
141  if (boost_ != 0 ) delete boost_;
142 }
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 77 of file BetaBoostEvtVtxGenerator.cc.

References visualization-live-secondInstance_cfg::m.

void BetaBoostEvtVtxGenerator::Beta ( double  m = 0)
inline
double BetaBoostEvtVtxGenerator::BetaFunction ( double  z,
double  z0 
)

beta function

Definition at line 172 of file BetaBoostEvtVtxGenerator.cc.

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

Referenced by newVertex().

173 {
174  return sqrt(femittance*(fbetastar+(((z-z0)*(z-z0))/fbetastar)));
175 
176 }
T sqrt(T t)
Definition: SSEVec.h:18
void BetaBoostEvtVtxGenerator::betastar ( double  m = 0)
inline
void BetaBoostEvtVtxGenerator::emittance ( double  m = 0)
inline
TMatrixD * BetaBoostEvtVtxGenerator::GetInvLorentzBoost ( )
virtual

Definition at line 191 of file BetaBoostEvtVtxGenerator.cc.

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

Referenced by produce().

191  {
192 
193  //alpha_ = 0;
194  //phi_ = 142.e-6;
195  // if (boost_ != 0 ) return boost_;
196 
197  //boost_.ResizeTo(4,4);
198  //boost_ = new TMatrixD(4,4);
199  TMatrixD tmpboost(4,4);
200  TMatrixD tmpboostZ(4,4);
201  TMatrixD tmpboostXYZ(4,4);
202 
203  //if ( (alpha_ == 0) && (phi_==0) ) { boost_->Zero(); return boost_; }
204 
205  // Lorentz boost to frame where the collision is head-on
206  // phi is the half crossing angle in the plane ZS
207  // alpha is the angle to the S axis from the X axis in the XY plane
208 
209  tmpboost(0,0) = 1./cos(phi_);
210  tmpboost(0,1) = - cos(alpha_)*sin(phi_);
211  tmpboost(0,2) = - tan(phi_)*sin(phi_);
212  tmpboost(0,3) = - sin(alpha_)*sin(phi_);
213  tmpboost(1,0) = - cos(alpha_)*tan(phi_);
214  tmpboost(1,1) = 1.;
215  tmpboost(1,2) = cos(alpha_)*tan(phi_);
216  tmpboost(1,3) = 0.;
217  tmpboost(2,0) = 0.;
218  tmpboost(2,1) = - cos(alpha_)*sin(phi_);
219  tmpboost(2,2) = cos(phi_);
220  tmpboost(2,3) = - sin(alpha_)*sin(phi_);
221  tmpboost(3,0) = - sin(alpha_)*tan(phi_);
222  tmpboost(3,1) = 0.;
223  tmpboost(3,2) = sin(alpha_)*tan(phi_);
224  tmpboost(3,3) = 1.;
225  //cout<<"beta "<<beta_;
226  double gama=1.0/sqrt(1-beta_*beta_);
227  tmpboostZ(0,0)=gama;
228  tmpboostZ(0,1)=0.;
229  tmpboostZ(0,2)=-1.0*beta_*gama;
230  tmpboostZ(0,3)=0.;
231  tmpboostZ(1,0)=0.;
232  tmpboostZ(1,1) = 1.;
233  tmpboostZ(1,2)=0.;
234  tmpboostZ(1,3)=0.;
235  tmpboostZ(2,0)=-1.0*beta_*gama;
236  tmpboostZ(2,1) = 0.;
237  tmpboostZ(2,2)=gama;
238  tmpboostZ(2,3) = 0.;
239  tmpboostZ(3,0)=0.;
240  tmpboostZ(3,1)=0.;
241  tmpboostZ(3,2)=0.;
242  tmpboostZ(3,3) = 1.;
243 
244  tmpboostXYZ=tmpboostZ*tmpboost;
245  tmpboostXYZ.Invert();
246 
247 
248 
249  boost_ = new TMatrixD(tmpboostXYZ);
250  if ( verbosity_ ) { boost_->Print(); }
251 
252  return boost_;
253 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:18
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 ( CLHEP::HepRandomEngine *  engine)
virtual

return a new event vertex

Definition at line 145 of file BetaBoostEvtVtxGenerator.cc.

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

Referenced by produce().

145  {
146 
147 
148  double X,Y,Z;
149 
150  double tmp_sigz = CLHEP::RandGaussQ::shoot(engine, 0.0, fSigmaZ);
151  Z = tmp_sigz + fZ0;
152 
153  double tmp_sigx = BetaFunction(Z,fZ0);
154  // need sqrt(2) for beamspot width relative to single beam width
155  tmp_sigx /= sqrt(2.0);
156  X = CLHEP::RandGaussQ::shoot(engine, 0.0, tmp_sigx) + fX0; // + Z*fdxdz ;
157 
158  double tmp_sigy = BetaFunction(Z,fZ0);
159  // need sqrt(2) for beamspot width relative to single beam width
160  tmp_sigy /= sqrt(2.0);
161  Y = CLHEP::RandGaussQ::shoot(engine, 0.0, tmp_sigy) + fY0; // + Z*fdydz;
162 
163  double tmp_sigt = CLHEP::RandGaussQ::shoot(engine, 0.0, fSigmaZ);
164  double T = tmp_sigt + fTimeOffset;
165 
166  if ( fVertex == 0 ) fVertex = new HepMC::FourVector();
167  fVertex->set(X,Y,Z,T);
168 
169  return fVertex;
170 }
const double Z[kNumberCalorimeter]
#define X(str)
Definition: MuonsGrabber.cc:48
T sqrt(T t)
Definition: SSEVec.h:18
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
void BetaBoostEvtVtxGenerator::produce ( edm::Event evt,
const edm::EventSetup  
)
overridevirtual

Implements edm::EDProducer.

Definition at line 255 of file BetaBoostEvtVtxGenerator.cc.

References Exception, edm::Event::getByToken(), edm::RandomNumberGenerator::getEngine(), GetInvLorentzBoost(), edm::Service< T >::isAvailable(), eostools::move(), newVertex(), edm::Event::put(), reco::return(), rng, sourceLabel, and edm::Event::streamID().

256 {
258  if (!rng.isAvailable()) {
259  throw cms::Exception("Configuration")
260  << "Attempt to get a random engine when the RandomNumberGeneratorService is not configured.\n"
261  "You must configure the service if you want an engine.\n";
262  }
263  CLHEP::HepRandomEngine* engine = &rng->getEngine(evt.streamID());
264 
265  Handle<HepMCProduct> HepUnsmearedMCEvt;
266  evt.getByToken(sourceLabel, HepUnsmearedMCEvt);
267 
268  // Copy the HepMC::GenEvent
269  HepMC::GenEvent* genevt = new HepMC::GenEvent(*HepUnsmearedMCEvt->GetEvent());
270  std::unique_ptr<edm::HepMCProduct> HepMCEvt(new edm::HepMCProduct(genevt));
271 
272  // generate new vertex & apply the shift
273  //
274  HepMCEvt->applyVtxGen( newVertex(engine) ) ;
275 
276  //HepMCEvt->LorentzBoost( 0., 142.e-6 );
277  HepMCEvt->boostToLab( GetInvLorentzBoost(), "vertex" );
278  HepMCEvt->boostToLab( GetInvLorentzBoost(), "momentum" );
279  evt.put(std::move(HepMCEvt));
280 
281  return ;
282 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
edm::Service< edm::RandomNumberGenerator > rng
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
virtual HepMC::FourVector * newVertex(CLHEP::HepRandomEngine *)
return a new event vertex
edm::EDGetTokenT< HepMCProduct > sourceLabel
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
def move
Definition: eostools.py:510
bool isAvailable() const
Definition: Service.h:46
return(e1-e2)*(e1-e2)+dp *dp
StreamID streamID() const
Definition: Event.h:81
virtual TMatrixD * GetInvLorentzBoost()
void BetaBoostEvtVtxGenerator::sigmaZ ( double  s = 1.0)

set resolution in Z in cm

Definition at line 179 of file BetaBoostEvtVtxGenerator.cc.

References Exception, fSigmaZ, and alignCSCRings::s.

180 {
181  if (s>=0 ) {
182  fSigmaZ=s;
183  }
184  else {
185  throw cms::Exception("LogicError")
186  << "Error in BetaBoostEvtVtxGenerator::sigmaZ: "
187  << "Illegal resolution in Z (negative)";
188  }
189 }
void BetaBoostEvtVtxGenerator::X0 ( double  m = 0)
inline
void BetaBoostEvtVtxGenerator::Y0 ( double  m = 0)
inline
void BetaBoostEvtVtxGenerator::Z0 ( double  m = 0)
inline

Member Data Documentation

double BetaBoostEvtVtxGenerator::alpha_
private

Definition at line 94 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and GetInvLorentzBoost().

double BetaBoostEvtVtxGenerator::beta_
private

Definition at line 96 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and GetInvLorentzBoost().

TMatrixD* BetaBoostEvtVtxGenerator::boost_
private

Definition at line 104 of file BetaBoostEvtVtxGenerator.cc.

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

double BetaBoostEvtVtxGenerator::falpha
private

Definition at line 101 of file BetaBoostEvtVtxGenerator.cc.

double BetaBoostEvtVtxGenerator::fbetastar
private

Definition at line 100 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and BetaFunction().

double BetaBoostEvtVtxGenerator::femittance
private

Definition at line 100 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and BetaFunction().

double BetaBoostEvtVtxGenerator::fSigmaZ
private

Definition at line 98 of file BetaBoostEvtVtxGenerator.cc.

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

double BetaBoostEvtVtxGenerator::fTimeOffset
private

Definition at line 105 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

HepMC::FourVector* BetaBoostEvtVtxGenerator::fVertex
private

Definition at line 103 of file BetaBoostEvtVtxGenerator.cc.

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

double BetaBoostEvtVtxGenerator::fX0
private

Definition at line 97 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

double BetaBoostEvtVtxGenerator::fY0
private

Definition at line 97 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

double BetaBoostEvtVtxGenerator::fZ0
private

Definition at line 97 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

double BetaBoostEvtVtxGenerator::phi_
private

Definition at line 94 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and GetInvLorentzBoost().

edm::EDGetTokenT<HepMCProduct> BetaBoostEvtVtxGenerator::sourceLabel
private

Definition at line 107 of file BetaBoostEvtVtxGenerator.cc.

Referenced by produce().

bool BetaBoostEvtVtxGenerator::verbosity_
private

Definition at line 109 of file BetaBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().