ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::AlVec Class Reference

#include <AlVec.h>

Collaboration diagram for Trk::AlVec:

Public Member Functions

 AlVec (int N)
 AlVec ()
 AlVec (const AlVec &v)
 AlVec (AlVec &&v)
 ~AlVec ()
double & operator[] (int i)
const double & operator[] (int i) const
AlVecoperator= (const AlVec &v)
AlVecoperator= (AlVec &&v)
AlVecoperator= (const double &v)
AlVec operator+ (const AlVec &) const
AlVecoperator+= (const AlVec &)
AlVec operator- (const AlVec &) const
AlVecoperator-= (const AlVec &)
double operator* (const AlVec &) const
AlVec operator* (const AlMat &) const
AlVec operator* (const AlSymMatBase &) const
AlVec operator* (const double &) const
AlVecoperator*= (const double &)
double norm () const
void reSize (int)
void RemoveModule (int)
void RemoveAlignPar (int, int)
int RemoveElements (std::vector< int >)
void SetPathBin (const std::string &)
void SetPathTxt (const std::string &)
StatusCode Write (const std::string &, bool, double, std::map< int, unsigned long long >, float)
StatusCode WritePartial (const std::string &, bool, double, std::map< int, unsigned long long >, float)
StatusCode WritePartial (const std::string &, bool, double, std::map< int, std::string >, float)
StatusCode InitializeOutputVector (const std::string &, bool, double, float, std::ofstream &)
StatusCode Read (const std::string &, double &, std::map< int, unsigned long long > &, float &)
StatusCode ReadPartial (const std::string &, double &, std::map< int, unsigned long long > &, float &)
StatusCode ReadProjected (const std::string &, double &, std::map< int, unsigned long long > &, float &)
StatusCode ReadScalaPack (const std::string &)
StatusCode WriteEigenvalueVec (const std::string &, bool)
int size () const
const double * ptrData () const
double * ptrData ()

Static Public Member Functions

static StatusCode CheckVecVersion (const std::string &, bool &)

Protected Member Functions

void copy (const AlVec &)

Protected Attributes

int m_size
double * m_ptr_data = nullptr
std::string m_pathbin
std::string m_pathtxt

Detailed Description

Definition at line 23 of file AlVec.h.

Constructor & Destructor Documentation

◆ AlVec() [1/4]

Trk::AlVec::AlVec ( int N)

Definition at line 38 of file AlVec.cxx.

39 : m_size(N)
40 , m_ptr_data(new double[m_size])
41 , m_pathbin("./")
42 , m_pathtxt("./")
43{
44
45 double* p = m_ptr_data + m_size;
46 while (p > m_ptr_data) *(--p) = 0.;
47}
std::string m_pathtxt
Definition AlVec.h:97
std::string m_pathbin
Definition AlVec.h:96
double * m_ptr_data
Definition AlVec.h:95
int m_size
Definition AlVec.h:94

◆ AlVec() [2/4]

Trk::AlVec::AlVec ( )

Definition at line 27 of file AlVec.cxx.

28 : m_size(0)
29 , m_ptr_data(nullptr)
30 , m_pathbin("./")
31 , m_pathtxt("./")
32{
33
34 // set pointer to null
35}

◆ AlVec() [3/4]

Trk::AlVec::AlVec ( const AlVec & v)

Definition at line 50 of file AlVec.cxx.

51 : m_size(v.m_size)
52 , m_ptr_data(new double[m_size])
53 , m_pathbin(v.m_pathbin)
54 , m_pathtxt(v.m_pathtxt)
55{
56
57 copy(v);
58}
void copy(const AlVec &)
Definition AlVec.cxx:67
@ v
Definition ParamDefs.h:78

◆ AlVec() [4/4]

Trk::AlVec::AlVec ( AlVec && v)
inline

Definition at line 28 of file AlVec.h.

29 : m_size (v.m_size),
30 m_ptr_data (v.m_ptr_data),
31 m_pathbin ( std::move(v.m_pathbin) ),
32 m_pathtxt ( std::move(v.m_pathtxt) )
33 {
34
35 v.m_size = 0;
36 v.m_ptr_data = nullptr;
37 }

◆ ~AlVec()

Trk::AlVec::~AlVec ( )

Definition at line 61 of file AlVec.cxx.

62{
63 delete [] m_ptr_data;
64}

Member Function Documentation

◆ CheckVecVersion()

StatusCode Trk::AlVec::CheckVecVersion ( const std::string & filename,
bool & StdUnits )
static

Definition at line 539 of file AlVec.cxx.

539 {
540 std::ifstream invec((filename).c_str(), std::ios::binary);
541 if(invec.fail())
542 return StatusCode::FAILURE;
543
544 int32_t vsiz=0;
545 invec.read(charAddress(vsiz), sizeof (vsiz));
546
547// int32_t scale=0;
548 double scale=0.;
549 invec.read(charAddress(scale), sizeof (scale));
550
551 float version=0.0;
552 invec.read(charAddress(version), sizeof (version));
553
554 StdUnits = version>=2.0;
555
556 invec.close();
557
558 // std::cout << "AlVec::StdUnits: " << StdUnits << std::endl;
559 // std::cout << "AlVec::scale: " << scale << std::endl;
560 // std::cout << "AlVec::vsiz: " << vsiz << std::endl;
561 // std::cout << "AlVec::version: " << version << std::endl;
562
563 return StatusCode::SUCCESS;
564}

◆ copy()

void Trk::AlVec::copy ( const AlVec & v)
protected

Definition at line 67 of file AlVec.cxx.

67 {
68 if(m_size!=v.m_size) {
69 throw std::range_error( "AlVec Assignment: size does not match!" );
70 }
71
72 double* p = m_ptr_data + m_size;
73 double* q = v.m_ptr_data + m_size;
74 while (p > m_ptr_data) *(--p) = (*(--q));
75}

◆ InitializeOutputVector()

StatusCode Trk::AlVec::InitializeOutputVector ( const std::string & filename,
bool binary,
double scale,
float version,
std::ofstream & outvec )

Definition at line 462 of file AlVec.cxx.

464{
465 int32_t io_size=m_size;
466
467 if(binary) {
468 outvec.open((m_pathbin+filename).c_str(), std::ios::binary);
469 if(outvec.fail())
470 return StatusCode::FAILURE;
471 outvec.write(charAddress(io_size), sizeof (io_size));
472 outvec.write(charAddress(scale), sizeof (scale));
473 outvec.write(charAddress(version), sizeof (version));
474
475 }
476 else {
477 outvec.open((m_pathtxt+filename).c_str());
478 if(outvec.fail())
479 return StatusCode::FAILURE;
480 outvec.setf(std::ios::fixed);
481 outvec.setf(std::ios::showpoint);
482 outvec.precision(6);
483 outvec << "DoF: " << std::setw(6) << m_size << std::endl;
484 outvec << "scale: " << std::setw(18) << scale << std::endl;
485 outvec << "AlVec version: " << std::setw(6) << version << std::endl;
486 }
487 return StatusCode::SUCCESS;
488}

◆ norm()

double Trk::AlVec::norm ( ) const

Definition at line 213 of file AlVec.cxx.

213 {
214
215 double result(0.);
216 double * p = m_ptr_data + m_size;
217 while (p > m_ptr_data) {
218 --p;
219 result += *p * *p ;
220 }
221
222 return sqrt(result);
223}

◆ operator*() [1/4]

AlVec Trk::AlVec::operator* ( const AlMat & m) const

Definition at line 174 of file AlVec.cxx.

174 {
175 if (m_size != m.nrow()) {
176 throw std::range_error( "Left hand vector-matrix multiplication: size does not match!" );
177 }
178
179 AlVec b(m.ncol());
180
181 for (int i=0;i<m.ncol();i++) {
182 for (int j=0;j<m_size;j++) *(b.m_ptr_data+i) += *(m_ptr_data+j)*m.elemc(j, i);
183 }
184 return b;
185}
AlVec(int N)
Definition AlVec.cxx:38

◆ operator*() [2/4]

AlVec Trk::AlVec::operator* ( const AlSymMatBase & m) const

Definition at line 188 of file AlVec.cxx.

188 {
189 if (m_size != m.size()) {
190 throw std::range_error( "Left hand vector-matrix multiplication: size does not match!" );
191 }
192
193 AlVec b(m_size);
194
195 for (int i=0;i<m_size;i++) {
196 for (int j=0;j<m_size;j++) *(b.m_ptr_data+i) += *(m_ptr_data+j)*m.elemc(j, i);
197 }
198 return b;
199}

◆ operator*() [3/4]

double Trk::AlVec::operator* ( const AlVec & v) const

Definition at line 160 of file AlVec.cxx.

160 {
161 double b=0.;
162 if( m_size != v.m_size ) {
163 throw std::range_error( "scalar product: vectors size does not match!" );
164 }
165
166 double* p = m_ptr_data + m_size;
167 double* q = v.m_ptr_data + m_size;
168 while (p > m_ptr_data) b += *(--p)*(*(--q));
169
170 return b;
171}

◆ operator*() [4/4]

AlVec Trk::AlVec::operator* ( const double & ) const

◆ operator*=()

AlVec & Trk::AlVec::operator*= ( const double & d)

Definition at line 202 of file AlVec.cxx.

202 {
203
204 double* p = m_ptr_data + m_size;
205 while (p > m_ptr_data) *(--p) *= d;
206
207 return *this;
208}

◆ operator+()

AlVec Trk::AlVec::operator+ ( const AlVec & v) const

Definition at line 102 of file AlVec.cxx.

102 {
103 if( m_size != v.m_size ) {
104 throw std::range_error( "operator+: vectors size does not match!" );
105 }
106
107 AlVec b(m_size);
108
109 double* p = m_ptr_data + m_size;
110 double* q = v.m_ptr_data + m_size;
111 double* r = b.m_ptr_data + m_size;
112 while (p > m_ptr_data) *(--r) = (*(--p))+(*(--q));
113
114 return b;
115}
int r
Definition globals.cxx:22

◆ operator+=()

AlVec & Trk::AlVec::operator+= ( const AlVec & v)

Definition at line 118 of file AlVec.cxx.

118 {
119 if( m_size != v.m_size ) {
120 throw std::range_error( "operator+=: vectors size does not match!" );
121 }
122
123 double* p = m_ptr_data + m_size;
124 double* q = v.m_ptr_data + m_size;
125 while (p > m_ptr_data) *(--p) += (*(--q));
126
127 return *this;
128}

◆ operator-()

AlVec Trk::AlVec::operator- ( const AlVec & v) const

Definition at line 131 of file AlVec.cxx.

131 {
132 if( m_size != v.m_size ) {
133 throw std::range_error( "operator-: vectors size does not match!" );
134 }
135
136 AlVec b(m_size);
137
138 double* p = m_ptr_data + m_size;
139 double* q = v.m_ptr_data + m_size;
140 double* r = b.m_ptr_data + m_size;
141 while (p > m_ptr_data) *(--r) = (*(--p))-(*(--q));
142
143 return b;
144}

◆ operator-=()

AlVec & Trk::AlVec::operator-= ( const AlVec & v)

Definition at line 147 of file AlVec.cxx.

147 {
148 if( m_size != v.m_size ) {
149 throw std::range_error( "operator+=: vectors size does not match!" );
150 }
151
152 double* p = m_ptr_data + m_size;
153 double* q = v.m_ptr_data + m_size;
154 while (p > m_ptr_data) *(--p) -= (*(--q));
155
156 return *this;
157}

◆ operator=() [1/3]

AlVec & Trk::AlVec::operator= ( AlVec && v)
inline

Definition at line 45 of file AlVec.h.

45 {
46 if (&v != this ) {
47 m_pathbin = std::move(v.m_pathbin);
48 m_pathtxt = std::move(v.m_pathtxt);
49 m_size = v.m_size;
50 m_ptr_data = v.m_ptr_data;
51 v.m_size = 0;
52 v.m_ptr_data = nullptr;
53 }
54
55 return *this;
56
57 }

◆ operator=() [2/3]

AlVec & Trk::AlVec::operator= ( const AlVec & v)

Definition at line 89 of file AlVec.cxx.

89 {
90 if (this==&v) return *this;
91
92 if(m_size!=0 && m_size!=v.m_size) {
93 throw std::range_error( "AlVec Assignment: size does not match!" );
94 }
95
96 if ( m_ptr_data != v.m_ptr_data ) copy(v);
97
98 return *this;
99}

◆ operator=() [3/3]

AlVec & Trk::AlVec::operator= ( const double & v)

Definition at line 78 of file AlVec.cxx.

78 {
79
80 double* p = m_ptr_data + m_size;
81 while (p > m_ptr_data) *(--p) = d;
82
83 return *this;
84}

◆ operator[]() [1/2]

double & Trk::AlVec::operator[] ( int i)
inline

Definition at line 121 of file AlVec.h.

121 {
122 if( i < 0 ) {
123 throw std::out_of_range( "AlVec: Index < zero! " );
124 }
125
126 if( i >= m_size ) {
127 throw std::out_of_range( "AlVec: Index too large! ");
128 }
129
130 return *(m_ptr_data+i);
131}

◆ operator[]() [2/2]

const double & Trk::AlVec::operator[] ( int i) const
inline

Definition at line 133 of file AlVec.h.

133 {
134 if( i < 0 ) {
135 throw std::out_of_range( "AlVec: Index < zero! " );
136 }
137
138 if( i >= m_size ) {
139 throw std::out_of_range( "AlVec: Index too large! " );
140 }
141
142 return *(m_ptr_data+i);
143}

◆ ptrData() [1/2]

double * Trk::AlVec::ptrData ( )
inline

Definition at line 117 of file AlVec.h.

117 {
118 return m_ptr_data;
119}

◆ ptrData() [2/2]

const double * Trk::AlVec::ptrData ( ) const
inline

Definition at line 113 of file AlVec.h.

113 {
114 return m_ptr_data;
115}

◆ Read()

StatusCode Trk::AlVec::Read ( const std::string & filename,
double & scale,
std::map< int, unsigned long long > & modmap,
float & version )

Definition at line 567 of file AlVec.cxx.

569{
570
571 bool StdUnits = true;
572 if (StatusCode::SUCCESS != CheckVecVersion(m_pathbin+filename, StdUnits)) {
573 //std::cout<<"CheckVecVersion failed"<<std::endl;
574 return StatusCode::FAILURE;
575 }
576
577 std::ifstream invec((m_pathbin+filename).c_str(), std::ios::binary);
578 if(invec.fail())
579 return StatusCode::FAILURE;
580
581 int32_t vsiz=0;
582 invec.read(charAddress(vsiz), sizeof (vsiz));
583 m_size = vsiz;
584// std::cout<<"size="<<m_size<<std::endl;
585
586// int32_t io_scale;
587 invec.read(charAddress(scale), sizeof (scale));
588// scale=io_scale;
589// std::cout<<"scale="<<scale<<std::endl;
590
591 if (StdUnits)
592 invec.read(charAddress(version), sizeof (version));
593
594// std::cout << "AlVec::StdUnits: " << StdUnits << std::endl;
595// std::cout << "AlVec::scale: " << scale << std::endl;
596// std::cout << "AlVec::version: " << version << std::endl;
597
598 int64_t ielem=0;
599 double velem=0.0;
600 for( int i=0; i<m_size; i++) {
601 invec.read(charAddress(ielem), sizeof (ielem));
602 modmap[i/6] = ielem;
603
604 invec.read(charAddress(velem), sizeof (velem));
605 *(m_ptr_data+i) = velem;
606
607 // std::cout << "AlVec (" << i << "):: " << ielem << ", " << velem << std::endl;
608
609 }
610
611 invec.close();
612 return StatusCode::SUCCESS;
613}
static StatusCode CheckVecVersion(const std::string &, bool &)
Definition AlVec.cxx:539

◆ ReadPartial()

StatusCode Trk::AlVec::ReadPartial ( const std::string & filename,
double & scale,
std::map< int, unsigned long long > & modmap,
float & version )

Definition at line 491 of file AlVec.cxx.

493{
494 bool StdUnits = true;
495 if (StatusCode::SUCCESS != CheckVecVersion(m_pathbin+filename, StdUnits)) {
496 //std::cout<<"CheckVecVersion failed"<<std::endl;
497 return StatusCode::FAILURE;
498 }
499
500 std::ifstream invec((m_pathbin+filename).c_str(), std::ios::binary);
501 if(invec.fail()) {
502 //std::cout<<"ifstream failed"<<std::endl;
503 return StatusCode::FAILURE;
504 }
505
506 int32_t vsiz=0;
507 invec.read(charAddress(vsiz), sizeof (vsiz));
508 m_size = vsiz;
509
510// int32_t io_scale;
511 invec.read(charAddress(scale), sizeof(scale));
512// scale=io_scale;
513
514 if (StdUnits)
515 invec.read(charAddress(version), sizeof (version));
516
517// std::cout << "AlVec::StdUnits: " << StdUnits << std::endl;
518// std::cout << "AlVec::scale: " << scale << std::endl;
519// std::cout << "AlVec::version: " << version << std::endl;
520
521 int64_t ielem=0;
522 double velem=0.0;
523 for( int i=0; i<m_size; i++) {
524 invec.read(charAddress(ielem), sizeof (ielem));
525 modmap[i] = ielem;
526
527 invec.read(charAddress(velem), sizeof (velem));
528 *(m_ptr_data+i) = velem;
529
530 // std::cout << "AlVec (" << i << "):: " << ielem << ", " << velem << std::endl;
531
532 }
533
534 invec.close();
535 return StatusCode::SUCCESS;
536}

◆ ReadProjected()

StatusCode Trk::AlVec::ReadProjected ( const std::string & filename,
double & scale,
std::map< int, unsigned long long > & modmap,
float & version )

Definition at line 616 of file AlVec.cxx.

618{
619 std::ifstream invec((m_pathbin+filename).c_str(), std::ios::binary);
620 if(invec.fail())
621 return StatusCode::FAILURE;
622
623 int32_t vsiz=0;
624 invec.read(charAddress(vsiz), sizeof (vsiz));
625 m_size = vsiz;
626
627// int32_t io_scale;
628 invec.read(charAddress(scale), sizeof (scale));
629// scale=io_scale;
630
631 invec.read(charAddress(version), sizeof (version));
632
633 // std::cout << "AlVec::scale: " << scale << std::endl;
634 // std::cout << "AlVec::version: " << version << std::endl;
635
636 int64_t ielem=0;
637 double velem=0.0;
638 for( int i=0; i<m_size; i++) {
639 invec.read(charAddress(ielem), sizeof (ielem));
640 modmap[i/6] = ielem;
641
642 invec.read(charAddress(velem), sizeof (velem));
643 *(m_ptr_data+i) = velem;
644
645 // std::cout << "AlVec (" << i << "):: " << ielem << ", " << velem << std::endl;
646
647 }
648
649 invec.close();
650 return StatusCode::SUCCESS;
651}

◆ ReadScalaPack()

StatusCode Trk::AlVec::ReadScalaPack ( const std::string & filename)

Definition at line 654 of file AlVec.cxx.

654 {
655 std::ifstream eigenvec(filename.c_str(), std::ios::binary);
656 if(eigenvec.fail())
657 return StatusCode::FAILURE;
658
659 int32_t vsiz=0;
660 eigenvec.read(charAddress(vsiz), sizeof (vsiz));
661 m_size=vsiz;
662
663 double velem=0;
664 for( int i=0; i<m_size; i++) {
665 eigenvec.read(charAddress(velem), sizeof (velem));
666 // printf("v[%d] = %.16lf \n",i,velem);
667 *(m_ptr_data+i) = velem;
668 }
669
670 eigenvec.close();
671 return StatusCode::SUCCESS;
672}

◆ RemoveAlignPar()

void Trk::AlVec::RemoveAlignPar ( int index,
int control )

Definition at line 256 of file AlVec.cxx.

257{
258 // Dynamic shift
259 int shift = 1;
260 int counter = 0;
261
262 index = index-control;
263 // std::cout << "index: " << index << " - control: " << control << std::endl;
264
265 for(int row=index; row<m_size; row++) {
266 *(m_ptr_data+row) = *(m_ptr_data+row+shift);
267 counter++;
268 if (counter==5-control) { counter=0; shift++; }
269 }
270}
str index
Definition DeMoScan.py:362
row
Appending html table to final .html summary file.

◆ RemoveElements()

int Trk::AlVec::RemoveElements ( std::vector< int > indices)

Definition at line 273 of file AlVec.cxx.

274{
275 int n = indices.size();
276 if (n==0) {
277 return m_size;
278 }
279 if (n>m_size) {
280 throw std::range_error( "Vector of indices larger than matrix size." );
281 }
282
283 // first sort the list of indices descending
284 // maybe not the fastest way to do that but it works
285 for (int i=0;i<n-1;i++)
286 for (int j=i+1; j<n; j++)
287 if (indices[j] > indices[i]) {
288 int itmp = indices[i];
289 indices[i] = indices[j];
290 indices[j] = itmp;
291 }
292
293 // remove elements starting from largest indices
294 for (int i=0;i<n;i++) {
295 int index = indices[i];
296 if (index > m_size-1) {
297 throw std::out_of_range( "AlVec::RemoveElements: Index goes beyond matrix " );
298 }
299
300 for (int j=index; j<m_size-1; j++)
301 *(m_ptr_data+j) = *(m_ptr_data+j+1);
302
303 m_size--;
304 }
305
306 return m_size;
307}
std::pair< long int, long int > indices

◆ RemoveModule()

void Trk::AlVec::RemoveModule ( int index)

Definition at line 243 of file AlVec.cxx.

243 {
244 // Static shift
245 const int shift=6;
246 const int start = shift*index;
247
248 if(start<m_size && index>=0){
249 for(int row=start; row<m_size; row++) {
250 *(m_ptr_data+row)=*(m_ptr_data+row+shift);
251 }
252 }
253}

◆ reSize()

void Trk::AlVec::reSize ( int Nnew)

Definition at line 226 of file AlVec.cxx.

226 {
227 if ( Nnew>=0 && Nnew != m_size ) {
228 double* p = m_ptr_data;
229 int size_old = m_size;
230 m_ptr_data = new double[Nnew];
231 m_size = Nnew;
232 int k = m_size <= size_old ? m_size : size_old;
233
234 p += k;
235 double* q = m_ptr_data + k;
236 while (q > m_ptr_data) *(--q) = *(--p);
237
238 delete [] p;
239 }
240}

◆ SetPathBin()

void Trk::AlVec::SetPathBin ( const std::string & path)

Definition at line 310 of file AlVec.cxx.

311{
312 m_pathbin.assign(path);
313}

◆ SetPathTxt()

void Trk::AlVec::SetPathTxt ( const std::string & path)

Definition at line 316 of file AlVec.cxx.

317{
318 m_pathtxt.assign(path);
319}

◆ size()

int Trk::AlVec::size ( ) const
inline

Definition at line 109 of file AlVec.h.

109 {
110 return m_size;
111}

◆ Write()

StatusCode Trk::AlVec::Write ( const std::string & filename,
bool binary,
double scale,
std::map< int, unsigned long long > moduleIndexMap,
float version )

Definition at line 322 of file AlVec.cxx.

324{
325 std::ofstream outvec;
326 int32_t io_size=m_size;
327// int32_t io_scale=scale;
328
329 if(binary) {
330 outvec.open((m_pathbin+filename).c_str(), std::ios::binary);
331 if(outvec.fail())
332 return StatusCode::FAILURE;
333 outvec.write(charAddress(io_size), sizeof (io_size));
334 outvec.write(charAddress(scale), sizeof (scale));
335 outvec.write(charAddress(version), sizeof (version));
336 }
337 else {
338 outvec.open((m_pathtxt+filename).c_str());
339 if(outvec.fail())
340 return StatusCode::FAILURE;
341 outvec.setf(std::ios::fixed);
342 outvec.setf(std::ios::showpoint);
343 outvec.precision(6);
344 outvec << "DoF: " << std::setw(6) << m_size << std::endl;
345 outvec << "scale: " << std::setw(18) << scale << std::endl;
346 outvec << "AlVec version: " << std::setw(6) << version << std::endl;
347 }
348
349 int64_t ielem=0;
350 double velem=0;
351 std::map<int,unsigned long long>::iterator itcod;
352
353 for( int i=0; i<m_size; i++) {
354 itcod=moduleIndexMap.find(i/6);
355 if (itcod != moduleIndexMap.end()) {
356 ielem = (itcod->second);
357 }
358
359 velem = *(m_ptr_data+i);
360
361 if(binary){
362 outvec.write(charAddress((ielem)), sizeof (ielem));
363 outvec.write(charAddress((velem)), sizeof (velem));
364 }
365 else
366 outvec << std::setw(20) << ielem << std::setw(18) << velem << std::endl;
367 }
368 outvec.close();
369 return StatusCode::SUCCESS;
370}

◆ WriteEigenvalueVec()

StatusCode Trk::AlVec::WriteEigenvalueVec ( const std::string & filename,
bool binary )

Definition at line 675 of file AlVec.cxx.

675 {
676
677 std::ofstream outvec;
678 int32_t io_size=m_size;
679
680 if(binary) {
681 outvec.open((m_pathbin+filename).c_str(), std::ios::binary);
682
683 if(outvec.fail())
684 return StatusCode::FAILURE;
685
686 outvec.write(charAddress(io_size), sizeof (io_size));
687 }
688 else{
689 outvec.open((m_pathtxt+filename).c_str());
690
691 if(outvec.fail())
692 return StatusCode::FAILURE;
693
694 outvec.setf(std::ios::fixed);
695 outvec.setf(std::ios::showpoint);
696 outvec.precision(6);
697 outvec << "AlVec::DoF: " << std::setw(6) << m_size << std::endl;
698 }
699
700 //jlove int32_t ielem=0;
701 double velem=0;
702// std::map<int,int>::iterator itcod;
703
704 for( int i=0; i<m_size; i++) {
705
706 velem = *(m_ptr_data+i);
707
708 if(binary)
709 outvec.write(charAddress((velem)), sizeof (velem));
710 else
711 outvec << std::setw(10) << i << std::setw(18) << velem << std::endl;
712 }
713 outvec.close();
714 return StatusCode::SUCCESS;
715}

◆ WritePartial() [1/2]

StatusCode Trk::AlVec::WritePartial ( const std::string & filename,
bool binary,
double scale,
std::map< int, std::string > moduleNameMap,
float version )

Definition at line 430 of file AlVec.cxx.

432{
433 std::ofstream outvec;
434
435 StatusCode sc=InitializeOutputVector(filename,binary,scale,version,outvec);
436 if (sc!=StatusCode::SUCCESS) return StatusCode::FAILURE;
437
438 std::string elem="";
439 double velem=0;
440 std::map<int,std::string>::iterator itcod;
441
442 for( int i=0; i<m_size; i++) {
443 itcod=moduleNameMap.find(i);
444 if (itcod != moduleNameMap.end()) {
445 elem = (itcod->second);
446 }
447
448 velem = *(m_ptr_data+i);
449
450 if(binary){
451 std::cout<<"can't write module name in binary output!"<<std::endl;
452 return StatusCode::FAILURE;
453 }
454 else
455 outvec << std::setw(20) << elem << std::setw(18) << velem << std::endl;
456 }
457 outvec.close();
458 return StatusCode::SUCCESS;
459}
static Double_t sc
StatusCode InitializeOutputVector(const std::string &, bool, double, float, std::ofstream &)
Definition AlVec.cxx:462
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ WritePartial() [2/2]

StatusCode Trk::AlVec::WritePartial ( const std::string & filename,
bool binary,
double scale,
std::map< int, unsigned long long > moduleIndexMap,
float version )

Definition at line 373 of file AlVec.cxx.

375{
376 std::ofstream outvec;
377
378 /*
379 int32_t io_size=m_size;
380 // int32_t io_scale=scale;
381
382 if(binary) {
383 outvec.open((m_pathbin+filename).c_str(), std::ios::binary);
384 if(outvec.fail())
385 return StatusCode::FAILURE;
386 outvec.write(charAddress(io_size), sizeof (io_size));
387 outvec.write(charAddress(scale), sizeof (scale));
388 outvec.write(charAddress(version), sizeof (version));
389
390 }
391 else {
392 outvec.open((m_pathtxt+filename).c_str());
393 if(outvec.fail())
394 return StatusCode::FAILURE;
395 outvec.setf(std::ios::fixed);
396 outvec.setf(std::ios::showpoint);
397 outvec.precision(6);
398 outvec << "DoF: " << std::setw(6) << m_size << std::endl;
399 outvec << "scale: " << std::setw(18) << scale << std::endl;
400 outvec << "AlVec version: " << std::setw(6) << version << std::endl;
401 }
402 */
403
404 StatusCode sc=InitializeOutputVector(filename,binary,scale,version,outvec);
405 if (sc!=StatusCode::SUCCESS) return StatusCode::FAILURE;
406
407 int64_t ielem=0;
408 double velem=0;
409 std::map<int,unsigned long long>::iterator itcod;
410
411 for( int i=0; i<m_size; i++) {
412 itcod=moduleIndexMap.find(i);
413 if (itcod != moduleIndexMap.end())
414 ielem = (itcod->second);
415
416 velem = *(m_ptr_data+i);
417
418 if(binary){
419 outvec.write(charAddress((ielem)), sizeof (ielem));
420 outvec.write(charAddress((velem)), sizeof (velem));
421 }
422 else
423 outvec << std::setw(20) << ielem << std::setw(18) << velem << std::endl;
424 }
425 outvec.close();
426 return StatusCode::SUCCESS;
427}

Member Data Documentation

◆ m_pathbin

std::string Trk::AlVec::m_pathbin
protected

Definition at line 96 of file AlVec.h.

◆ m_pathtxt

std::string Trk::AlVec::m_pathtxt
protected

Definition at line 97 of file AlVec.h.

◆ m_ptr_data

double* Trk::AlVec::m_ptr_data = nullptr
protected

Definition at line 95 of file AlVec.h.

◆ m_size

int Trk::AlVec::m_size
protected

Definition at line 94 of file AlVec.h.


The documentation for this class was generated from the following files: