CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/DataFormats/TrackerRecHit2D/src/SiStripRecHit2D.cc

Go to the documentation of this file.
00001 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
00002 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit1D.h"
00003 #include "DataFormats/TrackerRecHit2D/interface/ProjectedSiStripRecHit2D.h"
00004 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h"
00005 
00006 
00007 SiStripRecHit2D::SiStripRecHit2D( const LocalPoint& pos, const LocalError& err,
00008                                   const DetId& id,
00009                                   ClusterRef const & cluster):
00010   
00011   BaseSiTrackerRecHit2DLocalPos(pos,err,id), 
00012   cluster_(cluster),
00013   clusterRegional_(),
00014   sigmaPitch_(-1.)
00015  {}
00016 
00017 
00018 SiStripRecHit2D::SiStripRecHit2D( const LocalPoint& pos, const LocalError& err,
00019                                   const DetId& id,
00020                                   ClusterRegionalRef const& cluster): 
00021   BaseSiTrackerRecHit2DLocalPos(pos,err,id), 
00022   cluster_(),
00023   clusterRegional_(cluster),
00024   sigmaPitch_(-1.) {}
00025 
00026 
00027 bool 
00028 SiStripRecHit2D::sharesInput( const TrackingRecHit* other, 
00029                               SharedInputType what) const
00030 {
00031   //here we exclude non si-strip subdetectors
00032   if( ((geographicalId().rawId()) >> (DetId::kSubdetOffset) ) != ( (other->geographicalId().rawId())>> (DetId::kSubdetOffset)) ) return false;
00033 
00034   //Protection against invalid hits
00035   if(! other->isValid()) return false;
00036 
00037   const std::type_info & otherType = typeid(*other);
00038   if (otherType == typeid(SiStripRecHit2D)) {
00039     const SiStripRecHit2D* otherCast = static_cast<const SiStripRecHit2D*>(other);
00040     // as 'null == null' is true, we can't just "or" the two equality tests: one of the two refs is always null! (gpetrucc)
00041     if (cluster_.isNonnull()) {
00042       return (cluster_ == otherCast->cluster());
00043     } else {
00044       return (clusterRegional_ == otherCast->cluster_regional());
00045     }
00046   } else if (otherType == typeid(SiStripRecHit1D)) {
00047     const SiStripRecHit1D* otherCast = static_cast<const SiStripRecHit1D*>(other);
00048     // as 'null == null' is true, we can't just "or" the two equality tests: one of the two refs is always null! (gpetrucc)
00049     if (cluster_.isNonnull()) {
00050       return (cluster_ == otherCast->cluster());
00051     } else {
00052       return (clusterRegional_ == otherCast->cluster_regional());
00053     }
00054   } else if (otherType == typeid(ProjectedSiStripRecHit2D)) {
00055     const SiStripRecHit2D* otherCast = & (static_cast<const ProjectedSiStripRecHit2D*>(other)->originalHit());
00056     // as 'null == null' is true, we can't just "or" the two equality tests: one of the two refs is always null! (gpetrucc)
00057     if (cluster_.isNonnull()) {
00058       return (cluster_ == otherCast->cluster());
00059     } else {
00060       return (clusterRegional_ == otherCast->cluster_regional());
00061     }
00062   } else if ((otherType == typeid(SiStripMatchedRecHit2D)) && (what == all)) {
00063     return false; 
00064   } else {
00065     // last resort, recur to 'recHits()', even if it returns a vector by value
00066     std::vector<const TrackingRecHit*> otherHits = other->recHits();
00067     int ncomponents=otherHits.size();
00068     if(ncomponents==0)return false;
00069     else if(ncomponents==1)return sharesInput(otherHits.front(),what);
00070     else if (ncomponents>1){
00071       if(what == all )return false;
00072       else{
00073         for(int i=0;i<ncomponents;i++){
00074           if(sharesInput(otherHits[i],what))return true;
00075         }
00076         return false;
00077       }
00078     }
00079     return false;
00080   }
00081 }
00082