Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-22 22:47:28

0001 
0002 #include "RecoPPS/Local/interface/RPixRoadFinder.h"
0003 
0004 // user include files
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 
0007 #include "TMath.h"
0008 #include "DataFormats/Math/interface/Error.h"
0009 #include "DataFormats/Math/interface/AlgebraicROOTObjects.h"
0010 
0011 #include <vector>
0012 #include <memory>
0013 #include <string>
0014 #include <iostream>
0015 
0016 //------------------------------------------------------------------------------------------------//
0017 
0018 RPixRoadFinder::RPixRoadFinder(edm::ParameterSet const& parameterSet) : RPixDetPatternFinder(parameterSet) {
0019   verbosity_ = parameterSet.getUntrackedParameter<int>("verbosity");
0020   roadRadius_ = parameterSet.getParameter<double>("roadRadius");
0021   minRoadSize_ = parameterSet.getParameter<int>("minRoadSize");
0022   maxRoadSize_ = parameterSet.getParameter<int>("maxRoadSize");
0023   roadRadiusBadPot_ = parameterSet.getParameter<double>("roadRadiusBadPot");
0024 }
0025 
0026 //------------------------------------------------------------------------------------------------//
0027 
0028 RPixRoadFinder::~RPixRoadFinder() {}
0029 
0030 //------------------------------------------------------------------------------------------------//
0031 
0032 void RPixRoadFinder::findPattern(bool isBadPot) {
0033   Road temp_all_hits;
0034   temp_all_hits.clear();
0035 
0036   Road temp_all_hits_badPot;
0037   temp_all_hits_badPot.clear();
0038 
0039   // convert local hit sto global and push them to a vector
0040   for (const auto& ds_rh2 : *hitVector_) {
0041     const auto myid = CTPPSPixelDetId(ds_rh2.id);
0042     for (const auto& it_rh : ds_rh2.data) {
0043       CTPPSGeometry::Vector localV(it_rh.point().x(), it_rh.point().y(), it_rh.point().z());
0044       const auto& globalV = geometry_->localToGlobal(ds_rh2.id, localV);
0045       math::Error<3>::type localError;
0046       localError[0][0] = it_rh.error().xx();
0047       localError[0][1] = it_rh.error().xy();
0048       localError[0][2] = 0.;
0049       localError[1][0] = it_rh.error().xy();
0050       localError[1][1] = it_rh.error().yy();
0051       localError[1][2] = 0.;
0052       localError[2][0] = 0.;
0053       localError[2][1] = 0.;
0054       localError[2][2] = 0.;
0055       if (verbosity_ > 2)
0056         edm::LogInfo("RPixRoadFinder") << "Hits = " << ds_rh2.data.size();
0057 
0058       DetGeomDesc::RotationMatrix theRotationMatrix = geometry_->sensor(myid)->rotation();
0059       AlgebraicMatrix33 theRotationTMatrix;
0060       theRotationMatrix.GetComponents(theRotationTMatrix(0, 0),
0061                                       theRotationTMatrix(0, 1),
0062                                       theRotationTMatrix(0, 2),
0063                                       theRotationTMatrix(1, 0),
0064                                       theRotationTMatrix(1, 1),
0065                                       theRotationTMatrix(1, 2),
0066                                       theRotationTMatrix(2, 0),
0067                                       theRotationTMatrix(2, 1),
0068                                       theRotationTMatrix(2, 2));
0069 
0070       math::Error<3>::type globalError = ROOT::Math::SimilarityT(theRotationTMatrix, localError);
0071 
0072       // create new collection for planes 0 and 5 of pot 45-220-fr
0073 
0074       if (isBadPot == true && myid.arm() == 0 && myid.station() == 2 && localV.x() > 0 &&
0075           (myid.plane() == 0 || myid.plane() == 5)) {  // 45-220-far
0076 
0077         temp_all_hits_badPot.emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
0078       }
0079       temp_all_hits.emplace_back(PointInPlane{globalV, globalError, it_rh, myid});
0080     }
0081   }
0082 
0083   Road::iterator it_gh1 = temp_all_hits.begin();
0084   Road::iterator it_gh2;
0085 
0086   patternVector_.clear();
0087 
0088   //look for points near wrt each other
0089   // starting algorithm
0090   while (it_gh1 != temp_all_hits.end() && temp_all_hits.size() >= minRoadSize_) {
0091     Road temp_road;
0092 
0093     it_gh2 = it_gh1;
0094 
0095     const auto currPoint = it_gh1->globalPoint;
0096     CTPPSPixelDetId currDet = CTPPSPixelDetId(it_gh1->detId);
0097 
0098     while (it_gh2 != temp_all_hits.end()) {
0099       bool same_pot = false;
0100       CTPPSPixelDetId tmpGh2Id = CTPPSPixelDetId(it_gh2->detId);
0101       if (currDet.rpId() == tmpGh2Id.rpId())
0102         same_pot = true;
0103       const auto subtraction = currPoint - it_gh2->globalPoint;
0104 
0105       if (subtraction.Rho() < roadRadius_ && same_pot) {  /// 1mm
0106         temp_road.push_back(*it_gh2);
0107         temp_all_hits.erase(it_gh2);
0108       } else {
0109         ++it_gh2;
0110       }
0111     }
0112 
0113     if (temp_road.size() >= minRoadSize_ && temp_road.size() < maxRoadSize_)
0114       patternVector_.push_back(temp_road);
0115   }
0116   // end of algorithm
0117 
0118   // badPot algorithm
0119   Road::iterator it_gh1_bP = temp_all_hits_badPot.begin();
0120   Road::iterator it_gh2_bP;
0121 
0122   while (it_gh1_bP != temp_all_hits_badPot.end() && temp_all_hits_badPot.size() >= 2) {
0123     Road temp_road;
0124 
0125     it_gh2_bP = it_gh1_bP;
0126 
0127     const auto currPoint = it_gh1_bP->globalPoint;
0128 
0129     while (it_gh2_bP != temp_all_hits_badPot.end()) {
0130       const auto subtraction = currPoint - it_gh2_bP->globalPoint;
0131 
0132       if (subtraction.Rho() < roadRadiusBadPot_) {
0133         temp_road.push_back(*it_gh2_bP);
0134         temp_all_hits_badPot.erase(it_gh2_bP);
0135       } else {
0136         ++it_gh2_bP;
0137       }
0138     }
0139 
0140     if (temp_road.size() == 2) {  // look for isolated tracks
0141       patternVector_.push_back(temp_road);
0142     }
0143   }
0144 }