17 #include "CLHEP/Random/Random.h"
22 #include "HepMC/GenEvent.h"
38 std::cout <<
" EvtGenProducer starting ... " << std::endl;
48 <<
"The EvtGenProducer module requires the RandomNumberGeneratorService\n"
49 "which is not present in the configuration file. You must add the service\n"
50 "in the configuration file if you want to run EvtGenProducer";
53 CLHEP::HepRandomEngine& m_engine = rngen->
getEngine();
54 m_flat =
new CLHEP::RandFlat(m_engine, 0., 1.);
64 std::string decay_table_s = decay_table.
fullPath();
65 std::string pdt_s = pdt.fullPath();
66 std::string user_decay_s = user_decay.fullPath();
72 std::vector<std::string> forced_names = pset.
getParameter< std::vector<std::string> >(
"list_forced_decays");
74 m_EvtGen =
new EvtGen (decay_table_s.c_str(),pdt_s.c_str(),the_engine);
77 if (!useDefault) m_EvtGen->readUDecay( user_decay_s.c_str() );
79 std::vector<std::string>::const_iterator
i;
82 for (i=forced_names.begin(); i!=forced_names.end(); ++
i)
88 if (found.getId()==-1)
91 <<
"name in part list for forced decays not found: " << *
i;
93 if (found.getId()==found.getAlias())
96 <<
"name in part list for forced decays is not an alias: " << *
i;
98 forced_Evt.push_back(found);
99 forced_Hep.push_back(EvtPDL::getStdHep(found));
108 m_PDGs.push_back( 300553 ) ;
109 m_PDGs.push_back( 511 ) ;
110 m_PDGs.push_back( 521 ) ;
111 m_PDGs.push_back( 523 ) ;
112 m_PDGs.push_back( 513 ) ;
113 m_PDGs.push_back( 533 ) ;
114 m_PDGs.push_back( 531 ) ;
116 m_PDGs.push_back( 15 ) ;
118 m_PDGs.push_back( 413 ) ;
119 m_PDGs.push_back( 423 ) ;
120 m_PDGs.push_back( 433 ) ;
121 m_PDGs.push_back( 411 ) ;
122 m_PDGs.push_back( 421 ) ;
123 m_PDGs.push_back( 431 ) ;
124 m_PDGs.push_back( 10411 );
125 m_PDGs.push_back( 10421 );
126 m_PDGs.push_back( 10413 );
127 m_PDGs.push_back( 10423 );
128 m_PDGs.push_back( 20413 );
129 m_PDGs.push_back( 20423 );
131 m_PDGs.push_back( 415 );
132 m_PDGs.push_back( 425 );
133 m_PDGs.push_back( 10431 );
134 m_PDGs.push_back( 20433 );
135 m_PDGs.push_back( 10433 );
136 m_PDGs.push_back( 435 );
138 m_PDGs.push_back( 310 );
139 m_PDGs.push_back( 311 );
140 m_PDGs.push_back( 313 );
141 m_PDGs.push_back( 323 );
142 m_PDGs.push_back( 10321 );
143 m_PDGs.push_back( 10311 );
144 m_PDGs.push_back( 10313 );
145 m_PDGs.push_back( 10323 );
146 m_PDGs.push_back( 20323 );
147 m_PDGs.push_back( 20313 );
148 m_PDGs.push_back( 325 );
149 m_PDGs.push_back( 315 );
151 m_PDGs.push_back( 100313 );
152 m_PDGs.push_back( 100323 );
153 m_PDGs.push_back( 30313 );
154 m_PDGs.push_back( 30323 );
155 m_PDGs.push_back( 30343 );
156 m_PDGs.push_back( 30353 );
157 m_PDGs.push_back( 30363 );
159 m_PDGs.push_back( 111 );
160 m_PDGs.push_back( 221 );
161 m_PDGs.push_back( 113 );
162 m_PDGs.push_back( 213 );
163 m_PDGs.push_back( 223 );
164 m_PDGs.push_back( 331 );
165 m_PDGs.push_back( 333 );
166 m_PDGs.push_back( 20213 );
167 m_PDGs.push_back( 20113 );
168 m_PDGs.push_back( 215 );
169 m_PDGs.push_back( 115 );
170 m_PDGs.push_back( 10213 );
171 m_PDGs.push_back( 10113 );
172 m_PDGs.push_back( 9000111 );
173 m_PDGs.push_back( 9000211 );
174 m_PDGs.push_back( 9010221 );
175 m_PDGs.push_back( 10221 );
176 m_PDGs.push_back( 20223 );
177 m_PDGs.push_back( 20333 );
178 m_PDGs.push_back( 225 );
179 m_PDGs.push_back( 9020221 );
180 m_PDGs.push_back( 335 );
181 m_PDGs.push_back( 10223 );
182 m_PDGs.push_back( 10333 );
183 m_PDGs.push_back( 100213 );
184 m_PDGs.push_back( 100113 );
186 m_PDGs.push_back( 441 );
187 m_PDGs.push_back( 100441 );
188 m_PDGs.push_back( 443 );
189 m_PDGs.push_back( 100443 );
190 m_PDGs.push_back( 9000443 );
191 m_PDGs.push_back( 9010443 );
192 m_PDGs.push_back( 9020443 );
193 m_PDGs.push_back( 10441 );
194 m_PDGs.push_back( 20443 );
195 m_PDGs.push_back( 445 );
197 m_PDGs.push_back( 30443 );
198 m_PDGs.push_back( 551 );
199 m_PDGs.push_back( 553 );
200 m_PDGs.push_back( 100553 );
201 m_PDGs.push_back( 200553 );
202 m_PDGs.push_back( 10551 );
203 m_PDGs.push_back( 20553 );
204 m_PDGs.push_back( 555 );
205 m_PDGs.push_back( 10553 );
207 m_PDGs.push_back( 110551 );
208 m_PDGs.push_back( 120553 );
209 m_PDGs.push_back( 100555 );
210 m_PDGs.push_back( 210551 );
211 m_PDGs.push_back( 220553 );
212 m_PDGs.push_back( 200555 );
213 m_PDGs.push_back( 30553 );
214 m_PDGs.push_back( 20555 );
216 m_PDGs.push_back( 557 );
217 m_PDGs.push_back( 130553 );
218 m_PDGs.push_back( 120555 );
219 m_PDGs.push_back( 100557 );
220 m_PDGs.push_back( 110553 );
221 m_PDGs.push_back( 210553 );
222 m_PDGs.push_back( 10555 );
223 m_PDGs.push_back( 110555 );
225 m_PDGs.push_back( 4122 );
226 m_PDGs.push_back( 4132 );
228 m_PDGs.push_back( 4112 );
229 m_PDGs.push_back( 4212 );
230 m_PDGs.push_back( 4232 );
231 m_PDGs.push_back( 4222 );
232 m_PDGs.push_back( 4322 );
233 m_PDGs.push_back( 4312 );
235 m_PDGs.push_back( 13122 );
236 m_PDGs.push_back( 13124 );
237 m_PDGs.push_back( 23122 );
238 m_PDGs.push_back( 33122 );
239 m_PDGs.push_back( 43122 );
240 m_PDGs.push_back( 53122 );
241 m_PDGs.push_back( 13126 );
242 m_PDGs.push_back( 13212 );
243 m_PDGs.push_back( 13241 );
245 m_PDGs.push_back( 3126 );
246 m_PDGs.push_back( 3124 );
247 m_PDGs.push_back( 3122 );
248 m_PDGs.push_back( 3222 );
249 m_PDGs.push_back( 2214 );
250 m_PDGs.push_back( 2224 );
251 m_PDGs.push_back( 3324 );
252 m_PDGs.push_back( 2114 );
253 m_PDGs.push_back( 1114 );
254 m_PDGs.push_back( 3112 );
255 m_PDGs.push_back( 3212 );
256 m_PDGs.push_back( 3114 );
257 m_PDGs.push_back( 3224 );
258 m_PDGs.push_back( 3214 );
259 m_PDGs.push_back( 3216 );
260 m_PDGs.push_back( 3322 );
261 m_PDGs.push_back( 3312 );
262 m_PDGs.push_back( 3314 );
263 m_PDGs.push_back( 3334 );
265 m_PDGs.push_back( 4114 );
266 m_PDGs.push_back( 4214 );
267 m_PDGs.push_back( 4224 );
268 m_PDGs.push_back( 4314 );
269 m_PDGs.push_back( 4324 );
270 m_PDGs.push_back( 4332 );
271 m_PDGs.push_back( 4334 );
274 m_PDGs.push_back( 10443 );
276 m_PDGs.push_back( 5122 );
277 m_PDGs.push_back( 5132 );
278 m_PDGs.push_back( 5232 );
279 m_PDGs.push_back( 5332 );
280 m_PDGs.push_back( 5222 );
281 m_PDGs.push_back( 5112 );
282 m_PDGs.push_back( 5212 );
283 m_PDGs.push_back( 541 );
284 m_PDGs.push_back( 14122 );
285 m_PDGs.push_back( 14124 );
286 m_PDGs.push_back( 5312 );
287 m_PDGs.push_back( 5322 );
288 m_PDGs.push_back( 10521 );
289 m_PDGs.push_back( 20523 );
290 m_PDGs.push_back( 10523 );
292 m_PDGs.push_back( 525 );
293 m_PDGs.push_back( 10511 );
294 m_PDGs.push_back( 20513 );
295 m_PDGs.push_back( 10513 );
296 m_PDGs.push_back( 515 );
297 m_PDGs.push_back( 10531 );
298 m_PDGs.push_back( 20533 );
299 m_PDGs.push_back( 10533 );
300 m_PDGs.push_back( 535 );
301 m_PDGs.push_back( 543 );
302 m_PDGs.push_back( 545 );
303 m_PDGs.push_back( 5114 );
304 m_PDGs.push_back( 5224 );
305 m_PDGs.push_back( 5214 );
306 m_PDGs.push_back( 5314 );
307 m_PDGs.push_back( 5324 );
308 m_PDGs.push_back( 5334 );
309 m_PDGs.push_back( 10541 );
310 m_PDGs.push_back( 10543 );
311 m_PDGs.push_back( 20543 );
313 m_PDGs.push_back( 4424 );
314 m_PDGs.push_back( 4422 );
315 m_PDGs.push_back( 4414 );
316 m_PDGs.push_back( 4412 );
317 m_PDGs.push_back( 4432 );
318 m_PDGs.push_back( 4434 );
320 m_PDGs.push_back( 130 );
323 if ( pset.
exists(
"operates_on_particles") )
325 std::vector<int> tmpPIDs = pset.
getParameter< std::vector<int> >(
"operates_on_particles");
326 if ( tmpPIDs.size() > 0 )
328 if ( tmpPIDs[0] > 0 )
341 std::cout <<
" EvtGenProducer terminating ... " << std::endl;
351 if (usePythia) EvtPythia::pythiaInit(0);
375 nPythia = evt->particles_size();
384 for (HepMC::GenEvent::particle_const_iterator
p= evt->particles_begin();
p != evt->particles_end(); ++
p)
386 status = (*p)->status();
391 idHep = (*p)->pdg_id();
393 for(
int i=0;
i<nforced;
i++)
395 if(idHep == forced_Hep[
i])
397 update_candlist(i,*
p);
403 idEvt = EvtPDL::evtIdFromStdHep(idHep);
404 ipart = idEvt.getId();
405 if (ipart==-1)
continue;
406 if (EvtDecayTable::getNMode(ipart)==0)
continue;
407 addToHepMC(*
p,idEvt,evt,
true);
415 int which = (int)(nlist*m_flat->fire());
416 if (which == nlist) which = nlist-1;
418 for(
int k=0;
k < nlist;
k++)
420 if(
k == which || !usePythia) {
421 addToHepMC(listp[
k],forced_Evt[
index[k]],evt,
false);
425 int id_non_alias = forced_Evt[
index[
k]].getId();
426 EvtId non_alias(id_non_alias,id_non_alias);
427 addToHepMC(listp[
k],non_alias,evt,
false);
439 EvtSpinType::spintype stype = EvtPDL::getSpinType(idEvt);
440 EvtParticle* partEvt;
442 case EvtSpinType::SCALAR:
443 partEvt =
new EvtScalarParticle();
446 partEvt =
new EvtStringParticle();
448 case EvtSpinType::DIRAC:
449 partEvt =
new EvtDiracParticle();
451 case EvtSpinType::VECTOR:
452 partEvt =
new EvtVectorParticle();
454 case EvtSpinType::RARITASCHWINGER:
455 partEvt =
new EvtRaritaSchwingerParticle();
457 case EvtSpinType::TENSOR:
458 partEvt =
new EvtTensorParticle();
460 case EvtSpinType::SPIN5HALF:
case EvtSpinType::SPIN3:
case EvtSpinType::SPIN7HALF:
case EvtSpinType::SPIN4:
461 partEvt =
new EvtHighSpinParticle();
464 std::cout <<
"Unknown spintype in EvtSpinType!" << std::endl;
470 HepMC::FourVector momHep = partHep->momentum();
471 momEvt.set(momHep.t(),momHep.x(),momHep.y(),momHep.z());
473 HepMC::GenVertex* initVert = partHep->production_vertex();
474 HepMC::FourVector posHep = initVert->position();
475 posEvt.set(posHep.t(),posHep.x(),posHep.y(),posHep.z());
476 partEvt->init(idEvt,momEvt);
477 partEvt->setDiagonalSpinDensity();
482 if (del_daug) go_through_daughters(partEvt);
485 static EvtStdHep evtstdhep;
488 partEvt->makeStdHep(evtstdhep);
500 partEvt->deleteTree();
505 HepMC::GenVertex* theVerts[200];
506 for (
int ivert = 0; ivert < 200; ivert++) {
510 for (
int ipart = 0; ipart < evtstdhep.getNPart(); ipart++) {
511 int theMum = evtstdhep.getFirstMother(ipart);
512 if (theMum != -1 && !theVerts[theMum]) {
513 EvtVector4R theVpos = evtstdhep.getX4(ipart) + posEvt;
515 new HepMC::GenVertex(HepMC::FourVector(theVpos.get(1),
523 partHep->set_status(2);
524 if (theVerts[0]) theVerts[0]->add_particle_in( partHep );
526 for (
int ipart2 = 1; ipart2 < evtstdhep.getNPart(); ipart2++) {
527 int idHep = evtstdhep.getStdHepID(ipart2);
530 evtstdhep.getP4(ipart2).get(2),
531 evtstdhep.getP4(ipart2).get(3),
532 evtstdhep.getP4(ipart2).get(0)),
534 evtstdhep.getIStat(ipart2));
536 thePart->suggest_barcode(npartial + nPythia);
537 int theMum2 = evtstdhep.getFirstMother(ipart2);
538 if (theMum2 != -1 && theVerts[theMum2]) theVerts[theMum2]->add_particle_out( thePart );
539 if (theVerts[ipart2]) theVerts[ipart2]->add_particle_in( thePart );
543 for (
int ipart3 = 0; ipart3 < evtstdhep.getNPart(); ipart3++) {
544 if (theVerts[ipart3]) theEvent->add_vertex( theVerts[ipart3] );
562 int NDaug=part->getNDaug();
565 EvtParticle* Daughter;
566 for (
int i=0;
i<NDaug;
i++)
568 Daughter=part->getDaug(
i);
569 int idHep = EvtPDL::getStdHep(Daughter->getId());
571 for(
int k=0;
k<nforced;
k++)
573 if(idHep == forced_Hep[
k])
576 Daughter->deleteDaughters();
579 if (!found) go_through_daughters(Daughter);
589 bool isThere =
false;
592 if (listp[
check]->barcode() == thePart->barcode()) isThere =
true;
596 listp[nlist] = thePart;
597 index[nlist++] = theIndex;
603 <<
"more than 10 candidates to be forced ";
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
HepMC::GenEvent * decay(HepMC::GenEvent *)
void addToHepMC(HepMC::GenParticle *partHep, EvtId idEvt, HepMC::GenEvent *theEvent, bool del_daug)
void update_candlist(int theIndex, HepMC::GenParticle *thePart)
static unsigned int getId(void)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void go_through_daughters(EvtParticle *part)
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
EvtGenInterface(const edm::ParameterSet &)
std::string fullPath() const