Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:59

0001 /*!
0002  *  \file       Tools.cc
0003  *  \brief      tools
0004  *  \author     Haiwang Yu <yuhw@nmsu.edu>
0005  */
0006 
0007 // GenFit
0008 #include <GenFit/AbsTrackRep.h>           // for AbsTrackRep
0009 #include <GenFit/Exception.h>             // for Exception
0010 #include <GenFit/MeasuredStateOnPlane.h>  // for MeasuredStateOnPlane
0011 #include <GenFit/RKTrackRep.h>
0012 
0013 #include <TVector3.h>  // for TVector3
0014 
0015 // STL
0016 #include <cassert>   // for assert
0017 #include <iostream>  // for operator<<, basic_ostream
0018 #include <limits>
0019 
0020 #define LogDebug(exp) std::cout << "DEBUG: " << __FILE__ << ": " << __LINE__ << ": " << (exp) << std::endl
0021 #define LogError(exp) std::cout << "ERROR: " << __FILE__ << ": " << __LINE__ << ": " << (exp) << std::endl
0022 #define LogWarning(exp) std::cout << "WARNING: " << __FILE__ << ": " << __LINE__ << ": " << (exp) << std::endl
0023 
0024 //#define _DEBUG_
0025 
0026 namespace PHGenFit
0027 {
0028   double extrapolateToCylinder(
0029       genfit::MeasuredStateOnPlane* state,
0030       double radius, const TVector3& line_point, const TVector3& line_direction,
0031       const int pdg_code, const int direction,
0032       const int verbosity)
0033   {
0034     assert(direction == 1 or direction == -1);
0035 
0036     assert(state);
0037 
0038     double pathlenth = std::numeric_limits<double>::quiet_NaN();
0039 
0040     genfit::AbsTrackRep* rep = new genfit::RKTrackRep(pdg_code);
0041     assert(rep);
0042 
0043     state->setRep(rep);
0044 
0045     try
0046     {
0047       pathlenth = rep->extrapolateToCylinder(*state, radius, line_point, line_direction);
0048     }
0049     catch (genfit::Exception& e)
0050     {
0051       if (verbosity > 1)
0052       {
0053         LogWarning("Can't extrapolate track!");
0054         std::cerr << e.what();
0055       }
0056       return pathlenth;
0057     }
0058 
0059     return pathlenth;
0060   }
0061 
0062 }  // namespace PHGenFit