File tree Expand file tree Collapse file tree 1 file changed +49
-1
lines changed
MC/config/PWGEM/ini/tests Expand file tree Collapse file tree 1 file changed +49
-1
lines changed Original file line number Diff line number Diff line change 11int External () {
2- return 0 ;
2+ std ::string path {"o2sim_Kine.root" };
3+ // Check that file exists, can be opened and has the correct tree
4+ TFile file (path .c_str (), "READ ");
5+ if (file .IsZombie ())
6+ {
7+ std ::cerr << "Cannot open ROOT file " << path << "\n" ;
8+ return 1 ;
9+ }
10+ auto tree = (TTree * )file .Get ("o2sim" );
11+ if (!tree )
12+ {
13+ std ::cerr << "Cannot find tree o2sim in file " << path << "\n" ;
14+ return 1 ;
15+ }
16+ std ::vector < o2 ::MCTrack > * tracks {};
17+ tree -> SetBranchAddress ("MCTrack" , & tracks );
18+
19+ // Check if all events are filled
20+ auto nEvents = tree -> GetEntries ();
21+ for (Long64_t i = 0 ; i < nEvents ; ++ i )
22+ {
23+ tree -> GetEntry (i );
24+ if (tracks -> empty ())
25+ {
26+ std ::cerr << "Empty entry found at event " << i << "\n" ;
27+ return 1 ;
28+ }
29+ }
30+ // check if each event has at least two oxygen ions
31+ for (int i = 0 ; i < nEvents ; i ++ )
32+ {
33+ auto check = tree -> GetEntry (i );
34+ int count = 0 ;
35+ for (int idxMCTrack = 0 ; idxMCTrack < tracks -> size (); ++ idxMCTrack )
36+ {
37+ auto track = tracks -> at (idxMCTrack );
38+ if (track .GetPdgCode () == 1000080160 )
39+ {
40+ count ++ ;
41+ }
42+ }
43+ if (count < 2 )
44+ {
45+ std ::cerr << "Event " << i << " has less than 2 oxygen ions\n" ;
46+ return 1 ;
47+ }
48+ }
49+
50+ return 0 ;
351}
452
553//int Pythia8()
You can’t perform that action at this time.
0 commit comments