Skip to content

Commit de608aa

Browse files
authored
[O2DPG,UTILS,O2-5725] Expand macros to find corrupted AO2Ds (#1913)
* [O2DPG,UTILS,O2-5725] Expand macros to find corrupted AO2Ds - Added check for "repair" messages in the `checkCorruptedAO2Ds.C` macro to also catch files, where some problem appears and root tries to repair on the fly. This addition is made based on the recent report by Nicolas on the JIRA ticket O2-5725 that we see still some AO2D files with problems that can not be catched with the old version of `checkCorruptedAO2Ds.C`. - Modified `findCorruptedAO2Ds.sh` to correctly read those cases and identify them as "broken" aswell. * Update macros to find corrupted AO2Ds * Added functionality to check for DFs which cause "repair" warning message * Fix comment in script
1 parent 48835e7 commit de608aa

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

UTILS/checkCorruptedAO2Ds.C

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@
44
#include <TTreeReader.h>
55
#include <TGrid.h>
66
#include <iostream>
7+
#include <TError.h>
8+
#include <cstring>
9+
10+
bool gWarningDetected = false; // Global flag to track the warning
11+
12+
void MyErrorHandler(int level, Bool_t abort, const char *location, const char *msg) {
13+
if (strstr(msg, "repair") != nullptr) {
14+
gWarningDetected = true;
15+
}
16+
DefaultErrorHandler(level, abort, location, msg); // Call ROOT’s default handler
17+
}
718

819
int checkCorruptedAO2Ds(TString infileName = "/alice/sim/2024/LHC24h2/535545/AOD/005/AO2D.root", bool fromAlien = true) {
20+
21+
SetErrorHandler(MyErrorHandler);
922

1023
if (fromAlien) {
1124
TGrid::Connect("alien://");
@@ -21,7 +34,7 @@ int checkCorruptedAO2Ds(TString infileName = "/alice/sim/2024/LHC24h2/535545/AOD
2134

2235
// all VLA branches in the AO2Ds.root
2336
std::map<std::string, std::vector<std::string>> branchesToCheck = {
24-
{"O2mcparticle_001", std::vector<std::string>{"fIndexArray_Mothers"}},
37+
{"O2mcparticle_001", std::vector<std::string>{"fIndexArray_Mothers", "fVx", "fIndexMcCollisions"}},
2538
{"O2ft0", std::vector<std::string>{"fAmplitudeA", "fChannelA", "fAmplitudeC", "fChannelC"}},
2639
{"O2fv0a", std::vector<std::string>{"fAmplitude", "fChannel"}},
2740
{"O2mccalolabel_001", std::vector<std::string>{"fIndexArrayMcParticles", "fAmplitudeA"}},
@@ -42,11 +55,15 @@ int checkCorruptedAO2Ds(TString infileName = "/alice/sim/2024/LHC24h2/535545/AOD
4255
std::cout << "Found corrupted file! DF: " << dirKey->GetName() << " Tree:" << pair.first.data() << " Branch:" << branchName.data() << std::endl;
4356
return -1;
4457
}
58+
if (gWarningDetected) {
59+
std::cout << "Found file in need of repair! DF: " << dirKey->GetName() << " Tree:" << pair.first.data() << " Branch:" << branchName.data() << std::endl;
60+
return -2;
61+
}
4562
}
4663
}
4764
}
4865
}
4966
}
5067

5168
return 0;
52-
}
69+
}

UTILS/findCorruptedAO2Ds.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,29 @@
22

33
# Simple script to find corrupted AO2Ds using the checkCorruptedAO2Ds.C macro
44

5-
PRODUCTION=LHC24h2
5+
PRODUCTION=LHC24f3c
66
RUN=* # use * for all runs
7-
NJOBS=90
7+
NJOBS=20
8+
PRODUCTIONCYCLE=0
89

910
OUTPUTFILE=corrupted_files_$PRODUCTION.txt
1011
if [ -e "$OUTPUTFILE" ]; then
1112
rm $OUTPUTFILE
1213
fi
1314

1415
# find all files in alien
15-
if [ "$variable" == "*" ]; then
16-
alien_find alien:///alice/sim/2024/${PRODUCTION} 5*/AOD/*/AO2D.root > files_to_check.txt
16+
if [ "$RUN" == "*" ]; then
17+
alien_find alien:///alice/sim/2024/${PRODUCTION}/${PRODUCTIONCYCLE}/5*/AOD/*/AO2D.root > files_to_check.txt
1718
else
18-
alien_find alien:///alice/sim/2024/${PRODUCTION} ${RUN}/AOD/*/AO2D.root > files_to_check.txt
19+
alien_find alien:///alice/sim/2024/${PRODUCTION}/${PRODUCTIONCYCLE}/${RUN}/AOD/*/AO2D.root > files_to_check.txt
1920
fi
2021
mapfile -t FILESTOCHECK < files_to_check.txt
2122

2223
# process AO2Ds
2324
process_file() {
2425
IFS='/' read -a num <<< "$1"
2526
INPUT=$1
26-
echo '.x checkCorruptedAO2Ds.C("'${INPUT}'", true)' | root -l -b > log_${num[5]}_${num[7]}
27+
echo '.x checkCorruptedAO2Ds.C("'${INPUT}'", true)' | root -l -b > log_${num[6]}_${num[8]}
2728
echo '.q'
2829
}
2930
export -f process_file
@@ -33,12 +34,15 @@ parallel -j $NJOBS process_file ::: "${FILESTOCHECK[@]}"
3334
# create list of corrupted files
3435
touch $OUTPUTFILE
3536
ERRORSTR="Found corrupted file!"
37+
REPAIRSTR="Found file in need of repair!"
3638
for FILE in "${FILESTOCHECK[@]}"; do
3739
IFS='/' read -a num <<< "$FILE"
38-
if grep -q "$ERRORSTR" log_${num[5]}_${num[7]}; then
39-
echo $FILE >> $OUTPUTFILE
40+
if grep -q "$ERRORSTR" log_${num[6]}_${num[8]}; then
41+
echo $FILE " is corrupted!" >> $OUTPUTFILE
42+
elif grep -q "$REPAIRSTR" log_${num[6]}_${num[8]}; then
43+
echo $FILE " is broken!" >> $OUTPUTFILE
4044
fi
4145
done
4246

4347
rm files_to_check.txt
44-
rm log*
48+
rm log_*

0 commit comments

Comments
 (0)