EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
viewer.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file viewer.C
1 
2 void viewer(const char *fname, double minR = 0.0, double maxR = 400.0,
3  double minZ = -450.0, double maxZ = 450.0, unsigned cvX = 1200,
4  unsigned cvY = 1200, bool plotBz = true, bool plotBr = false,
5  bool plotBm = true)
6 {
7  gStyle->SetOptStat(0);
8 
9  auto bmf = new BeastMagneticField(fname);
10 
11  if (bmf->ValidMapImported()) {
12  bool plot[3] = {plotBz, plotBr, plotBm};
13  unsigned divY = plotBz + plotBr + plotBm;
14  auto cv = new TCanvas("cv", "", 0, 0, cvX, cvY); cv->Divide(1,divY);
15 
16  unsigned dimR = 200, dimZ = 600;
17  double cellR = (maxR - minR)/dimR, cellZ = (maxZ - minZ)/dimZ;
18 
19  auto hbr = new TH2D("hbr", "R-component", dimZ, minZ, maxZ, dimR, minR, maxR);
20  auto hbz = new TH2D("hbz", "Z-component", dimZ, minZ, maxZ, dimR, minR, maxR);
21  auto hbm = new TH2D("hbm", "SQRT(BR^2+BZ^2)", dimZ, minZ, maxZ, dimR, minR, maxR);
22  TH2D *hh[3] = {hbz, hbr, hbm};
23 
24  for(unsigned ir=0; ir<dimR; ir++)
25  for(unsigned iz=0; iz<dimZ; iz++) {
26  double br, bz;
27  bmf->GetFieldValue(minR + cellR*(ir + 0.5), minZ + cellZ*(iz + 0.5), br, bz);
28 
29  hbz->SetBinContent(iz+1, ir+1, bz);
30  hbr->SetBinContent(iz+1, ir+1, br);
31  hbm->SetBinContent(iz+1, ir+1, sqrt(bz*bz+br*br));
32  } //for ir..iz
33 
34  {
35  unsigned iYcurrent = 1;
36 
37  for(unsigned iy=0; iy<3; iy++)
38  if (plot[iy]) {
39  cv->cd(iYcurrent++);
40  hh[iy]->Draw("COLZ");
41  }
42  }
43  } else
44  printf("\n Was not able to import the field map!\n");
45 } // viewer()