Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:25

0001 /*
0002  * MilleBinary.h
0003  *
0004  *  Created on: Aug 31, 2011
0005  *      Author: kleinwrt
0006  */
0007 
0008 /** \file
0009  *  MilleBinary definition.
0010  *
0011  *  \author Claus Kleinwort, DESY, 2011 (Claus.Kleinwort@desy.de)
0012  *
0013  *  \copyright
0014  *  Copyright (c) 2011 - 2016 Deutsches Elektronen-Synchroton,
0015  *  Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY \n\n
0016  *  This library is free software; you can redistribute it and/or modify
0017  *  it under the terms of the GNU Library General Public License as
0018  *  published by the Free Software Foundation; either version 2 of the
0019  *  License, or (at your option) any later version. \n\n
0020  *  This library is distributed in the hope that it will be useful,
0021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0023  *  GNU Library General Public License for more details. \n\n
0024  *  You should have received a copy of the GNU Library General Public
0025  *  License along with this program (see the file COPYING.LIB for more
0026  *  details); if not, write to the Free Software Foundation, Inc.,
0027  *  675 Mass Ave, Cambridge, MA 02139, USA.
0028  */
0029 
0030 #ifndef MILLEBINARY_H_
0031 #define MILLEBINARY_H_
0032 
0033 #include<fstream>
0034 #include<vector>
0035 
0036 //! Namespace for the general broken lines package
0037 namespace gbl {
0038 
0039 ///  Millepede-II (binary) record.
0040 /**
0041  *  Containing information for local (track) and global fit.
0042  *
0043  *  The data blocks are collected in two arrays, a real array
0044  *  (containing float or double values) and integer array, of same length.
0045  *  A positive record length indicate _float_ and a negative one _double_ values.
0046  *  The content of the record is:
0047  *\verbatim
0048  *         real array              integer array
0049  *     0   0.0                     error count (this record)
0050  *     1   RMEAS, measured value   0                            -+
0051  *     2   local derivative        index of local derivative     |
0052  *     3   local derivative        index of local derivative     |
0053  *     4    ...                                                  | block
0054  *         SIGMA, error (>0)       0                             |
0055  *         global derivative       label of global derivative    |
0056  *         global derivative       label of global derivative   -+
0057  *         RMEAS, measured value   0
0058  *         local derivative        index of local derivative
0059  *         local derivative        index of local derivative
0060  *         ...
0061  *         SIGMA, error            0
0062  *         global derivative       label of global derivative
0063  *         global derivative       label of global derivative
0064  *         ...
0065  *         global derivative       label of global derivative
0066  *\endverbatim
0067  */
0068 class MilleBinary {
0069 public:
0070     MilleBinary(const std::string &fileName = "milleBinaryISN.dat",
0071             bool doublePrec = false, unsigned int aSize = 2000);
0072     virtual ~MilleBinary();
0073     void addData(double aMeas, double aPrec,
0074             const std::vector<unsigned int> &indLocal,
0075             const std::vector<double> &derLocal,
0076             const std::vector<int> &labGlobal,
0077             const std::vector<double> &derGlobal);
0078     void writeRecord();
0079 
0080 private:
0081     std::ofstream binaryFile; ///< Binary File
0082     std::vector<int> intBuffer; ///< Integer buffer
0083     std::vector<float> floatBuffer; ///< Float buffer
0084     std::vector<double> doubleBuffer; ///< Double buffer
0085     bool doublePrecision; ///< Flag for storage in as *double* values
0086 };
0087 }
0088 #endif /* MILLEBINARY_H_ */