StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSvtSimulation.cc
1 /***************************************************************************
2  *
3  * $Id: StSvtSimulation.cc,v 1.13 2009/02/21 14:22:03 caines Exp $
4  *
5  * Author: Selemon Bekele
6  ***************************************************************************
7  *
8  * Description: Fills hybrid pixel objects
9  *
10  ***************************************************************************
11  *
12  * $Log: StSvtSimulation.cc,v $
13  * Revision 1.13 2009/02/21 14:22:03 caines
14  * Comment out debugging statements
15  *
16  * Revision 1.12 2005/07/23 03:37:34 perev
17  * IdTruth + Cleanup
18  *
19  * Revision 1.11 2005/02/09 14:33:35 caines
20  * New electron expansion routine
21  *
22  * Revision 1.10 2004/01/22 16:30:47 caines
23  * Getting closer to a final simulation
24  *
25  * Revision 1.9 2003/11/15 20:24:29 caines
26  * fixes to remove warnings at compilation
27  *
28  * Revision 1.8 2003/11/13 16:24:59 caines
29  * Further improvements to get simulator looking like reality
30  *
31  * Revision 1.7 2003/09/02 17:59:09 perev
32  * gcc 3.2 updates + WarnOff
33  *
34  * Revision 1.6 2003/07/31 19:18:10 caines
35  * Petrs improved simulation code
36  *
37  * Revision 1.5 2001/08/13 15:34:18 bekele
38  * Debugging tools added
39  *
40  * Revision 1.4 2001/03/19 22:25:53 caines
41  * Catch wrong wafer ids more elegantly
42  *
43  * Revision 1.3 2001/03/15 15:12:08 bekele
44  * added a method to fill the whole SVT hybrid with background
45  *
46  * Revision 1.2 2001/02/07 19:13:51 caines
47  * Small fixes to allow to run without setup from command line
48  *
49  * Revision 1.1 2000/11/30 20:47:49 caines
50  * First version of Slow Simulator - S. Bekele
51  *
52  **************************************************************************/
53 
54 
55 #include "StSvtClassLibrary/StSvtHybridPixelsD.hh"
56 
57 #include "StSvtSignal.hh"
58 #include "StSvtSimulation.hh"
59 #include "StMCTruth.h"
60 
61 //#include "tables/St_svg_geom_Table.h"
62 
63 ClassImp(StSvtSimulation)
64 
65 
67 {
68 
69  mElectronCloud = NULL;
70  mSvtSignal = new StSvtSignal();
71  mSvtSignal->setOption(0); //as default do use mixed method for PASA
72 
73  setPasaSigAttributes(kFALSE,8);
74 }
75 
76 StSvtSimulation::~StSvtSimulation()
77 {
78  delete mSvtSignal;
79 }
80 
81 void StSvtSimulation::setOptions(int option)
82 {
83  mSignalOption = option;
84  mSvtSignal->setOption(mSignalOption);
85 }
86 
87 void StSvtSimulation::setElCloud(StSvtElectronCloud* elCloud)
88 {
89  mElectronCloud = elCloud;
90 }
91 
92 void StSvtSimulation::setAnodeTimeBinSizes(double timBinSize, double anodeSize)
93  {
94  mTimeBinSize = timBinSize ;
95  mAnodeSize = anodeSize;
96  mSvtSignal->setAnodeTimeBinSizes(mTimeBinSize,mAnodeSize);
97  }
98 
99 
100 void StSvtSimulation::setDriftVelocity(double driftVelocity)
101 {
102 
103  mDriftVelocity = driftVelocity;
104  mSvtSignal->setDriftVelocity(mDriftVelocity);
105  mSvtSignal->pasaRelatedStuff();
106 }
107 
108 
109 
110 void StSvtSimulation::setPasaSigAttributes(int pasaSigAttributes, int numOfAnodesPerHit)
111  {
112  mNumOfAnodesPerHit = numOfAnodesPerHit;
113  mPasaDebug = pasaSigAttributes;
114 
115  if(mNumOfAnodesPerHit == 0){
116 
117  mUpperAn = 3;
118  mLowerAn = -3;
119 
120  } else {
121 
122  mUpperAn = (int)(mNumOfAnodesPerHit/2);
123 
124  if((mNumOfAnodesPerHit%2) == 0){
125 
126  mUpperAn = mUpperAn + 1;
127  }
128 
129  mLowerAn = -mUpperAn;
130  }
131  //cout<<"upperAn = "<<mUpperAn<<endl;
132  //cout<<"lowerAn = "<<mLowerAn<<endl;
133 
134  }
135 
136 
137 
138 //____________________________________________________________________________
139 void StSvtSimulation::doCloud(double time, double Energy,double mTheta,double mPhi,int trackId)
140 {
141  mElectronCloud->setPar(Energy,mTheta,mPhi,mTimeBinSize,trackId); //this has to be done for each hit
142  mElectronCloud->setDriftVelocity(mDriftVelocity);
143  mElectronCloud->CalcExpansion(time);
144  //cout<<"Time " << time<<" sigAn= "<<mElectronCloud->getSigmaAnode()<<" sigT= "<<mElectronCloud->getSigmaDrift()<<endl;
145  mSvtSignal->setCloud(mElectronCloud);
146 }
147 
148 
149 //____________________________________________________________________________
150 void StSvtSimulation::fillBuffer(double mAnHit, double mTimeHit, StSvtHybridPixelsD *svtSimDataPixels)
151 {
152  //cout<<"StSvtSimulation::fillBuffer"<<endl;
153 
154  if(mPasaDebug){
155  resetAnodeAttributes();
156  resetBuffer();
157  }
158 
159  mPeakSignal = 0.0;
160  int centAn = (int)(mAnHit) + 1; //mAnHit in fraction of anode numbers
161 
162  for(int an = mLowerAn; an <= mUpperAn ; an++)
163  {
164  int anode = centAn+an;
165  if( (anode<=0)||(anode>240) ) continue;
166  int counter = an-mLowerAn;
167 
168  //cout<<"****** an = "<<anode<<" *******"<<endl;
169  double chargeOnAnode = mSvtSignal->chargeFraction(anode,mAnHit); //mAnHit in fraction of anodes
170  //cout<<"\n";
171 
172  if(mPasaDebug)mPasaSignals.mCharge[counter] = chargeOnAnode;
173 
174  if(chargeOnAnode == 0.0) continue;
175 
176  mSvtSignal->timeCenterAndWidth(mAnHit,mTimeHit); //mTimeHit in fraction of time buckets
177  mSvtSignal->calcConvSignal(chargeOnAnode);
178 
179  int lowBin = mSvtSignal->getLowTBin();
180  int hiBin = mSvtSignal->getHiTBin();
181  // cout<<" chargeOnAnode "<<anode<<" = "<<chargeOnAnode<< " for timebin " <<lowBin << " to " << hiBin << endl;
182  mPeakSignal = -1.0e-20;
183  for(int n = lowBin; n <= hiBin; n++)
184  {
185  //double t = n*mTimeBinSize;
186  double adc = mSvtSignal->getSignal(n-1); //this is in mV
187  if(adc==0.0) continue;
188  adc = adc/3.90625; // in counts with 1 count <-> 4mV*1000/1024
189  //cout<< "n = " << n << " Setting adc to " << adc << endl;
190  if(adc > mPeakSignal) mPeakSignal = adc;
191  int trackId = mSvtSignal->getTrackId();
192 
193 
194  if(mPasaDebug) mPasaSignals.mTempBuffer[counter][n-1] = adc;
195 
196  int pixelIndex = svtSimDataPixels->getPixelIndex(anode, n - 1);
197  svtSimDataPixels->addToPixel(pixelIndex, adc,trackId);
198  //adc can be negative - it should be taken care of during rounding to 8 bits
199  }
200 
201 
202  if(mPasaDebug){
203  mPasaSignals.anode[counter] = anode; //actual anode
204  mPasaSignals.mPeak[counter] = mSvtSignal->getPeak()/4; //in counts (not exactly an integer)
205  mPasaSignals.mTimeCenter[counter] = mSvtSignal->getTimeCenter();
206  mPasaSignals.mTimeWidth[counter] = mSvtSignal->getTimeWidth();
207  mPasaSignals.mUnderShoot[counter] = mSvtSignal->getMinUnderShoot();
208  }
209 
210  }
211 }
212 
213 void StSvtSimulation::resetAnodeAttributes()
214 {
215  for(int j = 0; j <SvtSim_MaxBufferSize; j++)
216  {
217  mPasaSignals.anode[j] = 0; //actual anode
218  mPasaSignals.mPeak[j] = 0;
219  mPasaSignals.mTimeCenter[j] = 0;
220  mPasaSignals.mTimeWidth[j] = 0;
221  mPasaSignals.mUnderShoot[j] = 0;
222  }
223 }
224 
225 void StSvtSimulation::resetBuffer()
226 {
227  for (int an= 0; an<SvtSim_MaxBufferSize;an++) for(int n = 0; n < 128; n++)
228  mPasaSignals.mTempBuffer[an][n] = 0; //adc counts, an is anode counter
229 }
230 
SVT electron cloud expansion routines Simulates electron cloud expansion inside of the silicon wafer...