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 &)
 
virtual ~RandomtXiGunProducer ()
 
- 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
 
virtual ~BaseRandomtXiGunProducer ()
 
- Public Member Functions inherited from edm::one::EDProducer< one::WatchRuns, EndRunProducer >
 EDProducer ()=default
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Attributes

double fMaxt
 
double fMaxXi
 
double fMint
 
double fMinXi
 
- Protected Attributes inherited from edm::BaseRandomtXiGunProducer
double fECMS
 
HepMC::GenEvent * fEvt
 
bool fFireBackward
 
bool fFireForward
 
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)
 
virtual 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
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 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 fMaxt, fMaxXi, fMint, fMinXi, and edm::ParameterSet::getParameter().

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 
39  produces<HepMCProduct>("unsmeared");
40  produces<GenEventInfoProduct>();
41 }
T getParameter(std::string const &) const
BaseRandomtXiGunProducer(const ParameterSet &)
RandomtXiGunProducer::~RandomtXiGunProducer ( )
virtual

Definition at line 43 of file RandomtXiGunProducer.cc.

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

Member Function Documentation

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

Definition at line 149 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().

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

Definition at line 48 of file RandomtXiGunProducer.cc.

References funct::abs(), gather_cfg::cout, edm::EventID::event(), cmsRelvalreport::exit, edm::BaseRandomtXiGunProducer::fEvt, edm::BaseRandomtXiGunProducer::fFireBackward, edm::BaseRandomtXiGunProducer::fFireForward, edm::BaseRandomtXiGunProducer::fMaxPhi, fMaxt, fMaxXi, edm::BaseRandomtXiGunProducer::fMinPhi, fMint, fMinXi, edm::BaseRandomtXiGunProducer::fPartIDs, edm::BaseRandomtXiGunProducer::fPDGTable, edm::BaseRandomtXiGunProducer::fVerbosity, GenParticle::GenParticle, edm::RandomNumberGenerator::getEngine(), edm::EventBase::id(), make_particle(), hpstanc_transforms::max, Minimum_t(), eostools::move(), source_particleGun_cfi::ParticleID, CastorDigiValidation::PartID, edm::BaseRandomtXiGunProducer::PData, phi, edm::Event::put(), edm::Event::streamID(), and lumiQTWidget::t.

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

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