CMS 3D CMS Logo

RPixRoadFinder.cc
Go to the documentation of this file.
1 
3 
4 // user include files
7 
11 
13 
14 //needed for the geometry:
17 
18 #include "TMath.h"
21 
22 #include <vector>
23 #include <memory>
24 #include <string>
25 #include <iostream>
26 
27 //------------------------------------------------------------------------------------------------//
28 
30  verbosity_ = parameterSet.getUntrackedParameter<int>("verbosity");
31  roadRadius_ = parameterSet.getParameter<double>("roadRadius");
32  minRoadSize_ = parameterSet.getParameter<int>("minRoadSize");
33  maxRoadSize_ = parameterSet.getParameter<int>("maxRoadSize");
34 }
35 
36 //------------------------------------------------------------------------------------------------//
37 
39 
40 //------------------------------------------------------------------------------------------------//
41 
43  Road temp_all_hits;
44  temp_all_hits.clear();
45 
46  // convert local hit sto global and push them to a vector
47  for (const auto& ds_rh2 : *hitVector_) {
48  const auto myid = CTPPSPixelDetId(ds_rh2.id);
49  for (const auto& it_rh : ds_rh2.data) {
50  CTPPSGeometry::Vector localV(it_rh.point().x(), it_rh.point().y(), it_rh.point().z());
51  const auto& globalV = geometry_->localToGlobal(ds_rh2.id, localV);
52  math::Error<3>::type localError;
53  localError[0][0] = it_rh.error().xx();
54  localError[0][1] = it_rh.error().xy();
55  localError[0][2] = 0.;
56  localError[1][0] = it_rh.error().xy();
57  localError[1][1] = it_rh.error().yy();
58  localError[1][2] = 0.;
59  localError[2][0] = 0.;
60  localError[2][1] = 0.;
61  localError[2][2] = 0.;
62  if (verbosity_ > 2)
63  edm::LogInfo("RPixRoadFinder") << "Hits = " << ds_rh2.data.size();
64 
65  DetGeomDesc::RotationMatrix theRotationMatrix = geometry_->sensor(myid)->rotation();
66  AlgebraicMatrix33 theRotationTMatrix;
67  theRotationMatrix.GetComponents(theRotationTMatrix(0, 0),
68  theRotationTMatrix(0, 1),
69  theRotationTMatrix(0, 2),
70  theRotationTMatrix(1, 0),
71  theRotationTMatrix(1, 1),
72  theRotationTMatrix(1, 2),
73  theRotationTMatrix(2, 0),
74  theRotationTMatrix(2, 1),
75  theRotationTMatrix(2, 2));
76 
77  math::Error<3>::type globalError = ROOT::Math::SimilarityT(theRotationTMatrix, localError);
78  PointInPlane thePointAndRecHit = {globalV, globalError, it_rh, myid};
79  temp_all_hits.push_back(thePointAndRecHit);
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 }
RPixRoadFinder::~RPixRoadFinder
~RPixRoadFinder() override
Definition: RPixRoadFinder.cc:38
RPixDetPatternFinder::hitVector_
const edm::DetSetVector< CTPPSPixelRecHit > * hitVector_
Definition: RPixDetPatternFinder.h:47
EDProducer.h
ESHandle.h
RPixRoadFinder::verbosity_
int verbosity_
Definition: RPixRoadFinder.h:43
RPixRoadFinder::findPattern
void findPattern() override
Definition: RPixRoadFinder.cc:42
AlgebraicMatrix33
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33
Definition: AlgebraicROOTObjects.h:41
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
RPixRoadFinder::roadRadius_
double roadRadius_
Definition: RPixRoadFinder.h:44
RPixDetPatternFinder::Road
std::vector< PointInPlane > Road
Definition: RPixDetPatternFinder.h:38
MakerMacros.h
RPixRoadFinder::RPixRoadFinder
RPixRoadFinder(const edm::ParameterSet &param)
Definition: RPixRoadFinder.cc:29
RPixDetPatternFinder::PointInPlane
Definition: RPixDetPatternFinder.h:32
RPixRoadFinder::minRoadSize_
unsigned int minRoadSize_
Definition: RPixRoadFinder.h:45
Error.h
edm::ParameterSet
Definition: ParameterSet.h:47
RPixRoadFinder::maxRoadSize_
unsigned int maxRoadSize_
Definition: RPixRoadFinder.h:46
RPixRoadFinder.h
Event.h
CTPPSPixelDetId
Definition: CTPPSPixelDetId.h:16
RPixDetPatternFinder::geometry_
const CTPPSGeometry * geometry_
Definition: RPixDetPatternFinder.h:49
Frameworkfwd.h
math::Error::type
ErrorD< N >::type type
Definition: Error.h:32
edm::parameterSet
ParameterSet const & parameterSet(Provenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ParameterSet.h
DetGeomDesc::RotationMatrix
ROOT::Math::Rotation3D RotationMatrix
Definition: DetGeomDesc.h:52
CTPPSDetId::rpId
CTPPSDetId rpId() const
Definition: CTPPSDetId.h:82
DetGeomDesc::rotation
const RotationMatrix & rotation() const
Definition: DetGeomDesc.h:74
CTPPSGeometry::localToGlobal
Vector localToGlobal(const DetGeomDesc *, const Vector &) const
Definition: CTPPSGeometry.cc:158
AlgebraicROOTObjects.h
RPixDetPatternFinder
Definition: RPixDetPatternFinder.h:26
CTPPSGeometry::sensor
const DetGeomDesc * sensor(unsigned int id) const
returns geometry of a detector performs necessary checks, returns NULL if fails
Definition: CTPPSGeometry.cc:91
RPixDetPatternFinder::patternVector_
std::vector< Road > patternVector_
Definition: RPixDetPatternFinder.h:48
CTPPSGeometry::Vector
DetGeomDesc::Translation Vector
Definition: CTPPSGeometry.h:39