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
 
 ~EcalTBHodoscopeRecInfoAlgo ()
 

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_
 
EcalTBHodoscopeGeometrymyGeometry_
 
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

◆ ~EcalTBHodoscopeRecInfoAlgo()

EcalTBHodoscopeRecInfoAlgo::~EcalTBHodoscopeRecInfoAlgo ( )
inline

Definition at line 19 of file EcalTBHodoscopeRecInfoAlgo.h.

References myGeometry_.

19  {
20  if (myGeometry_)
21  delete myGeometry_;
22  };
EcalTBHodoscopeGeometry * myGeometry_

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 13 of file EcalTBHodoscopeRecInfoAlgo.cc.

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

Referenced by fitHodo(), and fitLine().

14  {
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 }
static float getFibreLp(int plane, int fibre)
static float getFibreRp(int plane, int fibre)
EcalTBHodoscopeGeometry * myGeometry_

◆ 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 31 of file EcalTBHodoscopeRecInfoAlgo.cc.

References clusterPos(), and x.

Referenced by fitLine(), and reconstruct().

36  {
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 }
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 47 of file EcalTBHodoscopeRecInfoAlgo.cc.

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

Referenced by reconstruct().

57  {
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 }
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
auto const & tracks
cannot be loose

◆ reconstruct()

EcalTBHodoscopeRecInfo EcalTBHodoscopeRecInfoAlgo::reconstruct ( const EcalTBHodoscopeRawInfo hodoscopeRawInfo) const

Fit 0

Fit 1

Fit 2

Definition at line 97 of file EcalTBHodoscopeRecInfoAlgo.cc.

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

Referenced by EcalTBHodoscopeRecInfoProducer::produce().

97  {
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 }
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
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
EcalTBHodoscopeGeometry * myGeometry_

Member Data Documentation

◆ fitMethod_

int EcalTBHodoscopeRecInfoAlgo::fitMethod_
private

Definition at line 67 of file EcalTBHodoscopeRecInfoAlgo.h.

Referenced by reconstruct().

◆ myGeometry_

EcalTBHodoscopeGeometry* EcalTBHodoscopeRecInfoAlgo::myGeometry_
private

◆ planeShift_

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

Definition at line 69 of file EcalTBHodoscopeRecInfoAlgo.h.

Referenced by clusterPos().

◆ zPosition_

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

Definition at line 70 of file EcalTBHodoscopeRecInfoAlgo.h.

Referenced by fitLine().