Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:26

0001 /* Copyright 2008-2010, Technische Universitaet Muenchen,
0002    Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
0003 
0004    This file is part of GENFIT.
0005 
0006    GENFIT is free software: you can redistribute it and/or modify
0007    it under the terms of the GNU Lesser General Public License as published
0008    by the Free Software Foundation, either version 3 of the License, or
0009    (at your option) any later version.
0010 
0011    GENFIT is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014    GNU Lesser General Public License for more details.
0015 
0016    You should have received a copy of the GNU Lesser General Public License
0017    along with GENFIT.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 
0020 
0021 #include "GFRaveVertex.h"
0022 #include "GFRaveConverters.h"
0023 #include <Exception.h>
0024 
0025 #include <iostream>
0026 
0027 namespace genfit {
0028 
0029 //#define COUNT
0030 
0031 #ifdef COUNT
0032 static int instCount(0);
0033 #endif
0034 
0035 GFRaveVertex::GFRaveVertex() :
0036   cov_(3,3),
0037   ndf_(0),
0038   chi2_(0),
0039   id_(-1)
0040 {
0041 #ifdef COUNT
0042   std::cerr << "GFRaveVertex::GFRaveVertex() - Number of objects: " << ++instCount << std::endl;
0043 #endif
0044 }
0045 
0046 
0047 GFRaveVertex::GFRaveVertex(const TVector3 & pos, const TMatrixDSym& cov,
0048                            const std::vector < GFRaveTrackParameters* > & smoothedTracks,
0049                            double ndf, double chi2, int id) :
0050   pos_(pos),
0051   cov_(cov),
0052   ndf_(ndf),
0053   chi2_(chi2),
0054   id_(id),
0055   smoothedTracks_(smoothedTracks)
0056 {
0057   if (cov_.GetNrows()!=3 || cov_.GetNcols()!=3) {
0058     Exception exc("GFRaveVertex ==> Covariance is not 3x3!",__LINE__,__FILE__);
0059     throw exc;
0060   }
0061 
0062 #ifdef COUNT
0063   std::cerr << "GFRaveVertex::GFRaveVertex(...) - Number of objects: " << ++instCount << std::endl;
0064 #endif
0065 }
0066 
0067 
0068 GFRaveVertex::GFRaveVertex(const GFRaveVertex & vertex) :
0069   TObject(vertex),
0070   pos_(vertex.pos_),
0071   cov_(vertex.cov_),
0072   ndf_(vertex.ndf_),
0073   chi2_(vertex.chi2_),
0074   id_(vertex.id_)
0075 {
0076   unsigned int nPar =  vertex.smoothedTracks_.size();
0077   smoothedTracks_.reserve(nPar);
0078   for (unsigned int i=0; i<nPar; ++i) {
0079     smoothedTracks_.push_back(new GFRaveTrackParameters(*(vertex.smoothedTracks_[i])));
0080   }
0081 
0082 #ifdef COUNT
0083   std::cerr << "GFRaveVertex::GFRaveVertex(GFRaveVertex) - Number of objects: " << ++instCount << std::endl;
0084 #endif
0085 }
0086 
0087 
0088 GFRaveVertex& GFRaveVertex::operator=(GFRaveVertex other) {
0089   swap(other);
0090   return *this;
0091 }
0092 
0093 
0094 void GFRaveVertex::swap(GFRaveVertex& other) {
0095   std::swap(this->pos_, other.pos_);
0096   this->cov_.ResizeTo(other.cov_);
0097   std::swap(this->cov_, other.cov_);
0098   std::swap(this->ndf_, other.ndf_);
0099   std::swap(this->chi2_, other.chi2_);
0100   std::swap(this->id_, other.id_);
0101   std::swap(this->smoothedTracks_, other.smoothedTracks_);
0102 }
0103 
0104 
0105 GFRaveVertex::~GFRaveVertex(){
0106   unsigned int nPar =  smoothedTracks_.size();
0107   for (unsigned int i=0; i<nPar; ++i) {
0108     delete smoothedTracks_[i];
0109   }
0110 
0111 #ifdef COUNT
0112   std::cerr << "GFRaveVertex::~GFRaveVertex() - Number of objects: " << --instCount << std::endl;
0113 #endif
0114 }
0115 
0116 
0117 void
0118 GFRaveVertex::Print(const Option_t*) const {
0119   std::cout << "GFRaveVertex\n";
0120   std::cout << "Position: "; getPos().Print();
0121   std::cout << "Covariance: "; getCov().Print();
0122   std::cout << "Ndf: " << getNdf() << ", Chi2: " << getChi2() << ", Id: " << getId() << "\n";
0123   std::cout << "Number of tracks: " << getNTracks() << "\n";
0124   for (unsigned int i=0;  i<getNTracks(); ++i) {
0125     std::cout << " track " << i << ":\n"; getParameters(i)->Print();
0126   }
0127 }
0128 
0129 } /* End of namespace genfit */
0130