21 #ifndef CCDDigitizer_h
22 #define CCDDigitizer_h 1
24 #include "marlin/Processor.h"
26 #include "EVENT/SimTrackerHit.h"
27 #include "IMPL/TrackerHitImpl.h"
28 #include "IMPL/SimTrackerHitImpl.h"
32 #include "EVENT/LCIO.h"
33 #include <IMPL/LCCollectionVec.h>
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>
44 #include <marlin/Global.h>
45 #include <marlin/VerbosityLevels.h>
46 #include <marlin/AIDAProcessor.h>
49 using namespace lcio ;
50 using namespace marlin ;
63 struct IonisationPoint {
71 typedef std::vector<IonisationPoint> IonisationPointVec;
72 typedef std::vector<TrackerHitImpl*> TrackerHitImplVec;
73 typedef std::vector<SimTrackerHitImpl*> SimTrackerHitImplVec;
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
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
86 //if using a table, numhitstep must be adjusted when changing Numstep
88 //#define numhitstepx 6//must be =(Numstepx/2)+1
89 //#define numhitstepy 6//must be =(Numstepy/2)+1
90 //#define numsigstep 20
94 class CCDDigitizer : public Processor {
98 CCDDigitizer(const CCDDigitizer&) = delete;
99 CCDDigitizer& operator=(const CCDDigitizer&) = delete;
101 virtual Processor* newProcessor() { return new CCDDigitizer ; }
109 virtual void init() ;
114 virtual void processRunHeader( LCRunHeader* run ) ;
118 virtual void processEvent( LCEvent * evt ) ;
122 virtual void check( LCEvent * evt ) ;
133 std::string _colName{};
134 std::string _outputCollectionName{};
135 std::string _colVTXRelation{};
147 double _cutOnDeltaRays{};
150 double _diffusionCoefficient{};
154 int _numberOfLayers{};
155 double _pixelSizeX{};
156 double _pixelSizeY{};
157 double _electronsPerKeV{};
158 double _segmentDepth{};
159 double _currentTotalCharge{};
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{};
175 int _currentModule{};
176 int _generateBackground{};
177 double _currentParticleMomentum{};
178 double _currentParticleEnergy{};
179 double _currentParticleMass{};
180 double _currentPhi{};
182 double PI{},TWOPI{},PI2{};
184 int _produceFullPattern{};
185 int _numberOfSegments{};
187 int _PoissonSmearing{};
188 int _electronicEffects{};
189 int _useMCPMomentum{};
193 double _saturation{};
197 double _currentLocalPosition[3]{};
198 double _electronicNoise{};
199 double _segmentLength{};
201 IonisationPointVec _ionisationPoints{};
204 MyG4UniversalFluctuationForSi * _fluctuate{};
208 void FindLocalPosition(SimTrackerHit * hit,
209 double * localPosition,
210 double * localDirection);
212 void TransformToLab(double * xLoc, double * xLab);
213 void ProduceIonisationPoints( SimTrackerHit * hit);
214 void diffusion(double xdif,double ydif, double sigma);
216 void ProduceHits(SimTrackerHitImplVec & simTrkVec);
217 void TransformXYToCellID(double x, double y,
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 );
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);
232 // double _currentLocalPosition[3];
233 // double _currentEntryPoint[3];
234 // double _currentExitPoint[3];
236 double _energyLoss{};
237 std::vector <SimTrackerHitImplVec> _hitsInLayer{};
243 double pxl[maxpixx][maxpixy]{};
251 double sigmacoefficient{};
259 double TanLorentzAngle{};
262 #ifdef CCD_diagnostics
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{};
281 // double table [numsigstep][numhitstepx][numhitstepy][maxpixx][maxpixy];
282 // void diffusiontable(double xdif,double ydif, double sigma);