Project
Loading...
Searching...
No Matches
HelperMethods.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
12#ifndef ALICEO2_TRD_HELPERMETHODS_HH
13#define ALICEO2_TRD_HELPERMETHODS_HH
14
16#include <iostream>
17#include <string>
18#include <fmt/format.h>
19
20namespace o2
21{
22namespace trd
23{
24
26 static int getROBfromPad(int irow, int icol)
27 {
28 return (irow / constants::NMCMROBINROW) * 2 + getColSide(icol);
29 }
30
31 static int getMCMfromPad(int irow, int icol)
32 {
33 if (irow < 0 || icol < 0 || irow > constants::NROWC1 || icol > constants::NCOLUMN) {
34 return -1;
35 }
36 return (icol % (constants::NCOLUMN / 2)) / constants::NCOLMCM + constants::NMCMROBINCOL * (irow % constants::NMCMROBINROW);
37 }
38
39 static int getColSide(int icol)
40 {
41 if (icol < 0 || icol >= constants::NCOLUMN) {
42 return -1;
43 }
44
45 return icol / (constants::NCOLUMN / 2);
46 }
47
48 static int getPadRowFromMCM(int irob, int imcm)
49 {
50 return constants::NMCMROBINROW * (irob / 2) + imcm / constants::NMCMROBINCOL;
51 }
52
53 static void printSectorStackLayer(int det)
54 {
55 // for a given chamber number prints SECTOR_STACK_LAYER
56 printf("%02i_%i_%i\n", det / constants::NCHAMBERPERSEC, (det % constants::NCHAMBERPERSEC) / constants::NLAYER, det % constants::NLAYER);
57 }
58
59 static std::string getSectorStackLayerSide(int hcid)
60 {
61 int det = hcid / 2;
62 std::string side = (hcid % 2 == 0) ? "A" : "B";
63 return fmt::format("{}_{}_{}{}", getSector(det), getStack(det), getLayer(det), side);
64 }
65
66 static void printSectorStackLayerSide(int hcid)
67 {
68 // for a given half-chamber number prints SECTOR_STACK_LAYER_side
69 printf("%s\n", getSectorStackLayerSide(hcid).c_str());
70 }
71
72 static int getPadColFromADC(int irob, int imcm, int iadc)
73 {
74 if (iadc < 0 || iadc > constants::NADCMCM) {
75 return -100;
76 }
77 int mcmcol = imcm % constants::NMCMROBINCOL + getROBSide(irob) * constants::NMCMROBINCOL; // MCM column number on ROC [0..7]
78 int padcol = mcmcol * constants::NCOLMCM + constants::NCOLMCM + 1 - iadc;
79 if (padcol < 0 || padcol >= constants::NCOLUMN) {
80 return -1; // this is commented because of reason above OK
81 }
82 return padcol;
83 }
84
85 static int getROBSide(int irob)
86 {
87 if (irob < 0 || irob >= constants::NROBC1) {
88 return -1;
89 }
90 return irob % 2;
91 }
92
93 static int getSector(int det)
94 {
95 return det / constants::NCHAMBERPERSEC;
96 }
97
98 static int getStack(int det)
99 {
100 return det % (constants::NSTACK * constants::NLAYER) / constants::NLAYER;
101 }
102 static int getLayer(int det)
103 {
104 return det % constants::NLAYER;
105 }
106
107 static int getDetector(int sector, int stack, int layer)
108 {
109 return (layer + stack * constants::NLAYER + sector * constants::NLAYER * constants::NSTACK);
110 }
111
112 static int getORIinSuperModule(int hcid)
113 {
114 // given a half chamber ID compute the link ID from [0..59]
115 // where link ID [0..29] is for A-side CRU and [30..59] for C-side CRU
116 int ori = -1;
117 int stack = getStack(hcid / 2);
118 int layer = getLayer(hcid / 2);
119 int side = (hcid % 2 == 0) ? 0 : 1;
120 bool isAside = false;
121 if (stack < 2 || (stack == 2 && side == 0)) {
122 isAside = true;
123 }
124 if (isAside) {
125 ori = stack * constants::NLAYER * 2 + side * constants::NLAYER + 5 - layer;
126 } else {
127 // C-side
128 ori = (4 - stack) * constants::NLAYER * 2 + side * constants::NLAYER + 5 - layer;
129 if (stack == 2) {
130 ori -= constants::NLAYER;
131 }
132 ori += constants::NLINKSPERCRU;
133 }
134 // TODO: put mapping into TDP and prepare for alternative mapping (CCDB?)
135 return ori;
136 }
137
138 static int getHCIDFromLinkID(int link)
139 {
140 // link = halfcrulink [0..14] + halfcru [0..71] * constants::NLINKSPERHALFCRU (15) -> [0..1079]
141
142 int sector = link / constants::NHCPERSEC;
143 int linkSector = link % constants::NHCPERSEC; // [0..59]
144 int linkCRU = linkSector % constants::NLINKSPERCRU; // [0..29]
145 int stack = linkCRU / (constants::NLAYER * 2);
146 int layer = 5 - (linkCRU % constants::NLAYER);
147 int side = (linkCRU / constants::NLAYER) % 2;
148 if (linkSector >= constants::NLINKSPERCRU) {
149 // C-side
150 stack = 4 - stack;
151 if (stack == 2) {
152 side = 1;
153 }
154 }
155 return sector * constants::NHCPERSEC + stack * constants::NLAYER * 2 + layer * 2 + side;
156 }
157
158 static int getLinkIDfromHCID(int hcid)
159 {
160 //return a number in range [0:29] for the link related to this hcid with in its respective CRU
161 //lower 15 is endpoint 0 and upper 15 is endpoint 1
162 //a side has 30, c side has 30 to give 60 links for a supermodule
163 int sector = hcid / constants::NHCPERSEC;
164 return getORIinSuperModule(hcid) + constants::NHCPERSEC * sector;
165 }
166
167 static int getChannelIndexInColumn(int rob, int mcm, int channel)
168 {
169 // the highest ADC channel number corresponds to the lowest pad column connected to given MCM
170 int mcmCol = (rob % 2) ? mcm % constants::NMCMROBINROW + constants::NMCMROBINCOL : mcm % constants::NMCMROBINROW;
171 return mcmCol * constants::NADCMCM + constants::NADCMCM - 1 - channel;
172 }
173
174 static int getGlobalChannelIndex(int det, int rob, int mcm, int channel)
175 {
176 // return global readout channel index for given detector, ROB, MCM and channel index
177 // start with sector offset
178 int idx = getSector(det) * constants::NCHANNELSPERSECTOR;
179 // layer offset
180 idx += getLayer(det) * constants::NCHANNELSPERLAYER;
181 // stack offset
182 idx += (getStack(det) < 3) ? getStack(det) * constants::NCHANNELSC1 : (getStack(det) - 1) * constants::NCHANNELSC1 + constants::NCHANNELSC0;
183 // pad row offset
184 idx += getPadRowFromMCM(rob, mcm) * constants::NCHANNELSPERROW;
185 // position within pad column
186 idx += getChannelIndexInColumn(rob, mcm, channel);
187
188 return idx;
189 }
190
191 static void getPositionFromGlobalChannelIndex(int idx, int& det, int& rob, int& mcm, int& channel)
192 {
193 int sec = idx / constants::NCHANNELSPERSECTOR;
194 int layer = (idx % constants::NCHANNELSPERSECTOR) / constants::NCHANNELSPERLAYER;
195 int stackIndex = ((idx % constants::NCHANNELSPERSECTOR) % constants::NCHANNELSPERLAYER);
196 int stack, chamberIndex;
197 if (stackIndex >= 2 * constants::NCHANNELSC1 + constants::NCHANNELSC0) {
198 stack = 3 + (stackIndex - 2 * constants::NCHANNELSC1 - constants::NCHANNELSC0) / constants::NCHANNELSC1;
199 chamberIndex = (stackIndex - constants::NCHANNELSC0) % constants::NCHANNELSC1;
200 } else if (stackIndex > 2 * constants::NCHANNELSC1) {
201 stack = 2;
202 chamberIndex = stackIndex - 2 * constants::NCHANNELSC1;
203 } else {
204 stack = stackIndex / constants::NCHANNELSC1;
205 chamberIndex = stackIndex % constants::NCHANNELSC1;
206 }
207 int row = chamberIndex / constants::NCHANNELSPERROW;
208 int mcmCol = (chamberIndex % constants::NCHANNELSPERROW) / constants::NADCMCM;
209 det = getDetector(sec, stack, layer);
210 rob = (mcmCol >= constants::NMCMROBINCOL) ? (row / constants::NMCMROBINROW) * 2 + 1 : (row / constants::NMCMROBINROW) * 2;
211 mcm = (row % constants::NMCMROBINROW) * constants::NMCMROBINCOL + (mcmCol % constants::NMCMROBINCOL);
212 channel = constants::NADCMCM - 1 - ((chamberIndex % constants::NCHANNELSPERROW) % constants::NADCMCM);
213 }
214};
215
216} // namespace trd
217} // namespace o2
218
219#endif
uint16_t mcm
uint16_t rob
Global TRD definitions and constants.
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 trd
uint32_t side
Definition RawData.h:0
uint32_t stack
Definition RawData.h:1
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static int getGlobalChannelIndex(int det, int rob, int mcm, int channel)
static int getROBfromPad(int irow, int icol)
static void getPositionFromGlobalChannelIndex(int idx, int &det, int &rob, int &mcm, int &channel)
static void printSectorStackLayerSide(int hcid)
static std::string getSectorStackLayerSide(int hcid)
static int getColSide(int icol)
static int getDetector(int sector, int stack, int layer)
static int getPadRowFromMCM(int irob, int imcm)
static int getLinkIDfromHCID(int hcid)
static int getStack(int det)
static void printSectorStackLayer(int det)
static int getPadColFromADC(int irob, int imcm, int iadc)
static int getHCIDFromLinkID(int link)
static int getLayer(int det)
static int getSector(int det)
static int getMCMfromPad(int irow, int icol)
static int getROBSide(int irob)
static int getORIinSuperModule(int hcid)
static int getChannelIndexInColumn(int rob, int mcm, int channel)
std::vector< int > row