test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 aPrec, const std::vector< unsigned int > &indLocal, const std::vector< 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 46 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 19 of file MilleBinary.cc.

References doubleBuffer, doublePrecision, floatBuffer, and intBuffer.

20  :
21  binaryFile(fileName.c_str(), std::ios::binary | std::ios::out), intBuffer(), floatBuffer(), doubleBuffer(), doublePrecision(
22  doublePrec) {
23  intBuffer.reserve(aSize);
24  intBuffer.push_back(0); // first word is error counter
25  if (doublePrecision) {
26  doubleBuffer.reserve(aSize);
27  doubleBuffer.push_back(0.);
28 
29  } else {
30  floatBuffer.reserve(aSize);
31  floatBuffer.push_back(0.);
32  }
33 }
std::vector< int > intBuffer
Integer buffer.
Definition: MilleBinary.h:60
std::vector< double > doubleBuffer
Double buffer.
Definition: MilleBinary.h:62
bool doublePrecision
Flag for storage in as double values.
Definition: MilleBinary.h:63
std::ofstream binaryFile
Binary File.
Definition: MilleBinary.h:59
std::vector< float > floatBuffer
Float buffer.
Definition: MilleBinary.h:61
gbl::MilleBinary::~MilleBinary ( )
virtual

Definition at line 35 of file MilleBinary.cc.

References binaryFile.

35  {
36  binaryFile.close();
37 }
std::ofstream binaryFile
Binary File.
Definition: MilleBinary.h:59

Member Function Documentation

void gbl::MilleBinary::addData ( double  aMeas,
double  aErr,
const std::vector< unsigned int > &  indLocal,
const std::vector< 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]indLocalList of labels of local parameters
[in]derLocalList of derivatives for local parameters
[in]labGlobalList of labels of global parameters
[in]derGlobalList of derivatives for global parameters

Definition at line 48 of file MilleBinary.cc.

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

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

51  {
52 
53  if (doublePrecision) {
54  // double values
55  intBuffer.push_back(0);
56  doubleBuffer.push_back(aMeas);
57  for (unsigned int i = 0; i < indLocal.size(); ++i) {
58  intBuffer.push_back(indLocal[i]);
59  doubleBuffer.push_back(derLocal[i]);
60  }
61  intBuffer.push_back(0);
62  doubleBuffer.push_back(aErr);
63  for (unsigned int i = 0; i < labGlobal.size(); ++i) {
64  if (derGlobal[i]) {
65  intBuffer.push_back(labGlobal[i]);
66  doubleBuffer.push_back(derGlobal[i]);
67  }
68  }
69  } else {
70  // float values
71  intBuffer.push_back(0);
72  floatBuffer.push_back(aMeas);
73  for (unsigned int i = 0; i < indLocal.size(); ++i) {
74  intBuffer.push_back(indLocal[i]);
75  floatBuffer.push_back(derLocal[i]);
76  }
77  intBuffer.push_back(0);
78  floatBuffer.push_back(aErr);
79  for (unsigned int i = 0; i < labGlobal.size(); ++i) {
80  if (derGlobal[i]) {
81  intBuffer.push_back(labGlobal[i]);
82  floatBuffer.push_back(derGlobal[i]);
83  }
84  }
85  }
86 }
int i
Definition: DBlmapReader.cc:9
std::vector< int > intBuffer
Integer buffer.
Definition: MilleBinary.h:60
std::vector< double > doubleBuffer
Double buffer.
Definition: MilleBinary.h:62
bool doublePrecision
Flag for storage in as double values.
Definition: MilleBinary.h:63
std::vector< float > floatBuffer
Float buffer.
Definition: MilleBinary.h:61
void gbl::MilleBinary::writeRecord ( )

Write record to file.

Definition at line 89 of file MilleBinary.cc.

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

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

89  {
90 
91  const int recordLength =
92  (doublePrecision) ? -intBuffer.size() * 2 : intBuffer.size() * 2;
93  binaryFile.write(reinterpret_cast<const char*>(&recordLength),
94  sizeof(recordLength));
95  if (doublePrecision)
96  binaryFile.write(reinterpret_cast<char*>(&doubleBuffer[0]),
97  doubleBuffer.size() * sizeof(doubleBuffer[0]));
98  else
99  binaryFile.write(reinterpret_cast<char*>(&floatBuffer[0]),
100  floatBuffer.size() * sizeof(floatBuffer[0]));
101  binaryFile.write(reinterpret_cast<char*>(&intBuffer[0]),
102  intBuffer.size() * sizeof(intBuffer[0]));
103 // start with new record
104  intBuffer.resize(1);
105  if (doublePrecision)
106  doubleBuffer.resize(1);
107  else
108  floatBuffer.resize(1);
109 }
std::vector< int > intBuffer
Integer buffer.
Definition: MilleBinary.h:60
std::vector< double > doubleBuffer
Double buffer.
Definition: MilleBinary.h:62
bool doublePrecision
Flag for storage in as double values.
Definition: MilleBinary.h:63
std::ofstream binaryFile
Binary File.
Definition: MilleBinary.h:59
std::vector< float > floatBuffer
Float buffer.
Definition: MilleBinary.h:61

Member Data Documentation

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

Binary File.

Definition at line 59 of file MilleBinary.h.

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

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

Double buffer.

Definition at line 62 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 63 of file MilleBinary.h.

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

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

Float buffer.

Definition at line 61 of file MilleBinary.h.

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

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

Integer buffer.

Definition at line 60 of file MilleBinary.h.

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