CMS 3D CMS Logo

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

#include <EvtGenInterface.h>

Public Member Functions

void addToHepMC (HepMC::GenParticle *partHep, EvtId idEvt, HepMC::GenEvent *theEvent, bool del_daug)
 
HepMC::GenEvent * decay (HepMC::GenEvent *)
 
 EvtGenInterface (const edm::ParameterSet &)
 
void go_through_daughters (EvtParticle *part)
 
void init ()
 
const std::vector< int > & operatesOnParticles ()
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
void update_candlist (int theIndex, HepMC::GenParticle *thePart)
 
 ~EvtGenInterface ()
 

Private Attributes

std::string decay_table_s
 
std::vector< EvtId > forced_Evt
 
std::vector< int > forced_Hep
 
std::vector< std::string > forced_names
 
int index [10]
 
HepMC::GenParticle * listp [10]
 
EvtGen * m_EvtGen
 
std::vector< int > m_PDGs
 
Pythia6Servicem_Py6Service
 
int nevent
 
int nforced
 
int nlist
 
int npartial
 
int nPythia
 
int ntotal
 
std::string pdt_s
 
std::map< int, float > polarizations
 
std::vector< int > polarize_ids
 
std::vector< double > polarize_pol
 
myEvtRandomEnginethe_engine
 
bool useDefault
 
bool usePythia
 
std::string user_decay_s
 

Detailed Description

Definition at line 49 of file EvtGenInterface.h.

Constructor & Destructor Documentation

EvtGenInterface::EvtGenInterface ( const edm::ParameterSet pset)

Definition at line 35 of file EvtGenInterface.cc.

References gather_cfg::cout, edm::hlt::Exception, edm::ParameterSet::exists(), edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), nevent, and groupFilesInBlocks::ntotal.

36 {
37 
38  ntotal = 0;
39  nevent = 0;
40  std::cout << " EvtGenProducer starting ... " << std::endl;
41 
42  the_engine = new myEvtRandomEngine(nullptr);
43 
44  // Get data from parameter set
45  edm::FileInPath decay_table = pset.getParameter<edm::FileInPath>("decay_table");
46  edm::FileInPath pdt = pset.getParameter<edm::FileInPath>("particle_property_file");
47  useDefault = pset.getUntrackedParameter<bool>("use_default_decay",true);
48  usePythia = pset.getUntrackedParameter<bool>("use_internal_pythia",true);
49  polarize_ids = pset.getUntrackedParameter<std::vector<int> >("particles_to_polarize",
50  std::vector<int>());
51  polarize_pol = pset.getUntrackedParameter<std::vector<double> >("particle_polarizations",
52  std::vector<double>());
53  if (polarize_ids.size() != polarize_pol.size()) {
54  throw cms::Exception("Configuration")
55  << "EvtGenProducer requires that the particles_to_polarize and particle_polarization\n"
56  "vectors be the same size. Please fix this in your configuration.";
57  }
58  for (unsigned int ndx = 0; ndx < polarize_ids.size(); ndx++) {
59  if (polarize_pol[ndx] < -1. || polarize_pol[ndx] > 1.) {
60  throw cms::Exception("Configuration")
61  << "EvtGenProducer error: particle polarizations must be in the range -1 < P < 1";
62  }
63  polarizations.insert(std::pair<int, float>(polarize_ids[ndx], polarize_pol[ndx]));
64  }
65 
66  edm::FileInPath user_decay = pset.getParameter<edm::FileInPath>("user_decay_file");
67  decay_table_s = decay_table.fullPath();
68  pdt_s = pdt.fullPath();
69  user_decay_s = user_decay.fullPath();
70 
71  //-->pythia_params = pset.getParameter< std::vector<std::string> >("processParameters");
72 
73 
74  // any number of alias names for forced decays can be specified using dynamic std vector of strings
75  forced_names = pset.getParameter< std::vector<std::string> >("list_forced_decays");
76 
77 
78  // fill up default list of particles to be declared stable in the "master generator"
79  // these are assumed to be PDG ID's
80  // in case of combo with Pythia6, translation is done in Pythia6Hadronizer
81  //
82  // Note: Pythia6's kc=43, 44, and 84 commented out because they're obsolete (per S.Mrenna)
83  //
84  m_PDGs.push_back( 300553 ) ;
85  m_PDGs.push_back( 511 ) ;
86  m_PDGs.push_back( 521 ) ;
87  m_PDGs.push_back( 523 ) ;
88  m_PDGs.push_back( 513 ) ;
89  m_PDGs.push_back( 533 ) ;
90  m_PDGs.push_back( 531 ) ;
91 
92  m_PDGs.push_back( 15 ) ;
93 
94  m_PDGs.push_back( 413 ) ;
95  m_PDGs.push_back( 423 ) ;
96  m_PDGs.push_back( 433 ) ;
97  m_PDGs.push_back( 411 ) ;
98  m_PDGs.push_back( 421 ) ;
99  m_PDGs.push_back( 431 ) ;
100  m_PDGs.push_back( 10411 );
101  m_PDGs.push_back( 10421 );
102  m_PDGs.push_back( 10413 );
103  m_PDGs.push_back( 10423 );
104  m_PDGs.push_back( 20413 );
105  m_PDGs.push_back( 20423 );
106 
107  m_PDGs.push_back( 415 );
108  m_PDGs.push_back( 425 );
109  m_PDGs.push_back( 10431 );
110  m_PDGs.push_back( 20433 );
111  m_PDGs.push_back( 10433 );
112  m_PDGs.push_back( 435 );
113 
114  m_PDGs.push_back( 310 );
115  m_PDGs.push_back( 311 );
116  m_PDGs.push_back( 313 );
117  m_PDGs.push_back( 323 );
118  m_PDGs.push_back( 10321 );
119  m_PDGs.push_back( 10311 );
120  m_PDGs.push_back( 10313 );
121  m_PDGs.push_back( 10323 );
122  m_PDGs.push_back( 20323 );
123  m_PDGs.push_back( 20313 );
124  m_PDGs.push_back( 325 );
125  m_PDGs.push_back( 315 );
126 
127  m_PDGs.push_back( 100313 );
128  m_PDGs.push_back( 100323 );
129  m_PDGs.push_back( 30313 );
130  m_PDGs.push_back( 30323 );
131  m_PDGs.push_back( 30343 );
132  m_PDGs.push_back( 30353 );
133  m_PDGs.push_back( 30363 );
134 
135  m_PDGs.push_back( 111 );
136  m_PDGs.push_back( 221 );
137  m_PDGs.push_back( 113 );
138  m_PDGs.push_back( 213 );
139  m_PDGs.push_back( 223 );
140  m_PDGs.push_back( 331 );
141  m_PDGs.push_back( 333 );
142  m_PDGs.push_back( 20213 );
143  m_PDGs.push_back( 20113 );
144  m_PDGs.push_back( 215 );
145  m_PDGs.push_back( 115 );
146  m_PDGs.push_back( 10213 );
147  m_PDGs.push_back( 10113 );
148  m_PDGs.push_back( 9000111 ); // PDG ID = 9000111, Pythia6 ID = 10111
149  m_PDGs.push_back( 9000211 ); // PDG ID = 9000211, Pythia6 ID = 10211
150  m_PDGs.push_back( 9010221 ); // PDG ID = 9010211, Pythia6 ID = ???
151  m_PDGs.push_back( 10221 );
152  m_PDGs.push_back( 20223 );
153  m_PDGs.push_back( 20333 );
154  m_PDGs.push_back( 225 );
155  m_PDGs.push_back( 9020221 ); // PDG ID = 9020211, Pythia6 ID = ???
156  m_PDGs.push_back( 335 );
157  m_PDGs.push_back( 10223 );
158  m_PDGs.push_back( 10333 );
159  m_PDGs.push_back( 100213 );
160  m_PDGs.push_back( 100113 );
161 
162  m_PDGs.push_back( 441 );
163  m_PDGs.push_back( 100441 );
164  m_PDGs.push_back( 443 );
165  m_PDGs.push_back( 100443 );
166  m_PDGs.push_back( 9000443 );
167  m_PDGs.push_back( 9010443 );
168  m_PDGs.push_back( 9020443 );
169  m_PDGs.push_back( 10441 );
170  m_PDGs.push_back( 20443 );
171  m_PDGs.push_back( 445 );
172 
173  m_PDGs.push_back( 30443 );
174  m_PDGs.push_back( 551 );
175  m_PDGs.push_back( 553 );
176  m_PDGs.push_back( 100553 );
177  m_PDGs.push_back( 200553 );
178  m_PDGs.push_back( 10551 );
179  m_PDGs.push_back( 20553 );
180  m_PDGs.push_back( 555 );
181  m_PDGs.push_back( 10553 );
182 
183  m_PDGs.push_back( 110551 );
184  m_PDGs.push_back( 120553 );
185  m_PDGs.push_back( 100555 );
186  m_PDGs.push_back( 210551 );
187  m_PDGs.push_back( 220553 );
188  m_PDGs.push_back( 200555 );
189  m_PDGs.push_back( 30553 );
190  m_PDGs.push_back( 20555 );
191 
192  m_PDGs.push_back( 557 );
193  m_PDGs.push_back( 130553 );
194  m_PDGs.push_back( 120555 );
195  m_PDGs.push_back( 100557 );
196  m_PDGs.push_back( 110553 );
197  m_PDGs.push_back( 210553 );
198  m_PDGs.push_back( 10555 );
199  m_PDGs.push_back( 110555 );
200 
201  m_PDGs.push_back( 4122 );
202  m_PDGs.push_back( 4132 );
203  // m_PDGs.push_back( 84 ); // obsolete
204  m_PDGs.push_back( 4112 );
205  m_PDGs.push_back( 4212 );
206  m_PDGs.push_back( 4232 );
207  m_PDGs.push_back( 4222 );
208  m_PDGs.push_back( 4322 );
209  m_PDGs.push_back( 4312 );
210 
211  m_PDGs.push_back( 13122 );
212  m_PDGs.push_back( 13124 );
213  m_PDGs.push_back( 23122 );
214  m_PDGs.push_back( 33122 );
215  m_PDGs.push_back( 43122 );
216  m_PDGs.push_back( 53122 );
217  m_PDGs.push_back( 13126 );
218  m_PDGs.push_back( 13212 );
219  m_PDGs.push_back( 13241 );
220 
221  m_PDGs.push_back( 3126 );
222  m_PDGs.push_back( 3124 );
223  m_PDGs.push_back( 3122 );
224  m_PDGs.push_back( 3222 );
225  m_PDGs.push_back( 2214 );
226  m_PDGs.push_back( 2224 );
227  m_PDGs.push_back( 3324 );
228  m_PDGs.push_back( 2114 );
229  m_PDGs.push_back( 1114 );
230  m_PDGs.push_back( 3112 );
231  m_PDGs.push_back( 3212 );
232  m_PDGs.push_back( 3114 );
233  m_PDGs.push_back( 3224 );
234  m_PDGs.push_back( 3214 );
235  m_PDGs.push_back( 3216 );
236  m_PDGs.push_back( 3322 );
237  m_PDGs.push_back( 3312 );
238  m_PDGs.push_back( 3314 );
239  m_PDGs.push_back( 3334 );
240 
241  m_PDGs.push_back( 4114 );
242  m_PDGs.push_back( 4214 );
243  m_PDGs.push_back( 4224 );
244  m_PDGs.push_back( 4314 );
245  m_PDGs.push_back( 4324 );
246  m_PDGs.push_back( 4332 );
247  m_PDGs.push_back( 4334 );
248  //m_PDGs.push_back( 43 ); // obsolete (?)
249  //m_PDGs.push_back( 44 ); // obsolete (?)
250  m_PDGs.push_back( 10443 );
251 
252  m_PDGs.push_back( 5122 );
253  m_PDGs.push_back( 5132 );
254  m_PDGs.push_back( 5232 );
255  m_PDGs.push_back( 5332 );
256  m_PDGs.push_back( 5222 );
257  m_PDGs.push_back( 5112 );
258  m_PDGs.push_back( 5212 );
259  m_PDGs.push_back( 541 );
260  m_PDGs.push_back( 14122 );
261  m_PDGs.push_back( 14124 );
262  m_PDGs.push_back( 5312 );
263  m_PDGs.push_back( 5322 );
264  m_PDGs.push_back( 10521 );
265  m_PDGs.push_back( 20523 );
266  m_PDGs.push_back( 10523 );
267 
268  m_PDGs.push_back( 525 );
269  m_PDGs.push_back( 10511 );
270  m_PDGs.push_back( 20513 );
271  m_PDGs.push_back( 10513 );
272  m_PDGs.push_back( 515 );
273  m_PDGs.push_back( 10531 );
274  m_PDGs.push_back( 20533 );
275  m_PDGs.push_back( 10533 );
276  m_PDGs.push_back( 535 );
277  m_PDGs.push_back( 543 );
278  m_PDGs.push_back( 545 );
279  m_PDGs.push_back( 5114 );
280  m_PDGs.push_back( 5224 );
281  m_PDGs.push_back( 5214 );
282  m_PDGs.push_back( 5314 );
283  m_PDGs.push_back( 5324 );
284  m_PDGs.push_back( 5334 );
285  m_PDGs.push_back( 10541 );
286  m_PDGs.push_back( 10543 );
287  m_PDGs.push_back( 20543 );
288 
289  m_PDGs.push_back( 4424 );
290  m_PDGs.push_back( 4422 );
291  m_PDGs.push_back( 4414 );
292  m_PDGs.push_back( 4412 );
293  m_PDGs.push_back( 4432 );
294  m_PDGs.push_back( 4434 );
295 
296  m_PDGs.push_back( 130 );
297 
298  // now check if we need to override default list of particles/IDs
299  if ( pset.exists("operates_on_particles") )
300  {
301  std::vector<int> tmpPIDs = pset.getParameter< std::vector<int> >("operates_on_particles");
302  if ( tmpPIDs.size() > 0 )
303  {
304  if ( tmpPIDs[0] > 0 ) // 0 means default !!!
305  {
306  m_PDGs.clear();
307  m_PDGs = tmpPIDs;
308  }
309  }
310  }
312 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > forced_names
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< int > polarize_ids
Pythia6Service * m_Py6Service
std::string decay_table_s
std::map< int, float > polarizations
std::vector< double > polarize_pol
std::vector< int > m_PDGs
myEvtRandomEngine * the_engine
tuple cout
Definition: gather_cfg.py:121
std::string fullPath() const
Definition: FileInPath.cc:171
std::string user_decay_s
EvtGenInterface::~EvtGenInterface ( )

Definition at line 314 of file EvtGenInterface.cc.

References gather_cfg::cout.

315 {
316  std::cout << " EvtGenProducer terminating ... " << std::endl;
317  delete m_Py6Service;
318 }
Pythia6Service * m_Py6Service
tuple cout
Definition: gather_cfg.py:121

Member Function Documentation

void EvtGenInterface::addToHepMC ( HepMC::GenParticle *  partHep,
EvtId  idEvt,
HepMC::GenEvent *  theEvent,
bool  del_daug 
)

Definition at line 438 of file EvtGenInterface.cc.

References gather_cfg::cout, Vector3DBase< T, FrameTag >::cross(), configurableAnalysis::GenParticle, groupFilesInBlocks::ntotal, edm::second(), sistrip::STRING, Vector3DBase< T, FrameTag >::unit(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

439 {
440  // Set spin type
441  EvtSpinType::spintype stype = EvtPDL::getSpinType(idEvt);
442  EvtParticle* partEvt;
443  switch (stype){
444  case EvtSpinType::SCALAR:
445  partEvt = new EvtScalarParticle();
446  break;
447  case EvtSpinType::STRING:
448  partEvt = new EvtStringParticle();
449  break;
450  case EvtSpinType::DIRAC:
451  partEvt = new EvtDiracParticle();
452  break;
453  case EvtSpinType::VECTOR:
454  partEvt = new EvtVectorParticle();
455  break;
456  case EvtSpinType::RARITASCHWINGER:
457  partEvt = new EvtRaritaSchwingerParticle();
458  break;
459  case EvtSpinType::TENSOR:
460  partEvt = new EvtTensorParticle();
461  break;
462  case EvtSpinType::SPIN5HALF: case EvtSpinType::SPIN3: case EvtSpinType::SPIN7HALF: case EvtSpinType::SPIN4:
463  partEvt = new EvtHighSpinParticle();
464  break;
465  default:
466  std::cout << "Unknown spintype in EvtSpinType!" << std::endl;
467  return;
468  }
469 
470  // Generate decay
471  EvtVector4R momEvt;
472  HepMC::FourVector momHep = partHep->momentum();
473  momEvt.set(momHep.t(),momHep.x(),momHep.y(),momHep.z());
474  EvtVector4R posEvt;
475  HepMC::GenVertex* initVert = partHep->production_vertex();
476  HepMC::FourVector posHep = initVert->position();
477  posEvt.set(posHep.t(),posHep.x(),posHep.y(),posHep.z());
478  partEvt->init(idEvt,momEvt);
479  if (stype == EvtSpinType::DIRAC
480  && polarizations.find(partHep->pdg_id()) != polarizations.end()) {
481  // std::cout << "Polarize particle" << std::endl;
482  //Particle is spin 1/2, so we can polarize it.
483  //Check polarizations map for particle, grab its polarization if it exists
484  // and make the spin density matrix
485  float pol = polarizations.find(partHep->pdg_id())->second;
486  GlobalVector pPart(momHep.x(), momHep.y(), momHep.z());
487  //std::cout << "Polarizing particle with PDG ID "
488  // << partHep->pdg_id()
489  // << " at " << pol*100 << "%" << std::endl;
490  GlobalVector zHat(0., 0., 1.);
491  GlobalVector zCrossP = zHat.cross(pPart);
492  GlobalVector polVec = pol * zCrossP.unit();
493 
494  EvtSpinDensity theSpinDensity;
495  theSpinDensity.SetDim(2);
496  theSpinDensity.Set(0, 0, EvtComplex(1./2. + polVec.z()/2., 0.));
497  theSpinDensity.Set(0, 1, EvtComplex(polVec.x()/2., -polVec.y()/2.));
498  theSpinDensity.Set(1, 0, EvtComplex(polVec.x()/2., polVec.y()/2.));
499  theSpinDensity.Set(1, 1, EvtComplex(1./2. - polVec.z()/2., 0.));
500 
501  partEvt->setSpinDensityForwardHelicityBasis(theSpinDensity);
502 
503  } else {
504  partEvt->setDiagonalSpinDensity();
505  }
506  partEvt->decay();
507 
508  // extend the search of candidates to be forced to EvtGen decay products and delete their daughters **
509  // otherwise they wouldn't get their chance to take part in the forced decay lottery **
510  if (del_daug) go_through_daughters(partEvt); // recursive function go_through_daughters will do **
511 
512  // Change particle in stdHEP format
513  static EvtStdHep evtstdhep;
514 
515  evtstdhep.init();
516  partEvt->makeStdHep(evtstdhep);
517 
518  ntotal++;
519  partEvt->deleteTree();
520 
521  // ********* Now add to the HepMC Event **********
522 
523  // Then loop on evtstdhep to add vertexes...
524  HepMC::GenVertex* theVerts[200];
525  for (int ivert = 0; ivert < 200; ivert++) {
526  theVerts[ivert] = 0;
527  }
528 
529  for (int ipart = 0; ipart < evtstdhep.getNPart(); ipart++) {
530  int theMum = evtstdhep.getFirstMother(ipart);
531  if (theMum != -1 && !theVerts[theMum]) {
532  EvtVector4R theVpos = evtstdhep.getX4(ipart) + posEvt;
533  theVerts[theMum] =
534  new HepMC::GenVertex(HepMC::FourVector(theVpos.get(1),
535  theVpos.get(2),
536  theVpos.get(3),
537  theVpos.get(0)),0);
538  }
539  }
540 
541  // ...then particles
542  partHep->set_status(2);
543  if (theVerts[0]) theVerts[0]->add_particle_in( partHep );
544 
545  for (int ipart2 = 1; ipart2 < evtstdhep.getNPart(); ipart2++) {
546  int idHep = evtstdhep.getStdHepID(ipart2);
547  HepMC::GenParticle* thePart =
548  new HepMC::GenParticle( HepMC::FourVector(evtstdhep.getP4(ipart2).get(1),
549  evtstdhep.getP4(ipart2).get(2),
550  evtstdhep.getP4(ipart2).get(3),
551  evtstdhep.getP4(ipart2).get(0)),
552  idHep,
553  evtstdhep.getIStat(ipart2));
554  npartial++;
555  thePart->suggest_barcode(npartial + nPythia);
556  int theMum2 = evtstdhep.getFirstMother(ipart2);
557  if (theMum2 != -1 && theVerts[theMum2]) theVerts[theMum2]->add_particle_out( thePart );
558  if (theVerts[ipart2]) theVerts[ipart2]->add_particle_in( thePart );
559 
560  }
561 
562  for (int ipart3 = 0; ipart3 < evtstdhep.getNPart(); ipart3++) {
563  if (theVerts[ipart3]) theEvent->add_vertex( theVerts[ipart3] );
564  }
565 
566 }
T y() const
Definition: PV3DBase.h:63
void go_through_daughters(EvtParticle *part)
U second(std::pair< T, U > const &p)
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:119
T z() const
Definition: PV3DBase.h:64
std::map< int, float > polarizations
Vector3DBase unit() const
Definition: Vector3DBase.h:57
tuple cout
Definition: gather_cfg.py:121
T x() const
Definition: PV3DBase.h:62
HepMC::GenEvent * EvtGenInterface::decay ( HepMC::GenEvent *  evt)

Definition at line 357 of file EvtGenInterface.cc.

References edm::hlt::Exception, i, getHLTprescales::index, gen::k, edm::errors::LogicError, nevent, gen::p, and ntuplemaker::status.

Referenced by gen::ExternalDecayDriver::decay().

358 {
359  if(the_engine->engine() == nullptr) {
361  << "The EvtGen code attempted to use a random number engine while\n"
362  << "the engine pointer was null in EvtGenInterface::decay. This might\n"
363  << "mean that the code was modified to generate a random number outside\n"
364  << "the event and beginLuminosityBlock methods, which is not allowed.\n";
365  }
366  CLHEP::RandFlat m_flat(*the_engine->engine(), 0., 1.);
367 
368  Pythia6Service::InstanceWrapper guard(m_Py6Service); // grab Py6 instance
369 
370  nevent++;
371  npartial = 0;
372  // std::cout << "nevent = " << nevent << std::endl ;
373 
374  int idHep,ipart,status;
375  EvtId idEvt;
376 
377  nPythia = evt->particles_size();
378  // FIX A MEMORY LEAK (RC)
379  // HepMC::GenEvent* newEvt = new HepMC::GenEvent( *evt );
380 
381  // First pass through undecayed Pythia particles to decay particles known to EvtGen left stable by Pythia
382  // except candidates to be forced which will be searched later to include EvtGen decay products
383  nlist = 0;
384 
385  // Notice dynamical use of evt
386  for (HepMC::GenEvent::particle_const_iterator p= evt->particles_begin(); p != evt->particles_end(); ++p)
387  {
388  status = (*p)->status();
389 
390  if(status==1) { // only not decayed (status = 1) particles
391 
392 
393  idHep = (*p)->pdg_id();
394  int do_force=0;
395  for(int i=0;i<nforced;i++) // First check if part with forced decay
396  { // In that case do not decay immediately
397  if(idHep == forced_Hep[i]) // (only 1 per event will be forced)
398  { // Fill list
399  update_candlist(i,*p);
400  do_force=1;
401  }
402  }
403  if(do_force==0) // particles with decays not forced are decayed immediately
404  {
405  idEvt = EvtPDL::evtIdFromStdHep(idHep);
406  ipart = idEvt.getId();
407  if (ipart==-1) continue; // particle not known to EvtGen
408  if (EvtDecayTable::getNMode(ipart)==0) continue; // particles stable for EvtGen
409  addToHepMC(*p,idEvt,evt,true); // generate decay
410  }
411  }
412  }
413 
414  if(nlist!=0)
415  {
416  // decide randomly which one to decay as alias
417  int which = (int)(nlist * m_flat.fire());
418  if (which == nlist) which = nlist-1;
419 
420  for(int k=0;k < nlist; k++)
421  {
422  if(k == which || !usePythia) {
423  addToHepMC(listp[k],forced_Evt[index[k]],evt,false); // decay as alias
424  }
425  else
426  {
427  int id_non_alias = forced_Evt[index[k]].getId();
428  EvtId non_alias(id_non_alias,id_non_alias); // create new EvtId with id = alias
429  addToHepMC(listp[k],non_alias,evt,false); // decay as standard (non alias)
430  }
431  }
432  }
433 
434  return evt;
435 
436 }
int i
Definition: DBlmapReader.cc:9
void addToHepMC(HepMC::GenParticle *partHep, EvtId idEvt, HepMC::GenEvent *theEvent, bool del_daug)
void update_candlist(int theIndex, HepMC::GenParticle *thePart)
std::vector< EvtId > forced_Evt
Pythia6Service * m_Py6Service
double p[5][pyjets_maxn]
CLHEP::HepRandomEngine * engine() const
HepMC::GenParticle * listp[10]
int k[5][pyjets_maxn]
myEvtRandomEngine * the_engine
std::vector< int > forced_Hep
tuple status
Definition: ntuplemaker.py:245
void EvtGenInterface::go_through_daughters ( EvtParticle *  part)

Definition at line 579 of file EvtGenInterface.cc.

References newFWLiteAna::found, i, and gen::k.

579  {
580 
581  int NDaug=part->getNDaug();
582  if(NDaug)
583  {
584  EvtParticle* Daughter;
585  for (int i=0;i<NDaug;i++)
586  {
587  Daughter=part->getDaug(i);
588  int idHep = EvtPDL::getStdHep(Daughter->getId());
589  int found=0;
590  for(int k=0;k<nforced;k++)
591  {
592  if(idHep == forced_Hep[k])
593  {
594  found = 1;
595  Daughter->deleteDaughters();
596  }
597  }
598  if (!found) go_through_daughters(Daughter);
599  }
600  }
601 }
int i
Definition: DBlmapReader.cc:9
void go_through_daughters(EvtParticle *part)
int k[5][pyjets_maxn]
part
Definition: HCALResponse.h:20
std::vector< int > forced_Hep
void EvtGenInterface::init ( void  )

Definition at line 320 of file EvtGenInterface.cc.

References edm::hlt::Exception, newFWLiteAna::found, and getId().

Referenced by gen::ExternalDecayDriver::init().

321 {
322  m_EvtGen = new EvtGen (decay_table_s.c_str(), pdt_s.c_str(), the_engine);
323  // 4th parameter should be rad cor - set to PHOTOS (default)
324 
325  if (!useDefault) m_EvtGen->readUDecay( user_decay_s.c_str() );
326 
327  nforced = 0;
328  for (auto const& forced_name : forced_names) {
329  ++nforced;
330  EvtId found = EvtPDL::getId(forced_name);
331  if (found.getId() == -1) {
332  throw cms::Exception("Configuration")
333  << "name in part list for forced decays not found: " << forced_name;
334  }
335  if (found.getId() == found.getAlias()) {
336  throw cms::Exception("Configuration")
337  << "name in part list for forced decays is not an alias: " << forced_name;
338  }
339  forced_Evt.push_back(found); // forced_Evt is the list of EvtId's
340  forced_Hep.push_back(EvtPDL::getStdHep(found)); // forced_Hep is the list of stdhep codes
341  }
342 
343  Pythia6Service::InstanceWrapper guard(m_Py6Service); // grab Py6 instance
344 
345  // Do here initialization of EvtPythia then restore original settings
346  if (usePythia) EvtPythia::pythiaInit(0);
347 
348 // no need - will be done via Pythia6Hadronizer::declareStableParticles
349 //
350 // for( std::vector<std::string>::const_iterator itPar = pythia_params.begin(); itPar != pythia_params.end(); ++itPar ) {
351 // call_pygive(*itPar);
352 // }
353 
354  return;
355 }
std::vector< std::string > forced_names
static unsigned int getId(void)
std::vector< EvtId > forced_Evt
Pythia6Service * m_Py6Service
std::string decay_table_s
myEvtRandomEngine * the_engine
std::vector< int > forced_Hep
std::string user_decay_s
const std::vector<int>& gen::EvtGenInterface::operatesOnParticles ( )
inline

Definition at line 58 of file EvtGenInterface.h.

References m_PDGs.

Referenced by gen::ExternalDecayDriver::init().

58 { return m_PDGs; }
std::vector< int > m_PDGs
void EvtGenInterface::setRandomEngine ( CLHEP::HepRandomEngine *  v)

Definition at line 629 of file EvtGenInterface.cc.

Referenced by gen::ExternalDecayDriver::setRandomEngine().

629  {
632 }
double v[5][pyjets_maxn]
Pythia6Service * m_Py6Service
myEvtRandomEngine * the_engine
void setRandomEngine(CLHEP::HepRandomEngine *v)
void setRandomEngine(CLHEP::HepRandomEngine *v)
void EvtGenInterface::update_candlist ( int  theIndex,
HepMC::GenParticle *  thePart 
)

Definition at line 604 of file EvtGenInterface.cc.

References CastorDataFrameFilter_impl::check(), edm::hlt::Exception, and getHLTprescales::index.

605 {
606  if(nlist<10) // not nice ... but is 10 a reasonable maximum?
607  {
608  bool isThere = false;
609  if (nlist) {
610  for (int check=0; check < nlist; check++) {
611  if (listp[check]->barcode() == thePart->barcode()) isThere = true;
612  }
613  }
614  if (!isThere) {
615  listp[nlist] = thePart;
616  index[nlist++] = theIndex;
617  }
618  }
619  else
620  {
621  throw cms::Exception("runtime")
622  << "more than 10 candidates to be forced ";
623  return;
624  }
625  return;
626 }
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
HepMC::GenParticle * listp[10]

Member Data Documentation

std::string gen::EvtGenInterface::decay_table_s
private

Definition at line 97 of file EvtGenInterface.h.

std::vector<EvtId> gen::EvtGenInterface::forced_Evt
private

Definition at line 76 of file EvtGenInterface.h.

std::vector<int> gen::EvtGenInterface::forced_Hep
private

Definition at line 77 of file EvtGenInterface.h.

std::vector<std::string> gen::EvtGenInterface::forced_names
private

Definition at line 100 of file EvtGenInterface.h.

int gen::EvtGenInterface::index[10]
private

Definition at line 92 of file EvtGenInterface.h.

Referenced by BeautifulSoup.PageElement::_invert().

HepMC::GenParticle* gen::EvtGenInterface::listp[10]
private

Definition at line 91 of file EvtGenInterface.h.

EvtGen* gen::EvtGenInterface::m_EvtGen
private

Definition at line 75 of file EvtGenInterface.h.

std::vector<int> gen::EvtGenInterface::m_PDGs
private

Definition at line 73 of file EvtGenInterface.h.

Referenced by operatesOnParticles().

Pythia6Service* gen::EvtGenInterface::m_Py6Service
private

Definition at line 71 of file EvtGenInterface.h.

int gen::EvtGenInterface::nevent
private

Definition at line 79 of file EvtGenInterface.h.

int gen::EvtGenInterface::nforced
private

Definition at line 78 of file EvtGenInterface.h.

int gen::EvtGenInterface::nlist
private

Definition at line 90 of file EvtGenInterface.h.

int gen::EvtGenInterface::npartial
private

Definition at line 79 of file EvtGenInterface.h.

int gen::EvtGenInterface::nPythia
private

Definition at line 81 of file EvtGenInterface.h.

int gen::EvtGenInterface::ntotal
private

Definition at line 79 of file EvtGenInterface.h.

std::string gen::EvtGenInterface::pdt_s
private

Definition at line 98 of file EvtGenInterface.h.

std::map<int, float> gen::EvtGenInterface::polarizations
private

Definition at line 88 of file EvtGenInterface.h.

std::vector<int> gen::EvtGenInterface::polarize_ids
private

Definition at line 86 of file EvtGenInterface.h.

std::vector<double> gen::EvtGenInterface::polarize_pol
private

Definition at line 87 of file EvtGenInterface.h.

myEvtRandomEngine* gen::EvtGenInterface::the_engine
private

Definition at line 94 of file EvtGenInterface.h.

bool gen::EvtGenInterface::useDefault
private

Definition at line 96 of file EvtGenInterface.h.

bool gen::EvtGenInterface::usePythia
private

Definition at line 82 of file EvtGenInterface.h.

std::string gen::EvtGenInterface::user_decay_s
private

Definition at line 99 of file EvtGenInterface.h.