CMS 3D CMS Logo

EcalTBHodoscopeRecInfoAlgo.cc
Go to the documentation of this file.
3 
4 #include <list>
5 
7  const std::vector<double>& planeShift,
8  const std::vector<double>& zPosition)
9  : fitMethod_(fitMethod), planeShift_(planeShift), zPosition_(zPosition) {
11 }
12 
14  float& x, float& xQuality, const int& ipl, const int& xclus, const int& width) const {
15  if (width == 1) {
16  // Single fiber
17  x = (myGeometry_->getFibreLp(ipl, xclus) + myGeometry_->getFibreRp(ipl, xclus)) / 2.0 - planeShift_[ipl];
18  xQuality = (myGeometry_->getFibreRp(ipl, xclus) - myGeometry_->getFibreLp(ipl, xclus));
19  } else if (width == 2) {
20  // Two half overlapped fibers
21  x = (myGeometry_->getFibreLp(ipl, xclus + 1) + myGeometry_->getFibreRp(ipl, xclus)) / 2.0 - planeShift_[ipl];
22  xQuality = (myGeometry_->getFibreRp(ipl, xclus) - myGeometry_->getFibreLp(ipl, xclus + 1));
23  } else {
24  // More then two fibers case
25  x = (myGeometry_->getFibreLp(ipl, xclus) + myGeometry_->getFibreRp(ipl, xclus + width - 1)) / 2.0 -
26  planeShift_[ipl];
27  xQuality = (myGeometry_->getFibreRp(ipl, xclus + width - 1) - myGeometry_->getFibreLp(ipl, xclus));
28  }
29 }
30 
32  float& xQuality,
33  const int& ipl,
34  const int& nclus,
35  const std::vector<int>& xclus,
36  const std::vector<int>& wclus) const {
37  if (nclus == 1) {
38  // Fill real x as mean position inside the cluster
39  // Quality - width of cluster
40  // To calculate sigma one can do sigma=sqrt(Quality**2/12.0)
41  clusterPos(x, xQuality, ipl, xclus[0], wclus[0]);
42  } else {
43  xQuality = -10 - nclus;
44  }
45 }
46 
48  float& xSlope,
49  float& xQuality,
50  const int& ipl1,
51  const int& nclus1,
52  const std::vector<int>& xclus1,
53  const std::vector<int>& wclus1,
54  const int& ipl2,
55  const int& nclus2,
56  const std::vector<int>& xclus2,
57  const std::vector<int>& wclus2) const {
58  if (nclus1 == 0) { // Fit with one plane
59  fitHodo(x, xQuality, ipl2, nclus2, xclus2, wclus2);
60  xSlope = 0.0; //?? Should we put another number indicating that is not fitted
61  return;
62  }
63  if (nclus2 == 0) { // Fit with one plane
64  fitHodo(x, xQuality, ipl1, nclus1, xclus1, wclus1);
65  xSlope = 0.0; //?? Should we put another number indicating that is not fitted
66  return;
67  }
68 
69  // We have clusters in both planes
70 
71  float x1, x2, xQ1, xQ2;
72  float xs, x0, xq;
73 
74  std::list<BeamTrack> tracks;
75 
76  for (int i1 = 0; i1 < nclus1; i1++) {
77  for (int i2 = 0; i2 < nclus2; i2++) {
78  clusterPos(x1, xQ1, ipl1, xclus1[i1], wclus1[i1]);
79  clusterPos(x2, xQ2, ipl2, xclus2[i2], wclus2[i2]);
80 
81  xs = (x2 - x1) / (zPosition_[ipl2] - zPosition_[ipl1]); // slope
82  x0 = ((x2 + x1) - xs * (zPosition_[ipl2] + zPosition_[ipl1])) / 2.0; // x0
83  xq = (xQ1 + xQ2) / 2.0; // Quality, how i can do better ?
84  tracks.push_back(BeamTrack(x0, xs, xq));
85  }
86  }
87 
88  // find track with minimal slope
89  tracks.sort();
90 
91  // Return results
92  x = tracks.begin()->x;
93  xSlope = tracks.begin()->xS;
94  xQuality = tracks.begin()->xQ;
95 }
96 
98  // Reset Hodo data
99  float x, y = -100.0;
100  float xSlope, ySlope = 0.0;
101  float xQuality, yQuality = -100.0;
102 
103  int nclus[4];
104  std::vector<int> xclus[4];
105  std::vector<int> wclus[4];
106 
107  for (int ipl = 0; ipl < myGeometry_->getNPlanes(); ipl++) {
108  int nhits = hodoscopeRawInfo[ipl].numberOfFiredHits();
109  // Finding clusters
110  nclus[ipl] = 0;
111  if (nhits > 0) {
112  int nh = nhits;
113  int first = 0;
114  int last = 0;
115  while (nh > 0) {
116  while (hodoscopeRawInfo[ipl][first] == 0)
117  first++; // start
118  last = first + 1;
119  nh--;
120  do {
121  while (last < myGeometry_->getNFibres() && hodoscopeRawInfo[ipl][last]) {
122  last++;
123  nh--;
124  } //end
125  if (last + 1 < myGeometry_->getNFibres() && hodoscopeRawInfo[ipl][last + 1]) { //Skip 1 fibre hole
126  last += 2;
127  nh--;
128  //std::cout << "Skip fibre " << ipl << " " << first << " "<< last << std::endl;
129  } else {
130  break;
131  }
132  } while (nh > 0 && last < myGeometry_->getNFibres());
133  wclus[ipl].push_back(last - first);
134  xclus[ipl].push_back(first); // Left edge !!!
135  nclus[ipl]++;
136 
137  first = last + 1;
138  }
139  }
140  // printClusters(ipl);
141  }
142 
144  // Straight line fit for one axis
145  if (fitMethod_ == 0) {
146  fitLine(x,
147  xSlope,
148  xQuality,
149  0,
150  nclus[0],
151  xclus[0],
152  wclus[0], // X1
153  2,
154  nclus[2],
155  xclus[2],
156  wclus[2]); // X2
157  fitLine(y,
158  ySlope,
159  yQuality,
160  1,
161  nclus[1],
162  xclus[1],
163  wclus[1], // Y1
164  3,
165  nclus[3],
166  xclus[3],
167  wclus[3]); // Y2
168  } else if (fitMethod_ == 1) {
170  // x1 and y2 hodoscope
171  fitHodo(x, xQuality, 0, nclus[0], xclus[0], wclus[0]); // X1
172  // if ( xQuality[1] < 0.0 ) {
173  // printFibres(0);
174  // printClusters(0);
175  // }
176  fitHodo(y, yQuality, 1, nclus[1], xclus[1], wclus[1]); // Y1
177  // if ( yQuality[1] < 0.0 ) {
178  // printFibres(1);
179  // printClusters(1);
180  // }
181  } else if (fitMethod_ == 2) {
183  //x2 and y2 hodoscope
184  fitHodo(x, xQuality, 2, nclus[2], xclus[2], wclus[2]); // X2
185  // if ( xQuality[2] < 0.0 ) {
186  // printFibres(2);
187  // printClusters(2);
188  // }
189  fitHodo(y, yQuality, 3, nclus[3], xclus[3], wclus[3]); // Y2
190  // if ( yQuality[2] < 0.0 ) {
191  // printFibres(3);
192  // printClusters(3);
193  // }
194  }
195 
196  return EcalTBHodoscopeRecInfo(x, y, xSlope, ySlope, xQuality, yQuality);
197 }
EcalTBHodoscopeGeometry::getFibreRp
static float getFibreRp(int plane, int fibre)
Definition: EcalTBHodoscopeGeometry.cc:18
DDAxes::y
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
MessageLogger.h
EcalTBHodoscopeRecInfoAlgo::BeamTrack
Class to hold track information.
Definition: EcalTBHodoscopeRecInfoAlgo.h:28
EcalTBHodoscopeRecInfoAlgo::clusterPos
void clusterPos(float &x, float &xQuality, const int &ipl, const int &xclus, const int &wclus) const
Definition: EcalTBHodoscopeRecInfoAlgo.cc:13
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
EcalTBHodoscopeGeometry
Definition: EcalTBHodoscopeGeometry.h:9
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
ecal2004TBHodoscopeReconstructor_cfi.planeShift
planeShift
Definition: ecal2004TBHodoscopeReconstructor_cfi.py:8
DDAxes::x
EcalTBHodoscopeGeometry::getFibreLp
static float getFibreLp(int plane, int fibre)
Definition: EcalTBHodoscopeGeometry.cc:10
dqmdumpme.first
first
Definition: dqmdumpme.py:55
ecal2004TBHodoscopeReconstructor_cfi.zPosition
zPosition
Definition: ecal2004TBHodoscopeReconstructor_cfi.py:9
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
EcalTBHodoscopeRecInfoAlgo::myGeometry_
EcalTBHodoscopeGeometry * myGeometry_
Definition: EcalTBHodoscopeRecInfoAlgo.h:73
dqmdumpme.last
last
Definition: dqmdumpme.py:56
ecal2004TBHodoscopeReconstructor_cfi.fitMethod
fitMethod
Definition: ecal2004TBHodoscopeReconstructor_cfi.py:5
EcalTBHodoscopeRecInfo
Definition: EcalTBHodoscopeRecInfo.h:12
cms::cuda::nh
uint32_t nh
Definition: HistoContainer.h:23
vertices_cff.x
x
Definition: vertices_cff.py:29
EcalTBHodoscopeRecInfoAlgo::planeShift_
std::vector< double > planeShift_
Definition: EcalTBHodoscopeRecInfoAlgo.h:69
EcalTBHodoscopeRecInfoAlgo::fitLine
void fitLine(float &x, float &xSlope, float &xQuality, const int &ipl1, const int &nclus1, const std::vector< int > &xclus1, const std::vector< int > &wclus1, const int &ipl2, const int &nclus2, const std::vector< int > &xclus2, const std::vector< int > &wclus2) const
Definition: EcalTBHodoscopeRecInfoAlgo.cc:47
nhits
Definition: HIMultiTrackSelector.h:42
EcalTBHodoscopeGeometry::getNFibres
static int getNFibres()
Definition: EcalTBHodoscopeGeometry.cc:28
EcalTBHodoscopeRecInfoAlgo::fitMethod_
int fitMethod_
Definition: EcalTBHodoscopeRecInfoAlgo.h:67
EcalTBHodoscopeRawInfo
Definition: EcalTBHodoscopeRawInfo.h:13
EcalTBHodoscopeRecInfoAlgo.h
EcalTBHodoscopeRecInfoAlgo::fitHodo
void fitHodo(float &x, float &xQuality, const int &ipl, const int &nclus, const std::vector< int > &xclus, const std::vector< int > &wclus) const
Definition: EcalTBHodoscopeRecInfoAlgo.cc:31
EcalTBHodoscopeRecInfoAlgo::reconstruct
EcalTBHodoscopeRecInfo reconstruct(const EcalTBHodoscopeRawInfo &hodoscopeRawInfo) const
Definition: EcalTBHodoscopeRecInfoAlgo.cc:97
EcalTBHodoscopeRecInfoAlgo::EcalTBHodoscopeRecInfoAlgo
EcalTBHodoscopeRecInfoAlgo()
EcalTBHodoscopeGeometry::getNPlanes
static int getNPlanes()
Definition: EcalTBHodoscopeGeometry.cc:26
EcalTBHodoscopeRecInfoAlgo::zPosition_
std::vector< double > zPosition_
Definition: EcalTBHodoscopeRecInfoAlgo.h:70