13 "Usage: fitsselect rawfile eventlist outfile\n" 21 po::options_description configs(
"Fitsdump options");
23 (
"infile", var<string>()->required(),
"")
24 (
"outfile", var<string>()->required(),
"")
25 (
"eventlist", var<string>()->required(),
"")
28 po::positional_options_description p;
30 p.add(
"eventlist", 1);
37 int main(
int argc,
const char** 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);
99 pointers.emplace_back(ptr, buffer.data()+
count);
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
void SetPrintUsage(const std::function< void(void)> &func)
T Get(const std::string &var)
void SetArgumentPositions(const po::positional_options_description &desc)
int64_t first
Size of this column in the tile.
void SetDrsCalibration(const std::vector< float > &calib)
assign a given drs offset calibration
void AddOptions(const po::options_description &opt, bool visible=true)
Commandline parsing, resource file parsing and database access.
int main(int argc, const char **argv)
void SetupConfiguration(Configuration &conf)
bool DoParse(int argc, const char **argv, const std::function< void()> &func=std::function< void()>())