diff --git a/algo/detectors/sts/StsReadoutConfigLegacy.cxx b/algo/detectors/sts/StsReadoutConfigLegacy.cxx index d700304c2c23513152ea9cf92ac949efd80a63ca..7dd142918213e82dce7c05a63a461f2c444f2e0e 100644 --- a/algo/detectors/sts/StsReadoutConfigLegacy.cxx +++ b/algo/detectors/sts/StsReadoutConfigLegacy.cxx @@ -145,7 +145,6 @@ namespace cbm::algo modAddress[11] = 0x10008012; modAddress[12] = 0x10018012; - // Constructing the map (equipmentId, eLink) -> (module, ASIC within module) uint16_t numElinksPerComp = numCrobPerComp * numElinksPerCrob; for (uint16_t comp = 0; comp < numComp; comp++) { @@ -196,6 +195,19 @@ namespace cbm::algo // ------------------------------------------------------------------------------------ + // --- Mapping (equimentId, elink) -> (address, ASIC) -------------------------------- + std::vector<double> StsReadoutConfigLegacy::WalkMap(int32_t modAddress, uint16_t asic) + { + std::vector<double> result; + auto modIter = fWalkMap.find(modAddress); + if (modIter != fWalkMap.end()) { + if (asic < modIter->second.size()) { result = modIter->second.at(asic); } + } + return result; + } + // ------------------------------------------------------------------------------------ + + // ----- Print readout map ------------------------------------------------ std::string StsReadoutConfigLegacy::PrintReadoutMap() { @@ -223,4 +235,104 @@ namespace cbm::algo // ---------------------------------------------------------------------------- + // --- Initialise the walk map --------------------------------------------- + void StsReadoutConfigLegacy::InitWalkCoeffs() + { + // Taken from macro/beamtime/mcbm2021/mStsAsicTimeWalk.par + fWalkMap[0x10008002][0] = {-24.343851, 2.794827, -0.103235, 0.001478}; + fWalkMap[0x10008002][1] = {-24.453138, 2.485316, -0.084344, 0.001143}; + fWalkMap[0x10008002][2] = {-21.335244, 2.585311, -0.094605, 0.001301}; + fWalkMap[0x10008002][3] = {-27.042286, 3.172233, -0.124657, 0.001763}; + fWalkMap[0x10008002][4] = {-25.045089, 3.203871, -0.127637, 0.001794}; + fWalkMap[0x10008002][5] = {-26.779818, 3.087139, -0.119053, 0.001645}; + fWalkMap[0x10008002][6] = {-24.481546, 3.110816, -0.121333, 0.001657}; + fWalkMap[0x10008002][7] = {-22.591301, 2.877937, -0.113311, 0.001577}; + fWalkMap[0x10008002][8] = {-19.424627, 2.142350, -0.076907, 0.001131}; + fWalkMap[0x10008002][9] = {-18.569512, 2.213657, -0.077985, 0.001104}; + fWalkMap[0x10008002][10] = {-16.501049, 2.082342, -0.076398, 0.001047}; + fWalkMap[0x10008002][11] = {-19.052489, 2.548761, -0.098873, 0.001388}; + fWalkMap[0x10008002][12] = {-21.833524, 2.704140, -0.105664, 0.001495}; + fWalkMap[0x10008002][13] = {-17.299280, 2.451026, -0.100094, 0.001467}; + fWalkMap[0x10008002][14] = {-19.148061, 2.444700, -0.094107, 0.001301}; + fWalkMap[0x10008002][15] = {-27.609664, 2.979764, -0.118827, 0.001815}; + fWalkMap[0x10008402][0] = {-16.073344, 2.122262, -0.077667, 0.001089}; + fWalkMap[0x10008402][1] = {-14.128047, 1.925380, -0.068603, 0.000927}; + fWalkMap[0x10008402][2] = {-14.816346, 2.138562, -0.086058, 0.001264}; + fWalkMap[0x10008402][3] = {-15.495564, 2.221024, -0.090255, 0.001300}; + fWalkMap[0x10008402][4] = {-14.726348, 2.047140, -0.081099, 0.001143}; + fWalkMap[0x10008402][5] = {-14.639612, 2.115243, -0.088436, 0.001292}; + fWalkMap[0x10008402][6] = {-15.862068, 2.403059, -0.105667, 0.001625}; + fWalkMap[0x10008402][7] = {-10.630106, 1.633339, -0.067333, 0.001027}; + fWalkMap[0x10008402][8] = {-18.162918, 1.839778, -0.062554, 0.000903}; + fWalkMap[0x10008402][9] = {-14.766435, 1.629818, -0.054458, 0.000773}; + fWalkMap[0x10008402][10] = {-13.242281, 1.478376, -0.050540, 0.000684}; + fWalkMap[0x10008402][11] = {-13.184870, 1.835602, -0.069212, 0.000971}; + fWalkMap[0x10008402][13] = {-15.820881, 2.125931, -0.085089, 0.001243}; + fWalkMap[0x10008402][14] = {-17.079033, 2.253279, -0.095055, 0.001457}; + fWalkMap[0x10008402][15] = {-21.763771, 2.444369, -0.097365, 0.001488}; + fWalkMap[0x10008412][0] = {-21.062298, 2.403890, -0.102558, 0.001589}; + fWalkMap[0x10008412][1] = {-24.543860, 2.389462, -0.096190, 0.001471}; + fWalkMap[0x10008412][2] = {-20.704607, 1.996227, -0.075500, 0.001141}; + fWalkMap[0x10008412][3] = {-22.341229, 2.170088, -0.084561, 0.001281}; + fWalkMap[0x10008412][4] = {-22.427438, 2.116928, -0.079242, 0.001178}; + fWalkMap[0x10008412][5] = {-23.909809, 2.120500, -0.077669, 0.001144}; + fWalkMap[0x10008412][6] = {-23.474690, 2.298446, -0.091476, 0.001419}; + fWalkMap[0x10008412][7] = {-21.015222, 2.099456, -0.081011, 0.001165}; + fWalkMap[0x10008412][8] = {-17.923666, 2.086692, -0.082284, 0.001242}; + fWalkMap[0x10008412][9] = {-14.506690, 1.860290, -0.069751, 0.001043}; + fWalkMap[0x10008412][10] = {-15.961562, 1.900934, -0.073619, 0.001135}; + fWalkMap[0x10008412][11] = {-15.770385, 1.936563, -0.073541, 0.001112}; + fWalkMap[0x10008412][12] = {-16.316668, 1.803342, -0.066135, 0.000997}; + fWalkMap[0x10008412][13] = {-14.351899, 1.640790, -0.057478, 0.000828}; + fWalkMap[0x10008412][14] = {-15.640816, 1.622711, -0.052814, 0.000721}; + fWalkMap[0x10008412][15] = {-29.251989, 3.538843, -0.151628, 0.002310}; + fWalkMap[0x10018002][0] = {-25.056458, 3.219929, -0.125826, 0.001851}; + fWalkMap[0x10018002][1] = {-24.371339, 2.918229, -0.110544, 0.001599}; + fWalkMap[0x10018002][2] = {-23.462901, 3.175956, -0.124907, 0.001805}; + fWalkMap[0x10018002][3] = {-24.111189, 3.086661, -0.123224, 0.001715}; + fWalkMap[0x10018002][4] = {-29.824286, 3.758626, -0.156249, 0.002269}; + fWalkMap[0x10018002][6] = {-27.337549, 3.448515, -0.136996, 0.001904}; + fWalkMap[0x10018002][7] = {-28.369105, 3.765852, -0.157456, 0.002274}; + fWalkMap[0x10018002][8] = {-20.791849, 2.486259, -0.089749, 0.001276}; + fWalkMap[0x10018002][9] = {-17.363288, 2.371768, -0.088625, 0.001300}; + fWalkMap[0x10018002][10] = {-18.272911, 2.389323, -0.090529, 0.001260}; + fWalkMap[0x10018002][11] = {-17.764736, 2.624238, -0.105000, 0.001490}; + fWalkMap[0x10018002][12] = {-19.324053, 2.746429, -0.113868, 0.001655}; + fWalkMap[0x10018002][13] = {-19.358567, 2.818979, -0.117600, 0.001718}; + fWalkMap[0x10018002][14] = {-23.161820, 2.978407, -0.117120, 0.001645}; + fWalkMap[0x10018002][15] = {-27.423694, 3.107933, -0.123165, 0.001840}; + fWalkMap[0x10018402][0] = {-16.145571, 2.285077, -0.084840, 0.001184}; + fWalkMap[0x10018402][1] = {-16.710720, 2.333578, -0.088014, 0.001256}; + fWalkMap[0x10018402][2] = {-13.307549, 2.055841, -0.082222, 0.001205}; + fWalkMap[0x10018402][3] = {-18.324998, 2.492320, -0.106166, 0.001586}; + fWalkMap[0x10018402][4] = {-12.216834, 2.021692, -0.085865, 0.001282}; + fWalkMap[0x10018402][5] = {-16.246236, 2.224143, -0.094434, 0.001413}; + fWalkMap[0x10018402][6] = {-16.092803, 2.422394, -0.103351, 0.001556}; + fWalkMap[0x10018402][7] = {-14.283653, 2.054059, -0.089415, 0.001367}; + fWalkMap[0x10018402][8] = {-16.091609, 1.761754, -0.058745, 0.000843}; + fWalkMap[0x10018402][9] = {-15.368578, 1.813220, -0.061890, 0.000874}; + fWalkMap[0x10018402][10] = {-15.429614, 1.815415, -0.064702, 0.000879}; + fWalkMap[0x10018402][11] = {-14.695207, 2.035016, -0.076519, 0.001062}; + fWalkMap[0x10018402][12] = {-14.439320, 1.914747, -0.075799, 0.001113}; + fWalkMap[0x10018402][13] = {-13.936573, 1.896988, -0.071429, 0.001002}; + fWalkMap[0x10018402][14] = {-16.212322, 2.087315, -0.082074, 0.001192}; + fWalkMap[0x10018402][15] = {-19.711627, 2.072715, -0.076144, 0.001141}; + fWalkMap[0x10018412][0] = {-14.367412, 1.870214, -0.068419, 0.000953}; + fWalkMap[0x10018412][1] = {-15.059765, 1.700618, -0.056864, 0.000772}; + fWalkMap[0x10018412][2] = {-14.580617, 1.835231, -0.065276, 0.000935}; + fWalkMap[0x10018412][3] = {-17.815214, 2.049838, -0.076863, 0.001137}; + fWalkMap[0x10018412][4] = {-15.237744, 1.915726, -0.069146, 0.001000}; + fWalkMap[0x10018412][5] = {-16.830010, 1.644316, -0.054014, 0.000760}; + fWalkMap[0x10018412][6] = {-18.143719, 2.165342, -0.081457, 0.001200}; + fWalkMap[0x10018412][7] = {-13.713480, 1.750551, -0.067606, 0.000995}; + fWalkMap[0x10018412][8] = {-15.973608, 1.941389, -0.070457, 0.001006}; + fWalkMap[0x10018412][9] = {-14.568116, 1.794739, -0.061400, 0.000856}; + fWalkMap[0x10018412][10] = {-17.442979, 1.840064, -0.062072, 0.000876}; + fWalkMap[0x10018412][11] = {-17.495727, 2.166743, -0.083457, 0.001253}; + fWalkMap[0x10018412][12] = {-15.841103, 1.836733, -0.065771, 0.000969}; + fWalkMap[0x10018412][13] = {-18.192644, 2.166289, -0.082612, 0.001239}; + fWalkMap[0x10018412][14] = {-21.460571, 2.277799, -0.084761, 0.001226}; + fWalkMap[0x10018412][15] = {-25.006354, 2.532571, -0.098309, 0.001455}; + } + } /* namespace cbm::algo */ diff --git a/algo/detectors/sts/StsReadoutConfigLegacy.h b/algo/detectors/sts/StsReadoutConfigLegacy.h index ef452d3eb85eddaf213217bd596db224ee48687a..83dfd2432debf627922fbf16d70a2c94152c8732 100644 --- a/algo/detectors/sts/StsReadoutConfigLegacy.h +++ b/algo/detectors/sts/StsReadoutConfigLegacy.h @@ -66,6 +66,14 @@ namespace cbm::algo std::pair<int32_t, uint16_t> Map(uint16_t equipId, uint16_t elink); + /** @brief API: Mapping from module address and ASIC number to walk coefficients. + ** @param modAddress module address + ** @param asic ASIC number within module + ** @return std::vector<double> of walk coefficients + */ + std::vector<double> WalkMap(int32_t modAddress, uint16_t asic); + + /** @brief Debug output of readout map **/ std::string PrintReadoutMap(); @@ -75,9 +83,15 @@ namespace cbm::algo // --- Map index: (equipment, elink), map value: (module address, ASIC number in module) std::map<uint16_t, std::vector<std::pair<int32_t, uint16_t>>> fReadoutMap = {}; //! + // --- STS walk correction map + // --- Map index: (module address, ASIC number in module, ADC value), map value: (walk coefficient) + std::map<int32_t, std::vector<std::vector<double>>> fWalkMap; /** @brief Initialisation of readout map **/ void Init(); + + /** @brief Initialisation of walk map **/ + void InitWalkCoeffs(); }; } /* namespace cbm::algo */ diff --git a/algo/detectors/sts/UnpackSts.cxx b/algo/detectors/sts/UnpackSts.cxx index d5a38c0a25765637ead6be06bcc6041991f31523..bcb389c2517d756a9b7276968cad77ea65e7484d 100644 --- a/algo/detectors/sts/UnpackSts.cxx +++ b/algo/detectors/sts/UnpackSts.cxx @@ -125,7 +125,9 @@ namespace cbm::algo // --- Correct ASIC-wise offsets messageTime -= elinkPar.fTimeOffset; - // --- TODO: Add walk correction (depends on ADC) + + // --- Apply walk correction if applicable + if (!elinkPar.fWalk.empty()) { messageTime += elinkPar.fWalk[message.GetHitAdc() - 1]; } // --- Charge double charge = elinkPar.fAdcOffset + (message.GetHitAdc() - 1) * elinkPar.fAdcGain; diff --git a/algo/detectors/sts/UnpackSts.h b/algo/detectors/sts/UnpackSts.h index 522ca24051b447f627db46addc7772265c4ee394..8378c418c304b308f46136462d7ce289d005b9bc 100644 --- a/algo/detectors/sts/UnpackSts.h +++ b/algo/detectors/sts/UnpackSts.h @@ -34,6 +34,7 @@ namespace cbm::algo uint64_t fTimeOffset = 0.; ///< Time calibration parameter double fAdcOffset = 0.; ///< Charge calibration parameter double fAdcGain = 0.; ///< Charge calibration parameter + std::vector<double> fWalk; ///< Walk correction coefficients }; diff --git a/algo/unpack/Unpack.cxx b/algo/unpack/Unpack.cxx index bab391dcf811218e7f110b4c360a0bc9495896c2..b6c9b40d799b3909b7e13387954e03f8aceca2b4 100644 --- a/algo/unpack/Unpack.cxx +++ b/algo/unpack/Unpack.cxx @@ -168,6 +168,7 @@ namespace cbm::algo elinkPar.fTimeOffset = 0.; elinkPar.fAdcOffset = 1.; elinkPar.fAdcGain = 1.; + elinkPar.fWalk = fStsConfig.WalkMap(elinkPar.fAddress, elinkPar.fAsicNr); // TODO: Add parameters for time and ADC calibration par->fElinkParams.push_back(elinkPar); }