CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
gbl::MilleBinary Class Reference

Millepede-II (binary) record. More...

#include <MilleBinary.h>

Public Member Functions

void addData (double aMeas, double aErr, unsigned int numLocal, unsigned int *indLocal, double *derLocal, const std::vector< int > &labGlobal, const std::vector< double > &derGlobal)
 Add data block to (end of) record. More...
 
 MilleBinary (const std::string &fileName="milleBinaryISN.dat", bool doublePrec=false, unsigned int aSize=2000)
 Create binary file. More...
 
void writeRecord ()
 Write record to file. More...
 
virtual ~MilleBinary ()
 

Private Attributes

std::ofstream binaryFile
 Binary File. More...
 
std::vector< double > doubleBuffer
 Double buffer. More...
 
bool doublePrecision
 Flag for storage in as double values. More...
 
std::vector< float > floatBuffer
 Float buffer. More...
 
std::vector< int > intBuffer
 Integer buffer. More...
 

Detailed Description

Millepede-II (binary) record.

Containing information for local (track) and global fit.

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:

*         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
*

Definition at line 68 of file MilleBinary.h.

Constructor & Destructor Documentation

gbl::MilleBinary::MilleBinary ( const std::string &  fileName = "milleBinaryISN.dat",
bool  doublePrec = false,
unsigned int  aSize = 2000 
)

Create binary file.

Parameters
[in]fileNameFile name
[in]doublePrecFlag for storage as double values
[in]aSizeBuffer size

Definition at line 41 of file MilleBinary.cc.

References doubleBuffer, doublePrecision, floatBuffer, and intBuffer.

42  :
43  binaryFile(fileName.c_str(), std::ios::binary | std::ios::out), intBuffer(),
44  floatBuffer(), doubleBuffer(), doublePrecision(doublePrec)
45  {
46  intBuffer.reserve(aSize);
47  intBuffer.push_back(0); // first word is error counter
48  if (doublePrecision) {
49  doubleBuffer.reserve(aSize);
50  doubleBuffer.push_back(0.);
51 
52  } else {
53  floatBuffer.reserve(aSize);
54  floatBuffer.push_back(0.);
55  }
56  }
std::vector< int > intBuffer
Integer buffer.
Definition: MilleBinary.h:81
std::vector< double > doubleBuffer
Double buffer.
Definition: MilleBinary.h:83
bool doublePrecision
Flag for storage in as double values.
Definition: MilleBinary.h:84
std::ofstream binaryFile
Binary File.
Definition: MilleBinary.h:80
std::vector< float > floatBuffer
Float buffer.
Definition: MilleBinary.h:82
gbl::MilleBinary::~MilleBinary ( )
virtual

Definition at line 58 of file MilleBinary.cc.

References binaryFile.

58  {
59  binaryFile.close();
60  }
std::ofstream binaryFile
Binary File.
Definition: MilleBinary.h:80

Member Function Documentation

void gbl::MilleBinary::addData ( double  aMeas,
double  aErr,
unsigned int  numLocal,
unsigned int *  indLocal,
double *  derLocal,
const std::vector< int > &  labGlobal,
const std::vector< double > &  derGlobal 
)

Add data block to (end of) record.

Parameters
[in]aMeasValue
[in]aErrError
[in]numLocalNumber of local labels/derivatives
[in]indLocalArray of labels of local parameters
[in]derLocalArray of derivatives for local parameters
[in]labGlobalList of labels of global parameters
[in]derGlobalList of derivatives for global parameters

Definition at line 72 of file MilleBinary.cc.

References doubleBuffer, doublePrecision, floatBuffer, mps_fire::i, and intBuffer.

Referenced by gbl::GblTrajectory::milleOut().

75  {
76 
77  if (doublePrecision) {
78  // double values
79  intBuffer.push_back(0);
80  doubleBuffer.push_back(aMeas);
81  for (unsigned int i = 0; i < numLocal; ++i) {
82  intBuffer.push_back(indLocal[i]);
83  doubleBuffer.push_back(derLocal[i]);
84  }
85  intBuffer.push_back(0);
86  doubleBuffer.push_back(aErr);
87  for (unsigned int i = 0; i < labGlobal.size(); ++i) {
88  if (derGlobal[i]) {
89  intBuffer.push_back(labGlobal[i]);
90  doubleBuffer.push_back(derGlobal[i]);
91  }
92  }
93  } else {
94  // float values
95  intBuffer.push_back(0);
96  floatBuffer.push_back(aMeas);
97  for (unsigned int i = 0; i < numLocal; ++i) {
98  intBuffer.push_back(indLocal[i]);
99  floatBuffer.push_back(derLocal[i]);
100  }
101  intBuffer.push_back(0);
102  floatBuffer.push_back(aErr);
103  for (unsigned int i = 0; i < labGlobal.size(); ++i) {
104  if (derGlobal[i]) {
105  intBuffer.push_back(labGlobal[i]);
106  floatBuffer.push_back(derGlobal[i]);
107  }
108  }
109  }
110  }
std::vector< int > intBuffer
Integer buffer.
Definition: MilleBinary.h:81
std::vector< double > doubleBuffer
Double buffer.
Definition: MilleBinary.h:83
bool doublePrecision
Flag for storage in as double values.
Definition: MilleBinary.h:84
std::vector< float > floatBuffer
Float buffer.
Definition: MilleBinary.h:82
void gbl::MilleBinary::writeRecord ( )

Write record to file.

Definition at line 113 of file MilleBinary.cc.

References binaryFile, doubleBuffer, doublePrecision, floatBuffer, and intBuffer.

Referenced by gbl::GblTrajectory::milleOut().

113  {
114 
115  const int recordLength =
116  (doublePrecision) ? -intBuffer.size() * 2 : intBuffer.size() * 2;
117  binaryFile.write(reinterpret_cast<const char*>(&recordLength),
118  sizeof(recordLength));
119  if (doublePrecision)
120  binaryFile.write(reinterpret_cast<char*>(&doubleBuffer[0]),
121  doubleBuffer.size() * sizeof(doubleBuffer[0]));
122  else
123  binaryFile.write(reinterpret_cast<char*>(&floatBuffer[0]),
124  floatBuffer.size() * sizeof(floatBuffer[0]));
125  binaryFile.write(reinterpret_cast<char*>(&intBuffer[0]),
126  intBuffer.size() * sizeof(intBuffer[0]));
127  // start with new record
128  intBuffer.resize(1);
129  if (doublePrecision)
130  doubleBuffer.resize(1);
131  else
132  floatBuffer.resize(1);
133  }
std::vector< int > intBuffer
Integer buffer.
Definition: MilleBinary.h:81
std::vector< double > doubleBuffer
Double buffer.
Definition: MilleBinary.h:83
bool doublePrecision
Flag for storage in as double values.
Definition: MilleBinary.h:84
std::ofstream binaryFile
Binary File.
Definition: MilleBinary.h:80
std::vector< float > floatBuffer
Float buffer.
Definition: MilleBinary.h:82

Member Data Documentation

std::ofstream gbl::MilleBinary::binaryFile
private

Binary File.

Definition at line 80 of file MilleBinary.h.

Referenced by writeRecord(), and ~MilleBinary().

std::vector<double> gbl::MilleBinary::doubleBuffer
private

Double buffer.

Definition at line 83 of file MilleBinary.h.

Referenced by addData(), MilleBinary(), and writeRecord().

bool gbl::MilleBinary::doublePrecision
private

Flag for storage in as double values.

Definition at line 84 of file MilleBinary.h.

Referenced by addData(), MilleBinary(), and writeRecord().

std::vector<float> gbl::MilleBinary::floatBuffer
private

Float buffer.

Definition at line 82 of file MilleBinary.h.

Referenced by addData(), MilleBinary(), and writeRecord().

std::vector<int> gbl::MilleBinary::intBuffer
private

Integer buffer.

Definition at line 81 of file MilleBinary.h.

Referenced by addData(), MilleBinary(), and writeRecord().