forked from AliceO2Group/O2DPG
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneratorHFTrigger_LambdaBToNuclei.C
More file actions
57 lines (51 loc) · 2.16 KB
/
GeneratorHFTrigger_LambdaBToNuclei.C
File metadata and controls
57 lines (51 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
int External()
{
std::string path{"o2sim_Kine.root"};
std::vector<int> checkPdgHadron{5122}; // Lambda_b
std::vector<int> nucleiDauPdg{1000020030, 1000010030}; // 3He, 3H
TFile file(path.c_str(), "READ");
if (file.IsZombie())
{
std::cerr << "Cannot open ROOT file " << path << "\n";
return 1;
}
auto tree = (TTree *)file.Get("o2sim");
std::vector<o2::MCTrack> *tracks{};
tree->SetBranchAddress("MCTrack", &tracks);
int nSignals{}, nSignalGoodDecay{};
auto nEvents = tree->GetEntries();
for (int i = 0; i < nEvents; i++)
{
tree->GetEntry(i);
for (auto &track : *tracks)
{
auto pdg = track.GetPdgCode();
if (std::find(checkPdgHadron.begin(), checkPdgHadron.end(), std::abs(pdg)) != checkPdgHadron.end()) // found signal
{
// count signal PDG
if(std::abs(track.GetRapidity()) > 1.5) continue; // skip if outside rapidity window
nSignals++;
for (int j{track.getFirstDaughterTrackId()}; j <= track.getLastDaughterTrackId(); ++j)
{
auto pdgDau = tracks->at(j).GetPdgCode();
if (std::find(nucleiDauPdg.begin(), nucleiDauPdg.end(), std::abs(pdgDau)) != nucleiDauPdg.end())
{
nSignalGoodDecay++;
}
}
}
}
}
std::cout << "--------------------------------\n";
std::cout << "# Events: " << nEvents << "\n";
std::cout <<"# signal hadrons: " << nSignals << "\n";
std::cout <<"# signal hadrons decaying into nuclei: " << nSignalGoodDecay << "\n";
float fracForcedDecays = nSignals ? float(nSignalGoodDecay) / nSignals : 0.0f;
float uncFracForcedDecays = nSignals ? std::sqrt(fracForcedDecays * (1 - fracForcedDecays) / nSignals) : 1.0f;
if (1 - fracForcedDecays > 0.2 + uncFracForcedDecays) // we put some tolerance (lambdaB in MB events do not coalesce)
{
std::cerr << "Fraction of signals decaying into nuclei: " << fracForcedDecays << ", lower than expected\n";
return 1;
}
return 0;
}