|
| 1 | +int External() |
| 2 | +{ |
| 3 | + std::string path{"o2sim_Kine.root"}; |
| 4 | + std::vector<int> checkPdgHadron{521}; // Bmeson |
| 5 | + std::vector<int> nucleiDauPdg{1000010020}; // d |
| 6 | + |
| 7 | + TFile file(path.c_str(), "READ"); |
| 8 | + if (file.IsZombie()) |
| 9 | + { |
| 10 | + std::cerr << "Cannot open ROOT file " << path << "\n"; |
| 11 | + return 1; |
| 12 | + } |
| 13 | + |
| 14 | + auto tree = (TTree *)file.Get("o2sim"); |
| 15 | + std::vector<o2::MCTrack> *tracks{}; |
| 16 | + tree->SetBranchAddress("MCTrack", &tracks); |
| 17 | + |
| 18 | + int nSignals{}, nSignalGoodDecay{}; |
| 19 | + auto nEvents = tree->GetEntries(); |
| 20 | + |
| 21 | + for (int i = 0; i < nEvents; i++) |
| 22 | + { |
| 23 | + tree->GetEntry(i); |
| 24 | + for (auto &track : *tracks) |
| 25 | + { |
| 26 | + auto pdg = track.GetPdgCode(); |
| 27 | + if (std::find(checkPdgHadron.begin(), checkPdgHadron.end(), std::abs(pdg)) != checkPdgHadron.end()) // found signal |
| 28 | + { |
| 29 | + // count signal PDG |
| 30 | + if(std::abs(track.GetRapidity()) > 1.5) continue; // skip if outside rapidity window |
| 31 | + nSignals++; |
| 32 | + for (int j{track.getFirstDaughterTrackId()}; j <= track.getLastDaughterTrackId(); ++j) |
| 33 | + { |
| 34 | + auto pdgDau = tracks->at(j).GetPdgCode(); |
| 35 | + if (std::find(nucleiDauPdg.begin(), nucleiDauPdg.end(), std::abs(pdgDau)) != nucleiDauPdg.end()) |
| 36 | + { |
| 37 | + nSignalGoodDecay++; |
| 38 | + } |
| 39 | + } |
| 40 | + } |
| 41 | + } |
| 42 | + } |
| 43 | + std::cout << "--------------------------------\n"; |
| 44 | + std::cout << "# Events: " << nEvents << "\n"; |
| 45 | + std::cout <<"# signal hadrons: " << nSignals << "\n"; |
| 46 | + std::cout <<"# signal hadrons decaying into nuclei: " << nSignalGoodDecay << "\n"; |
| 47 | + |
| 48 | + float fracForcedDecays = nSignals ? float(nSignalGoodDecay) / nSignals : 0.0f; |
| 49 | + float uncFracForcedDecays = nSignals ? std::sqrt(fracForcedDecays * (1 - fracForcedDecays) / nSignals) : 1.0f; |
| 50 | + if (1 - fracForcedDecays > 0.2 + uncFracForcedDecays) // we put some tolerance (lambdaB in MB events do not coalesce) |
| 51 | + { |
| 52 | + std::cerr << "Fraction of signals decaying into nuclei: " << fracForcedDecays << ", lower than expected\n"; |
| 53 | + return 1; |
| 54 | + } |
| 55 | + |
| 56 | + return 0; |
| 57 | +} |
0 commit comments