CMS 3D CMS Logo

MuonDetIdAssociator.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    TrackAssociator
00004 // Class:      MuonDetIdAssociator
00005 // 
00006 /*
00007 
00008  Description: <one line class summary>
00009 
00010  Implementation:
00011      <Notes on implementation>
00012 */
00013 //
00014 // Original Author:  Dmytro Kovalskyi
00015 //         Created:  Fri Apr 21 10:59:41 PDT 2006
00016 // $Id: MuonDetIdAssociator.cc,v 1.8 2008/03/31 13:31:42 dmytro Exp $
00017 //
00018 //
00019 
00020 
00021 #include "TrackingTools/TrackAssociator/interface/MuonDetIdAssociator.h"
00022 // #include "Utilities/Timing/interface/TimerStack.h"
00023 #include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h"
00024 #include "DataFormats/GeometrySurface/interface/Plane.h"
00025 #include "Geometry/DTGeometry/interface/DTChamber.h"
00026 #include "Geometry/CSCGeometry/interface/CSCChamber.h"
00027 #include <deque>
00028 
00029 void MuonDetIdAssociator::check_setup() const {
00030    if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00031    DetIdAssociator::check_setup();
00032 }
00033 
00034 const GeomDet* MuonDetIdAssociator::getGeomDet( const DetId& id ) const
00035 {
00036    if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00037    const GeomDet* gd = geometry_->idToDet(id);
00038    if (gd == 0) throw cms::Exception("NoGeometry") << "Cannot find GeomDet for DetID: " << id.rawId() <<"\n";
00039    return gd;
00040 }
00041 
00042 
00043 GlobalPoint MuonDetIdAssociator::getPosition(const DetId& id) const {
00044    Surface::PositionType point(getGeomDet(id)->surface().position());
00045    return GlobalPoint(point.x(),point.y(),point.z());
00046 }
00047 
00048 std::set<DetId> MuonDetIdAssociator::getASetOfValidDetIds() const {
00049    std::set<DetId> setOfValidIds;
00050    if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00051    // we need to store only DTChambers as well as CSCChambers
00052    // Let's get all GeomDet by dets() and select only DTChambers and CSCChambers
00053 
00054    // comment this for now, till the fix of GlobalTrackingGeometry is in a release
00055    // std::vector<GeomDet*> vectOfGeomDetPtrs = geometry_->dets();
00056    // LogTrace("TrackAssociator") << "Number of GeomDet found: " << vectOfGeomDetPtrs.size();
00057    // for(std::vector<GeomDet*>::const_iterator it = vectOfGeomDetPtrs.begin(); it != vectOfGeomDetPtrs.end(); ++it)
00058    //  {
00059    //   if ((*it)->subDetector() == GeomDetEnumerators::CSC || (*it)->subDetector() == GeomDetEnumerators::DT)
00060    //     {
00061    //        if (DTChamber* dt = dynamic_cast< DTChamber*>(*it)) {
00062    //           setOfValidIds.insert(dt->id());
00063    //        }else{
00064    //           if (CSCChamber* csc = dynamic_cast< CSCChamber*>(*it)) {
00065    //              setOfValidIds.insert(csc->id());
00066    //           }
00067    //        }
00068    //     }
00069    //   }
00070    
00071    // CSC 
00072    if (! geometry_->slaveGeometry(CSCDetId()) ) throw cms::Exception("FatalError") << "Cannnot CSCGeometry\n";
00073    std::vector<GeomDet*> geomDetsCSC = geometry_->slaveGeometry(CSCDetId())->dets();
00074    for(std::vector<GeomDet*>::const_iterator it = geomDetsCSC.begin(); it != geomDetsCSC.end(); ++it)
00075      if (CSCChamber* csc = dynamic_cast< CSCChamber*>(*it)) setOfValidIds.insert(csc->id());
00076    
00077    // DT
00078    if (! geometry_->slaveGeometry(DTChamberId()) ) throw cms::Exception("FatalError") << "Cannnot DTGeometry\n";
00079    std::vector<GeomDet*> geomDetsDT = geometry_->slaveGeometry(DTChamberId())->dets();
00080    for(std::vector<GeomDet*>::const_iterator it = geomDetsDT.begin(); it != geomDetsDT.end(); ++it)
00081      if (DTChamber* dt = dynamic_cast< DTChamber*>(*it)) setOfValidIds.insert(dt->id());
00082 
00083    return setOfValidIds;
00084 }
00085 
00086 bool MuonDetIdAssociator::insideElement(const GlobalPoint& point, const DetId& id) const {
00087    if (geometry_==0) throw cms::Exception("ConfigurationProblem") << "GlobalTrackingGeomtry is not set\n";
00088    LocalPoint lp = geometry_->idToDet(id)->toLocal(point);
00089    return geometry_->idToDet(id)->surface().bounds().inside(lp);
00090 }
00091 
00092 std::vector<GlobalPoint> MuonDetIdAssociator::getDetIdPoints(const DetId& id) const {
00093    std::vector<GlobalPoint> points;
00094    const GeomDet* geomDet = getGeomDet( id );
00095    
00096    // the coners of muon detector elements are not stored and can be only calculated
00097    // based on methods defined in the interface class Bounds:
00098    //   width() - x
00099    //   length() - y 
00100    //   thinkness() - z
00101    // NOTE: this convention is implementation specific and can fail. Both
00102    //       RectangularPlaneBounds and TrapezoidalPlaneBounds use it.
00103    // Even though the CSC geomtry is more complicated (trapezoid),  it's enough 
00104    // to estimate which bins should contain this element. For the distance
00105    // calculation from the edge, we will use exact geometry to get it right.
00106             
00107    const Bounds* bounds = &(geometry_->idToDet(id)->surface().bounds());
00108    points.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,+bounds->length()/2,+bounds->thickness()/2)));
00109    points.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,+bounds->length()/2,+bounds->thickness()/2)));
00110    points.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,-bounds->length()/2,+bounds->thickness()/2)));
00111    points.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,-bounds->length()/2,+bounds->thickness()/2)));
00112    points.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,+bounds->length()/2,-bounds->thickness()/2)));
00113    points.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,+bounds->length()/2,-bounds->thickness()/2)));
00114    points.push_back(geomDet->toGlobal(LocalPoint(+bounds->width()/2,-bounds->length()/2,-bounds->thickness()/2)));
00115    points.push_back(geomDet->toGlobal(LocalPoint(-bounds->width()/2,-bounds->length()/2,-bounds->thickness()/2)));
00116    
00117    return  points;
00118 }

Generated on Tue Jun 9 17:48:28 2009 for CMSSW by  doxygen 1.5.4