MilleBinary.h 3.28 KB
Newer Older
1
2
3
4
5
6
7
/*
 * MilleBinary.h
 *
 *  Created on: Aug 31, 2011
 *      Author: kleinwrt
 */

8
9
10
11
12
13
/** \file
 *  MilleBinary definition.
 *
 *  \author Claus Kleinwort, DESY, 2011 (Claus.Kleinwort@desy.de)
 *
 *  \copyright
14
 *  Copyright (c) 2011 - 2017 Deutsches Elektronen-Synchroton,
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 *  Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY \n\n
 *  This library is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Library General Public License as
 *  published by the Free Software Foundation; either version 2 of the
 *  License, or (at your option) any later version. \n\n
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details. \n\n
 *  You should have received a copy of the GNU Library General Public
 *  License along with this program (see the file COPYING.LIB for more
 *  details); if not, write to the Free Software Foundation, Inc.,
 *  675 Mass Ave, Cambridge, MA 02139, USA.
 */

30
31
32
33
34
35
#ifndef MILLEBINARY_H_
#define MILLEBINARY_H_

#include<fstream>
#include<vector>

36
//! Namespace for the general broken lines package
Claus Kleinwort's avatar
Claus Kleinwort committed
37
namespace gbl {
38

39
40
41
42
///  Millepede-II (binary) record.
/**
 *  Containing information for local (track) and global fit.
 *
43
44
45
46
 *  The data blocks are collected in two arrays, a real array
 *  (containing float or double values) and integer array, of same length.
 *  A positive record length indicate _float_ and a negative one _double_ values.
 *  The content of the record is:
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 *\verbatim
 *         real array              integer array
 *     0   0.0                     error count (this record)
 *     1   RMEAS, measured value   0                            -+
 *     2   local derivative        index of local derivative     |
 *     3   local derivative        index of local derivative     |
 *     4    ...                                                  | block
 *         SIGMA, error (>0)       0                             |
 *         global derivative       label of global derivative    |
 *         global derivative       label of global derivative   -+
 *         RMEAS, measured value   0
 *         local derivative        index of local derivative
 *         local derivative        index of local derivative
 *         ...
 *         SIGMA, error            0
 *         global derivative       label of global derivative
 *         global derivative       label of global derivative
 *         ...
 *         global derivative       label of global derivative
 *\endverbatim
 */
class MilleBinary {
public:
70
	MilleBinary(const std::string fileName = "milleBinaryISN.dat",
71
			bool doublePrec = false, unsigned int aSize = 2000);
72
	virtual ~MilleBinary();
73
	void addData(double aMeas, double aErr, unsigned int numLocal,
74
75
76
			unsigned int* indLocal, double* derLocal,
			const std::vector<int> &labGlobal,
			const std::vector<double> &derGlobal);
77
78
79
80
81
82
	void writeRecord();

private:
	std::ofstream binaryFile; ///< Binary File
	std::vector<int> intBuffer; ///< Integer buffer
	std::vector<float> floatBuffer; ///< Float buffer
83
84
	std::vector<double> doubleBuffer; ///< Double buffer
	bool doublePrecision; ///< Flag for storage in as *double* values
85
};
86
}
87
#endif /* MILLEBINARY_H_ */