CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes | Private Member Functions
edm::RandomtXiGunProducer Class Reference

#include <RandomtXiGunProducer.h>

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

Public Member Functions

 RandomtXiGunProducer (const ParameterSet &)
 
 ~RandomtXiGunProducer () override
 
- Public Member Functions inherited from edm::BaseRandomtXiGunProducer
 BaseRandomtXiGunProducer (const ParameterSet &)
 
void beginRun (const edm::Run &r, const edm::EventSetup &) override
 
void endRun (const edm::Run &r, const edm::EventSetup &) override
 
void endRunProduce (edm::Run &r, const edm::EventSetup &) override
 
 ~BaseRandomtXiGunProducer () 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
 
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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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)
 

Protected Attributes

double fMaxt
 
double fMaxXi
 
double fMint
 
double fMinXi
 
- Protected Attributes inherited from edm::BaseRandomtXiGunProducer
double fECMS
 
HepMC::GenEventfEvt
 
bool fFireBackward
 
bool fFireForward
 
bool fLog_t
 
double fMaxPhi
 
double fMinPhi
 
std::vector< int > fPartIDs
 
ESHandle< HepPDT::ParticleDataTablefPDGTable
 
double fpEnergy
 
int fVerbosity
 
const HepPDT::ParticleDataPData
 

Private Member Functions

HepMC::FourVector make_particle (double t, double Xi, double phi, int PartID, int direction)
 
double Minimum_t (double xi)
 
void produce (Event &e, const EventSetup &es) override
 

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
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 9 of file RandomtXiGunProducer.h.

Constructor & Destructor Documentation

◆ RandomtXiGunProducer()

RandomtXiGunProducer::RandomtXiGunProducer ( const ParameterSet pset)

Definition at line 25 of file RandomtXiGunProducer.cc.

26  ParameterSet defpset;
27  edm::ParameterSet pgun_params = pset.getParameter<edm::ParameterSet>("PGunParameters");
28 
29  fMint = pgun_params.getParameter<double>("Mint");
30  fMaxt = pgun_params.getParameter<double>("Maxt");
31  fMinXi = pgun_params.getParameter<double>("MinXi");
32  fMaxXi = pgun_params.getParameter<double>("MaxXi");
33  fLog_t = pgun_params.getUntrackedParameter<bool>("Log_t", false);
34 
35  produces<HepMCProduct>("unsmeared");
36  produces<GenEventInfoProduct>();
37 }

References edm::BaseRandomtXiGunProducer::fLog_t, fMaxt, fMaxXi, fMint, fMinXi, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and muonDTDigis_cfi::pset.

◆ ~RandomtXiGunProducer()

RandomtXiGunProducer::~RandomtXiGunProducer ( )
override

Definition at line 39 of file RandomtXiGunProducer.cc.

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

Member Function Documentation

◆ make_particle()

HepMC::FourVector RandomtXiGunProducer::make_particle ( double  t,
double  Xi,
double  phi,
int  PartID,
int  direction 
)
private

Definition at line 141 of file RandomtXiGunProducer.cc.

141  {
142  double mass = PData->mass().value();
143  double fpMom = sqrt(fpEnergy * fpEnergy - mass * mass); // momentum of beam proton
144  double sEnergy = (1.0 - Xi) * fpEnergy; // energy of scattered particle
145  double sMom = sqrt(sEnergy * sEnergy - mass * mass); // momentum of scattered particle
146  double min_t = -2. * (fpMom * sMom - fpEnergy * sEnergy + mass * mass);
147  if (t < min_t)
148  t = min_t; // protect against kinemactically forbiden region
149  long double theta = acos((-t / 2. - mass * mass + fpEnergy * sEnergy) / (sMom * fpMom)); // use t = -t
150 
151  if (direction < 1)
152  theta = acos(-1.) - theta;
153 
154  double px = sMom * cos(phi) * sin(theta);
155  double py = sMom * sin(phi) * sin(theta);
156  double pz = sMom * cos(theta); // the direction is already set by the theta angle
157  if (fVerbosity > 0)
158  edm::LogInfo("RandomXiGunProducer")
159  << "-----------------------------------------------------------------------------------------------------\n"
160  << "Produced a proton with phi : " << phi << " theta: " << theta << " t: " << t << " Xi: " << Xi << "\n"
161  << " Px : " << px << " Py : " << py << " Pz : " << pz << "\n"
162  << " direction: " << direction << "\n"
163  << "-----------------------------------------------------------------------------------------------------"
164  << std::endl;
165 
166  return HepMC::FourVector(px, py, pz, sEnergy);
167 }

References funct::cos(), edm::BaseRandomtXiGunProducer::fpEnergy, edm::BaseRandomtXiGunProducer::fVerbosity, EgHLTOffHistBins_cfi::mass, edm::BaseRandomtXiGunProducer::PData, phi, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, funct::sin(), mathSSE::sqrt(), OrderedSet::t, and theta().

Referenced by produce().

◆ Minimum_t()

double edm::RandomtXiGunProducer::Minimum_t ( double  xi)
inlineprivate

Definition at line 18 of file RandomtXiGunProducer.h.

18  {
19  double partE = fpEnergy * (1. - xi);
20  double massSQ = pow(PData->mass().value(), 2);
21  double partP = sqrt(partE * partE - massSQ);
22  return -2. * (sqrt(fpEnergy * fpEnergy - massSQ) * partP - fpEnergy * partE + massSQ);
23  };

References edm::BaseRandomtXiGunProducer::fpEnergy, edm::BaseRandomtXiGunProducer::PData, funct::pow(), mathSSE::sqrt(), and hybridSuperClusters_cfi::xi.

Referenced by produce().

◆ produce()

void RandomtXiGunProducer::produce ( edm::Event e,
const EventSetup es 
)
overrideprivatevirtual

Implements edm::one::EDProducerBase.

Definition at line 43 of file RandomtXiGunProducer.cc.

43  {
45  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
46 
47  if (fVerbosity > 0) {
48  edm::LogInfo("RandomtXiGunProducer") << "Begin New Event Generation\n";
49  }
50  // event loop (well, another step in it...)
51 
52  // no need to clean up GenEvent memory - done in HepMCProduct
53  //
54 
55  // here re-create fEvt (memory)
56  //
57  fEvt = new HepMC::GenEvent();
58 
59  // now actualy, cook up the event from PDGTable and gun parameters
60  //
61  // 1st, primary vertex
62  //
63  HepMC::GenVertex* Vtx = new HepMC::GenVertex(HepMC::FourVector(0., 0., 0.));
64 
65  // loop over particles
66  //
67  int barcode = 1;
68  for (unsigned int ip = 0; ip < fPartIDs.size(); ++ip) {
69  int PartID = fPartIDs[ip];
70  // t = -2*P*P'*(1-cos(theta)) -> t/(2*P*P')+1=cos(theta)
71  // xi = 1 - P'/P --> P'= (1-xi)*P
72  //
74  if (!PData)
75  exit(1);
76  double t = 0;
77  double Xi = 0;
78  double phi = 0;
79  if (fFireForward) {
80  while (true) {
81  Xi = CLHEP::RandFlat::shoot(engine, fMinXi, fMaxXi);
82  double min_t = std::max(fMint, Minimum_t(Xi));
83  double max_t = fMaxt;
84  if (min_t > max_t) {
85  edm::LogInfo("RandomtXiGunProducer") << "WARNING: t limits redefined (unphysical values for given xi).\n";
86  max_t = min_t;
87  }
88  t = (fLog_t) ? pow(CLHEP::RandFlat::shoot(engine, log10(min_t), log10(max_t)), 10)
89  : CLHEP::RandFlat::shoot(engine, min_t, max_t);
90  break;
91  }
92  phi = CLHEP::RandFlat::shoot(engine, fMinPhi, fMaxPhi);
93  HepMC::GenParticle* Part = new HepMC::GenParticle(make_particle(t, Xi, phi, PartID, 1), PartID, 1);
94  Part->suggest_barcode(barcode);
95  barcode++;
96  Vtx->add_particle_out(Part);
97  }
98  if (fFireBackward) {
99  while (true) {
100  Xi = CLHEP::RandFlat::shoot(engine, fMinXi, fMaxXi);
101  double min_t = std::max(fMint, Minimum_t(Xi));
102  double max_t = fMaxt;
103  if (min_t > max_t) {
104  edm::LogInfo("RandomtXiGunProducer")
105  << "WARNING: t limits redefined (unphysical values for given xi)." << endl;
106  max_t = min_t;
107  }
108  t = (fLog_t) ? pow(CLHEP::RandFlat::shoot(engine, log10(min_t), log10(max_t)), 10)
109  : CLHEP::RandFlat::shoot(engine, min_t, max_t);
110  break;
111  }
112  phi = CLHEP::RandFlat::shoot(engine, fMinPhi, fMaxPhi);
113  HepMC::GenParticle* Part2 = new HepMC::GenParticle(make_particle(t, Xi, phi, PartID, -1), PartID, 1);
114  Part2->suggest_barcode(barcode);
115  barcode++;
116  Vtx->add_particle_out(Part2);
117  }
118  }
119 
120  fEvt->add_vertex(Vtx);
121  fEvt->set_event_number(e.id().event());
122  fEvt->set_signal_process_id(20);
123 
124  if (fVerbosity > 0) {
125  fEvt->print();
126  }
127 
128  std::unique_ptr<HepMCProduct> BProduct(new HepMCProduct());
129  BProduct->addHepMCData(fEvt);
130  e.put(std::move(BProduct), "unsmeared");
131 
132  std::unique_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(fEvt));
133  e.put(std::move(genEventInfo));
134 
135  if (fVerbosity > 0) {
136  // for testing purpose only
137  // fEvt->print() ; // prints empty info after it's made into edm::Event
138  edm::LogInfo("RandomtXiGunProducer") << " Event Generation Done \n";
139  }
140 }

References funct::abs(), MillePedeFileConverter_cfg::e, beamvalidation::exit(), edm::BaseRandomtXiGunProducer::fEvt, edm::BaseRandomtXiGunProducer::fFireBackward, edm::BaseRandomtXiGunProducer::fFireForward, edm::BaseRandomtXiGunProducer::fLog_t, edm::BaseRandomtXiGunProducer::fMaxPhi, fMaxt, fMaxXi, edm::BaseRandomtXiGunProducer::fMinPhi, fMint, fMinXi, edm::BaseRandomtXiGunProducer::fPartIDs, edm::BaseRandomtXiGunProducer::fPDGTable, edm::BaseRandomtXiGunProducer::fVerbosity, genParticles2HepMC_cfi::genEventInfo, GenParticle::GenParticle, edm::RandomNumberGenerator::getEngine(), ZgammaFilter_cfi::HepMCProduct, make_particle(), SiStripPI::max, Minimum_t(), eostools::move(), LHEGenericFilter_cfi::ParticleID, genfragment_ptgun_cfg::PartID, edm::BaseRandomtXiGunProducer::PData, phi, funct::pow(), and OrderedSet::t.

Member Data Documentation

◆ fMaxt

double edm::RandomtXiGunProducer::fMaxt
protected

Definition at line 29 of file RandomtXiGunProducer.h.

Referenced by produce(), and RandomtXiGunProducer().

◆ fMaxXi

double edm::RandomtXiGunProducer::fMaxXi
protected

Definition at line 31 of file RandomtXiGunProducer.h.

Referenced by produce(), and RandomtXiGunProducer().

◆ fMint

double edm::RandomtXiGunProducer::fMint
protected

Definition at line 23 of file RandomtXiGunProducer.h.

Referenced by produce(), and RandomtXiGunProducer().

◆ fMinXi

double edm::RandomtXiGunProducer::fMinXi
protected

Definition at line 30 of file RandomtXiGunProducer.h.

Referenced by produce(), and RandomtXiGunProducer().

edm::BaseRandomtXiGunProducer::fEvt
HepMC::GenEvent * fEvt
Definition: BaseRandomtXiGunProducer.h:48
GenEventInfoProduct
Definition: GenEventInfoProduct.h:17
edm::BaseRandomtXiGunProducer::BaseRandomtXiGunProducer
BaseRandomtXiGunProducer(const ParameterSet &)
Definition: BaseRandomtXiGunProducer.cc:31
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
edm::RandomtXiGunProducer::fMaxt
double fMaxt
Definition: RandomtXiGunProducer.h:29
edm::BaseRandomtXiGunProducer::fPartIDs
std::vector< int > fPartIDs
Definition: BaseRandomtXiGunProducer.h:41
edm::BaseRandomtXiGunProducer::PData
const HepPDT::ParticleData * PData
Definition: BaseRandomtXiGunProducer.h:54
edm::BaseRandomtXiGunProducer::fMinPhi
double fMinPhi
Definition: BaseRandomtXiGunProducer.h:42
edm::BaseRandomtXiGunProducer::fFireForward
bool fFireForward
Definition: BaseRandomtXiGunProducer.h:56
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
ZgammaFilter_cfi.HepMCProduct
HepMCProduct
Definition: ZgammaFilter_cfi.py:9
hybridSuperClusters_cfi.xi
xi
Definition: hybridSuperClusters_cfi.py:10
edm::LogInfo
Definition: MessageLogger.h:254
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::RandomtXiGunProducer::fMint
double fMint
Definition: RandomtXiGunProducer.h:23
edm::BaseRandomtXiGunProducer::fLog_t
bool fLog_t
Definition: BaseRandomtXiGunProducer.h:58
edm::RandomtXiGunProducer::make_particle
HepMC::FourVector make_particle(double t, double Xi, double phi, int PartID, int direction)
Definition: RandomtXiGunProducer.cc:141
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
OrderedSet.t
t
Definition: OrderedSet.py:90
edm::RandomtXiGunProducer::fMinXi
double fMinXi
Definition: RandomtXiGunProducer.h:30
edm::BaseRandomtXiGunProducer::fpEnergy
double fpEnergy
Definition: BaseRandomtXiGunProducer.h:44
edm::RandomtXiGunProducer::fMaxXi
double fMaxXi
Definition: RandomtXiGunProducer.h:31
edm::ParameterSet
Definition: ParameterSet.h:36
PVValHelper::phi
Definition: PVValidationHelpers.h:68
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
edm::Service< edm::RandomNumberGenerator >
genfragment_ptgun_cfg.PartID
PartID
Definition: genfragment_ptgun_cfg.py:6
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
edm::BaseRandomtXiGunProducer::fPDGTable
ESHandle< HepPDT::ParticleDataTable > fPDGTable
Definition: BaseRandomtXiGunProducer.h:50
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
eostools.move
def move(src, dest)
Definition: eostools.py:511
genParticles2HepMC_cfi.genEventInfo
genEventInfo
Definition: genParticles2HepMC_cfi.py:6
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
edm::BaseRandomtXiGunProducer::fFireBackward
bool fFireBackward
Definition: BaseRandomtXiGunProducer.h:57
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
edm::BaseRandomtXiGunProducer::fVerbosity
int fVerbosity
Definition: BaseRandomtXiGunProducer.h:52
LHEGenericFilter_cfi.ParticleID
ParticleID
Definition: LHEGenericFilter_cfi.py:6
edm::RandomtXiGunProducer::Minimum_t
double Minimum_t(double xi)
Definition: RandomtXiGunProducer.h:18
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
edm::BaseRandomtXiGunProducer::fMaxPhi
double fMaxPhi
Definition: BaseRandomtXiGunProducer.h:43