Project
Loading...
Searching...
No Matches
NoiseSlotCalibrator.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
13
15
16#include <fairlogger/Logger.h>
17#include "TFile.h"
21
22namespace o2
23{
24using Slot = calibration::TimeSlot<o2::itsmft::NoiseMap>;
25
26namespace mft
27{
29 gsl::span<const o2::itsmft::Digit> const& digits,
30 gsl::span<const o2::itsmft::ROFRecord> const& rofs)
31{
32 LOG(detail) << "Processing TF# " << nTF;
33
34 auto& slotTF = getSlotForTF(nTF);
35 auto& noiseMap = *(slotTF.getContainer());
36
37 for (const auto& rof : rofs) {
38 auto digitsInFrame = rof.getROFData(digits);
39 for (const auto& d : digitsInFrame) {
40 auto id = d.getChipIndex();
41 auto row = d.getRow();
42 auto col = d.getColumn();
43
44 noiseMap.increaseNoiseCount(id, row, col);
45 }
46 }
47 noiseMap.addStrobes(rofs.size());
48 mNumberOfStrobes += rofs.size();
49 return hasEnoughData(slotTF);
50}
51
53 gsl::span<const o2::itsmft::CompClusterExt> const& clusters,
54 gsl::span<const unsigned char> const& patterns,
55 gsl::span<const o2::itsmft::ROFRecord> const& rofs)
56{
57 LOG(detail) << "Processing TF# " << nTF;
58
59 auto& slotTF = getSlotForTF(nTF);
60 auto& noiseMap = *(slotTF.getContainer());
61
62 auto pattIt = patterns.begin();
63 for (const auto& rof : rofs) {
64 auto clustersInFrame = rof.getROFData(clusters);
65 for (const auto& c : clustersInFrame) {
66 if (c.getPatternID() != o2::itsmft::CompCluster::InvalidPatternID) {
67 // For the noise calibration, we use "pass1" clusters...
68 continue;
69 }
70 o2::itsmft::ClusterPattern patt(pattIt);
71
72 auto id = c.getSensorID();
73 auto row = c.getRow();
74 auto col = c.getCol();
75 auto colSpan = patt.getColumnSpan();
76 auto rowSpan = patt.getRowSpan();
77
78 // Fast 1-pixel calibration
79 if ((rowSpan == 1) && (colSpan == 1)) {
80 noiseMap.increaseNoiseCount(id, row, col);
81 continue;
82 }
83
84 // All-pixel calibration
85 auto nBits = rowSpan * colSpan;
86 int ic = 0, ir = 0;
87 for (unsigned int i = 2; i < patt.getUsedBytes() + 2; i++) {
88 unsigned char tempChar = patt.getByte(i);
89 int s = 128; // 0b10000000
90 while (s > 0) {
91 if ((tempChar & s) != 0) {
92 noiseMap.increaseNoiseCount(id, row + ir, col + ic);
93 }
94 ic++;
95 s >>= 1;
96 if ((ir + 1) * ic == nBits) {
97 break;
98 }
99 if (ic == colSpan) {
100 ic = 0;
101 ir++;
102 }
103 }
104 if ((ir + 1) * ic == nBits) {
105 break;
106 }
107 }
108 }
109 }
110 noiseMap.addStrobes(rofs.size());
111 mNumberOfStrobes += rofs.size();
112 return hasEnoughData(slotTF);
113}
114
115// Functions overloaded from the calibration framework
116bool NoiseSlotCalibrator::process(calibration::TFType tf, const gsl::span<const o2::itsmft::CompClusterExt> data)
117{
118 LOG(warning) << "Only 1-pix noise calibraton is possible !";
120}
121
122// Functions required by the calibration framework
123
125{
126 auto& cont = getSlots();
127 auto& slot = front ? cont.emplace_front(tstart, tend) : cont.emplace_back(tstart, tend);
128 slot.setContainer(std::make_unique<o2::itsmft::NoiseMap>(936));
129 return slot;
130}
131
133{
134 return slot.getContainer()->getNumberOfStrobes() > mMinROFs ? true : false;
135}
136
138{
140 LOG(info) << "Number of processed strobes is " << map->getNumberOfStrobes();
141 map->applyProbThreshold(mProbabilityThreshold, map->getNumberOfStrobes(), mProbRelErr);
142}
143
144} // namespace mft
145} // namespace o2
Definition of the ITSMFT digit.
int32_t i
Definition of the ITSMFT ROFrame (trigger) record.
uint32_t col
Definition RawData.h:4
uint32_t c
Definition RawData.h:2
const Container * getContainer() const
Definition TimeSlot.h:53
int getRowSpan() const
Returns the number of rows.
int getColumnSpan() const
Returns the number of columns.
unsigned char getByte(int n) const
Returns a specific byte of the pattern.
int getUsedBytes() const
Returns the number of bytes used for the pattern.
static constexpr unsigned short InvalidPatternID
Definition CompCluster.h:46
NoiseMap class for the ITS and MFT.
Definition NoiseMap.h:39
long getNumberOfStrobes() const
Definition NoiseMap.h:222
void applyProbThreshold(float t, long int n, float relErr=0.2f, int minChipID=0, int maxChipID=24119)
Definition NoiseMap.h:105
bool process(calibration::TFType tf, const gsl::span< const o2::itsmft::CompClusterExt > data) final
void finalizeSlot(Slot &slot) final
Slot & emplaceNewSlot(bool, calibration::TFType, calibration::TFType) final
bool processTimeFrame(calibration::TFType tf, gsl::span< const o2::itsmft::Digit > const &digits, gsl::span< const o2::itsmft::ROFRecord > const &rofs)
bool hasEnoughData(const Slot &slot) const final
GLboolean * data
Definition glcorearb.h:298
uint32_t TFType
Definition TimeSlot.h:29
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::unique_ptr< GPUReconstructionTimeframe > tf
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
o2::InteractionRecord ir(0, 0)
std::vector< Cluster > clusters
std::vector< Digit > digits
std::vector< int > row