StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtSlowSimu_response.cxx
1 // *-- Author : J.Balewski
2 //
3 // \date July 2007
4 // $Id: StFgtSlowSimu_response.cxx,v 1.1 2012/06/06 20:35:09 jeromel Exp $
5 
6 #include <TRandom3.h>
7 #include <TH2.h>
8 #include <TF1.h>
9 #include <TVector2.h>
10 
11 
12 #include "StFgtSlowSimuMaker.h"
13 
14 
15 #include "StFgtDbMaker/StFgtDbMaker.h"
16 
17 //--------------------------------------------
18 //--------------------------------------------
19 //--------------------------------------------
20 // http://drupal.star.bnl.gov/STAR/system/files/2001-F.Simon-diploma.pdf
21 // chapter 3. The GEM Concept
22 void
23 StFgtSlowSimuMaker::responseMipModel(TVector3 Rloc, TVector3 Dloc){
24 
25 
26  /* in order to simulate the energy loss for individual ionizing collisions a table from Bichsel is used.
27  This is given in figure 9 in NIM A562, 154 (2006)
28  This table gives the energy loss for a given random number (from 0 to 1 in steps of 10^-4)
29  Two files, low and high beta gamma:
30  file Low: beta gamma .31623 1.00000 3.16228 10.00000 31.62278
31  file High: beta gamma 100.00000 316.22777 1000.00000 3162.27766 10000.00000
32 
33  here use column 2 for High file
34  */
35 
36  Double_t zLocEnd=Rloc.z()+Dloc.z(); // for transverse diffusion
37  Double_t pathLength=Dloc.Mag(); // convert from cm to mm
38  TVector3 rv=Dloc; rv=rv.Unit(); // unit vector along the path
39 // printf("|v|=%.3f x,y,z=%.3f,%.3f,%.3f, pT=%.3f\n",rv.Mag(), rv.x(),rv.y(),rv.z(),rvT);
40 
41  Double_t totalEnergy_eV = 0;
42  Double_t path = 0; // in mm, traveled so far
43  Int_t nPrimPair = 0; //# primary pairs for this path
44  Int_t nTotPair = 0; //# any pairs for this path
45 
46  Double_t sum1=0,sum2=0; // to calculate average charge position along the tracks
47  while (1) {
48  // make a random step
49  Double_t stepLength = - TMath::Log(mRnd->Uniform()) / par_pairsPerCm;
50  path += stepLength;
51  if (path > pathLength) break;
52  nPrimPair++;
53  // additional weight according to secondary energy distribution, according to Bichsel dist
54  Int_t rndBin = ((int) (10000.0 * mRnd->Uniform()));
55  // Cutoff at 9992 WMZ
56  if(rndBin > par_cutoffOfBichel) rndBin = par_cutoffOfBichel;
57  //eLossTab removed from StFgtDbMaker in review
58  Double_t eL_eV=fgtDb->getEloss(rndBin);
59  //jjassert(eL_eV);
60  Int_t nAnyPair = 1 + ((int) ((eL_eV-15.4)/26.)); // # of pairs for this sub-step, includes amplification
61  if (nAnyPair < 0) continue; // skip electron inf absorbed
62  totalEnergy_eV += eL_eV;
63  // add this electron as hit
64  TVector3 r=Rloc+ path*rv; // here we use cm as in the whole GSTAR
65  // printf("Loc %f %f %f Rxy=%f path=%f ns=%d\n", r.x(),r.y(),r.z(),r.Perp(),path,nAnyPair);
66  nTotPair+= nAnyPair;
67 
68  //............... transverse difusion in drift gap
69  if(par_transDiffusionPerPath>0.001) {
70  Double_t zDrift=zLocEnd-r.z(); // distance to 1st GEM foil
71  /* WMZ 10/13/09
72  Negative zDrift would happen in some events. The next line is added
73  to avoid it temporarily. Negative zDrift of hits in FGT disks (Z>0)
74  with a negative P_z is probably caused by "back-scattering" tracks.
75  Ignoring the sign of zDrift here does not seem to affect the estimation
76  of PERPENDICULAR diffusion to a hit. But, a better understanding of the
77  "back-scattering" is needed to make a permanent solution for it.
78  */
79  if(zDrift < 0) zDrift *= -1.0;
80 // cout << "Debug: zDrift = " << zDrift << endl;
81  Double_t perpDiffRms=par_transDiffusionPerPath*sqrt(zDrift);
82  Double_t phi=mRnd->Uniform(TMath::TwoPi());
83  Double_t perp=mRnd->Gaus(0,perpDiffRms);
84  TVector3 dR; dR.SetPtThetaPhi(perp,0.,phi);
85  r+=dR; // add diffusion to current hit location
86  // printf("aaa/um %.1f %.1f --> %.1f %.1f %.1f\n", zDrift*1e4, perpDiffRms*1e4, dR.x()*1e4, dR.y()*1e4, dR.z()*1e4);
87 #ifdef __FGT_QA_HISTO__
88  hA[27]->Fill(zDrift*10); // histo is in mm
89  hA[28]->Fill( dR.x()*1e4, dR.y()*1e4);
90 #endif
91  }
92 
93  addHit(r,nAnyPair); //position & amplitude of total ionisation caused by this primary pair
94 
95 #ifdef __FGT_QA_HISTO__
96  hA[20]->Fill(eL_eV);
97 #endif
98  sum1+=nAnyPair;
99  sum2+=nAnyPair*path;
100  }
101 
102 #ifdef __FGT_QA_HISTO__
103  hA[21]->Fill(nPrimPair );
104  hA[22]->Fill(totalEnergy_eV/ 1000.);
105  hA[23]->Fill(nTotPair );
106  hA[24]->Fill(path*10 ); // convert to mm
107  Double_t meanPath=sum2/sum1;
108  Double_t rvT=rv.Perp(); // only for QA histos
109 
110  Double_t meanTpath=meanPath*rvT;
111  // printf("nAnyEle weighted meanL/mm=%.3f , rvT=%4f, meanLT/mm=%3f\n",meanPath*10, rvT,meanTpath*10);
112  hA[25]->Fill(meanPath*10);
113  hA[26]->Fill(meanTpath*10);
114 #endif
115 }
116 
117 
118 
119 
120 //--------------------------------------------
121 //--------------------------------------------
122 //--------------------------------------------
123 void
124 StFgtSlowSimuMaker::addHit(TVector3 rLoc, Double_t ampl) {
125 
126 
127  //printf("addH %f %f %f Rxy=%f ampl=%f\n", rLoc.x(),rLoc.y(),rLoc.z(),rLoc.Perp(), ampl);
128  Float_t xH=fabs(rLoc.x()); // hit centroid in local ref frame
129  Float_t yH=fabs(rLoc.y());
130  //jjassert(xH>0);
131  //jjassert(yH>0);
132  //digXY->Fill(xH,yH); // store just one value per hit
133 
134  TAxis *axX=quadDigitizationXY->GetXaxis();
135  Int_t ixH=axX->FindFixBin(xH);
136  Int_t mxX=axX->GetNbins();
137  Int_t ix1=ixH-par_binStep,ix2=ixH+par_binStep;
138  if(ix1<1) ix1=1;
139  if(ix1>mxX) ix1=mxX;
140  // printf("hh2x %f %d %d %d\n",xH,ixH,ix1,ix2);
141  TAxis *axY=quadDigitizationXY->GetYaxis();
142  Int_t iyH=axY->FindFixBin(yH);
143  Int_t mxY=axY->GetNbins();
144  Int_t iy1=iyH-par_binStep,iy2=iyH+par_binStep;
145  if(iy1<1) iy1=1;
146  if(iy1>mxY) iy1=mxY;
147  // printf("hh2y %f %d %d %d\n",yH,iyH,iy1,iy2);
148 
149  Float_t valMax=0;
150  Int_t ix,iy;
151  for(ix=ix1;ix<=ix2;ix++) {
152  Float_t x=axX->GetBinCenter(ix);
153  Float_t val_x=amplFunc(x-xH);
154  // printf("hh3 ix=%d x=%f dx=%f, ampl_x=%f\n",ix,x,x-xH,val_x);
155  for(iy=iy1;iy<=iy2;iy++) {
156  Float_t y=axY->GetBinCenter(iy);
157  Float_t val_y=amplFunc(y-yH);
158  Float_t val2D=ampl*val_x*val_y;
159  // printf("hh4 iy=%d y=%f dy=%f, ampl_y=%f ampl_xy=%f\n",iy,y,y-yH,val_y,val2D);
160  quadDigitizationXY->Fill(x,y,val2D);
161 #ifdef __FGT_QA_HISTO__
162  digXYAll->Fill(x,y,val2D);
163 #endif
164  if(valMax<val2D) valMax=val2D;
165  }
166  }
167  // printf("hh5 valMax=%f\n",valMax);
168 
169 
170 }
171 
172 
173 
174 
177 
178 // $Log: StFgtSlowSimu_response.cxx,v $
179 // Revision 1.1 2012/06/06 20:35:09 jeromel
180 // Code review closed (requested Anselm/Jan; reviewed Jonathan/Jason)
181 //
182 // Revision 1.9 2012/05/08 16:40:26 avossen
183 // prepare for review
184 //
185 // Revision 1.8 2012/03/15 19:27:15 avossen
186 // added getEloss to StFgtDb
187 //
188 // Revision 1.7 2012/03/10 01:57:05 rfatemi
189 // disable access to eLossTab
190 //
191 // Revision 1.6 2011/12/02 01:10:46 balewski
192 // add back fgtDb->eLosTab(..)
193 //
194 // Revision 1.5 2011/12/01 00:58:01 avossen
195 // changed the use of the naive maker to use of StFgtDb, replaced geom-> with StFgtGeom::
196 //
197 // Revision 1.4 2011/10/06 19:05:56 balewski
198 // Elos table is now read in from STAR DB
199 //
200 // Revision 1.3 2011/10/05 18:04:33 balewski
201 // storing of FGT in StEvent is almost working
202 //
203 // Revision 1.2 2011/09/29 21:36:17 balewski
204 // now 2D distribution of charge & fiducial cuts are workimng properly
205 //
206 // Revision 1.1 2011/09/28 20:57:37 balewski
207 // merging private code
208 //
209 // Revision 1.1 2011/04/07 19:31:22 balewski
210 // start
211 //
212 
213 
214 
215 
216