CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
gen::Pythia6Gun Class Referenceabstract

#include <Pythia6Gun.h>

Inheritance diagram for gen::Pythia6Gun:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper gen::Pythia6ParticleGun gen::Pythia6PartonGun gen::Pythia6EGun gen::Pythia6JetGun gen::Pythia6PtGun gen::Pythia6PtYDistGun gen::Pythia6PartonEGun gen::Pythia6PartonPtGun

Public Member Functions

void beginJob ()
 
void beginRun (edm::Run &, edm::EventSetup const &)
 
void endJob ()
 
void endRun (edm::Run &, edm::EventSetup const &)
 
void produce (edm::Event &, const edm::EventSetup &)
 
 Pythia6Gun (const edm::ParameterSet &)
 
virtual ~Pythia6Gun ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Protected Member Functions

HepMC::GenParticle * addAntiParticle (int &, int &, double &, double &, double &)
 
void attachPy6DecaysToGenEvent ()
 
virtual void generateEvent ()=0
 
void loadEvent (edm::Event &)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Protected Attributes

HepMC::GenEvent * fEvt
 
bool fHepMCVerbosity
 
int fMaxEventsToPrint
 
double fMaxPhi
 
double fMinPhi
 
std::vector< int > fPartIDs
 
Pythia6ServicefPy6Service
 
int fPylistVerbosity
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

Definition at line 32 of file Pythia6Gun.h.

Constructor & Destructor Documentation

Pythia6Gun::Pythia6Gun ( const edm::ParameterSet pset)

Definition at line 25 of file Pythia6Gun.cc.

References gen::call_pygive(), edm::errors::Configuration, edm::hlt::Exception, funct::false, fHepMCVerbosity, fMaxEventsToPrint, fMaxPhi, fMinPhi, fPylistVerbosity, edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

25  :
26  fPy6Service( new Pythia6Service(pset) ),
27  fEvt(0)
28  // fPDGTable( new DefaultConfig::ParticleDataTable("PDG Table") )
29 {
30 
31  ParameterSet pgun_params =
32  pset.getParameter<ParameterSet>("PGunParameters");
33 
34  // although there's the method ParameterSet::empty(),
35  // it looks like it's NOT even necessary to check if it is,
36  // before trying to extract parameters - if it is empty,
37  // the default values seem to be taken
38  //
39  fMinPhi = pgun_params.getParameter<double>("MinPhi"); // ,-3.14159265358979323846);
40  fMaxPhi = pgun_params.getParameter<double>("MaxPhi"); // , 3.14159265358979323846);
41 
42  fHepMCVerbosity = pset.getUntrackedParameter<bool>("pythiaHepMCVerbosity", false ) ;
43  fPylistVerbosity = pset.getUntrackedParameter<int>( "pythiaPylistVerbosity", 0 ) ;
44  fMaxEventsToPrint = pset.getUntrackedParameter<int>( "maxEventsToPrint", 0 );
45 
46 // Turn off banner printout
47  if (!call_pygive("MSTU(12)=12345"))
48  {
49  throw edm::Exception(edm::errors::Configuration,"PythiaError")
50  <<" pythia did not accept MSTU(12)=12345";
51  }
52 
53  produces<HepMCProduct>();
54 
55 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool call_pygive(const std::string &line)
HepMC::GenEvent * fEvt
Definition: Pythia6Gun.h:62
bool fHepMCVerbosity
Definition: Pythia6Gun.h:69
int fPylistVerbosity
Definition: Pythia6Gun.h:70
double fMinPhi
Definition: Pythia6Gun.h:57
int fMaxEventsToPrint
Definition: Pythia6Gun.h:71
double fMaxPhi
Definition: Pythia6Gun.h:58
Pythia6Service * fPy6Service
Definition: Pythia6Gun.h:52
Pythia6Gun::~Pythia6Gun ( )
virtual

Definition at line 57 of file Pythia6Gun.cc.

References fPy6Service.

58 {
59  if ( fPy6Service ) delete fPy6Service;
60  //
61  // note that GenEvent or any undelaying (GenVertex, GenParticle) do NOT
62  // need to be cleaned, as it'll be done automatically by HepMCProduct
63  //
64 }
Pythia6Service * fPy6Service
Definition: Pythia6Gun.h:52

Member Function Documentation

HepMC::GenParticle * Pythia6Gun::addAntiParticle ( int &  ip,
int &  particleID,
double &  ee,
double &  eta,
double &  phi 
)
protected

Definition at line 242 of file Pythia6Gun.cc.

References create_public_lumi_plots::exp, configurableAnalysis::GenParticle, M_PI, gen::py1ent_(), and gen::pycomp_().

Referenced by gen::Pythia6EGun::generateEvent(), gen::Pythia6PtGun::generateEvent(), gen::Pythia6PartonPtGun::generateEvent(), and gen::Pythia6PartonEGun::generateEvent().

244 {
245 
246  if ( ip < 2 ) return 0;
247 
248 // translate PDG to Py6
249  int py6PID = HepPID::translatePDTtoPythia( particleID );
250 // Check if particle is its own anti-particle.
251  int pythiaCode = pycomp_(py6PID); // this is py6 internal validity check, it takes Pythia6 pid
252  // so actually I'll need to convert
253  int has_antipart = pydat2.kchg[3-1][pythiaCode-1];
254  int particleID2 = has_antipart ? -1 * particleID : particleID; // this is PDG, for HepMC::GenEvent
255  int py6PID2 = has_antipart ? -1 * py6PID : py6PID; // this py6 id, for py1ent
256  double the = 2.*atan(exp(eta));
257  phi = phi + M_PI;
258  if (phi > 2.* M_PI) {phi = phi - 2.* M_PI;}
259 
260  // copy over mass of the previous one, because then py6 will pick it up
261  pyjets.p[4][ip-1] = pyjets.p[4][ip-2];
262 
263  py1ent_(ip, py6PID2, ee, the, phi);
264 
265  double px = pyjets.p[0][ip-1]; // pt*cos(phi) ;
266  double py = pyjets.p[1][ip-1]; // pt*sin(phi) ;
267  double pz = pyjets.p[2][ip-1]; // mom*cos(the) ;
268  HepMC::FourVector ap(px,py,pz,ee) ;
269  HepMC::GenParticle* APart =
270  new HepMC::GenParticle(ap,particleID2,1);
271  APart->suggest_barcode( ip ) ;
272 
273  return APart;
274 
275 }
T eta() const
int pycomp_(int &)
#define M_PI
Definition: BFit3D.cc:3
void py1ent_(int &ip, int &kf, double &pe, double &the, double &phi)
Definition: DDAxes.h:10
void Pythia6Gun::attachPy6DecaysToGenEvent ( )
protected

Definition at line 107 of file Pythia6Gun.cc.

References fEvt, fPartIDs, configurableAnalysis::GenParticle, and dbtoconf::parent.

Referenced by produce().

108 {
109 
110  for ( int iprt=fPartIDs.size(); iprt<pyjets.n; iprt++ ) // the pointer is shifted by -1, c++ style
111  {
112  int parent = pyjets.k[2][iprt];
113  if ( parent != 0 )
114  {
115  // pull up parent particle
116  //
117  HepMC::GenParticle* parentPart = fEvt->barcode_to_particle( parent );
118  parentPart->set_status( 2 ); // reset status, to mark that it's decayed
119 
120  HepMC::GenVertex* DecVtx = new HepMC::GenVertex(HepMC::FourVector(pyjets.v[0][iprt],
121  pyjets.v[1][iprt],
122  pyjets.v[2][iprt],
123  pyjets.v[3][iprt]));
124  DecVtx->add_particle_in( parentPart ); // this will cleanup end_vertex if exists,
125  // and replace with the new one
126  // I presume barcode will be given automatically
127 
128  HepMC::FourVector pmom(pyjets.p[0][iprt],pyjets.p[1][iprt],
129  pyjets.p[2][iprt],pyjets.p[3][iprt] );
130 
131  int dstatus = 0;
132  if ( pyjets.k[0][iprt] >= 1 && pyjets.k[0][iprt] <= 10 )
133  {
134  dstatus = 1;
135  }
136  else if ( pyjets.k[0][iprt] >= 11 && pyjets.k[0][iprt] <= 20 )
137  {
138  dstatus = 2;
139  }
140  else if ( pyjets.k[0][iprt] >= 21 && pyjets.k[0][iprt] <= 30 )
141  {
142  dstatus = 3;
143  }
144  else if ( pyjets.k[0][iprt] >= 31 && pyjets.k[0][iprt] <= 100 )
145  {
146  dstatus = pyjets.k[0][iprt];
147  }
148  HepMC::GenParticle* daughter =
149  new HepMC::GenParticle(pmom,
150  HepPID::translatePythiatoPDT( pyjets.k[1][iprt] ),
151  dstatus);
152  daughter->suggest_barcode( iprt+1 );
153  DecVtx->add_particle_out( daughter );
154  // give particle barcode as well !
155 
156  int iprt1;
157  for ( iprt1=iprt+1; iprt1<pyjets.n; iprt1++ ) // the pointer is shifted by -1, c++ style
158  {
159  if ( pyjets.k[2][iprt1] != parent ) break; // another parent particle, break the loop
160 
161  HepMC::FourVector pmomN(pyjets.p[0][iprt1],pyjets.p[1][iprt1],
162  pyjets.p[2][iprt1],pyjets.p[3][iprt1] );
163 
164  dstatus = 0;
165  if ( pyjets.k[0][iprt1] >= 1 && pyjets.k[0][iprt1] <= 10 )
166  {
167  dstatus = 1;
168  }
169  else if ( pyjets.k[0][iprt1] >= 11 && pyjets.k[0][iprt1] <= 20 )
170  {
171  dstatus = 2;
172  }
173  else if ( pyjets.k[0][iprt1] >= 21 && pyjets.k[0][iprt1] <= 30 )
174  {
175  dstatus = 3;
176  }
177  else if ( pyjets.k[0][iprt1] >= 31 && pyjets.k[0][iprt1] <= 100 )
178  {
179  dstatus = pyjets.k[0][iprt1];
180  }
181  HepMC::GenParticle* daughterN =
182  new HepMC::GenParticle(pmomN,
183  HepPID::translatePythiatoPDT( pyjets.k[1][iprt1] ),
184  dstatus);
185  daughterN->suggest_barcode( iprt1+1 );
186  DecVtx->add_particle_out( daughterN );
187  }
188 
189  iprt = iprt1-1; // reset counter such that it doesn't go over the same child more than once
190  // don't forget to offset back into c++ counting, as it's already +1 forward
191 
192  fEvt->add_vertex( DecVtx );
193 
194  }
195  }
196 
197  return;
198 
199 }
list parent
Definition: dbtoconf.py:74
HepMC::GenEvent * fEvt
Definition: Pythia6Gun.h:62
std::vector< int > fPartIDs
Definition: Pythia6Gun.h:56
void Pythia6Gun::beginJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 67 of file Pythia6Gun.cc.

References hitfit::return.

68 {
69  // es.getData( fPDGTable ) ;
70  return ;
71 
72 }
void Pythia6Gun::beginRun ( edm::Run r,
edm::EventSetup const &  es 
)
virtual

Reimplemented from edm::EDProducer.

Definition at line 78 of file Pythia6Gun.cc.

References gen::call_pygive(), gather_cfg::cout, fPy6Service, gen::Pythia6Service::setCSAParams(), gen::Pythia6Service::setGeneralParams(), and gen::Pythia6Service::setSLHAParams().

79 {
80  assert ( fPy6Service ) ;
81 
82  Pythia6Service::InstanceWrapper guard(fPy6Service); // grab Py6 instance
83 
87 
88  call_pygive("MSTU(10)=1");
89 
90  call_pyinit("NONE", "", "", 0.0);
91 
92  std::cout << " FYI: MSTU(10)=1 is ENFORCED in Py6-PGuns, for technical reasons"
93  << std::endl;
94  return;
95 }
bool call_pygive(const std::string &line)
Pythia6Service * fPy6Service
Definition: Pythia6Gun.h:52
tuple cout
Definition: gather_cfg.py:121
void Pythia6Gun::endJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 74 of file Pythia6Gun.cc.

75 {
76 }
void Pythia6Gun::endRun ( edm::Run r,
edm::EventSetup const &  es 
)
virtual

Reimplemented from edm::EDProducer.

Definition at line 97 of file Pythia6Gun.cc.

98 {
99 
100  // here put in GenRunInfoProduct
101 
102  call_pystat(1);
103 
104  return;
105 }
virtual void gen::Pythia6Gun::generateEvent ( )
protectedpure virtual
void Pythia6Gun::loadEvent ( edm::Event evt)
protected

Definition at line 228 of file Pythia6Gun.cc.

References fEvt, and edm::Event::put().

Referenced by produce().

229 {
230 
231  std::auto_ptr<HepMCProduct> bare_product(new HepMCProduct());
232 
233  if(fEvt) bare_product->addHepMCData( fEvt );
234 
235  evt.put(bare_product);
236 
237 
238  return;
239 
240 }
HepMC::GenEvent * fEvt
Definition: Pythia6Gun.h:62
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
void Pythia6Gun::produce ( edm::Event evt,
const edm::EventSetup  
)
virtual

Implements edm::EDProducer.

Definition at line 201 of file Pythia6Gun.cc.

References attachPy6DecaysToGenEvent(), gen::call_pylist(), edm::EventID::event(), fEvt, fHepMCVerbosity, fMaxEventsToPrint, fPylistVerbosity, generateEvent(), edm::EventBase::id(), loadEvent(), and pypars.

202 {
203 
204  generateEvent() ;
205 
206  fEvt->set_beam_particles(0,0);
207  fEvt->set_event_number(evt.id().event()) ;
208  fEvt->set_signal_process_id(pypars.msti[0]) ;
209 
211 
212  int evtN = evt.id().event();
213  if ( evtN <= fMaxEventsToPrint )
214  {
215  if ( fPylistVerbosity )
216  {
218  }
219  if ( fHepMCVerbosity )
220  {
221  if ( fEvt ) fEvt->print();
222  }
223  }
224 
225  loadEvent( evt );
226 }
EventNumber_t event() const
Definition: EventID.h:44
HepMC::GenEvent * fEvt
Definition: Pythia6Gun.h:62
bool fHepMCVerbosity
Definition: Pythia6Gun.h:69
int fPylistVerbosity
Definition: Pythia6Gun.h:70
#define pypars
virtual void generateEvent()=0
void call_pylist(int mode)
void attachPy6DecaysToGenEvent()
Definition: Pythia6Gun.cc:107
int fMaxEventsToPrint
Definition: Pythia6Gun.h:71
void loadEvent(edm::Event &)
Definition: Pythia6Gun.cc:228
edm::EventID id() const
Definition: EventBase.h:56

Member Data Documentation

HepMC::GenEvent* gen::Pythia6Gun::fEvt
protected
bool gen::Pythia6Gun::fHepMCVerbosity
protected

Definition at line 69 of file Pythia6Gun.h.

Referenced by produce(), and Pythia6Gun().

int gen::Pythia6Gun::fMaxEventsToPrint
protected

Definition at line 71 of file Pythia6Gun.h.

Referenced by produce(), and Pythia6Gun().

double gen::Pythia6Gun::fMaxPhi
protected
double gen::Pythia6Gun::fMinPhi
protected
std::vector<int> gen::Pythia6Gun::fPartIDs
protected

Definition at line 56 of file Pythia6Gun.h.

Referenced by attachPy6DecaysToGenEvent().

Pythia6Service* gen::Pythia6Gun::fPy6Service
protected
int gen::Pythia6Gun::fPylistVerbosity
protected

Definition at line 70 of file Pythia6Gun.h.

Referenced by produce(), and Pythia6Gun().