File indexing completed on 2025-08-05 08:18:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <string>
0021
0022 #include "GFRaveVertexFactory.h"
0023 #include "GFRaveConverters.h"
0024 #include "GFRaveVertex.h"
0025
0026 #include "GFRaveMagneticField.h"
0027 #include "GFRavePropagator.h"
0028
0029 #include "Exception.h"
0030
0031 #include "rave/Propagator.h"
0032 #include "rave/MagneticField.h"
0033 #include "rave/VertexFactory.h"
0034 #include "rave/Vertex.h"
0035 #include "rave/Ellipsoid3D.h"
0036
0037
0038 namespace genfit {
0039
0040 GFRaveVertexFactory::GFRaveVertexFactory(int verbosity, bool useVacuumPropagator) {
0041
0042 if (useVacuumPropagator) {
0043 propagator_ = new rave::VacuumPropagator();
0044 }
0045 else {
0046 propagator_ = new GFRavePropagator();
0047 (static_cast<GFRavePropagator*>(propagator_))->setIdGFTrackStateMap(&IdGFTrackStateMap_);
0048 }
0049
0050 magneticField_ = new GFRaveMagneticField();
0051
0052 if (verbosity > 0) ++verbosity;
0053
0054 factory_ = new rave::VertexFactory(*magneticField_, *propagator_, "kalman-smoothing:1", verbosity);
0055 }
0056
0057
0058 GFRaveVertexFactory::~GFRaveVertexFactory(){
0059 clearMap();
0060 delete magneticField_;
0061 delete propagator_;
0062 delete factory_;
0063 }
0064
0065
0066 void
0067 GFRaveVertexFactory::findVertices ( std::vector < genfit::GFRaveVertex* > * GFvertices,
0068 const std::vector < genfit::Track* > & GFTracks,
0069 bool use_beamspot ){
0070
0071 clearMap();
0072
0073 try{
0074 RaveToGFVertices(GFvertices,
0075 factory_->create(GFTracksToTracks(GFTracks, nullptr, IdGFTrackStateMap_, 0),
0076 use_beamspot),
0077 IdGFTrackStateMap_);
0078 }
0079 catch(Exception & e){
0080 clearMap();
0081 std::cerr << e.what();
0082 }
0083
0084 clearMap();
0085 }
0086
0087
0088 void
0089 GFRaveVertexFactory::findVertices ( std::vector < genfit::GFRaveVertex* > * GFvertices,
0090 const std::vector < genfit::Track* > & GFTracks,
0091 std::vector < genfit::MeasuredStateOnPlane* > & GFStates,
0092 bool use_beamspot ){
0093
0094 clearMap();
0095
0096 try{
0097 RaveToGFVertices(GFvertices,
0098 factory_->create(GFTracksToTracks(GFTracks, &GFStates, IdGFTrackStateMap_, 0),
0099 use_beamspot),
0100 IdGFTrackStateMap_);
0101 }
0102 catch(Exception & e){
0103 clearMap();
0104 std::cerr << e.what();
0105 }
0106
0107 clearMap();
0108 }
0109
0110
0111 void
0112 GFRaveVertexFactory::setBeamspot(const TVector3 & pos, const TMatrixDSym & cov){
0113 factory_->setBeamSpot(rave::Ellipsoid3D(TVector3ToPoint3D(pos),
0114 TMatrixDSymToCovariance3D(cov)));
0115 }
0116
0117
0118 void
0119 GFRaveVertexFactory::setMethod(const std::string & method){
0120 size_t found = method.find("smoothing:1");
0121 if (found==std::string::npos){
0122 std::cerr << "GFRaveVertexFactory::setMethod(" << method << ") ==> smoothing not turned on! GFRaveTrackParameters will be unsmoothed!" << std::endl;
0123 }
0124 factory_->setDefaultMethod(method);
0125 std::cout << "GFRaveVertexFactory::setMethod ==> set method to " << factory_->method() << std::endl;
0126 }
0127
0128
0129 void
0130 GFRaveVertexFactory::clearMap() {
0131
0132 for (unsigned int i=0; i<IdGFTrackStateMap_.size(); ++i)
0133 delete IdGFTrackStateMap_[i].state_;
0134
0135 IdGFTrackStateMap_.clear();
0136 }
0137
0138
0139 }