CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DataFormats/TrackerRecHit2D/src/SiTrackerMultiRecHit.cc

Go to the documentation of this file.
00001 #include "DataFormats/TrackerRecHit2D/interface/SiTrackerMultiRecHit.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 
00004 using namespace std;
00005 using namespace edm;
00006 
00007 SiTrackerMultiRecHit::SiTrackerMultiRecHit(const LocalPoint& pos, const LocalError& err, const DetId& id, 
00008                                            const std::vector< std::pair<const TrackingRecHit*, float> >& aHitMap):
00009   BaseTrackerRecHit(pos,err,id,trackerHitRTTI::multi)   
00010 {
00011   for(std::vector<std::pair<const TrackingRecHit*, float> >::const_iterator ihit = aHitMap.begin(); ihit != aHitMap.end(); ihit++){
00012     theHits.push_back(ihit->first->clone());
00013     theWeights.push_back(ihit->second);
00014   }
00015 }
00016 
00017 
00018 bool SiTrackerMultiRecHit::sharesInput(const TrackingRecHit* other,
00019                                        SharedInputType what) const
00020 {
00021   if(geographicalId() != other->geographicalId()&& what==all ) return false;
00022   vector<const TrackingRecHit*> otherhits=other->recHits();
00023   if(what==all){
00024     if(theHits.size()!=other->recHits().size())return false;
00025     for(vector<const TrackingRecHit*>::iterator otherhit=otherhits.begin();otherhit!=otherhits.end();++otherhit){
00026       bool found=false;
00027       for(OwnVector<TrackingRecHit>::const_iterator hit=theHits.begin();hit!=theHits.end();++hit){
00028         if((hit)->sharesInput(*otherhit,all)){
00029           found=true;
00030           break;
00031         }
00032       }
00033       if(found==false){
00034         return false;
00035       }
00036     }
00037     return true;
00038   }
00039   else{
00040     for(OwnVector<TrackingRecHit>::const_iterator hit=theHits.begin();hit!=theHits.end();++hit){
00041       if(otherhits.size()!=0){ 
00042         for(vector<const TrackingRecHit*>::iterator otherhit=otherhits.begin();otherhit!=otherhits.end();++otherhit){
00043           if((hit)->sharesInput(*otherhit,some))return true;
00044         }
00045       }
00046       else{//otherwise it should be a single rechit
00047         if((hit)->sharesInput(other,some))return true;
00048       } 
00049     }
00050     return false;
00051   }
00052 }
00053 
00054 
00055 vector<const TrackingRecHit*> SiTrackerMultiRecHit::recHits() const{
00056   vector<const TrackingRecHit*> myhits;
00057   for(edm::OwnVector<TrackingRecHit>::const_iterator ihit = theHits.begin(); ihit != theHits.end(); ihit++) {
00058     myhits.push_back(&*ihit);
00059   }
00060   return myhits;
00061 }
00062 
00063 vector<TrackingRecHit*> SiTrackerMultiRecHit::recHits() {
00064   //        vector<TrackingRecHit*> myhits;
00065   //         for(edm::OwnVector<TrackingRecHit>::const_iterator ihit = theHits.begin(); ihit != theHits.end(); ihit++) {
00066   //                 const TrackingRecHit* ahit = &(*ihit);
00067   //                 myhits.push_back(const_cast<TrackingRecHit*>(ahit));
00068   //         }
00069   return theHits.data();
00070 }