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, const std::vector< std::pair<const TrackingRecHit*, float> >& aHitMap):
00008 BaseSiTrackerRecHit2DLocalPos(pos,err,id)
00009 {
00010 for(std::vector<std::pair<const TrackingRecHit*, float> >::const_iterator ihit = aHitMap.begin(); ihit != aHitMap.end(); ihit++){
00011 theHits.push_back(ihit->first->clone());
00012 theWeights.push_back(ihit->second);
00013 }
00014 }
00015
00016 float SiTrackerMultiRecHit::weight(unsigned int i) const {
00017 if (i < theWeights.size()) return theWeights[i];
00018 edm::LogError("SiTrackerMultiRecHit") << "You are requesting a the weight for a hit out of range, returning 0";
00019 return 0;
00020 }
00021
00022
00023 bool SiTrackerMultiRecHit::sharesInput(const TrackingRecHit* other,
00024 SharedInputType what) const
00025 {
00026 if(geographicalId() != other->geographicalId()&& what==all ) return false;
00027 vector<const TrackingRecHit*> otherhits=other->recHits();
00028 if(what==all){
00029 if(theHits.size()!=other->recHits().size())return false;
00030 for(vector<const TrackingRecHit*>::iterator otherhit=otherhits.begin();otherhit!=otherhits.end();++otherhit){
00031 bool found=false;
00032 for(OwnVector<TrackingRecHit>::const_iterator hit=theHits.begin();hit!=theHits.end();++hit){
00033 if((hit)->sharesInput(*otherhit,all)){
00034 found=true;
00035 break;
00036 }
00037 }
00038 if(found==false){
00039 return false;
00040 }
00041 }
00042 return true;
00043 }
00044 else{
00045 for(OwnVector<TrackingRecHit>::const_iterator hit=theHits.begin();hit!=theHits.end();++hit){
00046 if(otherhits.size()!=0){
00047 for(vector<const TrackingRecHit*>::iterator otherhit=otherhits.begin();otherhit!=otherhits.end();++otherhit){
00048 if((hit)->sharesInput(*otherhit,some))return true;
00049 }
00050 }
00051 else{
00052 if((hit)->sharesInput(other,some))return true;
00053 }
00054 }
00055 return false;
00056 }
00057 }
00058
00059
00060 vector<const TrackingRecHit*> SiTrackerMultiRecHit::recHits() const{
00061 vector<const TrackingRecHit*> myhits;
00062 for(edm::OwnVector<TrackingRecHit>::const_iterator ihit = theHits.begin(); ihit != theHits.end(); ihit++) {
00063 myhits.push_back(&*ihit);
00064 }
00065 return myhits;
00066 }
00067
00068 vector<TrackingRecHit*> SiTrackerMultiRecHit::recHits() {
00069
00070
00071
00072
00073
00074 return theHits.data();
00075 }