11 #include "SaveCanvas.C"
13 void DrawFieldMap(
const TString sfield_map =
"/phenix/upgrades/decadal/fieldmaps/fsPHENIX.2d.root")
16 gROOT->LoadMacro(
"sPhenixStyle.C");
19 TFile *
_file0 = TFile::Open(sfield_map);
20 TTree *fieldmap = (TTree *) _file0->GetObjectChecked(
"fieldmap",
"TTree");
22 TH2F *hfield =
new TH2F(
"hfield",
"hfield", 480 / 2, -30, 450, 280 / 2, 0, 280);
23 TH2F *hbendingfield = hfield->Clone(
"hbendingfield");
25 fieldmap->SetAlias(
"perb_angle",
"atan2(r,z) + pi/2");
26 fieldmap->SetAlias(
"bendingfield",
"br*cos(perb_angle) + bz*sin(perb_angle)");
28 fieldmap->Draw(
"r:z>>hfield",
"sqrt(br**2 + bz**2)",
"goff");
29 fieldmap->Draw(
"r:z>>hbendingfield",
"bendingfield",
"goff");
31 TCanvas *c1 =
new TCanvas(TString(
"DrawFieldMap_hfield_") + gSystem->BaseName(sfield_map),
32 TString(
"DrawFieldMap_hfield_") + gSystem->BaseName(sfield_map), 1800,
37 p = (TPad *) c1->cd(idx++);
40 p->SetRightMargin(0.2);
42 hfield->GetZaxis()->SetRangeUser(0., 2.5);
43 hfield->SetTitle(
"#it{#bf{sPHENIX}} Field Map;z [cm];R [cm];Field strength [T]");
44 hfield->GetYaxis()->SetTitleOffset(0.9);
55 TBox *
b =
new TBox(2.91750 * 100, 0.1 * 100, 3.2 * 100, 1.82655 * 100);
58 b->SetLineColor(kGray);
70 TBox *b =
new TBox(3.5 * 100, 0.05 * 100, 4.5 * 100, 2.62 * 100);
73 b->SetLineColor(kGray);
86 TLine *l =
new TLine(1.2 * 100, 0.1 * 100, 1.2 * 100, 0.8 * 100);
87 l->SetLineColor(kGray);
90 TLine *l =
new TLine(1.5 * 100, 0.1 * 100, 1.5 * 100, 1 * 100);
91 l->SetLineColor(kGray);
94 TLine *l =
new TLine(2.7 * 100, 0.1 * 100, 2.7 * 100, 0.8 * 100);
95 l->SetLineColor(kGray);
98 TLine *l =
new TLine(2.7 * 100, 0.8 * 100, 2.5 * 100, 1.3 * 100);
99 l->SetLineColor(kGray);
103 TBox *b =
new TBox(-30, 0.02 * 100, 100, 78);
106 b->SetLineColor(kGray);
110 SaveCanvas(c1, TString(c1->GetName()), kTRUE);
112 c1->Print(TString(c1->GetName()) +
".eps");
131 const int n_data = fieldmap->Draw(
"r:z:br:bz",
"",
"goff");
133 string file_name =
string(c1->GetName()) +
".data";
136 for (
int i = 0;
i < n_data; ++
i)
138 foutput << (fieldmap->GetV1())[
i] <<
"\t";
139 foutput << (fieldmap->GetV2())[
i] <<
"\t";
140 foutput << (fieldmap->GetV3())[
i] <<
"\t";
141 foutput << (fieldmap->GetV4())[
i] <<
"\n";
146 TFile *_file1 = TFile::Open(TString(
"ReverseBr_") + gSystem->BaseName(sfield_map),
"recreate");
148 TNtuple *ReverseBr_fieldmap =
149 new TNtuple(
"fieldmap",
150 "Field Map for fsPHENIX with corrected Br",
153 for (
int i = 0;
i < n_data; ++
i)
155 ReverseBr_fieldmap->Fill((fieldmap->GetV2())[
i], (fieldmap->GetV1())[
i], (fieldmap->GetV4())[
i], -(fieldmap->GetV3())[
i]);
157 ReverseBr_fieldmap->Write();