forked from AliceO2Group/O2DPG
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneratorSigmaProtonTriggered.C
More file actions
49 lines (38 loc) · 1.06 KB
/
GeneratorSigmaProtonTriggered.C
File metadata and controls
49 lines (38 loc) · 1.06 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
int External()
{
std::string path{"o2sim_Kine.root"};
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");
if (!tree) {
std::cerr << "Cannot find tree o2sim in file " << path << "\n";
return 1;
}
std::vector<o2::MCTrack>* tracks = nullptr;
tree->SetBranchAddress("MCTrack", &tracks);
const auto nEvents = tree->GetEntries();
for (Long64_t iEv = 0; iEv < nEvents; ++iEv) {
tree->GetEntry(iEv);
bool hasSigma = false;
bool hasProton = false;
for (const auto& track : *tracks) {
const int pdg = track.GetPdgCode();
const int absPdg = std::abs(pdg);
if (absPdg == 3112 || absPdg == 3222) {
hasSigma = true;
}
if (pdg == 2212) {
hasProton = true;
}
if (hasSigma && hasProton) {
std::cout << "Found event of interest at entry " << iEv << "\n";
return 0;
}
}
}
std::cerr << "No Sigma-proton event of interest\n";
return 1;
}