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"
20
21namespace o2
22{
24
25namespace its
26{
27bool NoiseSlotCalibrator::processTimeFrame(gsl::span<const o2::itsmft::CompClusterExt> const& clusters,
28 gsl::span<const unsigned char> const& patterns,
29 gsl::span<const o2::itsmft::ROFRecord> const& rofs)
30{
31 calibration::TFType nTF = rofs[0].getBCData().orbit / 256;
32 LOG(detail) << "Processing TF# " << nTF;
33
34 auto& slotTF = getSlotForTF(nTF);
35 auto& noiseMap = *(slotTF.getContainer());
36
37 auto pattIt = patterns.begin();
38 for (const auto& rof : rofs) {
39 auto clustersInFrame = rof.getROFData(clusters);
40 for (const auto& c : clustersInFrame) {
41 auto pattID = c.getPatternID();
43 auto row = c.getRow();
44 auto col = c.getCol();
45 if (mDict.getSize() == 0) {
47 patt.acquirePattern(pattIt);
48 } else {
49 LOG(fatal) << "Clusters contain pattern IDs, but no dictionary is provided...";
50 }
51 } else if (pattID == o2::itsmft::CompCluster::InvalidPatternID) {
52 patt.acquirePattern(pattIt);
53 } else if (mDict.isGroup(pattID)) {
54 patt.acquirePattern(pattIt);
55 float xCOG = 0., zCOG = 0.;
56 patt.getCOG(xCOG, zCOG); // for grouped patterns the reference pixel is at COG
57 row -= round(xCOG);
58 col -= round(zCOG);
59 } else {
60 patt = mDict.getPattern(pattID);
61 }
62 auto id = c.getSensorID();
63 auto colSpan = patt.getColumnSpan();
64 auto rowSpan = patt.getRowSpan();
65
66 // Fast 1-pixel calibration
67 if ((rowSpan == 1) && (colSpan == 1)) {
68 noiseMap.increaseNoiseCount(id, row, col);
69 continue;
70 }
71 if (m1pix) {
72 continue;
73 }
74
75 // All-pixel calibration
76 auto nBits = rowSpan * colSpan;
77 int ic = 0, ir = 0;
78 for (unsigned int i = 2; i < patt.getUsedBytes() + 2; i++) {
79 unsigned char tempChar = patt.getByte(i);
80 int s = 128; // 0b10000000
81 while (s > 0) {
82 if ((tempChar & s) != 0) {
83 noiseMap.increaseNoiseCount(id, row + ir, col + ic);
84 }
85 ic++;
86 s >>= 1;
87 if ((ir + 1) * ic == nBits) {
88 break;
89 }
90 if (ic == colSpan) {
91 ic = 0;
92 ir++;
93 }
94 }
95 if ((ir + 1) * ic == nBits) {
96 break;
97 }
98 }
99 }
100 }
101
102 noiseMap.addStrobes(rofs.size());
103 mNumberOfStrobes += rofs.size();
104 return hasEnoughData(slotTF);
105}
106
107// Functions overloaded from the calibration framework
108bool NoiseSlotCalibrator::process(const gsl::span<const o2::itsmft::CompClusterExt> data)
109{
110 LOG(warning) << "Only 1-pix noise calibraton is possible !";
112}
113
114// Functions required by the calibration framework
115
117{
118 auto& cont = getSlots();
119 auto& slot = front ? cont.emplace_front(tstart, tend) : cont.emplace_back(tstart, tend);
120 slot.setContainer(std::make_unique<o2::itsmft::NoiseMap>(24120));
121 return slot;
122}
123
125{
126 return slot.getContainer()->getNumberOfStrobes() > mMinROFs ? true : false;
127}
128
130{
132 LOG(info) << "Number of processed strobes is " << map->getNumberOfStrobes();
133 map->applyProbThreshold(mProbabilityThreshold, map->getNumberOfStrobes(), mProbRelErr);
134}
135
136} // namespace its
137} // namespace o2
int32_t i
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
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
bool processTimeFrame(gsl::span< const o2::itsmft::CompClusterExt > const &clusters, gsl::span< const unsigned char > const &patterns, gsl::span< const o2::itsmft::ROFRecord > const &rofs)
bool process(const gsl::span< const o2::itsmft::CompClusterExt > data)
bool hasEnoughData(const Slot &slot) const final
Slot & emplaceNewSlot(bool, calibration::TFType, calibration::TFType) final
void finalizeSlot(Slot &slot) final
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
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
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.
return true
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
o2::InteractionRecord ir(0, 0)
std::vector< Cluster > clusters
std::vector< int > row