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
 
 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
 
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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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
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::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<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 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 9 of file RandomtXiGunProducer.h.

Constructor & Destructor Documentation

◆ RandomtXiGunProducer()

RandomtXiGunProducer::RandomtXiGunProducer ( const ParameterSet pset)

Definition at line 25 of file RandomtXiGunProducer.cc.

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

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 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
BaseRandomtXiGunProducer(const ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const

◆ ~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.

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(), submitPVValidationJobs::t, and theta().

Referenced by produce().

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 }
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
Log< level::Info, false > LogInfo
const HepPDT::ParticleData * PData
Geom::Theta< T > theta() const

◆ Minimum_t()

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

Definition at line 18 of file RandomtXiGunProducer.h.

References edm::BaseRandomtXiGunProducer::fpEnergy, edm::BaseRandomtXiGunProducer::PData, conifer::pow(), mathSSE::sqrt(), and protons_cff::xi.

Referenced by produce().

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  };
constexpr int pow(int x)
Definition: conifer.h:24
T sqrt(T t)
Definition: SSEVec.h:19
const HepPDT::ParticleData * PData

◆ produce()

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

Implements edm::one::EDProducerBase.

Definition at line 43 of file RandomtXiGunProducer.cc.

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, conifer::pow(), and submitPVValidationJobs::t.

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 }
HepMC::FourVector make_particle(double t, double Xi, double phi, int PartID, int direction)
constexpr int pow(int x)
Definition: conifer.h:24
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ESHandle< HepPDT::ParticleDataTable > fPDGTable
Log< level::Info, false > LogInfo
const HepPDT::ParticleData * PData
def move(src, dest)
Definition: eostools.py:511
def exit(msg="")

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