@@ -74,6 +74,8 @@ void ITSThresholdCalibrator::init(InitContext& ic)
7474 LOG (warning) << " mColStep = " << mColStep << " : saving s-curves of only 1 pixel (pix 0) per row" ;
7575 }
7676
77+ isLocal = ic.options ().get <bool >(" local" );
78+
7779 std::string fittype = ic.options ().get <std::string>(" fittype" );
7880 if (fittype == " derivative" ) {
7981 this ->mFitType = DERIVATIVE;
@@ -1002,6 +1004,7 @@ void ITSThresholdCalibrator::setRunType(const short int& runtype)
10021004 this ->mMax = 0 ;
10031005 this ->N_RANGE = mMax - mMin + 1 ;
10041006 this ->mCheckExactRow = false ;
1007+ mRowStep = 1 ;
10051008
10061009 } else if (runtype == ANALOGUE_SCAN) {
10071010 // Analogue scan -- only storing one value per chip, no fit needed
@@ -1488,10 +1491,13 @@ void ITSThresholdCalibrator::run(ProcessingContext& pc)
14881491 if (ruIndex < 0 ) {
14891492 continue ;
14901493 }
1491- short int nL = ruIndex > 47 ? 2 : 3 ; // total number of links per RU
1494+ short int nL = getNumberOfActiveLinks (mActiveLinks [ruIndex]);
1495+ if (isLocal) {
1496+ nL = ruIndex > 47 ? 2 : 3 ;
1497+ }
14921498 std::vector<short int > chipEnabled = getChipListFromRu (ruIndex, mActiveLinks [ruIndex]); // chip boundaries
14931499 // Fill the chipDone info string
1494- if (mRunTypeRUCopy [ruIndex] == nInjScaled * nL) {
1500+ if (mRunTypeRUCopy [ruIndex] == nInjScaled * nL && nL > 0 ) {
14951501 for (short int iChip = 0 ; iChip < chipEnabled.size (); iChip++) {
14961502 if ((chipEnabled[iChip] % mChipModBase ) != mChipModSel ) {
14971503 continue ;
@@ -1501,10 +1507,20 @@ void ITSThresholdCalibrator::run(ProcessingContext& pc)
15011507 mRunTypeRUCopy [ruIndex] = 0 ; // reset here is safer (the other counter is reset in finalize)
15021508 }
15031509 // Check if scan of a row is finished: only for specific scans!
1504- bool passCondition = true ;
1510+ bool passCondition = nL > 0 ? true : false ;
15051511 for (int j1 = 0 ; j1 < N_RANGE2; j1++) {
15061512 for (int j2 = 0 ; j2 < N_RANGE; j2++) {
1507- if (mScanType == ' t' ) { // ToT scan is done in specific ranges depending on charge (see ITSComm)
1513+ if (mScanType == ' D' || mScanType == ' A' ) { // D and A are processed in finalize and include >1 rows: row data can be mixed in time!
1514+ for (int ir = 0 ; ir < mRowScan ; ir += mRowStep ) {
1515+ if (!mCdwCntRU [ruIndex].count (ir)) {
1516+ passCondition = false ;
1517+ break ;
1518+ } else if (mCdwCntRU [ruIndex][ir][j1][j2] < nInjScaled * nL) {
1519+ passCondition = false ;
1520+ break ;
1521+ }
1522+ }
1523+ } else if (mScanType == ' t' ) { // ToT scan is done in specific ranges depending on charge (see ITSComm)
15081524 if ((j1 == 0 && j2 < ((600 - mMin ) / mStep )) || (j2 >= ((600 - mMin ) / mStep ) && j2 <= ((800 - mMin ) / mStep )) || (j1 == 1 && j2 > ((800 - mMin ) / mStep ))) {
15091525 if (mCdwCntRU [ruIndex][row][j1][j2] < nInjScaled * nL) {
15101526 passCondition = false ;
@@ -1548,6 +1564,19 @@ void ITSThresholdCalibrator::run(ProcessingContext& pc)
15481564 if (mRunTypeRU [ruIndex] >= nInjScaled * nL && passCondition) {
15491565 mFlagsRU [ruIndex] = true ;
15501566 finalize ();
1567+ // Reset Active Links, mRunTypeRU, mFlagsRU (needed only for local data replay!)
1568+ if (mVerboseOutput ) {
1569+ LOG (info) << " Resetting links of RU " << ruIndex;
1570+ }
1571+ if (!isLocal) {
1572+ mActiveLinks [ruIndex][0 ] = 0 ;
1573+ mActiveLinks [ruIndex][1 ] = 0 ;
1574+ mActiveLinks [ruIndex][2 ] = 0 ;
1575+ mRunTypeRU [ruIndex] = 0 ;
1576+ mFlagsRU [ruIndex] = false ;
1577+ mCdwCntRU .erase (ruIndex); // for D,A,P,R (not entering the if above)
1578+ }
1579+
15511580 LOG (info) << " Shipping all outputs to aggregator (before endOfStream arrival!)" ;
15521581 pc.outputs ().snapshot (Output{" ITS" , " TSTR" , (unsigned int )mChipModSel }, this ->mTuning );
15531582 pc.outputs ().snapshot (Output{" ITS" , " PIXTYP" , (unsigned int )mChipModSel }, this ->mPixStat );
@@ -1810,6 +1839,7 @@ void ITSThresholdCalibrator::finalize()
18101839 }
18111840 std::vector<float > data = {50 , 0 , 0 , 0 , 0 };
18121841 addDatabaseEntry (chipList[i], name, data, false );
1842+ isChipDB[chipList[i]] = true ;
18131843 }
18141844 }
18151845 }
@@ -1954,9 +1984,9 @@ void ITSThresholdCalibrator::endOfStream(EndOfStreamContext& ec)
19541984{
19551985 if (!isEnded && !mRunStopRequested ) {
19561986 LOGF (info, " endOfStream report:" , mSelfName );
1957- if (isCRUITS) {
1958- finalize ();
1959- }
1987+ LOG (info) << " Calling finalize(), doing nothing if scan has properly ended, otherwise save partial data in ROOT trees as backup " ;
1988+ finalize ();
1989+
19601990 this ->finalizeOutput ();
19611991 isEnded = true ;
19621992 }
@@ -1969,6 +1999,8 @@ void ITSThresholdCalibrator::stop()
19691999{
19702000 if (!isEnded) {
19712001 LOGF (info, " stop() report:" , mSelfName );
2002+ LOG (info) << " Calling finalize(), doing nothing if scan has properly ended, otherwise save partial data in ROOT trees as backup" ;
2003+ finalize ();
19722004 this ->finalizeOutput ();
19732005 isEnded = true ;
19742006 }
@@ -2036,7 +2068,8 @@ DataProcessorSpec getITSThresholdCalibratorSpec(const ITSCalibInpConf& inpConf)
20362068 {" charge-b" , VariantType::Int, 0 , {" To use with --calculate-slope, it defines the charge (in DAC) for the 2nd point used for the slope calculation" }},
20372069 {" meb-select" , VariantType::Int, -1 , {" Select from which multi-event buffer consider the hits: 0,1 or 2" }},
20382070 {" s-curve-col-step" , VariantType::Int, 8 , {" save s-curves points to tree every s-curve-col-step pixels on 1 row" }},
2039- {" percentage-cut" , VariantType::Int, 25 , {" discard chip in ITHR/VCASN scan if the percentage of success is less than this cut" }}}};
2071+ {" percentage-cut" , VariantType::Int, 25 , {" discard chip in ITHR/VCASN scan if the percentage of success is less than this cut" }},
2072+ {" local" , VariantType::Bool, false , {" Enable in case of data replay of scans processed row by row or in 1 go in finalize() but with partial data in the raw TF (e.g. data dump stopped before the real end of run)" }}}};
20402073}
20412074} // namespace its
20422075} // namespace o2
0 commit comments