Skip to content

Commit d80e3e7

Browse files
authored
Merge branch 'AliceO2Group:dev' into new-detector4
2 parents 96c6826 + 9e9afd8 commit d80e3e7

File tree

37 files changed

+636
-313
lines changed

37 files changed

+636
-313
lines changed

CCDB/src/CcdbApi.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ std::map<std::string, std::string> CcdbApi::retrieveHeaders(std::string const& p
14611461

14621462
if (!mSnapshotCachePath.empty()) {
14631463
// protect this sensitive section by a multi-process named semaphore
1464-
auto semaphore_barrier = std::make_unique<CCDBSemaphore>(mSnapshotCachePath, path);
1464+
auto semaphore_barrier = std::make_unique<CCDBSemaphore>(mSnapshotCachePath + std::string("_headers"), path);
14651465

14661466
std::string logfile = mSnapshotCachePath + "/log";
14671467
std::fstream out(logfile, ios_base::out | ios_base::app);

Detectors/ITSMFT/ITS/workflow/include/ITSWorkflow/ThresholdCalibratorSpec.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ class ITSThresholdCalibrator : public Task
148148

149149
// Hash tables to store the hit and threshold information per pixel
150150
std::map<short int, std::map<int, std::vector<std::vector<std::vector<unsigned short int>>>>> mPixelHits;
151-
std::map<short int, std::deque<short int>> mForbiddenRows;
152151
// Unordered map for saving sum of values (thr/ithr/vcasn) for avg calculation
153152
std::map<short int, std::array<long int, 6>> mThresholds;
154153
// Map including PixID for noisy pixels

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

Lines changed: 65 additions & 49 deletions
Large diffs are not rendered by default.

Detectors/ITSMFT/MFT/calibration/src/NoiseCalibratorSpec.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ void NoiseCalibratorSpec::run(ProcessingContext& pc)
8383
} else {
8484
LOG(info) << "Sending an object to Production-CCDB and DCS-CCDB";
8585
sendOutputCcdbDcs(pc.outputs());
86+
LOG(info) << "Sending an object to Production-CCDBMerge";
87+
sendOutputCcdbMerge(pc.outputs());
8688
}
8789
pc.services().get<ControlService>().readyToQuit(mStopMeOnly ? QuitRequest::Me : QuitRequest::All);
8890
}
@@ -105,6 +107,8 @@ void NoiseCalibratorSpec::run(ProcessingContext& pc)
105107
} else {
106108
LOG(info) << "Sending an object to Production-CCDB and DCS-CCDB";
107109
sendOutputCcdbDcs(pc.outputs());
110+
LOG(info) << "Sending an object to Production-CCDBMerge";
111+
sendOutputCcdbMerge(pc.outputs());
108112
}
109113
pc.services().get<ControlService>().readyToQuit(mStopMeOnly ? QuitRequest::Me : QuitRequest::All);
110114
}

Detectors/TPC/base/include/TPCBase/CDBTypes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ enum class CDBType {
6666
CalSAC1, ///< I_1(t) = <I(r,\phi,t) / I_0(r,\phi)>_{r,\phi}
6767
CalSACDelta, ///< \Delta I(r,\phi,t) = I(r,\phi,t) / ( I_0(r,\phi) * I_1(t) )
6868
CalSACFourier, ///< Fourier coefficients of CalSAC1
69+
CalSAC, ///< CalSAC0, CalSAC1 and CalSACDelta
6970
///
7071
CalITPC0, ///< 2D average TPC clusters for longer time interval
7172
CalITPC1, ///< 1D integrated TPC clusters
@@ -133,6 +134,7 @@ const std::unordered_map<CDBType, const std::string> CDBTypeMap{
133134
{CDBType::CalSAC0, "TPC/Calib/SAC_0"},
134135
{CDBType::CalSAC1, "TPC/Calib/SAC_1"},
135136
{CDBType::CalSACDelta, "TPC/Calib/SAC_DELTA"},
137+
{CDBType::CalSAC, "TPC/Calib/SAC"},
136138
{CDBType::CalSACFourier, "TPC/Calib/SAC_FOURIER"},
137139
// ITPCCs
138140
{CDBType::CalITPC0, "TPC/Calib/ITPCC_0"},

Detectors/TPC/base/include/TPCBase/CRUCalibHelpers.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,8 @@ constexpr float fixedSizeToFloat(uint32_t value)
9393
/// write values of map to fileName
9494
///
9595
template <typename DataMap>
96-
void writeValues(const std::string_view fileName, const DataMap& map, bool onlyFilled = false)
96+
void writeValues(std::ostream& str, const DataMap& map, bool onlyFilled = false)
9797
{
98-
std::ofstream str(fileName.data(), std::ofstream::out);
99-
10098
for (const auto& [linkInfo, data] : map) {
10199
if (onlyFilled) {
102100
if (!std::accumulate(data.begin(), data.end(), uint32_t(0))) {
@@ -117,6 +115,13 @@ void writeValues(const std::string_view fileName, const DataMap& map, bool onlyF
117115
}
118116
}
119117

118+
template <typename DataMap>
119+
void writeValues(const std::string_view fileName, const DataMap& map, bool onlyFilled = false)
120+
{
121+
std::ofstream str(fileName.data(), std::ofstream::out);
122+
writeValues(str, map, onlyFilled);
123+
}
124+
120125
template <class T>
121126
struct is_map {
122127
static constexpr bool value = false;
@@ -126,7 +131,8 @@ template <class Key, class Value>
126131
struct is_map<std::map<Key, Value>> {
127132
static constexpr bool value = true;
128133
};
129-
/// fill cal pad object from HV data map
134+
135+
/// fill cal pad object from HW data map
130136
/// TODO: Function to be tested
131137
template <typename DataMap, uint32_t SignificantBitsT = 0>
132138
typename std::enable_if_t<is_map<DataMap>::value, void>
@@ -251,6 +257,7 @@ o2::tpc::CalDet<float> getCalPad(const std::string_view fileName, const std::str
251257
/// \param minADCROCType can be either one value for all ROC types, or {IROC, OROC}, or {IROC, OROC1, OROC2, OROC3}
252258
std::unordered_map<std::string, CalPad> preparePedestalFiles(const CalPad& pedestals, const CalPad& noise, std::vector<float> sigmaNoiseROCType = {3, 3, 3, 3}, std::vector<float> minADCROCType = {2, 2, 2, 2}, float pedestalOffset = 0, bool onlyFilled = false, bool maskBad = true, float noisyChannelThreshold = 1.5, float sigmaNoiseNoisyChannels = 4, float badChannelThreshold = 6, bool fixedSize = false);
253259

260+
DataMapU32 getDataMap(const CalPad& calPad);
254261
} // namespace o2::tpc::cru_calib_helpers
255262

256263
#endif

Detectors/TPC/base/src/CRUCalibHelpers.cxx

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ std::unordered_map<std::string, CalPad> cru_calib_helpers::preparePedestalFiles(
130130
pedestalsThreshold["PedestalsPhys"] = CalPad("Pedestals");
131131
pedestalsThreshold["ThresholdMapPhys"] = CalPad("ThresholdMap");
132132

133-
auto& pedestalsCRU = pedestalsThreshold["Pedestals"];
134-
auto& thresholdCRU = pedestalsThreshold["ThresholdMap"];
135-
136133
// ===| prepare values |===
137134
for (size_t iroc = 0; iroc < pedestals.getData().size(); ++iroc) {
138135
const ROC roc(iroc);
@@ -179,7 +176,7 @@ std::unordered_map<std::string, CalPad> cru_calib_helpers::preparePedestalFiles(
179176
}
180177

181178
float noise = std::abs(rocNoise.getValue(ipad)); // it seems with the new fitting procedure, the noise can also be negative, since in gaus sigma is quadratic
182-
float noiseCorr = noise - (0.847601 + 0.031514 * traceLength);
179+
const float noiseCorr = noise - (0.847601 + 0.031514 * traceLength);
183180
if ((pedestal <= 0) || (pedestal > 150) || (noise <= 0) || (noise > 50)) {
184181
LOGP(info, "Bad pedestal or noise value in ROC {:2}, CRU {:3}, fec in CRU: {:2}, SAMPA: {}, channel: {:2}, pedestal: {:.4f}, noise {:.4f}", iroc, cruID, fecInPartition, sampa, sampaChannel, pedestal, noise);
185182
if (maskBad) {
@@ -230,3 +227,48 @@ std::unordered_map<std::string, CalPad> cru_calib_helpers::preparePedestalFiles(
230227

231228
return pedestalsThreshold;
232229
}
230+
231+
cru_calib_helpers::DataMapU32 cru_calib_helpers::getDataMap(const CalPad& calPad)
232+
{
233+
const auto& mapper = Mapper::instance();
234+
235+
DataMapU32 dataMap;
236+
237+
for (size_t iroc = 0; iroc < calPad.getData().size(); ++iroc) {
238+
const ROC roc(iroc);
239+
240+
const auto& calRoc = calPad.getCalArray(iroc);
241+
242+
const int padOffset = roc.isOROC() ? mapper.getPadsInIROC() : 0;
243+
244+
// skip empty ROCs
245+
if (!(std::abs(calRoc.getSum()) > 0)) {
246+
continue;
247+
}
248+
249+
// loop over pads
250+
for (size_t ipad = 0; ipad < calRoc.getData().size(); ++ipad) {
251+
const int globalPad = ipad + padOffset;
252+
const FECInfo& fecInfo = mapper.fecInfo(globalPad);
253+
const CRU cru = mapper.getCRU(roc.getSector(), globalPad);
254+
const uint32_t region = cru.region();
255+
const int cruID = cru.number();
256+
const int sampa = fecInfo.getSampaChip();
257+
const int sampaChannel = fecInfo.getSampaChannel();
258+
259+
const PartitionInfo& partInfo = mapper.getMapPartitionInfo()[cru.partition()];
260+
const int nFECs = partInfo.getNumberOfFECs();
261+
const int fecOffset = (nFECs + 1) / 2;
262+
const int fecInPartition = fecInfo.getIndex() - partInfo.getSectorFECOffset();
263+
const int dataWrapperID = fecInPartition >= fecOffset;
264+
const int globalLinkID = (fecInPartition % fecOffset) + dataWrapperID * 12;
265+
266+
const int hwChannel = getHWChannel(sampa, sampaChannel, region % 2);
267+
268+
const auto value = calRoc.getValue(ipad);
269+
dataMap[LinkInfo(cruID, globalLinkID)][hwChannel] = floatToFixedSize(value);
270+
}
271+
}
272+
273+
return dataMap;
274+
}

Detectors/TPC/calibration/include/TPCCalibration/IDCContainer.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,14 @@ struct SACDelta {
402402
std::array<IDCDelta<DataT>, SIDES> mSACDelta{};
403403
};
404404

405+
/// container to be written to CCDB
406+
template <typename DataT>
407+
struct SAC {
408+
SACZero mSACZero{};
409+
SACOne mSACOne{};
410+
SACDelta<DataT> mSACDelta{};
411+
};
412+
405413
struct FourierCoeffSAC {
406414
std::array<FourierCoeff, SIDES> mCoeff{};
407415
};

Detectors/TPC/calibration/macro/preparePedestalFiles.C

Lines changed: 8 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -60,72 +60,17 @@ void preparePedestalFiles(const std::string_view pedestalFile, std::string outpu
6060
f.GetObject("Noise", calNoise);
6161
}
6262

63-
DataMapU32 pedestalValues;
64-
DataMapU32 thresholdlValues;
65-
DataMapU32 pedestalValuesPhysics;
66-
DataMapU32 thresholdlValuesPhysics;
67-
6863
auto pedestalsThreshold = preparePedestalFiles(*calPedestal, *calNoise, sigmaNoiseROCType, minADCROCType, pedestalOffset, onlyFilled, maskBad, noisyChannelThreshold, sigmaNoiseNoisyChannels, badChannelThreshold);
6964

70-
// ===| prepare values |===
71-
for (size_t iroc = 0; iroc < calPedestal->getData().size(); ++iroc) {
72-
const ROC roc(iroc);
73-
74-
const auto& rocPedestal = calPedestal->getCalArray(iroc);
75-
const auto& rocNoise = calNoise->getCalArray(iroc);
76-
auto& rocOut = output.getCalArray(iroc);
65+
const auto& pedestals = pedestalsThreshold["Pedestals"];
66+
const auto& thresholds = pedestalsThreshold["ThresholdMap"];
67+
const auto& pedestalsPhys = pedestalsThreshold["PedestalsPhys"];
68+
const auto& thresholdsPhys = pedestalsThreshold["ThresholdMapPhys"];
7769

78-
const int padOffset = roc.isOROC() ? mapper.getPadsInIROC() : 0;
79-
80-
// skip empty
81-
if (!(std::abs(rocPedestal.getSum() + rocNoise.getSum()) > 0)) {
82-
continue;
83-
}
84-
85-
// loop over pads
86-
for (size_t ipad = 0; ipad < rocPedestal.getData().size(); ++ipad) {
87-
const int globalPad = ipad + padOffset;
88-
const FECInfo& fecInfo = mapper.fecInfo(globalPad);
89-
const CRU cru = mapper.getCRU(roc.getSector(), globalPad);
90-
const uint32_t region = cru.region();
91-
const int cruID = cru.number();
92-
const int sampa = fecInfo.getSampaChip();
93-
const int sampaChannel = fecInfo.getSampaChannel();
94-
// int globalLinkID = fecInfo.getIndex();
95-
96-
const PartitionInfo& partInfo = mapper.getMapPartitionInfo()[cru.partition()];
97-
const int nFECs = partInfo.getNumberOfFECs();
98-
const int fecOffset = (nFECs + 1) / 2;
99-
const int fecInPartition = fecInfo.getIndex() - partInfo.getSectorFECOffset();
100-
const int dataWrapperID = fecInPartition >= fecOffset;
101-
const int globalLinkID = (fecInPartition % fecOffset) + dataWrapperID * 12;
102-
103-
const auto pedestal = pedestalsThreshold["Pedestals"].getCalArray(iroc).getValue(ipad);
104-
const auto threshold = pedestalsThreshold["ThresholdMap"].getCalArray(iroc).getValue(ipad);
105-
const auto pedestalHighNoise = pedestalsThreshold["PedestalsPhys"].getCalArray(iroc).getValue(ipad);
106-
const auto thresholdHighNoise = pedestalsThreshold["ThresholdMapPhys"].getCalArray(iroc).getValue(ipad);
107-
108-
const int hwChannel = getHWChannel(sampa, sampaChannel, region % 2);
109-
// for debugging
110-
// printf("%4d %4d %4d %4d %4d: %u\n", cru.number(), globalLinkID, hwChannel, fecInfo.getSampaChip(), fecInfo.getSampaChannel(), getADCValue(pedestal));
111-
112-
// default thresholds
113-
const auto adcPedestal = floatToFixedSize(pedestal);
114-
const auto adcThreshold = floatToFixedSize(threshold);
115-
pedestalValues[LinkInfo(cruID, globalLinkID)][hwChannel] = adcPedestal;
116-
thresholdlValues[LinkInfo(cruID, globalLinkID)][hwChannel] = adcThreshold;
117-
118-
// higher thresholds for physics data taking
119-
const auto adcPedestalPhysics = floatToFixedSize(pedestalHighNoise);
120-
const auto adcThresholdPhysics = floatToFixedSize(thresholdHighNoise);
121-
pedestalValuesPhysics[LinkInfo(cruID, globalLinkID)][hwChannel] = adcPedestalPhysics;
122-
thresholdlValuesPhysics[LinkInfo(cruID, globalLinkID)][hwChannel] = adcThresholdPhysics;
123-
// for debugging
124-
// if(!(std::abs(pedestal - fixedSizeToFloat(adcPedestal)) <= 0.5 * 0.25)) {
125-
// printf("%4d %4d %4d %4d %4d: %u %.2f %.4f %.4f\n", cru.number(), globalLinkID, hwChannel, sampa, sampaChannel, adcPedestal, fixedSizeToFloat(adcPedestal), pedestal, pedestal - fixedSizeToFloat(adcPedestal));
126-
//}
127-
}
128-
}
70+
auto pedestalValues = getDataMap(pedestals);
71+
auto thresholdlValues = getDataMap(thresholds);
72+
auto pedestalValuesPhysics = getDataMap(pedestalsPhys);
73+
auto thresholdlValuesPhysics = getDataMap(thresholdsPhys);
12974

13075
// text files
13176
const auto outFilePedestalTXT(outputDir + "/pedestal_values.txt");

Detectors/TPC/calibration/src/CalibdEdx.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,8 @@ void CalibdEdx::finalize(const bool useGausFits)
549549
fitter.SetFormula("1");
550550
mCalib.setDims(0);
551551
}
552-
LOGP(info, "Fitting {}D dE/dx correction for GEM stacks with gaussian fits {}", mCalib.getDims(), useGausFits);
552+
LOGP(info, "Fitting {}D dE/dx correction for GEM stacks with gaussian fits {}, minStackEntries {}, m2DThreshold {}, m1DThreshold {}, mFitSnp {}",
553+
mCalib.getDims(), useGausFits, entries, m2DThreshold, m1DThreshold, mFitSnp);
553554

554555
// if entries below minimum sector threshold, integrate all sectors
555556
if (mCalib.getDims() == 0 || entries >= mSectorThreshold) {

0 commit comments

Comments
 (0)