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 isBadPot) {
33  Road temp_all_hits;
34  temp_all_hits.clear();
35 
36  Road temp_all_hits_badPot;
37  temp_all_hits_badPot.clear();
38 
39  // convert local hit sto global and push them to a vector
40  for (const auto& ds_rh2 : *hitVector_) {
41  const auto myid = CTPPSPixelDetId(ds_rh2.id);
42  for (const auto& it_rh : ds_rh2.data) {
43  CTPPSGeometry::Vector localV(it_rh.point().x(), it_rh.point().y(), it_rh.point().z());
44  const auto& globalV = geometry_->localToGlobal(ds_rh2.id, localV);
45  math::Error<3>::type localError;
46  localError[0][0] = it_rh.error().xx();
47  localError[0][1] = it_rh.error().xy();
48  localError[0][2] = 0.;
49  localError[1][0] = it_rh.error().xy();
50  localError[1][1] = it_rh.error().yy();
51  localError[1][2] = 0.;
52  localError[2][0] = 0.;
53  localError[2][1] = 0.;
54  localError[2][2] = 0.;
55  if (verbosity_ > 2)
56  edm::LogInfo("RPixRoadFinder") << "Hits = " << ds_rh2.data.size();
57 
58  DetGeomDesc::RotationMatrix theRotationMatrix = geometry_->sensor(myid)->rotation();
59  AlgebraicMatrix33 theRotationTMatrix;
60  theRotationMatrix.GetComponents(theRotationTMatrix(0, 0),
61  theRotationTMatrix(0, 1),
62  theRotationTMatrix(0, 2),
63  theRotationTMatrix(1, 0),
64  theRotationTMatrix(1, 1),
65  theRotationTMatrix(1, 2),
66  theRotationTMatrix(2, 0),
67  theRotationTMatrix(2, 1),
68  theRotationTMatrix(2, 2));
69 
70  math::Error<3>::type globalError = ROOT::Math::SimilarityT(theRotationTMatrix, localError);
71 
72  // create new collection for planes 0 and 5 of pot 45-220-fr
73 
74  if (isBadPot == true && myid.arm() == 0 && myid.station() == 2 && localV.x() > 0 &&
75  (myid.plane() == 0 || myid.plane() == 5)) { // 45-220-far
76 
77  temp_all_hits_badPot.emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
78  }
79  temp_all_hits.emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
80  }
81  }
82 
83  Road::iterator it_gh1 = temp_all_hits.begin();
84  Road::iterator it_gh2;
85 
86  patternVector_.clear();
87 
88  //look for points near wrt each other
89  // starting algorithm
90  while (it_gh1 != temp_all_hits.end() && temp_all_hits.size() >= minRoadSize_) {
91  Road temp_road;
92 
93  it_gh2 = it_gh1;
94 
95  const auto currPoint = it_gh1->globalPoint;
96  CTPPSPixelDetId currDet = CTPPSPixelDetId(it_gh1->detId);
97 
98  while (it_gh2 != temp_all_hits.end()) {
99  bool same_pot = false;
100  CTPPSPixelDetId tmpGh2Id = CTPPSPixelDetId(it_gh2->detId);
101  if (currDet.rpId() == tmpGh2Id.rpId())
102  same_pot = true;
103  const auto subtraction = currPoint - it_gh2->globalPoint;
104 
105  if (subtraction.Rho() < roadRadius_ && same_pot) {
106  temp_road.push_back(*it_gh2);
107  temp_all_hits.erase(it_gh2);
108  } else {
109  ++it_gh2;
110  }
111  }
112 
113  if (temp_road.size() >= minRoadSize_ && temp_road.size() < maxRoadSize_)
114  patternVector_.push_back(temp_road);
115  }
116  // end of algorithm
117 
118  // badPot algorithm
119  Road::iterator it_gh1_bP = temp_all_hits_badPot.begin();
120  Road::iterator it_gh2_bP;
121 
122  while (it_gh1_bP != temp_all_hits_badPot.end() && temp_all_hits_badPot.size() >= 2) {
123  Road temp_road;
124 
125  it_gh2_bP = it_gh1_bP;
126 
127  const auto currPoint = it_gh1_bP->globalPoint;
128 
129  while (it_gh2_bP != temp_all_hits_badPot.end()) {
130  const auto subtraction = currPoint - it_gh2_bP->globalPoint;
131 
132  if (subtraction.Rho() < roadRadiusBadPot_) {
133  temp_road.push_back(*it_gh2_bP);
134  temp_all_hits_badPot.erase(it_gh2_bP);
135  } else {
136  ++it_gh2_bP;
137  }
138  }
139 
140  if (temp_road.size() == 2) { // look for isolated tracks
141  patternVector_.push_back(temp_road);
142  }
143  }
144 }
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_
void findPattern(bool isbadpot) override
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:78
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_
~RPixRoadFinder() override
ROOT::Math::Rotation3D RotationMatrix
Definition: DetGeomDesc.h:54