Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GFRaveVertex.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GFRaveVertex.cc
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 
21 #include "GFRaveVertex.h"
22 #include "GFRaveConverters.h"
23 #include <Exception.h>
24 
25 #include <iostream>
26 
27 namespace genfit {
28 
29 //#define COUNT
30 
31 #ifdef COUNT
32 static int instCount(0);
33 #endif
34 
36  cov_(3,3),
37  ndf_(0),
38  chi2_(0),
39  id_(-1)
40 {
41 #ifdef COUNT
42  std::cerr << "GFRaveVertex::GFRaveVertex() - Number of objects: " << ++instCount << std::endl;
43 #endif
44 }
45 
46 
47 GFRaveVertex::GFRaveVertex(const TVector3 & pos, const TMatrixDSym& cov,
48  const std::vector < GFRaveTrackParameters* > & smoothedTracks,
49  double ndf, double chi2, int id) :
50  pos_(pos),
51  cov_(cov),
52  ndf_(ndf),
53  chi2_(chi2),
54  id_(id),
55  smoothedTracks_(smoothedTracks)
56 {
57  if (cov_.GetNrows()!=3 || cov_.GetNcols()!=3) {
58  Exception exc("GFRaveVertex ==> Covariance is not 3x3!",__LINE__,__FILE__);
59  throw exc;
60  }
61 
62 #ifdef COUNT
63  std::cerr << "GFRaveVertex::GFRaveVertex(...) - Number of objects: " << ++instCount << std::endl;
64 #endif
65 }
66 
67 
69  TObject(vertex),
70  pos_(vertex.pos_),
71  cov_(vertex.cov_),
72  ndf_(vertex.ndf_),
73  chi2_(vertex.chi2_),
74  id_(vertex.id_)
75 {
76  unsigned int nPar = vertex.smoothedTracks_.size();
77  smoothedTracks_.reserve(nPar);
78  for (unsigned int i=0; i<nPar; ++i) {
79  smoothedTracks_.push_back(new GFRaveTrackParameters(*(vertex.smoothedTracks_[i])));
80  }
81 
82 #ifdef COUNT
83  std::cerr << "GFRaveVertex::GFRaveVertex(GFRaveVertex) - Number of objects: " << ++instCount << std::endl;
84 #endif
85 }
86 
87 
89  swap(other);
90  return *this;
91 }
92 
93 
95  std::swap(this->pos_, other.pos_);
96  this->cov_.ResizeTo(other.cov_);
97  std::swap(this->cov_, other.cov_);
98  std::swap(this->ndf_, other.ndf_);
99  std::swap(this->chi2_, other.chi2_);
100  std::swap(this->id_, other.id_);
102 }
103 
104 
106  unsigned int nPar = smoothedTracks_.size();
107  for (unsigned int i=0; i<nPar; ++i) {
108  delete smoothedTracks_[i];
109  }
110 
111 #ifdef COUNT
112  std::cerr << "GFRaveVertex::~GFRaveVertex() - Number of objects: " << --instCount << std::endl;
113 #endif
114 }
115 
116 
117 void
118 GFRaveVertex::Print(const Option_t*) const {
119  std::cout << "GFRaveVertex\n";
120  std::cout << "Position: "; getPos().Print();
121  std::cout << "Covariance: "; getCov().Print();
122  std::cout << "Ndf: " << getNdf() << ", Chi2: " << getChi2() << ", Id: " << getId() << "\n";
123  std::cout << "Number of tracks: " << getNTracks() << "\n";
124  for (unsigned int i=0; i<getNTracks(); ++i) {
125  std::cout << " track " << i << ":\n"; getParameters(i)->Print();
126  }
127 }
128 
129 } /* End of namespace genfit */
130