8 #include "G4VPhysicalVolume.hh" 10 #include "G4TransportationManager.hh" 13 #include "Randomize.hh" 21 fCoordinateSet(false),
24 fZShiftDrawingCoordinate(-1.0e13),
25 fZShiftUpstrWorldToLocal(-1.0e13),
27 fHornNeckOuterRadius(-1.0e13),
28 fHornNeckInnerRadius(-1.0e13),
30 fOuterRadiusEff(1.0e9),
31 fSkinDepth(4.1*
CLHEP::mm),
32 fSkinDepthInnerRad(1.0e10*
CLHEP::mm)
66 "Horn1PolyM1",
"LBNEMagneticField::LBNEMagneticField");
70 const double zCDFirstRing = 0.544*zCDNeckStart;
104 const double epsil = 0.050*CLHEP::mm;
105 for (
size_t k=0;
k != nPts;
k++) {
126 "Horn2TopLevel",
"LBNEMagneticField::LBNEMagneticField");
182 "Horn2Hall",
"LBNEMagneticField::LBNEMagneticField");
185 std::cerr <<
" Magnetic field coordinate definition done. fZShiftUpstrWorldToLocal " <<
219 theSurvey->
GetPoint(G4String(upstrStr + leftStr + ballStr + hornIndexStr));
221 theSurvey->
GetPoint(G4String(upstrStr + rightStr + ballStr + hornIndexStr));
223 theSurvey->
GetPoint(G4String(downstrStr + leftStr + ballStr + hornIndexStr));
225 theSurvey->
GetPoint(G4String(downstrStr + rightStr + ballStr + hornIndexStr));
226 const G4ThreeVector pUpLeft = itUpLeft->GetPosition();
227 const G4ThreeVector pUpRight = itUpRight->GetPosition();
228 const G4ThreeVector pDwLeft = itDwLeft->GetPosition();
229 const G4ThreeVector pDwRight = itDwRight->GetPosition();
231 for (
size_t k=0;
k!=2;
k++) {
232 fShift[
k] = -0.50*(pUpLeft[
k] + pUpRight[
k]);
238 if (
amHorn1) std::cerr <<
" Horn1 ";
239 else std::cerr <<
" Horn2 ";
240 std::cerr <<
" is misaligned " 272 for (
size_t k=0;
k!=3; ++
k) Bfield[
k] = 0.;
306 std::vector<double> ptTrans(2,0.);
308 for (
size_t k=0;
k != 2;
k++)
310 const double r = std::sqrt(ptTrans[0]*ptTrans[0] + ptTrans[1]*ptTrans[1]);
312 if ( r < 1.0e-3)
return;
314 double magBField = current / (5.*r/CLHEP::cm)/10*CLHEP::tesla;
319 const double attLength = std::exp(-dr/
fSkinDepth);
320 magBField *= attLength;
324 if (
std::abs(radIC) > 1.0e6)
return;
330 if (zLocD >
fZDCEnd[k])
continue;
345 if ((radIC < 1.0e-3) || (radOC < 1.0e-3)) {
346 std::ostringstream mStrStr;
347 mStrStr <<
" Wrong equation index at Z " << Point[2] <<
std::endl;
348 G4String mStr(mStrStr.str());
349 G4Exception(
"LBNEMagneticFieldHorn::GetFieldValue",
" ", FatalErrorInArgument, mStr.c_str());
359 if (r < radIC)
return;
371 if ((r > radIC) && (r < radOC)) {
372 const double surfCyl = radOC*radOC - radIC*radIC;
373 const double deltaRSq = (r*r - radIC*radIC);
374 const double factR = deltaRSq/surfCyl;
385 Bfield[0] = -magBField*ptTrans[1]/
r;
386 Bfield[1] = magBField*ptTrans[0]/
r;
392 std::vector<double> bFieldLocal(3);
393 for(
size_t k=0;
k != 3;
k++) { bFieldLocal[
k] = Bfield[
k]; Bfield[
k] = 0.; }
394 for (
size_t k1=0; k1 !=3; k1++) {
416 std::ofstream fOut(fName.c_str());
418 double zStart = -500.;
423 if (!
amHorn1) { zStart = 6000.; zEnd = 11000.; }
424 const int numZStep = 100;
425 const int numRStep= 2000;
426 const double zStep = (zEnd-zStart)/numZStep;
427 const double rStep = rMax/numRStep;
429 for (
int iZ=0; iZ !=numZStep; iZ++) {
430 double z = zStart + iZ*zStep;
446 double r =
std::max(0., (radIC - 5.*CLHEP::mm));
449 const double phi = 2.0*M_PI*G4RandFlat::shoot();
450 point[0] = r*std::cos(phi);
451 point[1] = r*std::sin(phi);
454 fOut <<
" " << z <<
" " << zLocD <<
" " << r <<
" " 455 << std::sqrt(bf[0]*bf[0] + bf[1]*bf[1])/CLHEP::tesla <<
std::endl;
456 if (r < (radIC + 5.0*CLHEP::mm)) r += 0.1*CLHEP::mm;
466 fOutTraj <<
" " << pRunManager->GetCurrentEvent()->GetEventID();
467 for (
size_t k=0;
k!= 3;
k++)
fOutTraj <<
" " << Point[
k];
468 fOutTraj <<
" " << bx/CLHEP::tesla <<
" " <<
" " << by/CLHEP::tesla <<
std::endl;
473 std::cerr <<
" Closing Output Trajectory file in LBNEMagneticFieldHorn " <<
std::endl;
480 isToroid(isToroidal),
490 for (
size_t k=0;
k!=3; ++
k) Bfield[
k] = 0.;
494 const double r = std::sqrt(Point[0]*Point[0] + Point[1]*Point[1]);
497 double magBField = current / (5.*r/CLHEP::cm)/10*CLHEP::tesla;
498 Bfield[0] = -magBField*Point[1]/
r;
499 Bfield[1] = magBField*Point[0]/
r;
double GetHorn1OuterTubeOuterRad() const
double getNormCurrDensityInnerC(double deltaR, double rOut) const
double GetHorn2ZEqnChange(size_t k) const
double GetHorn1EffectiveLength() const
const LBNEVolumePlacementData * Find(const G4String &name, const char *motherName, const char *method) const
G4double fZShiftDrawingCoordinate
std::vector< LBNESurveyedPt >::const_iterator GetPoint(const std::string &aName) const
static LBNEVolumePlacements * Instance()
double GetHorn1RMinAllBG() const
double GetHorn2DeltaZEntranceToZOrigin() const
G4double fEffectiveLength
bool GetUseHorn1Polycone() const
virtual void GetFieldValue(const double Point[3], double *Bfield) const
std::vector< size_t > fEqnIndicesInner
std::vector< double > fRadsInnerC
G4double fHornNeckOuterRadius
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::vector< double > fZDCBegin
double GetHornParabolicRZCoord(size_t iH, size_t k) const
LBNEMagneticFieldDecayPipe(bool isToroidal)
virtual void GetFieldValue(const double Point[3], double *Bfield) const
G4RotationMatrix fRotation
double GetHorn1NeckInnerRadius() const
double GetHorn1LongRescale() const
double GetHorn2OuterTubeOuterRad() const
std::vector< double > fParams
static LBNESurveyor * Instance()
double GetHorn2NeckInnerRadius() const
std::vector< double > fShift
double GetHorn1ZEndIC() const
double GetHorn1PolyInnerConductorThickness(size_t numPts) const
static int max(int a, int b)
G4double fSkinDepthInnerRad
double fEffectiveInnerRad
bool IsHornPnParabolic(size_t numHorn) const
double GetHorn1NeckOuterRadius() const
double fEffectiveOuterRad
std::vector< double > fZDCEnd
double GetConductorRadiusHorn2(double zD, size_t eqn) const
double GetHorn1NeckZPosition() const
double GetHorn1PolyInnerConductorRadius(size_t numPts) const
G4double fHornNeckInnerRadius
double GetHorn2LongRescale() const
std::vector< double > fShiftSlope
double GetHorn1PolyInnerConductorZCoord(size_t numPts) const
double GetHornParabolicThick(size_t iH, size_t k) const
G4RotationMatrix fRotMatrixHornContainer
double GetHorn1NeckLength() const
void fillHorn1PolygonRadii(double z, double *rIn, double *rOut) const
std::vector< double > fRadsOuterC
double GetConductorRadiusHorn1(double zD, size_t eqn) const
LBNEMagneticFieldHorn(bool isHorn1)
double GetHornParabolicRIn(size_t iH, size_t k) const
std::vector< size_t > fEqnIndicesOuter
void fillTrajectories(const double Point[3], double bx, double by) const
int GetNumberOfHornsPolycone() const
G4double fZShiftUpstrWorldToLocal
double GetHorn1ZDEndNeckRegion() const
double fEffectiveSkinDepthFact
size_t GetHornParabolicNumInnerPts(size_t iH) const
double GetHorn2LongPosition() const
int GetUseHorn1PolyNumInnerPts() const
double GetHorn1RMaxAllBG() const
QTextStream & endl(QTextStream &s)
bool IsHorn1RadiusBigEnough() const
double GetHorn2NeckOuterRadius() const