All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
CCDDigitizer.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 
3 /** Digitizer for Simulated Hits in the Vertex Detector. Track segment within
4  a layer is approximated with a line.
5  It is divided by n subsegments, where the length of the segments can be
6  specified by the user via external Processor parameter.
7  For each subsegment the charge is simulated according to Landau distribution
8  as expected for Silicon. The charge transfer from the middle point of track
9  subsegment (referred hereafter to as ionisation point) to the collection plane
10  is performed taking into account Lorentz effect int the depleted zone. It is assumed that on the collection plane the electron cloud from each ionisation point is spread according to a gaussian distribution divided by the lateral distance. This Formular is taken from Sinevs Code, where it is not justified. The width of the distribution depends on the distance between ionisationpoint and collection plane.
11  The charge on each fired pixel is then calculated as a sum of contributions from n distributions. The VTX ladder is assumed to have matrix of rectangular pixels. The output of the processor is the collection of Reconstructed Tracker Hits.There are to reconstruction methods which can be chosen by the user. Lorentz effect in the depleted zone is corrected.
12 Input collections and prerequisites:
13 Processor requires collection of simulated vertex tracker hits. If such a collection with the user specified name does not exist processor takes no action. <h4>Output</h4> Processor produces an output collection of the Tracker Hits. Collection has name "VTXTrackerHits".
14 
15  author: Stefan Uebelacker, RAL, 2008
16  the code is based on:
17  - VTXDigitizer written A. Raspereza, MPI (Munich)
18  - Simulation of CCD detection process by M. Sinev (http://source.freehep.or g/jcvsweb/ilc/LCSIM/list/lcsim/src/org/lcsim/mc/CCDSim)
19 */
20 
21 #ifndef CCDDigitizer_h
22 #define CCDDigitizer_h 1
23 
24 #include "marlin/Processor.h"
25 #include "lcio.h"
26 #include "EVENT/SimTrackerHit.h"
27 #include "IMPL/TrackerHitImpl.h"
28 #include "IMPL/SimTrackerHitImpl.h"
29 #include <string>
30 #include <vector>
32 #include "EVENT/LCIO.h"
33 #include <IMPL/LCCollectionVec.h>
34 
35 
36 
37 #ifdef CCD_diagnostics
38 #include <AIDA/IHistogramFactory.h>
39 #include <AIDA/IHistogram1D.h>
40 #include <AIDA/IHistogram2D.h>
41 #include <AIDA/IAxis.h>
42 #include <AIDA/ITree.h>
43 
44 #include <marlin/Global.h>
45 #include <marlin/VerbosityLevels.h>
46 #include <marlin/AIDAProcessor.h>
47 #endif
48 
49 using namespace lcio ;
50 using namespace marlin ;
51 
52 /**
53 \addtogroup TrackDigi TrackDigi
54 @{
55 
56 /**
57 \addtogroup CCDDigitizer CCDDigitizer
58 @{
59 Digitizer for Simulated Hits in the Vertex Detector.
60 */
61 
62 
63 struct IonisationPoint {
64  double x;
65  double y;
66  double z;
67  double eloss;
68 };
69 
70 
71 typedef std::vector<IonisationPoint> IonisationPointVec;
72 typedef std::vector<TrackerHitImpl*> TrackerHitImplVec;
73 typedef std::vector<SimTrackerHitImpl*> SimTrackerHitImplVec;
74 
75 
76 
77 #define maxpixx 9// grid size in local(ladder) x axis
78 #define maxpixy 9// grid size in local(ladder) y axis
79 //grid size in which diffusion is computed, the charge, which diffuses outside this grid, is lost;value may be redefined again after sigmacoefficient or thickness of active layer is changed
80 
81 //we approach the continual distribution of the diffusion with discrete points:
82 #define Numstepx 10// Number of points at which amplitude of diffusion is calculated within one pixel in x direction
83 #define Numstepy 10// Number of points at which amplitude of diffusion is calculated within one pixel in y direction
84 //according to first tests increasing the number of steps effects the performance of the processor only slightly and non- systematically
85 
86 //if using a table, numhitstep must be adjusted when changing Numstep
87 //table
88 //#define numhitstepx 6//must be =(Numstepx/2)+1
89 //#define numhitstepy 6//must be =(Numstepy/2)+1
90 //#define numsigstep 20
91 //table//
92 
93 
94 class CCDDigitizer : public Processor {
95 
96  public:
97 
98  CCDDigitizer(const CCDDigitizer&) = delete;
99  CCDDigitizer& operator=(const CCDDigitizer&) = delete;
100 
101  virtual Processor* newProcessor() { return new CCDDigitizer ; }
102 
103 
104  CCDDigitizer() ;
105 
106  /**
107  * Initialisation member function
108  */
109  virtual void init() ;
110 
111  /**
112  * Processing of run header
113  */
114  virtual void processRunHeader( LCRunHeader* run ) ;
115 
116  /** Processing of one event
117  */
118  virtual void processEvent( LCEvent * evt ) ;
119 
120  /** Produces check plots
121  */
122  virtual void check( LCEvent * evt ) ;
123 
124  /** Termination member function
125  */
126  virtual void end() ;
127 
128 
129  protected:
130 
131  /** Input collection name.
132  */
133  std::string _colName{};
134  std::string _outputCollectionName{};
135  std::string _colVTXRelation{};
136 
137  /** Run number
138  */
139  int _nRun{};
140 
141  /** Event number
142  */
143  int _nEvt{};
144  /** tangent of Lorentz angle
145  */
146 
147  double _cutOnDeltaRays{};
148  /** Diffusion coefficient in mm for nominla layer thickness
149  */
150  double _diffusionCoefficient{};
151 
152 
153 
154  int _numberOfLayers{};
155  double _pixelSizeX{};
156  double _pixelSizeY{};
157  double _electronsPerKeV{};
158  double _segmentDepth{};
159  double _currentTotalCharge{};
160 
161  std::vector<int> _laddersInLayer{};
162  std::vector<float> _layerRadius{};
163  std::vector<float> _layerThickness{};
164  std::vector<float> _layerHalfThickness{};
165  std::vector<float> _layerLadderLength{};
166  std::vector<float> _layerLadderHalfWidth{};
167  std::vector<float> _layerPhiOffset{};
168  std::vector<float> _layerActiveSiOffset{};
169  std::vector<float> _layerHalfPhi{};
170  std::vector<float> _layerLadderGap{};
171  std::vector<float> _bkgdHitsInLayer{};
172  std::vector<float> _layerLadderWidth{};
173 
174  int _currentLayer{};
175  int _currentModule{};
176  int _generateBackground{};
177  double _currentParticleMomentum{};
178  double _currentParticleEnergy{};
179  double _currentParticleMass{};
180  double _currentPhi{};
181 
182  double PI{},TWOPI{},PI2{};
183 
184  int _produceFullPattern{};
185  int _numberOfSegments{};
186  int _debug{};
187  int _PoissonSmearing{};
188  int _electronicEffects{};
189  int _useMCPMomentum{};
190 
191  int _recmethod{};
192  double _threshold{};
193  double _saturation{};
194  int _framesize{};
195  int maxnionpoint{};
196 
197  double _currentLocalPosition[3]{};
198  double _electronicNoise{};
199  double _segmentLength{};
200 
201  IonisationPointVec _ionisationPoints{};
202 
203 
204  MyG4UniversalFluctuationForSi * _fluctuate{};
205 
206 
207  //Finds coordinates
208  void FindLocalPosition(SimTrackerHit * hit,
209  double * localPosition,
210  double * localDirection);
211 
212  void TransformToLab(double * xLoc, double * xLab);
213  void ProduceIonisationPoints( SimTrackerHit * hit);
214  void diffusion(double xdif,double ydif, double sigma);
215 
216  void ProduceHits(SimTrackerHitImplVec & simTrkVec);
217  void TransformXYToCellID(double x, double y,
218  int & ix,
219  int & iy,double & xdif,double & ydif);
220  void TransformCellIDToXY(int ix, int iy,
221  double & x, double & y);
222  void PoissonSmearer( SimTrackerHitImplVec & simTrkVec );
223  void GainSmearer( SimTrackerHitImplVec & simTrkVec );
224  void PrintInfo( SimTrackerHit * simTrkHit, TrackerHitImpl * recoHit);
225  TrackerHitImpl * ReconstructTrackerHit(SimTrackerHitImplVec & simTrkVec );
226  void TrackerHitToLab( TrackerHitImpl * recoHit );
227 
228  void generateBackground(LCCollectionVec * col);
229  void settanlorentzangle(double B, double E, double mu, double T);
230  void settanlorentzangleb(double B, double E, double mu, double T);
231 
232 // double _currentLocalPosition[3];
233 // double _currentEntryPoint[3];
234 // double _currentExitPoint[3];
235 
236  double _energyLoss{};
237  std::vector <SimTrackerHitImplVec> _hitsInLayer{};
238 
239  double depdep{};
240  double undep{};
241  double epitaxdep{};
242 
243  double pxl[maxpixx][maxpixy]{};
244  int midpixx{};
245  int midpixy{};
246  double stepx{};
247  double stepy{};
248  double xobsoffset{};
249  double yobsoffset{};
250 
251  double sigmacoefficient{};
252  double sigmin{};
253  double _difcoef{};
254  double _efield{};
255  double _biasvolt{};
256  double _bfield{};
257  double _T{};
258  double _mu{};
259  double TanLorentzAngle{};
260 
261 
262 #ifdef CCD_diagnostics
263  double dirraw[3]{};
264  double posraw[3]{};
265  AIDA::IHistogram1D* histdist{};
266  AIDA::IHistogram1D* histcluster{};
267  AIDA::IHistogram2D* histclustxy{};
268  AIDA::IHistogram1D* histcharge{};
269  AIDA::IHistogram2D* histdistxy{};
270  AIDA::IHistogram1D* histNionpoint{};
271  AIDA::IHistogram1D* histzcoord{};
272  AIDA::IHistogram1D* histenergy{};
273  AIDA::IHistogram1D* histsignal{};
274  AIDA::IHistogram1D* histsignalframe{};
275  AIDA::IHistogram1D* histenergycentre{};
276  int Nionpoint{};
277 #endif
278 
279  // table
280  // double sigstep;
281 // double table [numsigstep][numhitstepx][numhitstepy][maxpixx][maxpixy];
282 // void diffusiontable(double xdif,double ydif, double sigma);
283 // void settable();
284 // table//
285 
286 };
287 
288 /** @} @} */
289 
290 #endif