ATLAS Offline Software
Loading...
Searching...
No Matches
DipoleBender.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "FPTracker/Point.h"
9#include <cmath>
10#include <cassert>
11#include <iostream>
12
13namespace FPTracker{
15 Bendplane bendplane,
16 double magnetLength,
17 double magnetStrength,
18 double pbeam0,
19 int side
20 ):
21 m_bendplane(bendplane),
22 m_length(magnetLength),
24 m_pbeam0(pbeam0),
25 m_dside(side==0 ? -1.:1.){
26 }
27
29 IBender::ConstPtr_t ib(new DipoleBender(*this));
30 return ib;
31 }
32
33 void DipoleBender::bend(IParticle& particle) const {
34
35 // -- DIPOLE MAGNET
36 // tandir is in x,y,z bearing in mind the sign of z/
37 // But the magnet strength is stored as its effect on dx/ds or dy/ds.
38 // bend = magnet strength, corrected for momentum, = bend for this proton.
39 // dzc = length of magnet, signed
40 // position[i] = New displ. = old + effect of gradient + effect of bend.
41 // position[i-1] = old displacement + effect of gradient in non-bending plane.
42
43 // calculates new x, y coordinates and direction after deflection
44
45 Point& position = particle.position();
46 Point& direction = particle.direction();
47
48 double tandir = direction[m_bendplane]/direction[2] ;
49 double bend = m_strength*m_pbeam0/particle.momentum();
50 double dzc = m_length*m_dside;
51
52 //std::cout<<"dir [2] from DipoleBender "<<direction[2]<<'\n';
53
54 position[m_bendplane] += dzc*tandir +(dzc/m_dside)*std::tan(0.5*bend) ;
55 position[1-m_bendplane] += dzc*direction[1-m_bendplane]/direction[2];
56 direction[m_bendplane] = (tandir*m_dside +std::tan(bend))/(1.-m_dside*tandir*std::tan(bend)); //update part. angles
57 direction[m_bendplane] = direction[m_bendplane]/std::sqrt(1. + direction[m_bendplane]*direction[m_bendplane]) ;
58
59 // tan(new angle) = tan(sum of orig. angle + angle of bend)
60 // Then we turn it into the sine, e.g. dx/ds (perhaps unncessarily)
61
62 // If main bending magnet, the local coord system must be redefined.
63 // Rotate wrt the local lab coords if necessary, and return to lab frame.
64 // The main bends are curved, so we must do this before evaluating the aperture.
65 if(m_length > 10.){ // Identifies MB magnet.
66 direction[0] -= m_strength; // Rotates the coords.
67 position[0] -= 0.5*m_strength*m_length;
68 // Shifts coord system laterally.
69 }
70
71 }
72
73 const std::string DipoleBender::s_label = "DiplBender";
74 std::string DipoleBender::label() const {return s_label;}
75}
static const std::string s_label
void bend(IParticle &) const
std::shared_ptr< IBender > clone() const
std::string label() const
DipoleBender(Bendplane, double length, double strength, double pbeam0, int side)
std::shared_ptr< IBender > ConstPtr_t
double magnetStrength(int type, double length, double strength, double Brho)