CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
edm::FlatRandomPtAndDxyGunProducer Class Reference

#include <FlatRandomPtAndDxyGunProducer.h>

Inheritance diagram for edm::FlatRandomPtAndDxyGunProducer:
edm::BaseFlatGunProducer edm::one::EDProducer< one::WatchRuns, EndRunProducer > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 FlatRandomPtAndDxyGunProducer (const ParameterSet &pset)
 
void produce (Event &e, const EventSetup &es) override
 
 ~FlatRandomPtAndDxyGunProducer () override
 
- Public Member Functions inherited from edm::BaseFlatGunProducer
 BaseFlatGunProducer (const ParameterSet &)
 
void beginRun (const edm::Run &r, const edm::EventSetup &) override
 
void endRun (edm::Run const &r, const edm::EventSetup &) override
 
void endRunProduce (edm::Run &r, const edm::EventSetup &) override
 
 ~BaseFlatGunProducer () override
 
- Public Member Functions inherited from edm::one::EDProducer< one::WatchRuns, EndRunProducer >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () 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
 
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)
 
 ~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

double ConeH_
 
double ConeRadius_
 
double DistanceToAPEX_
 
double dxyMax_
 
double dxyMin_
 
double fMaxPt
 
double fMinPt
 
double lxyMax_
 
double lzMax_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
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)
 
- Protected Attributes inherited from edm::BaseFlatGunProducer
bool fAddAntiParticle
 
HepMC::GenEventfEvt
 
double fMaxEta
 
double fMaxPhi
 
double fMinEta
 
double fMinPhi
 
std::vector< int > fPartIDs
 
ESHandle
< HepPDT::ParticleDataTable
fPDGTable
 
int fVerbosity
 

Detailed Description

Definition at line 24 of file FlatRandomPtAndDxyGunProducer.h.

Constructor & Destructor Documentation

FlatRandomPtAndDxyGunProducer::FlatRandomPtAndDxyGunProducer ( const ParameterSet pset)

Definition at line 18 of file FlatRandomPtAndDxyGunProducer.cc.

References ConeH_, ConeRadius_, DistanceToAPEX_, dxyMax_, dxyMin_, fMaxPt, fMinPt, edm::ParameterSet::getParameter(), lxyMax_, and lzMax_.

18  : BaseFlatGunProducer(pset) {
19  ParameterSet defpset;
20  ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters");
21 
22  fMinPt = pgun_params.getParameter<double>("MinPt");
23  fMaxPt = pgun_params.getParameter<double>("MaxPt");
24  dxyMin_ = pgun_params.getParameter<double>("dxyMin");
25  dxyMax_ = pgun_params.getParameter<double>("dxyMax");
26  lxyMax_ = pgun_params.getParameter<double>("LxyMax");
27  lzMax_ = pgun_params.getParameter<double>("LzMax");
28  ConeRadius_ = pgun_params.getParameter<double>("ConeRadius");
29  ConeH_ = pgun_params.getParameter<double>("ConeH");
30  DistanceToAPEX_ = pgun_params.getParameter<double>("DistanceToAPEX");
31 
32  produces<HepMCProduct>("unsmeared");
33  produces<GenEventInfoProduct>();
34 }
BaseFlatGunProducer(const ParameterSet &)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
FlatRandomPtAndDxyGunProducer::~FlatRandomPtAndDxyGunProducer ( )
override

Definition at line 36 of file FlatRandomPtAndDxyGunProducer.cc.

36  {
37  // no need to cleanup GenEvent memory - done in HepMCProduct
38 }

Member Function Documentation

void FlatRandomPtAndDxyGunProducer::produce ( Event e,
const EventSetup es 
)
overridevirtual

Implements edm::one::EDProducerBase.

Definition at line 40 of file FlatRandomPtAndDxyGunProducer.cc.

References funct::abs(), ConeH_, ConeRadius_, funct::cos(), gather_cfg::cout, DistanceToAPEX_, PVValHelper::dxy, dxyMax_, dxyMin_, relval_parameters_module::energy, PVValHelper::eta, edm::EventID::event(), edm::BaseFlatGunProducer::fAddAntiParticle, edm::BaseFlatGunProducer::fEvt, edm::BaseFlatGunProducer::fMaxEta, edm::BaseFlatGunProducer::fMaxPhi, fMaxPt, edm::BaseFlatGunProducer::fMinEta, edm::BaseFlatGunProducer::fMinPhi, fMinPt, edm::BaseFlatGunProducer::fPartIDs, edm::BaseFlatGunProducer::fPDGTable, edm::BaseFlatGunProducer::fVerbosity, GenParticle::GenParticle, edm::RandomNumberGenerator::getEngine(), mps_fire::i, edm::EventBase::id(), dqmiolumiharvest::j, lxyMax_, lzMax_, ResonanceBuilder::mass, eostools::move(), or, AlCaHLTBitMon_ParallelJobs::p, DiDispStaMuonMonitor_cfi::pt, edm::Event::put(), funct::sin(), mathSSE::sqrt(), and edm::Event::streamID().

40  {
42  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
43 
44  if (fVerbosity > 0) {
45  cout << " FlatRandomPtAndDxyGunProducer : Begin New Event Generation" << endl;
46  }
47  // event loop (well, another step in it...)
48 
49  // no need to clean up GenEvent memory - done in HepMCProduct
50  //
51 
52  // here re-create fEvt (memory)
53  //
54  fEvt = new HepMC::GenEvent();
55 
56  // now actualy, cook up the event from PDGTable and gun parameters
57  int barcode = 1;
58  for (unsigned int ip = 0; ip < fPartIDs.size(); ++ip) {
59  double phi_vtx = 0;
60  double dxy = 0;
61  double pt = 0;
62  double eta = 0;
63  double px = 0;
64  double py = 0;
65  double pz = 0;
66  double vx = 0;
67  double vy = 0;
68  double vz = 0;
69  double lxy = 0;
70 
71  bool passLoop = false;
72  while (not passLoop) {
73  bool passLxy = false;
74  bool passLz = false;
75  phi_vtx = CLHEP::RandFlat::shoot(engine, fMinPhi, fMaxPhi);
76  dxy = CLHEP::RandFlat::shoot(engine, dxyMin_, dxyMax_);
77  float dxysign = CLHEP::RandFlat::shoot(engine, -1, 1);
78  if (dxysign < 0)
79  dxy = -dxy;
80  pt = CLHEP::RandFlat::shoot(engine, fMinPt, fMaxPt);
81  px = pt * cos(phi_vtx);
82  py = pt * sin(phi_vtx);
83  for (int i = 0; i < 10000; i++) {
84  vx = CLHEP::RandFlat::shoot(engine, -lxyMax_, lxyMax_);
85  vy = (pt * dxy + vx * py) / px;
86  lxy = sqrt(vx * vx + vy * vy);
87  if (lxy < abs(lxyMax_) and (vx * px + vy * py) > 0) {
88  passLxy = true;
89  break;
90  }
91  }
92  eta = CLHEP::RandFlat::shoot(engine, fMinEta, fMaxEta);
93  pz = pt * sinh(eta);
94  //vz = fabs(fRandomGaussGenerator->fire(0.0, LzWidth_/2.0));
95  float ConeTheta = ConeRadius_ / ConeH_;
96  for (int j = 0; j < 100; j++) {
97  vz = CLHEP::RandFlat::shoot(engine, 0.0, lzMax_); // this is abs(vz)
98  float v0 = vz - DistanceToAPEX_;
99  if (v0 <= 0 or lxy * lxy / (ConeTheta * ConeTheta) > v0 * v0) {
100  passLz = true;
101  break;
102  }
103  }
104  if (pz < 0)
105  vz = -vz;
106  passLoop = (passLxy and passLz);
107 
108  if (passLoop)
109  break;
110  }
111 
112  float time = sqrt(vx * vx + vy * vy + vz * vz);
113 
114  HepMC::GenVertex* Vtx1 = new HepMC::GenVertex(HepMC::FourVector(vx, vy, vz, time));
115 
116  int PartID = fPartIDs[ip];
117  const HepPDT::ParticleData* PData = fPDGTable->particle(HepPDT::ParticleID(abs(PartID)));
118  double mass = PData->mass().value();
119  double energy2 = px * px + py * py + pz * pz + mass * mass;
120  double energy = sqrt(energy2);
121  HepMC::FourVector p(px, py, pz, energy);
122  HepMC::GenParticle* Part = new HepMC::GenParticle(p, PartID, 1);
123  Part->suggest_barcode(barcode);
124  barcode++;
125  Vtx1->add_particle_out(Part);
126  fEvt->add_vertex(Vtx1);
127 
128  if (fAddAntiParticle) {
129  HepMC::GenVertex* Vtx2 = new HepMC::GenVertex(HepMC::FourVector(-vx, -vy, -vz, time));
130  HepMC::FourVector ap(-px, -py, -pz, energy);
131  int APartID = -PartID;
132  if (PartID == 22 || PartID == 23) {
133  APartID = PartID;
134  }
135  HepMC::GenParticle* APart = new HepMC::GenParticle(ap, APartID, 1);
136  APart->suggest_barcode(barcode);
137  barcode++;
138  Vtx2->add_particle_out(APart);
139  fEvt->add_vertex(Vtx2);
140  }
141  }
142  fEvt->set_event_number(e.id().event());
143  fEvt->set_signal_process_id(20);
144 
145  if (fVerbosity > 0) {
146  fEvt->print();
147  }
148 
149  unique_ptr<HepMCProduct> BProduct(new HepMCProduct());
150  BProduct->addHepMCData(fEvt);
151  e.put(std::move(BProduct), "unsmeared");
152 
153  unique_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(fEvt));
154  e.put(std::move(genEventInfo));
155 
156  if (fVerbosity > 0) {
157  cout << " FlatRandomPtAndDxyGunProducer : End New Event Generation" << endl;
158  fEvt->print();
159  }
160 }
EventNumber_t event() const
Definition: EventID.h:40
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
ESHandle< HepPDT::ParticleDataTable > fPDGTable
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
def move
Definition: eostools.py:511
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< int > fPartIDs
HepPDT::ParticleData ParticleData
edm::EventID id() const
Definition: EventBase.h:59
StreamID streamID() const
Definition: Event.h:98
tuple cout
Definition: gather_cfg.py:144

Member Data Documentation

double edm::FlatRandomPtAndDxyGunProducer::ConeH_
private

Definition at line 41 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::ConeRadius_
private

Definition at line 40 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::DistanceToAPEX_
private

Definition at line 42 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::dxyMax_
private

Definition at line 37 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::dxyMin_
private

Definition at line 36 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::fMaxPt
private

Definition at line 35 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::fMinPt
private

Definition at line 34 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::lxyMax_
private

Definition at line 38 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::lzMax_
private

Definition at line 39 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().