Changeset 17329


Ignore:
Timestamp:
11/21/13 17:14:09 (11 years ago)
Author:
tbretz
Message:
Removed trigger counter - this is now done globally; adapted function calls to get access to the new information.
Location:
trunk/FACT++/src
Files:
4 edited

Legend:

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

    r16055 r17329  
    22
    33#include "HeadersFAD.h"
    4 #include "FAD.h"
     4#include "EventBuilder.h"
    55#include "Converter.h"
    66
     
    1010DataWriteFits::~DataWriteFits()
    1111{
    12     Close();
     12    if (fFile.IsOpen())
     13    {
     14        WriteFooter();
     15        fFile.Close();
     16    }
     17
    1318    delete fConv;
    1419}
     
    187192    fTstop[0]  = 0;
    188193
    189     memset(fTriggerCounter.data(), 0, fTriggerCounter.size()*sizeof(uint32_t));
     194    fTriggerCounter.fill(0);
    190195
    191196    //Last but not least, add header keys that will be updated when closing the file
    192     return WriteFooter(NULL);
     197    return WriteFooter();
    193198}
    194199
     
    198203//! @param e the pointer to the EVENT
    199204//
    200 bool DataWriteFits::WriteEvt(const EVENT &e)
     205bool DataWriteFits::WriteEvt(const EVT_CTRL2 &evt)
    201206{
    202207    if (!fFile.AddRow())
    203208        return false;
    204209
    205     if (e.TriggerType && !(e.TriggerType & FAD::EventHeader::kAll))
    206         fTriggerCounter[0]++;
    207     else  if ((e.TriggerType&FAD::EventHeader::kPedestal) && !(e.TriggerType&FAD::EventHeader::kTIM))
    208         fTriggerCounter[1]++;
    209     else if (e.TriggerType & FAD::EventHeader::kLPext)
    210         fTriggerCounter[2]++;
    211     else if (e.TriggerType & (FAD::EventHeader::kTIM|FAD::EventHeader::kPedestal))
    212         fTriggerCounter[3]++;
    213     else if (e.TriggerType & FAD::EventHeader::kLPint)
    214         fTriggerCounter[4]++;
    215     else if (e.TriggerType & FAD::EventHeader::kExt1)
    216         fTriggerCounter[5]++;
    217     else if (e.TriggerType & FAD::EventHeader::kExt2)
    218         fTriggerCounter[6]++;
    219     else
    220         fTriggerCounter[7]++;
     210    fTriggerCounter = evt.runCtrl->triggerCounter;
     211
     212    const EVENT &e = *evt.fEvent;
    221213
    222214    memcpy(fTstop, &e.PCTime, 2*sizeof(uint32_t));
     
    232224}
    233225
    234 bool DataWriteFits::WriteFooter(const RUN_TAIL */*rt*/)
     226bool DataWriteFits::WriteFooter()
    235227{
    236228    try
     
    288280//! @param rt the pointer to the RUN_TAIL data structure
    289281//
    290 bool DataWriteFits::Close(const RUN_TAIL *rt)
     282bool DataWriteFits::Close(const EVT_CTRL2 &evt)
    291283{
    292284    if (!fFile.IsOpen())
    293285        return false;
    294286
    295     WriteFooter(rt);
     287    // Just for safety
     288    fTriggerCounter = evt.triggerCounter;
     289    WriteFooter();
    296290
    297291    fFile.Close();
  • trunk/FACT++/src/DataWriteFits.h

    r16055 r17329  
    2323        void WriteKey(const string &name, const int idx, const T &value, const string &comment);
    2424
    25     bool WriteFooter(const RUN_TAIL *rt);
     25    bool WriteFooter();
    2626
    2727    virtual int GetDrsStep() const { return -1; }
     
    3636
    3737    bool Open(const RUN_HEAD &h, const FAD::RunDescription &d);
    38     bool WriteEvt(const EVENT &e);
    39     bool Close(const RUN_TAIL *rt = 0);
     38    bool WriteEvt(const EVT_CTRL2 &);
     39    bool Close(const EVT_CTRL2 &);
    4040};
    4141
  • trunk/FACT++/src/DataWriteFits2.cc

    r17299 r17329  
    44
    55#include "HeadersFAD.h"
    6 #include "FAD.h"
     6#include "EventBuilder.h"
    77
    88#include "externals/factofits.h"
     
    156156    fTstop[1] = 0;
    157157
    158     memset(fTriggerCounter.data(), 0, fTriggerCounter.size()*sizeof(uint32_t));
    159 
    160     //Last but not least, add header keys that will be updated when closing the file
    161     WriteFooter(NULL);
     158    fTriggerCounter.fill(0);
     159
     160    WriteFooter();
    162161
    163162    fFile->WriteTableHeader("Events");
     
    248247//! @param e the pointer to the EVENT
    249248//
    250 bool DataWriteFits2::WriteEvt(const EVENT &e)
    251 {
    252     if (e.TriggerType && !(e.TriggerType & FAD::EventHeader::kAll))
    253         fTriggerCounter[0]++;
    254     else  if ((e.TriggerType&FAD::EventHeader::kPedestal) && !(e.TriggerType&FAD::EventHeader::kTIM))
    255         fTriggerCounter[1]++;
    256     else if (e.TriggerType & FAD::EventHeader::kLPext)
    257         fTriggerCounter[2]++;
    258     else if (e.TriggerType & (FAD::EventHeader::kTIM|FAD::EventHeader::kPedestal))
    259         fTriggerCounter[3]++;
    260     else if (e.TriggerType & FAD::EventHeader::kLPint)
    261         fTriggerCounter[4]++;
    262     else if (e.TriggerType & FAD::EventHeader::kExt1)
    263         fTriggerCounter[5]++;
    264     else if (e.TriggerType & FAD::EventHeader::kExt2)
    265         fTriggerCounter[6]++;
    266     else
    267         fTriggerCounter[7]++;
    268 
    269     fTstop[0] = e.PCTime;
    270     fTstop[1] = e.PCUsec;
     249bool DataWriteFits2::WriteEvt(const EVT_CTRL2 &evt)
     250{
     251    fTriggerCounter = evt.runCtrl->triggerCounter;
     252
     253    fTstop[0] = evt.time.tv_sec;
     254    fTstop[1] = evt.time.tv_usec;
     255
     256    const EVENT &e = *evt.fEvent;
    271257
    272258    const int realRoiTM = (e.RoiTM > e.Roi) ? e.Roi : 0;
     
    294280}
    295281
    296 void DataWriteFits2::WriteFooter(const RUN_TAIL */*rt*/)
     282void DataWriteFits2::WriteFooter()
    297283{
    298284    //FIXME shouldn't we convert start and stop time to MjD first ?
     
    330316//! @param rt the pointer to the RUN_TAIL data structure
    331317//
    332 bool DataWriteFits2::Close(const RUN_TAIL *rt)
     318bool DataWriteFits2::Close(const EVT_CTRL2 &evt)
    333319{
    334320    if (!fFile->is_open())
     
    340326    try
    341327    {
    342         WriteFooter(rt);
     328        // Just for safety
     329        fTriggerCounter = evt.triggerCounter;
     330
     331        WriteFooter();
    343332    }
    344333    catch (const exception &e)
  • trunk/FACT++/src/DataWriteFits2.h

    r17266 r17329  
    2020
    2121    void WriteHeader(const RUN_HEAD &h, const FAD::RunDescription &d);
    22     void WriteFooter(const RUN_TAIL *rt);
     22    void WriteFooter();
    2323
    2424    virtual int GetDrsStep() const { return -1; }
     
    2929
    3030    bool Open(const RUN_HEAD &h, const FAD::RunDescription &d);
    31     bool WriteEvt(const EVENT &e);
    32     bool Close(const RUN_TAIL *rt = 0);
     31    bool WriteEvt(const EVT_CTRL2 &e);
     32    bool Close(const EVT_CTRL2 &);
    3333
    3434    Time GetTstart() const { return Time(fTstart[0], fTstart[1]); }
Note: See TracChangeset for help on using the changeset viewer.