Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:42

0001 #include "CompatibleDetToGroupAdder.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "DetGroupMerger.h"
0004 
0005 using namespace std;
0006 
0007 bool CompatibleDetToGroupAdder::add(const GeometricSearchDet& det,
0008                                     const TrajectoryStateOnSurface& tsos,
0009                                     const Propagator& prop,
0010                                     const MeasurementEstimator& est,
0011                                     vector<DetGroup>& result) {
0012   if (det.hasGroups()) {
0013     vector<DetGroup> tmp;
0014     det.groupedCompatibleDetsV(tsos, prop, est, tmp);
0015     if (tmp.empty())
0016       return false;
0017 
0018     if (result.empty())
0019       result.swap(tmp);
0020     else
0021       DetGroupMerger::addSameLevel(std::move(tmp), result);
0022   } else {
0023     vector<GeometricSearchDet::DetWithState> compatDets;
0024     det.compatibleDetsV(tsos, prop, est, compatDets);
0025     if (compatDets.empty())
0026       return false;
0027 
0028     if (result.empty())
0029       result.push_back(DetGroup(0, 1));  // empty group for insertion
0030 
0031     if (result.size() != 1)
0032       edm::LogError("TkDetLayers")
0033           << "CompatibleDetToGroupAdder: det is not grouped but result has more than one group!";
0034     result.front().reserve(result.front().size() + compatDets.size());
0035     for (vector<GeometricSearchDet::DetWithState>::const_iterator i = compatDets.begin(); i != compatDets.end(); i++)
0036       result.front().push_back(*i);
0037   }
0038   return true;
0039 }
0040 
0041 #include "TrackingTools/DetLayers/interface/GeomDetCompatibilityChecker.h"
0042 // #include "TkGeomDetCompatibilityChecker.h"
0043 
0044 bool CompatibleDetToGroupAdder::add(const GeomDet& det,
0045                                     const TrajectoryStateOnSurface& tsos,
0046                                     const Propagator& prop,
0047                                     const MeasurementEstimator& est,
0048                                     vector<DetGroup>& result) {
0049   //TkGeomDetCompatibilityChecker theCompatibilityChecker;
0050   GeomDetCompatibilityChecker theCompatibilityChecker;
0051   auto&& compat = theCompatibilityChecker.isCompatible(&det, tsos, prop, est);
0052 
0053   if (!compat.first)
0054     return false;
0055 
0056   if (result.empty())
0057     result.push_back(DetGroup(0, 1));  // empty group for ge insertion
0058 
0059   if (result.size() != 1)
0060     edm::LogError("TkDetLayers") << "CompatibleDetToGroupAdder: det is not grouped but result has more than one group!";
0061 
0062   result.front().emplace_back(&det, std::move(compat.second));
0063   return true;
0064 }