36 if (!mOutFile.is_open()) {
37 LOG(fatal) <<
"Failed to open Mille file " << outFileName;
39 mBufferInt.reserve(1024);
40 mBufferFloat.reserve(1024);
56 int NGL,
const float* derGl,
const int*
label,
57 float rMeas,
float sigma)
63 mBufferFloat.push_back(rMeas);
64 mBufferInt.push_back(0);
67 for (
int i = 0;
i < NLC; ++
i) {
68 if (derLc[
i] || mWriteZero) {
69 mBufferFloat.push_back(derLc[
i]);
70 mBufferInt.push_back(
i + 1);
75 mBufferFloat.push_back(sigma);
76 mBufferInt.push_back(0);
79 for (
int i = 0;
i < NGL; ++
i) {
80 if (derGl[
i] || mWriteZero) {
81 if ((
label[
i] > 0 || mWriteZero) &&
label[
i] <= MaxLabel) {
82 mBufferFloat.push_back(derGl[
i]);
83 mBufferInt.push_back(
label[
i]);
85 LOGP(error,
"Mille: invalid label {} <=0 or > {}",
label[
i], MaxLabel);
104 LOG(error) <<
"Mille: special values already stored for this record.";
115 mBufferFloat.push_back(0.);
116 mBufferInt.push_back(0);
118 mBufferFloat.push_back(-nSpecial);
119 mBufferInt.push_back(0);
121 for (
int i = 0;
i < nSpecial; ++
i) {
122 mBufferFloat.push_back(floats[
i]);
123 mBufferInt.push_back(ints[
i]);
132 int nw = mBufferInt.size();
134 const int numWordsToWrite = nw * 2;
137 mOutFile.write(
reinterpret_cast<const char*
>(&numWordsToWrite),
sizeof(
int));
138 mOutFile.write(
reinterpret_cast<const char*
>(mBufferFloat.data()), nw *
sizeof(mBufferFloat[0]));
139 mOutFile.write(
reinterpret_cast<const char*
>(mBufferInt.data()), nw *
sizeof(mBufferInt[0]));
141 mOutFile << numWordsToWrite <<
"\n";
142 for (
int i = 0;
i < nw;
i++) {
143 mOutFile << mBufferFloat[
i] <<
" ";
146 for (
int i = 0;
i < nw;
i++) {
147 mOutFile << mBufferInt[
i] <<
" ";
151 wrote = nw * (
sizeof(mBufferFloat[0]) +
sizeof(mBufferInt[0])) +
sizeof(
int);
163 mBufferFloat.clear();
164 mBufferFloat.push_back(0.f);
165 mBufferInt.push_back(0);
Class to write C binary file.
Mille(const std::string &outFileName, bool asBinary=true, bool writeZero=false)
void mille(int NLC, const float *derLc, int NGL, const float *derGl, const int *label, float rMeas, float sigma)
Add measurement to buffer.
void clear()
Initialize for new set of locals, e.g. new track.
void special(int nSpecial, const float *floatings, const int *integers)
Add special data to buffer.
int finalise()
Write buffer (set of derivatives with same local parameters) to file.
const GLuint GLenum const void * binary
GLuint GLsizei const GLchar * label
void align(gsl::span< ElinkEncoder< BareFormat, CHARGESUM > > elinks)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
std::string asBinary(uint64_t value)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"