Skip to content

Commit c5b147f

Browse files
committed
Merge branch 'dev' into gpu_clusterizer
2 parents 207ba9c + 46380fc commit c5b147f

File tree

18 files changed

+535
-166
lines changed

18 files changed

+535
-166
lines changed

Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/RunManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class CTPRunManager : public ctpCCDBManager
4747
CTPRunManager() = default;
4848
void init();
4949
int loadRun(const std::string& cfg);
50-
int startRun(const std::string& cfg);
50+
int setRunConfigBK(uint32_t runNumber, const std::string& cfg);
5151
int stopRun(uint32_t irun, long timeStamp);
5252
int addScalers(uint32_t irun, std::time_t time, bool start = 0);
5353
int processMessage(std::string& topic, const std::string& message);

Detectors/CTP/workflowScalers/include/CTPWorkflowScalers/ctpCCDBManager.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ class ctpCCDBManager
2727
int saveRunScalersToCCDB(CTPRunScalers& scalers, long timeStart, long timeStop);
2828
int saveRunScalersToQCDB(CTPRunScalers& scalers, long timeStart, long timeStop);
2929
int saveRunConfigToCCDB(CTPConfiguration* cfg, long timeStart);
30+
int saveSoxOrbit(uint32_t runNumber, uint32_t soxOrbit, long timeStart);
31+
int saveOrbitReset(long timeStamp);
3032
static CTPConfiguration getConfigFromCCDB(long timestamp, std::string run, bool& ok);
3133
static CTPConfiguration getConfigFromCCDB(long timestamp, std::string run);
3234
CTPRunScalers getScalersFromCCDB(long timestamp, std::string, bool& ok);
33-
void setCCDBPathConfig(std::string path) { mCCDBPathCTPConfig = path; };
34-
void setCCDBPathScalers(std::string path) { mCCDBPathCTPScalers = path; };
35-
void setQCDBPathScalers(std::string path) { mQCDBPathCTPScalers = path; };
3635
static void setCCDBHost(std::string host) { mCCDBHost = host; };
3736
static void setQCDBHost(std::string host) { mQCDBHost = host; };
3837

@@ -42,9 +41,11 @@ class ctpCCDBManager
4241
// std::string mQCDBHost = "http://ali-qcdb.cern.ch:8083";
4342
static std::string mCCDBHost;
4443
static std::string mQCDBHost;
45-
std::string mCCDBPathCTPScalers = "CTP/Calib/Scalers";
46-
std::string mCCDBPathCTPConfig = "CTP/Config/Config";
47-
std::string mQCDBPathCTPScalers = "qc/CTP/Scalers";
44+
const std::string mCCDBPathCTPScalers = "CTP/Calib/Scalers";
45+
// std::string mCCDBPathCTPConfig = "CTP/Config/Config"; - in Configuration.h
46+
const std::string mQCDBPathCTPScalers = "qc/CTP/Scalers";
47+
const std::string mCCDBPathSoxOrbit = "CTP/Calib/FirstRunOrbit";
48+
const std::string mCCDBPathOrbitReset = "CTP/Calib/OrbitReset";
4849
ClassDefNV(ctpCCDBManager, 1);
4950
};
5051
} // namespace ctp

Detectors/CTP/workflowScalers/src/RunManager.cxx

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int CTPActiveRun::send2BK(std::unique_ptr<BkpClient>& BKClient, size_t ts, bool
5757
std::string clsname = cfg.getClassNameFromHWIndex(cls.first);
5858
// clsname = std::to_string(runOri) + "_" + clsname;
5959
try {
60-
BKClient->triggerCounters()->createOrUpdateForRun(runNumber, clsname, ts, cntsbk[0], cntsbk[1], cntsbk[2], cntsbk[3], cntsbk[4], cntsbk[5]);
60+
BKClient->ctpTriggerCounters()->createOrUpdateForRun(runNumber, clsname, ts, cntsbk[0], cntsbk[1], cntsbk[2], cntsbk[3], cntsbk[4], cntsbk[5]);
6161
} catch (std::runtime_error& error) {
6262
std::cerr << "An error occurred: " << error.what() << std::endl;
6363
return 1;
@@ -124,8 +124,19 @@ int CTPRunManager::loadRun(const std::string& cfg)
124124

125125
return 0;
126126
}
127-
int CTPRunManager::startRun(const std::string& cfg)
127+
int CTPRunManager::setRunConfigBK(uint32_t runNumber, const std::string& cfg)
128128
{
129+
std::cout << "Printing cfg:" << cfg << std::endl;
130+
if (mBKClient) {
131+
try {
132+
uint32_t runNumber = 1;
133+
mBKClient->run()->setRawCtpTriggerConfiguration(runNumber, cfg);
134+
} catch (std::runtime_error& error) {
135+
std::cerr << "An error occurred: " << error.what() << std::endl;
136+
return 1;
137+
}
138+
LOG(info) << "Run BK:" << runNumber << " CFG:" << cfg;
139+
}
129140
return 0;
130141
}
131142
int CTPRunManager::stopRun(uint32_t irun, long timeStamp)
@@ -221,6 +232,13 @@ int CTPRunManager::processMessage(std::string& topic, const std::string& message
221232
loadRun(message);
222233
return 0;
223234
}
235+
if (topic.find("soxorbit") != std::string::npos) {
236+
return 0;
237+
}
238+
if (topic.find("orbitreset") != std::string::npos) {
239+
return 0;
240+
}
241+
static int nerror = 0;
224242
if (topic.find("sox") != std::string::npos) {
225243
// get config
226244
size_t irun = message.find("run");
@@ -230,17 +248,15 @@ int CTPRunManager::processMessage(std::string& topic, const std::string& message
230248
}
231249
LOG(info) << "SOX received, Run keyword position:" << irun;
232250
std::string cfg = message.substr(irun, message.size() - irun);
233-
startRun(cfg);
234251
firstcounters = message.substr(0, irun);
235-
}
236-
if (topic.find("eox") != std::string::npos) {
252+
} else if (topic.find("eox") != std::string::npos) {
237253
LOG(info) << "EOX received";
238254
mEOX = 1;
239-
}
240-
static int nerror = 0;
241-
if (topic == "rocnts") {
242-
if (nerror < 1) {
243-
LOG(warning) << "Skipping topic rocnts";
255+
} else if (topic.find("cnts") != std::string::npos) {
256+
// just continue
257+
} else {
258+
if (nerror < 10) {
259+
LOG(warning) << "Skipping topic:" << topic;
244260
nerror++;
245261
}
246262
return 0;
@@ -293,6 +309,7 @@ int CTPRunManager::processMessage(std::string& topic, const std::string& message
293309
mActiveRunNumbers[i] = mCounters[i];
294310
mActiveRuns[i] = run->second;
295311
mRunsLoaded.erase(run);
312+
setRunConfigBK(mActiveRuns[i]->cfg.getRunNumber(), mActiveRuns[i]->cfg.getConfigString());
296313
addScalers(i, tt, 1);
297314
saveRunScalersToQCDB(mActiveRuns[i]->scalers, tt * 1000, tt * 1000);
298315
} else {

Detectors/CTP/workflowScalers/src/ctpCCDBManager.cxx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,65 @@ int ctpCCDBManager::saveRunConfigToCCDB(CTPConfiguration* cfg, long timeStart)
107107
}
108108
return ret;
109109
}
110+
int ctpCCDBManager::saveSoxOrbit(uint32_t runNumber, uint32_t soxOrbit, long timestamp)
111+
{
112+
// data base
113+
if (mCCDBHost == "none") {
114+
LOG(info) << "SOX Orbit not written to CCDB none";
115+
return 0;
116+
}
117+
std::vector<int64_t> vect;
118+
if (timestamp == 0) {
119+
auto now = std::chrono::system_clock::now();
120+
timestamp = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
121+
}
122+
vect.push_back(timestamp);
123+
vect.push_back((uint64_t)runNumber);
124+
vect.push_back((uint64_t)soxOrbit);
125+
long tmin = timestamp;
126+
long tmax = tmin + 381928219;
127+
o2::ccdb::CcdbApi api;
128+
map<string, string> metadata; // can be empty
129+
metadata["runNumber"] = std::to_string(runNumber);
130+
api.init(mCCDBHost.c_str()); // or http://localhost:8080 for a local installation
131+
132+
// store abitrary user object in strongly typed manner
133+
int ret = api.storeAsTFileAny(&vect, mCCDBPathSoxOrbit, metadata, tmin, tmax);
134+
if (ret == 0) {
135+
LOG(info) << "SOX orbit saved in ccdb:" << mCCDBHost << " run:" << runNumber << " tmin:" << tmin << " tmax:" << tmax;
136+
} else {
137+
LOG(fatal) << "SOX orbit Problem writing to database ret:" << ret;
138+
}
139+
return 0;
140+
}
141+
int ctpCCDBManager::saveOrbitReset(long timeStamp)
142+
{
143+
// data base
144+
if (mCCDBHost == "none") {
145+
LOG(info) << "Orbit Reset not written to CCDB none";
146+
return 0;
147+
}
148+
std::vector<int64_t> vect;
149+
if (timeStamp == 0) {
150+
auto now = std::chrono::system_clock::now();
151+
timeStamp = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()).count();
152+
}
153+
vect.push_back(timeStamp);
154+
long tmin = timeStamp;
155+
long tmax = tmin + 381928219;
156+
o2::ccdb::CcdbApi api;
157+
map<string, string> metadata; // can be empty
158+
api.init(mCCDBHost.c_str()); // or http://localhost:8080 for a local installation
159+
160+
// store abitrary user object in strongly typed manner
161+
int ret = api.storeAsTFileAny(&vect, mCCDBPathOrbitReset, metadata, tmin, tmax);
162+
if (ret == 0) {
163+
LOG(info) << "Orbit reset saved in ccdb:" << mCCDBHost << " tmin:" << tmin << " tmax:" << tmax;
164+
} else {
165+
LOG(fatal) << "Orbit reset Problem writing to database ret:" << ret;
166+
}
167+
return 0;
168+
}
110169
CTPConfiguration ctpCCDBManager::getConfigFromCCDB(long timestamp, std::string run, bool& ok)
111170
{
112171
auto& mgr = o2::ccdb::BasicCCDBManager::instance();

Detectors/GlobalTrackingWorkflow/study/src/TrackingStudy.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,8 @@ void TrackingStudySpec::process(o2::globaltracking::RecoContainer& recoData)
591591
pr.nshTPCRow = shinfo.second;
592592
}
593593
}
594+
(*mDBGOut) << "pairs" << "pr=" << trcPairsVec << "\n";
594595
}
595-
(*mDBGOut) << "pairs"
596-
<< "pr=" << trcPairsVec << "\n";
597596
}
598597

599598
int nvtot = mMaxNeighbours < 0 ? -1 : (int)pveVec.size();

Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ void ITSTrackingInterface::initialise()
3838
std::vector<TrackingParameters> trackParams;
3939
const auto& trackConf = o2::its::TrackerParamConfig::Instance();
4040
float bFactor = std::abs(o2::base::Propagator::Instance()->getNominalBz()) / 5.0066791;
41+
if (bFactor < 0.01) {
42+
bFactor = 1.;
43+
}
4144
if (mMode == TrackingMode::Unset) {
4245
mMode = (TrackingMode)(trackConf.trackingMode);
4346
LOGP(info, "Tracking mode not set, trying to fetch it from configurable params to: {}", asString(mMode));

Detectors/ITSMFT/ITS/workflow/src/ThresholdCalibratorSpec.cxx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,8 @@ void ITSThresholdCalibrator::setRunType(const short int& runtype)
10011001
this->mFitType = NO_FIT;
10021002
this->mMin = 0;
10031003
this->mMax = 400; // strobe delay goes from 0 to 400 (included) in steps of 4
1004-
this->mStep = 4;
1005-
this->mStrobeWindow = 5; // it's 4 but it corresponds to 4+1 (as from alpide manual)
1004+
this->mStep = 1;
1005+
this->mStrobeWindow = 1; // it's 0 but it corresponds to 0+1 (as from alpide manual)
10061006
this->N_RANGE = (mMax - mMin) / mStep + 1;
10071007
this->mCheckExactRow = true;
10081008
} else if (runtype == TOT_CALIBRATION_1_ROW) {
@@ -1013,7 +1013,7 @@ void ITSThresholdCalibrator::setRunType(const short int& runtype)
10131013
this->mMin = 0;
10141014
this->mMax = 2000; // strobe delay goes from 0 to 2000 in steps of 10
10151015
this->mStep = 10;
1016-
this->mStrobeWindow = 2; // it's 1 but it corresponds to 1+1 (as from alpide manual)
1016+
this->mStrobeWindow = 10; // it's 9 but it corresponds to 9+1 (as from alpide manual)
10171017
this->N_RANGE = (mMax - mMin) / mStep + 1;
10181018
this->mMin2 = 0; // charge min
10191019
this->mMax2 = 170; // charge max
@@ -1028,7 +1028,7 @@ void ITSThresholdCalibrator::setRunType(const short int& runtype)
10281028
this->mMin = 300;
10291029
this->mMax = 1100; // strobe delay goes from 300 to 1100 (included) in steps of 10
10301030
this->mStep = 10;
1031-
this->mStrobeWindow = 2; // it's 1 but it corresponds to 1+1 (as from alpide manual)
1031+
this->mStrobeWindow = 10; // it's 9 but it corresponds to 9+1 (as from alpide manual)
10321032
this->N_RANGE = (mMax - mMin) / mStep + 1;
10331033
this->mMin2 = 30; // charge min
10341034
this->mMax2 = 60; // charge max
@@ -1116,39 +1116,39 @@ std::vector<float> ITSThresholdCalibrator::calculatePulseParams(const short int&
11161116

11171117
for (auto itrow = mPixelHits[chipID].begin(); itrow != mPixelHits[chipID].end(); itrow++) { // loop over the chip rows
11181118
short int row = itrow->first;
1119-
for (short int col_i = 0; col_i < this->N_COL; col_i++) { // loop over the pixels on the row
1120-
for (short int sdel_i = 0; sdel_i < this->N_RANGE; sdel_i++) { // loop over the strobe delays
1121-
if (mPixelHits[chipID][row][col_i][0][sdel_i] > 0 && mPixelHits[chipID][row][col_i][0][sdel_i] < nInj && rt_mindel < 0) { // from left, the last bin with 0 hits or the first with some hits
1122-
rt_mindel = sdel_i > 0 ? ((sdel_i - 1) * mStep) + 1 : (sdel_i * mStep) + 1; // + 1 because if delay = n, we get n+1 in reality (ALPIDE feature)
1119+
for (short int col_i = 0; col_i < this->N_COL; col_i++) { // loop over the pixels on the row
1120+
for (short int sdel_i = 0; sdel_i < this->N_RANGE; sdel_i++) { // loop over the strobe delays
1121+
if (mPixelHits[chipID][row][col_i][0][sdel_i] > 0.1 * nInj && mPixelHits[chipID][row][col_i][0][sdel_i] < nInj && rt_mindel < 0) { // from left, first bin with 10% hits and 90% hits
1122+
rt_mindel = (sdel_i * mStep) + 1; // + 1 because if delay = n, we get n+1 in reality (ALPIDE feature)
11231123
}
1124-
if (mPixelHits[chipID][row][col_i][0][sdel_i] == nInj) {
1124+
if (mPixelHits[chipID][row][col_i][0][sdel_i] >= 0.9 * nInj) { // for Rt max take the 90% point
11251125
rt_maxdel = (sdel_i * mStep) + 1;
1126+
break;
1127+
}
1128+
}
1129+
for (short int sdel_i = 0; sdel_i < N_RANGE; sdel_i++) {
1130+
if (mPixelHits[chipID][row][col_i][0][sdel_i] >= 0.5 * nInj) { // for ToT take the 50% point
11261131
tot_mindel = (sdel_i * mStep) + 1;
11271132
break;
11281133
}
11291134
}
11301135

1131-
for (short int sdel_i = N_RANGE - 1; sdel_i >= 0; sdel_i--) { // from right, the first bin with nInj hits
1132-
if (mPixelHits[chipID][row][col_i][0][sdel_i] == nInj) {
1136+
for (short int sdel_i = N_RANGE - 1; sdel_i >= 0; sdel_i--) { // from right, the first bin with 50% nInj hits
1137+
if (mPixelHits[chipID][row][col_i][0][sdel_i] >= 0.5 * nInj) {
11331138
tot_maxdel = (sdel_i * mStep) + 1;
11341139
break;
11351140
}
11361141
}
11371142

11381143
if (tot_maxdel > tot_mindel && tot_mindel >= 0 && tot_maxdel >= 0) {
1139-
sumTot += tot_maxdel - tot_mindel - (int)(mStrobeWindow / 2);
1140-
sumSqTot += (tot_maxdel - tot_mindel - (int)(mStrobeWindow / 2)) * (tot_maxdel - tot_mindel - (int)(mStrobeWindow / 2));
1144+
sumTot += tot_maxdel - tot_mindel - mStrobeWindow;
1145+
sumSqTot += (tot_maxdel - tot_mindel - mStrobeWindow) * (tot_maxdel - tot_mindel - mStrobeWindow);
11411146
countTot++;
11421147
}
11431148

1144-
if (rt_maxdel > rt_mindel && rt_maxdel > 0) {
1145-
if (rt_mindel < 0) {
1146-
sumRt += mStep + (int)(mStrobeWindow / 2); // resolution -> in case the rise is "instantaneous"
1147-
sumSqRt += (mStep + (int)(mStrobeWindow / 2)) * (mStep + (int)(mStrobeWindow / 2));
1148-
} else {
1149-
sumRt += rt_maxdel - rt_mindel + (int)(mStrobeWindow / 2);
1150-
sumSqRt += (rt_maxdel - rt_mindel + (int)(mStrobeWindow / 2)) * (rt_maxdel - rt_mindel + (int)(mStrobeWindow / 2));
1151-
}
1149+
if (rt_maxdel > rt_mindel && rt_maxdel > 0 && rt_mindel > 0) {
1150+
sumRt += rt_maxdel - rt_mindel + mStrobeWindow;
1151+
sumSqRt += (rt_maxdel - rt_mindel + mStrobeWindow) * (rt_maxdel - rt_mindel + mStrobeWindow);
11521152
countRt++;
11531153
}
11541154

@@ -1232,8 +1232,8 @@ std::vector<float> ITSThresholdCalibrator::calculatePulseParams2D(const short in
12321232
}
12331233

12341234
if (maxPl > tot_mindel && tot_mindel < 1e7 && maxPl >= 0) { // ToT
1235-
sumTot += maxPl - tot_mindel - (int)(mStrobeWindow / 2);
1236-
sumSqTot += (maxPl - tot_mindel - (int)(mStrobeWindow / 2)) * (maxPl - tot_mindel - (int)(mStrobeWindow / 2));
1235+
sumTot += maxPl - tot_mindel - mStrobeWindow;
1236+
sumSqTot += (maxPl - tot_mindel - mStrobeWindow) * (maxPl - tot_mindel - mStrobeWindow);
12371237
countTot++;
12381238
}
12391239

0 commit comments

Comments
 (0)