4 #include <sartre/Enumerations.h>
5 #include <sartre/Event.h>
6 #include <sartre/EventGeneratorSettings.h>
14 #include <sartre/Sartre.h>
16 #include <TGenPhaseSpace.h>
17 #include <TLorentzVector.h>
18 #include <TParticlePDG.h>
20 #include <CLHEP/Vector/LorentzVector.h>
22 #include <HepMC/GenEvent.h>
23 #include <HepMC/GenParticle.h>
24 #include <HepMC/GenVertex.h>
25 #include <HepMC/PdfInfo.h>
26 #include <HepMC/SimpleVector.h>
27 #include <HepMC/Units.h>
29 #include <gsl/gsl_rng.h>
45 , _registeredTriggers()
54 , daughterMasses{0., 0.}
57 char *charPath = getenv(
"SARTRE_DIR");
60 cout <<
"PHSartre::Could not find $SARTRE_DIR path!" << endl;
86 cerr <<
"Initialization of sartre failed." << endl;
92 cerr <<
"Sartre configuration file must be specified" << endl;
104 decay =
new TGenPhaseSpace();
112 <<
"Will decay vector meson: ";
113 cout <<
"PHSartre: " <<
settings->lookupPDG(
settings->vectorMesonId())->GetName();
127 if (
Verbosity() > 1) cout <<
"PHSartre::End - I'm here!" << endl;
130 <<
" Total cross-section: " <<
_sartre->totalCrossSection() <<
" nb" << endl;
133 cout <<
" *------- Begin PHSARTRE Trigger Statistics ----------------------"
134 <<
"-------------------------------------------------* " << endl;
138 <<
" events passed trigger" << endl;
142 cout <<
" *------- End PHSARTRE Trigger Statistics ------------------------"
143 <<
"-------------------------------------------------* " << endl;
158 bool passedTrigger =
false;
159 Event *
event =
nullptr;
161 TLorentzVector *eIn =
nullptr;
162 TLorentzVector *pIn =
nullptr;
163 TLorentzVector *eOut =
nullptr;
164 TLorentzVector *
gamma =
nullptr;
165 TLorentzVector *vm =
nullptr;
166 TLorentzVector *PomOut =
nullptr;
167 TLorentzVector *pOut =
nullptr;
168 TLorentzVector *vmDecay1 =
nullptr;
169 TLorentzVector *vmDecay2 =
nullptr;
170 unsigned int preVMDecaySize = 0;
172 while (!passedTrigger)
177 event =
_sartre->generateEvent();
200 eIn = &
event->particles[0].p;
201 pIn = &
event->particles[1].p;
202 eOut = &
event->particles[2].p;
203 gamma = &
event->particles[3].p;
204 vm = &
event->particles[4].p;
205 PomOut = &
event->particles[5].p;
206 pOut = &
event->particles[6].p;
210 preVMDecaySize =
event->particles.size();
216 double weight =
decay->Generate();
217 if ((weight - 1) > FLT_EPSILON)
219 cout <<
"PHSartre: Warning decay weight != 1, weight = " << weight << endl;
221 TLorentzVector *vmDaughter1 =
decay->GetDecay(0);
222 TLorentzVector *vmDaughter2 =
decay->GetDecay(1);
224 event->particles[4].status = 2;
227 vmDC1.index =
event->particles.size();
230 vmDC1.
p = *vmDaughter1;
231 vmDC1.parents.push_back(4);
232 event->particles.push_back(vmDC1);
233 vmDecay1 = &
event->particles[
event->particles.size() - 1].
p;
236 vmDC2.index =
event->particles.size();
239 vmDC2.
p = *vmDaughter2;
240 vmDC2.parents.push_back(4);
241 event->particles.push_back(vmDC2);
242 vmDecay2 = &
event->particles[
event->particles.size() - 1].
p;
246 cout <<
"PHSartre: WARNING: Kinematics of Vector Meson does not allow decay!" << endl;
252 bool andScoreKeeper =
true;
264 cout <<
"PHSartre::process_event trigger: "
270 passedTrigger =
true;
275 andScoreKeeper &= trigResult;
280 cout <<
"PHSartre::process_event - failed trigger: "
287 passedTrigger =
true;
293 HepMC::GenEvent *
genevent =
new HepMC::GenEvent(HepMC::Units::GEV, HepMC::Units::MM);
299 HepMC::PdfInfo pdfinfo;
300 pdfinfo.set_scalePDF(event->Q2);
301 genevent->set_pdf_info(pdfinfo);
325 HepMC::GenVertex *egammavtx =
new HepMC::GenVertex(CLHEP::HepLorentzVector(0.0, 0.0, 0.0, 0.0));
326 genevent->add_vertex(egammavtx);
328 egammavtx->add_particle_in(
329 new HepMC::GenParticle(CLHEP::HepLorentzVector(eIn->Px(),
333 event->particles[0].pdgId,
336 HepMC::GenParticle *hgamma =
new HepMC::GenParticle(CLHEP::HepLorentzVector(gamma->Px(),
340 event->particles[3].pdgId,
343 egammavtx->add_particle_out(hgamma);
345 egammavtx->add_particle_out(
346 new HepMC::GenParticle(CLHEP::HepLorentzVector(eOut->Px(),
350 event->particles[2].pdgId,
355 HepMC::GenVertex *ppomvtx =
new HepMC::GenVertex(CLHEP::HepLorentzVector(0.0, 0.0, 0.0, 0.0));
356 genevent->add_vertex(ppomvtx);
358 ppomvtx->add_particle_in(
359 new HepMC::GenParticle(CLHEP::HepLorentzVector(pIn->Px(),
363 event->particles[1].pdgId,
366 HepMC::GenParticle *hPomOut =
new HepMC::GenParticle(CLHEP::HepLorentzVector(PomOut->Px(),
370 event->particles[5].pdgId,
373 ppomvtx->add_particle_out(hPomOut);
379 if (
settings->enableNuclearBreakup() and
event->diffractiveMode == incoherent)
381 for (
unsigned int iParticle = 7; iParticle < preVMDecaySize; iParticle++)
383 if (event->particles[iParticle].status == 1)
386 ppomvtx->add_particle_out(
387 new HepMC::GenParticle(CLHEP::HepLorentzVector(particle.
p.Px(),
398 ppomvtx->add_particle_out(
399 new HepMC::GenParticle(CLHEP::HepLorentzVector(pOut->Px(),
403 event->particles[6].pdgId,
409 HepMC::GenVertex *gammapomvtx =
new HepMC::GenVertex(CLHEP::HepLorentzVector(0.0, 0.0, 0.0, 0.0));
410 genevent->add_vertex(gammapomvtx);
412 gammapomvtx->add_particle_in(hgamma);
413 gammapomvtx->add_particle_in(hPomOut);
418 HepMC::GenParticle *hvm =
new HepMC::GenParticle(CLHEP::HepLorentzVector(vm->Px(),
422 event->particles[4].pdgId,
425 gammapomvtx->add_particle_out(hvm);
431 if (vmDecay1 && vmDecay2)
433 HepMC::GenVertex *fvtx =
new HepMC::GenVertex(CLHEP::HepLorentzVector(0.0, 0.0, 0.0, 0.0));
434 genevent->add_vertex(fvtx);
436 fvtx->add_particle_in(hvm);
438 fvtx->add_particle_out(
439 new HepMC::GenParticle(CLHEP::HepLorentzVector(vmDecay1->Px(),
445 fvtx->add_particle_out(
446 new HepMC::GenParticle(CLHEP::HepLorentzVector(vmDecay2->Px(),
455 cout <<
"PHSartre: WARNING: Kinematics of Vector Meson does not allow decay!" << endl;
464 cout <<
"PHSartre::process_event - Failed to add event to HepMC record!" << endl;
470 if (
Verbosity() > 2) cout <<
"PHSartre::process_event - FINISHED WHOLE EVENT" << endl;
485 if (
Verbosity() > 1) cout <<
"PHSartre::registerTrigger - trigger " << theTrigger->
GetName() <<
" registered" << endl;
494 for (
unsigned int i = 0; i < myEvent->particles.size(); i++)
495 myEvent->particles.at(i).p.RotateX(
M_PI);
506 for (
unsigned int i = 0; i < myEvent->particles.size(); i++)
507 myEvent->particles.at(i).p.RotateX(
M_PI);