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

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::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)
 

Detailed Description

Definition at line 10 of file RandomtXiGunProducer.h.

Constructor & Destructor Documentation

RandomtXiGunProducer::RandomtXiGunProducer ( const ParameterSet pset)

Definition at line 26 of file RandomtXiGunProducer.cc.

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

26  :
28 {
29 
30  ParameterSet defpset ;
31  edm::ParameterSet pgun_params =
32  pset.getParameter<edm::ParameterSet>("PGunParameters") ;
33 
34  fMint = pgun_params.getParameter<double>("Mint");
35  fMaxt = pgun_params.getParameter<double>("Maxt");
36  fMinXi= pgun_params.getParameter<double>("MinXi");
37  fMaxXi= pgun_params.getParameter<double>("MaxXi");
38  fLog_t= pgun_params.getUntrackedParameter<bool>("Log_t",false);
39 
40  produces<HepMCProduct>("unsmeared");
41  produces<GenEventInfoProduct>();
42 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
BaseRandomtXiGunProducer(const ParameterSet &)
RandomtXiGunProducer::~RandomtXiGunProducer ( )
override

Definition at line 44 of file RandomtXiGunProducer.cc.

45 {
46  // no need to cleanup GenEvent memory - done in HepMCProduct
47 }

Member Function Documentation

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

Definition at line 152 of file RandomtXiGunProducer.cc.

References funct::cos(), edm::BaseRandomtXiGunProducer::fpEnergy, edm::BaseRandomtXiGunProducer::fVerbosity, ResonanceBuilder::mass, edm::BaseRandomtXiGunProducer::PData, funct::sin(), mathSSE::sqrt(), and theta().

Referenced by produce().

153 {
154  double mass = PData->mass().value() ;
155  double fpMom = sqrt(fpEnergy*fpEnergy-mass*mass); // momentum of beam proton
156  double sEnergy = (1.0-Xi)*fpEnergy; // energy of scattered particle
157  double sMom = sqrt(sEnergy*sEnergy-mass*mass); // momentum of scattered particle
158  double min_t = -2.*(fpMom*sMom-fpEnergy*sEnergy+mass*mass);
159  if (t<min_t) t=min_t; // protect against kinemactically forbiden region
160  long double theta = acos((-t/2.- mass*mass + fpEnergy*sEnergy)/(sMom*fpMom)); // use t = -t
161 
162  if (direction<1) theta = acos(-1.) - theta;
163 
164  double px = sMom*cos(phi)*sin(theta);
165  double py = sMom*sin(phi)*sin(theta);
166  double pz = sMom*cos(theta) ; // the direction is already set by the theta angle
167  if (fVerbosity > 0)
168  edm::LogInfo("RandomXiGunProducer") << "-----------------------------------------------------------------------------------------------------\n"
169  << "Produced a proton with phi : " << phi << " theta: " << theta << " t: " << t << " Xi: " << Xi << "\n"
170  << " Px : " << px << " Py : " << py << " Pz : " << pz << "\n"
171  << " direction: " << direction << "\n"
172  << "-----------------------------------------------------------------------------------------------------"
173  << std::endl;
174 
175  return HepMC::FourVector(px,py,pz,sEnergy) ;
176 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const HepPDT::ParticleData * PData
double edm::RandomtXiGunProducer::Minimum_t ( double  xi)
inlineprivate

Definition at line 21 of file RandomtXiGunProducer.h.

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

Referenced by produce().

21  {double partE = fpEnergy*(1.-xi);
22  double massSQ= pow(PData->mass().value(),2);
23  double partP = sqrt(partE*partE-massSQ);
24  return -2.*(sqrt(fpEnergy*fpEnergy-massSQ)*partP-fpEnergy*partE+massSQ);
25  };
T sqrt(T t)
Definition: SSEVec.h:18
const HepPDT::ParticleData * PData
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void RandomtXiGunProducer::produce ( edm::Event e,
const EventSetup es 
)
overrideprivate

Definition at line 49 of file RandomtXiGunProducer.cc.

References funct::abs(), edm::EventID::event(), cmsRelvalreport::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, particlelevel_cff::genEventInfo, GenParticle::GenParticle, edm::RandomNumberGenerator::getEngine(), edm::EventBase::id(), make_particle(), SiStripPI::max, Minimum_t(), eostools::move(), source_particleGun_cfi::ParticleID, CastorDigiValidation::PartID, edm::BaseRandomtXiGunProducer::PData, phi, funct::pow(), edm::Event::put(), edm::Event::streamID(), and protons_cff::t.

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

Member Data Documentation

double edm::RandomtXiGunProducer::fMaxt
protected

Definition at line 32 of file RandomtXiGunProducer.h.

Referenced by produce(), and RandomtXiGunProducer().

double edm::RandomtXiGunProducer::fMaxXi
protected

Definition at line 34 of file RandomtXiGunProducer.h.

Referenced by produce(), and RandomtXiGunProducer().

double edm::RandomtXiGunProducer::fMint
protected

Definition at line 25 of file RandomtXiGunProducer.h.

Referenced by produce(), and RandomtXiGunProducer().

double edm::RandomtXiGunProducer::fMinXi
protected

Definition at line 33 of file RandomtXiGunProducer.h.

Referenced by produce(), and RandomtXiGunProducer().