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 (std::string_view, bool, double, const std::map< int, unsigned long long > &, float)
StatusCode WritePartial (std::string_view, bool, double, const std::map< int, unsigned long long > &, float)
StatusCode WritePartial (std::string_view, bool, double, const std::map< int, std::string > &, float)
StatusCode InitializeOutputVector (std::string_view, 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 26 of file AlVec.h.

Constructor & Destructor Documentation

◆ AlVec() [1/4]

Trk::AlVec::AlVec ( int N)

Definition at line 36 of file AlVec.cxx.

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

◆ AlVec() [2/4]

Trk::AlVec::AlVec ( )

Definition at line 25 of file AlVec.cxx.

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

◆ AlVec() [3/4]

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

Definition at line 48 of file AlVec.cxx.

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

◆ AlVec() [4/4]

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

Definition at line 31 of file AlVec.h.

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

◆ ~AlVec()

Trk::AlVec::~AlVec ( )

Definition at line 59 of file AlVec.cxx.

60{
61 delete [] m_ptr_data;
62}

Member Function Documentation

◆ CheckVecVersion()

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

Definition at line 512 of file AlVec.cxx.

512 {
513 std::ifstream invec((filename), std::ios::binary);
514 if(invec.fail())
515 return StatusCode::FAILURE;
516
517 int32_t vsiz=0;
518 invec.read(charAddress(vsiz), sizeof (vsiz));
519
520// int32_t scale=0;
521 double scale=0.;
522 invec.read(charAddress(scale), sizeof (scale));
523
524 float version=0.0;
525 invec.read(charAddress(version), sizeof (version));
526
527 StdUnits = version>=2.0;
528
529 invec.close();
530
531 // std::cout << "AlVec::StdUnits: " << StdUnits << std::endl;
532 // std::cout << "AlVec::scale: " << scale << std::endl;
533 // std::cout << "AlVec::vsiz: " << vsiz << std::endl;
534 // std::cout << "AlVec::version: " << version << std::endl;
535
536 return StatusCode::SUCCESS;
537}

◆ copy()

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

Definition at line 65 of file AlVec.cxx.

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

◆ InitializeOutputVector()

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

Definition at line 435 of file AlVec.cxx.

437{
438 int32_t io_size=m_size;
439
440 if(binary) {
441 outvec.open(m_pathbin.append(filename), std::ios::binary);
442 if(outvec.fail())
443 return StatusCode::FAILURE;
444 outvec.write(charAddress(io_size), sizeof (io_size));
445 outvec.write(charAddress(scale), sizeof (scale));
446 outvec.write(charAddress(version), sizeof (version));
447
448 }
449 else {
450 outvec.open(m_pathtxt.append(filename));
451 if(outvec.fail())
452 return StatusCode::FAILURE;
453 outvec.setf(std::ios::fixed);
454 outvec.setf(std::ios::showpoint);
455 outvec.precision(6);
456 outvec << "DoF: " << std::setw(6) << m_size << std::endl;
457 outvec << "scale: " << std::setw(18) << scale << std::endl;
458 outvec << "AlVec version: " << std::setw(6) << version << std::endl;
459 }
460 return StatusCode::SUCCESS;
461}

◆ norm()

double Trk::AlVec::norm ( ) const

Definition at line 211 of file AlVec.cxx.

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

◆ operator*() [1/4]

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

Definition at line 172 of file AlVec.cxx.

172 {
173 if (m_size != m.nrow()) {
174 throw std::range_error( "Left hand vector-matrix multiplication: size does not match!" );
175 }
176
177 AlVec b(m.ncol());
178
179 for (int i=0;i<m.ncol();i++) {
180 for (int j=0;j<m_size;j++) *(b.m_ptr_data+i) += *(m_ptr_data+j)*m.elemc(j, i);
181 }
182 return b;
183}
AlVec(int N)
Definition AlVec.cxx:36
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)

◆ operator*() [2/4]

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

Definition at line 186 of file AlVec.cxx.

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

◆ operator*() [3/4]

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

Definition at line 158 of file AlVec.cxx.

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

◆ operator*() [4/4]

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

◆ operator*=()

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

Definition at line 200 of file AlVec.cxx.

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

◆ operator+()

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

Definition at line 100 of file AlVec.cxx.

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

◆ operator+=()

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

Definition at line 116 of file AlVec.cxx.

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

◆ operator-()

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

Definition at line 129 of file AlVec.cxx.

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

◆ operator-=()

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

Definition at line 145 of file AlVec.cxx.

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

◆ operator=() [1/3]

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

Definition at line 48 of file AlVec.h.

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

◆ operator=() [2/3]

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

Definition at line 87 of file AlVec.cxx.

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

◆ operator=() [3/3]

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

Definition at line 76 of file AlVec.cxx.

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

◆ operator[]() [1/2]

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

Definition at line 124 of file AlVec.h.

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

◆ operator[]() [2/2]

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

Definition at line 136 of file AlVec.h.

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

◆ ptrData() [1/2]

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

Definition at line 120 of file AlVec.h.

120 {
121 return m_ptr_data;
122}

◆ ptrData() [2/2]

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

Definition at line 116 of file AlVec.h.

116 {
117 return m_ptr_data;
118}

◆ Read()

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

Definition at line 540 of file AlVec.cxx.

542{
543
544 bool StdUnits = true;
545 if (StatusCode::SUCCESS != CheckVecVersion(m_pathbin+filename, StdUnits)) {
546 //std::cout<<"CheckVecVersion failed"<<std::endl;
547 return StatusCode::FAILURE;
548 }
549
550 std::ifstream invec(m_pathbin+filename, std::ios::binary);
551 if(invec.fail())
552 return StatusCode::FAILURE;
553
554 int32_t vsiz=0;
555 invec.read(charAddress(vsiz), sizeof (vsiz));
556 m_size = vsiz;
557// std::cout<<"size="<<m_size<<std::endl;
558
559// int32_t io_scale;
560 invec.read(charAddress(scale), sizeof (scale));
561// scale=io_scale;
562// std::cout<<"scale="<<scale<<std::endl;
563
564 if (StdUnits)
565 invec.read(charAddress(version), sizeof (version));
566
567// std::cout << "AlVec::StdUnits: " << StdUnits << std::endl;
568// std::cout << "AlVec::scale: " << scale << std::endl;
569// std::cout << "AlVec::version: " << version << std::endl;
570
571 int64_t ielem=0;
572 double velem=0.0;
573 for( int i=0; i<m_size; i++) {
574 invec.read(charAddress(ielem), sizeof (ielem));
575 modmap[i/6] = ielem;
576
577 invec.read(charAddress(velem), sizeof (velem));
578 *(m_ptr_data+i) = velem;
579
580 // std::cout << "AlVec (" << i << "):: " << ielem << ", " << velem << std::endl;
581
582 }
583
584 invec.close();
585 return StatusCode::SUCCESS;
586}
static StatusCode CheckVecVersion(const std::string &, bool &)
Definition AlVec.cxx:512

◆ ReadPartial()

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

Definition at line 464 of file AlVec.cxx.

466{
467 bool StdUnits = true;
468 if (StatusCode::SUCCESS != CheckVecVersion(m_pathbin+filename, StdUnits)) {
469 //std::cout<<"CheckVecVersion failed"<<std::endl;
470 return StatusCode::FAILURE;
471 }
472
473 std::ifstream invec((m_pathbin+filename), std::ios::binary);
474 if(invec.fail()) {
475 //std::cout<<"ifstream failed"<<std::endl;
476 return StatusCode::FAILURE;
477 }
478
479 int32_t vsiz=0;
480 invec.read(charAddress(vsiz), sizeof (vsiz));
481 m_size = vsiz;
482
483// int32_t io_scale;
484 invec.read(charAddress(scale), sizeof(scale));
485// scale=io_scale;
486
487 if (StdUnits)
488 invec.read(charAddress(version), sizeof (version));
489
490// std::cout << "AlVec::StdUnits: " << StdUnits << std::endl;
491// std::cout << "AlVec::scale: " << scale << std::endl;
492// std::cout << "AlVec::version: " << version << std::endl;
493
494 int64_t ielem=0;
495 double velem=0.0;
496 for( int i=0; i<m_size; i++) {
497 invec.read(charAddress(ielem), sizeof (ielem));
498 modmap[i] = ielem;
499
500 invec.read(charAddress(velem), sizeof (velem));
501 *(m_ptr_data+i) = velem;
502
503 // std::cout << "AlVec (" << i << "):: " << ielem << ", " << velem << std::endl;
504
505 }
506
507 invec.close();
508 return StatusCode::SUCCESS;
509}

◆ ReadProjected()

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

Definition at line 589 of file AlVec.cxx.

591{
592 std::ifstream invec(m_pathbin+filename, std::ios::binary);
593 if(invec.fail())
594 return StatusCode::FAILURE;
595
596 int32_t vsiz=0;
597 invec.read(charAddress(vsiz), sizeof (vsiz));
598 m_size = vsiz;
599
600// int32_t io_scale;
601 invec.read(charAddress(scale), sizeof (scale));
602// scale=io_scale;
603
604 invec.read(charAddress(version), sizeof (version));
605
606 // std::cout << "AlVec::scale: " << scale << std::endl;
607 // std::cout << "AlVec::version: " << version << std::endl;
608
609 int64_t ielem=0;
610 double velem=0.0;
611 for( int i=0; i<m_size; i++) {
612 invec.read(charAddress(ielem), sizeof (ielem));
613 modmap[i/6] = ielem;
614
615 invec.read(charAddress(velem), sizeof (velem));
616 *(m_ptr_data+i) = velem;
617
618 // std::cout << "AlVec (" << i << "):: " << ielem << ", " << velem << std::endl;
619
620 }
621
622 invec.close();
623 return StatusCode::SUCCESS;
624}

◆ ReadScalaPack()

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

Definition at line 627 of file AlVec.cxx.

627 {
628 std::ifstream eigenvec(filename, std::ios::binary);
629 if(eigenvec.fail())
630 return StatusCode::FAILURE;
631
632 int32_t vsiz=0;
633 eigenvec.read(charAddress(vsiz), sizeof (vsiz));
634 m_size=vsiz;
635
636 double velem=0;
637 for( int i=0; i<m_size; i++) {
638 eigenvec.read(charAddress(velem), sizeof (velem));
639 // printf("v[%d] = %.16lf \n",i,velem);
640 *(m_ptr_data+i) = velem;
641 }
642
643 eigenvec.close();
644 return StatusCode::SUCCESS;
645}

◆ RemoveAlignPar()

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

Definition at line 254 of file AlVec.cxx.

255{
256 // Dynamic shift
257 int shift = 1;
258 int counter = 0;
259
260 index = index-control;
261 // std::cout << "index: " << index << " - control: " << control << std::endl;
262
263 for(int row=index; row<m_size; row++) {
264 *(m_ptr_data+row) = *(m_ptr_data+row+shift);
265 counter++;
266 if (counter==5-control) { counter=0; shift++; }
267 }
268}
str index
Definition DeMoScan.py:362
row
Appending html table to final .html summary file.
virtual void shift(size_t pos, ptrdiff_t offs) override
Shift the elements of the container.

◆ RemoveElements()

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

Definition at line 271 of file AlVec.cxx.

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

◆ RemoveModule()

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

Definition at line 241 of file AlVec.cxx.

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

◆ reSize()

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

Definition at line 224 of file AlVec.cxx.

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

◆ SetPathBin()

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

Definition at line 308 of file AlVec.cxx.

309{
310 m_pathbin.assign(path);
311}

◆ SetPathTxt()

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

Definition at line 314 of file AlVec.cxx.

315{
316 m_pathtxt.assign(path);
317}

◆ size()

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

Definition at line 112 of file AlVec.h.

112 {
113 return m_size;
114}

◆ Write()

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

Definition at line 320 of file AlVec.cxx.

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

◆ WriteEigenvalueVec()

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

Definition at line 648 of file AlVec.cxx.

648 {
649
650 std::ofstream outvec;
651 int32_t io_size=m_size;
652
653 if(binary) {
654 outvec.open(m_pathbin+filename, std::ios::binary);
655
656 if(outvec.fail())
657 return StatusCode::FAILURE;
658
659 outvec.write(charAddress(io_size), sizeof (io_size));
660 }
661 else{
662 outvec.open(m_pathtxt+filename);
663
664 if(outvec.fail())
665 return StatusCode::FAILURE;
666
667 outvec.setf(std::ios::fixed);
668 outvec.setf(std::ios::showpoint);
669 outvec.precision(6);
670 outvec << "AlVec::DoF: " << std::setw(6) << m_size << std::endl;
671 }
672
673 //jlove int32_t ielem=0;
674 double velem=0;
675// std::map<int,int>::iterator itcod;
676
677 for( int i=0; i<m_size; i++) {
678
679 velem = *(m_ptr_data+i);
680
681 if(binary)
682 outvec.write(charAddress((velem)), sizeof (velem));
683 else
684 outvec << std::setw(10) << i << std::setw(18) << velem << std::endl;
685 }
686 outvec.close();
687 return StatusCode::SUCCESS;
688}

◆ WritePartial() [1/2]

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

Definition at line 404 of file AlVec.cxx.

406{
407 std::ofstream outvec;
408
409 StatusCode sc=InitializeOutputVector(filename,binary,scale,version,outvec);
410 if (sc!=StatusCode::SUCCESS) return StatusCode::FAILURE;
411
412 std::string elem="";
413 double velem=0;
414
415 for( int i=0; i<m_size; i++) {
416 auto itcod=moduleNameMap.find(i);
417 if (itcod != moduleNameMap.end()) {
418 elem = (itcod->second);
419 }
420
421 velem = *(m_ptr_data+i);
422
423 if(binary){
424 std::cout<<"can't write module name in binary output!"<<std::endl;
425 return StatusCode::FAILURE;
426 }
427 else
428 outvec << std::setw(20) << elem << std::setw(18) << velem << std::endl;
429 }
430 outvec.close();
431 return StatusCode::SUCCESS;
432}
static Double_t sc
StatusCode InitializeOutputVector(std::string_view, bool, double, float, std::ofstream &)
Definition AlVec.cxx:435
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ WritePartial() [2/2]

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

Definition at line 374 of file AlVec.cxx.

376{
377 std::ofstream outvec;
378
379 StatusCode sc=InitializeOutputVector(filename,binary,scale,version,outvec);
380 if (sc!=StatusCode::SUCCESS) return StatusCode::FAILURE;
381
382 int64_t ielem=0;
383 double velem=0;
384
385 for( int i=0; i<m_size; i++) {
386 auto itcod=moduleIndexMap.find(i);
387 if (itcod != moduleIndexMap.end())
388 ielem = (itcod->second);
389
390 velem = *(m_ptr_data+i);
391
392 if(binary){
393 outvec.write(charAddress((ielem)), sizeof (ielem));
394 outvec.write(charAddress((velem)), sizeof (velem));
395 }
396 else
397 outvec << std::setw(20) << ielem << std::setw(18) << velem << std::endl;
398 }
399 outvec.close();
400 return StatusCode::SUCCESS;
401}

Member Data Documentation

◆ m_pathbin

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

Definition at line 99 of file AlVec.h.

◆ m_pathtxt

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

Definition at line 100 of file AlVec.h.

◆ m_ptr_data

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

Definition at line 98 of file AlVec.h.

◆ m_size

int Trk::AlVec::m_size
protected

Definition at line 97 of file AlVec.h.


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