LBNFMagneticFieldPolyconeHorn.hh
Go to the documentation of this file.
1 
2 // $Id: LBNEMagneticField.hh,v 1.2.2.8 2013/12/24 20:30:46 lebrun Exp $
3 // --------------------------------------------------------------
4 // LBNEMagneticField.hh modified by Yuki 2004/7/16
5 // modified by Yuki 8/2/04
6 #ifndef LBNFMagneticFieldPolyconeHorn_H
7 #define LBNFMagneticFieldPolyconeHorn_H 1
8 #include <fstream>
9 #include <vector>
10 #include <map>
11 
12 #include "globals.hh"
13 #include "G4MagneticField.hh"
14 #include "G4RotationMatrix.hh"
15 #include <fstream>
16 
17 class LBNFMagneticFieldPolyconeHorn : public G4MagneticField
18 {
19  public:
20  explicit LBNFMagneticFieldPolyconeHorn(size_t iH);
22 
23  virtual void GetFieldValue( const double Point[3], double *Bfield ) const;
24 
25  private:
26  size_t hornNumber; // from 0 to 4, as Horn1 magentic field is still serviced by LBNEMagneticField
27  G4double fHornCurrent;
28  // data specific for the Polyhorn, and the skin depth effect.
29  std::vector<double> fZDCBegin;
30  std::vector<double> fRadsInnerC;
31  std::vector<double> fRadsOuterC;
32  bool fHornIsMisaligned; // Then, we will rotate the field
33  G4RotationMatrix fRotMatrixHornContainer;
35  double fOuterRadius, fOuterRadiusEff; // Not sure we need both of them..
36  // Data for the World coordinate transform to the Horn coordinate system.
37  // We linearize the tranformation, leave Z unchanged, except for a translation.
38  G4double fSkinDepth;
40  G4double fSkinDepthIIRInv;
41  double fDeltaEccentricityIO; // March 2016: the delta parameter that set the eccentricity between the inner and Outer conductors
42  // See Note NuMI-B-471, Feb. 15 1999, page 31
43  double fDeltaEllipticityI; // March 2016: the delta parameter that set the ellipticity of the inner conductor
44  // See Note NuMI-B-471, Feb. 15 1999, page 33
45  double fCurrentEqualizerLongAbsLength; // the characteristic length at which the azimutal anisotropy decreases.
46  // Units: inverse mm. Default value: 100 mm
47 
48  double fCurrentEqualizerQuadAmpl; // Quadrupolar moment amplitude of the azimuthal anisotropy, at Z = zMax.
49  // unit: pure number Default value = 0.
50  double fCurrentEqualizerOctAmpl; // Octupole moment amplitude of the azimuthal anisotropy, at Z = zMax.
51  // unit: pure number Default value = 0.
52 
53  mutable std::ofstream fOutTraj;
54  //
55  // More variable for debugging and checking field values from the stepping Action
56  //
57  mutable bool fDebugIsOn;
58  mutable double fEffectiveInnerRad;
59  mutable double fEffectiveOuterRad; // of the inner conductor.
60  mutable double fEffectiveSkinDepthFact;
61  //
62  // For possible (albeit futuer, not implemented yet) misalignment studies.
63  //
64  std::vector<double> fShift;
65  std::vector<double> fShiftSlope;
66  mutable G4double fZShiftDrawingCoordinate; // same, might not be needed...
67 
69  mutable unsigned int fNumZPtsForCE;
70  mutable unsigned int fNumRPtsForCE;
71  mutable unsigned int fNumPhiPtsForCE;
72  // a simple Cartesian grid in Z, R square, and phi.
76 
77  mutable std::map<unsigned int, std::pair<float, float> > fField3DMapCurrentEqualizer;
78  mutable std::vector<double> fField3DMapCurrentEqualizerRadSqAtZ;
79  mutable std::vector<double> fField3DMapCurrentEqualizerRadSqRStepAtZ;
80  // In global coodinate system. ( but rotation and misalignment taken out. )
81  void getFieldFrom3DMapCurrentEqualizer(const double Point[3], double *Bfield) const;
82  // No skin depth effect using this map..
83  void fill3DMapCurrentEqualizer() const ; // pseudo const.
84 
85  inline void fillHornPolygonRadii(double z, double *rIn, double *rOut) const {
86  size_t kLow = 0;
87  size_t kHigh = fZDCBegin.size() - 1;
88  for (size_t k=0; k != fZDCBegin.size() - 1; k++) {
89  if ((z >= fZDCBegin[k]) && (z < fZDCBegin[k+1])) {
90  kLow = k;
91  kHigh = k+1;
92  const double dzFrac = (z - fZDCBegin[kLow])/(fZDCBegin[kHigh] - fZDCBegin[kLow]);
93  *rIn = fRadsInnerC[kLow] + dzFrac*(fRadsInnerC[kHigh] - fRadsInnerC[kLow]);
94  *rOut = fRadsOuterC[kLow] + dzFrac*(fRadsOuterC[kHigh] - fRadsOuterC[kLow]);
95 // if ((*rIn) < 160.) std::cerr << " .......... z " << z << " k " << k << " rIn " << (*rIn) << " rOut " << (*rOut) << std::endl;
96  return;
97  }
98  }
99  *rIn = 1.0e10;
100  *rOut = 2.0e10;
101  }
102 
103  void fillTrajectories(const double Point[3], double bx, double by) const;
104  //
105  // Implement the Skin depth for the Inner conductors.
106  // References: Zarko's Thesis (MINOS Document 5694-v1), section 5.2.4, p150 - 156)
107  // DeltaR : difference from the radial coordinate of the track and the inner radius of the inner conductor.
108  //
109  // Note: Approximate, because this reasoning is based on a cylindical (not tubular) conductor.
110  //
111  inline double getNormCurrDensityInnerC(double deltaR, double rOut) const {
112  if (deltaR < 0.) return 0.;
113  const double xby2 = fSkinDepthIIRInv*deltaR/2.; // x must be less < 1, otherwise Taylor expansion fails..
114  const double xby2Out = fSkinDepthIIRInv*rOut/2.; // x must be less < 1, otherwise Taylor expansion fails..
115  // keep only 3 terms..
116  const double ber = 1.0 - std::pow(xby2, 4.)/4. + std::pow(xby2, 8.)/576.;
117  const double bei = std::pow(xby2, 2.) - std::pow(xby2, 6.)/36 + std::pow(xby2, 10.)/14400.;
118  const double beNSq = ber*ber + bei*bei;
119  const double berOut = 1.0 - std::pow(xby2Out, 4.)/4. + std::pow(xby2Out, 8.)/576.;
120  const double beiOut = std::pow(xby2Out, 2.) - std::pow(xby2Out, 6.)/36 + std::pow(xby2Out, 10.)/14400.;
121  const double beNSqOut = berOut*berOut + beiOut*beiOut;
122  return std::sqrt(beNSq/beNSqOut);
123  }
124 
125  public:
126 
127  inline void SetHornCurrent(G4double ihorn) {fHornCurrent = ihorn;}
128  inline G4double GetHornCurrent() const { return fHornCurrent;}
129  inline void SetSkinDepthInnerRad(G4double f) {fSkinDepthInnerRad = f; fSkinDepthIIRInv= std::sqrt(2.0)/f;}
130  inline void SetZShiftDrawingCoordinate(double z) { fZShiftDrawingCoordinate = z;}
131  inline void SetEffectiveLength(double z) { fEffectiveLength = z;}
132  inline void SetDeltaEccentricityIO(G4double f) {fDeltaEccentricityIO = f;}
133  inline void SetDeltaEllipticityI(G4double f) {fDeltaEllipticityI = f;}
134  inline double GetEffectiveInnerRad() const { return fEffectiveInnerRad;}
135  inline double GetEffectiveOuterRad() const { return fEffectiveOuterRad;}
136  inline double GetEffectiveSkinDepthFact() const { return fEffectiveSkinDepthFact;}
137 
138  inline void SetCurrentEqualizerLongAbsLength(double v) {fCurrentEqualizerLongAbsLength = v;}
139  inline void SetCurrentEqualizerQuadAmpl(double v) {fCurrentEqualizerQuadAmpl = v;}
140  inline void SetCurrentEqualizerOctAmpl(double v) {fCurrentEqualizerOctAmpl = v;}
141  inline void SetFileNameFieldMapForCE(std::string s) { fFileNameFieldMapForCE = s;}
144 
145  void dumpField() const;
146  void TestDivergence(int opt) const;
147  void TestEccentricityBerkeley() const;
148  void writeFieldMapCurrentEqualizer() const;
149  void readFieldMapCurrentEqualizer() const; // not really, evidently..
150 };
151 
152 #endif
153 
std::vector< double > fField3DMapCurrentEqualizerRadSqRStepAtZ
void fillTrajectories(const double Point[3], double bx, double by) const
std::string string
Definition: nybbler.cc:12
opt
Definition: train.py:196
constexpr T pow(T x)
Definition: pow.h:72
void getFieldFrom3DMapCurrentEqualizer(const double Point[3], double *Bfield) const
virtual void GetFieldValue(const double Point[3], double *Bfield) const
double z
double getNormCurrDensityInnerC(double deltaR, double rOut) const
void fillHornPolygonRadii(double z, double *rIn, double *rOut) const
std::vector< double > fField3DMapCurrentEqualizerRadSqAtZ
std::map< unsigned int, std::pair< float, float > > fField3DMapCurrentEqualizer
static QCString * s
Definition: config.cpp:1042