CMS 3D CMS Logo

RPixRoadFinder.cc
Go to the documentation of this file.
1 
3 
4 // user include files
6 
7 #include "TMath.h"
10 
11 #include <vector>
12 #include <memory>
13 #include <string>
14 #include <iostream>
15 
16 //------------------------------------------------------------------------------------------------//
17 
19  verbosity_ = parameterSet.getUntrackedParameter<int>("verbosity");
20  roadRadius_ = parameterSet.getParameter<double>("roadRadius");
21  minRoadSize_ = parameterSet.getParameter<int>("minRoadSize");
22  maxRoadSize_ = parameterSet.getParameter<int>("maxRoadSize");
23  roadRadiusBadPot_ = parameterSet.getParameter<double>("roadRadiusBadPot");
24 }
25 
26 //------------------------------------------------------------------------------------------------//
27 
29 
30 //------------------------------------------------------------------------------------------------//
31 
32 void RPixRoadFinder::findPattern(bool* is2PlanePot) {
33  Road temp_all_hits;
34  Road temp_all_hits_2PlanePot[4];
35 
36  // convert local hit sto global and push them to a vector
37  for (const auto& ds_rh2 : *hitVector_) {
38  const auto myid = CTPPSPixelDetId(ds_rh2.id);
39  for (const auto& it_rh : ds_rh2.data) {
40  CTPPSGeometry::Vector localV(it_rh.point().x(), it_rh.point().y(), it_rh.point().z());
41  const auto& globalV = geometry_->localToGlobal(ds_rh2.id, localV);
42  math::Error<3>::type localError;
43  localError[0][0] = it_rh.error().xx();
44  localError[0][1] = it_rh.error().xy();
45  localError[0][2] = 0.;
46  localError[1][0] = it_rh.error().xy();
47  localError[1][1] = it_rh.error().yy();
48  localError[1][2] = 0.;
49  localError[2][0] = 0.;
50  localError[2][1] = 0.;
51  localError[2][2] = 0.;
52  if (verbosity_ > 2)
53  edm::LogInfo("RPixRoadFinder") << "Hits = " << ds_rh2.data.size();
54 
55  DetGeomDesc::RotationMatrix theRotationMatrix = geometry_->sensor(myid)->rotation();
56  AlgebraicMatrix33 theRotationTMatrix;
57  theRotationMatrix.GetComponents(theRotationTMatrix(0, 0),
58  theRotationTMatrix(0, 1),
59  theRotationTMatrix(0, 2),
60  theRotationTMatrix(1, 0),
61  theRotationTMatrix(1, 1),
62  theRotationTMatrix(1, 2),
63  theRotationTMatrix(2, 0),
64  theRotationTMatrix(2, 1),
65  theRotationTMatrix(2, 2));
66 
67  math::Error<3>::type globalError = ROOT::Math::SimilarityT(theRotationTMatrix, localError);
68 
69  // create new collections for bad (2 planes) and good pots
70 
71  if (is2PlanePot[0] == true && myid.arm() == 0 && myid.station() == 2) { // 45-220
72  temp_all_hits_2PlanePot[0].emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
73  } else if (is2PlanePot[1] == true && myid.arm() == 0 && myid.station() == 0) { // 45-210
74  temp_all_hits_2PlanePot[1].emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
75  } else if (is2PlanePot[2] == true && myid.arm() == 1 && myid.station() == 0) { // 56-210
76  temp_all_hits_2PlanePot[2].emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
77  } else if (is2PlanePot[3] == true && myid.arm() == 1 && myid.station() == 2) { // 56-220
78  temp_all_hits_2PlanePot[3].emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
79  } else {
80  temp_all_hits.emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
81  }
82  }
83  }
84 
85  Road::iterator it_gh1 = temp_all_hits.begin();
86  Road::iterator it_gh2;
87 
88  patternVector_.clear();
89 
90  //look for points near wrt each other
91  // starting algorithm
92  while (it_gh1 != temp_all_hits.end() && temp_all_hits.size() >= minRoadSize_) {
93  Road temp_road;
94 
95  it_gh2 = it_gh1;
96 
97  const auto currPoint = it_gh1->globalPoint;
98  CTPPSPixelDetId currDet = CTPPSPixelDetId(it_gh1->detId);
99 
100  while (it_gh2 != temp_all_hits.end()) {
101  bool same_pot = false;
102  CTPPSPixelDetId tmpGh2Id = CTPPSPixelDetId(it_gh2->detId);
103  if (currDet.rpId() == tmpGh2Id.rpId())
104  same_pot = true;
105  const auto subtraction = currPoint - it_gh2->globalPoint;
106 
107  if (subtraction.Rho() < roadRadius_ && same_pot) {
108  temp_road.push_back(*it_gh2);
109  temp_all_hits.erase(it_gh2);
110  } else {
111  ++it_gh2;
112  }
113  }
114 
115  if (temp_road.size() >= minRoadSize_ && temp_road.size() < maxRoadSize_)
116  patternVector_.push_back(temp_road);
117  }
118  // end of algorithm
119 
120  // 2PlanePot algorithm
121 
122  for (unsigned int i = 0; i < 4; i++) {
123  if (is2PlanePot[i]) {
124  Road::iterator it_gh1_bP = temp_all_hits_2PlanePot[i].begin();
125  Road::iterator it_gh2_bP;
126 
127  while (it_gh1_bP != temp_all_hits_2PlanePot[i].end() && temp_all_hits_2PlanePot[i].size() >= 2) {
128  Road temp_road;
129 
130  it_gh2_bP = it_gh1_bP;
131 
132  const auto currPoint = it_gh1_bP->globalPoint;
133 
134  while (it_gh2_bP != temp_all_hits_2PlanePot[i].end()) {
135  const auto subtraction = currPoint - it_gh2_bP->globalPoint;
136 
137  if (subtraction.Rho() < roadRadiusBadPot_) {
138  temp_road.push_back(*it_gh2_bP);
139  temp_all_hits_2PlanePot[i].erase(it_gh2_bP);
140  } else {
141  ++it_gh2_bP;
142  }
143  }
144 
145  if (temp_road.size() == 2) { // look for isolated tracks
146  patternVector_.push_back(temp_road);
147  }
148  }
149  }
150  }
151 }
size
Write out results.
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33
unsigned int maxRoadSize_
ErrorD< N >::type type
Definition: Error.h:32
std::vector< PointInPlane > Road
Vector localToGlobal(const DetGeomDesc *, const Vector &) const
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
DetGeomDesc::Translation Vector
Definition: CTPPSGeometry.h:36
T getUntrackedParameter(std::string const &, T const &) const
const CTPPSGeometry * geometry_
const edm::DetSetVector< CTPPSPixelRecHit > * hitVector_
CTPPSDetId rpId() const
Definition: CTPPSDetId.h:84
RPixRoadFinder(const edm::ParameterSet &param)
const DetGeomDesc * sensor(unsigned int id) const
returns geometry of a detector performs necessary checks, returns NULL if fails
std::vector< Road > patternVector_
Log< level::Info, false > LogInfo
double roadRadiusBadPot_
const RotationMatrix & rotation() const
Definition: DetGeomDesc.h:81
unsigned int minRoadSize_
void findPattern(bool *is2planepot) override
~RPixRoadFinder() override
ROOT::Math::Rotation3D RotationMatrix
Definition: DetGeomDesc.h:54