Project
Loading...
Searching...
No Matches
CommonModeCorrection.h
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
15
16#ifndef AliceO2_TPC_CommonModeCorrection_H_
17#define AliceO2_TPC_CommonModeCorrection_H_
18
19#include <gsl/span>
20#include <string_view>
21#include <vector>
22
24#include "TPCBase/FEEConfig.h"
25
26namespace o2::tpc
27{
28
34{
35 public:
36 struct CMdata {
37 std::vector<float> adcValues;
38 std::vector<float> cmKValues;
39 std::vector<float> pedestals;
40
41 void resize(size_t newSize)
42 {
43 adcValues.resize(newSize);
44 cmKValues.resize(newSize);
45 pedestals.resize(newSize);
46 }
47
48 void clear()
49 {
50 adcValues.clear();
51 cmKValues.clear();
52 pedestals.clear();
53 }
54 };
55
67
68 struct CMDebug {
69 std::vector<uint8_t> nPadsOk{};
70 std::vector<uint16_t> adcDist{};
71 };
72
73 using CalPadMapType = std::unordered_map<std::string, CalPad>;
74
81 CMInfo getCommonMode(gsl::span<const float> values, gsl::span<const float> cmKValues, gsl::span<const float> pedestals, CMDebug* cmDebug = nullptr) const;
82 CMInfo getCommonMode(const std::vector<float>& values, const std::vector<float>& cmKValues, const std::vector<float>& pedestals) const { return getCommonMode(gsl::span(values), gsl::span(cmKValues), gsl::span(pedestals)); }
83
84 CMInfo getCommonMode(const CMdata& cmData) const { return getCommonMode(std::span(cmData.adcValues), std::span(cmData.cmKValues), std::span(cmData.pedestals)); }
85
86 void setNPadsCompRandom(int n) { mNPadsCompRamdom = n; }
87 int getNPadsCompRandom() const { return mNPadsCompRamdom; }
88
89 void setNPadsCompMin(int n) { mNPadsCompMin = n; }
90 int getNPadsCompMin() const { return mNPadsCompMin; }
91
93 void setNPadsMinCM(int n) { mNPadsMinCM = n; }
94 int getNPadsMinCM() const { return mNPadsMinCM; }
95
96 void setQEmpty(float q) { mQEmpty = q; }
97 float getQEmpty() const { return mQEmpty; }
98
99 void setQComp(float q) { mQComp = q; }
100 float getQComp() const { return mQComp; }
101
103 void setQCompScaleThreshold(float q) { mQCompScaleThreshold = q; }
104 float getQCompScaleThreshold() const { return mQCompScaleThreshold; }
105
107 void setQCompScale(float q) { mQCompScale = q; }
108 float getQCompScale() const { return mQCompScale; }
109
111 void setSumPosThreshold(float threshold) { mSumPosThreshold = threshold; }
112 float getSumPosThreshold() const { return mSumPosThreshold; }
113
115 void setOccupancyThreshold(float threshold) { mOccupancyThreshold = threshold; }
116 float getOccupancyThreshold() const { return mOccupancyThreshold; }
117
119 void setPadMaps(CalPadMapType& padMaps) { mPadMaps = padMaps; }
120
125 void loadCalPad(std::string_view fileName, std::string_view nameInFile, std::string_view namePadMap = "");
126
128 void loadCMkValues(std::string_view fileName) { loadCalPad(fileName, "CMkValues"); }
129
131 void loadPedestals(std::string_view fileName) { loadCalPad(fileName, "Pedestals"); }
132
134 void setCalPad(const CalPad& calPad, std::string_view name) { mPadMaps[name.data()] = calPad; }
135
137 float getCMkValue(int sector, int row, int pad) { return mPadMaps["CMkValues"].getValue(sector, row, pad); }
138
140 float getPedestalValue(int sector, int row, int pad) { return mPadMaps["Pedestals"].getValue(sector, row, pad); }
141
143 void
145
146 CMdata collectCMdata(const std::vector<Digit>& digits, int cru, int timeBin);
147
148 int getCommonMode(std::vector<Digit>& digits, std::vector<std::vector<CMInfo>>& cmValues, bool negativeOnly = false, bool hasInjectedCMValue = false, std::vector<std::vector<CMDebug>>* cmDebug = nullptr, int minTimeBin = -1, int maxTimeBin = -1) const;
149
154 int correctDigits(std::vector<Digit>& digits, std::vector<std::vector<CMInfo>>& cmValues, bool negativeOnly = false, bool hasInjectedCMValue = false, std::vector<std::vector<CMDebug>>* cmDebug = nullptr, int minTimeBin = -1, int maxTimeBin = -1) const;
155
156 void correctDigits(std::string_view digiFileIn, Long64_t maxEntries = -1, std::string_view digitFileOut = "tpcdigit_cmcorr.root", std::string_view cmFileOut = "CommonModeValues.root", bool negativeOnly = false, int nThreads = 1, bool writeOnlyCM = false, bool writeDebug = false, bool hasInjectedCMValue = false, int minTimeBin = -1, int maxTimeBin = -1);
157
158 void limitKFactorPrecision(bool limit = true) { mLimitKFactor = limit; }
159 void limitPedestalPrecision(bool limit = true) { mLimitPedestal = limit; }
160
163 static void setNThreads(const int nThreads) { sNThreads = nThreads; }
164
166 static int getNThreads() { return sNThreads; }
167
169 void addCommonMode(float cm) { mArtificialCM = cm; }
170
171 void setCorrectOutputForPedestal(bool corret = true) { mCorrectOutputForPedestal = corret; }
172 bool getCorrectOutputForPedestal() const { return mCorrectOutputForPedestal; }
173
175 void setAddSubthreshold(bool addSubthreshold) { mSubthreshold = addSubthreshold; }
176 bool getAddSubthreshold() const { return mSubthreshold; }
177
178 static float decodeInjectedCMValue(float lower, float upper);
179
180 private:
181 inline static int sNThreads{1};
182 int mNPadsCompRamdom{10};
183 int mNPadsCompMin{7};
184 int mNPadsMinCM{0};
185 float mQEmpty{2};
186 float mQComp{1};
187 float mQCompScaleThreshold{0};
188 float mQCompScale{0};
189 float mSumPosThreshold{2};
190 float mOccupancyThreshold{3};
191 bool mLimitKFactor{false};
192 bool mLimitPedestal{false};
193 int mSubthreshold{0};
194 float mArtificialCM{};
195 bool mCorrectOutputForPedestal{false};
196
197 CalPadMapType mPadMaps;
198
199 struct pos {
200 int row;
201 int pad;
202 };
203
204 // positions of lower words per CRU in sector
205 const std::array<pos, 10> mCMInjectIDLower{
206 // row0 pad0 row1 pad1
207 pos{0, 2},
208 pos{20, 1},
209 pos{32, 2},
210 pos{51, 1},
211 pos{63, 1},
212 pos{84, 1},
213 pos{97, 1},
214 pos{116, 2},
215 pos{127, 2},
216 pos{142, 0},
217 };
218
219 // positions of upper words per CRU in sector
220 const std::array<pos, 10> mCMInjectIDUpper{
221 // row0 pad0 row1 pad1
222 pos{0, 3},
223 pos{20, 3},
224 pos{32, 3},
225 pos{51, 3},
226 pos{63, 2},
227 pos{84, 4},
228 pos{97, 2},
229 pos{115, 5},
230 pos{127, 3},
231 pos{142, 4},
232 };
233
238 float getCalPadValue(const std::string calibName, int icru, int pad) const;
239
240 bool padMapExists(const std::string& calibName);
241
242 ClassDefNV(CommonModeCorrection, 2);
243};
244
245} // namespace o2::tpc
246#endif
Definition of the TPC Digit.
Frontend electronics configuration values.
unsigned short int uint16_t
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual sector
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in cm(in case phi of track=lorentz angle)") AddOptionRTC(trkltResVsTanPhiMisalign
double lower[3]
double upper[3]
uint16_t pos
Definition RawData.h:3
float getPedestalValue(int sector, int row, int pad)
pedestal value
void setPadMaps(CalPadMapType &padMaps)
Pad maps loaded from FEEConfig.
CMdata collectCMdata(const std::vector< Digit > &digits, int cru, int timeBin)
void loadPedestals(std::string_view fileName)
load Pedestals from file, assuming it is stored under the name "Pedestals
void setCalPad(const CalPad &calPad, std::string_view name)
Custom setting of CalPad, overwriting what was set in mPadMaps.
CMInfo getCommonMode(gsl::span< const float > values, gsl::span< const float > cmKValues, gsl::span< const float > pedestals, CMDebug *cmDebug=nullptr) const
void addCommonMode(float cm)
add artificial common mode, only works when using the 'correctDigits' function
int correctDigits(std::vector< Digit > &digits, std::vector< std::vector< CMInfo > > &cmValues, bool negativeOnly=false, bool hasInjectedCMValue=false, std::vector< std::vector< CMDebug > > *cmDebug=nullptr, int minTimeBin=-1, int maxTimeBin=-1) const
void loadCalPad(std::string_view fileName, std::string_view nameInFile, std::string_view namePadMap="")
float getCMkValue(int sector, int row, int pad)
cmk value
void setNPadsMinCM(int n)
Minimum number of pads required in the CM calculation to be used for digit correction.
void setOccupancyThreshold(float threshold)
Threshold above which a signal is considered for the occupancy.
void setAddSubthreshold(bool addSubthreshold)
Add zeros for pads without signal.
static void setNThreads(const int nThreads)
CMInfo getCommonMode(const std::vector< float > &values, const std::vector< float > &cmKValues, const std::vector< float > &pedestals) const
static float decodeInjectedCMValue(float lower, float upper)
CMInfo getCommonMode(const CMdata &cmData) const
void loadCMkValues(std::string_view fileName)
load CMkValues from file, assuming it is stored under the name "CMkValues
std::unordered_map< std::string, CalPad > CalPadMapType
void setCorrectOutputForPedestal(bool corret=true)
void setQCompScale(float q)
The mQComp will be set to (cm - mQCompScaleThreshold) * mQCompScale, if cm > mQCompScaleThreshold.
void limitKFactorPrecision(bool limit=true)
void loadDefaultPadMaps(FEEConfig::Tags feeTag=FEEConfig::Tags::Physics30sigma)
load the Pad maps from CCDB
void setSumPosThreshold(float threshold)
Threshold above which a signal is considered for sumPos, if debug information is used.
void limitPedestalPrecision(bool limit=true)
void setQCompScaleThreshold(float q)
The mQComp will be set to (cm - mQCompScaleThreshold) * mQCompScale, if cm > mQCompScaleThreshold.
GLdouble n
Definition glcorearb.h:1982
GLuint const GLchar * name
Definition glcorearb.h:781
GLenum GLsizei GLsizei GLint * values
Definition glcorearb.h:1576
Global TPC definitions and constants.
float cmValueCRU
common mode value from firmware, if available
uint16_t nSaturation
number of pads in saturation
float cmValueStd
std dev of common mode values from pseudo code
uint16_t nPadsUsed
number of pads used for CM calculation
float sumNeg
sum of negative signals <= mSumPosThreshold, corrected for k-factor
uint16_t nOccupancy
number of CM corrected pads larger than mOccupancyThreshold
float sumPos
sum of positive signals > mSumPosThreshold
float cmValue
common mode value from pseudo code
uint16_t nNeg
number of pads used for sumNeg
Tags
Tag definitions for TPC/Config/FEE.
Definition FEEConfig.h:50
@ Physics30sigma
Physics configuration with 3.0 sigma thresholds.
std::vector< Digit > digits
std::vector< int > row