12myOutFile(outFileName, (asBinary ? (
std::ios::binary |
std::ios::out) :
std::ios::out)),
13myAsBinary(asBinary), myWriteZero(writeZero), myBufferPos(-1), myHasSpecial(kFALSE) {
17 myBufferFloat[0] = 0.;
19 if (!myOutFile.is_open()) {
20 cerr <<
"Mille::Mille: Could not open " << outFileName
21 <<
" as output file." << endl;
45 Int_t NGL,
const Double_t* derGl,
const Int_t* label,
46 Double_t rMeas, Double_t sigma) {
47 if (sigma <= 0.)
return;
48 if (myBufferPos == -1) this->newSet();
49 if (!this->checkBufferSize(NLC, NGL))
return;
53 myBufferFloat[myBufferPos] = rMeas;
54 myBufferInt [myBufferPos] = 0;
57 for (Int_t
i = 0;
i < NLC; ++
i) {
58 if (derLc[
i] || myWriteZero) {
60 myBufferFloat[myBufferPos] = derLc[
i];
61 myBufferInt [myBufferPos] =
i + 1;
67 myBufferFloat[myBufferPos] = sigma;
68 myBufferInt [myBufferPos] = 0;
71 for (Int_t
i = 0;
i < NGL; ++
i) {
72 if (derGl[
i] || myWriteZero) {
73 if ((label[
i] > 0 || myWriteZero) && label[
i] <= myMaxLabel) {
75 myBufferFloat[myBufferPos] = derGl[
i];
76 myBufferInt [myBufferPos] = label[
i];
78 cerr <<
"Mille::mille: Invalid label " << label[
i]
79 <<
" <= 0 or > " << myMaxLabel << endl;
94 if (nSpecial == 0)
return;
95 if (myBufferPos == -1) this->newSet();
97 cerr <<
"Mille::special: Special values already stored for this record."
101 if (!this->checkBufferSize(nSpecial, 0))
return;
102 myHasSpecial = kTRUE;
111 myBufferFloat[myBufferPos] = 0.;
112 myBufferInt [myBufferPos] = 0;
115 myBufferFloat[myBufferPos] = -nSpecial;
116 myBufferInt [myBufferPos] = 0;
118 for (Int_t
i = 0;
i < nSpecial; ++
i) {
120 myBufferFloat[myBufferPos] = floatings[
i];
121 myBufferInt [myBufferPos] = integers[
i];
136 if (myBufferPos > 0) {
137 const Int_t numWordsToWrite = (myBufferPos + 1)*2;
140 myOutFile.write(
reinterpret_cast<const char*
> (&numWordsToWrite),
141 sizeof (numWordsToWrite));
142 myOutFile.write(
reinterpret_cast<char*
> (myBufferFloat),
143 (myBufferPos + 1) *
sizeof (myBufferFloat[0]));
144 myOutFile.write(
reinterpret_cast<char*
> (myBufferInt),
145 (myBufferPos + 1) *
sizeof (myBufferInt[0]));
147 myOutFile << numWordsToWrite <<
"\n";
148 for (Int_t
i = 0;
i < myBufferPos + 1; ++
i) {
149 myOutFile << myBufferFloat[
i] <<
" ";
153 for (Int_t
i = 0;
i < myBufferPos + 1; ++
i) {
154 myOutFile << myBufferInt[
i] <<
" ";
165void BmnMille::newSet() {
167 myHasSpecial = kFALSE;
168 myBufferFloat[0] = 0.0;
180bool BmnMille::checkBufferSize(Int_t nLocal, Int_t nGlobal) {
181 if (myBufferPos + nLocal + nGlobal + 2 >= myBufferSize) {
183 std::cerr <<
"Mille::checkBufferSize: Buffer too short ("
184 << myBufferSize <<
"),"
185 <<
"\n need space for nLocal (" << nLocal <<
")"
186 <<
"/nGlobal (" << nGlobal <<
") local/global derivatives, "
187 << myBufferPos + 1 <<
" already stored!"
void end()
Write buffer (set of derivatives with same local parameters) to file.
void mille(Int_t NLC, const Double_t *derLc, Int_t NGL, const Double_t *derGl, const Int_t *label, Double_t rMeas, Double_t sigma)
Add measurement to buffer.
BmnMille(const Char_t *outFileName, Bool_t asBinary=kTRUE, Bool_t writeZero=kFALSE)
Opens outFileName (by default as binary file).
void kill()
Reset buffers, i.e. kill derivatives accumulated for current set.
void special(Int_t nSpecial, const Double_t *floatings, const Int_t *integers)
Add special data to buffer.