CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/RecoMuon/DetLayers/src/MuDetRod.cc

Go to the documentation of this file.
00001 
00008 #include "RecoMuon/DetLayers/interface/MuDetRod.h"
00009 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00010 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
00011 #include "TrackingTools/PatternTools/interface/MeasurementEstimator.h"
00012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00013 
00014 #include <iostream>
00015 
00016 using namespace std;
00017 
00018 
00019 MuDetRod::MuDetRod(vector<const GeomDet*>::const_iterator first,
00020                    vector<const GeomDet*>::const_iterator last)
00021   : DetRodOneR(first,last) {
00022   init();
00023 }
00024 
00025 MuDetRod::MuDetRod(const vector<const GeomDet*>& vdets)
00026   : DetRodOneR(vdets) {
00027   init();
00028 }
00029 
00030 
00031 void MuDetRod::init() {
00032   theBinFinder = BinFinderType(basicComponents().begin(), basicComponents().end());
00033 }
00034 
00035 
00036 MuDetRod::~MuDetRod(){}
00037 
00038 const vector<const GeometricSearchDet*>&
00039 MuDetRod::components() const {
00040 
00041   // FIXME dummy impl.
00042   cout << "temporary dummy implementation of MuDetRod::components()!!" << endl;
00043   static vector<const GeometricSearchDet*> result;
00044   return result;
00045 }
00046 
00047 pair<bool, TrajectoryStateOnSurface>
00048 MuDetRod::compatible(const TrajectoryStateOnSurface& ts, const Propagator& prop, 
00049                      const MeasurementEstimator& est) const {
00050   
00051   TrajectoryStateOnSurface ms = prop.propagate(ts,specificSurface());
00052   if (ms.isValid()) return make_pair(est.estimate(ms, specificSurface()) != 0, ms);
00053   else return make_pair(false, ms);
00054 }
00055 
00056 
00057 vector<GeometricSearchDet::DetWithState> 
00058 MuDetRod::compatibleDets( const TrajectoryStateOnSurface& startingState,
00059                           const Propagator& prop, 
00060                           const MeasurementEstimator& est) const {
00061   const std::string metname = "Muon|RecoMuon|RecoMuonDetLayers|MuDetRod";
00062   
00063   LogTrace(metname) << "MuDetRod::compatibleDets, Surface at R,phi: " 
00064                     << surface().position().perp()  << ","
00065                     << surface().position().phi() << "     DetRod pos.";
00066     // FIXME        << " TS at R,phi: " << startingState.position().perp() << ","
00067     //              << startingState.position().phi()
00068 
00069     
00070   vector<DetWithState> result;
00071   
00072   // Propagate and check that the result is within bounds
00073   pair<bool, TrajectoryStateOnSurface> compat =
00074     compatible(startingState, prop, est);
00075   
00076   if (!compat.first) {
00077     LogTrace(metname) << "    MuDetRod::compatibleDets: not compatible"
00078                       << "    (should not have been selected!)";
00079     return result;
00080   }
00081   
00082   // Find the most probable destination component
00083   TrajectoryStateOnSurface& tsos = compat.second;
00084   GlobalPoint startPos = tsos.globalPosition();
00085   int closest = theBinFinder.binIndex(startPos.z());
00086   const vector<const GeomDet*> dets = basicComponents();
00087   LogTrace(metname) << "     MuDetRod::compatibleDets, closest det: " << closest 
00088                     << " pos: " << dets[closest]->surface().position()
00089                     << " impact " << startPos;
00090   
00091   // Add this detector, if it is compatible
00092   // NOTE: add performs a null propagation
00093   add(closest, result, tsos, prop, est);
00094   
00095   int nclosest = result.size(); int nnextdet=0; // just DEBUG counters
00096   
00097   // Try the neighbors on each side until no more compatible.
00098   // If closest is not compatible the next cannot be either
00099   if (!result.empty()) {
00100     const BoundPlane& closestPlane(dets[closest]->surface());
00101     MeasurementEstimator::Local2DVector maxDistance = 
00102       est.maximalLocalDisplacement( result.front().second, closestPlane);
00103     
00104     // detHalfLen is assumed to be the same for all detectors.
00105     float detHalfLen = closestPlane.bounds().length()/2.;
00106     
00107     for (unsigned int idet=closest+1; idet < dets.size(); idet++) {
00108       LocalPoint nextPos(dets[idet]->toLocal(startPos));
00109       if (fabs(nextPos.y()) < detHalfLen + maxDistance.y()) { 
00110         LogTrace(metname) << "     negativeZ: det:" << idet
00111                           << " pos " << nextPos.y()
00112                           << " maxDistance " << maxDistance.y();
00113         nnextdet++;
00114         if ( !add(idet, result, tsos, prop, est)) break;
00115       } else {
00116         break;
00117       }
00118     }
00119     
00120     for (int idet=closest-1; idet >= 0; idet--) {
00121       LocalPoint nextPos( dets[idet]->toLocal(startPos));
00122       if (fabs(nextPos.y()) < detHalfLen + maxDistance.y()) {
00123         LogTrace(metname) << "     positiveZ: det:" << idet
00124                           << " pos " << nextPos.y()
00125                           << " maxDistance " << maxDistance.y();
00126         nnextdet++;
00127         if ( !add(idet, result, tsos, prop, est)) break;
00128       } else {
00129         break;
00130       }
00131     }
00132   }
00133   
00134   LogTrace(metname) << "     MuDetRod::compatibleDets, size: " << result.size()
00135                     << " on closest: " << nclosest
00136                     << " # checked dets: " << nnextdet+1;
00137   if (result.size()==0) {
00138     LogTrace(metname) << "   ***Rod not compatible---should have been discarded before!!!";
00139   }
00140   return result;
00141 }
00142 
00143 
00144 vector<DetGroup> 
00145 MuDetRod::groupedCompatibleDets( const TrajectoryStateOnSurface& startingState,
00146                                  const Propagator& prop,
00147                                  const MeasurementEstimator& est) const {
00148   // FIXME should return only 1 group 
00149   cout << "dummy implementation of MuDetRod::groupedCompatibleDets()" << endl;
00150   vector<DetGroup> result;
00151   return result;
00152 }