Skip to content

Commit 7cb0335

Browse files
committed
improved memory usage for vresetd scan
1 parent 9424b41 commit 7cb0335

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

Detectors/ITSMFT/ITS/workflow/include/ITSWorkflow/ThresholdCalibratorSpec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ class ITSThresholdCalibrator : public Task
234234
short int mRunTypeRU[N_RU] = {0};
235235
short int mRunTypeRUCopy[N_RU] = {0};
236236
short int mCdwCntRU[N_RU][N_ROW] = {{0}};
237+
short int mLoopVal[N_RU][N_ROW] = {{0}};
237238
short int mRowRU[N_RU] = {0};
238239
bool mActiveLinks[N_RU][3] = {{false}};
239240
std::set<short int> mRuSet;

Detectors/ITSMFT/ITS/workflow/src/ThresholdCalibratorSpec.cxx

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -744,41 +744,39 @@ void ITSThresholdCalibrator::extractThresholdRow(const short int& chipID, const
744744

745745
} else { // threshold, vcasn, ithr
746746

747-
for (int scan_i = 0; scan_i < ((mScanType == 'r') ? N_RANGE : N_RANGE2); scan_i++) {
748-
747+
short int iRU = getRUID(chipID);
749748
#ifdef WITH_OPENMP
750-
omp_set_num_threads(mNThreads);
749+
omp_set_num_threads(mNThreads);
751750
#pragma omp parallel for schedule(dynamic)
752751
#endif
753-
// Loop over all columns (pixels) in the row
754-
for (short int col_i = 0; col_i < this->N_COL; col_i++) {
755-
756-
// Do the threshold fit
757-
float thresh = 0., noise = 0.;
758-
bool success = false;
759-
int spoints = 0;
760-
if (isDumpS) { // already protected for multi-thread in the init
761-
mFitHist->SetName(Form("scurve_chip%d_row%d_col%d_scani%d", chipID, row, col_i, scan_i));
762-
}
752+
// Loop over all columns (pixels) in the row
753+
for (short int col_i = 0; col_i < this->N_COL; col_i++) {
754+
// Do the threshold fit
755+
float thresh = 0., noise = 0.;
756+
bool success = false;
757+
int spoints = 0;
758+
int scan_i = mScanType == 'r' ? (mLoopVal[iRU][row] - mMin) / mStep : 0;
759+
if (isDumpS) { // already protected for multi-thread in the init
760+
mFitHist->SetName(Form("scurve_chip%d_row%d_col%d_scani%d", chipID, row, col_i, scan_i));
761+
}
763762

764-
success = this->findThreshold(chipID, mPixelHits[chipID][row][col_i],
765-
this->mX, mScanType == 'r' ? N_RANGE2 : N_RANGE, thresh, noise, spoints, scan_i);
763+
success = this->findThreshold(chipID, mPixelHits[chipID][row][col_i],
764+
this->mX, mScanType == 'r' ? N_RANGE2 : N_RANGE, thresh, noise, spoints, scan_i);
766765

767-
vChipid[col_i] = chipID;
768-
vRow[col_i] = row;
769-
vThreshold[col_i] = (mScanType == 'T' || mScanType == 'r') ? (short int)(thresh * 10.) : (short int)(thresh);
770-
vNoise[col_i] = (float)(noise * 10.); // always factor 10 also for ITHR/VCASN to not have all zeros
771-
vSuccess[col_i] = success;
772-
vPoints[col_i] = spoints > 0 ? (unsigned char)(spoints) : 0;
766+
vChipid[col_i] = chipID;
767+
vRow[col_i] = row;
768+
vThreshold[col_i] = (mScanType == 'T' || mScanType == 'r') ? (short int)(thresh * 10.) : (short int)(thresh);
769+
vNoise[col_i] = (float)(noise * 10.); // always factor 10 also for ITHR/VCASN to not have all zeros
770+
vSuccess[col_i] = success;
771+
vPoints[col_i] = spoints > 0 ? (unsigned char)(spoints) : 0;
773772

774-
if (mScanType == 'r') {
775-
vMixData[col_i] = (scan_i * this->mStep) + mMin;
776-
}
777-
}
778773
if (mScanType == 'r') {
779-
this->saveThreshold(); // save before moving to the next vresetd
774+
vMixData[col_i] = mLoopVal[iRU][row];
780775
}
781776
}
777+
if (mScanType == 'r') {
778+
this->saveThreshold(); // save before moving to the next vresetd
779+
}
782780

783781
// Fill the ScTree tree
784782
if (mScanType == 'T') { // TODO: store also for other scans?
@@ -1363,9 +1361,10 @@ void ITSThresholdCalibrator::run(ProcessingContext& pc)
13631361
cwcnt = (short int)(calib.calibCounter);
13641362
// count the last N injections
13651363
short int checkVal = (mScanType == 'I') ? mMin : mMax;
1366-
if (loopval == checkVal && realcharge == mMin2) { // the second condition is relevant only for mScanType=p
1364+
if ((mScanType != 'r' && loopval == checkVal) || (mScanType == 'r' && realcharge == mMax2)) {
13671365
mCdwCntRU[iRU][row]++;
1368-
mRowRU[iRU] = row; // keep the row
1366+
mRowRU[iRU] = row; // keep the row
1367+
mLoopVal[iRU][row] = loopval; // keep loop val (relevant for VRESET2D scan only)
13691368
}
13701369
if (this->mVerboseOutput) {
13711370
LOG(info) << "RU: " << iRU << " CDWcounter: " << cwcnt << " row: " << row << " Loopval: " << loopval << " realcharge: " << realcharge << " confDBv: " << mCdwVersion;
@@ -1412,6 +1411,9 @@ void ITSThresholdCalibrator::run(ProcessingContext& pc)
14121411
if ((chipID % mChipModBase) != mChipModSel) {
14131412
continue;
14141413
}
1414+
if ((loopval == 100 || loopval == 105) && (chipID == 1 || chipID == 8)) {
1415+
LOG(info) << "Loopval: " << loopval << " Charge: " << realcharge << " Chip: " << chipID << " row: " << d.getRow() << " Col: " << d.getColumn();
1416+
}
14151417
if (d.getRow() != row && mVerboseOutput) {
14161418
LOG(info) << "iROF: " << iROF << " ChipID " << chipID << ": current row is " << d.getRow() << " (col = " << d.getColumn() << ") but the one in CW is " << row;
14171419
}
@@ -1425,7 +1427,7 @@ void ITSThresholdCalibrator::run(ProcessingContext& pc)
14251427
short int ru = getRUID(chipID);
14261428
mActiveLinks[ru][getLinkID(chipID, ru)] = true;
14271429
// check rows and allocate memory
1428-
if (mForbiddenRows.count(chipID)) {
1430+
if (mScanType != 'r' && mForbiddenRows.count(chipID)) {
14291431
for (int iforb = mForbiddenRows[chipID].size() - 1; iforb >= 0; iforb--) {
14301432
if (mForbiddenRows[chipID][iforb] == row) {
14311433
mChipsForbRows[chipID] = true;
@@ -1490,7 +1492,7 @@ void ITSThresholdCalibrator::run(ProcessingContext& pc)
14901492
}
14911493
// Check if scan of a row is finished: only for specific scans!
14921494
bool passCondition = (mCdwCntRU[iRU][mRowRU[iRU]] >= nInjScaled * nL);
1493-
if (mScanType != 'D' && mScanType != 'A' && mScanType != 'P' && mScanType != 'p' && mScanType != 'R' && mScanType != 'r' && passCondition) {
1495+
if (mScanType != 'D' && mScanType != 'A' && mScanType != 'P' && mScanType != 'p' && mScanType != 'R' && passCondition) {
14941496
// extract data from the row
14951497
for (short int iChip = 0; iChip < chipEnabled.size(); iChip++) {
14961498
short int chipID = chipEnabled[iChip];
@@ -1871,7 +1873,7 @@ void ITSThresholdCalibrator::finalize()
18711873
this->addDatabaseEntry(it_ineff->first, name, std::vector<float>(), false);
18721874
it_ineff = this->mIneffPixID.erase(it_ineff);
18731875
}
1874-
} else if (this->mScanType == 'P' || this->mScanType == 'p' || this->mScanType == 'r' || mScanType == 'R') { // pulse length scan 1D and 2D, vresetd scan 1D & 2D
1876+
} else if (this->mScanType == 'P' || this->mScanType == 'p' || mScanType == 'R') { // pulse length scan 1D and 2D, vresetd scan 1D (2D already extracted in run())
18751877
name = "Pulse";
18761878
// extract hits for the available row(s)
18771879
auto itchip = this->mPixelHits.cbegin();

0 commit comments

Comments
 (0)