All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
TPCDigiProcessor.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 
3 /*
4 Evolved version of TPCDigi that provides additional functionality to deal with background. Couple to the Mokka Sensitive Detector Driver TPCSD03.cc
5 
6 SJA:FIXME: Still needs to be tidied up for production release.
7 
8 Three cases can be consider in the treatment of SimTrackerHits
9 i) A clean isolated hit; this will be smeared according to the parametric point resolution and converted to a TrackerHit
10 ii) Two or Three hits which are considered to be closer than the double hit resolution and which therefore cannot be viewed as seperable hits. These will be merged and be assigned a large associated measurement error.
11 iii) A continuous set of hits within one pad row which cannot be resolved as single hits, these are condidered to be charaterisable as background hits created by extremely low pt charged particles (pt < 10MeV) and therefore are removed from the hit collection.
12 
13 The Driver has been modified to take an additional collection of SimTrackerHits which are produced by the Mokka TPC Sensitive Driver TPCSD03.cc. These hits are produced for particles which have very low pt and often do not move outside of the dimensions of a single pad row. These hits need to be treated differently as they do not cross any geometric boundaries in a Padrow based TPC Geometry. This negates the need to voxalise the TPC in Geant4 which has proved in the past to be prohibitive in terms of processing time due to the vastly increased number of geometric volumes.
14 
15 Steve Aplin 26 June 2009 (DESY)
16 
17 */
18 
19 #ifndef TPCDigiProcessor_h
20 #define TPCDigiProcessor_h 1
21 
22 #include <marlin/Processor.h>
23 #include <lcio.h>
24 
25 
26 #include <string>
27 #include <gsl/gsl_rng.h>
28 
29 #ifdef MARLIN_USE_AIDA
30 
31 #include <marlin/AIDAProcessor.h>
32 #include <AIDA/IHistogramFactory.h>
33 #include <AIDA/ICloud1D.h>
34 //#include <AIDA/IHistogram1D.h>
35 
36 
37 
38 //#define DIGIPLOTS
39 
40 
41 
42 #ifdef DIGIPLOTS
43 // includes all AIDA header files
44 #include <AIDA/AIDA.h>
45 #endif
46 
47 #endif
48 
49 #include <vector>
50 #include <map>
51 
52 #include <EVENT/LCCollection.h>
53 #include <IMPL/LCCollectionVec.h>
54 #include <EVENT/MCParticle.h>
55 #include <EVENT/SimTrackerHit.h>
56 #include <IMPL/TrackerHitImpl.h>
57 #include <UTIL/CellIDEncoder.h>
58 
59 #include "CLHEP/Vector/TwoVector.h"
60 class Voxel_tpc;
61 
62 
63 
64 
65 using namespace lcio ;
66 using namespace marlin ;
67 #ifdef MARLIN_USE_AIDA
68 using namespace AIDA ;
69 #endif
70 
71 
72 /**
73 \addtogroup TrackDigi TrackDigi
74 @{
75 
76 \addtogroup TPCDigiProcessor TPCDigiProcessor
77 @{
78 Evolved version of TPCDigi that provides additional functionality to deal with background.
79  * ====== TPCDigiProcessor ====== <br>
80  *
81  * This Processor depends on Circle.h from MarlinUtil
82  *
83  * Caution: This digitiser presently does not process space-point like SimTrackerHits which have been flagged with CellIDs set to the negetive row number. This must be implemented in future.
84  *Produces TPC TrackerHit collection from SimTrackerHit collection, smeared in r-phi and z.
85  * Double hits are identified but are currently not added to the collection. This may be change
86  * at a later date when criteria for their seperation is defined. The resolutions are defined in
87  * the GEAR stearing file.
88  *
89  * Resolution in r-phi is calculated according to the formular <br>
90  * sigma_{point}^2 = sigma_0^2 + Cd^2/N_{eff} * L_{drift}
91  * Cd^2/N_{eff}} = 25^2/(22/sin(theta)*h/6mm)
92  * Cd = 25 ( microns / cm^(1/2) )
93  * (this is for B=4T, h is the pad height = pad-row pitch in mm,
94  * theta is the polar angle)
95  *
96  * At the moment resolution in z assumed to be independent of drift length. <br>
97  *
98  * The type of TPC TrackerHit is set to 500 via method TrackerHitImpl::setType(int type) <br>
99  * <h4>Input collections and prerequisites</h4>
100  * Processor requires collections of SimTrackerHits in TPC <br>
101  * <h4>Output</h4>
102  * Processor produces collection of digitized TrackerHits in TPC <br>
103  * @param CollectionName The name of input SimTrackerHit collection <br>
104  * (default name STpc01_TPC)
105  * @param RejectCellID0 Whether or not to reject SimTrackerHits with Cell ID 0. Mokka drivers
106  * TPC00-TPC03 encoded the pad row number in the cell ID, which should always be non-zero anyway.
107  * Drivers TPC04 and TPC05 do not simulate pad rows and thus have the cell ID set to zero for all hits.
108  * You will need to set RejectCellID0 to 0 in order to use this processor with these drivers, but note
109  * that the implications for track reconstruction are not strictly defined. Mokka driver TPC06 uses
110  * a mixed approach with one hit per pad row having non-zero cell ID, extra hits having 0 cell ID.
111  * Typically, unless you use TPC04 or TPC05, you should not touch this parameter. <br>
112  * (default value 1)
113  * @param TPCTrackerHitsCol The name of output collection of TrackerHits <br>
114  * (default name TPCTrackerHits) <br>
115  * <br>
116  * @authors S. Aplin, DESY and A.Raspereza, MPI
117  *
118  * Changed 7/9/07 so that the const and diffusion resolution terms are taken as processor parameters rather than the gear file.
119  * The parameters _pixZ and pixRP were also changed from gear parameters to processor parameters
120  * clare.lynch@bristol.ac.uk
121  *
122  */
123 class TPCDigiProcessor : public Processor {
124 
125 public:
126 
127  TPCDigiProcessor(const TPCDigiProcessor&) = delete;
128  TPCDigiProcessor& operator=(const TPCDigiProcessor&) = delete;
129 
130  virtual Processor* newProcessor() { return new TPCDigiProcessor ; }
131 
132 
133  TPCDigiProcessor() ;
134 
135  /** Called at the begin of the job before anything is read.
136  * Use to initialize the processor, e.g. book histograms.
137  */
138  virtual void init() ;
139 
140  /** Called for every run.
141  */
142  virtual void processRunHeader( LCRunHeader* run ) ;
143 
144  /** Called for every event - the working horse.
145  */
146  virtual void processEvent( LCEvent * evt ) ;
147 
148 
149  virtual void check( LCEvent * evt ) ;
150 
151 
152  /** Called after data processing for clean up.
153  */
154  virtual void end() ;
155 
156  void writeVoxelToHit( Voxel_tpc* aVoxel) ;
157  void writeMergedVoxelsToHit( std::vector <Voxel_tpc*>* hitList ) ;
158  void plotHelixHitResidual(MCParticle *mcp, CLHEP::Hep3Vector *thisPointRPhi);
159  double getPadPhi( CLHEP::Hep3Vector* thisPointRPhi, CLHEP::Hep3Vector* firstPointRPhi, CLHEP::Hep3Vector* middlePointRPhi, CLHEP::Hep3Vector* lastPointRPhi);
160  double getPadTheta( CLHEP::Hep3Vector* firstPointRPhi, CLHEP::Hep3Vector* middlePointRPhi, CLHEP::Hep3Vector* lastPointRPhi );
161 
162 protected:
163 
164  /** Input collection name.
165  */
166  std::string _padRowHitColName{};
167  std::string _spacePointColName{};
168  std::string _lowPtHitscolName{};
169 
170 
171  /** Output collection name.
172  */
173  std::string _TPCTrackerHitsCol{};
174  std::string _outRelColName{};
175 
176  bool _use_raw_hits_to_store_simhit_pointer{};
177 
178  int _rejectCellID0{};
179  float _padWidth{};
180 
181  int _nRun{};
182  int _nEvt{};
183 
184  EVENT::MCParticle* _mcp{};
185  EVENT::MCParticle* _previousMCP{};
186  EVENT::MCParticle* _nextMCP{};
187  EVENT::MCParticle* _nMinus2MCP{};
188  EVENT::MCParticle* _nPlus2MCP{};
189 
190  SimTrackerHit* _SimTHit{};
191  SimTrackerHit* _previousSimTHit{};
192  SimTrackerHit* _nextSimTHit{};
193  SimTrackerHit* _nPlus2SimHit{};
194  SimTrackerHit* _nMinus2SimHit{};
195 
196  // gsl random number generator
197  gsl_rng * _random{};
198 
199  bool _dontEncodeSide{};
200 
201  float _pointResoRPhi0{}; // Coefficient for RPhi point res independant of drift length
202  float _pointResoPadPhi{}; // Coefficient for the point res dependance on relative phi angle to the pad verticle
203  float _diffRPhi{}; // Coefficient for the rphi point res dependance on diffusion
204  int _nEff{}; // number of effective electrons
205 
206 
207  float _pointResoZ0{}; // Coefficient Z point res independant of drift length
208  float _diffZ{}; // Coefficient for the Z point res dependance on diffusion
209 
210  float _binningZ{};
211  float _binningRPhi{};
212  float _doubleHitResZ{};
213  float _doubleHitResRPhi{};
214  int _maxMerge{};
215 
216  int _nRechits{};
217 
218  std::vector< std::vector <Voxel_tpc *> > _tpcRowHits{};
219  std::map< Voxel_tpc *,SimTrackerHit *> _tpcHitMap{};
220  std::vector<float> _length{};
221  int lenpos{};
222 
223  LCCollectionVec* _trkhitVec{};
224  LCCollectionVec* _relCol{};
225  CellIDEncoder<TrackerHitImpl>* _cellid_encoder{};
226 
227  int _NSimTPCHits{};
228  int _NBackgroundSimTPCHits{};
229  int _NPhysicsSimTPCHits{};
230  int _NPhysicsAbove02GeVSimTPCHits{};
231  int _NPhysicsAbove1GeVSimTPCHits{};
232  int _NRecTPCHits{};
233 
234  int _NLostPhysicsTPCHits{};
235  int _NLostPhysicsAbove02GeVPtTPCHits{};
236  int _NLostPhysicsAbove1GeVPtTPCHits{};
237  int _NRevomedHits{};
238 
239 
240 #ifdef DIGIPLOTS
241  IAnalysisFactory * _AF{};
242  ITreeFactory * _TRF{};
243  ITree * _TREE{};
244  IHistogramFactory * _HF{};
245  IHistogram1D * _phiDiffHisto{};
246  IHistogram1D * _thetaDiffHisto{};
247  IHistogram1D * _phiRelHisto{};
248  IHistogram1D * _thetaRelHisto{};
249 
250  IHistogram1D * _phiDistHisto{};
251  IHistogram1D * _rPhiPullHisto{};
252  IHistogram1D * _rPhiDiffHisto{};
253  IHistogram1D * _zDiffHisto{};
254  IHistogram1D * _zPullHisto{};
255  IHistogram2D * _zSigmaVsZHisto{};
256  IHistogram1D * _zSigmaHisto{};
257  IHistogram1D * _rPhiSigmaHisto{};
258  IHistogram1D * _radiusCheckHisto{};
259  IHistogram1D * _ResidualsRPhiHisto{};
260 
261  IHistogram1D * _NSimTPCHitsHisto{};
262  IHistogram1D * _NBackgroundSimTPCHitsHisto{};
263  IHistogram1D * _NPhysicsSimTPCHitsHisto{};
264  IHistogram1D * _NPhysicsAbove02GeVSimTPCHitsHisto{};
265  IHistogram1D * _NPhysicsAbove1GeVSimTPCHitsHisto{};
266  IHistogram1D * _NRecTPCHitsHisto{};
267 
268  IHistogram1D * _NLostPhysicsTPCHitsHisto{};
269  IHistogram1D * _NLostPhysicsAbove02GeVPtTPCHitsHisto{};
270  IHistogram1D * _NLostPhysicsAbove1GeVPtTPCHitsHisto{};
271  IHistogram1D * _NRevomedHitsHisto{};
272 
273  IHistogram1D * _NKeptPhysicsTPCHitsHistoPercent{};
274  IHistogram1D * _NKeptPhysicsAbove02GeVPtTPCHitsHistoPercent{};
275  IHistogram1D * _NKeptPhysicsAbove1GeVPtTPCHitsHistoPercent{};
276 
277 #endif
278 
279 
280 } ;
281 
282 
283 /** @} @} */
284 
285 #endif
virtual Processor * newProcessor()
std::vector< LCCollection * > LCCollectionVec
Definition: SiStripClus.h:55