BmnRoot
Loading...
Searching...
No Matches
StsConst.h
Go to the documentation of this file.
1/************************************************************
2 * Copyright: JINR
3 * Authors: V.Leontyev
4 * Goal: to setup the STS constants, calculations
5 * Date: 07.03.2026
6 ************************************************************/
7
8#ifndef STSCONST_H
9#define STSCONST_H
10
11#include <TMath.h>
12
13namespace StsConst
14{
15static constexpr uint16_t kuHitNbAdcBins = 32; // 5 bit
16static constexpr uint16_t kuHitNbTsBins = 512; // 9 bit
17static constexpr double kdClockCycleNs = 12.5;
18static constexpr uint16_t kuStripsPerSide = 1024;
19
20static constexpr Double_t kdSensorsSzX = 60.; // [mm], active is 59.570 mm (kiNbStrips*kdPitchMm)
21static constexpr Double_t kdSensorsSzY = 60.; // [mm], jun 22
22
23static constexpr Double_t kdPitchMm = 0.058; // [mm]
24
25static constexpr Double_t kdStereoAngle = 7.5; // [deg], angle-2023
26
27// static constexpr uint16_t kuMaxELinks = 96;
28static constexpr uint16_t kuNbElinksPerDpb = 48;
29static constexpr uint16_t kuTotalNbOfSensors = 6;
30
31static constexpr uint16_t kuTotalNbOfMAPS = 3;
32
34{
35 POS = 0,
36 NEG = 1
37};
38static const TString cSideName[2] = {"POS", "NEG"}; // naming, MUST coinside with SideType
39// static constexpr char cSideName[1024][2] = {"POS", "NEG"}; // naming, MUST coinside with SideType
40
41static constexpr uint16_t kuELinkToAsicMap[kuNbElinksPerDpb]{
42 // mar23 mapping 2AFCK
43 0x0000, 0x0002, 0x0004, 0x0006, 0x0001, 0x0003, 0x0005, 0x0007, 0x0009, 0x000B, 0x000D, 0x000F,
44 0x0008, 0x000A, 0x000C, 0x000E, 0x0010, 0x0012, 0x0014, 0x0016, 0x0011, 0x0013, 0x0015, 0x0017, // p-side, sens01
45 0x0019, 0x001B, 0x001D, 0x001F, 0x0018, 0x001A, 0x001C, 0x001E, // n-side. sens01
46 0x0020, 0x0022, 0x0024, 0x0026, 0x0021, 0x0023, 0x0025, 0x0027, // p-side, sens02
47 0x0029, 0x002B, 0x002D, 0x002F, 0x0028, 0x002A, 0x002C, 0x002E, // n-side. sens02
48};
49static constexpr uint16_t kuDpbArray[2]{0x18D1, 0x1940}; // apr25
50// static constexpr uint16_t kuDpbArray[2] {0x18D1, 0x10DB}; // 6353, 4315 - run323(generator)-feb24
51// static constexpr uint16_t kuDpbArray[2] {0x10DB, 0x18D1}; // 4315, 6353
52
53// enum SensMID{B011 = 0, B010 = 1, B004 = 2, B035 = 3}; // Manufacturer Id, beam arranged in Gatchina march23
54// enum SensMID{B011 = 3, B010 = 2, B004 = 1, B008 = 0}; // cosmics-feb24
55// enum SensMID{B011 = 0, B010 = 1, B004 = 2, B008 = 3, B034 = 4, B032 = 5}; // Gatchina march24, details
56// enum SensMID{ B011, B010, B004, B008, B034, B032 }; // Gatchina march24
57// enum SensMID{B008 = 0, B032 = 1, B004 = 2, B010 = 3, B034 = 4, B011 = 5}; // Dubna dec24-err?, details
59{
60 B008 = 0,
61 B032 = 1,
62 B004 = 2,
63 B011 = 3,
64 B034 = 4,
65 B010 = 5
66}; // Dubna mar26, details
67static const TString sMID[kuTotalNbOfSensors]{"B008", "B032", "B004",
68 "B011", "B034", "B010"}; // naming, MUST coinside with SensMID, mar26
69
70static const Double_t kdStereoAngleTan = TMath::Tan(StsConst::kdStereoAngle * TMath::DegToRad());
71
72UInt_t GetIdx_SideFromAsic(UInt_t iAsicIdx)
73{
74 if (((iAsicIdx / 8) % 2) != 0)
75 return StsConst::NEG; // every odd 8th-modulo, "8-15", etc
76 return StsConst::POS;
77};
78
79uint16_t GetIdx_AsicFromELink(uint16_t uELinkIdx)
80{
81 // from CbmCern2017UnpackParSts
82 if (uELinkIdx < StsConst::kuNbElinksPerDpb)
83 return StsConst::kuELinkToAsicMap[uELinkIdx];
84 else {
85 cout << " GetIdx_AsicFromELink => ELink Index is out of bound: " << uELinkIdx;
86 cout << "\treturning dummy value!(0)" << endl;
87 return 0;
88 }
89};
90
91UInt_t GetIdx_SensorFromAsic(uint16_t iDpbIdx, uint16_t iAsicIdx)
92{ // call for the multi DPB analysis
93 if (iDpbIdx == StsConst::kuDpbArray[0]) { // the 1st one, 4315 , 0x10DB
94 if (iAsicIdx <= 0x000F) {
95 return 0;
96 } // the stright forward order for the BeamBox, the closest module
97 else if (iAsicIdx >= 0x0010 && iAsicIdx <= 0x001F)
98 {
99 return 1;
100 } // the 2nd module
101 else if (iAsicIdx >= 0x0020 && iAsicIdx <= 0x002F)
102 {
103 return 2;
104 } // the 3rd module
105 }
106 if (iDpbIdx == StsConst::kuDpbArray[1]) { // the 2nd one, 46353 , 0x18D1
107 if (iAsicIdx <= 0x000F) {
108 return 3;
109 }
110 // if (iAsicIdx >= 0x0010 && iAsicIdx <= 0x001F) { return 3; }
111 else if (iAsicIdx >= 0x0010 && iAsicIdx <= 0x001F)
112 {
113 return 4;
114 } else if (iAsicIdx >= 0x0020 && iAsicIdx <= 0x002F) {
115 return 5;
116 }
117 cout << "GetIdx_SensorFromAsic: WARNING, iAsicIdx= " << iAsicIdx;
118 cout << "\tat iDpbIdx= " << iDpbIdx << endl;
119 return 3;
120 // else if (iAsicIdx >= 0x0010 && iAsicIdx <= 0x001F) { return 3; }
121 // else if (iAsicIdx >= 0x0020 && iAsicIdx <= 0x002F) { return 3; }
122 // else if (iAsicIdx >= 0x0030 && iAsicIdx <= 0x003F) { return 3; }
123 }
124 cout << "GetIdx_SensorFromAsic: unknown DPB index, using Asic 0" << endl;
125 return 0;
126};
127
128uint16_t GetIdx_Strip(uint16_t iSensIdx, uint16_t iAsicIdx, uint16_t iChannel)
129{
130 uint16_t st = 0;
131 uint16_t iAsIdx = iAsicIdx & 0xF; // take only lower 4 bits (inside one Sensor)
132 uint16_t iF8Idx = iAsIdx % 8; // FEB8 chip index inside one Side
133
134 // MappingPatch apr23, v2.1, (_work51)
135 SensMID midSensIdx = static_cast<SensMID>(iSensIdx);
136
137 if (iAsIdx > 7) { // N side, begin
138 st = 128 * iF8Idx + 127 - iChannel; // apr23-II, eq.(3)
139 // if ( iSensIdx==1 ) { // Patch Sens01Chip00, N side, apr23-II
140 if (midSensIdx == B010) { // Patch Sens05 Chip00, N side, apr23-II, MID-mod-mar26
141 if (iAsIdx == 0x8 && iChannel % 2 == 0 && iChannel != 126) {
142 st = 128 * iF8Idx + 127 - iChannel - 2; // eq.(4)
143 // cout << "StsConst.h: eq.4 patch, iSensIdx= " << iSensIdx << "\tiF8Idx=" << iF8Idx
144 //<< "\tiChannel=" << iChannel << "\tStrip=" << st << endl;
145 }
146 }
147 } // N side, end
148 else
149 { // P side, begin
150 if (iChannel % 2 == 0)
151 st = 128 * iF8Idx + iChannel; // Patch of the mapping in apr23, v2.0, eq.(1)
152 else {
153 st = 128 * iF8Idx + iChannel + 2; // eq.(2)
154 if (iF8Idx == 7 && iChannel == 127)
155 st = 1;
156 }
157 if (midSensIdx == B010 && iAsIdx == 0x3 // Sens05, chip03, MID-mod-mar26
158 // midSensIdx == B035 && (iAsIdx == 0x2 || iAsIdx == 0x4)
159 // SensNO,
160 // chip02, chip04, MID-mod-mar26
161 )
162 st = 128 * iF8Idx + iChannel + 2; // eq.(-2)
163 } // P side, end
164
165 return st;
166};
167
169{
170 Double_t X;
171 Double_t Y;
172};
173
174// fsdHitXY fsdSensLocCoord[kuTotalNbOfSensors] = {-60., 30., 0., 60., 60., 30.,
175// 60., -30., 0., -60., -60., -30}; // VSPdec24 coordinates
176
177// const Double_t dSp = 58. * 1.024; // for fsdSensLocCoord calculation - the case of a sharp alignment
178const Double_t dSp = 58. * 0.990; // for fsdSensLocCoord calculation - 34 strips shift
179const Double_t dSpHalf = 0.5 * dSp;
180
181fsdHitXY fsdSensLocCoord[kuTotalNbOfSensors] = {-dSp, dSpHalf, 0., dSp, dSp, 30.,
182 dSp, -30., 0., -dSp, -dSp, -30}; // VSPfeb25 coordinates
183
184fsdHitXY ComputeHitXYfromStrip(Double_t dStripN, Double_t dStripP)
185{
186 fsdHitXY f1;
187 Double_t dMapSizeMmX = StsConst::kdSensorsSzX;
188 Double_t dMapSizeMmY = StsConst::kdSensorsSzY;
189
190 Double_t dCoordN = dStripN;
191 Double_t dCoordP = dStripP;
192
193 const Double_t dZgap = 134.;
194
195 /* // Gatchina24 coordinates, begin
196 f1.X = dMapSizeMmX / 2.;
197 f1.Y = dMapSizeMmY / 2.;
198
199 f1.Y -= StsConst::kdPitchMm * dCoordN; // work46
200
201 // Z-strips, the lower half
202 if( dCoordP <= (dZgap-1.) && dCoordN >= (StsConst::kuStripsPerSide-dZgap-1.) ) {
203 f1.X -= ( (dCoordP + StsConst::kuStripsPerSide) - dCoordN ) *
204 StsConst::kdPitchMm / kdStereoAngleTan;
205 }
206 else { // non-Z-strips, or the upper half with the Z-strips
207 f1.X -= ( dCoordP - dCoordN ) * StsConst::kdPitchMm / kdStereoAngleTan; // work46
208 }
209// Gatchina24 coordinates, end
210 */
211
212 // VSPdec24 coordinates, begin
213 f1.X = -dMapSizeMmX / 2.;
214 f1.Y = -dMapSizeMmY / 2.;
215
216 f1.X += StsConst::kdPitchMm * dCoordN;
217
218 // Z-strips, the lower half
219 if (dCoordP <= (dZgap - 1.) && dCoordN >= (StsConst::kuStripsPerSide - dZgap - 1.)) {
220 f1.Y += ((dCoordP + StsConst::kuStripsPerSide) - dCoordN) * StsConst::kdPitchMm / kdStereoAngleTan;
221 } else { // non-Z-strips, or the upper half with the Z-strips
222 f1.Y += (dCoordP - dCoordN) * StsConst::kdPitchMm / kdStereoAngleTan;
223 }
224
225 // VSPdec24 coordinates, end
226
227 return f1;
228};
229
230fsdHitXY ComputeVspGeomFromSsXY(UInt_t uSensIdx, Double_t dSsX, Double_t dSsY)
231{
232 fsdHitXY f2;
233
234 // f2.X = static_cast<Double_t> (uSensIdx);
235 // f2.Y = static_cast<Double_t> (uSensIdx);
236 if (uSensIdx < 3) { // the TOP halfstation
237 f2.X = fsdSensLocCoord[uSensIdx].X - dSsX;
238 f2.Y = fsdSensLocCoord[uSensIdx].Y - dSsY;
239 // f2.X = fsdSensLocCoord[uSensIdx].X - dSsY;
240 // f2.Y = fsdSensLocCoord[uSensIdx].Y - dSsX;
241 } else if (uSensIdx < 6) { // the BOTTOM halfstation
242 f2.X = fsdSensLocCoord[uSensIdx].X + dSsX;
243 f2.Y = fsdSensLocCoord[uSensIdx].Y + dSsY;
244 } else { // dummy case
245 f2.X = -1.;
246 f2.Y = -1.;
247 }
248 return f2;
249};
250
251}; // namespace StsConst
252#endif // STSCONST_H
fsdHitXY ComputeVspGeomFromSsXY(UInt_t uSensIdx, Double_t dSsX, Double_t dSsY)
Definition StsConst.h:230
UInt_t GetIdx_SensorFromAsic(uint16_t iDpbIdx, uint16_t iAsicIdx)
Definition StsConst.h:91
const Double_t dSp
Definition StsConst.h:178
fsdHitXY fsdSensLocCoord[kuTotalNbOfSensors]
Definition StsConst.h:181
fsdHitXY ComputeHitXYfromStrip(Double_t dStripN, Double_t dStripP)
Definition StsConst.h:184
const Double_t dSpHalf
Definition StsConst.h:179
uint16_t GetIdx_Strip(uint16_t iSensIdx, uint16_t iAsicIdx, uint16_t iChannel)
Definition StsConst.h:128
UInt_t GetIdx_SideFromAsic(UInt_t iAsicIdx)
Definition StsConst.h:72
uint16_t GetIdx_AsicFromELink(uint16_t uELinkIdx)
Definition StsConst.h:79