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>
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();
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);
326 genevent->add_vertex(egammavtx);
328 egammavtx->add_particle_in(
333 event->particles[0].pdgId,
340 event->particles[3].pdgId,
343 egammavtx->add_particle_out(hgamma);
345 egammavtx->add_particle_out(
350 event->particles[2].pdgId,
356 genevent->add_vertex(ppomvtx);
358 ppomvtx->add_particle_in(
363 event->particles[1].pdgId,
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)
385 const Particle &
particle =
event->particles[iParticle];
386 ppomvtx->add_particle_out(
398 ppomvtx->add_particle_out(
403 event->particles[6].pdgId,
410 genevent->add_vertex(gammapomvtx);
412 gammapomvtx->add_particle_in(hgamma);
413 gammapomvtx->add_particle_in(hPomOut);
422 event->particles[4].pdgId,
425 gammapomvtx->add_particle_out(hvm);
431 if (vmDecay1 && vmDecay2)
434 genevent->add_vertex(fvtx);
436 fvtx->add_particle_in(hvm);
438 fvtx->add_particle_out(
445 fvtx->add_particle_out(
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);