16 #include "CLHEP/Random/Random.h"
17 #include "CLHEP/Random/RandFlat.h"
19 #include "EvtGen/EvtGen.hh"
20 #include "EvtGenBase/EvtId.hh"
21 #include "EvtGenBase/EvtPDL.hh"
22 #include "EvtGenBase/EvtDecayTable.hh"
23 #include "EvtGenBase/EvtSpinType.hh"
24 #include "EvtGenBase/EvtVector4R.hh"
25 #include "EvtGenBase/EvtParticle.hh"
26 #include "EvtGenBase/EvtScalarParticle.hh"
27 #include "EvtGenBase/EvtStringParticle.hh"
28 #include "EvtGenBase/EvtDiracParticle.hh"
29 #include "EvtGenBase/EvtVectorParticle.hh"
30 #include "EvtGenBase/EvtRaritaSchwingerParticle.hh"
31 #include "EvtGenBase/EvtTensorParticle.hh"
32 #include "EvtGenBase/EvtHighSpinParticle.hh"
33 #include "EvtGenBase/EvtStdHep.hh"
34 #include "EvtGenBase/EvtSecondary.hh"
35 #include "EvtGenModels/EvtPythia.hh"
40 #include "HepMC/GenEvent.h"
44 namespace PhotosRandomVar {
75 std::cout <<
" EvtGenProducer starting ... " << std::endl;
85 <<
"The EvtGenProducer module requires the RandomNumberGeneratorService\n"
86 "which is not present in the configuration file. You must add the service\n"
87 "in the configuration file if you want to run EvtGenProducer";
90 CLHEP::HepRandomEngine& m_engine = rngen->
getEngine();
91 m_flat =
new CLHEP::RandFlat(m_engine, 0., 1.);
102 std::vector<double>());
103 if (polarize_ids.size() != polarize_pol.size()) {
105 <<
"EvtGenProducer requires that the particles_to_polarize and particle_polarization\n"
106 "vectors be the same size. Please fix this in your configuration.";
108 for (
unsigned int ndx = 0; ndx < polarize_ids.size(); ndx++) {
109 if (polarize_pol[ndx] < -1. || polarize_pol[ndx] > 1.) {
111 <<
"EvtGenProducer error: particle polarizations must be in the range -1 < P < 1";
113 polarizations.insert(std::pair<int, float>(polarize_ids[ndx], polarize_pol[ndx]));
117 std::string decay_table_s = decay_table.
fullPath();
118 std::string pdt_s = pdt.fullPath();
119 std::string user_decay_s = user_decay.
fullPath();
125 std::vector<std::string> forced_names = pset.
getParameter< std::vector<std::string> >(
"list_forced_decays");
127 m_EvtGen =
new EvtGen (decay_table_s.c_str(),pdt_s.c_str(),the_engine);
130 if (!useDefault) m_EvtGen->readUDecay( user_decay_s.c_str() );
132 std::vector<std::string>::const_iterator
i;
135 for (i=forced_names.begin(); i!=forced_names.end(); ++
i)
141 if (found.getId()==-1)
144 <<
"name in part list for forced decays not found: " << *
i;
146 if (found.getId()==found.getAlias())
149 <<
"name in part list for forced decays is not an alias: " << *
i;
151 forced_Evt.push_back(found);
152 forced_Hep.push_back(EvtPDL::getStdHep(found));
161 m_PDGs.push_back( 300553 ) ;
162 m_PDGs.push_back( 511 ) ;
163 m_PDGs.push_back( 521 ) ;
164 m_PDGs.push_back( 523 ) ;
165 m_PDGs.push_back( 513 ) ;
166 m_PDGs.push_back( 533 ) ;
167 m_PDGs.push_back( 531 ) ;
169 m_PDGs.push_back( 15 ) ;
171 m_PDGs.push_back( 413 ) ;
172 m_PDGs.push_back( 423 ) ;
173 m_PDGs.push_back( 433 ) ;
174 m_PDGs.push_back( 411 ) ;
175 m_PDGs.push_back( 421 ) ;
176 m_PDGs.push_back( 431 ) ;
177 m_PDGs.push_back( 10411 );
178 m_PDGs.push_back( 10421 );
179 m_PDGs.push_back( 10413 );
180 m_PDGs.push_back( 10423 );
181 m_PDGs.push_back( 20413 );
182 m_PDGs.push_back( 20423 );
184 m_PDGs.push_back( 415 );
185 m_PDGs.push_back( 425 );
186 m_PDGs.push_back( 10431 );
187 m_PDGs.push_back( 20433 );
188 m_PDGs.push_back( 10433 );
189 m_PDGs.push_back( 435 );
191 m_PDGs.push_back( 310 );
192 m_PDGs.push_back( 311 );
193 m_PDGs.push_back( 313 );
194 m_PDGs.push_back( 323 );
195 m_PDGs.push_back( 10321 );
196 m_PDGs.push_back( 10311 );
197 m_PDGs.push_back( 10313 );
198 m_PDGs.push_back( 10323 );
199 m_PDGs.push_back( 20323 );
200 m_PDGs.push_back( 20313 );
201 m_PDGs.push_back( 325 );
202 m_PDGs.push_back( 315 );
204 m_PDGs.push_back( 100313 );
205 m_PDGs.push_back( 100323 );
206 m_PDGs.push_back( 30313 );
207 m_PDGs.push_back( 30323 );
208 m_PDGs.push_back( 30343 );
209 m_PDGs.push_back( 30353 );
210 m_PDGs.push_back( 30363 );
212 m_PDGs.push_back( 111 );
213 m_PDGs.push_back( 221 );
214 m_PDGs.push_back( 113 );
215 m_PDGs.push_back( 213 );
216 m_PDGs.push_back( 223 );
217 m_PDGs.push_back( 331 );
218 m_PDGs.push_back( 333 );
219 m_PDGs.push_back( 20213 );
220 m_PDGs.push_back( 20113 );
221 m_PDGs.push_back( 215 );
222 m_PDGs.push_back( 115 );
223 m_PDGs.push_back( 10213 );
224 m_PDGs.push_back( 10113 );
225 m_PDGs.push_back( 9000111 );
226 m_PDGs.push_back( 9000211 );
227 m_PDGs.push_back( 9010221 );
228 m_PDGs.push_back( 10221 );
229 m_PDGs.push_back( 20223 );
230 m_PDGs.push_back( 20333 );
231 m_PDGs.push_back( 225 );
232 m_PDGs.push_back( 9020221 );
233 m_PDGs.push_back( 335 );
234 m_PDGs.push_back( 10223 );
235 m_PDGs.push_back( 10333 );
236 m_PDGs.push_back( 100213 );
237 m_PDGs.push_back( 100113 );
239 m_PDGs.push_back( 441 );
240 m_PDGs.push_back( 100441 );
241 m_PDGs.push_back( 443 );
242 m_PDGs.push_back( 100443 );
243 m_PDGs.push_back( 9000443 );
244 m_PDGs.push_back( 9010443 );
245 m_PDGs.push_back( 9020443 );
246 m_PDGs.push_back( 10441 );
247 m_PDGs.push_back( 20443 );
248 m_PDGs.push_back( 445 );
250 m_PDGs.push_back( 30443 );
251 m_PDGs.push_back( 551 );
252 m_PDGs.push_back( 553 );
253 m_PDGs.push_back( 100553 );
254 m_PDGs.push_back( 200553 );
255 m_PDGs.push_back( 10551 );
256 m_PDGs.push_back( 20553 );
257 m_PDGs.push_back( 555 );
258 m_PDGs.push_back( 10553 );
260 m_PDGs.push_back( 110551 );
261 m_PDGs.push_back( 120553 );
262 m_PDGs.push_back( 100555 );
263 m_PDGs.push_back( 210551 );
264 m_PDGs.push_back( 220553 );
265 m_PDGs.push_back( 200555 );
266 m_PDGs.push_back( 30553 );
267 m_PDGs.push_back( 20555 );
269 m_PDGs.push_back( 557 );
270 m_PDGs.push_back( 130553 );
271 m_PDGs.push_back( 120555 );
272 m_PDGs.push_back( 100557 );
273 m_PDGs.push_back( 110553 );
274 m_PDGs.push_back( 210553 );
275 m_PDGs.push_back( 10555 );
276 m_PDGs.push_back( 110555 );
278 m_PDGs.push_back( 4122 );
279 m_PDGs.push_back( 4132 );
281 m_PDGs.push_back( 4112 );
282 m_PDGs.push_back( 4212 );
283 m_PDGs.push_back( 4232 );
284 m_PDGs.push_back( 4222 );
285 m_PDGs.push_back( 4322 );
286 m_PDGs.push_back( 4312 );
288 m_PDGs.push_back( 13122 );
289 m_PDGs.push_back( 13124 );
290 m_PDGs.push_back( 23122 );
291 m_PDGs.push_back( 33122 );
292 m_PDGs.push_back( 43122 );
293 m_PDGs.push_back( 53122 );
294 m_PDGs.push_back( 13126 );
295 m_PDGs.push_back( 13212 );
296 m_PDGs.push_back( 13241 );
298 m_PDGs.push_back( 3126 );
299 m_PDGs.push_back( 3124 );
300 m_PDGs.push_back( 3122 );
301 m_PDGs.push_back( 3222 );
302 m_PDGs.push_back( 2214 );
303 m_PDGs.push_back( 2224 );
304 m_PDGs.push_back( 3324 );
305 m_PDGs.push_back( 2114 );
306 m_PDGs.push_back( 1114 );
307 m_PDGs.push_back( 3112 );
308 m_PDGs.push_back( 3212 );
309 m_PDGs.push_back( 3114 );
310 m_PDGs.push_back( 3224 );
311 m_PDGs.push_back( 3214 );
312 m_PDGs.push_back( 3216 );
313 m_PDGs.push_back( 3322 );
314 m_PDGs.push_back( 3312 );
315 m_PDGs.push_back( 3314 );
316 m_PDGs.push_back( 3334 );
318 m_PDGs.push_back( 4114 );
319 m_PDGs.push_back( 4214 );
320 m_PDGs.push_back( 4224 );
321 m_PDGs.push_back( 4314 );
322 m_PDGs.push_back( 4324 );
323 m_PDGs.push_back( 4332 );
324 m_PDGs.push_back( 4334 );
327 m_PDGs.push_back( 10443 );
329 m_PDGs.push_back( 5122 );
330 m_PDGs.push_back( 5132 );
331 m_PDGs.push_back( 5232 );
332 m_PDGs.push_back( 5332 );
333 m_PDGs.push_back( 5222 );
334 m_PDGs.push_back( 5112 );
335 m_PDGs.push_back( 5212 );
336 m_PDGs.push_back( 541 );
337 m_PDGs.push_back( 14122 );
338 m_PDGs.push_back( 14124 );
339 m_PDGs.push_back( 5312 );
340 m_PDGs.push_back( 5322 );
341 m_PDGs.push_back( 10521 );
342 m_PDGs.push_back( 20523 );
343 m_PDGs.push_back( 10523 );
345 m_PDGs.push_back( 525 );
346 m_PDGs.push_back( 10511 );
347 m_PDGs.push_back( 20513 );
348 m_PDGs.push_back( 10513 );
349 m_PDGs.push_back( 515 );
350 m_PDGs.push_back( 10531 );
351 m_PDGs.push_back( 20533 );
352 m_PDGs.push_back( 10533 );
353 m_PDGs.push_back( 535 );
354 m_PDGs.push_back( 543 );
355 m_PDGs.push_back( 545 );
356 m_PDGs.push_back( 5114 );
357 m_PDGs.push_back( 5224 );
358 m_PDGs.push_back( 5214 );
359 m_PDGs.push_back( 5314 );
360 m_PDGs.push_back( 5324 );
361 m_PDGs.push_back( 5334 );
362 m_PDGs.push_back( 10541 );
363 m_PDGs.push_back( 10543 );
364 m_PDGs.push_back( 20543 );
366 m_PDGs.push_back( 4424 );
367 m_PDGs.push_back( 4422 );
368 m_PDGs.push_back( 4414 );
369 m_PDGs.push_back( 4412 );
370 m_PDGs.push_back( 4432 );
371 m_PDGs.push_back( 4434 );
373 m_PDGs.push_back( 130 );
376 if ( pset.
exists(
"operates_on_particles") )
378 std::vector<int> tmpPIDs = pset.
getParameter< std::vector<int> >(
"operates_on_particles");
379 if ( tmpPIDs.size() > 0 )
381 if ( tmpPIDs[0] > 0 )
394 std::cout <<
" EvtGenProducer terminating ... " << std::endl;
409 if (usePythia) EvtPythia::pythiaInit(0);
433 nPythia = evt->particles_size();
442 for (HepMC::GenEvent::particle_const_iterator
p= evt->particles_begin();
p != evt->particles_end(); ++
p)
444 status = (*p)->status();
449 idHep = (*p)->pdg_id();
451 for(
int i=0;
i<nforced;
i++)
453 if(idHep == forced_Hep[
i])
455 update_candlist(i,*
p);
461 idEvt = EvtPDL::evtIdFromStdHep(idHep);
462 ipart = idEvt.getId();
463 if (ipart==-1)
continue;
464 if (EvtDecayTable::getNMode(ipart)==0)
continue;
465 addToHepMC(*
p,idEvt,evt,
true);
473 int which = (int)(nlist*m_flat->fire());
474 if (which == nlist) which = nlist-1;
476 for(
int k=0;
k < nlist;
k++)
478 if(
k == which || !usePythia) {
479 addToHepMC(listp[
k],forced_Evt[
index[k]],evt,
false);
483 int id_non_alias = forced_Evt[
index[
k]].getId();
484 EvtId non_alias(id_non_alias,id_non_alias);
485 addToHepMC(listp[
k],non_alias,evt,
false);
497 EvtSpinType::spintype stype = EvtPDL::getSpinType(idEvt);
498 EvtParticle* partEvt;
500 case EvtSpinType::SCALAR:
501 partEvt =
new EvtScalarParticle();
504 partEvt =
new EvtStringParticle();
506 case EvtSpinType::DIRAC:
507 partEvt =
new EvtDiracParticle();
509 case EvtSpinType::VECTOR:
510 partEvt =
new EvtVectorParticle();
512 case EvtSpinType::RARITASCHWINGER:
513 partEvt =
new EvtRaritaSchwingerParticle();
515 case EvtSpinType::TENSOR:
516 partEvt =
new EvtTensorParticle();
518 case EvtSpinType::SPIN5HALF:
case EvtSpinType::SPIN3:
case EvtSpinType::SPIN7HALF:
case EvtSpinType::SPIN4:
519 partEvt =
new EvtHighSpinParticle();
522 std::cout <<
"Unknown spintype in EvtSpinType!" << std::endl;
528 HepMC::FourVector momHep = partHep->momentum();
529 momEvt.set(momHep.t(),momHep.x(),momHep.y(),momHep.z());
531 HepMC::GenVertex* initVert = partHep->production_vertex();
532 HepMC::FourVector posHep = initVert->position();
533 posEvt.set(posHep.t(),posHep.x(),posHep.y(),posHep.z());
534 partEvt->init(idEvt,momEvt);
535 if (stype == EvtSpinType::DIRAC
536 && polarizations.find(partHep->pdg_id()) != polarizations.end()) {
541 float pol = polarizations.find(partHep->pdg_id())->
second;
550 EvtSpinDensity theSpinDensity;
551 theSpinDensity.SetDim(2);
552 theSpinDensity.Set(0, 0, EvtComplex(1./2. + polVec.
z()/2., 0.));
553 theSpinDensity.Set(0, 1, EvtComplex(polVec.
x()/2., -polVec.
y()/2.));
554 theSpinDensity.Set(1, 0, EvtComplex(polVec.
x()/2., polVec.
y()/2.));
555 theSpinDensity.Set(1, 1, EvtComplex(1./2. - polVec.
z()/2., 0.));
557 partEvt->setSpinDensityForwardHelicityBasis(theSpinDensity);
560 partEvt->setDiagonalSpinDensity();
566 if (del_daug) go_through_daughters(partEvt);
569 static EvtStdHep evtstdhep;
572 partEvt->makeStdHep(evtstdhep);
575 partEvt->deleteTree();
580 HepMC::GenVertex* theVerts[200];
581 for (
int ivert = 0; ivert < 200; ivert++) {
585 for (
int ipart = 0; ipart < evtstdhep.getNPart(); ipart++) {
586 int theMum = evtstdhep.getFirstMother(ipart);
587 if (theMum != -1 && !theVerts[theMum]) {
588 EvtVector4R theVpos = evtstdhep.getX4(ipart) + posEvt;
590 new HepMC::GenVertex(HepMC::FourVector(theVpos.get(1),
598 partHep->set_status(2);
599 if (theVerts[0]) theVerts[0]->add_particle_in( partHep );
601 for (
int ipart2 = 1; ipart2 < evtstdhep.getNPart(); ipart2++) {
602 int idHep = evtstdhep.getStdHepID(ipart2);
605 evtstdhep.getP4(ipart2).get(2),
606 evtstdhep.getP4(ipart2).get(3),
607 evtstdhep.getP4(ipart2).get(0)),
609 evtstdhep.getIStat(ipart2));
611 thePart->suggest_barcode(npartial + nPythia);
612 int theMum2 = evtstdhep.getFirstMother(ipart2);
613 if (theMum2 != -1 && theVerts[theMum2]) theVerts[theMum2]->add_particle_out( thePart );
614 if (theVerts[ipart2]) theVerts[ipart2]->add_particle_in( thePart );
618 for (
int ipart3 = 0; ipart3 < evtstdhep.getNPart(); ipart3++) {
619 if (theVerts[ipart3]) theEvent->add_vertex( theVerts[ipart3] );
637 int NDaug=part->getNDaug();
640 EvtParticle* Daughter;
641 for (
int i=0;
i<NDaug;
i++)
643 Daughter=part->getDaug(
i);
644 int idHep = EvtPDL::getStdHep(Daughter->getId());
646 for(
int k=0;
k<nforced;
k++)
648 if(idHep == forced_Hep[
k])
651 Daughter->deleteDaughters();
654 if (!found) go_through_daughters(Daughter);
664 bool isThere =
false;
667 if (listp[
check]->barcode() == thePart->barcode()) isThere =
true;
671 listp[nlist] = thePart;
672 index[nlist++] = theIndex;
678 <<
"more than 10 candidates to be forced ";
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
CLHEP::HepRandomEngine * decayRandomEngine
void addToHepMC(HepMC::GenParticle *partHep, EvtId idEvt, HepMC::GenEvent *theEvent, bool del_daug)
void update_candlist(int theIndex, HepMC::GenParticle *thePart)
double phoran_(int *idummy)
static unsigned int getId(void)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void go_through_daughters(EvtParticle *part)
CLHEP::HepRandomEngine * decayRandomEngine
U second(std::pair< T, U > const &p)
void SetPhotosDecayRandomEngine(CLHEP::HepRandomEngine *decayRandomEngine)
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
Vector3DBase unit() const
EvtGenInterface(const edm::ParameterSet &)
std::string fullPath() const
HepMC::GenEvent * decay(HepMC::GenEvent *evt)