1+ #include <TFile.h>
2+ #include <TDirectoryFile.h>
3+ #include <TTree.h>
4+ #include <TTreeReader.h>
5+ #include <TGrid.h>
6+ #include <iostream>
7+
8+ int checkCorruptedAO2Ds (TString infileName = "/alice/sim/2024/LHC24h2/535545/AOD/005/AO2D.root" , bool fromAlien = true) {
9+
10+ if (fromAlien ) {
11+ TGrid ::Connect ("alien://" );
12+ if (!infileName .Contains ("alien://" )) {
13+ infileName = "alien://" + infileName ;
14+ }
15+ }
16+
17+ auto inFile = TFile ::Open (infileName .Data ());
18+ if (!inFile || inFile -> IsZombie ()) {
19+ return -1 ;
20+ }
21+
22+ // all VLA branches in the AO2Ds.root
23+ std ::map < std ::string , std ::vector < std ::string >> branchesToCheck = {
24+ {"O2mcparticle_001" , std ::vector < std ::string > {"fIndexArray_Mothers" }},
25+ {"O2ft0" , std ::vector < std ::string > {"fAmplitudeA" , "fChannelA" , "fAmplitudeC" , "fChannelC" }},
26+ {"O2fv0a" , std ::vector < std ::string > {"fAmplitude" , "fChannel" }},
27+ {"O2mccalolabel_001" , std ::vector < std ::string > {"fIndexArrayMcParticles" , "fAmplitudeA" }},
28+ {"O2zdc_001" , std ::vector < std ::string > {"fEnergy" , "fChannelE" , "fAmplitude" , "fTime" , "fChannelT" }}
29+ };
30+
31+ for (auto const & dirKey : * inFile -> GetListOfKeys ()) {
32+ if (TString (dirKey -> GetName ()).Contains ("DF ")) {
33+ auto df = static_cast < TDirectoryFile * > (inFile - > Get (dirKey - > GetName ()));
34+ std ::cout << dirKey -> GetName () << std ::endl ;
35+ for (auto const & pair : branchesToCheck ) {
36+ auto tree = static_cast < TTree * > (df -> Get (pair .first .data ()));
37+ for (auto const & branchName : pair .second ) {
38+ auto leaf = static_cast < TLeaf * > (tree -> GetLeaf (branchName .data ()));
39+
40+ for (int iEntry {0 }; iEntry < tree -> GetEntries (); ++ iEntry ) {
41+ if (tree -> GetEntry (iEntry ) < 0 ) {
42+ std ::cout << "Found corrupted file! DF: " << dirKey -> GetName () << " Tree:" << pair .first .data () << " Branch:" << branchName .data () << std ::endl ;
43+ return -1 ;
44+ }
45+ }
46+ }
47+ }
48+ }
49+ }
50+
51+ return 0 ;
52+ }
0 commit comments