CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
BetaBoostEvtVtxGenerator Class Reference
Inheritance diagram for BetaBoostEvtVtxGenerator:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 BetaBoostEvtVtxGenerator (const edm::ParameterSet &p)
 
 BetaBoostEvtVtxGenerator (const BetaBoostEvtVtxGenerator &p)=delete
 
double BetaFunction (double z, double z0) const
 beta function More...
 
TMatrixD GetInvLorentzBoost () const
 
HepMC::FourVector newVertex (CLHEP::HepRandomEngine *) const
 return a new event vertex More...
 
BetaBoostEvtVtxGeneratoroperator= (const BetaBoostEvtVtxGenerator &rhs)=delete
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 ~BetaBoostEvtVtxGenerator () override=default
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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 & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

const double alpha_
 
const double beta_
 
const TMatrixD boost_
 
const double fbetastar
 
const double femittance
 
const double fSigmaZ
 
const double fTimeOffset
 
const double fX0
 
const double fY0
 
const double fZ0
 
const double phi_
 
const edm::EDGetTokenT< HepMCProductsourceLabel
 
const bool verbosity_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 51 of file BetaBoostEvtVtxGenerator.cc.

Constructor & Destructor Documentation

◆ BetaBoostEvtVtxGenerator() [1/2]

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

Definition at line 89 of file BetaBoostEvtVtxGenerator.cc.

References Exception, and fSigmaZ.

90  : alpha_(p.getParameter<double>("Alpha") * radian),
91  phi_(p.getParameter<double>("Phi") * radian),
92  beta_(p.getParameter<double>("Beta")),
93  fX0(p.getParameter<double>("X0") * cm),
94  fY0(p.getParameter<double>("Y0") * cm),
95  fZ0(p.getParameter<double>("Z0") * cm),
96  fSigmaZ(p.getParameter<double>("SigmaZ") * cm),
97  fbetastar(p.getParameter<double>("BetaStar") * cm),
98  femittance(p.getParameter<double>("Emittance") * cm), // this is not the normalized emittance
99  fTimeOffset(p.getParameter<double>("TimeOffset") * ns * c_light), // HepMC time units are mm
101  sourceLabel(consumes<HepMCProduct>(p.getParameter<edm::InputTag>("src"))),
102  verbosity_(p.getUntrackedParameter<bool>("verbosity", false)) {
103  if (fSigmaZ <= 0) {
104  throw cms::Exception("Configuration") << "Error in BetaBoostEvtVtxGenerator: "
105  << "Illegal resolution in Z (SigmaZ is negative)";
106  }
107 
108  produces<edm::HepMCProduct>();
109 }
const edm::EDGetTokenT< HepMCProduct > sourceLabel

◆ BetaBoostEvtVtxGenerator() [2/2]

BetaBoostEvtVtxGenerator::BetaBoostEvtVtxGenerator ( const BetaBoostEvtVtxGenerator p)
delete

Copy constructor

◆ ~BetaBoostEvtVtxGenerator()

BetaBoostEvtVtxGenerator::~BetaBoostEvtVtxGenerator ( )
overridedefault

Member Function Documentation

◆ BetaFunction()

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

beta function

Definition at line 133 of file BetaBoostEvtVtxGenerator.cc.

References fbetastar, femittance, mathSSE::sqrt(), z, and HLTMuonOfflineAnalyzer_cfi::z0.

Referenced by newVertex().

◆ GetInvLorentzBoost()

TMatrixD BetaBoostEvtVtxGenerator::GetInvLorentzBoost ( ) const

Definition at line 137 of file BetaBoostEvtVtxGenerator.cc.

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

137  {
138  //alpha_ = 0;
139  //phi_ = 142.e-6;
140  // if (boost_ != 0 ) return boost_;
141 
142  //boost_.ResizeTo(4,4);
143  //boost_ = new TMatrixD(4,4);
144  TMatrixD tmpboost(4, 4);
145  TMatrixD tmpboostZ(4, 4);
146  TMatrixD tmpboostXYZ(4, 4);
147 
148  //if ( (alpha_ == 0) && (phi_==0) ) { boost_->Zero(); return boost_; }
149 
150  // Lorentz boost to frame where the collision is head-on
151  // phi is the half crossing angle in the plane ZS
152  // alpha is the angle to the S axis from the X axis in the XY plane
153 
154  tmpboost(0, 0) = 1. / cos(phi_);
155  tmpboost(0, 1) = -cos(alpha_) * sin(phi_);
156  tmpboost(0, 2) = -tan(phi_) * sin(phi_);
157  tmpboost(0, 3) = -sin(alpha_) * sin(phi_);
158  tmpboost(1, 0) = -cos(alpha_) * tan(phi_);
159  tmpboost(1, 1) = 1.;
160  tmpboost(1, 2) = cos(alpha_) * tan(phi_);
161  tmpboost(1, 3) = 0.;
162  tmpboost(2, 0) = 0.;
163  tmpboost(2, 1) = -cos(alpha_) * sin(phi_);
164  tmpboost(2, 2) = cos(phi_);
165  tmpboost(2, 3) = -sin(alpha_) * sin(phi_);
166  tmpboost(3, 0) = -sin(alpha_) * tan(phi_);
167  tmpboost(3, 1) = 0.;
168  tmpboost(3, 2) = sin(alpha_) * tan(phi_);
169  tmpboost(3, 3) = 1.;
170  //cout<<"beta "<<beta_;
171  double gama = 1.0 / sqrt(1 - beta_ * beta_);
172  tmpboostZ(0, 0) = gama;
173  tmpboostZ(0, 1) = 0.;
174  tmpboostZ(0, 2) = -1.0 * beta_ * gama;
175  tmpboostZ(0, 3) = 0.;
176  tmpboostZ(1, 0) = 0.;
177  tmpboostZ(1, 1) = 1.;
178  tmpboostZ(1, 2) = 0.;
179  tmpboostZ(1, 3) = 0.;
180  tmpboostZ(2, 0) = -1.0 * beta_ * gama;
181  tmpboostZ(2, 1) = 0.;
182  tmpboostZ(2, 2) = gama;
183  tmpboostZ(2, 3) = 0.;
184  tmpboostZ(3, 0) = 0.;
185  tmpboostZ(3, 1) = 0.;
186  tmpboostZ(3, 2) = 0.;
187  tmpboostZ(3, 3) = 1.;
188 
189  tmpboostXYZ = tmpboostZ * tmpboost;
190  tmpboostXYZ.Invert();
191 
192  if (verbosity_) {
193  tmpboostXYZ.Print();
194  }
195 
196  return tmpboostXYZ;
197 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22

◆ newVertex()

HepMC::FourVector BetaBoostEvtVtxGenerator::newVertex ( CLHEP::HepRandomEngine *  engine) const

return a new event vertex

Definition at line 111 of file BetaBoostEvtVtxGenerator.cc.

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

Referenced by produce().

111  {
112  double X, Y, Z;
113 
114  double tmp_sigz = CLHEP::RandGaussQ::shoot(engine, 0.0, fSigmaZ);
115  Z = tmp_sigz + fZ0;
116 
117  double tmp_sigx = BetaFunction(Z, fZ0);
118  // need sqrt(2) for beamspot width relative to single beam width
119  tmp_sigx /= sqrt(2.0);
120  X = CLHEP::RandGaussQ::shoot(engine, 0.0, tmp_sigx) + fX0; // + Z*fdxdz ;
121 
122  double tmp_sigy = BetaFunction(Z, fZ0);
123  // need sqrt(2) for beamspot width relative to single beam width
124  tmp_sigy /= sqrt(2.0);
125  Y = CLHEP::RandGaussQ::shoot(engine, 0.0, tmp_sigy) + fY0; // + Z*fdydz;
126 
127  double tmp_sigt = CLHEP::RandGaussQ::shoot(engine, 0.0, fSigmaZ);
128  double T = tmp_sigt + fTimeOffset;
129 
130  return HepMC::FourVector(X, Y, Z, T);
131 }
double BetaFunction(double z, double z0) const
beta function
#define X(str)
Definition: MuonsGrabber.cc:38
T sqrt(T t)
Definition: SSEVec.h:19
long double T

◆ operator=()

BetaBoostEvtVtxGenerator& BetaBoostEvtVtxGenerator::operator= ( const BetaBoostEvtVtxGenerator rhs)
delete

Copy assignment operator

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 199 of file BetaBoostEvtVtxGenerator.cc.

References boost_, Exception, edm::Event::get(), edm::RandomNumberGenerator::getEngine(), edm::Service< T >::isAvailable(), eostools::move(), newVertex(), edm::Event::put(), sourceLabel, edm::Event::streamID(), and bphysicsOniaDQM_cfi::vertex.

199  {
201  if (!rng.isAvailable()) {
202  throw cms::Exception("Configuration")
203  << "Attempt to get a random engine when the RandomNumberGeneratorService is not configured.\n"
204  "You must configure the service if you want an engine.\n";
205  }
206  CLHEP::HepRandomEngine* engine = &rng->getEngine(evt.streamID());
207 
208  const auto& HepUnsmearedMCEvt = evt.get(sourceLabel);
209 
210  // Copy the HepMC::GenEvent
211  auto HepMCEvt = std::make_unique<edm::HepMCProduct>(new HepMC::GenEvent(*HepUnsmearedMCEvt.GetEvent()));
212 
213  // generate new vertex & apply the shift
214  //
215  auto vertex = newVertex(engine);
216  HepMCEvt->applyVtxGen(&vertex);
217 
218  //HepMCEvt->LorentzBoost( 0., 142.e-6 );
219  HepMCEvt->boostToLab(&boost_, "vertex");
220  HepMCEvt->boostToLab(&boost_, "momentum");
221  evt.put(std::move(HepMCEvt));
222 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:347
HepMC::FourVector newVertex(CLHEP::HepRandomEngine *) const
return a new event vertex
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
const edm::EDGetTokenT< HepMCProduct > sourceLabel
StreamID streamID() const
Definition: Event.h:98
bool isAvailable() const
Definition: Service.h:40
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ alpha_

const double BetaBoostEvtVtxGenerator::alpha_
private

Definition at line 69 of file BetaBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().

◆ beta_

const double BetaBoostEvtVtxGenerator::beta_
private

Definition at line 71 of file BetaBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().

◆ boost_

const TMatrixD BetaBoostEvtVtxGenerator::boost_
private

Definition at line 82 of file BetaBoostEvtVtxGenerator.cc.

Referenced by produce().

◆ fbetastar

const double BetaBoostEvtVtxGenerator::fbetastar
private

Definition at line 77 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaFunction().

◆ femittance

const double BetaBoostEvtVtxGenerator::femittance
private

Definition at line 78 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaFunction().

◆ fSigmaZ

const double BetaBoostEvtVtxGenerator::fSigmaZ
private

Definition at line 75 of file BetaBoostEvtVtxGenerator.cc.

Referenced by BetaBoostEvtVtxGenerator(), and newVertex().

◆ fTimeOffset

const double BetaBoostEvtVtxGenerator::fTimeOffset
private

Definition at line 80 of file BetaBoostEvtVtxGenerator.cc.

Referenced by newVertex().

◆ fX0

const double BetaBoostEvtVtxGenerator::fX0
private

Definition at line 72 of file BetaBoostEvtVtxGenerator.cc.

Referenced by newVertex().

◆ fY0

const double BetaBoostEvtVtxGenerator::fY0
private

Definition at line 73 of file BetaBoostEvtVtxGenerator.cc.

Referenced by newVertex().

◆ fZ0

const double BetaBoostEvtVtxGenerator::fZ0
private

Definition at line 74 of file BetaBoostEvtVtxGenerator.cc.

Referenced by newVertex().

◆ phi_

const double BetaBoostEvtVtxGenerator::phi_
private

Definition at line 70 of file BetaBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().

◆ sourceLabel

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

Definition at line 84 of file BetaBoostEvtVtxGenerator.cc.

Referenced by produce().

◆ verbosity_

const bool BetaBoostEvtVtxGenerator::verbosity_
private

Definition at line 86 of file BetaBoostEvtVtxGenerator.cc.

Referenced by GetInvLorentzBoost().