Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:51

0001 #include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
0002 #include "MagneticField/Engine/interface/MagneticField.h"
0003 #include "FWCore/Utilities/interface/Likely.h"
0004 
0005 GlobalTrajectoryParameters::GlobalTrajectoryParameters(const GlobalPoint& aX,
0006                                                        const GlobalVector& direction,
0007                                                        float transverseCurvature,
0008                                                        int,
0009                                                        const MagneticField* fieldProvider)
0010     : theField(fieldProvider), theX(aX) {
0011   cachedMagneticField = theField->inTesla(theX);
0012   float bza = -2.99792458e-3f * cachedMagneticField.z();
0013   float qbpi = bza / (direction.perp() * transverseCurvature);
0014   theP = direction * std::abs(qbpi);
0015   theCharge = qbpi > 0.f ? 1 : -1;
0016 }
0017 
0018 GlobalTrajectoryParameters::GlobalTrajectoryParameters(const GlobalPoint& aX,
0019                                                        const GlobalVector& direction,
0020                                                        float transverseCurvature,
0021                                                        int,
0022                                                        const MagneticField* fieldProvider,
0023                                                        GlobalVector fieldValue)
0024     : theField(fieldProvider), theX(aX), cachedMagneticField(fieldValue) {
0025   float bza = -2.99792458e-3f * cachedMagneticField.z();
0026   float qbpi = bza / (direction.perp() * transverseCurvature);
0027   theP = direction * std::abs(qbpi);
0028   theCharge = qbpi > 0.f ? 1 : -1;
0029 }
0030 
0031 void GlobalTrajectoryParameters::setCache() {
0032   cachedMagneticField = theField ? theField->inTesla(theX) : GlobalVector(0, 0, 0);
0033 }  // we must initialize cache to non-NAN to avoid FPE
0034 
0035 GlobalVector GlobalTrajectoryParameters::magneticFieldInInverseGeV(const GlobalPoint& x) const {
0036   return 2.99792458e-3f * theField->inTesla(x);
0037 }
0038 
0039 /*  the field is different as it is attached to each given volume!!!!
0040 // const MagneticField* GlobalTrajectoryParameters::theField=0;
0041 #include<iostream>
0042 // FIXME debug code mostly
0043 void GlobalTrajectoryParameters::setMF(const MagneticField* fieldProvider) {
0044   if (0==fieldProvider) return;
0045   if (0!=theField && fieldProvider!=theField)
0046     std::cout << "GlobalTrajectoryParameters: a different MF???? " 
0047           << theField << " " << fieldProvider << std::endl;
0048   theField =fieldProvider;
0049 }
0050 */