Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:30

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 "HelixTrackModel.h"
0021 #include <FieldManager.h>
0022 
0023 #include <assert.h>
0024 #include <math.h>
0025 
0026 namespace genfit {
0027 
0028 HelixTrackModel::HelixTrackModel(const TVector3& pos, const TVector3& mom, double charge) {
0029 
0030   mom_ = mom.Mag();
0031 
0032   TVector3 B = genfit::FieldManager::getInstance()->getFieldVal(pos);
0033 
0034   // B must point in Z direction
0035   assert(B.X() == 0);
0036   assert(B.Y() == 0);
0037 
0038   double Bz = B.Z();
0039 
0040   // calc helix parameters
0041   TVector3 dir2D(mom);
0042   dir2D.SetZ(0);
0043   dir2D.SetMag(1.);
0044   R_ = 100.*mom.Perp()/(0.0299792458*Bz) / fabs(charge);
0045   sgn_ = 1;
0046   if (charge<0) sgn_=-1.;
0047   center_ = pos + sgn_ * R_ * dir2D.Orthogonal();
0048   alpha0_ = (pos-center_).Phi();
0049 
0050   theta_ = mom.Theta();
0051 
0052   //std::cout<<"radius " << R_ << "  center ";
0053   //center_.Print();
0054 
0055 }
0056 
0057 
0058 TVector3 HelixTrackModel::getPos(double tracklength) const {
0059 
0060   TVector3 pos;
0061 
0062   double angle = alpha0_ - sgn_ * tracklength / R_ * sin(theta_);
0063 
0064   TVector3 radius(R_,0,0);
0065   radius.SetPhi(angle);
0066   pos = center_ + radius;
0067   pos.SetZ(center_.Z() - sgn_ * ((alpha0_-angle)*R_ * tan(theta_-M_PI/2.)) );
0068 
0069   return pos;
0070 }
0071 
0072 void HelixTrackModel::getPosMom(double tracklength, TVector3& pos, TVector3& mom) const {
0073 
0074   double angle = alpha0_ - sgn_ * tracklength / R_ * sin(theta_);
0075 
0076   TVector3 radius(R_,0,0);
0077   radius.SetPhi(angle);
0078   pos = center_ + radius;
0079   pos.SetZ(center_.Z() - sgn_ * ((alpha0_-angle)*R_ * tan(theta_-M_PI/2.)) );
0080 
0081   mom.SetXYZ(1,1,1);
0082   mom.SetTheta(theta_);
0083   mom.SetPhi(angle - sgn_*M_PI/2.);
0084   mom.SetMag(mom_);
0085 
0086   /*std::cout<<"tracklength " << tracklength << "\n";
0087   std::cout<<"angle " << angle << "\n";
0088   std::cout<<"radius vector "; radius.Print();
0089   std::cout<<"pos "; pos.Print();
0090   std::cout<<"mom "; mom.Print();*/
0091 
0092 }
0093 
0094 
0095 } /* End of namespace genfit */