94 std::vector<float> meanSample[Tile::MAX_GAIN];
95 std::vector<float> meanSampleChannel[Tile::MAX_GAIN];
97 std::vector<float> meanSampleProd[Tile::MAX_GAIN];
98 std::vector<float> meanSampleProdChannel1[Tile::MAX_GAIN];
99 std::vector<float> meanSampleProdChannel2[Tile::MAX_GAIN];
104 const uint32_t* cispar = dqStatus->
cispar();
110 if (digitsCollection->empty() )
continue;
112 HWIdentifier adc_id = digitsCollection->front()->adc_HWID();
116 int partition = ros - 1;
118 const std::vector<uint32_t>& headerWordsLow = digitsCollection->getFragChipHeaderWords();
119 const std::vector<uint32_t>& headerWordsHigh = digitsCollection->getFragChipHeaderWordsHigh();
120 std::vector<std::reference_wrapper<const std::vector<uint32_t>>> headerWordsAll{headerWordsLow};
121 if (headerWordsHigh.empty()) {
123 headerWordsAll.push_back(headerWordsLow);
125 headerWordsAll.push_back(headerWordsHigh);
128 std::vector<std::vector<bool>> corruptedData(Tile::MAX_GAIN, std::vector<bool>(
MAX_DMU));
129 uint32_t fragStatus = digitsCollection->getFragStatus();
135 uint32_t rodBCID = digitsCollection->getRODBCID();
136 checkBCID(headerWordsAll, rodBCID, ros, drawer);
138 bool isCalibMode = (dqStatus->
calibMode() == 1);
141 int nDMU = headerWordsLow.size();
142 uint32_t crc32 = digitsCollection->getFragCRC();
143 uint32_t crcMask = digitsCollection->getFragDMUMask();
144 checkCRC(isCalibMode, crc32, crcMask, nDMU, ros, drawer);
153 charge = cispar[6] * cispar[7] * (2. * 4.096 / 4095.);
155 charge = cispar[6] * cispar[7] * (2. * 4.096 / 1023.);
158 const TileDigits* moduleDigits[Tile::MAX_CHAN][Tile::MAX_GAIN] = {{
nullptr}};
160 for (
const TileDigits* tile_digits : *digitsCollection) {
162 adc_id = tile_digits->adc_HWID();
166 if (corruptedData[adc][channel / 3]) {
170 moduleDigits[channel][adc] = tile_digits;
172 std::string channelGainSuffix =
"_" + std::to_string(channel) +
"_" + std::to_string(adc);
174 const std::vector<float>& digits = tile_digits->samples();
175 unsigned int nSamples = digits.size();
180 double pedestal = digits[0];
192 double sampleMean = 0.0;
193 double sampleRMS = 0.0;
195 for (
double sample : digits) {
196 sampleMean += sample;
197 sampleRMS += sample * sample;
200 fill(
"TileDigitsOverflow", monCharge);
204 sampleMean /= nSamples;
205 sampleRMS = sampleRMS / nSamples - sampleMean * sampleMean;
206 sampleRMS = (sampleRMS > 0.0) ? sqrt(sampleRMS * nSamples / (nSamples - 1)) : 0.0;
209 meanSample[adc].push_back(sampleMean);
210 meanSampleChannel[adc].push_back(channel);
218 || (cispar[6] > 0. && (adc < 1 ||
charge < 12.))) {
228 std::vector<int> sampleNumbers(nSamples);
229 std::iota(sampleNumbers.begin(), sampleNumbers.end(), 0);
236 int evtMod32 = (ctx.evt() + 1) % 32;
245 for (
unsigned int gain = 0; gain < Tile::MAX_GAIN; ++gain) {
246 if (!meanSampleChannel[gain].
empty()) {
247 auto monChannel =
Monitored::Collection(
"channel_" + Tile::getDrawerString(ros, drawer), meanSampleChannel[gain]);
248 auto monMeanSample =
Monitored::Collection(
"meanSample_" + Tile::getDrawerString(ros, drawer), meanSample[gain]);
251 for (
int channel1 : meanSampleChannel[gain]) {
252 const std::vector<float>& digits1 = moduleDigits[channel1][gain]->
samples();
253 for (
int channel2 : meanSampleChannel[gain]) {
254 const std::vector<float>& digits2 = moduleDigits[channel2][gain]->
samples();
255 double sampleProdMean = 0.;
256 unsigned int nSamples = digits1.size();
257 for (
unsigned int i = 0; i < nSamples; ++i) {
258 sampleProdMean += digits1[i] * digits2[i];
260 sampleProdMean /= nSamples;
261 meanSampleProd[gain].push_back(sampleProdMean);
262 meanSampleProdChannel1[gain].push_back(channel1);
263 meanSampleProdChannel2[gain].push_back(channel2);
266 auto monChannel1 =
Monitored::Collection(
"channel1_" + Tile::getDrawerString(ros, drawer), meanSampleProdChannel1[gain]);
267 auto monChannel2 =
Monitored::Collection(
"channel2_" + Tile::getDrawerString(ros, drawer), meanSampleProdChannel2[gain]);
268 auto monMeanSampleProd =
Monitored::Collection(
"meanSampleProd_" + Tile::getDrawerString(ros, drawer), meanSampleProd[gain]);
271 meanSample[gain].clear();
272 meanSampleChannel[gain].clear();
274 meanSampleProd[gain].clear();
275 meanSampleProdChannel1[gain].clear();
276 meanSampleProdChannel2[gain].clear();
289 fill(
"TileDigitsMonExecuteTime", timer);
291 return StatusCode::SUCCESS;
295 int nDMU,
int ros,
int drawer)
const {
308 int partition = ros - 1;
312 int dmuFE_EB[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 12, 13, 8, 9, 10, 11, 14, 15 };
313 int dmuFE_EB_special[16] = { 11, 0, 1, 2, 3, 4, 5, 6, 12, 13, 7, 8, 9, 10, 14, 15 };
316 uint32_t crc0 = crc32 & 0xFFFF;
317 uint32_t crc1 = crc32 >> 16;
319 int crcGlobal = (crc32 == 0) ? 0 : (crc0 == crc1) ? 1 : 2;
326 for (
int dmu = 0; dmu < nDMU; ++dmu) {
342 for (
int dmu = 0; dmu < nDMU; ++dmu) {
346 }
else if (crcMask == 0xFFFFFFFF) {
348 for (
int dmu = 0; dmu < nDMU; ++dmu) {
353 uint32_t fe_crc = crcMask & 0xFFFF;
354 uint32_t rod_crc = crcMask >> 16;
355 for (
int dmu = 0; dmu < nDMU; ++dmu) {
358 if ((fe_crc >> dmu & 0x1) == 0x0) {
363 if ((ros == 3 && drawer == 14) || (ros == 4 && drawer == 17)) {
365 if ((fe_crc >> dmuFE_EB_special[dmu] & 0x1) == 0x0) {
369 if ((fe_crc >> dmuFE_EB[dmu] & 0x1) == 0x0) {
374 if ((rod_crc >> dmu & 0x1) == 0x0) {