43 if (!conf.DoParse(argc, argv))
46 const string infile = conf.Get<
string>(
"infile");
48 const string outfile = conf.Get<
string>(
"outfile");
49 const string eventlist = conf.Get<
string>(
"eventlist");
52 ifstream fin(eventlist.c_str());
63 factfits inf(infile.c_str(),
"Events",
false);
68 uint32_t rowWidth = inf.HasKey(
"ZNAXIS1") ? inf.GetUInt(
"ZNAXIS1") : inf.GetUInt(
"ZNAXIS2");
70 vector<char>
buffer(rowWidth);
74 vector<pair<void*, char*>> pointers;
76 unsigned int count = 0;
81 for (fits::Table::Columns::const_iterator it=columns.begin(); it!=columns.end(); it++)
85 if (it->first==
"Data" || it->first==
"TimeMarker")
87 vector<uint16_t> processing(2);
93 outf.AddColumn(comp, col.
num, col.
type, it->first, col.
unit,
"");
96 outf.AddColumn(col.
num, col.
type, it->first, col.
unit,
"");
98 void *ptr = inf.SetPtrAddress(it->first);
102 if (it->first==
"EventNum")
103 evtNum =
reinterpret_cast<uint32_t*
>(ptr);
107 throw runtime_error(
"Colum EventNum not found.");
110 throw runtime_error(
"Size mismatch.");
114 outf.WriteTableHeader(inf.GetStr(
"EXTNAME").c_str());
116 while (inf.GetNextRow())
118 if (list.find(*evtNum)==list.end())
122 for (fits::Table::Columns::const_iterator it=columns.begin(); it!= columns.end(); it++, i++)
123 memcpy(pointers[i].
second, pointers[i].
first, it->second.num*it->second.size);
125 outf.WriteRow(
buffer.data(), rowWidth);
127 throw runtime_error(
"Write stream failure.");
131 throw runtime_error(
"Read stream failure.");
134 throw runtime_error(
"Write stream failure.");
std::map< std::string, Column > Columns
int64_t second
offset of this column in the tile, from the start of the heap area
int64_t first
Size of this column in the tile.
void SetDrsCalibration(const std::vector< float > &calib)
assign a given drs offset calibration
Commandline parsing, resource file parsing and database access.
void SetupConfiguration(Configuration &conf)