1111//
1212// Author: J. E. Munoz Mendez jesus.munoz@cern.ch
1313
14+ #include <functional>
15+ #include <cmath>
16+ #include <TCanvas.h>
17+ #include <TH2F.h>
18+ #include <TStyle.h>
19+
1420std ::function < void (const double * , double * )> field ()
1521{
1622 return [](const double * x , double * b ) {
17- double Rc ;
18- double R1 ;
19- double R2 ;
20- const double B1 = 0.5 ; // [T]
21- double B2 ;
22- const double beamStart = 500. ; // [cm]
23- static constexpr double tokGauss = 1. / 0.1 ; // conversion from Tesla to kGauss
23+ // RADIUS
24+ static constexpr double Rc = 170. ; // [cm] — R_out_coil per Ian DetectorConstruction.cc; confirmed by A. Ortiz definition
25+ static constexpr double R1 = 220. ; // [cm]
26+ static constexpr double R2 = 290. ; // [cm]
2427
25- bool isMagAbs = true;
28+ // FIELD
29+ static constexpr double B1 = 2. ; // [T]
30+ // static constexpr double B2 = -B1 * Rc * Rc / (R2 * R2 - R1 * R1); // [T] — B1 in numerator, confirmed by A. Ortiz Aug 2026
31+ static constexpr double B2 = - Rc * Rc / ((R2 * R2 - R1 * R1 ) * B1 ); //[T]
32+ static constexpr double beamStart = 500. ; // [cm]
33+ static constexpr double tokGauss = 1. / 0.1 ; // conversion from Tesla to kGauss
2634
27- // ***********************
28- // LAYOUT 1
29- // ***********************
30-
31- // RADIUS
32- Rc = 170. ; //[cm] — R_out_coil per Ian DetectorConstruction.cc; confirmed by A. Ortiz definition
33- R1 = 220. ; //[cm]
34- R2 = 290. ; //[cm]
35+ static constexpr bool isMagAbs = true;
3536
3637 // To set the B2
37- B2 = - B1 * Rc * Rc / (R2 * R2 - R1 * R1 ); //[T] — B1 in numerator, confirmed by A. Ortiz Aug 2026
3838
39- if ((abs (x [2 ]) <= beamStart ) && (sqrt (x [0 ] * x [0 ] + x [1 ] * x [1 ]) < Rc )) {
39+ if ((std :: abs (x [2 ]) <= beamStart ) && (sqrt (x [0 ] * x [0 ] + x [1 ] * x [1 ]) < Rc )) {
4040 b [0 ] = 0. ;
4141 b [1 ] = 0. ;
4242 b [2 ] = B1 * tokGauss ;
43- } else if ((abs (x [2 ]) <= beamStart ) &&
43+ } else if ((std :: abs (x [2 ]) <= beamStart ) &&
4444 (sqrt (x [0 ] * x [0 ] + x [1 ] * x [1 ]) >= Rc &&
4545 sqrt (x [0 ] * x [0 ] + x [1 ] * x [1 ]) < R1 )) {
4646 b [0 ] = 0. ;
4747 b [1 ] = 0. ;
4848 b [2 ] = 0. ;
49- } else if ((abs (x [2 ]) <= beamStart ) &&
49+ } else if ((std :: abs (x [2 ]) <= beamStart ) &&
5050 (sqrt (x [0 ] * x [0 ] + x [1 ] * x [1 ]) >= R1 &&
5151 sqrt (x [0 ] * x [0 ] + x [1 ] * x [1 ]) < R2 )) {
5252 b [0 ] = 0. ;
@@ -66,6 +66,9 @@ std::function<void(const double*, double*)> field()
6666
6767void ALICE3Field ()
6868{
69+ gStyle -> SetPalette (kRainBow );
70+ gStyle -> SetNumberContours (255 );
71+
6972 auto fieldFunc = field ();
7073 // RZ plane visualization
7174 TCanvas * cRZ = new TCanvas ("cRZ" , "Field in RZ plane" , 800 , 800 );
@@ -83,6 +86,7 @@ void ALICE3Field()
8386 }
8487 }
8588
89+ hRZ -> GetZaxis ()-> SetRangeUser (-30 , 30 );
8690 hRZ -> Draw ("COLZ" );
8791 cRZ -> Update ();
8892
@@ -103,6 +107,7 @@ void ALICE3Field()
103107 }
104108 }
105109
110+ hXY -> GetZaxis ()-> SetRangeUser (-30 , 30 );
106111 hXY -> Draw ("COLZ" );
107112 cXY -> Update ();
108113}
0 commit comments