Changeset 11871 for trunk


Ignore:
Timestamp:
08/09/11 23:55:12 (13 years ago)
Author:
tbretz
Message:
added the possibility to read the pixel map from a file
Location:
trunk/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/Changelog

    r11870 r11871  
    2727     - when setting a pixel map, subtract one to get from the id to
    2828       the index
     29
     30   * mraw/MRawFitsRead.[h,cc]:
     31     - added the possibility to read the pixel map from a file
    2932
    3033
  • trunk/Mars/mraw/MRawFitsRead.cc

    r11690 r11871  
    3838#include "MRawFitsRead.h"
    3939
     40#include <fstream>
     41
    4042#include <TClass.h>
    4143
     
    6466    : MRawFileRead(fname, name, title)
    6567{
     68}
     69
     70Bool_t MRawFitsRead::LoadMap(const char *name)
     71{
     72    fPixelMap.resize(1440);
     73
     74    ifstream fin(name);
     75
     76    int l = 0;
     77
     78    string buf;
     79    while (getline(fin, buf, '\n'))
     80    {
     81        if (l>1439)
     82            break;
     83
     84        const TString bf = TString(buf.c_str()).Strip(TString::kBoth);
     85        if (bf[0]=='#')
     86            continue;
     87
     88        stringstream str(bf.Data());
     89
     90        int index, cbpx;
     91
     92        str >> index;
     93        str >> cbpx;
     94
     95        const int c =  cbpx/1000;
     96        const int b = (cbpx/100)%10;
     97        const int p = (cbpx/10)%10;
     98        const int x =  cbpx%10;
     99
     100        const int hw = x+p*9+b*36+c*360;
     101        if (hw>1439)
     102            break;
     103
     104        fPixelMap[hw] = index;
     105        l++;
     106    }
     107
     108    if (l!=1440)
     109    {
     110        gLog << err << "ERROR - Problems reading FACTmapV5.txt" << endl;
     111        fPixelMap.resize(0);
     112        return kFALSE;
     113    }
     114
     115    return kTRUE;
    66116}
    67117
     
    91141    fRawRunHeader->SetObservation("", "FACT");
    92142    fRawRunHeader->SetRunInfo(0, fin.GetUInt("NIGHT"), fin.GetUInt("RUNID"));
    93     fRawRunHeader->InitFact(fin.GetUInt("NPIX")/9, 9, fin.GetUInt("NROI"));
     143    fRawRunHeader->InitFact(fin.GetUInt("NPIX")/9, 9, fin.GetUInt("NROI"), fPixelMap.size()==0?0:fPixelMap.data());
    94144    fRawRunHeader->SetFormat(0xf172, fin.GetUInt("BLDVER"));
    95145    fRawRunHeader->SetRunType(0/*data*/);
     
    129179        return kFALSE;
    130180
    131     fRawEvtData1->SetIndices();
     181    fRawEvtData1->SetIndices(fRawRunHeader->GetPixAssignment());
    132182
    133183    return kTRUE;
  • trunk/Mars/mraw/MRawFitsRead.h

    r11490 r11871  
    1111{
    1212private:
    13     std::vector<UInt_t> fPCTime; //! Buffer
     13    std::vector<UInt_t>   fPCTime;   //! Buffer
     14    std::vector<UShort_t> fPixelMap; //!
    1415
    1516    istream *OpenFile(const char *filename);
     
    2425    static Bool_t IsFits(const char *name);
    2526
     27    Bool_t LoadMap(const char *name);
     28
    2629    ClassDef(MRawFitsRead, 0)   // Task to read the raw data binary file
    2730};
Note: See TracChangeset for help on using the changeset viewer.