|
12 | 12 | #include <fstream> |
13 | 13 | #include <iostream> |
14 | 14 | #include <numeric> |
| 15 | +#include <vector> |
15 | 16 |
|
| 17 | +#include "TPCBase/Utils.h" |
16 | 18 | #include "TROOT.h" |
17 | 19 |
|
18 | 20 | #include "Framework/Logger.h" |
@@ -102,10 +104,26 @@ void cru_calib_helpers::debugDiff(std::string_view file1, std::string_view file2 |
102 | 104 | } |
103 | 105 | } |
104 | 106 |
|
105 | | -std::unordered_map<std::string, CalPad> cru_calib_helpers::preparePedestalFiles(const CalPad& pedestals, const CalPad& noise, float sigmaNoise, float minADC, float pedestalOffset, bool onlyFilled, bool maskBad, float noisyChannelThreshold, float sigmaNoiseNoisyChannels, float badChannelThreshold, bool fixedSize) |
| 107 | +std::unordered_map<std::string, CalPad> cru_calib_helpers::preparePedestalFiles(const CalPad& pedestals, const CalPad& noise, std::vector<float> sigmaNoiseROCType, std::vector<float> minADCROCType, float pedestalOffset, bool onlyFilled, bool maskBad, float noisyChannelThreshold, float sigmaNoiseNoisyChannels, float badChannelThreshold, bool fixedSize) |
106 | 108 | { |
107 | 109 | const auto& mapper = Mapper::instance(); |
108 | 110 |
|
| 111 | + auto expandVector = [](std::vector<float>& vec, const std::string name) { |
| 112 | + if (vec.size() == 1) { |
| 113 | + vec.resize(4); |
| 114 | + std::fill_n(&vec[1], 3, vec[0]); |
| 115 | + } else if (vec.size() == 2) { |
| 116 | + vec.resize(4); |
| 117 | + std::fill_n(&vec[2], 2, vec[1]); |
| 118 | + } else if (vec.size() != 4) { |
| 119 | + LOGP(fatal, "{} definition must be either one value for all ROC types, or {{IROC, OROC}}, or {{IROC, OROC1, OROC2, OROC3}}", name); |
| 120 | + } |
| 121 | + LOGP(info, "Using {} = {{{}}}", name, utils::elementsToString(vec)); |
| 122 | + }; |
| 123 | + |
| 124 | + expandVector(sigmaNoiseROCType, "sigmaNoiseROCType"); |
| 125 | + expandVector(minADCROCType, "minADCROCType"); |
| 126 | + |
109 | 127 | std::unordered_map<std::string, CalPad> pedestalsThreshold; |
110 | 128 | pedestalsThreshold["Pedestals"] = CalPad("Pedestals"); |
111 | 129 | pedestalsThreshold["ThresholdMap"] = CalPad("ThresholdMap"); |
@@ -147,6 +165,9 @@ std::unordered_map<std::string, CalPad> cru_calib_helpers::preparePedestalFiles( |
147 | 165 | const int fecInPartition = fecInfo.getIndex() - partInfo.getSectorFECOffset(); |
148 | 166 | // const int dataWrapperID = fecInPartition >= fecOffset; |
149 | 167 | // const int globalLinkID = (fecInPartition % fecOffset) + dataWrapperID * 12; |
| 168 | + const int rocType = roc.isIROC() ? 0 : cru.partition() - 1; |
| 169 | + const float sigmaNoise = sigmaNoiseROCType[rocType]; |
| 170 | + const float minADC = minADCROCType[rocType]; |
150 | 171 |
|
151 | 172 | const auto traceLength = traceLengths[ipad]; |
152 | 173 |
|
@@ -174,6 +195,7 @@ std::unordered_map<std::string, CalPad> cru_calib_helpers::preparePedestalFiles( |
174 | 195 | float threshold = (noise > 0) ? std::max(sigmaNoise * noise, minADC) : 0; |
175 | 196 | threshold = std::min(threshold, 1023.f); |
176 | 197 | float thresholdHighNoise = (noiseCorr > noisyChannelThreshold) ? std::max(sigmaNoiseNoisyChannels * noise, minADC) : threshold; |
| 198 | + thresholdHighNoise = std::min(thresholdHighNoise, 1023.f); |
177 | 199 |
|
178 | 200 | float pedestalHighNoise = pedestal; |
179 | 201 | if (noiseCorr > badChannelThreshold) { |
|
0 commit comments