simple-tof-analysis
 All Classes Namespaces Functions Variables Groups Pages
GetClusterFitExtrapolatedTOFPixelID.hpp
1 
10 //__________________________________________________________________________________________________________________________
11 std::vector<int>
12 GetClusterFitExtrapolatedTOFPixelID(const Track& track,
13  const RecEvent& recEvent,
14  const det::TOFWall& TOFwall,
15  bool debug = false)
16 {
17  if (debug == true)
18  cerr<<"\n\nNumber of points on track in the MTPC = "<<track.GetNumberOfClusters(TrackConst::eMTPC)<<endl;
19 
20  const utl::Point& last_point_on_track = track.GetLastPointOnTrack();
21  std::vector<Point> clusters;
22 
23 
25  int iPoint = 0;
26  for (ClusterIndexIterator ClusterIter = track.ClustersEnd(); ClusterIter != track.ClustersBegin(); --ClusterIter)
27  {
28  if (clusters.size() > 9)
29  break;
30 
31  if (debug == true)
32  cerr<<"\nClusterIter = "<<*ClusterIter;
33 
34  if (iPoint == 0) --ClusterIter;
35  ++iPoint;
36 
37  if (debug == true)
38  cerr<<"\nFor iPoint = "<<iPoint;
39 
40  const Cluster& cluster = recEvent.Get(*ClusterIter);
41  clusters.push_back(cluster.GetPosition());
42 
43  if (debug == true)
44  {
45  cerr<<": "<<cluster.GetPosition().GetX()<<", "<<cluster.GetPosition().GetY()<<", "<<cluster.GetPosition().GetZ();
46 
47  if (last_point_on_track == cluster.GetPosition())
48  cerr<<". Found last point on track, corresponding to iPoint = "<<iPoint;
49  }
50  }
51 
52  if (debug == true) cerr<<"\n";
53 
54 
56  /*
57  int pointsIter = 0;
58  for (ClusterIndexIterator ClusterIter = track.ClustersEnd(); pointsIter < 10; ++pointsIter)
59  {
60  if (debug == true)
61  cerr<<"\nClusterIter = "<<*ClusterIter;
62 
63  const Cluster& cluster = recEvent.Get(*(--ClusterIter));
64  clusters.push_back(cluster.GetPosition());
65 
66  if (debug == true)
67  {
68  cerr<<"\nFor pointsIter = "<<pointsIter;
69  cerr<<": "<<cluster.GetPosition().GetX()<<", "<<cluster.GetPosition().GetY()<<", "<<cluster.GetPosition().GetZ();
70 
71  if (last_point_on_track == cluster.GetPosition())
72  cerr<<". Found last point on track, corresponding to pointsIter = "<<pointsIter;
73  }
74  }
75 
76  if (debug == true) cerr<<"\n";
77  */
78 
79 
80  TGraph * graph_track_XZ = new TGraph(clusters.size());
81  TGraph * graph_track_YZ = new TGraph(clusters.size());
82  for(unsigned int iclust = 0; iclust < clusters.size(); iclust++)
83  {
84  graph_track_XZ->SetPoint((int)iclust, clusters.at(iclust).GetZ(), clusters.at(iclust).GetX());
85  graph_track_YZ->SetPoint((int)iclust, clusters.at(iclust).GetZ(), clusters.at(iclust).GetY());
86  }
87  TF1 * lin_fit_XZ = new TF1("track_XZ", "[0]*x+[1]", 650, 830);
88  TF1 * lin_fit_YZ = new TF1("track_XZ", "[0]*x+[1]", 650, 830);
89 
90 
91  graph_track_XZ->Fit(lin_fit_XZ, "Q"); //"V"
92  graph_track_YZ->Fit(lin_fit_YZ, "Q");
93 
95  // TFitResultPtr r1 = graph_track_XZ->Fit(lin_fit_XZ, "SQ");
96  // TFitResultPtr r2 = graph_track_YZ->Fit(lin_fit_YZ, "SQ");
97  // cout<<"Chi-sq/ndf: Fit XZ = "<<r1->Chi2()/r1->Ndf()<<", Fit YZ = "<<r2->Chi2()/r2->Ndf()<<endl;
98  // delete r1;
99  // delete r2;
100 
101 
102  std::vector<int> vTOFHitIndex;
103  for(int hitindex = 1; hitindex <= 891; ++hitindex)
104  {
105  const det::TOFScintillator& Iscint = TOFwall.GetScintillator(hitindex);
106  double extrapolationPositionZ = Iscint.GetCenterPosition().GetZ() - 2.3/2;
107  double extrapolationPositionX = lin_fit_XZ->Eval(extrapolationPositionZ);
108  double extrapolationPositionY = lin_fit_YZ->Eval(extrapolationPositionZ);
109 
110  if (extrapolationPositionX < Iscint.GetCenterPosition().GetX() - Iscint.GetWidth()/2.) continue;
111  if (extrapolationPositionX > Iscint.GetCenterPosition().GetX() + Iscint.GetWidth()/2.) continue;
112  if (extrapolationPositionY < Iscint.GetCenterPosition().GetY() - 3.4/2) continue;
113  if (extrapolationPositionY > Iscint.GetCenterPosition().GetY() + 3.4/2) continue;
114 
115  vTOFHitIndex.push_back(hitindex);
116  }
117 
118 
119  delete graph_track_XZ;
120  delete graph_track_YZ;
121  delete lin_fit_XZ;
122  delete lin_fit_YZ;
123 
124  return vTOFHitIndex;
125 }