提交格式

选手提交HDF5格式的文件,在文件中写入一个与数据集中GroundTruth表结构相似的表,只是加入Weight一列数据,并命名为为Answer

Answer
EventID (int64) ChannelID (int16) PETime (int16) Weight (float32)
1 0 269 0.3
1 0 284 0.5
1 0 287 2.0

Weight 是对 PETime 的补充,Weight=1 表示 PETime 处有 1 个光电子,因此 可以把训练集的 GroundTruth 表看到有一列省略的 Weight=1 的列。Weight=2 就表示该 PETime 处有 2 个光电子重叠。

进一步推广,如果分析算法认为在 PETime 处有 50% 的几率有 1 个光电子,则 可以把该行的 Weight 写为 0.5。

竞赛培训文件

竞赛培训文件,包括样例算法和样例程序可在赛事平台的 Knowledge Base 处获得。

也可以从 亚洲区欧洲区 的镜像获得。

写入文件的示例

在下面的示例中,我们向文件中写入上表中的三条示例数据。

Python

# An example of writing a file.
import tables

# Define the database columns
class AnswerData(tables.IsDescription):
    EventID    = tables.Int64Col(pos=0)
    ChannelID  = tables.Int16Col(pos=1)
    PETime     = tables.Int16Col(pos=2)
    Weight     = tables.Float32Col(pos=3)

# Create the output file and the group
h5file = tables.open_file("MyAnswer.h5", mode="w", title="OneTonDetector")

# Create tables
AnswerTable = h5file.create_table("/", "Answer", AnswerData, "Answer")
answer = AnswerTable.row

# Write data 
answer['EventID'] =  1
answer['ChannelID'] = 0
answer['PETime'] = 269 
answer['Weight'] = 0.3 
answer.append()
answer['EventID'] =  1
answer['ChannelID'] = 0
answer['PETime'] = 284 
answer['Weight'] = 0.5 
answer.append()
answer['EventID'] =  1
answer['ChannelID'] = 0
answer['PETime'] = 287 
answer['Weight'] = 2.0 
answer.append()

# Flush into the output file
AnswerTable.flush()

h5file.close()

C++

g++ -std=c++11 -o submit -I/usr/local/hdf5/include/ Submit.cpp -lhdf5 -lhdf5_hl
#include "hdf5.h"
#include "hdf5_hl.h"
#include <cstdlib>
#include <iostream>
using namespace std;

constexpr size_t nFields = 4;
constexpr size_t nRecord = 3;

struct AnswerData
{
    long long EventID;
    short ChannelID;
    short PETime;
    float Weight;
};

int main() {

    AnswerData dst_buf;

    // Calculate the size and the offsets of our struct members in memory
    size_t dst_size =  sizeof( AnswerData );
    size_t dst_offset[nFields] = { HOFFSET( AnswerData, EventID ),
        HOFFSET( AnswerData, ChannelID ),
        HOFFSET( AnswerData, PETime ),
        HOFFSET( AnswerData, Weight )
    };

    size_t dst_sizes[nFields] = { sizeof( dst_buf.EventID),
        sizeof( dst_buf.ChannelID),
        sizeof( dst_buf.PETime),
        sizeof( dst_buf.Weight)
    };

    // Define an array of data
    AnswerData p_data[nRecord] = {
        {1,0, 269, 0.3},
        {1,0, 284, 0.5},
        {1,0, 287, 2.0}
    };

    // Define field information
    const char *field_names[nFields]  =
    { "EventID","ChannelID", "PETime", "Weight"};
    hid_t      field_type[nFields];
    hid_t      file_id;
    hsize_t    chunk_size = 10;
    int        *fill_data = NULL;
    int        compress  = 0;
    int        i;

    // Initialize field_type
    field_type[0] = H5T_NATIVE_LLONG;
    field_type[1] = H5T_NATIVE_SHORT;
    field_type[2] = H5T_NATIVE_SHORT;
    field_type[3] = H5T_NATIVE_FLOAT;

    // Create a new file using default properties.
    file_id = H5Fcreate( "MyAnswer_cpp.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );


    // Make the table.
    H5TBmake_table( "Table Title", file_id, "Answer", nFields, nRecord,
                dst_size,field_names, dst_offset, field_type,
                chunk_size, fill_data, compress, p_data  );

    // Close the file.
    H5Fclose( file_id );

    return 0;
}