Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Langevin.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Langevin.cxx
1 #include "Langevin.h"
2 #include <string>
3 
4 #include "TH3F.h"
5 #include "TFile.h"
6 #include "TMath.h"
7 
8 //=====================
10  fDebug = 0;
11  fEr = NULL;
12  fEp = NULL;
13  fEz = NULL;
14  fDeltaR = NULL;
15  fRDeltaPHI = NULL;
16  fInnerRadius=1.;
17  fOutterRadius=2.;
18  fHalfLength=1.;
19  fNRadialSteps=1;
22  fFileNameRoot="rho";
23 }
24 //=====================
26 }
27 //=====================
29  InitMaps();
30 
31  //------------
32  //STEER
33  if(fEr==NULL) {
34  printf("Input fields not found. A B O R T I N G\n");
35  return;
36  }
37  if(fDebug>0) printf("Langevin solutions are being computed... \n");
38 
39  const float prec=1e-8;
40  const float kE0 = 400; //V/cm
41  //const float kB0 = 5; //kGauss ALICE / STAR
42  const float kB0 = 15; //kGauss PHENIX
43  //Langevin gas parameters
44  // P9 gas
45  //const float kT1 = 1.34; //NIM Phys Res A235,296 (1985)
46  //const float kT2 = 1.11; //NIM Phys Res A235,296 (1985)
47  // P10 gas
48  //const float kT1 = 1.36; //measured by STAR
49  //const float kT2 = 1.11; //measured by STAR
50  // 85.7%Ne / 9.5%CO2 / 4.5%N2
51  const float kT1 = 1.0; // measured by ALICE
52  const float kT2 = 1.0; // measured by ALICE
53  const float kV0 = 4.0; // [cm/us] @ E=400V/cm (need fine tunning)
54  float wt = -10*kB0*kV0/kE0; //[kGauss] * [cm/us] / [V/cm] //0.32 != -10*5*4/400
55  float c0 = 1.0/(1.0+kT2*kT2*wt*wt);
56  float c1 = kT1*wt/(1.0+kT1*kT1*wt*wt);
57  float c2 = kT2*kT2*wt*wt*c0;
58  if(fDebug>1) printf("wt = %f \n",wt);
59  if(fDebug>1) printf("c0 = %f \n",c0);
60  if(fDebug>1) printf("c1 = %f \n",c1);
61  if(fDebug>1) printf("c2 = %f \n",c2);
62  float dz = fEz->GetZaxis()->GetBinWidth(1);
63  for(int r=0; r!=fNRadialSteps; ++r)
64  for(int p=0; p!=fNAzimuthalSteps; ++p)
65  for(int z=0; z!=fNLongitudinalSteps; ++z) {
66  float intDR = 0, intRDPHI = 0;
67  // integrating over drift ditance
68  int minZ = 0;
69  int maxZ = z+1;
70  if( fEz->GetZaxis()->GetBinCenter(z+1)>0 ) {
71  minZ=z;
73  }
74  for(int zprime=minZ; zprime!=maxZ; ++zprime) {
75  float dR, RdPHI;
76  float dEz = fEz->GetBinContent( r+1, p+1, z+1 ) + kE0;
77  dR = c0*fEr->GetBinContent( r+1, p+1, zprime+1 )/dEz;
78  dR += c1*fEp->GetBinContent( r+1, p+1, zprime+1 )/dEz;
79  RdPHI = -c1*fEr->GetBinContent( r+1, p+1, zprime+1 )/dEz;
80  RdPHI += c0*fEp->GetBinContent( r+1, p+1, zprime+1 )/dEz;
81  if(!TMath::AreEqualAbs( dR, 0, prec )) intDR += dR*dz;
82  if(!TMath::AreEqualAbs( RdPHI, 0, prec )) intRDPHI += RdPHI*dz;
83  }
84  fDeltaR->SetBinContent( r+1, p+1, z+1, intDR );
85  fRDeltaPHI->SetBinContent( r+1, p+1, z+1, intRDPHI );
86  if(fDebug>2) printf("@{Ir,Ip,Iz}={%d,%d,%d}, deltaR=%f\n",r,p,z,intDR);
87  if(fDebug>2) printf("@{Ir,Ip,Iz}={%d,%d,%d}, RdeltaPHI=%f\n",r,p,z,intRDPHI);
88  }
89  if(fDebug>0) printf("[DONE]\n");
90  //------------
91 
92  SaveMaps();
93 }
94 //=====================
96  const char *inputfile = Form("%s_1.root",fFileNameRoot.data());
97  if(fDebug>0) printf("Langevin is reading the input file %s... ",inputfile);
98  TFile *ifile = new TFile(inputfile);
99  fEr = (TH3F*) ifile->Get("Er");
100  fEp = (TH3F*) ifile->Get("Ep");
101  fEz = (TH3F*) ifile->Get("Ez");
102  if(fDebug>0) printf("[DONE]\n");
103 }
104 //=====================
106  ReadFile();
107  if(fDebug>0) printf("Langevin is initializing distortion maps... ");
108  fDeltaR = new TH3F("mapDeltaR","#delta_{R} [cm];Radial [cm];Azimuthal [rad];Longitudinal [cm]",
112  fRDeltaPHI = new TH3F("mapRDeltaPHI","R#delta_{#varphi} [cm];Radial [cm];Azimuthal [rad];Longitudinal [cm]",
116  if(fDebug>0) printf("[DONE]\n");
117 }
118 //=====================
120  const char *outputfile= Form("%s_2.root",fFileNameRoot.data());
121  if(fDebug>0) printf("Langevin saving distortion maps... ");
122  TFile *ofile = new TFile(outputfile,"RECREATE");
123  ofile->WriteObject(fDeltaR,"mapDeltaR");
124  ofile->WriteObject(fRDeltaPHI,"mapRDeltaPHI");
125  ofile->Close();
126  if(fDebug>0) printf("[DONE]\n");
127 }