Skip to content

Commit 5d5a5f0

Browse files
fix for strobe length + processing for TPC
1 parent 3aa3dc1 commit 5d5a5f0

File tree

5 files changed

+463
-0
lines changed

5 files changed

+463
-0
lines changed

DATA/production/configurations/2022/LHC22f/apass1/selectSettings.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ COLLISIONCONTEXT=collisioncontext_Single_3b_2_2_2.root
1212
# GRPMAG=o2sim_grp_b5p_128HB.root
1313
#fi
1414

15+
export ITS_STROBE=198
16+
export MFT_STROBE=198
17+
1518
if [[ $RUNNUMBER -ge 520259 ]] && [[ $RUNNUMBER -le 520290 ]]; then
1619
export ITS_STROBE=297
1720
export MFT_STROBE=297
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
#!/bin/bash
2+
3+
# Script to run the async processing
4+
#
5+
# if run locally, you need to export e.g.:
6+
#
7+
# export ALIEN_JDL_LPMRUNNUMBER=505673
8+
# export ALIEN_JDL_LPMINTERACTIONTYPE=pp
9+
# export ALIEN_JDL_LPMPRODUCTIONTAG=OCT
10+
# export ALIEN_JDL_LPMPASSNAME=apass4
11+
# export ALIEN_JDL_LPMANCHORYEAR=2021
12+
13+
14+
if [[ "${1##*.}" == "root" ]]; then
15+
#echo ${1##*.}
16+
#echo "alien://${1}" > list.list
17+
#export MODE="remote"
18+
echo "${1}" > list.list
19+
export MODE="LOCAL"
20+
shift
21+
elif [[ "${1##*.}" == "xml" ]]; then
22+
sed -rn 's/.*turl="([^"]*)".*/\1/p' $1 > list.list
23+
export MODE="remote"
24+
shift
25+
fi
26+
27+
POSITIONAL=()
28+
while [[ $# -gt 0 ]]; do
29+
key="$1"
30+
case $key in
31+
-rnb|--run-number)
32+
RUNNUMBER="$2"
33+
shift
34+
shift
35+
;;
36+
-b|--beam-type)
37+
BEAMTYPE="$2"
38+
shift
39+
shift
40+
;;
41+
-m|--mode)
42+
MODE="$2"
43+
shift
44+
shift
45+
;;
46+
-p|--period)
47+
PERIOD="$2"
48+
shift
49+
shift
50+
;;
51+
-pa|--pass)
52+
PASS="$2"
53+
shift
54+
shift
55+
;;
56+
*)
57+
POSITIONAL+=("$1")
58+
shift
59+
;;
60+
esac
61+
done
62+
63+
# now we overwrite if we found them in the jdl
64+
if [[ -n "$ALIEN_JDL_LPMRUNNUMBER" ]]; then
65+
export RUNNUMBER="$ALIEN_JDL_LPMRUNNUMBER"
66+
fi
67+
68+
# beam type
69+
if [[ -n "$ALIEN_JDL_LPMINTERACTIONTYPE" ]]; then
70+
export BEAMTYPE="$ALIEN_JDL_LPMINTERACTIONTYPE"
71+
fi
72+
73+
# period
74+
if [[ -n "$ALIEN_JDL_LPMPRODUCTIONTAG" ]]; then
75+
export PERIOD="$ALIEN_JDL_LPMPRODUCTIONTAG"
76+
export O2DPGPATH="$PERIOD"
77+
fi
78+
79+
# pass
80+
if [[ -n "$ALIEN_JDL_LPMPASSNAME" ]]; then
81+
export PASS="$ALIEN_JDL_LPMPASSNAME"
82+
fi
83+
84+
if [[ -z $RUNNUMBER ]] || [[ -z $PERIOD ]] || [[ -z $BEAMTYPE ]] || [[ -z $PASS ]]; then
85+
echo "check env variables we need RUNNUMBER (--> $RUNNUMBER), PERIOD (--> $PERIOD), PASS (--> $PASS), BEAMTYPE (--> $BEAMTYPE)"
86+
exit 3
87+
fi
88+
89+
echo processing run $RUNNUMBER, from period $PERIOD with $BEAMTYPE collisions and mode $MODE
90+
91+
###if [[ $MODE == "remote" ]]; then
92+
# common archive
93+
if [[ ! -f commonInput.tgz ]]; then
94+
echo "No commonInput.tgz found exiting"
95+
exit 2
96+
fi
97+
tar -xzvf commonInput.tgz
98+
SELECTSETTINGSSCRIPT="$O2DPG_ROOT/DATA/production/configurations/$ALIEN_JDL_LPMANCHORYEAR/$O2DPGPATH/$ALIEN_JDL_LPMPASSNAME/selectSettings.sh"
99+
if [[ -f "selectSettings.sh" ]]; then
100+
SELECTSETTINGSSCRIPT="selectSettings.sh"
101+
fi
102+
source $SELECTSETTINGSSCRIPT
103+
# run specific archive
104+
if [[ ! -f runInput_$RUNNUMBER.tgz ]]; then
105+
echo "No runInput_$RUNNUMBER.tgz, let's hope we don't need it"
106+
else
107+
tar -xzvf runInput_$RUNNUMBER.tgz
108+
fi
109+
###fi
110+
111+
echo "Checking current directory content"
112+
ls -altr
113+
114+
if [[ -f "setenv_extra.sh" ]]; then
115+
source setenv_extra.sh $RUNNUMBER $BEAMTYPE
116+
else
117+
echo "************************************************************************************"
118+
echo "No ad-hoc setenv_extra settings for current async processing; using the one in O2DPG"
119+
echo "************************************************************************************"
120+
if [[ -f $O2DPG_ROOT/DATA/production/configurations/$ALIEN_JDL_LPMANCHORYEAR/$O2DPGPATH/$ALIEN_JDL_LPMPASSNAME/setenv_extra.sh ]]; then
121+
ln -s $O2DPG_ROOT/DATA/production/configurations/$ALIEN_JDL_LPMANCHORYEAR/$O2DPGPATH/$ALIEN_JDL_LPMPASSNAME/setenv_extra.sh
122+
source setenv_extra.sh $RUNNUMBER $BEAMTYPE
123+
else
124+
echo "*********************************************************************************************************"
125+
echo "No setenev_extra for $ALIEN_JDL_LPMANCHORYEAR/$O2DPGPATH/$ALIEN_JDL_LPMPASSNAME in O2DPG"
126+
echo " No special settings will be used"
127+
echo "*********************************************************************************************************"
128+
fi
129+
fi
130+
131+
rm -f /dev/shm/*
132+
133+
if [[ -f run-workflow-on-inputlist.sh ]]; then
134+
echo "Use run-workflow-on-inputlist.sh macro passed as input"
135+
else
136+
echo "Use run-workflow-on-inputlist.sh macro from O2"
137+
cp $O2_ROOT/prodtests/full-system-test/run-workflow-on-inputlist.sh .
138+
fi
139+
140+
if [[ -z $DPL_WORKFLOW_FROM_OUTSIDE ]]; then
141+
echo "Use dpl-workflow.sh from O2"
142+
cp $O2_ROOT/prodtests/full-system-test/dpl-workflow.sh .
143+
else
144+
echo "Use dpl-workflow.sh passed as input"
145+
cp $DPL_WORKFLOW_FROM_OUTSIDE .
146+
fi
147+
148+
if [[ ! -z $QC_JSON_FROM_OUTSIDE ]]; then
149+
echo "QC json from outside is $QC_JSON_FROM_OUTSIDE"
150+
fi
151+
152+
ln -sf $O2DPG_ROOT/DATA/common/setenv.sh
153+
ln -sf $O2DPG_ROOT/DATA/common/getCommonArgs.sh
154+
ln -sf $O2_ROOT/prodtests/full-system-test/workflow-setup.sh
155+
156+
# TFDELAY and throttling
157+
TFDELAYSECONDS=40
158+
if [[ -n "$ALIEN_JDL_TFDELAYSECONDS" ]]; then
159+
TFDELAYSECONDS="$ALIEN_JDL_TFDELAYSECONDS"
160+
# ...otherwise, it depends on whether we have throttling
161+
elif [[ -n "$ALIEN_JDL_USETHROTTLING" ]]; then
162+
TFDELAYSECONDS=8
163+
TIMEFRAME_RATE_LIMIT=1
164+
fi
165+
166+
# reco and matching
167+
# print workflow
168+
IS_SIMULATED_DATA=0 WORKFLOWMODE=print DISABLE_ROOT_OUTPUT="" TFDELAY=$TFDELAYSECONDS NTIMEFRAMES=-1 SHMSIZE=16000000000 DDSHMSIZE=32000 ./run-workflow-on-inputlist.sh CTF list.list > workflowconfig.log
169+
# run it
170+
IS_SIMULATED_DATA=0 WORKFLOWMODE=run DISABLE_ROOT_OUTPUT="" TFDELAY=$TFDELAYSECONDS NTIMEFRAMES=-1 SHMSIZE=16000000000 DDSHMSIZE=32000 ./run-workflow-on-inputlist.sh CTF list.list
171+
172+
# now extract all performance metrics
173+
IFS=$'\n'
174+
if [[ -f "performanceMetrics.json" ]]; then
175+
for workflow in `grep ': {' performanceMetrics.json`; do
176+
strippedWorkflow=`echo $workflow | cut -d\" -f2`
177+
cat performanceMetrics.json | jq '.'\"${strippedWorkflow}\"'' > ${strippedWorkflow}_metrics.json
178+
done
179+
fi
180+
181+
# flag to possibly enable Analysis QC
182+
[[ -z ${ALIEN_JDL_RUNANALYSISQC+x} ]] && ALIEN_JDL_RUNANALYSISQC=1
183+
184+
# now checking AO2D file
185+
if [[ -f "AO2D.root" ]]; then
186+
root -l -b -q $O2DPG_ROOT/DATA/production/common/readAO2Ds.C > checkAO2D.log
187+
exitcode=$?
188+
if [[ $exitcode -ne 0 ]]; then
189+
echo "exit code from AO2D check is " $exitcode > validation_error.message
190+
echo "exit code from AO2D check is " $exitcode
191+
exit $exitcode
192+
fi
193+
if [[ $ALIEN_JDL_RUNANALYSISQC == 1 ]]; then
194+
${O2DPG_ROOT}/MC/analysis_testing/o2dpg_analysis_test_workflow.py --merged-task -f AO2D.root
195+
${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow_analysis_test.json > analysisQC.log
196+
if [[ -f "Analysis/MergedAnalyses/AnalysisResults.root" ]]; then
197+
mv Analysis/MergedAnalyses/AnalysisResults.root .
198+
else
199+
echo "No Analysis/MergedAnalyses/AnalysisResults.root found! check analysis QC"
200+
fi
201+
if ls Analysis/*/*.log 1> /dev/null 2>&1; then
202+
mv Analysis/*/*.log .
203+
fi
204+
else
205+
echo "Analysis QC will not be run, ALIEN_JDL_RUNANALYSISQC = $ALIEN_JDL_RUNANALYSISQC"
206+
fi
207+
fi
208+
209+
# copying the QC json file here
210+
if [[ ! -z $QC_JSON_FROM_OUTSIDE ]]; then
211+
QC_JSON=$QC_JSON_FROM_OUTSIDE
212+
else
213+
if [[ -d $GEN_TOPO_WORKDIR/json_cache ]]; then
214+
echo "copying latest file found in ${GEN_TOPO_WORKDIR}/json_cache"
215+
QC_JSON=`ls -dArt $GEN_TOPO_WORKDIR/json_cache/* | tail -n 1`
216+
else
217+
echo "No QC files found, probably QC was not run"
218+
fi
219+
fi
220+
if [[ ! -z $QC_JSON ]]; then
221+
cp $QC_JSON QC_production.json
222+
fi
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include <cmath>
2+
#include <fmt/format.h>
3+
#include <string_view>
4+
#include <fstream>
5+
6+
#include "TSystem.h"
7+
8+
#include "CCDB/CcdbApi.h"
9+
#include "DataFormatsTPC/LtrCalibData.h"
10+
#include "TPCBase/ParameterGas.h"
11+
12+
float getTPCvdrift(int run, std::string_view ltrUrl = "http://alice-ccdb.cern.ch")
13+
{
14+
o2::ccdb::CcdbApi c;
15+
c.init("http://alice-ccdb.cern.ch");
16+
std::map<std::string, std::string> headers, metadataRCT, metadata, mm;
17+
headers = c.retrieveHeaders(fmt::format("RCT/Info/RunInformation/{}", run), metadataRCT, -1);
18+
printf("\nLooking for vdrift for run %d\n", run);
19+
const auto sor = std::stol(headers["SOR"].data());
20+
21+
const auto defaultDriftV = o2::tpc::ParameterGas::Instance().DriftV;
22+
23+
std::string_view calibType = "TPC/Calib/LaserTracks";
24+
//
25+
// query present run up to +-3days
26+
const auto queryInterval = 3l * 24l * 60l * 60l * 1000l;
27+
const auto queryString = fmt::format("curl -H \"If-Not-Before: {}\" -H \"If-Not-After: {}\" -H \"Accept: application/json\" {}/browse/{}", sor - queryInterval, sor + queryInterval, ltrUrl.data(), calibType.data());
28+
fmt::print("Query: {}\n", queryString);
29+
const auto queryResultTString = gSystem->GetFromPipe(queryString.data());
30+
std::string queryResult(queryResultTString);
31+
32+
// find closest entry in time
33+
long minDist = 9999999999999;
34+
long minTime = sor;
35+
size_t pos = 0;
36+
const std::string_view searchString("validFrom");
37+
while ((pos = queryResult.find(searchString.data(), pos)) < queryResult.size()) {
38+
const auto startPosTime = queryResult.find(":", pos) + 1;
39+
const auto endPosTime = queryResult.find(",", pos);
40+
const auto startValidity = std::atol(queryResult.substr(startPosTime, endPosTime - startPosTime).data());
41+
fmt::print("add object {}\n", startValidity);
42+
if (std::abs(startValidity - sor) < minDist) {
43+
minTime = startValidity;
44+
minDist = std::abs(startValidity - sor);
45+
}
46+
pos = endPosTime;
47+
}
48+
fmt::print("{} closest to {} is at {}\n", calibType, sor, minTime);
49+
50+
//
51+
// Get object closest to present run and return the drfit veloctiy calibration factor
52+
c.init(ltrUrl.data());
53+
const auto ltrCalib = c.retrieveFromTFileAny<o2::tpc::LtrCalibData>(calibType.data(), metadata, minTime); /// timestamp in the run of interest
54+
const auto corr = ltrCalib->getDriftVCorrection();
55+
const float vcorr = defaultDriftV / corr;
56+
printf("vdrift = %f\n", vcorr);
57+
58+
ofstream fp("vdrift.txt");
59+
fp << vcorr << endl;
60+
fp.close();
61+
62+
return vcorr;
63+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
GRPMAG=o2sim_grp_b5p_128HB.root
4+
COLLISIONCONTEXT=collisioncontext_Single_3b_2_2_2.root
5+
6+
#if [[ $RUNNUMBER -ge 517676 ]] && [[ $RUNNUMBER -le 517679 ]]; then
7+
# COLLISIONCONTEXT=collisioncontext_Single_3b_0_2_2.root
8+
#fi
9+
10+
# B field update
11+
#if [[ $RUNNUMBER -ge 519041 ]]; then
12+
# GRPMAG=o2sim_grp_b5p_128HB.root
13+
#fi
14+
15+
export ITS_STROBE=198
16+
export MFT_STROBE=198
17+
if [[ $RUNNUMBER -ge 520259 ]] && [[ $RUNNUMBER -le 520290 ]]; then
18+
export ITS_STROBE=297
19+
export MFT_STROBE=297
20+
fi
21+
22+
echo "GRP B field = $GRPMAG"
23+
echo "filling scheme = $COLLISIONCONTEXT"
24+
echo "ITS strobe = $ITS_STROBE"
25+
echo "MFT strobe = $MFT_STROBE"
26+
27+
ln -s $COLLISIONCONTEXT collisioncontext.root
28+
ln -s $GRPMAG o2sim_grp.root

0 commit comments

Comments
 (0)