ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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 31 of file AlVec.cxx.

32  : m_size(N)
33  , m_ptr_data(new double[m_size])
34  , m_pathbin("./")
35  , m_pathtxt("./")
36 {
37 
38  double* p = m_ptr_data + m_size;
39  while (p > m_ptr_data) *(--p) = 0.;
40 }

◆ AlVec() [2/4]

Trk::AlVec::AlVec ( )

Definition at line 20 of file AlVec.cxx.

21  : m_size(0)
22  , m_ptr_data(nullptr)
23  , m_pathbin("./")
24  , m_pathtxt("./")
25 {
26 
27  // set pointer to null
28 }

◆ AlVec() [3/4]

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

Definition at line 43 of file AlVec.cxx.

44  : m_size(v.m_size)
45  , m_ptr_data(new double[m_size])
46  , m_pathbin(v.m_pathbin)
47  , m_pathtxt(v.m_pathtxt)
48 {
49 
50  copy(v);
51 }

◆ 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 54 of file AlVec.cxx.

55 {
56  delete [] m_ptr_data;
57 }

Member Function Documentation

◆ CheckVecVersion()

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

Definition at line 532 of file AlVec.cxx.

532  {
533  std::ifstream invec((filename).c_str(), std::ios::binary);
534  if(invec.fail())
535  return StatusCode::FAILURE;
536 
537  int32_t vsiz=0;
538  invec.read((char*)&vsiz, sizeof (vsiz));
539 
540 // int32_t scale=0;
541  double scale=0.;
542  invec.read((char*)&scale, sizeof (scale));
543 
544  float version=0.0;
545  invec.read((char*)&version, sizeof (version));
546 
547  StdUnits = version>=2.0;
548 
549  invec.close();
550 
551  // std::cout << "AlVec::StdUnits: " << StdUnits << std::endl;
552  // std::cout << "AlVec::scale: " << scale << std::endl;
553  // std::cout << "AlVec::vsiz: " << vsiz << std::endl;
554  // std::cout << "AlVec::version: " << version << std::endl;
555 
556  return StatusCode::SUCCESS;
557 }

◆ copy()

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

Definition at line 60 of file AlVec.cxx.

60  {
61  if(m_size!=v.m_size) {
62  throw std::range_error( "AlVec Assignment: size does not match!" );
63  }
64 
65  double* p = m_ptr_data + m_size;
66  double* q = v.m_ptr_data + m_size;
67  while (p > m_ptr_data) *(--p) = (*(--q));
68 }

◆ InitializeOutputVector()

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

Definition at line 455 of file AlVec.cxx.

457 {
458  int32_t io_size=m_size;
459 
460  if(binary) {
461  outvec.open((m_pathbin+filename).c_str(), std::ios::binary);
462  if(outvec.fail())
463  return StatusCode::FAILURE;
464  outvec.write((char*)&io_size, sizeof (io_size));
465  outvec.write((char*)&scale, sizeof (scale));
466  outvec.write((char*)&version, sizeof (version));
467 
468  }
469  else {
470  outvec.open((m_pathtxt+filename).c_str());
471  if(outvec.fail())
472  return StatusCode::FAILURE;
473  outvec.setf(std::ios::fixed);
474  outvec.setf(std::ios::showpoint);
475  outvec.precision(6);
476  outvec << "DoF: " << std::setw(6) << m_size << std::endl;
477  outvec << "scale: " << std::setw(18) << scale << std::endl;
478  outvec << "AlVec version: " << std::setw(6) << version << std::endl;
479  }
480  return StatusCode::SUCCESS;
481 }

◆ norm()

double Trk::AlVec::norm ( ) const

Definition at line 206 of file AlVec.cxx.

206  {
207 
208  double result(0.);
209  double * p = m_ptr_data + m_size;
210  while (p > m_ptr_data) {
211  --p;
212  result += *p * *p ;
213  }
214 
215  return sqrt(result);
216 }

◆ operator*() [1/4]

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

Definition at line 167 of file AlVec.cxx.

167  {
168  if (m_size != m.nrow()) {
169  throw std::range_error( "Left hand vector-matrix multiplication: size does not match!" );
170  }
171 
172  AlVec b(m.ncol());
173 
174  for (int i=0;i<m.ncol();i++) {
175  for (int j=0;j<m_size;j++) *(b.m_ptr_data+i) += *(m_ptr_data+j)*m.elemc(j, i);
176  }
177  return b;
178 }

◆ operator*() [2/4]

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

Definition at line 181 of file AlVec.cxx.

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

◆ operator*() [3/4]

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

Definition at line 153 of file AlVec.cxx.

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

◆ operator*() [4/4]

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

◆ operator*=()

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

Definition at line 195 of file AlVec.cxx.

195  {
196 
197  double* p = m_ptr_data + m_size;
198  while (p > m_ptr_data) *(--p) *= d;
199 
200  return *this;
201 }

◆ operator+()

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

Definition at line 95 of file AlVec.cxx.

95  {
96  if( m_size != v.m_size ) {
97  throw std::range_error( "operator+: vectors size does not match!" );
98  }
99 
100  AlVec b(m_size);
101 
102  double* p = m_ptr_data + m_size;
103  double* q = v.m_ptr_data + m_size;
104  double* r = b.m_ptr_data + m_size;
105  while (p > m_ptr_data) *(--r) = (*(--p))+(*(--q));
106 
107  return b;
108 }

◆ operator+=()

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

Definition at line 111 of file AlVec.cxx.

111  {
112  if( m_size != v.m_size ) {
113  throw std::range_error( "operator+=: vectors size does not match!" );
114  }
115 
116  double* p = m_ptr_data + m_size;
117  double* q = v.m_ptr_data + m_size;
118  while (p > m_ptr_data) *(--p) += (*(--q));
119 
120  return *this;
121 }

◆ operator-()

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

Definition at line 124 of file AlVec.cxx.

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

◆ operator-=()

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

Definition at line 140 of file AlVec.cxx.

140  {
141  if( m_size != v.m_size ) {
142  throw std::range_error( "operator+=: vectors size does not match!" );
143  }
144 
145  double* p = m_ptr_data + m_size;
146  double* q = v.m_ptr_data + m_size;
147  while (p > m_ptr_data) *(--p) -= (*(--q));
148 
149  return *this;
150 }

◆ 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 82 of file AlVec.cxx.

82  {
83  if (this==&v) return *this;
84 
85  if(m_size!=0 && m_size!=v.m_size) {
86  throw std::range_error( "AlVec Assignment: size does not match!" );
87  }
88 
89  if ( m_ptr_data != v.m_ptr_data ) copy(v);
90 
91  return *this;
92 }

◆ operator=() [3/3]

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

Definition at line 71 of file AlVec.cxx.

71  {
72 
73  double* p = m_ptr_data + m_size;
74  while (p > m_ptr_data) *(--p) = d;
75 
76  return *this;
77 }

◆ 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 560 of file AlVec.cxx.

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

◆ ReadPartial()

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

Definition at line 484 of file AlVec.cxx.

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

◆ ReadProjected()

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

Definition at line 609 of file AlVec.cxx.

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

◆ ReadScalaPack()

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

Definition at line 647 of file AlVec.cxx.

647  {
648  std::ifstream eigenvec(filename.c_str(), std::ios::binary);
649  if(eigenvec.fail())
650  return StatusCode::FAILURE;
651 
652  int32_t vsiz=0;
653  eigenvec.read((char*)&vsiz, sizeof (vsiz));
654  m_size=vsiz;
655 
656  double velem=0;
657  for( int i=0; i<m_size; i++) {
658  eigenvec.read((char*)&velem, sizeof (velem));
659  // printf("v[%d] = %.16lf \n",i,velem);
660  *(m_ptr_data+i) = velem;
661  }
662 
663  eigenvec.close();
664  return StatusCode::SUCCESS;
665 }

◆ RemoveAlignPar()

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

Definition at line 249 of file AlVec.cxx.

250 {
251  // Dynamic shift
252  int shift = 1;
253  int counter = 0;
254 
255  index = index-control;
256  // std::cout << "index: " << index << " - control: " << control << std::endl;
257 
258  for(int row=index; row<m_size; row++) {
259  *(m_ptr_data+row) = *(m_ptr_data+row+shift);
260  counter++;
261  if (counter==5-control) { counter=0; shift++; }
262  }
263 }

◆ RemoveElements()

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

Definition at line 266 of file AlVec.cxx.

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

◆ RemoveModule()

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

Definition at line 236 of file AlVec.cxx.

236  {
237  // Static shift
238  const int shift=6;
239  const int start = shift*index;
240 
241  if(start<m_size && index>=0){
242  for(int row=start; row<m_size; row++) {
243  *(m_ptr_data+row)=*(m_ptr_data+row+shift);
244  }
245  }
246 }

◆ reSize()

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

Definition at line 219 of file AlVec.cxx.

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

◆ SetPathBin()

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

Definition at line 303 of file AlVec.cxx.

304 {
305  m_pathbin.assign(path);
306 }

◆ SetPathTxt()

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

Definition at line 309 of file AlVec.cxx.

310 {
311  m_pathtxt.assign(path);
312 }

◆ 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 315 of file AlVec.cxx.

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

◆ WriteEigenvalueVec()

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

Definition at line 668 of file AlVec.cxx.

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

◆ 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 423 of file AlVec.cxx.

425 {
426  std::ofstream outvec;
427 
429  if (sc!=StatusCode::SUCCESS) return StatusCode::FAILURE;
430 
431  std::string elem="";
432  double velem=0;
434 
435  for( int i=0; i<m_size; i++) {
436  itcod=moduleNameMap.find(i);
437  if (itcod != moduleNameMap.end()) {
438  elem = (itcod->second);
439  }
440 
441  velem = *(m_ptr_data+i);
442 
443  if(binary){
444  std::cout<<"can't write module name in binary output!"<<std::endl;
445  return StatusCode::FAILURE;
446  }
447  else
448  outvec << std::setw(20) << elem << std::setw(18) << velem << std::endl;
449  }
450  outvec.close();
451  return StatusCode::SUCCESS;
452 }

◆ 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 366 of file AlVec.cxx.

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

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:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
query_example.row
row
Definition: query_example.py:24
beamspotman.r
def r
Definition: beamspotman.py:676
Trk::AlVec::InitializeOutputVector
StatusCode InitializeOutputVector(const std::string &, bool, double, float, std::ofstream &)
Definition: AlVec.cxx:455
Trk::AlVec::CheckVecVersion
static StatusCode CheckVecVersion(const std::string &, bool &)
Definition: AlVec.cxx:532
beamspotPlotBcids.k
k
Definition: beamspotPlotBcids.py:524
get_generator_info.result
result
Definition: get_generator_info.py:21
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
Trk::AlVec::copy
void copy(const AlVec &)
Definition: AlVec.cxx:60
index
Definition: index.py:1
hist_file_dump.d
d
Definition: hist_file_dump.py:137
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
Trk::AlVec::m_size
int m_size
Definition: AlVec.h:94
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
Trk::AlVec::m_pathtxt
std::string m_pathtxt
Definition: AlVec.h:97
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::AlVec::AlVec
AlVec()
Definition: AlVec.cxx:20
Trk::AlVec::m_pathbin
std::string m_pathbin
Definition: AlVec.h:96
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
get_generator_info.version
version
Definition: get_generator_info.py:33
Trk::AlVec::m_ptr_data
double * m_ptr_data
Definition: AlVec.h:95
DeMoScan.index
string index
Definition: DeMoScan.py:362
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
extractSporadic.q
list q
Definition: extractSporadic.py:98
test_pyathena.counter
counter
Definition: test_pyathena.py:15
Trk::v
@ v
Definition: ParamDefs.h:84