Project
Loading...
Searching...
No Matches
Mapping.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
14
15#include <fstream>
16#include "TSystem.h"
17#include <fairlogger/Logger.h>
18#include "PHOSBase/Mapping.h"
19#include "PHOSBase/Geometry.h"
20
21using namespace o2::phos;
22Mapping* Mapping::sMapping = nullptr;
23//_______________________________________________________
24Mapping::Mapping(std::basic_string_view<char> path) : mPath(path),
25 mInitialized(false)
26{
27}
28//_______________________________________________________
30{
31 if (sMapping) {
32 return sMapping;
33 } else {
34 sMapping = new Mapping();
35 sMapping->setMapping();
36 return sMapping;
37 }
38}
39//_______________________________________________________
40Mapping* Mapping::Instance(std::basic_string_view<char> path)
41{
42 if (sMapping) {
43 if (sMapping->mPath == path) {
44 return sMapping;
45 } else {
46 delete sMapping;
47 }
48 }
49 sMapping = new Mapping(path);
50 sMapping->setMapping();
51 return sMapping;
52}
53//_______________________________________________________
54Mapping::ErrorStatus Mapping::hwToAbsId(short ddl, short hwAddr, short& absId, CaloFlag& caloFlag) const
55{
56
57 if (!mInitialized) {
58 LOG(error) << "Mapping not initialized";
59 return kNotInitialized;
60 }
61
62 if (ddl < 0 || ddl > 14) {
63 return kWrongDDL;
64 }
65
66 if ((hwAddr >= 112 && hwAddr < 128) || (hwAddr >= 2159 && hwAddr < 2176)) { // TRU flags
67 caloFlag = kTRU;
68 absId = -1;
69 return kOK;
70 }
71 if (hwAddr < 0 || hwAddr >= NMaxHWAddress) {
72 return kWrongHWAddress;
73 }
74
75 // transform
76 absId = mAbsId[ddl][hwAddr];
77 caloFlag = mCaloFlag[ddl][hwAddr];
78
79 if (caloFlag == 2) {
80 absId += NCHANNELS;
81 }
82 if (caloFlag < 2 && (absId > NCHANNELS || absId <= 1792)) {
83 absId = 0;
84 return kWrongHWAddress;
85 }
86 return kOK;
87}
88//_______________________________________________________
89Mapping::ErrorStatus Mapping::absIdTohw(short absId, short caloFlag, short& ddl, short& hwAddr) const
90{
91
92 if (caloFlag < 0 || caloFlag > 2) {
93 ddl = 0;
94 hwAddr = 0;
95 return kWrongCaloFlag;
96 }
97 if (caloFlag < 2) {
98 if (absId <= 1792 || absId > NCHANNELS) {
99 ddl = 0;
100 hwAddr = 0;
101 return kWrongAbsId;
102 }
103 } else { // TRU: absId goes after readout ones
104 absId -= NCHANNELS;
105 if (absId < 1 || absId > NTRUReadoutChannels) {
106 ddl = 0;
107 hwAddr = 0;
108 return kWrongAbsId;
109 }
110 }
111
112 if (!mInitialized) {
113 LOG(error) << "Mapping not initialized";
114 return kNotInitialized;
115 }
116
117 ddl = mAbsToHW[absId - 1][caloFlag][0];
118 hwAddr = mAbsToHW[absId - 1][caloFlag][1];
119 return kOK;
120}
121//_______________________________________________________
123{
124 // Read mapping from data files a-la Run2
125
126 std::string p;
127 if (mPath.empty()) { // use default path
128 p = gSystem->Getenv("O2_ROOT");
129 p += "/share/Detectors/PHOS/files";
130 } else {
131 p = mPath.data();
132 }
133
134 for (short m = 0; m < 4; m++) { // modules
135 for (short i = 0; i < 4; i++) { // RCU
136 if (m == 0 && (i < 2)) {
137 continue; // half of module: only RCU 2,3
138 }
139
140 short numberOfChannels = 0;
141 short maxHWAddress = 0;
142 std::string fname = fmt::format("{:s}/Mod{:d}RCU{:d}.data", p, m, i);
143 std::ifstream fIn(fname);
144 if (!fIn.is_open()) {
145 LOG(fatal) << "Missing mapping file " << p << "/Mod" << m << "RCU" << i << ".data";
146 return kNotInitialized;
147 }
148 if (!(fIn >> numberOfChannels)) {
149 LOG(fatal) << "Syntax of mapping file " << p << "/Mod" << m << "RCU" << i << ".data is wrong: no numberOfChannels";
150 return kNotInitialized;
151 }
152 if (numberOfChannels != NHWPERDDL) {
153 LOG(fatal) << "Unexpected number of channels: " << numberOfChannels << " expecting " << NHWPERDDL << " file " << p << "/Mod" << m << "RCU" << i << ".data is wrong: no numberOfChannels";
154 return kNotInitialized;
155 }
156 if (!(fIn >> maxHWAddress)) {
157 LOG(fatal) << "Syntax of mapping file " << p << "/Mod" << m << "RCU" << i << ".data is wrong: no maxHWAddress";
158 return kNotInitialized;
159 }
160 if (maxHWAddress > NMaxHWAddress) {
161 LOG(fatal) << "Maximal HW address in file " << maxHWAddress << "larger than array size " << NMaxHWAddress << "for /Mod" << m << "RCU" << i << ".data is wrong: no maxHWAddress";
162 return kNotInitialized;
163 }
164 for (short ich = 0; ich < numberOfChannels; ich++) { // 1792 = 2*896 channels connected to each RCU
165 int hwAddress;
166 if (!(fIn >> hwAddress)) {
167 LOG(fatal) << "Syntax of mapping file " << p << "/Mod" << m << "RCU" << i << ".data is wrong: no HWadd for ch " << ich;
168 return kNotInitialized;
169 }
170 if (hwAddress > maxHWAddress) {
171 LOG(fatal) << "Hardware (ALTRO) adress (" << hwAddress << ") outside the range (0 -> " << maxHWAddress << ") !";
172 return kNotInitialized;
173 }
174 int row, col, caloFlag;
175 if (!(fIn >> row >> col >> caloFlag)) {
176 LOG(fatal) << "Syntax of mapping file " << p << "/Mod" << m << "RCU" << i << ".data is wrong: no (raw col caloFlag)";
177 return kNotInitialized;
178 }
179
180 if (caloFlag < 0 || caloFlag > 2) {
181 LOG(fatal) << "Wrong CaloFlag value found (" << caloFlag << "). Should be 0, 1, 2 !";
182 return kNotInitialized;
183 }
184
185 // convert ddl, col,raw caloFlag to AbsId
186 // Converts the absolute numbering into the following array
187 // relid[0] = PHOS Module number
188 // relid[1] = Row number inside a PHOS module (Phi coordinate)
189 // relid[2] = Column number inside a PHOS module (Z coordinate)
190 short ddl = 4 * m + i - 2;
191 if (ddl < 0 || ddl >= NDDL) {
192 LOG(fatal) << "Wrong ddl address found (" << ddl << "). Module= " << m << " RCU =" << i;
193 return kNotInitialized;
194 }
195
196 short absId;
197 if (caloFlag < 2) { // readout channels
198 char relid[3] = {static_cast<char>(m + 1), static_cast<char>(row + 1), static_cast<char>(col + 1)};
199 Geometry::relToAbsNumbering(relid, absId);
200 } else { // TRU channels: internal storage of TRU channesl absId-NCHANNELS
201 if (isTRUReadoutchannel(hwAddress)) {
202 if (hwAddress < 2048) { // branch 28<=z<56
203 absId = 1 + ddl * 2 * NTRUBranchReadoutChannels + hwAddress;
204 } else { // branch 0<=z<28
205 absId = 1 + (ddl * 2 + 1) * NTRUBranchReadoutChannels + hwAddress - 2048;
206 }
207 } else { // TRU flag channels, no absId
208 continue;
209 }
210 }
211
212 mAbsId[ddl][hwAddress] = absId;
213 mCaloFlag[ddl][hwAddress] = (CaloFlag)caloFlag;
214 mAbsToHW[absId - 1][caloFlag][0] = ddl;
215 mAbsToHW[absId - 1][caloFlag][1] = hwAddress;
216 }
217 fIn.close();
218 } // RCU
219 } // module
220 mInitialized = true;
221 return kOK;
222}
int32_t i
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 maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions false
char error[CURL_ERROR_SIZE]
uint32_t col
Definition RawData.h:4
static bool relToAbsNumbering(const char *RelId, short &AbsId)
Definition Geometry.cxx:207
static constexpr short NDDL
Total number of DDLs.
Definition Mapping.h:45
static constexpr short NMaxHWAddress
Maximal HW address (size of array)
Definition Mapping.h:44
static Mapping * Instance()
Definition Mapping.cxx:29
static constexpr short NTRUBranchReadoutChannels
Number of TRU readout channels per branch.
Definition Mapping.h:46
static bool isTRUReadoutchannel(short hwAddress)
Definition Mapping.h:112
static constexpr short NHWPERDDL
Number of HW addressed per DDL.
Definition Mapping.h:43
ErrorStatus setMapping()
Definition Mapping.cxx:122
static constexpr short NCHANNELS
Number of channels starting from 1.
Definition Mapping.h:42
ErrorStatus hwToAbsId(short ddl, short hw, short &absId, CaloFlag &caloFlag) const
convert hardware address to absId and caloFlag
Definition Mapping.cxx:54
ErrorStatus absIdTohw(short absId, short caloFlag, short &ddl, short &hwAddr) const
convert absId and caloflag to hardware address and ddl
Definition Mapping.cxx:89
static constexpr short NTRUReadoutChannels
Total number of TRU readout channels.
Definition Mapping.h:47
const GLfloat * m
Definition glcorearb.h:4066
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< int > row