Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#---> GeneratorLF_Strangeness_ppLStar
[GeneratorExternal]
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_Lstar.C
funcName=generator_Lstar(3)

[GeneratorPythia8]
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_forceLStar.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#---> GeneratorLF_Strangeness_ppLStar
[GeneratorExternal]
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_Lstar.C
funcName=generator_Lstar(4)

[GeneratorPythia8]
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator/pythia8_inel_forceLStar.cfg
56 changes: 35 additions & 21 deletions MC/config/PWGLF/ini/tests/GeneratorLF_Strangeness_ppLStar.C
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
int External()
{
std::string path{"o2sim_Kine.root"};
const int pdgMother = 3124; // Lambda(1520)0
const int triggerRatio = 5; // must match generator_Lstar(N) in the .ini file
const int pdgMother = 3124; // Lambda(1520)0

TFile file(path.c_str(), "READ");
if (file.IsZombie()) {
Expand All @@ -20,19 +19,12 @@ int External()
const auto nEvents = tree->GetEntries();
int nMother = 0;
int nNotDecayed = 0;
int nBadDecay = 0; // mothers not decaying exactly to Lambda + gamma
int nEventsWrongCount = 0; // events with the wrong number of injected mothers
int nGapEvents = 0; // events expected to contain the injected mother
int nBadDecay = 0; // mothers not decaying exactly to Lambda + gamma
std::vector<int> motherPerEvent; // number of injected mothers in each event

for (int i = 0; i < nEvents; i++) {
tree->GetEntry(i);

// the generator injects in every triggerRatio-th event (it counts events from 1)
const bool isGapEvent = ((i + 1) % triggerRatio == 0);
if (isGapEvent) {
nGapEvents++;
}

int nInEvent = 0;
for (auto &track : *tracks) {
const int pdg = track.GetPdgCode();
Expand All @@ -59,30 +51,52 @@ int External()
std::cerr << "Unexpected decay of " << pdg << " (" << nDau << " daughters)\n";
}
}
motherPerEvent.push_back(nInEvent);
}

const int nExpected = isGapEvent ? 1 : 0;
if (nInEvent != nExpected) {
nEventsWrongCount++;
std::cerr << "Event " << i << ": found " << nInEvent
<< " Lambda(1520), expected " << nExpected << "\n";
// the trigger ratio is inferred from the first event containing a mother
// (the generator counts events from 1 and injects every triggerRatio-th event)
int triggerRatio = 0;
for (int i = 0; i < nEvents; i++) {
if (motherPerEvent[i] > 0) {
triggerRatio = i + 1;
break;
}
}

int nEventsWrongCount = 0;
int nGapEvents = 0;
if (triggerRatio > 0) {
for (int i = 0; i < nEvents; i++) {
const bool isGapEvent = ((i + 1) % triggerRatio == 0);
if (isGapEvent) {
nGapEvents++;
}
const int nExpected = isGapEvent ? 1 : 0;
if (motherPerEvent[i] != nExpected) {
nEventsWrongCount++;
std::cerr << "Event " << i << ": found " << motherPerEvent[i]
<< " Lambda(1520), expected " << nExpected << "\n";
}
}
}

std::cout << "--------------------------------\n";
std::cout << "# Events: " << nEvents << "\n";
std::cout << "# Gap-trigger events: " << nGapEvents << " (ratio " << triggerRatio << ")\n";
std::cout << "# Inferred trigger ratio: " << triggerRatio << "\n";
std::cout << "# Gap-trigger events: " << nGapEvents << "\n";
std::cout << "# Lambda(1520) + anti: " << nMother << "\n";
std::cout << "# not decayed: " << nNotDecayed << "\n";
std::cout << "# unexpected decays: " << nBadDecay << "\n";
std::cout << "# events wrong count: " << nEventsWrongCount << "\n";
std::cout << "--------------------------------\n";

if (nMother != nGapEvents) {
std::cerr << "Expected one injected Lambda(1520) per gap-trigger event\n";
if (triggerRatio == 0) {
std::cerr << "No Lambda(1520) found in any event\n";
return 1;
}
if (nEventsWrongCount > 0) {
std::cerr << "Lambda(1520) must appear in every gap-triggered events\n";
if (nMother != nGapEvents || nEventsWrongCount > 0) {
std::cerr << "Lambda(1520) must appear exactly once every triggerRatio events\n";
return 1;
}
if (nNotDecayed > 0 || nBadDecay > 0) {
Expand Down
11 changes: 7 additions & 4 deletions MC/config/PWGLF/pythia8/generator_pythia8_Lstar.C
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#include "Framework/Logger.h"

#if !defined(__CLING__) || defined(__ROOTCLING__)

#include "Pythia8/Pythia.h"
#include "Pythia8/HeavyIons.h"
#include "FairGenerator.h"
#include "FairPrimaryGenerator.h"
#include "Generators/GeneratorPythia8.h"
#include "TF1.h"
#include "TRandom3.h"
//#include "TParticlePDG.h"
//#include "TDatabasePDG.h"

#include <map>
#include <unordered_set>

#endif

class GeneratorPythia8ExtraStrangeness : public o2::eventgen::GeneratorPythia8
{
public:
Expand Down Expand Up @@ -268,4 +271,4 @@ private:
{
auto myGen = new GeneratorPythia8ExtraStrangeness(3124, inputTriggerRatio);
return myGen;
}
}
Loading