CMS 3D CMS Logo

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
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
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::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
 
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)
 
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<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)
 
- Protected Attributes inherited from edm::BaseFlatGunProducer
bool fAddAntiParticle
 
HepMC::GenEventfEvt
 
double fMaxEta
 
double fMaxPhi
 
double fMinEta
 
double fMinPhi
 
std::vector< int > fPartIDs
 
ESHandle< HepPDT::ParticleDataTablefPDGTable
 
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 }
T getParameter(std::string const &) const
BaseFlatGunProducer(const ParameterSet &)
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 
)
override

Definition at line 40 of file FlatRandomPtAndDxyGunProducer.cc.

References funct::abs(), ConeH_, ConeRadius_, funct::cos(), gather_cfg::cout, DistanceToAPEX_, PVValHelper::dxy, dxyMax_, dxyMin_, HCALHighEnergyHPDFilter_cfi::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, genParticles2HepMC_cfi::genEventInfo, GenParticle::GenParticle, edm::RandomNumberGenerator::getEngine(), GenLeadTrackFilter_cfi::HepMCProduct, mps_fire::i, edm::EventBase::id(), dqmiolumiharvest::j, lxyMax_, lzMax_, EgHLTOffHistBins_cfi::mass, eostools::move(), or, AlCaHLTBitMon_ParallelJobs::p, LHEGenericFilter_cfi::ParticleID, genfragment_ptgun_cfg::PartID, DiDispStaMuonMonitor_cfi::pt, edm::Event::put(), multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, funct::sin(), mathSSE::sqrt(), edm::Event::streamID(), and V0Monitor_cff::v0.

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  HepMC::GenVertex* Vtx1 = new HepMC::GenVertex(HepMC::FourVector(vx, vy, vz));
113 
114  int PartID = fPartIDs[ip];
115  const HepPDT::ParticleData* PData = fPDGTable->particle(HepPDT::ParticleID(abs(PartID)));
116  double mass = PData->mass().value();
117  double energy2 = px * px + py * py + pz * pz + mass * mass;
118  double energy = sqrt(energy2);
119  HepMC::FourVector p(px, py, pz, energy);
120  HepMC::GenParticle* Part = new HepMC::GenParticle(p, PartID, 1);
121  Part->suggest_barcode(barcode);
122  barcode++;
123  Vtx1->add_particle_out(Part);
124  fEvt->add_vertex(Vtx1);
125 
126  if (fAddAntiParticle) {
127  HepMC::GenVertex* Vtx2 = new HepMC::GenVertex(HepMC::FourVector(-vx, -vy, -vz));
128  HepMC::FourVector ap(-px, -py, -pz, energy);
129  int APartID = -PartID;
130  if (PartID == 22 || PartID == 23) {
131  APartID = PartID;
132  }
133  HepMC::GenParticle* APart = new HepMC::GenParticle(ap, APartID, 1);
134  APart->suggest_barcode(barcode);
135  barcode++;
136  Vtx2->add_particle_out(APart);
137  fEvt->add_vertex(Vtx2);
138  }
139  }
140  fEvt->set_event_number(e.id().event());
141  fEvt->set_signal_process_id(20);
142 
143  if (fVerbosity > 0) {
144  fEvt->print();
145  }
146 
147  unique_ptr<HepMCProduct> BProduct(new HepMCProduct());
148  BProduct->addHepMCData(fEvt);
149  e.put(std::move(BProduct), "unsmeared");
150 
151  unique_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(fEvt));
153 
154  if (fVerbosity > 0) {
155  cout << " FlatRandomPtAndDxyGunProducer : End New Event Generation" << endl;
156  fEvt->print();
157  }
158 }
EventNumber_t event() const
Definition: EventID.h:40
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
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
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::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
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:96
def move(src, dest)
Definition: eostools.py:511

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().