Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DEventProcessor_bcal_calib.h
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DEventProcessor_bcal_calib.h
4 // Created: Thu Oct 18 17:15:41 EDT 2012
5 // Creator: staylor (on Linux ifarm1102 2.6.18-274.3.1.el5 x86_64)
6 //
7 
8 #ifndef _DEventProcessor_bcal_calib_
9 #define _DEventProcessor_bcal_calib_
10 
11 #include <pthread.h>
12 #include <map>
13 #include <vector>
14 #include <deque>
15 using std::map;
16 
17 #include <TTree.h>
18 #include <TFile.h>
19 #include <TH1.h>
20 #include <TH2.h>
21 #include <TH3.h>
22 
23 #include <JANA/JFactory.h>
24 #include <JANA/JEventProcessor.h>
25 #include <JANA/JEventLoop.h>
26 #include <JANA/JCalibration.h>
27 
28 #include <PID/DKinematicData.h>
29 #include <CDC/DCDCTrackHit.h>
30 #include <BCAL/DBCALShower.h>
31 #include <DMatrixSIMD.h>
32 #include <DVector2.h>
33 #include <DVector3.h>
34 
35 typedef struct{
40  double z,t;
41  int num_hits;
42  unsigned int h_id;
44 
45 typedef struct{
46  bool matched;
48  vector<const DCDCTrackHit *>hits;
50 
51 typedef struct{
53  vector<const DCDCTrackHit *>axial_hits;
54  vector<const DCDCTrackHit *>stereo_hits;
56 
57 typedef struct{
61 
62 
63 
64 #define EPS 1e-3
65 #define ITER_MAX 20
66 #define CDC_MATCH_RADIUS 5.0
67 
68 class DEventProcessor_bcal_calib:public jana::JEventProcessor{
69  public:
72  const char* className(void){return "DEventProcessor_bcal_calib";}
73 
74  enum track_type{
77  };
83  };
84 
85  private:
86  jerror_t init(void); ///< Called once at program start.
87  jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber); ///< Called everytime a new run number is detected.
88  jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber); ///< Called every event.
89  jerror_t erun(void); ///< Called everytime run number changes, provided brun has been called.
90  jerror_t fini(void); ///< Called after last event of last event source has been processed.
91 
93  jerror_t DoFilter(DMatrix4x1 &S,vector<const DCDCTrackHit *>&hits);
94  jerror_t KalmanFilter(DMatrix4x1 &S,DMatrix4x4 &C,
95  vector<const DCDCTrackHit *>&hits,
96  deque<trajectory_t>&trajectory,
97  double &chi2,unsigned int &ndof,
98  bool timebased=false);
99  jerror_t SetReferenceTrajectory(double z,DMatrix4x1 &S,
100  deque<trajectory_t>&trajectory,
101  const DCDCTrackHit *last_cdc);
102  jerror_t FindSegments(vector<const DCDCTrackHit*>&hits,
103  vector<cdc_segment_t>&segments,
104  vector<bool>&used_hits
105  );
106  jerror_t LinkSegments(vector<cdc_segment_t>&axial_segments,
107  vector<bool>&used_axial,
108  vector<const DCDCTrackHit *>&axial_hits,
109  vector<const DCDCTrackHit *>&stereo_hits,
110  vector<cdc_track_t>&LinkedSegments);
111  bool MatchCDCHit(const DVector3 &vhat,const DVector3 &pos0,
112  const DCDCTrackHit *hit);
113 
114  void PlotLines(deque<trajectory_t>&traj);
115 
116  bool MatchToBCAL(vector<const DBCALShower *>&bcalshowers,DMatrix4x1 &S);
117 
118  unsigned int locate(vector<double>&xx,double x);
119  double cdc_variance(double t);
120  double cdc_drift_distance(double t);
121  double FindDoca(double z,const DMatrix4x1 &S,const DVector3 &vhat,
122  const DVector3 &origin);
123 
124  double GetDriftDistance(double t);
125  double GetDriftVariance(double t);
126 
127  pthread_mutex_t mutex;
128 
131 
132  double mT0;
133 
136 
138 
139  // drift time tables
140  vector<double>cdc_drift_table;
141 
142  // Resolution parameters
144 
146 };
147 
148 
149 // Smearing function derived from fitting residuals
151  // return 0.001*0.001;
152  //if (t<0.) t=0.;
153 
154  double sigma=CDC_RES_PAR1/(t+1.)+CDC_RES_PAR2;
155  sigma+=0.025;
156  return sigma*sigma;
157 }
158 
159 #endif // _DEventProcessor_bcal_calib_
Definition: track.h:16
bool MatchCDCHit(const DVector3 &vhat, const DVector3 &pos0, const DCDCTrackHit *hit)
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
const DBCALShower * match
TVector3 DVector3
Definition: DVector3.h:14
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
bool MatchToBCAL(vector< const DBCALShower * > &bcalshowers, DMatrix4x1 &S)
unsigned int locate(vector< double > &xx, double x)
void PlotLines(deque< trajectory_t > &traj)
jerror_t KalmanFilter(DMatrix4x1 &S, DMatrix4x4 &C, vector< const DCDCTrackHit * > &hits, deque< trajectory_t > &trajectory, double &chi2, unsigned int &ndof, bool timebased=false)
jerror_t SetReferenceTrajectory(double z, DMatrix4x1 &S, deque< trajectory_t > &trajectory, const DCDCTrackHit *last_cdc)
jerror_t init(void)
Called once at program start.
jerror_t fini(void)
Called after last event of last event source has been processed.
jerror_t GuessForStateVector(const cdc_track_t &track, DMatrix4x1 &S)
vector< const DCDCTrackHit * > stereo_hits
vector< const DCDCTrackHit * > hits
double GetDriftDistance(double t)
double FindDoca(double z, const DMatrix4x1 &S, const DVector3 &vhat, const DVector3 &origin)
jerror_t LinkSegments(vector< cdc_segment_t > &axial_segments, vector< bool > &used_axial, vector< const DCDCTrackHit * > &axial_hits, vector< const DCDCTrackHit * > &stereo_hits, vector< cdc_track_t > &LinkedSegments)
Double_t sigma[NCHANNELS]
Definition: st_tw_resols.C:37
vector< const DCDCTrackHit * > axial_hits
double GetDriftVariance(double t)
#define S(str)
Definition: hddm-c.cpp:84
jerror_t DoFilter(DMatrix4x1 &S, vector< const DCDCTrackHit * > &hits)
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
jerror_t FindSegments(vector< const DCDCTrackHit * > &hits, vector< cdc_segment_t > &segments, vector< bool > &used_hits)