Changeset 15184 for trunk/FACT++


Ignore:
Timestamp:
03/29/13 20:41:49 (12 years ago)
Author:
tbretz
Message:
Updated the calculation of on-time and eff. on-time. In some special cases when the timestamp and the trigger counter had increased by the ontime counter decreased (new run started), a negative sign could get propagated as odiff to DimTriggerRates resulting in huge values in the file. Now instead of a artificial check of the values the state change itself is used plus a sanity check that the trigger counter has not decreased an dthe on-time counter has not decreased. In both cases the start or stop of the trigger is also assumed.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/ftmctrl.cc

    r15132 r15184  
    12071207    uint64_t fTimeStampOn;
    12081208    uint32_t fTriggerCounter;
     1209    uint64_t fPrevState;
    12091210
    12101211    void UpdateFirstHeader()
     
    12531254        fDimDynamicData.Update(data);
    12541255
    1255         float    rate = -1;
    1256         uint64_t tdiff = 0;
    1257         uint64_t odiff = 0;
    1258         if (fHeader.fTimeStamp>=fTimeStamp && fHeader.fTriggerCounter>=fTriggerCounter)
    1259         {
    1260             tdiff = fHeader.fTimeStamp          -fTimeStamp;
    1261             odiff = fDynamicData.fOnTimeCounter -fTimeStampOn;
    1262 
    1263             const uint32_t cdiff = fHeader.fTriggerCounter-fTriggerCounter;
    1264             rate = tdiff==0 ? 0 : 1000000*float(cdiff)/tdiff;
    1265         }
     1256        uint64_t odiff = fDynamicData.fOnTimeCounter;
     1257        uint32_t cdiff = fHeader.fTriggerCounter;
     1258
     1259        // When the state changes (trigger on or trigger off)
     1260        // The counters will be resetted, thus in the next report
     1261        // the correct counters are the counters itself, or the correct
     1262        // offset is 0. For the first call, fPrevState is 0 (which is not
     1263        // a valid state, so it will be considered as 'changed') and
     1264        // fTimeStamp, fTimeStampOn and fTriggerCounter are also 0.
     1265        // The checks on the on-time counter and the trigger counter
     1266        // are just for the very unlikely case that we miss the state
     1267        // change because we get no updated reports in between.
     1268        const uint8_t state = fHeader.fState & FTM::States::kFtmStates;
     1269
     1270        if (state == fPrevState && fHeader.fTriggerCounter>=fTriggerCounter &&
     1271            fDynamicData.fOnTimeCounter>=fTimeStampOn)
     1272        {
     1273            odiff -= fTimeStampOn;
     1274            cdiff -= fTriggerCounter;
     1275        }
     1276
     1277        // The observation time calculated in the first report is most likely
     1278        // too large because the previous report is taken as reference,
     1279        // but this is the best what could be done.
     1280        const uint64_t tdiff = fHeader.fTimeStamp - fTimeStamp;
     1281        const float    rate  = fHeader.fTimeStamp>fTimeStamp ? 0 : 1000000*float(cdiff)/tdiff;
    12661282
    12671283        fTimeStamp      = fHeader.fTimeStamp;
    12681284        fTimeStampOn    = fDynamicData.fOnTimeCounter;
    12691285        fTriggerCounter = fHeader.fTriggerCounter;
     1286        fPrevState      = state;
    12701287
    12711288        const FTM::DimTriggerRates rates(fHeader, fDynamicData, fStaticData,
     
    13171334                                                          "|BoardRate[Hz]:Trigger rate of individual FTUs"
    13181335                                                          "|PatchRate[Hz]:Trigger rate of individual patches"
    1319                                                           "|ElapsedTime[sec]:Time elapsed since previous report"
    1320                                                           "|OnTime[sec]:OnTime elapsed since previous report"),
     1336                                                          "|ElapsedTime[s]:Time elapsed since previous report"
     1337                                                          "|OnTime[s]:OnTime elapsed since previous report"),
    13211338        fDimError         ("FTM_CONTROL/ERROR",           "X:1;S:1;S:28", ""),
    13221339        fDimFtuList       ("FTM_CONTROL/FTU_LIST",        "X:1;X:1;S:1;C:4;X:40;C:40;C:40",
     
    13691386                                                          "|NumErrors[int]:Num. of error messages"
    13701387                                                          "|NumRegister[int]:Num. of answers from a single register accesess"),
    1371         fTimeStamp(UINT64_MAX),
    1372         fTriggerCounter(UINT32_MAX)
     1388        fTimeStamp(0), fTimeStampOn(0), fTriggerCounter(0), fPrevState(0)
    13731389    {
    13741390    }
     
    19882004            fCounterStat = fFTM.GetCounter(FTM::kStaticData);
    19892005
     2006            // T::Info(" ==> TODO: Update run in database!");
    19902007            T::Message("Sending new configuration was successfull.");
    19912008
Note: See TracChangeset for help on using the changeset viewer.