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)
 
 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &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

 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::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
 
- 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 50 of file BetaBoostEvtVtxGenerator.cc.

Constructor & Destructor Documentation

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

Definition at line 111 of file BetaBoostEvtVtxGenerator.cc.

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

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

Definition at line 136 of file BetaBoostEvtVtxGenerator.cc.

References boost_, and fVertex.

137 {
138  delete fVertex ;
139  if (boost_ != 0 ) delete boost_;
140 }
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 visualization-live-secondInstance_cfg::m.

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

beta function

Definition at line 170 of file BetaBoostEvtVtxGenerator.cc.

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

Referenced by newVertex().

171 {
172  return sqrt(femittance*(fbetastar+(((z-z0)*(z-z0))/fbetastar)));
173 
174 }
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 189 of file BetaBoostEvtVtxGenerator.cc.

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

Referenced by produce().

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

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

Referenced by produce().

143  {
144 
145 
146  double X,Y,Z;
147 
148  double tmp_sigz = CLHEP::RandGaussQ::shoot(engine, 0.0, fSigmaZ);
149  Z = tmp_sigz + fZ0;
150 
151  double tmp_sigx = BetaFunction(Z,fZ0);
152  // need sqrt(2) for beamspot width relative to single beam width
153  tmp_sigx /= sqrt(2.0);
154  X = CLHEP::RandGaussQ::shoot(engine, 0.0, tmp_sigx) + fX0; // + Z*fdxdz ;
155 
156  double tmp_sigy = BetaFunction(Z,fZ0);
157  // need sqrt(2) for beamspot width relative to single beam width
158  tmp_sigy /= sqrt(2.0);
159  Y = CLHEP::RandGaussQ::shoot(engine, 0.0, tmp_sigy) + fY0; // + Z*fdydz;
160 
161  double tmp_sigt = CLHEP::RandGaussQ::shoot(engine, 0.0, fSigmaZ);
162  double T = tmp_sigt + fTimeOffset;
163 
164  if ( fVertex == 0 ) fVertex = new HepMC::FourVector();
165  fVertex->set(X,Y,Z,T);
166 
167  return fVertex;
168 }
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 253 of file BetaBoostEvtVtxGenerator.cc.

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

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

set resolution in Z in cm

Definition at line 177 of file BetaBoostEvtVtxGenerator.cc.

References Exception, fSigmaZ, and alignCSCRings::s.

178 {
179  if (s>=0 ) {
180  fSigmaZ=s;
181  }
182  else {
183  throw cms::Exception("LogicError")
184  << "Error in BetaBoostEvtVtxGenerator::sigmaZ: "
185  << "Illegal resolution in Z (negative)";
186  }
187 }
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 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().

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 105 of file BetaBoostEvtVtxGenerator.cc.

Referenced by produce().

bool BetaBoostEvtVtxGenerator::verbosity_
private

Definition at line 107 of file BetaBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().