Project
Loading...
Searching...
No Matches
NoiseCalibrator.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"
22
23namespace o2
24{
25namespace mft
26{
28 gsl::span<const o2::itsmft::Digit> const& digits,
29 gsl::span<const o2::itsmft::ROFRecord> const& rofs)
30{
31 static int nTF = 0;
32 LOG(detail) << "Processing TF# " << nTF++;
33
34 for (const auto& rof : rofs) {
35 auto digitsInFrame = rof.getROFData(digits);
36 for (const auto& d : digitsInFrame) {
37 auto id = d.getChipIndex();
38 auto row = d.getRow();
39 auto col = d.getColumn();
40
41 mNoiseMap.increaseNoiseCount(id, row, col);
42 }
43 }
44 mNumberOfStrobes += rofs.size();
45 return (mNumberOfStrobes > mMinROFs) ? true : false;
46}
47
49 gsl::span<const o2::itsmft::CompClusterExt> const& clusters,
50 gsl::span<const unsigned char> const& patterns,
51 gsl::span<const o2::itsmft::ROFRecord> const& rofs)
52{
53 static int nTF = 0;
54 LOG(detail) << "Processing TF# " << nTF++;
55
56 auto pattIt = patterns.begin();
57 for (const auto& rof : rofs) {
58 auto clustersInFrame = rof.getROFData(clusters);
59 for (const auto& c : clustersInFrame) {
60 auto pattID = c.getPatternID();
62 auto row = c.getRow();
63 auto col = c.getCol();
64 if (mDict->getSize() == 0) {
66 patt.acquirePattern(pattIt);
67 } else {
68 LOG(fatal) << "Clusters contain pattern IDs, but no dictionary is provided...";
69 }
70 } else if (pattID == o2::itsmft::CompCluster::InvalidPatternID) {
71 patt.acquirePattern(pattIt);
72 } else if (mDict->isGroup(pattID)) {
73 patt.acquirePattern(pattIt);
74 float xCOG = 0., zCOG = 0.;
75 patt.getCOG(xCOG, zCOG); // for grouped patterns the reference pixel is at COG
76 row -= round(xCOG);
77 col -= round(zCOG);
78 } else {
79 patt = mDict->getPattern(pattID);
80 }
81 auto id = c.getSensorID();
82 auto colSpan = patt.getColumnSpan();
83 auto rowSpan = patt.getRowSpan();
84
85 // Fast 1-pixel calibration
86 if ((rowSpan == 1) && (colSpan == 1)) {
87 mNoiseMap.increaseNoiseCount(id, row, col);
88 continue;
89 }
90
91 // All-pixel calibration
92 auto nBits = rowSpan * colSpan;
93 int ic = 0, ir = 0;
94 for (unsigned int i = 2; i < patt.getUsedBytes() + 2; i++) {
95 unsigned char tempChar = patt.getByte(i);
96 int s = 128; // 0b10000000
97 while (s > 0) {
98 if ((tempChar & s) != 0) {
99 mNoiseMap.increaseNoiseCount(id, row + ir, col + ic);
100 }
101 ic++;
102 s >>= 1;
103 if ((ir + 1) * ic == nBits) {
104 break;
105 }
106 if (ic == colSpan) {
107 ic = 0;
108 ir++;
109 }
110 }
111 if ((ir + 1) * ic == nBits) {
112 break;
113 }
114 }
115 }
116 }
117 mNumberOfStrobes += rofs.size();
118 return (mNumberOfStrobes > mMinROFs) ? true : false;
119}
120
122{
123 LOG(info) << "Number of processed strobes is " << mNumberOfStrobes;
124 mNoiseMap.applyProbThreshold(mProbabilityThreshold, mNumberOfStrobes);
125 mNoiseMap.print();
126}
127
128} // namespace mft
129} // namespace o2
Definition of the ITSMFT compact cluster.
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
int getRowSpan() const
Returns the number of rows.
void acquirePattern(iterator &pattIt)
int getColumnSpan() const
Returns the number of columns.
static int getCOG(int rowSpan, int colSpan, const unsigned char patt[MaxPatternBytes], float &xCOG, float &zCOG)
Static: Compute pattern's COG position. Returns the number of fired pixels.
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
void increaseNoiseCount(int chip, int row, int col)
Definition NoiseMap.h:66
void applyProbThreshold(float t, long int n, float relErr=0.2f, int minChipID=0, int maxChipID=24119)
Definition NoiseMap.h:105
int getSize() const
Returns the number of elements in the dicionary;.
const ClusterPattern & getPattern(int n) const
Returns the pattern of the topology.
bool isGroup(int n) const
Returns true if the element corresponds to a group of rare topologies.
bool processTimeFrame(calibration::TFType tf, gsl::span< const o2::itsmft::Digit > const &digits, gsl::span< const o2::itsmft::ROFRecord > const &rofs)
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