GENFIT  Rev:NoNumberAvailable
GFRaveVertexFactory.cc
Go to the documentation of this file.
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 #include <string>
21 
22 #include "GFRaveVertexFactory.h"
23 #include "GFRaveConverters.h"
24 #include "GFRaveVertex.h"
25 
26 #include "GFRaveMagneticField.h"
27 #include "GFRavePropagator.h"
28 
29 #include "Exception.h"
30 
31 #include "rave/Propagator.h"
32 #include "rave/MagneticField.h"
33 #include "rave/VertexFactory.h"
34 #include "rave/Vertex.h"
35 #include "rave/Ellipsoid3D.h"
36 
37 
38 namespace genfit {
39 
40 GFRaveVertexFactory::GFRaveVertexFactory(int verbosity, bool useVacuumPropagator) {
41 
42  if (useVacuumPropagator) {
43  propagator_ = new rave::VacuumPropagator();
44  }
45  else {
47  (static_cast<GFRavePropagator*>(propagator_))->setIdGFTrackStateMap(&IdGFTrackStateMap_);
48  }
49 
51 
52  if (verbosity > 0) ++verbosity; // verbosity has to be >1 for rave
53 
54  factory_ = new rave::VertexFactory(*magneticField_, *propagator_, "kalman-smoothing:1", verbosity); // here copies of magneticField_ and propagator_ are made!
55 }
56 
57 
59  delete magneticField_;
60  delete propagator_;
61  delete factory_;
62 }
63 
64 
65 void
66 GFRaveVertexFactory::findVertices ( std::vector < genfit::GFRaveVertex* > * GFvertices,
67  const std::vector < genfit::Track* > & GFTracks,
68  bool use_beamspot ){
69 
70  clearMap();
71 
72  try{
73  RaveToGFVertices(GFvertices,
74  factory_->create(GFTracksToTracks(GFTracks, NULL, IdGFTrackStateMap_, 0),
75  use_beamspot),
77  }
78  catch(Exception & e){
79  std::cerr << e.what();
80  }
81 
82 }
83 
84 
85 void
86 GFRaveVertexFactory::findVertices ( std::vector < genfit::GFRaveVertex* > * GFvertices,
87  const std::vector < genfit::Track* > & GFTracks,
88  std::vector < genfit::MeasuredStateOnPlane* > & GFStates,
89  bool use_beamspot ){
90 
91  clearMap();
92 
93  try{
94  RaveToGFVertices(GFvertices,
95  factory_->create(GFTracksToTracks(GFTracks, &GFStates, IdGFTrackStateMap_, 0),
96  use_beamspot),
98  }
99  catch(Exception & e){
100  std::cerr << e.what();
101  }
102 
103 }
104 
105 
106 void
107 GFRaveVertexFactory::setBeamspot(const TVector3 & pos, const TMatrixDSym & cov){
108  factory_->setBeamSpot(rave::Ellipsoid3D(TVector3ToPoint3D(pos),
110 }
111 
112 
113 void
114 GFRaveVertexFactory::setMethod(const std::string & method){
115  size_t found = method.find("smoothing:1");
116  if (found==std::string::npos){
117  std::cerr << "GFRaveVertexFactory::setMethod(" << method << ") ==> smoothing not turned on! GFRaveTrackParameters will be unsmoothed!" << std::endl;
118  }
119  factory_->setDefaultMethod(method);
120  std::cout << "GFRaveVertexFactory::setMethod ==> set method to " << factory_->method() << std::endl;
121 }
122 
123 
124 void
126 
127  for (unsigned int i=0; i<IdGFTrackStateMap_.size(); ++i)
128  delete IdGFTrackStateMap_[i].state_;
129 
130  IdGFTrackStateMap_.clear();
131 }
132 
133 
134 } /* End of namespace genfit */
genfit::GFRaveVertexFactory::clearMap
void clearMap()
Definition: GFRaveVertexFactory.cc:125
genfit::RaveToGFVertices
void RaveToGFVertices(std::vector< GFRaveVertex * > *GFVertices, const std::vector< rave::Vertex > &raveVertices, const std::map< int, genfit::trackAndState > &IdGFTrackStateMap)
Definition: GFRaveConverters.cc:210
genfit::GFRaveVertexFactory::factory_
rave::VertexFactory * factory_
Definition: GFRaveVertexFactory.h:89
genfit::Exception
Exception class for error handling in GENFIT (provides storage for diagnostic information)
Definition: Exception.h:48
genfit
Defines for I/O streams used for error and debug printing.
Definition: AbsFinitePlane.cc:22
genfit::GFRaveVertexFactory::~GFRaveVertexFactory
~GFRaveVertexFactory()
Definition: GFRaveVertexFactory.cc:58
genfit::TVector3ToPoint3D
rave::Point3D TVector3ToPoint3D(const TVector3 &vec)
Definition: GFRaveConverters.cc:329
genfit::GFTracksToTracks
std::vector< rave::Track > GFTracksToTracks(const std::vector< genfit::Track * > &GFTracks, std::vector< genfit::MeasuredStateOnPlane * > *GFStates, std::map< int, genfit::trackAndState > &IdGFTrackStateMap, int startID)
Definition: GFRaveConverters.cc:36
GFRaveMagneticField.h
GFRaveVertex.h
genfit::Exception::what
virtual const char * what() const
Standard error message handling for exceptions. use like "std::cerr << e.what();".
Definition: Exception.cc:52
genfit::GFRaveMagneticField
GFRaveMagneticField class Uses the FieldManager to provide a magnetic field to rave.
Definition: GFRaveMagneticField.h:40
genfit::GFRavePropagator
GFRavePropagator class.
Definition: GFRavePropagator.h:55
genfit::TMatrixDSymToCovariance3D
rave::Covariance3D TMatrixDSymToCovariance3D(const TMatrixDSym &matrix)
Definition: GFRaveConverters.cc:335
GFRaveVertexFactory.h
genfit::GFRaveVertexFactory::setBeamspot
void setBeamspot(const TVector3 &pos, const TMatrixDSym &cov)
Definition: GFRaveVertexFactory.cc:107
genfit::GFRaveVertexFactory::IdGFTrackStateMap_
std::map< int, genfit::trackAndState > IdGFTrackStateMap_
Definition: GFRaveVertexFactory.h:88
genfit::GFRaveVertexFactory::findVertices
void findVertices(std::vector< genfit::GFRaveVertex * > *, const std::vector< genfit::Track * > &, bool use_beamspot=false)
Definition: GFRaveVertexFactory.cc:66
genfit::GFRaveVertexFactory::setMethod
void setMethod(const std::string &method)
Definition: GFRaveVertexFactory.cc:114
GFRavePropagator.h
GFRaveConverters.h
Exception.h
genfit::GFRaveVertexFactory::magneticField_
rave::MagneticField * magneticField_
Definition: GFRaveVertexFactory.h:90
genfit::GFRaveVertexFactory::GFRaveVertexFactory
GFRaveVertexFactory(int verbosity=0, bool useVacuumPropagator=false)
Definition: GFRaveVertexFactory.cc:40
genfit::GFRaveVertexFactory::propagator_
rave::Propagator * propagator_
Definition: GFRaveVertexFactory.h:91