|
| 1 | +int External() |
| 2 | +{ |
| 3 | + int checkPdgDecay = 13; |
| 4 | + std::string path{"o2sim_Kine.root"}; |
| 5 | + TFile file(path.c_str(), "READ"); |
| 6 | + if (file.IsZombie()) { |
| 7 | + std::cerr << "Cannot open ROOT file " << path << "\n"; |
| 8 | + return 1; |
| 9 | + } |
| 10 | + auto tree = (TTree*)file.Get("o2sim"); |
| 11 | + std::vector<o2::MCTrack>* tracks{}; |
| 12 | + tree->SetBranchAddress("MCTrack", &tracks); |
| 13 | + |
| 14 | + int nLeptons{}; |
| 15 | + int nLeptonsInAcceptance{}; |
| 16 | + int nLeptonsToBeDone{}; |
| 17 | + int nSignalPairs{}; |
| 18 | + int nLeptonPairs{}; |
| 19 | + int nLeptonPairsInAcceptance{}; |
| 20 | + int nLeptonPairsToBeDone{}; |
| 21 | + auto nEvents = tree->GetEntries(); |
| 22 | + |
| 23 | + for (int i = 0; i < nEvents; i++) { |
| 24 | + tree->GetEntry(i); |
| 25 | + int nleptonseinacc = 0; |
| 26 | + int nleptonse = 0; |
| 27 | + int nleptonseToBeDone = 0; |
| 28 | + int nopenHeavy = 0; |
| 29 | + for (auto& track : *tracks) { |
| 30 | + auto pdg = track.GetPdgCode(); |
| 31 | + auto y = track.GetRapidity(); |
| 32 | + if (std::abs(pdg) == checkPdgDecay) { |
| 33 | + int igmother = track.getMotherTrackId(); |
| 34 | + if (igmother > 0) { |
| 35 | + auto gmTrack = (*tracks)[igmother]; |
| 36 | + int gmpdg = gmTrack.GetPdgCode(); |
| 37 | + if ( int(std::abs(gmpdg)/100.) == 4 || int(std::abs(gmpdg)/1000.) == 4 || int(std::abs(gmpdg)/100.) == 5 || int(std::abs(gmpdg)/1000.) == 5 ) { |
| 38 | + nLeptons++; |
| 39 | + nleptonse++; |
| 40 | + if (-4.3 < y && y < -2.2) { |
| 41 | + nleptonseinacc++; |
| 42 | + nLeptonsInAcceptance++; |
| 43 | + } |
| 44 | + if (track.getToBeDone()) { |
| 45 | + nLeptonsToBeDone++; |
| 46 | + nleptonseToBeDone++; |
| 47 | + } |
| 48 | + } |
| 49 | + } |
| 50 | + } else if (std::abs(pdg) == 411 || std::abs(pdg) == 421 || std::abs(pdg) == 431 || std::abs(pdg) == 4122 || std::abs(pdg) == 4132 || std::abs(pdg) == 4232 || std::abs(pdg) == 4332) { |
| 51 | + nopenHeavy++; |
| 52 | + } |
| 53 | + } |
| 54 | + if (nopenHeavy > 1) nSignalPairs++; |
| 55 | + if (nleptonse > 1) nLeptonPairs++; |
| 56 | + if (nleptonseToBeDone > 1) nLeptonPairsToBeDone++; |
| 57 | + if (nleptonseinacc > 1) nLeptonPairsInAcceptance++; |
| 58 | + } |
| 59 | + std::cout << "#events: " << nEvents << "\n" |
| 60 | + << "#muons in acceptance: " << nLeptonsInAcceptance << "\n" |
| 61 | + << "#muon pairs in acceptance: " << nLeptonPairsInAcceptance << "\n" |
| 62 | + << "#muons: " << nLeptons << "\n" |
| 63 | + << "#muons to be done: " << nLeptonsToBeDone << "\n" |
| 64 | + << "#signal pairs: " << nSignalPairs << "\n" |
| 65 | + << "#muon pairs: " << nLeptonPairs << "\n" |
| 66 | + << "#muon pairs to be done: " << nLeptonPairsToBeDone << "\n"; |
| 67 | + if (nLeptonPairs != nLeptonPairsToBeDone) { |
| 68 | + std::cerr << "The number of muon pairs should be the same as the number of muon pairs which should be transported.\n"; |
| 69 | + return 1; |
| 70 | + } |
| 71 | + if (nLeptons != nLeptonsToBeDone) { |
| 72 | + std::cerr << "The number of muons should be the same as the number of muons which should be transported.\n"; |
| 73 | + return 1; |
| 74 | + } |
| 75 | + |
| 76 | + return 0; |
| 77 | +} |
0 commit comments