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 #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; // verbosity has to be >1 for rave
0053 
0054   factory_ = new rave::VertexFactory(*magneticField_, *propagator_, "kalman-smoothing:1", verbosity); // here copies of magneticField_ and propagator_ are made!
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 } /* End of namespace genfit */