All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
FPCCDClustering.h
Go to the documentation of this file.
1 #ifndef FPCCDClustering_h
2 #define FPCCDClustering_h 1
3 
4 #include "marlin/Processor.h"
5 #include "marlin/EventModifier.h"
6 #include "lcio.h"
7 #include <EVENT/LCCollection.h>
8 #include <IMPL/LCCollectionVec.h>
9 #include <EVENT/SimTrackerHit.h>
10 #include <IMPL/LCRelationImpl.h>
11 #include <string>
12 #include <vector>
13 #include <fstream>
14 #include <iostream>
15 
16 #include <gsl/gsl_randist.h>
17 
18 #include <marlin/Global.h>
19 #include <gear/GEAR.h>
20 
21 
22 /**
23 \addtogroup TrackDigi TrackDigi
24 @{
25 
26 \addtogroup FPCCDClustering FPCCDClustering
27 @{
28 Produces VXDTrackerHits collection from VTXPixelHits collections for FPCCD.
29 ======= FPCCDClustering ========== <br>
30  *
31  * Some modifications are done by mori.
32  * 1. The utility for making LCRelation between TrackerHit and SimTrackerHit is set.
33  * 2. The utility for studying the position resolution of valiable clusters is set.
34  * 3. The system of reading position resolution map for valiable clusters is set.
35  * 4. Pair-BG cluster rejection algorithms are set.
36  * @author Tatsuya Mori, Tohoku University: 2014-02-10
37  *
38  *
39  *
40  *
41  *
42  * Produces VXDTrackerHits collection from VTXPixelHits collections for FPCCD. <br>
43  *
44  * Parameters of this process
45  * Debug : default(0). : if 1, print debug information
46  * FPCCD_PixelSize : default(0.005) : FPCCD pixel size, which is used
47  * digitization
48  * PointResolutionRPhi: default(0.001440) : resolution value assigned to
49  * coveriance matric of TrackerHits.
50  * PointResolutionZ: default(0.001440) : resolution value assigned to
51  * coveriance matric of TrackerHits.
52  *
53  * <br>
54  * @author Akiya Miyamoto, KEK: 2010-04-19
55  *
56  */
57 
58 using namespace lcio;
59 
60 
61 
62 class FPCCDData;
63 class FPCCDPixelHit;
64 class FPCCDDigitizer;
65 class TTree;
66 class TFile;
67 
68 typedef std::pair<unsigned int, unsigned int> FPCCDHitLoc_t;
69 typedef std::map<FPCCDHitLoc_t, FPCCDPixelHit*> FPCCDLadderHit_t;
70 typedef std::vector<FPCCDPixelHit*> FPCCDCluster_t;
71 typedef std::vector<FPCCDCluster_t*> FPCCDClusterVec_t;
72 
73 
74 // =================================================================
75 class FPCCDClustering : public marlin::Processor, public marlin::EventModifier {
76 
77  public:
78  FPCCDClustering(const FPCCDClustering&) = delete;
79  FPCCDClustering& operator=(const FPCCDClustering&) = delete;
80 
81  virtual Processor* newProcessor() { return new FPCCDClustering ; }
82 
83  FPCCDClustering() ;
84 
85  virtual const std::string & name() const { return Processor::name() ; }
86 
87  virtual void modifyEvent( LCEvent * evt ) ;
88 
89  /** Called at the begin of the job before anything is read.
90  * Use to initialize the processor, e.g. book histograms.
91  */
92  virtual void init() ;
93 
94  /** Called for every run.
95  */
96  virtual void processRunHeader( LCRunHeader* run ) ;
97 
98  /** Called for every event - the working horse.
99  */
100 
101  virtual void check( LCEvent * evt ) ;
102 
103  /** Called after data processing for clean up.
104  */
105  virtual void end() ;
106 
107  // make TrackerHits from VTXPixelHits
108  void makeTrackerHitVec(FPCCDData* pxHits, LCCollection* STHcol, LCCollectionVec* relCol, LCCollectionVec* trkHitvec);
109 
110  // Initialize Geometry data
111  void InitGeometry();
112 
113  protected:
114  // Make clusters in a ladder
115  void makeClustersInALadder( int layer, FPCCDLadderHit_t &ladderHit, FPCCDClusterVec_t &cvec);
116 
117  // Make TrackerHit from clusters
118  void makeTrackerHit(LCCollection* STHcol, int layer, int ladder, FPCCDClusterVec_t &cvec, std::multimap< std::pair<int,int>, SimTrackerHit*> relMap, LCCollectionVec* relCol, LCCollectionVec* trkHitVec);
119 
120  void EnergyDigitizer(FPCCDPixelHit* aHit);
121 protected:
122 
123  std::string _colNameSTH{};
124  std::string _colNameVTX{};
125  std::string _outColNameVTX{};
126  std::string _outRelColNameVTX{};
127 
128  int _nRun{};
129  int _nEvt{};
130  int _debug{};
131 
132  bool _new_tracking_system{};
133  bool _remove_pixelhits_collection{};
134  bool _makeRelation{}; // 2012_12_20 added to escape BG hit linking error.
135  int _energyDigitization{};
136  int _randomNoise{};
137  float _pixelSize{};
138  FloatVec _pixelSizeVec{};
139  float _pixelheight{};
140  float _pointResoRPhi{};
141  float _pointResoZ{};
142 
143  double _electronsPerKeV{};
144  double _threshold{};
145  double _electronNoiseRate{};
146  int _electronsPerStep{};
147  int _nbitsForEdep{};
148 
149  int _ranSeed{};
150  gsl_rng* _rng{};
151 
152  int _nLayer{}; // Number of layers
153  int _maxLadder{}; // max number of ladders
154 
155  struct GeoData_t {
156  int nladder{};
157  double rmin{}; // distance of inner surface of sensitive region from IP
158  double dphi{}; // azimuthal angle step of each ladder
159  double phi0{}; // aximuthal angle offset
160  std::vector<double> cosphi{}; // cos[phi_ladder], cos_phi of each ladder
161  std::vector<double> sinphi{}; // sin[phi_ladder], sin_phi of each ladder
162  std::vector<double> ladder_incline{};
163  double sthick{}; // sensitive region thickness
164  double sximin{}; // minimum xi of sensitive region.
165  double sximax{}; // maximum xi of sensitive region
166  double hlength{}; // ladder's half length in z
167  int num_xi_pixel{}; // Number of xi pixel in this ladder
168  int num_zeta_pixel{}; // Number of zeta pixel in this ladder
169  };
170  std::vector<GeoData_t> _geodata{};
171 
172 // FPCCDCluster_t _cluster; // Contains one ladder of clusters
173 
174 
175 
176 //*****************For Root Writing*******************//
177 /*
178 _tree->Branch("nlinks",&_link.nlink,"nlinks/I");
179 325 _tree->Branch("weight",_link.weight,"weight[nlinks]/F");
180 326 _tree->Branch("simthits_x",_simthits.x,"simthits_x[nlinks]/D");
181 327 _tree->Branch("simthits_y",_simthits.y,"simthits_y[nlinks]/D");
182 328 _tree->Branch("simthits_z",_simthits.z,"simthits_z[nlinks]/D");
183 329 _tree->Branch("simthits_pdg",_simthits.pdg,"simthits_pdg[nlinks]/I");
184 330
185 331 _tree->Branch("trkhits_x",_trkhits.x,"trkhits_x[nlinks]/D");
186 332 _tree->Branch("trkhits_y",_trkhits.y,"trkhits_y[nlinks]/D");
187 333 _tree->Branch("trkhits_z",_trkhits.z,"trkhits_z[nlinks]/D");
188 334 _tree->Branch("trkhits_CWidth_RPhi",_trkhits.CWidth_RPhi,"trkhits_CWidth_RPhi[nlinks]/D");
189 335 _tree->Branch("trkhits_CWidth_Z",_trkhits.CWidth_Z,"trkhits_CWidth_Z[nlinks]/D");
190 */
191 
192  TTree* _tree{};
193  TFile* _rootf{};
194  #define MAX_LINK 5000
195  struct {
196  unsigned int nlink;
197  float weight[MAX_LINK];
198  } _link{};
199 
200  struct {
201  double x[MAX_LINK];
202  double y[MAX_LINK];
203  double z[MAX_LINK];
204  double R[MAX_LINK];
205  double vx[MAX_LINK];
206  double vy[MAX_LINK];
207  double vz[MAX_LINK];
208  double mcp_px[MAX_LINK];
209  double mcp_py[MAX_LINK];
210  double mcp_pz[MAX_LINK];
211  double mcp_Pt[MAX_LINK];
212  double mcp_energy[MAX_LINK];
213  float mcp_time[MAX_LINK];
214  int mcp_isCreatedInSimulation[MAX_LINK];
215  int mcp_isBackscatter[MAX_LINK];
216  int mcp_vertexIsNotEndpointOfParent[MAX_LINK];
217  int mcp_isDecayedInTracker[MAX_LINK];
218  int mcp_isDecayedInCalorimeter[MAX_LINK];
219  int mcp_hasLeftDetector[MAX_LINK];
220  int mcp_isStopped[MAX_LINK];
221  float mcp_d0[MAX_LINK];
222  float mcp_phi0[MAX_LINK];
223  float mcp_omega[MAX_LINK];
224  float mcp_z0[MAX_LINK];
225  float mcp_tanL[MAX_LINK];
226  double xi[MAX_LINK];
227  double zeta[MAX_LINK];
228  float edep[MAX_LINK];
229 
230 
231 
232 
233 
234  float px[MAX_LINK];
235  float py[MAX_LINK];
236  float pz[MAX_LINK];
237  double pAbs[MAX_LINK];
238  int pdg[MAX_LINK];
239  double mass[MAX_LINK];
240  double theta[MAX_LINK];
241  double phi[MAX_LINK];
242  double area_theta[MAX_LINK];
243  double area_phi[MAX_LINK];
244  int layer[MAX_LINK];
245  int ladder[MAX_LINK];
246  } _simthits{};
247 
248  struct {
249  double x[MAX_LINK];
250  double y[MAX_LINK];
251  double z[MAX_LINK];
252  double tposX[MAX_LINK];
253  double tposY[MAX_LINK];
254  double tposZ[MAX_LINK];
255  double cx[MAX_LINK];
256  double cy[MAX_LINK];
257  double cz[MAX_LINK];
258  double dot[MAX_LINK];
259  double R[MAX_LINK];
260  double area_theta[MAX_LINK];
261  double area_phi[MAX_LINK];
262  unsigned int CWidth_RPhi[MAX_LINK];
263  unsigned int CWidth_Z[MAX_LINK];
264  unsigned int tilt[MAX_LINK];
265  unsigned int nPix[MAX_LINK];
266  int layer[MAX_LINK];
267  int ladder[MAX_LINK];
268  double xi[MAX_LINK];
269  double zeta[MAX_LINK];
270  float edep[MAX_LINK];
271  } _trkhits{};
272 
273  struct {
274  double RPhi[MAX_LINK];
275  double Z[MAX_LINK];
276  } _diff{};
277 
278  std::string _rootFileName{};
279  std::string _treeName{};
280 
281  bool _positionReso_ReadingFile_ON{};
282  std::string _positionReso_ReadingFile{};
283  typedef std::map<short int,float> ResoMap;
284  ResoMap _resolutionMapRPhi{};
285  ResoMap _resolutionMapZ{};
286  std::ifstream _fin{};
287  void calcTrackParameterOfMCP(MCParticle* pmcp, double* par);
288 
289  struct firstCut{
290  bool isActive{};
291  IntVec RPhiWidth{};
292  IntVec ZWidth{};
293  IntVec nPix{};
294  }_firstCut{};
295 
296  struct Mori2ndCut{
297  bool isActive{};
298  FloatVec zpar{};
299  }_m2Cut{};
300 
301  struct Kamai2ndCut{
302  bool isActive{};
303  FloatVec bpar{};
304  IntVec minZWidth{};
305  }_k2Cut{};
306 
307 
308 
309 
310 
311 
312 
313 } ;
314 /** @}@} */
315 #endif
std::pair< unsigned int, unsigned int > FPCCDHitLoc_t
std::map< FPCCDHitLoc_t, FPCCDPixelHit * > FPCCDLadderHit_t
#define MAX_LINK
std::vector< FPCCDCluster_t * > FPCCDClusterVec_t
virtual Processor * newProcessor()
std::vector< LCCollection * > LCCollectionVec
Definition: SiStripClus.h:55
std::vector< FPCCDPixelHit * > FPCCDCluster_t
std::map< short int, float > ResoMap
virtual const std::string & name() const