Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:45

0001 /** \file
0002  *
0003  *  \author N. Amapane - CERN
0004  */
0005 
0006 #include "RecoMuon/DetLayers/interface/MuDetRod.h"
0007 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0008 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0009 #include "TrackingTools/DetLayers/interface/MeasurementEstimator.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 
0012 #include <iostream>
0013 
0014 using namespace std;
0015 
0016 MuDetRod::MuDetRod(vector<const GeomDet*>::const_iterator first, vector<const GeomDet*>::const_iterator last)
0017     : DetRodOneR(first, last) {
0018   init();
0019 }
0020 
0021 MuDetRod::MuDetRod(const vector<const GeomDet*>& vdets) : DetRodOneR(vdets) { init(); }
0022 
0023 void MuDetRod::init() { theBinFinder = BinFinderType(basicComponents().begin(), basicComponents().end()); }
0024 
0025 MuDetRod::~MuDetRod() {}
0026 
0027 const vector<const GeometricSearchDet*>& MuDetRod::components() const {
0028   // FIXME dummy impl.
0029   cout << "temporary dummy implementation of MuDetRod::components()!!" << endl;
0030   static const vector<const GeometricSearchDet*> result;
0031   return result;
0032 }
0033 
0034 pair<bool, TrajectoryStateOnSurface> MuDetRod::compatible(const TrajectoryStateOnSurface& ts,
0035                                                           const Propagator& prop,
0036                                                           const MeasurementEstimator& est) const {
0037   TrajectoryStateOnSurface ms = prop.propagate(ts, specificSurface());
0038   if (ms.isValid())
0039     return make_pair(est.estimate(ms, specificSurface()) != 0, ms);
0040   else
0041     return make_pair(false, ms);
0042 }
0043 
0044 vector<GeometricSearchDet::DetWithState> MuDetRod::compatibleDets(const TrajectoryStateOnSurface& startingState,
0045                                                                   const Propagator& prop,
0046                                                                   const MeasurementEstimator& est) const {
0047   const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuDetRod";
0048 
0049   LogTrace(metname) << "MuDetRod::compatibleDets, Surface at R,phi: " << surface().position().perp() << ","
0050                     << surface().position().phi() << "     DetRod pos.";
0051   // FIXME      << " TS at R,phi: " << startingState.position().perp() << ","
0052   //            << startingState.position().phi()
0053 
0054   vector<DetWithState> result;
0055 
0056   // Propagate and check that the result is within bounds
0057   pair<bool, TrajectoryStateOnSurface> compat = compatible(startingState, prop, est);
0058 
0059   if (!compat.first) {
0060     LogTrace(metname) << "    MuDetRod::compatibleDets: not compatible"
0061                       << "    (should not have been selected!)";
0062     return result;
0063   }
0064 
0065   // Find the most probable destination component
0066   TrajectoryStateOnSurface& tsos = compat.second;
0067   GlobalPoint startPos = tsos.globalPosition();
0068   int closest = theBinFinder.binIndex(startPos.z());
0069   const vector<const GeomDet*> dets = basicComponents();
0070   LogTrace(metname) << "     MuDetRod::compatibleDets, closest det: " << closest
0071                     << " pos: " << dets[closest]->surface().position() << " impact " << startPos;
0072 
0073   // Add this detector, if it is compatible
0074   // NOTE: add performs a null propagation
0075   add(closest, result, tsos, prop, est);
0076 
0077   int nclosest = result.size();
0078   int nnextdet = 0;  // just DEBUG counters
0079 
0080   // Try the neighbors on each side until no more compatible.
0081   // If closest is not compatible the next cannot be either
0082   if (!result.empty()) {
0083     const BoundPlane& closestPlane(dets[closest]->surface());
0084     MeasurementEstimator::Local2DVector maxDistance = est.maximalLocalDisplacement(result.front().second, closestPlane);
0085 
0086     // detHalfLen is assumed to be the same for all detectors.
0087     float detHalfLen = closestPlane.bounds().length() / 2.;
0088 
0089     for (unsigned int idet = closest + 1; idet < dets.size(); idet++) {
0090       LocalPoint nextPos(dets[idet]->toLocal(startPos));
0091       if (fabs(nextPos.y()) < detHalfLen + maxDistance.y()) {
0092         LogTrace(metname) << "     negativeZ: det:" << idet << " pos " << nextPos.y() << " maxDistance "
0093                           << maxDistance.y();
0094         nnextdet++;
0095         if (!add(idet, result, tsos, prop, est))
0096           break;
0097       } else {
0098         break;
0099       }
0100     }
0101 
0102     for (int idet = closest - 1; idet >= 0; idet--) {
0103       LocalPoint nextPos(dets[idet]->toLocal(startPos));
0104       if (fabs(nextPos.y()) < detHalfLen + maxDistance.y()) {
0105         LogTrace(metname) << "     positiveZ: det:" << idet << " pos " << nextPos.y() << " maxDistance "
0106                           << maxDistance.y();
0107         nnextdet++;
0108         if (!add(idet, result, tsos, prop, est))
0109           break;
0110       } else {
0111         break;
0112       }
0113     }
0114   }
0115 
0116   LogTrace(metname) << "     MuDetRod::compatibleDets, size: " << result.size() << " on closest: " << nclosest
0117                     << " # checked dets: " << nnextdet + 1;
0118   if (result.empty()) {
0119     LogTrace(metname) << "   ***Rod not compatible---should have been discarded before!!!";
0120   }
0121   return result;
0122 }
0123 
0124 vector<DetGroup> MuDetRod::groupedCompatibleDets(const TrajectoryStateOnSurface& startingState,
0125                                                  const Propagator& prop,
0126                                                  const MeasurementEstimator& est) const {
0127   // FIXME should return only 1 group
0128   cout << "dummy implementation of MuDetRod::groupedCompatibleDets()" << endl;
0129   vector<DetGroup> result;
0130   return result;
0131 }