Changeset 11565 for trunk/FACT++


Ignore:
Timestamp:
07/24/11 17:52:12 (13 years ago)
Author:
tbretz
Message:
Automatically initialize the Converter from the defined FITS format.
File:
1 edited

Legend:

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

    r11545 r11565  
    407407    }
    408408
     409        int fRoiTM;
     410
    409411    // --------------------------------------------------------------------------
    410412    //
     
    414416    //
    415417    bool OpenFile(RUN_HEAD* h)
    416     {
     418        {
    417419        //Form filename, based on runid and run-type
    418420        const string fileName = FormFileName(GetRunId(), "fits");
     
    451453        }
    452454
     455        h->NroiTM = 0;
     456
    453457        vector<string> colNames;
    454458        vector<string> dataTypes;
    455         AddColumnEntry(colNames, dataTypes, 1,            'J', "EventNum");
    456         AddColumnEntry(colNames, dataTypes, 1,            'I', "TriggerType");
    457         AddColumnEntry(colNames, dataTypes, 1,            'I', "NumBoards");
    458         AddColumnEntry(colNames, dataTypes, 1,            'I', "reserved");
    459         AddColumnEntry(colNames, dataTypes, 1,            'J', "SoftTrig");
    460         AddColumnEntry(colNames, dataTypes, 2,            'J', "PCTime");
    461         AddColumnEntry(colNames, dataTypes, NBOARDS,      'J', "BoardTime");
    462         AddColumnEntry(colNames, dataTypes, NPIX,         'I', "StartCell");
    463         AddColumnEntry(colNames, dataTypes, NTMARK,       'I', "StartTM");
    464         AddColumnEntry(colNames, dataTypes, NPIX*h->Nroi, 'I', "Data");
     459        AddColumnEntry(colNames, dataTypes, 1,                'J', "EventNum");
     460        AddColumnEntry(colNames, dataTypes, 1,                'I', "TriggerType");
     461        AddColumnEntry(colNames, dataTypes, 1,                'J', "NumBoards");
     462        AddColumnEntry(colNames, dataTypes, 1,                'J', "reserved");
     463        AddColumnEntry(colNames, dataTypes, 1,                'J', "SoftTrig");
     464        AddColumnEntry(colNames, dataTypes, 2,                'J', "PCTime");
     465        AddColumnEntry(colNames, dataTypes, h->NBoard,        'J', "BoardTime");
     466        AddColumnEntry(colNames, dataTypes, h->NPix,          'I', "StartCellData");
     467        AddColumnEntry(colNames, dataTypes, h->NTm,           'I', "StartCellTimeMarker");
     468        AddColumnEntry(colNames, dataTypes, h->NPix*h->Nroi,  'I', "Data");
     469        AddColumnEntry(colNames, dataTypes, h->NTm*h->NroiTM, 'I', "TimeMarker");
    465470
    466471        // Write length of physical pipeline (1024)
    467472
     473        /*
    468474        ostringstream fmt;
    469         fmt << "I:1;S:1;I:1;I:1;I:1;I:2";
    470         fmt << ";I:" << NBOARDS;
    471         fmt << ";S:" << NPIX;
    472         fmt << ";S:" << NTMARK;
    473         fmt << ";S:" << NPIX*h->Nroi;
    474 
    475         fConv = new Converter(fmt.str());
     475        fmt << "I:1";   // uint32_t EventNum
     476        fmt << ";S:1";  // uint16_t TriggerType
     477        fmt << ";I:5";  // uint32_t NumBoards, reserved, SoftTrig, PCTime, PCUsec
     478        fmt << ";I:" << h->NBoard;       // uint32_t BoardTime[NBOARDS]
     479        fmt << ";S:" << h->NPix+h->NTm;  // int16_t StartPix[NPIX], StartTM[NTMARK]
     480        fmt << ";S:" << h->NPix*h->Nroi + h->NTm*h->NroiTM; // int16_t Adc_Data[]
     481        */
     482        fRoiTM = h->NroiTM;
     483
     484        cout << "==> " << Converter::ToFormat(dataTypes) << endl;
     485
     486        fConv = new Converter(Converter::ToFormat(dataTypes));
    476487
    477488        //actually create the table
     
    515526        WriteKey("NTMARK",   h->NTm,      "Number of Time marks");
    516527        WriteKey("NROI",     h->Nroi,     "Number of slices per pixels");
     528        WriteKey("NROITM",   h->NroiTM,   "Number of slices per time-marker");
    517529
    518530        const Time now;
     
    526538        WriteKey("DAQ",      "DRS4", "");
    527539
    528         Fatal("Write sampling frequency...");
     540        WriteKey("ADCCOUNT",  2.0f,       "ADC Counts per milliVolt");
     541
     542        Info("==> TODO: Write sampling frequency...");
    529543
    530544        // Write a single key for:
     
    637651        fNumRows++;
    638652
    639         const vector<char> data = fConv->ToFits(((char*)e)+2, sizeof(EVENT)+NPIX*e->Roi*2-2);
     653        // FIXME: Get NPIX and NTMARK from header
     654        const size_t sz = sizeof(EVENT) + sizeof(e->StartPix)*e->Roi+sizeof(e->StartTM)*fRoiTM;
     655
     656        const vector<char> data = fConv->ToFits(reinterpret_cast<char*>(e)+2, sz-2);
    640657
    641658        // column size pointer
     
    11601177        catch (const exception &e)
    11611178        {
     1179            fMsg.Error("Exception trying to open file: "+string(e.what()));
    11621180            return 0;
    11631181        }
     
    13511369         */
    13521370
    1353         /*
    13541371        const FAD::EventHeader *beg = reinterpret_cast<FAD::EventHeader*>(fadhd);
    1355         const FAD::EventHeader *end = reinterpret_cast<FAD::EventHeader*>(fadhd)+41;
     1372        const FAD::EventHeader *end = reinterpret_cast<FAD::EventHeader*>(fadhd)+40;
    13561373
    13571374        for (const FAD::EventHeader *ptr=beg; ptr!=end; ptr++)
     
    13781395            if (ptr->fVersion     != beg->fVersion)
    13791396                return -1;
    1380         }*/
     1397        }
    13811398
    13821399        // check REFCLK_frequency
Note: See TracChangeset for help on using the changeset viewer.