SND@LHC Software
Loading...
Searching...
No Matches
ShipBellField.cxx
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- ShipBellField source file -----
3// -------------------------------------------------------------------------
4#include "ShipBellField.h"
5#include "math.h"
6#include "ShipFieldPar.h"
7
8#include <iomanip>
9#include <iostream>
10
11using std::cout;
12using std::cerr;
13using std::endl;
14using std::setw;
15
16Double_t kilogauss = 1.;
17Double_t tesla = 10*kilogauss;
18
19Double_t cm = 1; // cm
20Double_t m = 100*cm; // m
21Double_t mm = 0.1*cm; // mm
22
23
24// ----- Default constructor -------------------------------------------
26 : FairField(),
27 fPeak(0.),
28 fMiddle(0.),
29 fBtube(0.)
30{
31 fType = 1;
32 fInclTarget=kFALSE;
33}
34// -------------------------------------------------------------------------
35
36
37
38// ----- Standard constructor ------------------------------------------
39ShipBellField::ShipBellField(const char* name, Double_t Peak,Double_t Middle,Int_t orientation, Double_t Btube )
40 : FairField(name),
41 fPeak(Peak),
42 fMiddle(Middle),
43 fBtube(Btube)
44{
45 fType=1;
46 fInclTarget=kFALSE;
47 fOrient = orientation;
48 fBtube = Btube;
49}
50// -------------------------------------------------------------------------
51
52
53
54// -------- Bell constructor from FieldPar -------------------------------
56 : FairField(),
57 fPeak(0.),
58 fMiddle(0.),
59 fBtube(0.),
60 fInclTarget(kFALSE)
61{
62 if ( ! fieldPar ) {
63 cerr << "-W- ShipBellField::ShipBellField: empty parameter container!"
64 << endl;
65 fType=0;
66 }
67 else {
68 fPeak = fieldPar->GetPeak();
69 fMiddle = fieldPar->GetMiddle();
70 fBtube = fieldPar->GetBtube();
71 fType = fieldPar->GetType();
72 }
73}
74// -------------------------------------------------------------------------
75
76
77
78// ----- Destructor ----------------------------------------------------
80// -------------------------------------------------------------------------
81
82// ----- Get x component of field --------------------------------------
83void ShipBellField::IncludeTarget(Double_t xy, Double_t z, Double_t l) {
84 fInclTarget = kTRUE;
85 targetXY = xy;
86 targetZ0 = z;
87 targetL = l;
88}
89// ----- Get x component of field --------------------------------------
90Double_t ShipBellField::GetBx(Double_t x, Double_t y, Double_t z) {
91 if (fOrient==1){ return 0.;}
92 else {
93 Double_t zlocal=fabs(z-fMiddle)/100.; //zlocal: convert cm->m
94 //old Bell field from Wilfried Flegel
95 //Double_t bx= fPeak/(1.+pow(fabs(zlocal)/2.1,6.));
96 //new field based on simulation of Davide Tommasini (22/1/2015)
97
98 Double_t bx=0.;
99 //field in box 20 cm larger than inner tube.
100 if ( (fabs(x)<2.7*m) && (fabs(y)<fBtube+0.2*m)) {
101 if (zlocal<3.8) {
102 bx=0.14361*exp( -0.5 * pow((zlocal-0.45479E-01)/2.5046,2.));
103 }else if (zlocal<11.9) {
104 bx=0.19532-0.61512E-01*zlocal+0.68447E-02*pow(zlocal,2.)-0.25672E-03*pow(zlocal,3.);
105 }
106 bx=((fPeak/tesla)/0.14361)*bx*tesla;
107 }
108 // cout << "Bell GetBX " << x << ", " << y << ", " << z << ", Bx= " << bx << endl;
109 return bx;
110 }
111}
112
113// -------------------------------------------------------------------------
114
115
116// ----- Get y component of field --------------------------------------
117Double_t ShipBellField::GetBy(Double_t x, Double_t y, Double_t z) {
118 Double_t by = 0.;
119 if (fInclTarget && z < targetZ0+targetL && z > targetZ0){
120 // check if in target area
121 if (fabs(x)<targetXY && fabs(y)<targetXY) {by = 1*tesla;}
122 if (fabs(x)>2*targetXY && fabs(x)<3*targetXY && fabs(y)<targetXY) {by = -1*tesla;}
123 }
124 else if (fOrient==1){
125 Double_t zlocal=(z-fMiddle)/100.;
126 by= fPeak/(1.+pow(fabs(zlocal)/2.1,6.));
127 //cout << "Bell GetBY " << z << ", By= " << by << endl;
128 }
129 return by;
130
131}
132// -------------------------------------------------------------------------
133
134
135
136// ----- Get z component of field --------------------------------------
137Double_t ShipBellField::GetBz(Double_t x, Double_t y, Double_t z) {
138 return 0.;
139}
140// -------------------------------------------------------------------------
141
142
143
144// ----- Screen output -------------------------------------------------
146 cout << "======================================================" << endl;
147 cout << "---- " << fTitle << " : " << fName << endl;
148 cout << "----" << endl;
149 cout << "---- Field type : constant" << endl;
150 cout << "----" << endl;
151 cout << "---- Field regions : " << endl;
152 cout.precision(4);
153 cout << "======================================================" << endl;
154}
155// -------------------------------------------------------------------------
156
157
158
160
161
Double_t tesla
Double_t cm
Double_t m
Double_t kilogauss
Double_t mm
virtual Double_t GetBy(Double_t x, Double_t y, Double_t z)
Double_t targetL
Double_t targetZ0
virtual Double_t GetBx(Double_t x, Double_t y, Double_t z)
virtual void Print()
void IncludeTarget(Double_t xy, Double_t z, Double_t l)
Double_t targetXY
virtual ~ShipBellField()
virtual Double_t GetBz(Double_t x, Double_t y, Double_t z)
Double_t fMiddle
Double_t fBtube
Double_t GetMiddle() const
Double_t GetPeak() const
Int_t GetType() const
Double_t GetBtube() const
ClassImp(ecalContFact) ecalContFact