CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
EcalTBHodoscopeRecInfoAlgo Class Reference

#include <EcalTBHodoscopeRecInfoAlgo.h>

Classes

class  BeamTrack
 Class to hold track information. More...
 

Public Member Functions

 EcalTBHodoscopeRecInfoAlgo ()
 
 EcalTBHodoscopeRecInfoAlgo (int fitMethod, const std::vector< double > &planeShift, const std::vector< double > &zPosition)
 
EcalTBHodoscopeRecInfo reconstruct (const EcalTBHodoscopeRawInfo &hodoscopeRawInfo) const
 

Private Member Functions

void clusterPos (float &x, float &xQuality, const int &ipl, const int &xclus, const int &wclus) const
 
void fitHodo (float &x, float &xQuality, const int &ipl, const int &nclus, const std::vector< int > &xclus, const std::vector< int > &wclus) const
 
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
 

Private Attributes

int fitMethod_
 
EcalTBHodoscopeGeometry myGeometry_
 
std::vector< double > planeShift_
 
std::vector< double > zPosition_
 

Detailed Description

Definition at line 11 of file EcalTBHodoscopeRecInfoAlgo.h.

Constructor & Destructor Documentation

◆ EcalTBHodoscopeRecInfoAlgo() [1/2]

EcalTBHodoscopeRecInfoAlgo::EcalTBHodoscopeRecInfoAlgo ( )

◆ EcalTBHodoscopeRecInfoAlgo() [2/2]

EcalTBHodoscopeRecInfoAlgo::EcalTBHodoscopeRecInfoAlgo ( int  fitMethod,
const std::vector< double > &  planeShift,
const std::vector< double > &  zPosition 
)
explicit

Member Function Documentation

◆ clusterPos()

void EcalTBHodoscopeRecInfoAlgo::clusterPos ( float &  x,
float &  xQuality,
const int &  ipl,
const int &  xclus,
const int &  wclus 
) const
private

Definition at line 11 of file EcalTBHodoscopeRecInfoAlgo.cc.

References EcalTBHodoscopeGeometry::getFibreLp(), EcalTBHodoscopeGeometry::getFibreRp(), myGeometry_, planeShift_, ApeEstimator_cff::width, and x.

Referenced by fitHodo(), and fitLine().

12  {
13  if (width == 1) {
14  // Single fiber
15  x = (myGeometry_.getFibreLp(ipl, xclus) + myGeometry_.getFibreRp(ipl, xclus)) / 2.0 - planeShift_[ipl];
16  xQuality = (myGeometry_.getFibreRp(ipl, xclus) - myGeometry_.getFibreLp(ipl, xclus));
17  } else if (width == 2) {
18  // Two half overlapped fibers
19  x = (myGeometry_.getFibreLp(ipl, xclus + 1) + myGeometry_.getFibreRp(ipl, xclus)) / 2.0 - planeShift_[ipl];
20  xQuality = (myGeometry_.getFibreRp(ipl, xclus) - myGeometry_.getFibreLp(ipl, xclus + 1));
21  } else {
22  // More then two fibers case
23  x = (myGeometry_.getFibreLp(ipl, xclus) + myGeometry_.getFibreRp(ipl, xclus + width - 1)) / 2.0 - planeShift_[ipl];
24  xQuality = (myGeometry_.getFibreRp(ipl, xclus + width - 1) - myGeometry_.getFibreLp(ipl, xclus));
25  }
26 }
static float getFibreLp(int plane, int fibre)
EcalTBHodoscopeGeometry myGeometry_
static float getFibreRp(int plane, int fibre)

◆ fitHodo()

void EcalTBHodoscopeRecInfoAlgo::fitHodo ( float &  x,
float &  xQuality,
const int &  ipl,
const int &  nclus,
const std::vector< int > &  xclus,
const std::vector< int > &  wclus 
) const
private

Definition at line 28 of file EcalTBHodoscopeRecInfoAlgo.cc.

References clusterPos(), and x.

Referenced by fitLine(), and reconstruct().

33  {
34  if (nclus == 1) {
35  // Fill real x as mean position inside the cluster
36  // Quality - width of cluster
37  // To calculate sigma one can do sigma=sqrt(Quality**2/12.0)
38  clusterPos(x, xQuality, ipl, xclus[0], wclus[0]);
39  } else {
40  xQuality = -10 - nclus;
41  }
42 }
void clusterPos(float &x, float &xQuality, const int &ipl, const int &xclus, const int &wclus) const

◆ fitLine()

void EcalTBHodoscopeRecInfoAlgo::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
private

Definition at line 44 of file EcalTBHodoscopeRecInfoAlgo.cc.

References clusterPos(), fitHodo(), testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, DiMuonV_cfg::tracks, x, testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, and zPosition_.

Referenced by reconstruct().

54  {
55  if (nclus1 == 0) { // Fit with one plane
56  fitHodo(x, xQuality, ipl2, nclus2, xclus2, wclus2);
57  xSlope = 0.0; //?? Should we put another number indicating that is not fitted
58  return;
59  }
60  if (nclus2 == 0) { // Fit with one plane
61  fitHodo(x, xQuality, ipl1, nclus1, xclus1, wclus1);
62  xSlope = 0.0; //?? Should we put another number indicating that is not fitted
63  return;
64  }
65 
66  // We have clusters in both planes
67 
68  float x1, x2, xQ1, xQ2;
69  float xs, x0, xq;
70 
71  std::list<BeamTrack> tracks;
72 
73  for (int i1 = 0; i1 < nclus1; i1++) {
74  for (int i2 = 0; i2 < nclus2; i2++) {
75  clusterPos(x1, xQ1, ipl1, xclus1[i1], wclus1[i1]);
76  clusterPos(x2, xQ2, ipl2, xclus2[i2], wclus2[i2]);
77 
78  xs = (x2 - x1) / (zPosition_[ipl2] - zPosition_[ipl1]); // slope
79  x0 = ((x2 + x1) - xs * (zPosition_[ipl2] + zPosition_[ipl1])) / 2.0; // x0
80  xq = (xQ1 + xQ2) / 2.0; // Quality, how i can do better ?
81  tracks.push_back(BeamTrack(x0, xs, xq));
82  }
83  }
84 
85  // find track with minimal slope
86  tracks.sort();
87 
88  // Return results
89  x = tracks.begin()->x;
90  xSlope = tracks.begin()->xS;
91  xQuality = tracks.begin()->xQ;
92 }
void fitHodo(float &x, float &xQuality, const int &ipl, const int &nclus, const std::vector< int > &xclus, const std::vector< int > &wclus) const
void clusterPos(float &x, float &xQuality, const int &ipl, const int &xclus, const int &wclus) const

◆ reconstruct()

EcalTBHodoscopeRecInfo EcalTBHodoscopeRecInfoAlgo::reconstruct ( const EcalTBHodoscopeRawInfo hodoscopeRawInfo) const

Fit 0

Fit 1

Fit 2

Definition at line 94 of file EcalTBHodoscopeRecInfoAlgo.cc.

References dqmdumpme::first, fitHodo(), fitLine(), fitMethod_, EcalTBHodoscopeGeometry::getNFibres(), EcalTBHodoscopeGeometry::getNPlanes(), dqmdumpme::last, myGeometry_, cms::cuda::nh, TrackingDataMCValidation_Standalone_cff::nhits, x, and y.

Referenced by EcalTBHodoscopeRecInfoProducer::produce().

94  {
95  // Reset Hodo data
96  float x, y = -100.0;
97  float xSlope, ySlope = 0.0;
98  float xQuality, yQuality = -100.0;
99 
100  int nclus[4];
101  std::vector<int> xclus[4];
102  std::vector<int> wclus[4];
103 
104  for (int ipl = 0; ipl < myGeometry_.getNPlanes(); ipl++) {
105  int nhits = hodoscopeRawInfo[ipl].numberOfFiredHits();
106  // Finding clusters
107  nclus[ipl] = 0;
108  if (nhits > 0) {
109  int nh = nhits;
110  int first = 0;
111  int last = 0;
112  while (nh > 0) {
113  while (hodoscopeRawInfo[ipl][first] == 0)
114  first++; // start
115  last = first + 1;
116  nh--;
117  do {
118  while (last < myGeometry_.getNFibres() && hodoscopeRawInfo[ipl][last]) {
119  last++;
120  nh--;
121  } //end
122  if (last + 1 < myGeometry_.getNFibres() && hodoscopeRawInfo[ipl][last + 1]) { //Skip 1 fibre hole
123  last += 2;
124  nh--;
125  //std::cout << "Skip fibre " << ipl << " " << first << " "<< last << std::endl;
126  } else {
127  break;
128  }
129  } while (nh > 0 && last < myGeometry_.getNFibres());
130  wclus[ipl].push_back(last - first);
131  xclus[ipl].push_back(first); // Left edge !!!
132  nclus[ipl]++;
133 
134  first = last + 1;
135  }
136  }
137  // printClusters(ipl);
138  }
139 
141  // Straight line fit for one axis
142  if (fitMethod_ == 0) {
143  fitLine(x,
144  xSlope,
145  xQuality,
146  0,
147  nclus[0],
148  xclus[0],
149  wclus[0], // X1
150  2,
151  nclus[2],
152  xclus[2],
153  wclus[2]); // X2
154  fitLine(y,
155  ySlope,
156  yQuality,
157  1,
158  nclus[1],
159  xclus[1],
160  wclus[1], // Y1
161  3,
162  nclus[3],
163  xclus[3],
164  wclus[3]); // Y2
165  } else if (fitMethod_ == 1) {
167  // x1 and y2 hodoscope
168  fitHodo(x, xQuality, 0, nclus[0], xclus[0], wclus[0]); // X1
169  // if ( xQuality[1] < 0.0 ) {
170  // printFibres(0);
171  // printClusters(0);
172  // }
173  fitHodo(y, yQuality, 1, nclus[1], xclus[1], wclus[1]); // Y1
174  // if ( yQuality[1] < 0.0 ) {
175  // printFibres(1);
176  // printClusters(1);
177  // }
178  } else if (fitMethod_ == 2) {
180  //x2 and y2 hodoscope
181  fitHodo(x, xQuality, 2, nclus[2], xclus[2], wclus[2]); // X2
182  // if ( xQuality[2] < 0.0 ) {
183  // printFibres(2);
184  // printClusters(2);
185  // }
186  fitHodo(y, yQuality, 3, nclus[3], xclus[3], wclus[3]); // Y2
187  // if ( yQuality[2] < 0.0 ) {
188  // printFibres(3);
189  // printClusters(3);
190  // }
191  }
192 
193  return EcalTBHodoscopeRecInfo(x, y, xSlope, ySlope, xQuality, yQuality);
194 }
void fitHodo(float &x, float &xQuality, const int &ipl, const int &nclus, const std::vector< int > &xclus, const std::vector< int > &wclus) const
uint32_t nh
EcalTBHodoscopeGeometry myGeometry_
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

Member Data Documentation

◆ fitMethod_

int EcalTBHodoscopeRecInfoAlgo::fitMethod_
private

Definition at line 62 of file EcalTBHodoscopeRecInfoAlgo.h.

Referenced by reconstruct().

◆ myGeometry_

EcalTBHodoscopeGeometry EcalTBHodoscopeRecInfoAlgo::myGeometry_
private

Definition at line 68 of file EcalTBHodoscopeRecInfoAlgo.h.

Referenced by clusterPos(), and reconstruct().

◆ planeShift_

std::vector<double> EcalTBHodoscopeRecInfoAlgo::planeShift_
private

Definition at line 64 of file EcalTBHodoscopeRecInfoAlgo.h.

Referenced by clusterPos().

◆ zPosition_

std::vector<double> EcalTBHodoscopeRecInfoAlgo::zPosition_
private

Definition at line 65 of file EcalTBHodoscopeRecInfoAlgo.h.

Referenced by fitLine().