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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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::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 25 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  :
20 {
21  ParameterSet defpset ;
22  ParameterSet pgun_params =
23  pset.getParameter<ParameterSet>("PGunParameters") ;
24 
25  fMinPt = pgun_params.getParameter<double>("MinPt");
26  fMaxPt = pgun_params.getParameter<double>("MaxPt");
27  dxyMin_ = pgun_params.getParameter<double>("dxyMin");
28  dxyMax_ = pgun_params.getParameter<double>("dxyMax");
29  lxyMax_ = pgun_params.getParameter<double>("LxyMax");
30  lzMax_ = pgun_params.getParameter<double>("LzMax");
31  ConeRadius_ = pgun_params.getParameter<double>("ConeRadius");
32  ConeH_ = pgun_params.getParameter<double>("ConeH");
33  DistanceToAPEX_ = pgun_params.getParameter<double>("DistanceToAPEX");
34 
35  produces<HepMCProduct>("unsmeared");
36  produces<GenEventInfoProduct>();
37 }
T getParameter(std::string const &) const
BaseFlatGunProducer(const ParameterSet &)
FlatRandomPtAndDxyGunProducer::~FlatRandomPtAndDxyGunProducer ( )
override

Definition at line 39 of file FlatRandomPtAndDxyGunProducer.cc.

40 {
41  // no need to cleanup GenEvent memory - done in HepMCProduct
42 }

Member Function Documentation

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

Definition at line 44 of file FlatRandomPtAndDxyGunProducer.cc.

References funct::abs(), ConeH_, ConeRadius_, funct::cos(), gather_cfg::cout, DistanceToAPEX_, PVValHelper::dxy, dxyMax_, dxyMin_, randomXiThetaGunProducer_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, particlelevel_cff::genEventInfo, GenParticle::GenParticle, edm::RandomNumberGenerator::getEngine(), mps_fire::i, edm::EventBase::id(), lxyMax_, lzMax_, ResonanceBuilder::mass, eostools::move(), or, AlCaHLTBitMon_ParallelJobs::p, source_particleGun_cfi::ParticleID, CastorDigiValidation::PartID, EnergyCorrector::pt, edm::Event::put(), funct::sin(), mathSSE::sqrt(), and edm::Event::streamID().

45 {
47  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
48 
49  if ( fVerbosity > 0 ){
50  cout << " FlatRandomPtAndDxyGunProducer : Begin New Event Generation" << endl ;
51  }
52  // event loop (well, another step in it...)
53 
54  // no need to clean up GenEvent memory - done in HepMCProduct
55  //
56 
57  // here re-create fEvt (memory)
58  //
59  fEvt = new HepMC::GenEvent() ;
60 
61  // now actualy, cook up the event from PDGTable and gun parameters
62  int barcode = 1 ;
63  for (unsigned int ip=0; ip<fPartIDs.size(); ++ip){
64 
65  double phi_vtx = 0;
66  double dxy = 0;
67  double pt = 0;
68  double eta = 0;
69  double px = 0;
70  double py = 0;
71  double pz = 0;
72  double vx = 0;
73  double vy = 0;
74  double vz = 0;
75  double lxy = 0;
76 
77  bool passLoop = false;
78  while (not passLoop) {
79 
80  bool passLxy = false;
81  bool passLz = false;
82  phi_vtx = CLHEP::RandFlat::shoot(engine, fMinPhi, fMaxPhi);
83  dxy = CLHEP::RandFlat::shoot(engine, dxyMin_, dxyMax_);
84  float dxysign = CLHEP::RandFlat::shoot(engine, -1, 1);
85  if (dxysign < 0)
86  dxy = -dxy;
87  pt = CLHEP::RandFlat::shoot(engine, fMinPt, fMaxPt);
88  px = pt*cos(phi_vtx);
89  py = pt*sin(phi_vtx);
90  for (int i=0; i<10000; i++){
91  vx = CLHEP::RandFlat::shoot(engine, -lxyMax_, lxyMax_);
92  vy = (pt*dxy + vx * py)/px;
93  lxy = sqrt(vx*vx + vy*vy);
94  if (lxy<abs(lxyMax_) and (vx*px + vy*py)>0){
95  passLxy = true;
96  break;
97  }
98  }
99  eta = CLHEP::RandFlat::shoot(engine, fMinEta, fMaxEta);
100  pz = pt * sinh(eta);
101  //vz = fabs(fRandomGaussGenerator->fire(0.0, LzWidth_/2.0));
102  float ConeTheta = ConeRadius_/ConeH_;
103  for (int j=0; j<100; j++){
104  vz = CLHEP::RandFlat::shoot(engine, 0.0, lzMax_);// this is abs(vz)
105  float v0 = vz - DistanceToAPEX_;
106  if ( v0<=0 or lxy*lxy/(ConeTheta*ConeTheta) > v0*v0 ) {
107  passLz=true;
108  break;
109  }
110  }
111  if (pz<0)
112  vz = -vz;
113  passLoop = (passLxy and passLz);
114 
115  if (passLoop)
116  break;
117  }
118 
119  HepMC::GenVertex* Vtx1 = new HepMC::GenVertex(HepMC::FourVector(vx,vy,vz));
120 
121  int PartID = fPartIDs[ip] ;
122  const HepPDT::ParticleData* PData = fPDGTable->particle(HepPDT::ParticleID(abs(PartID))) ;
123  double mass = PData->mass().value() ;
124  double energy2= px*px + py*py + pz*pz + mass*mass ;
125  double energy = sqrt(energy2) ;
126  HepMC::FourVector p(px,py,pz,energy) ;
127  HepMC::GenParticle* Part = new HepMC::GenParticle(p,PartID,1);
128  Part->suggest_barcode( barcode ) ;
129  barcode++;
130  Vtx1->add_particle_out(Part);
131  fEvt->add_vertex(Vtx1) ;
132 
133  if ( fAddAntiParticle ) {
134  HepMC::GenVertex* Vtx2 = new HepMC::GenVertex(HepMC::FourVector(-vx,-vy,-vz));
135  HepMC::FourVector ap(-px,-py,-pz,energy) ;
136  int APartID = -PartID ;
137  if ( PartID == 22 || PartID == 23 )
138  {
139  APartID = PartID ;
140  }
141  HepMC::GenParticle* APart = new HepMC::GenParticle(ap,APartID,1);
142  APart->suggest_barcode( barcode ) ;
143  barcode++ ;
144  Vtx2->add_particle_out(APart) ;
145  fEvt->add_vertex(Vtx2) ;
146  }
147  }
148  fEvt->set_event_number(e.id().event()) ;
149  fEvt->set_signal_process_id(20) ;
150 
151  if ( fVerbosity > 0 ){
152  fEvt->print() ;
153  }
154 
155  unique_ptr<HepMCProduct> BProduct(new HepMCProduct()) ;
156  BProduct->addHepMCData( fEvt );
157  e.put(std::move(BProduct), "unsmeared");
158 
159  unique_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(fEvt));
161 
162  if ( fVerbosity > 0 ){
163  cout << " FlatRandomPtAndDxyGunProducer : End New Event Generation" << endl ;
164  fEvt->print();
165  }
166 }
EventNumber_t event() const
Definition: EventID.h:41
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
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:18
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:95
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

double edm::FlatRandomPtAndDxyGunProducer::ConeH_
private

Definition at line 45 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::ConeRadius_
private

Definition at line 44 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::DistanceToAPEX_
private

Definition at line 46 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::dxyMax_
private

Definition at line 41 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::dxyMin_
private

Definition at line 40 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::fMaxPt
private

Definition at line 39 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::fMinPt
private

Definition at line 38 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::lxyMax_
private

Definition at line 42 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().

double edm::FlatRandomPtAndDxyGunProducer::lzMax_
private

Definition at line 43 of file FlatRandomPtAndDxyGunProducer.h.

Referenced by FlatRandomPtAndDxyGunProducer(), and produce().