Changeset 16105


Ignore:
Timestamp:
05/24/13 13:54:56 (11 years ago)
Author:
tbretz
Message:
Added the new structures EVT_CTRL2 and RUN_CTRL2
File:
1 edited

Legend:

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

    r15473 r16105  
    1414
    1515*/
    16 extern int  g_runStat   ;  //main steering variable
    1716extern int  g_reset     ;  //>0 = reset different levels of eventbuilder
    18 extern int  g_maxProc   ;
    1917extern size_t g_maxMem  ;  //maximum memory allowed for buffer
    2018
     
    2321extern uint gi_NumConnect[NBOARDS];   //4 crates * 10 boards
    2422
     23class DrsCalibration;
     24
     25enum FileStatus_t
     26{
     27    kFileNotYetOpen,
     28    kFileOpen,
     29    kFileClosed
     30};
     31
     32enum CloseRequest_t
     33{
     34    kRequestNone = 0,
     35    kRequestManual = 1,
     36    kRequestTimeout = 2,
     37    kRequestConnectionChange = 4
     38};
     39
     40
     41struct RUN_CTRL2
     42{
     43    int64_t runId ;      // Run number
     44
     45    time_t openTime;     // Time when first event (first board) was received
     46    time_t lastTime;     // Time when last event was received (set when first board data received)
     47    time_t closeTime;    // Time when run should be closed
     48    uint32_t night;      // night as int as determined for this run
     49
     50    uint32_t lastEvt;    // number of events received (counted when the first board was received)
     51    uint32_t maxEvt;     // maximum number which should be written to file
     52
     53    uint16_t roi0;       // roi for normal pixels
     54    uint16_t roi8;       // roi for pixels8
     55
     56    std::string runType;
     57
     58    FileStatus_t fileStat;
     59    int closeRequest;
     60
     61    std::shared_ptr<DrsCalibration> calib;
     62
     63    RUN_CTRL2() : runId(-1), lastTime(0), lastEvt(0), maxEvt(1<<31), fileStat(kFileNotYetOpen), closeRequest(kRequestNone)
     64    {
     65        // runId   = -1;
     66        // fileId  = kFileNotYetOpen;
     67        // lastEvt =  0;    // Number of events partially started to read
     68        // actEvt  =  0;    // Number of written events
     69        // maxEvt  = 1<<31; // max number events allowed (~2400min @ 250Hz)
     70
     71    }
     72    //~RUN_CTRL2();
     73};
     74
     75struct EVT_CTRL2
     76{
     77    int64_t   runNum;
     78    uint32_t  evNum;
     79
     80    uint32_t  trgNum;
     81    uint32_t  trgTyp;
     82    uint32_t  fadLen;
     83
     84    uint32_t  nBoard;
     85    int16_t   board[NBOARDS];
     86
     87    uint16_t  nRoi;
     88    uint16_t  nRoiTM;
     89
     90    timeval   time;
     91    uint8_t   Errors[4];
     92
     93    std::shared_ptr<PEVNT_HEADER> FADhead;
     94    EVENT *fEvent;
     95
     96    std::shared_ptr<RUN_CTRL2> runCtrl;
     97
     98    EVT_CTRL2(std::shared_ptr<RUN_CTRL2> run=std::shared_ptr<RUN_CTRL2>()) : runNum(-1), runCtrl(run)
     99    {
     100        Errors[0] = 0;
     101        Errors[1] = 0;
     102        Errors[2] = 0;
     103        Errors[3] = 0;
     104
     105        //flag all boards as unused
     106        nBoard = 0;
     107        for (int b=0; b<NBOARDS; b++)
     108            board[b] = -1;
     109    }
     110
     111    operator RUN_HEAD() const
     112    {
     113        RUN_HEAD rh;
     114
     115        rh.Nroi    = nRoi;
     116        rh.NroiTM  = nRoiTM;
     117        rh.RunTime = time.tv_sec;
     118        rh.RunUsec = time.tv_usec;
     119
     120        memcpy(rh.FADhead, FADhead.get(), NBOARDS*sizeof(PEVNT_HEADER));
     121
     122        return rh;
     123    }
     124
     125    void initEvent(const std::shared_ptr<PEVNT_HEADER> &mem)
     126    {
     127        FADhead = mem;
     128        fEvent  = reinterpret_cast<EVENT*>(mem.get()+NBOARDS);
     129
     130        memset(fEvent->Adc_Data, 0, (NPIX+NTMARK)*2*nRoi);
     131
     132        //flag all pixels as unused
     133        for (int k = 0; k < NPIX; k++)
     134            fEvent->StartPix[k] = -1;
     135
     136        //flag all TMark as unused
     137        for (int k = 0; k < NTMARK; k++)
     138            fEvent->StartTM[k] = -1;
     139
     140        fEvent->NumBoards   = 0;
     141        fEvent->SoftTrig    = 0;
     142        fEvent->PCTime      = time.tv_sec;
     143        fEvent->PCUsec      = time.tv_usec;
     144        fEvent->Roi         = nRoi;
     145        fEvent->RoiTM       = nRoiTM;
     146        fEvent->EventNum    = evNum;
     147        fEvent->TriggerNum  = trgNum;
     148        fEvent->TriggerType = trgTyp;
     149    }
     150};
     151
    25152#endif
Note: See TracChangeset for help on using the changeset viewer.