Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:34

0001 /** \file
0002  *
0003  *  \author G. Ortona - Torino
0004  */
0005 
0006 #include "ParabolicParametrizedMagneticField.h"
0007 #include <FWCore/ParameterSet/interface/ParameterSet.h>
0008 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0009 
0010 using namespace std;
0011 
0012 // Default parameters are the best fit of 3.8T to the OAEParametrizedMagneticField parametrization.
0013 ParabolicParametrizedMagneticField::ParabolicParametrizedMagneticField()
0014     : c1(3.8114), b0(-3.94991e-06), b1(7.53701e-06), a(2.43878e-11) {
0015   setNominalValue();
0016 }
0017 
0018 ParabolicParametrizedMagneticField::ParabolicParametrizedMagneticField(const vector<double>& parameters)
0019     : c1(parameters[0]), b0(parameters[1]), b1(parameters[2]), a(parameters[3]) {
0020   setNominalValue();
0021 }
0022 
0023 ParabolicParametrizedMagneticField::~ParabolicParametrizedMagneticField() {}
0024 
0025 GlobalVector ParabolicParametrizedMagneticField::inTesla(const GlobalPoint& gp) const {
0026   if (isDefined(gp)) {
0027     return inTeslaUnchecked(gp);
0028   } else {
0029     LogDebug("MagneticField|FieldOutsideValidity")
0030         << " Point " << gp << " is outside the validity region of ParabolicParametrizedMagneticField";
0031     return GlobalVector();
0032   }
0033 }
0034 
0035 GlobalVector ParabolicParametrizedMagneticField::inTeslaUnchecked(const GlobalPoint& gp) const {
0036   return GlobalVector(0, 0, B0Z(gp.z()) * Kr(gp.perp2()));
0037 }
0038 
0039 inline float ParabolicParametrizedMagneticField::B0Z(const float z) const { return b0 * z * z + b1 * z + c1; }
0040 
0041 inline float ParabolicParametrizedMagneticField::Kr(const float R2) const { return a * R2 + 1.; }
0042 
0043 inline bool ParabolicParametrizedMagneticField::isDefined(const GlobalPoint& gp) const {
0044   return (gp.perp2() < (13225.f) && fabs(gp.z()) < 280.f);
0045 }