2828using namespace o2 ::tpc ::cru_calib_helpers ;
2929using namespace o2 ::tpc ;
3030
31- void prepareCMFiles (const std ::string_view pulserFile , std ::string outputDir = "./" )
31+ /// \param limitHighCouplingPads if > 0 limit pads in the high coupling region to this value
32+ /// \param replaceHighCouplingPads if > 0 replace pads in the high coupling region by this value (take preceedence over limitHighCouplingPads)
33+ /// \param maxValue if > 0 limit to this maximum value
34+ void prepareCMFiles (const std ::string_view pulserFile , std ::string outputDir = "./" , float limitHighCouplingPads = 0 , float replaceHighCouplingPads = 0 , float maxValue = 0 )
3235{
3336 constexpr uint32_t DataBits = 8 ;
3437 constexpr uint32_t FractionalBits = 6 ;
@@ -115,6 +118,7 @@ void prepareCMFiles(const std::string_view pulserFile, std::string outputDir = "
115118 const int fecInPartition = fecInfo .getIndex () - partInfo .getSectorFECOffset ();
116119 const int dataWrapperID = fecInPartition >= fecOffset ;
117120 const int globalLinkID = (fecInPartition % fecOffset ) + dataWrapperID * 12 ;
121+ const auto& padPos = mapper .padPos (globalPad );
118122
119123 float pulserVal = rocPulserQtot .getValue (ipad );
120124
@@ -128,6 +132,20 @@ void prepareCMFiles(const std::string_view pulserFile, std::string outputDir = "
128132 pulserVal = MaxVal ;
129133 }
130134
135+ if (replaceHighCouplingPads > 0 ) {
136+ if (Mapper ::isHighCouplingPad (padPos .getRow (), padPos .getPad ())) {
137+ pulserVal = replaceHighCouplingPads ;
138+ }
139+ } else if (limitHighCouplingPads > 0 ) {
140+ if (Mapper ::isHighCouplingPad (padPos .getRow (), padPos .getPad ())) {
141+ pulserVal = std ::min (pulserVal , limitHighCouplingPads );
142+ }
143+ }
144+
145+ if (maxValue > 0 ) {
146+ pulserVal = std ::min (pulserVal , maxValue );
147+ }
148+
131149 const int hwChannel = getHWChannel (sampa , sampaChannel , region % 2 );
132150 // for debugging
133151 // printf("%4d %4d %4d %4d %4d: %u\n", cru.number(), globalLinkID, hwChannel, fecInfo.getSampaChip(), fecInfo.getSampaChannel(), getADCValue(pedestal));
@@ -143,22 +161,36 @@ void prepareCMFiles(const std::string_view pulserFile, std::string outputDir = "
143161
144162 const bool onlyFilled = false;
145163 // ===| k-Values full float precision |===
146- const auto outFileFloatTxt = (outputDir + "/commonMode_K_values_float.txt" );
147- const auto outFileFloatRoot = (outputDir + "/commonMode_K_values_float.root" );
164+ string nameAdd ;
165+ if (replaceHighCouplingPads > 0 ) {
166+ nameAdd = fmt ::format (".replaceHC_{:.2}" , replaceHighCouplingPads );
167+ } else if (limitHighCouplingPads > 0 ) {
168+ nameAdd = fmt ::format (".limitHC_{:.2}" , limitHighCouplingPads );
169+ }
170+
171+ if (maxValue > 0 ) {
172+ nameAdd += fmt ::format (".maxValue_{:.2}" , maxValue );
173+ }
174+
175+ string outNameBase = "commonMode_K_values" + nameAdd ;
176+ string outNameInvBase = "commonMode_inv_K_values" + nameAdd ;
177+
178+ const auto outFileFloatTxt = (outputDir + "/" + outNameBase + "_float.txt" );
179+ const auto outFileFloatRoot = (outputDir + "/" + outNameBase + "_float.root" );
148180 writeValues (outFileFloatTxt , commonModeKValuesFloat , onlyFilled );
149181
150- getCalPad < FractionalBits > (outFileFloatTxt , outFileFloatRoot , "CMkValues" );
182+ getCalPad < 0 > (outFileFloatTxt , outFileFloatRoot , "CMkValues" );
151183
152184 // ===| k-Values limited precision 2I6F |===
153- const auto outFileTxt = (outputDir + "/commonMode_K_values .txt" );
154- const auto outFileRoot = (outputDir + "/commonMode_K_values .root" );
185+ const auto outFileTxt = (outputDir + "/" + outNameBase + " .txt" );
186+ const auto outFileRoot = (outputDir + "/" + outNameBase + " .root" );
155187 writeValues (outFileTxt , commonModeKValues , onlyFilled );
156188
157189 getCalPad < FractionalBits > (outFileTxt , outFileRoot , "CMkValues" );
158190
159191 // ===| inverse k-Values limited precision 2I6F |===
160- const auto outFileInvTxt = (outputDir + "/commonMode_inv_K_values .txt" );
161- const auto outFileInvRoot = (outputDir + "/commonMode_inv_K_values .root" );
192+ const auto outFileInvTxt = (outputDir + "/" + outNameInvBase + " .txt" );
193+ const auto outFileInvRoot = (outputDir + "/" + outNameInvBase + " .root" );
162194 writeValues (outFileInvTxt , commonModeInvKValues , onlyFilled );
163195
164196 getCalPad < FractionalBits > (outFileInvTxt , outFileInvRoot , "InvCMkValues" );
0 commit comments