CMS 3D CMS Logo

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

#include <EvtGenLHCInterface.h>

Inheritance diagram for gen::EvtGenLHCInterface:
gen::EvtGenInterfaceBase

Public Member Functions

void addToHepMC (HepMC::GenParticle *partHep, EvtId idEvt, HepMC::GenEvent *theEvent, bool del_daug)
 
HepMC::GenEvent * decay (HepMC::GenEvent *)
 
 EvtGenLHCInterface (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)
 
 ~EvtGenLHCInterface ()
 
- Public Member Functions inherited from gen::EvtGenInterfaceBase
 EvtGenInterfaceBase ()
 
virtual void SetPhotosDecayRandomEngine (CLHEP::HepRandomEngine *decayRandomEngine)
 
virtual const std::vector
< std::string > & 
specialSettings ()
 
virtual ~EvtGenInterfaceBase ()
 

Static Public Member Functions

static double flat ()
 

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

Static Private Attributes

static CLHEP::HepRandomEngine * fRandomEngine
 

Additional Inherited Members

- Protected Attributes inherited from gen::EvtGenInterfaceBase
std::vector< std::string > fSpecialSettings
 
std::vector< int > m_PDGs
 

Detailed Description

Definition at line 46 of file EvtGenLHCInterface.h.

Constructor & Destructor Documentation

EvtGenLHCInterface::EvtGenLHCInterface ( const edm::ParameterSet pset)

Definition at line 49 of file EvtGenLHCInterface.cc.

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

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

Definition at line 328 of file EvtGenLHCInterface.cc.

References gather_cfg::cout.

329 {
330  std::cout << " EvtGenProducer terminating ... " << std::endl;
331  delete m_Py6Service;
332 }
Pythia6Service * m_Py6Service
tuple cout
Definition: gather_cfg.py:121

Member Function Documentation

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

Definition at line 452 of file EvtGenLHCInterface.cc.

References gather_cfg::cout, Vector3DBase< T, FrameTag >::cross(), GenParticle::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().

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

Reimplemented from gen::EvtGenInterfaceBase.

Definition at line 371 of file EvtGenLHCInterface.cc.

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

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

Definition at line 649 of file EvtGenLHCInterface.cc.

References edm::hlt::Exception.

Referenced by phoran_().

649  {
650  if ( !fRandomEngine ) {
651  throw cms::Exception("LogicError")
652  << "EvtGenLHCInterface::flat: Attempt to generate random number when engine pointer is null\n"
653  << "This might mean that the code was modified to generate a random number outside the\n"
654  << "event and beginLuminosityBlock methods, which is not allowed.\n";
655  }
656  return fRandomEngine->flat();
657 }
static CLHEP::HepRandomEngine * fRandomEngine
void EvtGenLHCInterface::go_through_daughters ( EvtParticle *  part)

Definition at line 593 of file EvtGenLHCInterface.cc.

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

593  {
594 
595  int NDaug=part->getNDaug();
596  if(NDaug)
597  {
598  EvtParticle* Daughter;
599  for (int i=0;i<NDaug;i++)
600  {
601  Daughter=part->getDaug(i);
602  int idHep = EvtPDL::getStdHep(Daughter->getId());
603  int found=0;
604  for(int k=0;k<nforced;k++)
605  {
606  if(idHep == forced_Hep[k])
607  {
608  found = 1;
609  Daughter->deleteDaughters();
610  }
611  }
612  if (!found) go_through_daughters(Daughter);
613  }
614  }
615 }
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 EvtGenLHCInterface::init ( void  )
virtual

Reimplemented from gen::EvtGenInterfaceBase.

Definition at line 334 of file EvtGenLHCInterface.cc.

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

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

Reimplemented from gen::EvtGenInterfaceBase.

Definition at line 54 of file EvtGenLHCInterface.h.

References gen::EvtGenInterfaceBase::m_PDGs.

54 { return m_PDGs; }
void EvtGenLHCInterface::setRandomEngine ( CLHEP::HepRandomEngine *  v)
virtual

Implements gen::EvtGenInterfaceBase.

Definition at line 643 of file EvtGenLHCInterface.cc.

References gen::v.

643  {
647 }
myEvtRandomEngine * the_engine
double v[5][pyjets_maxn]
static CLHEP::HepRandomEngine * fRandomEngine
Pythia6Service * m_Py6Service
void setRandomEngine(CLHEP::HepRandomEngine *v)
void setRandomEngine(CLHEP::HepRandomEngine *v)
void EvtGenLHCInterface::update_candlist ( int  theIndex,
HepMC::GenParticle *  thePart 
)

Definition at line 618 of file EvtGenLHCInterface.cc.

References DDVectorGetter::check(), edm::hlt::Exception, cmsHarvester::index, and theIndex().

619 {
620  if(nlist<10) // not nice ... but is 10 a reasonable maximum?
621  {
622  bool isThere = false;
623  if (nlist) {
624  for (int check=0; check < nlist; check++) {
625  if (listp[check]->barcode() == thePart->barcode()) isThere = true;
626  }
627  }
628  if (!isThere) {
629  listp[nlist] = thePart;
630  index[nlist++] = theIndex;
631  }
632  }
633  else
634  {
635  throw cms::Exception("runtime")
636  << "more than 10 candidates to be forced ";
637  return;
638  }
639  return;
640 }
theIndex(0)
HepMC::GenParticle * listp[10]
bool check(const std::string &)

Member Data Documentation

std::string gen::EvtGenLHCInterface::decay_table_s
private

Definition at line 91 of file EvtGenLHCInterface.h.

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

Definition at line 70 of file EvtGenLHCInterface.h.

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

Definition at line 71 of file EvtGenLHCInterface.h.

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

Definition at line 94 of file EvtGenLHCInterface.h.

CLHEP::HepRandomEngine * EvtGenLHCInterface::fRandomEngine
staticprivate

Definition at line 96 of file EvtGenLHCInterface.h.

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

Definition at line 86 of file EvtGenLHCInterface.h.

Referenced by BeautifulSoup.PageElement::_invert().

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

Definition at line 85 of file EvtGenLHCInterface.h.

EvtGen* gen::EvtGenLHCInterface::m_EvtGen
private

Definition at line 69 of file EvtGenLHCInterface.h.

Pythia6Service* gen::EvtGenLHCInterface::m_Py6Service
private

Definition at line 67 of file EvtGenLHCInterface.h.

int gen::EvtGenLHCInterface::nevent
private

Definition at line 73 of file EvtGenLHCInterface.h.

int gen::EvtGenLHCInterface::nforced
private

Definition at line 72 of file EvtGenLHCInterface.h.

int gen::EvtGenLHCInterface::nlist
private

Definition at line 84 of file EvtGenLHCInterface.h.

int gen::EvtGenLHCInterface::npartial
private

Definition at line 73 of file EvtGenLHCInterface.h.

int gen::EvtGenLHCInterface::nPythia
private

Definition at line 75 of file EvtGenLHCInterface.h.

int gen::EvtGenLHCInterface::ntotal
private

Definition at line 73 of file EvtGenLHCInterface.h.

std::string gen::EvtGenLHCInterface::pdt_s
private

Definition at line 92 of file EvtGenLHCInterface.h.

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

Definition at line 82 of file EvtGenLHCInterface.h.

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

Definition at line 80 of file EvtGenLHCInterface.h.

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

Definition at line 81 of file EvtGenLHCInterface.h.

myEvtRandomEngine* gen::EvtGenLHCInterface::the_engine
private

Definition at line 88 of file EvtGenLHCInterface.h.

bool gen::EvtGenLHCInterface::useDefault
private

Definition at line 90 of file EvtGenLHCInterface.h.

bool gen::EvtGenLHCInterface::usePythia
private

Definition at line 76 of file EvtGenLHCInterface.h.

std::string gen::EvtGenLHCInterface::user_decay_s
private

Definition at line 93 of file EvtGenLHCInterface.h.