CMS 3D CMS Logo

RPixRoadFinder.cc
Go to the documentation of this file.
1 
3 
4 // user include files
7 
11 
13 
14 
15 //needed for the geometry:
18 
19 #include "TMath.h"
22 
23 #include <vector>
24 #include <memory>
25 #include <string>
26 #include <iostream>
27 
28 //------------------------------------------------------------------------------------------------//
29 
31  RPixDetPatternFinder(parameterSet){
32 
33  verbosity_ = parameterSet.getUntrackedParameter<int> ("verbosity");
34  roadRadius_ = parameterSet.getParameter<double>("roadRadius");
35  minRoadSize_ = parameterSet.getParameter<int>("minRoadSize");
36  maxRoadSize_ = parameterSet.getParameter<int>("maxRoadSize");
37 
38 }
39 
40 //------------------------------------------------------------------------------------------------//
41 
43 }
44 
45 //------------------------------------------------------------------------------------------------//
46 
48 
49  Road temp_all_hits;
50  temp_all_hits.clear();
51 
52 // convert local hit sto global and push them to a vector
53  for(const auto & ds_rh2 : *hitVector_){
54  const auto myid = CTPPSPixelDetId(ds_rh2.id);
55  for (const auto & it_rh : ds_rh2.data){
56  CLHEP::Hep3Vector localV(it_rh.getPoint().x(),it_rh.getPoint().y(),it_rh.getPoint().z() );
57  CLHEP::Hep3Vector globalV = geometry_->localToGlobal(ds_rh2.id,localV);
58  math::Error<3>::type localError;
59  localError[0][0] = it_rh.getError().xx();
60  localError[0][1] = it_rh.getError().xy();
61  localError[0][2] = 0.;
62  localError[1][0] = it_rh.getError().xy();
63  localError[1][1] = it_rh.getError().yy();
64  localError[1][2] = 0.;
65  localError[2][0] = 0.;
66  localError[2][1] = 0.;
67  localError[2][2] = 0.;
68  if(verbosity_>2) edm::LogInfo("RPixRoadFinder")<<"Hits = "<<ds_rh2.data.size();
69 
70  DDRotationMatrix theRotationMatrix = geometry_->getSensor(myid)->rotation();
71  AlgebraicMatrix33 theRotationTMatrix;
72  theRotationMatrix.GetComponents(theRotationTMatrix(0, 0), theRotationTMatrix(0, 1), theRotationTMatrix(0, 2),
73  theRotationTMatrix(1, 0), theRotationTMatrix(1, 1), theRotationTMatrix(1, 2),
74  theRotationTMatrix(2, 0), theRotationTMatrix(2, 1), theRotationTMatrix(2, 2));
75 
76  math::Error<3>::type globalError = ROOT::Math::SimilarityT(theRotationTMatrix, localError);
77  PointInPlane thePointAndRecHit = {globalV,globalError,it_rh,myid};
78  temp_all_hits.push_back(thePointAndRecHit);
79  }
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  CLHEP::Hep3Vector 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.getRPId() == tmpGh2Id.getRPId() ) same_pot = true;
102  CLHEP::Hep3Vector subtraction = currPoint - it_gh2->globalPoint;
103 
104  if(subtraction.perp() < roadRadius_ && same_pot) {
105  temp_road.push_back(*it_gh2);
106  temp_all_hits.erase(it_gh2);
107  }else{
108  ++it_gh2;
109  }
110 
111  }
112 
113  if(temp_road.size() >= minRoadSize_ && temp_road.size() < maxRoadSize_ )patternVector_.push_back(temp_road);
114 
115  }
116 // end of algorithm
117 
118 
119 
120 }
121 
122 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
DDRotationMatrix rotation() const
geometry information
Definition: DetGeomDesc.h:83
unsigned int maxRoadSize_
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
ErrorD< N >::type type
Definition: Error.h:33
std::vector< PointInPlane > Road
const DetGeomDesc * getSensor(unsigned int id) const
returns geometry of a detector performs necessary checks, returns NULL if fails
const CTPPSGeometry * geometry_
const edm::DetSetVector< CTPPSPixelRecHit > * hitVector_
RPixRoadFinder(const edm::ParameterSet &param)
CTPPSDetId getRPId() const
Definition: CTPPSDetId.h:97
void findPattern() override
CLHEP::Hep3Vector localToGlobal(const DetGeomDesc *, const CLHEP::Hep3Vector &) const
std::vector< Road > patternVector_
unsigned int minRoadSize_
~RPixRoadFinder() override
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33