Skip to content

Commit 8a545bf

Browse files
lbarioglgconesab
authored andcommitted
Add generator for hypernuclei
1 parent d8b1e40 commit 8a545bf

3 files changed

Lines changed: 63 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[GeneratorExternal]
2+
fileName=${O2DPG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_longlived_gaptriggered.C
3+
funcName=generateLongLivedGapTriggered("${O2DPG_ROOT}/MC/config/PWGLF/pythia8/generator/hyper.gun", 5)
4+
5+
[GeneratorPythia8]
6+
config=${O2_ROOT}/share/Generators/egconfig/pythia8_inel.cfg
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
int External()
2+
{
3+
std::string path{"o2sim_Kine.root"};
4+
std::vector<int> possiblePDGs = {1010010030, -1010010030,
5+
1010010040, -1010010040};
6+
7+
int nPossiblePDGs = possiblePDGs.size();
8+
9+
TFile file(path.c_str(), "READ");
10+
if (file.IsZombie())
11+
{
12+
std::cerr << "Cannot open ROOT file " << path << "\n";
13+
return 1;
14+
}
15+
16+
auto tree = (TTree *)file.Get("o2sim");
17+
if (!tree)
18+
{
19+
std::cerr << "Cannot find tree o2sim in file " << path << "\n";
20+
return 1;
21+
}
22+
std::vector<o2::MCTrack> *tracks{};
23+
tree->SetBranchAddress("MCTrack", &tracks);
24+
25+
std::vector<int> injectedPDGs;
26+
27+
auto nEvents = tree->GetEntries();
28+
for (int i = 0; i < nEvents; i++)
29+
{
30+
auto check = tree->GetEntry(i);
31+
for (int idxMCTrack = 0; idxMCTrack < tracks->size(); ++idxMCTrack)
32+
{
33+
auto track = tracks->at(idxMCTrack);
34+
auto pdg = track.GetPdgCode();
35+
auto it = std::find(possiblePDGs.begin(), possiblePDGs.end(), pdg);
36+
if (it != possiblePDGs.end() && track.isPrimary()) // found
37+
{
38+
injectedPDGs.push_back(pdg);
39+
}
40+
}
41+
}
42+
std::cout << "--------------------------------\n";
43+
std::cout << "# Events: " << nEvents << "\n";
44+
if(injectedPDGs.empty()){
45+
std::cerr << "No injected particles\n";
46+
return 1; // At least one of the injected particles should be generated
47+
}
48+
for (int i = 0; i < nPossiblePDGs; i++)
49+
{
50+
std::cout << "# Injected nuclei \n";
51+
std::cout << possiblePDGs[i] << ": " << std::count(injectedPDGs.begin(), injectedPDGs.end(), possiblePDGs[i]) << "\n";
52+
}
53+
return 0;
54+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# PDG N ptMin ptMax yMin yMax
2+
1010010030 1 0.2 6 -1 1
3+
1010010040 1 0.2 6 -1 1

0 commit comments

Comments
 (0)