EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GFRaveVertexFactory.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GFRaveVertexFactory.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 #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  clearMap();
60  delete magneticField_;
61  delete propagator_;
62  delete factory_;
63 }
64 
65 
66 void
67 GFRaveVertexFactory::findVertices ( std::vector < genfit::GFRaveVertex* > * GFvertices,
68  const std::vector < genfit::Track* > & GFTracks,
69  bool use_beamspot ){
70 
71  clearMap();
72 
73  try{
74  RaveToGFVertices(GFvertices,
75  factory_->create(GFTracksToTracks(GFTracks, nullptr, IdGFTrackStateMap_, 0),
76  use_beamspot),
78  }
79  catch(Exception & e){
80  clearMap();
81  std::cerr << e.what();
82  }
83 
84  clearMap();
85 }
86 
87 
88 void
89 GFRaveVertexFactory::findVertices ( std::vector < genfit::GFRaveVertex* > * GFvertices,
90  const std::vector < genfit::Track* > & GFTracks,
91  std::vector < genfit::MeasuredStateOnPlane* > & GFStates,
92  bool use_beamspot ){
93 
94  clearMap();
95 
96  try{
97  RaveToGFVertices(GFvertices,
98  factory_->create(GFTracksToTracks(GFTracks, &GFStates, IdGFTrackStateMap_, 0),
99  use_beamspot),
101  }
102  catch(Exception & e){
103  clearMap();
104  std::cerr << e.what();
105  }
106 
107  clearMap();
108 }
109 
110 
111 void
112 GFRaveVertexFactory::setBeamspot(const TVector3 & pos, const TMatrixDSym & cov){
113  factory_->setBeamSpot(rave::Ellipsoid3D(TVector3ToPoint3D(pos),
115 }
116 
117 
118 void
119 GFRaveVertexFactory::setMethod(const std::string & method){
120  size_t found = method.find("smoothing:1");
121  if (found==std::string::npos){
122  std::cerr << "GFRaveVertexFactory::setMethod(" << method << ") ==> smoothing not turned on! GFRaveTrackParameters will be unsmoothed!" << std::endl;
123  }
124  factory_->setDefaultMethod(method);
125  std::cout << "GFRaveVertexFactory::setMethod ==> set method to " << factory_->method() << std::endl;
126 }
127 
128 
129 void
131 
132  for (unsigned int i=0; i<IdGFTrackStateMap_.size(); ++i)
133  delete IdGFTrackStateMap_[i].state_;
134 
135  IdGFTrackStateMap_.clear();
136 }
137 
138 
139 } /* End of namespace genfit */