Changeset 15186


Ignore:
Timestamp:
Mar 30, 2013, 11:46:32 AM (6 years ago)
Author:
tbretz
Message:
Also added a consistency check on the TimeStamp. Now everything should be consistent and we can remove the negative rate.
File:
1 edited

Legend:

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

    r15185 r15186  
    12561256        uint64_t odiff = fDynamicData.fOnTimeCounter;
    12571257        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.
     1258        uint64_t tdiff = fHeader.fTimeStamp;
     1259
     1260        // The easiest way to detect whether the counters have been
     1261        // reset or not is to detect a state change, because with
     1262        // every state change they are reset. However, there are cases
     1263        // when the trigger is switched on already (data run) and
     1264        // the trigger is turned off ans switched on again within
     1265        // a very short time, that the state of the previous and the
     1266        // new report is the same. So in addition we have to check
     1267        // for other indications. Any counter decreasing is a hint.
     1268        // None of them should ever decrease. So all three are checked.
    12681269        const uint8_t state = fHeader.fState & FTM::States::kFtmStates;
    12691270
    12701271        const bool first = state!=fPrevState ||
     1272            fHeader.fTimeStamp<fTimeStamp ||
    12711273            fHeader.fTriggerCounter<fTriggerCounter ||
    12721274            fDynamicData.fOnTimeCounter<fTimeStampOn;
     
    12741276        if (!first)
    12751277        {
     1278            tdiff -= fTimeStamp;
    12761279            odiff -= fTimeStampOn;
    12771280            cdiff -= fTriggerCounter;
     
    12811284        // too large because the previous report is taken as reference,
    12821285        // but this is the best what could be done.
    1283         const uint64_t tdiff = fHeader.fTimeStamp - fTimeStamp;
    1284         const float    rate  = fHeader.fTimeStamp>fTimeStamp ? 0 : 1000000*float(cdiff)/tdiff;
     1286        const float rate = tdiff==0 ? 0 : 1e6*cdiff/tdiff;
    12851287
    12861288        fTimeStamp      = fHeader.fTimeStamp;
     
    12901292
    12911293        const FTM::DimTriggerRates rates(fHeader, fDynamicData, fStaticData,
    1292                                          first ? -1 : rate, first ? -1 : tdiff*1e-6, odiff*1e-6);
     1294                                         rate, tdiff*1e-6, odiff*1e-6);
    12931295
    12941296        fDimTriggerRates.setQuality(fHeader.fState);
Note: See TracChangeset for help on using the changeset viewer.