Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FieldMapsLaplace.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FieldMapsLaplace.cxx
1 #include "FieldMapsLaplace.h"
2 #include "LaplaceSolution.h"
3 #include <string>
4 #include <iostream>
5 #include "TH3F.h"
6 #include "TAxis.h"
7 #include "TFile.h"
8 #include "TMath.h"
9 
10 
11 //=====================
13  const float prec=1e-8;
14 
15  //------------
16  //STEER
17  if(fDebug>0) printf("FieldMaps is being computed from Laplace solutions... \n");
18  LaplaceSolution *laplace_green_solution;
19  if(0) {
20  laplace_green_solution = new LaplaceSolution(fLSNameRoot);
21  } else {
22  laplace_green_solution = new LaplaceSolution(fInnerRadius/100/*[m]*/,fOutterRadius/100/*[m]*/,fHalfLength/100/*[m]*/);
23  }
24  int brprimeINI=0;
25  int brprimeEND=fNRadialSteps;
26  if(fRadialBin>-0.5) {
27  brprimeINI = fRadialBin;
28  brprimeEND = fRadialBin+1;
29  }
30  // constructing volume element
34  float dV = dr*dphi*dz;
35 
36  float e0 = 8.854187817e+1; //[fC]/[V.cm]
37  // looping over volume
38  for(int br=0; br!=fNRadialSteps; ++br) {
39  float r = fEr->GetXaxis()->GetBinCenter( br+1 ); //[cm]
40  if(fDebug>0) printf("FieldMaps: %.2f -> 1\n",float(br)/fNRadialSteps);
41  for(int bp=0; bp!=fNAzimuthalSteps; ++bp) {
42  float phi = fEr->GetYaxis()->GetBinCenter( bp+1 ); //[rad]
43  for(int bz=0; bz!=fNLongitudinalSteps; ++bz) {
44  float z = fEr->GetZaxis()->GetBinCenter( bz+1 ); //[cm]
45  //std::cout << " z :" << z << std::endl;
46  if(fDebug>1) printf("FieldMaps: Integral( dvprime Q(rprime) G_E(rprime,[%f,%f,%f]) )",r,phi,z);
47  float intEr = 0, intEp = 0, intEz = 0;
48  if(fMirrorZ) if(z>0) continue;
49  //std::cout << " z :" << z << std::endl;
50  // looping over volume prime
51  for(int bzprime=0; bzprime!=fNLongitudinalSteps; ++bzprime) {
52  float zprime = fEr->GetZaxis()->GetBinCenter( bzprime+1 ); //[cm]
53  //std::cout << " z*z' :" << z*zprime << std::endl;
54  if(z*zprime < 0) continue; // only integrates same side along Z
55  //std::cout << " z :"<< z << " z' :" << zprime << " z*z' :" << z*zprime << std::endl;
56  for(int brprime=brprimeINI; brprime!=brprimeEND; ++brprime) {
57  float rprime = fEr->GetXaxis()->GetBinCenter( brprime+1 ); //[cm]
58  for(int bphiprime=0; bphiprime!=fNAzimuthalSteps; ++bphiprime) {
59  float phiprime = fEr->GetYaxis()->GetBinCenter( bphiprime+1 );
60  //float phiprime = fEr->GetYaxis()->GetBinCenter(1);
61  float charge = ReadCharge(rprime,phiprime,zprime,dr,dphi,dz); // fC
62  if(TMath::AreEqualAbs( charge, 0, prec )) continue;
63  float GR = laplace_green_solution->Er(r/100,phi,TMath::Abs(z)/100, rprime/100, phiprime, TMath::Abs(zprime)/100); // GRad
64  float GP = 0;//laplace_green_solution->Ephi(r/100,phi,TMath::Abs(z)/100, rprime/100, phi, TMath::Abs(zprime)/100); // GPhi
65  float GZ = laplace_green_solution->Ez(r/100,phi,TMath::Abs(z)/100, rprime/100, phiprime, TMath::Abs(zprime)/100); // GPhi
66  if(!TMath::AreEqualAbs( GR, 0, prec )) intEr += GR*charge; // [fC/m^2]
67  //std::cout << " z :"<< z << " z' :" << zprime << " GR :" << GR << " q :" << charge <<" intEr :" << intEr<< std::endl;
68  if(!TMath::AreEqualAbs( GP, 0, prec )) intEp += GP*charge; // [fC/m^2]
69  if(!TMath::AreEqualAbs( GZ, 0, prec )) intEz += GZ*charge; // [fC/m^2]
70  }//loop over phi'
71  }// loop over r'
72  }//loop over z'
73  if(fDebug>1) printf(" => Er=%f ( similar for Ep=%f, Ez=%f )\n",intEr,intEp,intEz);
74  float toVperCM = 0.155*1e-4/e0;
75  fEr->Fill(r,phi,z,intEr*toVperCM); //[V/cm]
76  fEp->Fill(r,phi,z,intEp*toVperCM); //[V/cm]
77  fEz->Fill(r,phi,z,intEz*toVperCM); //[V/cm]
78  } // loop over z
79  } // loop over phi
80  } //loop over r
81  if(fDebug>0) printf("[DONE]\n");
82  //------------
83 }