-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_2DA_VR2_batch.sh
More file actions
executable file
·143 lines (111 loc) · 4.53 KB
/
run_2DA_VR2_batch.sh
File metadata and controls
executable file
·143 lines (111 loc) · 4.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
echo "Run script starting"
echo "Template Config: $1"
echo "Signal: $2"
echo "TF Type: $3"
arch=el8_amd64_gcc12
rel=CMSSW_14_1_0_pre4
echo -e "------------------- START --------------------"
printf "Start time: "; TZ=CET /bin/date
printf "Job is running on node: "; /bin/hostname
printf "Job running as user: "; /usr/bin/id
printf "Job is running in directory: "; /bin/pwd -P
echo
echo -e "---------------- Environments ----------------"
baseDir=`/bin/pwd -P`
echo "Base directory: $baseDir"
echo -e "\n[0] export SCRAM_ARCH= $arch (BEFORE sourcing cmsset)"
export SCRAM_ARCH=$arch
echo -e "\n[1] source /cvmfs/cms.cern.ch/cmsset_default.sh"
source /cvmfs/cms.cern.ch/cmsset_default.sh
echo -e "\n[2] Verify SCRAM_ARCH"
echo "SCRAM_ARCH is: $SCRAM_ARCH"
echo -e "\n[3] scramv1 project CMSSW $rel"
scramv1 project CMSSW $rel
# Move analysis directories into CMSSW src
echo -e "\n[4] Moving HiggsAnalysis, CombineHarvester, and 2DAlphabet to CMSSW/src"
mv HiggsAnalysis $rel/src/
mv CombineHarvester $rel/src/
mv 2DAlphabet $rel/src/
# Also move the scripts we'll need later
echo -e "\n[4b] Moving scripts, config, and histogram files to CMSSW/src"
mv run_single_signal_2DA.py $rel/src/
mv config_Binningv7alt_InputTemplate_VR2_Unblind.json $rel/src/
# Move histogram directory
echo -e "\n[4c] Moving histogram directory to CMSSW/src"
mv histograms_for_2DAlphabet_v21 $rel/src/
echo "Histogram directory contents:"
ls -lh $rel/src/histograms_for_2DAlphabet_v21/ | head -10
# cd into CMSSW and do cmsenv
echo -e "\n[5] cd $rel/src/"
cd $rel/src/
echo -e "\n[6] cmsenv and verify architecture"
eval `scramv1 runtime -sh`
echo "After cmsenv, SCRAM_ARCH is: $SCRAM_ARCH"
echo "GCC version: $(gcc --version | head -1)"
########CMSSW environment is now active with ROOT############
# Show directory structure
echo -e "\n[DEBUG] CMSSW src directory:"
echo "Current directory: $(pwd)"
ls -lah
echo -e "\n[7] Compile with scram b"
echo "Attempting compilation..."
scram b -j 4
COMPILE_STATUS=$?
if [ $COMPILE_STATUS -ne 0 ]; then
echo "WARNING: Compilation failed with status $COMPILE_STATUS"
echo "Checking if RooParametricHist2D is available anyway..."
python3 -c "from ROOT import RooParametricHist2D; print('RooParametricHist2D is available!')" 2>&1
fi
echo -e "\n[8] Create and activate virtual environment"
python3 -m virtualenv twoD-env
source twoD-env/bin/activate
echo -e "\n[9] Install TwoDAlphabet in development mode"
cd 2DAlphabet
python3 setup.py develop
cd ..
echo "Virtual environment ready: $(which python3)"
echo "Python version: $(python3 --version)"
echo -e "\n------------------ Process Signal ------------------"
template_config=$1
signal=$2
tf_type=$3
# Create working area name based on signal
workingArea="rpf2x0_${signal}"
# Histogram directory should already be here from earlier move
echo -e "\n[1] Checking histogram directory"
if [ ! -d "histograms_for_2DAlphabet_v21" ]; then
echo "ERROR: histogram directory not found!"
ls -la
exit 1
fi
echo "Histogram files:"
ls -lh histograms_for_2DAlphabet_v21/ | grep -E "(${signal}|Data_SR)" || echo "WARNING: Expected files not found"
# Create job-specific config by replacing SIGNAME_PLACEHOLDER
echo -e "\n[2] Creating job-specific config for $signal"
config_file="config_${signal}.json"
sed "s/SIGNAME_PLACEHOLDER/$signal/g" "$template_config" > "$config_file"
echo "Created config file: $config_file"
# Run the Python script (transferred to local directory)
echo -e "\n[3] Running analysis for $signal"
python3 run_single_signal_2DA.py "$workingArea" "$config_file" "$signal" "$tf_type"
# Copy workspace back to initial directory for Condor to transfer
echo -e "\n[4] Preparing output for transfer"
# Create parent directory structure unconditionally (so Condor always has something to transfer)
parent_dir="rpf2x0_Binningv7alt_Inputv21_VR2_Unblind"
echo "Creating parent directory: $baseDir/$parent_dir"
mkdir -p "$baseDir/$parent_dir"
if [ -d "$workingArea" ]; then
echo "Workspace created: $workingArea"
echo "Workspace size: $(du -sh $workingArea | cut -f1)"
# Copy workspace to parent directory so Condor can transfer it back
echo "Copying workspace to $baseDir/$parent_dir/$workingArea"
cp -r "$workingArea" "$baseDir/$parent_dir/"
echo "Workspace copied successfully"
echo "Condor will transfer this back on job completion."
else
echo "WARNING: Workspace directory not found! Job may have failed."
echo "Parent directory created anyway for Condor file transfer."
fi
echo -e "-------------------- END ---------------------\n"
echo "UnixTime-JobEnd: "$(date +%s)