test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CACell.h
Go to the documentation of this file.
1 #ifndef RECOPIXELVERTEXING_PIXELTRIPLETS_CACELL_h
2 #define RECOPIXELVERTEXING_PIXELTRIPLETS_CACELL_h
3 
7 
9 
10 #include <cmath>
11 #include <array>
12 
13 class CACell {
14 public:
16  using CAntuplet = std::vector<CACell*>;
17 
18  CACell(const HitDoublets* doublets, int doubletId, const unsigned int cellId, const int innerHitId, const int outerHitId) :
19  theCAState(0), theInnerHitId(innerHitId), theOuterHitId(outerHitId), theCellId(cellId), hasSameStateNeighbors(0), theDoublets(doublets), theDoubletId(doubletId),
20  theInnerR(doublets->r(doubletId, HitDoublets::inner)), theOuterR(doublets->r(doubletId, HitDoublets::outer)),
21  theInnerZ(doublets->z(doubletId, HitDoublets::inner)), theOuterZ(doublets->z(doubletId, HitDoublets::outer)) {
22  }
23 
24  unsigned int getCellId() const {
25  return theCellId;
26  }
27 
28  Hit const & getInnerHit() const {
30  }
31 
32  Hit const & getOuterHit() const {
34  }
35 
36  float getInnerX() const {
38  }
39 
40  float getOuterX() const {
42  }
43 
44  float getInnerY() const {
46  }
47 
48  float getOuterY() const {
50  }
51 
52  float getInnerZ() const {
53  return theInnerZ;
54  }
55 
56  float getOuterZ() const {
57  return theOuterZ;
58  }
59 
60  float getInnerR() const {
61  return theInnerR;
62  }
63 
64  float getOuterR() const {
65  return theOuterR;
66  }
67 
68  float getInnerPhi() const {
70  }
71 
72  float getOuterPhi() const {
74  }
75 
76  unsigned int getInnerHitId() const {
77  return theInnerHitId;
78  }
79 
80  unsigned int getOuterHitId() const {
81  return theOuterHitId;
82  }
83 
84  void evolve() {
85 
87  unsigned int numberOfNeighbors = theOuterNeighbors.size();
88 
89  for (unsigned int i = 0; i < numberOfNeighbors; ++i) {
90 
92 
94 
95  break;
96  }
97  }
98 
99  }
100 
101 
102  void checkAlignmentAndTag(CACell* innerCell, const float ptmin, const float region_origin_x,
103  const float region_origin_y, const float region_origin_radius, const float thetaCut,
104  const float phiCut, const float hardPtCut) {
105 
106  if (areAlignedRZ(innerCell, ptmin, thetaCut) &&
107  haveSimilarCurvature(innerCell,ptmin, region_origin_x, region_origin_y,
108  region_origin_radius, phiCut, hardPtCut)) {
109  tagAsInnerNeighbor(innerCell);
110  innerCell->tagAsOuterNeighbor(this);
111  }
112  }
113 
114  void checkAlignmentAndPushTriplet(CACell* innerCell, std::vector<CACell::CAntuplet>& foundTriplets,
115  const float ptmin, const float region_origin_x, const float region_origin_y,
116  const float region_origin_radius, const float thetaCut, const float phiCut,
117  const float hardPtCut) {
118 
119  if (areAlignedRZ(innerCell, ptmin, thetaCut) &&
120  haveSimilarCurvature(innerCell,ptmin, region_origin_x, region_origin_y,
121  region_origin_radius, phiCut, hardPtCut)) {
122  foundTriplets.emplace_back(CACell::CAntuplet{innerCell,this});
123 
124  }
125  }
126 
127 
128 
129  bool areAlignedRZ(const CACell* otherCell, const float ptmin, const float thetaCut) const
130  {
131 
132  float r1 = otherCell->getInnerR();
133  float z1 = otherCell->getInnerZ();
134  float radius_diff = std::abs(r1 - theOuterR);
135  float distance_13_squared = radius_diff*radius_diff + (z1 - theOuterZ)*(z1 - theOuterZ);
136 
137  float pMin = ptmin*std::sqrt(distance_13_squared); //this needs to be divided by radius_diff later
138 
139  float tan_12_13_half_mul_distance_13_squared = fabs(z1 * (theInnerR - theOuterR) + theInnerZ * (theOuterR - r1) + theOuterZ * (r1 - theInnerR)) ;
140  return tan_12_13_half_mul_distance_13_squared * pMin <= thetaCut * distance_13_squared * radius_diff;
141  }
142 
143  void tagAsOuterNeighbor(CACell* otherCell)
144  {
145  theOuterNeighbors.push_back(otherCell);
146  }
147 
148  void tagAsInnerNeighbor(CACell* otherCell)
149  {
150  theInnerNeighbors.push_back(otherCell);
151  }
152 
153  bool haveSimilarCurvature(const CACell* otherCell, const float ptmin,
154  const float region_origin_x, const float region_origin_y, const float region_origin_radius, const float phiCut, const float hardPtCut) const
155  {
156 
157 
158  auto x1 = otherCell->getInnerX();
159  auto y1 = otherCell->getInnerY();
160 
161  auto x2 = getInnerX();
162  auto y2 = getInnerY();
163 
164  auto x3 = getOuterX();
165  auto y3 = getOuterY();
166 
167  float distance_13_squared = (x1 - x3)*(x1 - x3) + (y1 - y3)*(y1 - y3);
168  float tan_12_13_half_mul_distance_13_squared = std::abs(y1 * (x2 - x3) + y2 * (x3 - x1) + y3 * (x1 - x2)) ;
169  if(tan_12_13_half_mul_distance_13_squared * ptmin <= 1.0e-4f*distance_13_squared)
170  {
171 
172  float distance_3_beamspot_squared = (x3-region_origin_x) * (x3-region_origin_x) + (y3-region_origin_y) * (y3-region_origin_y);
173 
174  float dot_bs3_13 = ((x1 - x3)*( region_origin_x - x3) + (y1 - y3) * (region_origin_y-y3));
175  float proj_bs3_on_13_squared = dot_bs3_13*dot_bs3_13/distance_13_squared;
176 
177  float distance_13_beamspot_squared = distance_3_beamspot_squared - proj_bs3_on_13_squared;
178 
179  if(distance_13_beamspot_squared > (region_origin_radius+phiCut)*(region_origin_radius+phiCut) )
180  {
181  return false;
182  }
183  return true;
184  }
185 
186  //87 cm/GeV = 1/(3.8T * 0.3)
187 
188  //take less than radius given by the hardPtCut and reject everything below
189  float minRadius = hardPtCut*87.f;
190 
191  auto det = (x1 - x2) * (y2 - y3) - (x2 - x3) * (y1 - y2);
192 
193 
194  auto offset = x2 * x2 + y2*y2;
195 
196  auto bc = (x1 * x1 + y1 * y1 - offset)*0.5f;
197 
198  auto cd = (offset - x3 * x3 - y3 * y3)*0.5f;
199 
200 
201 
202  auto idet = 1.f / det;
203 
204  auto x_center = (bc * (y2 - y3) - cd * (y1 - y2)) * idet;
205  auto y_center = (cd * (x1 - x2) - bc * (x2 - x3)) * idet;
206 
207  auto radius = std::sqrt((x2 - x_center)*(x2 - x_center) + (y2 - y_center)*(y2 - y_center));
208 
209  if(radius < minRadius)
210  return false;
211  auto centers_distance_squared = (x_center - region_origin_x)*(x_center - region_origin_x) + (y_center - region_origin_y)*(y_center - region_origin_y);
212  auto region_origin_radius_plus_tolerance = region_origin_radius + phiCut;
213  auto minimumOfIntersectionRange = (radius - region_origin_radius_plus_tolerance)*(radius - region_origin_radius_plus_tolerance);
214 
215  if (centers_distance_squared >= minimumOfIntersectionRange) {
216  auto maximumOfIntersectionRange = (radius + region_origin_radius_plus_tolerance)*(radius + region_origin_radius_plus_tolerance);
217  return centers_distance_squared <= maximumOfIntersectionRange;
218  }
219 
220  return false;
221 
222 
223 
224  }
225 
226  unsigned int getCAState() const {
227  return theCAState;
228  }
229  // if there is at least one left neighbor with the same state (friend), the state has to be increased by 1.
230 
231  void updateState() {
233  }
234 
235  bool isRootCell(const unsigned int minimumCAState) const {
236  return (theCAState >= minimumCAState);
237  }
238 
239  // trying to free the track building process from hardcoded layers, leaving the visit of the graph
240  // based on the neighborhood connections between cells.
241 
242  void findNtuplets(std::vector<CAntuplet>& foundNtuplets, CAntuplet& tmpNtuplet, const unsigned int minHitsPerNtuplet) const {
243 
244  // the building process for a track ends if:
245  // it has no outer neighbor
246  // it has no compatible neighbor
247  // the ntuplets is then saved if the number of hits it contains is greater than a threshold
248 
249  if (tmpNtuplet.size() == minHitsPerNtuplet - 1)
250  {
251  foundNtuplets.push_back(tmpNtuplet);
252  }
253  else
254  {
255  if(theOuterNeighbors.size() == 0)
256  {
257  return;
258  }
259  else
260  {
261  unsigned int numberOfOuterNeighbors = theOuterNeighbors.size();
262  for (unsigned int i = 0; i < numberOfOuterNeighbors; ++i) {
263  tmpNtuplet.push_back((theOuterNeighbors[i]));
264  theOuterNeighbors[i]->findNtuplets(foundNtuplets, tmpNtuplet, minHitsPerNtuplet);
265  tmpNtuplet.pop_back();
266  }
267  }
268 
269  }
270 
271  }
272 
273 
274 private:
275  std::vector<CACell*> theInnerNeighbors;
276  std::vector<CACell*> theOuterNeighbors;
277 
278  unsigned int theCAState;
279 
280  const unsigned int theInnerHitId;
281  const unsigned int theOuterHitId;
282  const unsigned int theCellId;
283  unsigned int hasSameStateNeighbors;
284 
286  const int theDoubletId;
287 
288  const float theInnerR;
289  const float theOuterR;
290  const float theInnerZ;
291  const float theOuterZ;
292 
293 };
294 
295 
296 #endif /*CACELL_H_ */
int i
Definition: DBlmapReader.cc:9
const float theInnerZ
Definition: CACell.h:290
const HitDoublets * theDoublets
Definition: CACell.h:285
const unsigned int theInnerHitId
Definition: CACell.h:280
float getInnerZ() const
Definition: CACell.h:52
float x(int i, layer l) const
void tagAsOuterNeighbor(CACell *otherCell)
Definition: CACell.h:143
bool isRootCell(const unsigned int minimumCAState) const
Definition: CACell.h:235
float getOuterR() const
Definition: CACell.h:64
const int theDoubletId
Definition: CACell.h:286
float getOuterZ() const
Definition: CACell.h:56
unsigned int getCAState() const
Definition: CACell.h:226
const float theOuterR
Definition: CACell.h:289
float getInnerY() const
Definition: CACell.h:44
float getOuterPhi() const
Definition: CACell.h:72
Hit const & getInnerHit() const
Definition: CACell.h:28
bool areAlignedRZ(const CACell *otherCell, const float ptmin, const float thetaCut) const
Definition: CACell.h:129
std::vector< CACell * > theInnerNeighbors
Definition: CACell.h:275
T sqrt(T t)
Definition: SSEVec.h:18
const float theInnerR
Definition: CACell.h:288
float getInnerR() const
Definition: CACell.h:60
float getOuterX() const
Definition: CACell.h:40
bool haveSimilarCurvature(const CACell *otherCell, const float ptmin, const float region_origin_x, const float region_origin_y, const float region_origin_radius, const float phiCut, const float hardPtCut) const
Definition: CACell.h:153
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
float getInnerX() const
Definition: CACell.h:36
void tagAsInnerNeighbor(CACell *otherCell)
Definition: CACell.h:148
float getOuterY() const
Definition: CACell.h:48
unsigned int getCellId() const
Definition: CACell.h:24
float y(int i, layer l) const
void checkAlignmentAndTag(CACell *innerCell, const float ptmin, const float region_origin_x, const float region_origin_y, const float region_origin_radius, const float thetaCut, const float phiCut, const float hardPtCut)
Definition: CACell.h:102
float getInnerPhi() const
Definition: CACell.h:68
Hit const & getOuterHit() const
Definition: CACell.h:32
BaseTrackerRecHit const * Hit
void findNtuplets(std::vector< CAntuplet > &foundNtuplets, CAntuplet &tmpNtuplet, const unsigned int minHitsPerNtuplet) const
Definition: CACell.h:242
void evolve()
Definition: CACell.h:84
unsigned int getInnerHitId() const
Definition: CACell.h:76
float phi(int i, layer l) const
Definition: CACell.h:13
const unsigned int theCellId
Definition: CACell.h:282
unsigned int getOuterHitId() const
Definition: CACell.h:80
CACell(const HitDoublets *doublets, int doubletId, const unsigned int cellId, const int innerHitId, const int outerHitId)
Definition: CACell.h:18
double ptmin
Definition: HydjetWrapper.h:90
Hit const & hit(int i, layer l) const
void updateState()
Definition: CACell.h:231
void checkAlignmentAndPushTriplet(CACell *innerCell, std::vector< CACell::CAntuplet > &foundTriplets, const float ptmin, const float region_origin_x, const float region_origin_y, const float region_origin_radius, const float thetaCut, const float phiCut, const float hardPtCut)
Definition: CACell.h:114
const float theOuterZ
Definition: CACell.h:291
unsigned int theCAState
Definition: CACell.h:278
unsigned int hasSameStateNeighbors
Definition: CACell.h:283
std::vector< CACell * > CAntuplet
Definition: CACell.h:16
std::vector< CACell * > theOuterNeighbors
Definition: CACell.h:276
const unsigned int theOuterHitId
Definition: CACell.h:281