1+ int External ()
2+ {
3+ std ::string path {"o2sim_Kine.root" };
4+ std ::vector < int > possiblePDGs = {1010000030 , -1010000030 };
5+
6+ int nPossiblePDGs = possiblePDGs .size ();
7+
8+ TFile file (path .c_str (), "READ ");
9+ if (file .IsZombie ())
10+ {
11+ std ::cerr << "Cannot open ROOT file " << path << "\n" ;
12+ return 1 ;
13+ }
14+
15+ auto tree = (TTree * )file .Get ("o2sim" );
16+ if (!tree )
17+ {
18+ std ::cerr << "Cannot find tree o2sim in file " << path << "\n" ;
19+ return 1 ;
20+ }
21+ std ::vector < o2 ::MCTrack > * tracks {};
22+ tree -> SetBranchAddress ("MCTrack" , & tracks );
23+
24+ std ::vector < int > injectedPDGs ;
25+
26+ auto nEvents = tree -> GetEntries ();
27+ for (int i = 0 ; i < nEvents ; i ++ )
28+ {
29+ auto check = tree -> GetEntry (i );
30+ for (int idxMCTrack = 0 ; idxMCTrack < tracks -> size (); ++ idxMCTrack )
31+ {
32+ auto track = tracks -> at (idxMCTrack );
33+ auto pdg = track .GetPdgCode ();
34+ auto it = std ::find (possiblePDGs .begin (), possiblePDGs .end (), pdg );
35+ if (it != possiblePDGs .end () && track .isPrimary ()) // found
36+ {
37+ injectedPDGs .push_back (pdg );
38+ }
39+ }
40+ }
41+ std ::cout << "--------------------------------\n" ;
42+ std ::cout << "# Events: " << nEvents << "\n" ;
43+ if (injectedPDGs .empty ()){
44+ std ::cerr << "No injected particles\n" ;
45+ return 1 ; // At least one of the injected particles should be generated
46+ }
47+ for (int i = 0 ; i < nPossiblePDGs ; i ++ )
48+ {
49+ std ::cout << "# Injected nuclei \n" ;
50+ std ::cout << possiblePDGs [i ] << ": " << std ::count (injectedPDGs .begin (), injectedPDGs .end (), possiblePDGs [i ]) << "\n" ;
51+ }
52+ return 0 ;
53+ }
0 commit comments