00001
00002
00003
00004
00005
00006 #include <TRandom3.h>
00007 #include <TH2.h>
00008 #include <TF1.h>
00009 #include <TVector2.h>
00010
00011
00012 #include "StFgtSlowSimuMaker.h"
00013 #include "HexLatice.h"
00014
00015
00016
00017
00018 void
00019 StFgtSlowSimuMaker::initFrankModel(TString fname){
00020 memset(meLossTab,0,sizeof(meLossTab));
00021
00022 LOG_INFO<<"::initFrankModel() load:"<<fname<< endm;
00023 FILE *fd=fopen(fname,"r");
00024 assert(fd);
00025
00026 const int mx=1000;
00027 char buf[mx];
00028
00029 for (int i = 0; i <eLossDim ; i++) {
00030 char * ret=fgets(buf,mx,fd);
00031 assert(ret);
00032
00033 float cl1, cl2, cl3, cl4, cl5, cl6, cl7;
00034 int ret1=sscanf(buf,"%f %f %f %f %f %f %f ",&cl1, &cl2, &cl3, &cl4, &cl5, &cl6, &cl7);
00035 assert(ret1==7);
00036 meLossTab[i] = cl4;
00037 }
00038 LOG_INFO<<"::initFrankModel() OK"<<endm;
00039
00040 }
00041
00042
00043
00044
00045
00046
00047
00048 void
00049 StFgtSlowSimuMaker::responseFrankModel(TVector3 Rloc, TVector3 Dloc){
00050 static const double dPi=4*acos(0.);
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 double par_pairsPerCm = 40.;
00064 double zLocEnd=Rloc.z()+Dloc.z();
00065 double pathLength=Dloc.Mag();
00066 TVector3 rv=Dloc; rv=rv.Unit();
00067 double rvT=rv.Perp();
00068
00069
00070 double totalEnergy_eV = 0;
00071 double path = 0;
00072 int nPrimPair = 0;
00073 int nTotPair = 0;
00074
00075 double sum1=0,sum2=0;
00076 while (1) {
00077
00078 double stepLength = - TMath::Log(mRnd->Uniform()) / par_pairsPerCm;
00079 path += stepLength;
00080 if (path > pathLength) break;
00081 nPrimPair++;
00082
00083 int rndBin = ((int) (10000.0 * mRnd->Uniform()));
00084
00085 if(rndBin > par_cutoffOfBichel) rndBin = par_cutoffOfBichel;
00086 double eL_eV = meLossTab[rndBin];
00087 int nAnyPair = 1 + ((int) ((eL_eV-15.4)/26.));
00088 totalEnergy_eV += eL_eV;
00089 if (nAnyPair < 0) continue;
00090
00091 TVector3 r=Rloc+ path*rv;
00092
00093 nTotPair+= nAnyPair;
00094
00095
00096 if(par_transDiffusionPerPath>0.001) {
00097 double zDrift=zLocEnd-r.z();
00098
00099
00100
00101
00102
00103
00104
00105
00106 if(zDrift < 0) zDrift *= -1.0;
00107
00108 double perpDiffRms=par_transDiffusionPerPath*sqrt(zDrift);
00109 double phi=mRnd->Uniform(dPi);
00110 double perp=mRnd->Gaus(0,perpDiffRms);
00111 TVector3 dR; dR.SetPtThetaPhi(perp,0.,phi);
00112 r+=dR;
00113
00114 hA[27]->Fill(zDrift*10);
00115 hA[28]->Fill( dR.x()*1e4, dR.y()*1e4);
00116 }
00117
00118
00119 if(hexLat) {
00120 TVector2 r2=r.XYvector(); int kU,kV;
00121 TVector2 r2s= hexLat->snap(r2,kU,kV);
00122 r.SetX(r2s.X()); r.SetY(r2s.Y());
00123 }
00124
00125 addHit(r,nAnyPair);
00126 hA[20]->Fill(eL_eV);
00127 sum1+=nAnyPair;
00128 sum2+=nAnyPair*path;
00129 }
00130 hA[21]->Fill(nPrimPair );
00131 hA[22]->Fill(totalEnergy_eV/ 1000.);
00132 hA[23]->Fill(nTotPair );
00133 hA[24]->Fill(path*10 );
00134 double meanPath=sum2/sum1;
00135 double meanTpath=meanPath*rvT;
00136
00137 hA[25]->Fill(meanPath*10);
00138 hA[26]->Fill(meanTpath*10);
00139 }
00140
00141
00142
00143
00144
00145
00146 void
00147 StFgtSlowSimuMaker::responseLinearModel(TVector3 r1, TVector3 Dloc){
00148
00149
00150
00151
00152 TVector3 rv=Dloc; rv.Unit();
00153
00154
00155
00156 int ns=1;
00157 double ddS=0;
00158 double amplS=10;
00159
00160
00161 int is;
00162 for(is=0;is<ns;is++) {
00163 TVector3 rLoc=r1+ (is+0.5)*ddS*rv;
00164
00165 addHit(rLoc,amplS);
00166 }
00167 }
00168
00169
00170
00171
00172
00173 void
00174 StFgtSlowSimuMaker::addHit(TVector3 rLoc, double ampl) {
00175 int par_binStep=6;
00176
00177
00178 float xH=fabs(rLoc.x());
00179 float yH=fabs(rLoc.y());
00180 assert(xH>0);
00181 assert(yH>0);
00182
00183
00184
00185 TAxis *axX=digXY->GetXaxis();
00186 int ixH=axX->FindFixBin(xH);
00187 int mxX=axX->GetNbins();
00188 int ix1=ixH-par_binStep,ix2=ixH+par_binStep;
00189 if(ix1<1) ix1=1;
00190 if(ix1>mxX) ix1=mxX;
00191
00192 TAxis *axY=digXY->GetYaxis();
00193 int iyH=axY->FindFixBin(yH);
00194 int mxY=axY->GetNbins();
00195 int iy1=iyH-par_binStep,iy2=iyH+par_binStep;
00196 if(iy1<1) iy1=1;
00197 if(iy1>mxY) iy1=mxY;
00198
00199
00200 float valMax=0;
00201 int ix,iy;
00202 for(ix=ix1;ix<=ix2;ix++) {
00203 float x=axX->GetBinCenter(ix);
00204 float val_x=amplF->Eval(x-xH);
00205
00206 for(iy=iy1;iy<=iy2;iy++) {
00207 float y=axY->GetBinCenter(iy);
00208 float val_y=amplF->Eval(y-yH);
00209 float val2D=ampl*val_x*val_y;
00210
00211 digXY->Fill(x,y,val2D);
00212 digXYAll->Fill(x,y,val2D);
00213 if(valMax<val2D) valMax=val2D;
00214 }
00215 }
00216
00217
00218
00219
00220 #if 0
00221 int iPhiID, iRadID;
00222 int iQuad=0;
00223 bool ok=geom->localXYtoStripID(iQuad,rLoc.x(),rLoc.y(),iRadID, iPhiID);
00224 if (!ok) return;
00225 hA[31]->Fill(iRadID);
00226 hA[32]->Fill(iPhiID);
00227 #endif
00228 }
00229
00230
00231
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243