Changeset 17658


Ignore:
Timestamp:
04/06/14 13:54:26 (11 years ago)
Author:
tbretz
Message:
Even if the event is not valid, attach the latest trigger counter to it.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

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

    r17332 r17658  
    850850        return true;
    851851
     852    // If we will have a software trigger which prevents single events from writing,
     853    // the logic of writing the stop time and the trigger counters need to be adapted.
     854    // Currently it is just the values of the last valid event.
    852855    bool rc1 = true;
    853856    if (evt->valid())
     
    896899bool procEvt(const shared_ptr<EVT_CTRL2> &evt)
    897900{
     901    RUN_CTRL2 &run = *evt->runCtrl;
     902
     903    bool check = true;
    898904    if (evt->valid())
    899905    {
     
    915921            event->BoardTime[ib] = evt->FADhead[ib].time;
    916922
    917         RUN_CTRL2 &run = *evt->runCtrl;
    918 
    919         // Physics trigger
    920         if (evt->trgTyp && !(evt->trgTyp & FAD::EventHeader::kAll))
    921             run.triggerCounter[0]++;
    922         // Pure pedestal trigger
    923         else  if ((evt->trgTyp&FAD::EventHeader::kPedestal) && !(evt->trgTyp&FAD::EventHeader::kTIM))
    924             run.triggerCounter[1]++;
    925         // external light pulser trigger
    926         else if (evt->trgTyp & FAD::EventHeader::kLPext)
    927             run.triggerCounter[2]++;
    928         // time calibration triggers
    929         else if (evt->trgTyp & (FAD::EventHeader::kTIM|FAD::EventHeader::kPedestal))
    930             run.triggerCounter[3]++;
    931         // internal light pulser trigger
    932         else if (evt->trgTyp & FAD::EventHeader::kLPint)
    933             run.triggerCounter[4]++;
    934         // external trigger input 1
    935         else if (evt->trgTyp & FAD::EventHeader::kExt1)
    936             run.triggerCounter[5]++;
    937         // external trigger input 2
    938         else if (evt->trgTyp & FAD::EventHeader::kExt2)
    939             run.triggerCounter[6]++;
    940         // other triggers
    941         else
    942             run.triggerCounter[7]++;
    943 
    944         evt->triggerCounter = run.triggerCounter;
    945 
    946         if (!eventCheck(*evt))
    947         {
    948             secondaryQueue.emplace(new EVT_CTRL2(kRequestEventCheckFailed, evt->runCtrl));
    949             return true;
    950         }
    951     }
    952 
    953     // If file is open post the event for being written
    954     secondaryQueue.post(evt);
     923        check = eventCheck(*evt);
     924
     925        // If the event is valid, increase the trigger counter accordingly
     926        if (check)
     927        {
     928            // Physics trigger
     929            if (evt->trgTyp && !(evt->trgTyp & FAD::EventHeader::kAll))
     930                run.triggerCounter[0]++;
     931            // Pure pedestal trigger
     932            else  if ((evt->trgTyp&FAD::EventHeader::kPedestal) && !(evt->trgTyp&FAD::EventHeader::kTIM))
     933                run.triggerCounter[1]++;
     934            // external light pulser trigger
     935            else if (evt->trgTyp & FAD::EventHeader::kLPext)
     936                run.triggerCounter[2]++;
     937            // time calibration triggers
     938            else if (evt->trgTyp & (FAD::EventHeader::kTIM|FAD::EventHeader::kPedestal))
     939                run.triggerCounter[3]++;
     940            // internal light pulser trigger
     941            else if (evt->trgTyp & FAD::EventHeader::kLPint)
     942                run.triggerCounter[4]++;
     943            // external trigger input 1
     944            else if (evt->trgTyp & FAD::EventHeader::kExt1)
     945                run.triggerCounter[5]++;
     946            // external trigger input 2
     947            else if (evt->trgTyp & FAD::EventHeader::kExt2)
     948                run.triggerCounter[6]++;
     949            // other triggers
     950            else
     951                run.triggerCounter[7]++;
     952        }
     953    }
     954
     955    // If this is an invalid event, the current triggerCounter needs to be copied
     956    // because runClose will use that one to update the TRIGGER_COUNTER.
     957    // When closing the file, the trigger counter of the last successfully
     958    // written event is used.
     959    evt->triggerCounter = run.triggerCounter;
     960
     961    // If event check has failed, skip the event and post a close request instead.
     962    // Otherwise, if file is open post the event for being written
     963    if (!check)
     964        secondaryQueue.emplace(new EVT_CTRL2(kRequestEventCheckFailed, evt->runCtrl));
     965    else
     966        secondaryQueue.post(evt);
    955967
    956968    return true;
  • trunk/FACT++/src/EventBuilder.h

    r17358 r17658  
    7474    FileStatus_t fileStat;
    7575
    76     std::array<uint32_t, 8> triggerCounter;
     76    std::array<uint32_t, 8> triggerCounter;  // triggerCounter must only be manipulated in procEvt to keep it thread safe
    7777
    7878    std::shared_ptr<DrsCalibration> calib;
     
    134134    int closeRequest;
    135135
    136     std::array<uint32_t, 8> triggerCounter;
     136    std::array<uint32_t, 8> triggerCounter;  // triggerCounter must only be manipulated in procEvt to keep it thread safe
    137137
    138138    std::shared_ptr<RUN_CTRL2> runCtrl;
Note: See TracChangeset for help on using the changeset viewer.