Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:20

0001 #include "DataFormats/TrackerRecHit2D/interface/SiTrackerMultiRecHit.h"
0002 
0003 using namespace std;
0004 using namespace edm;
0005 
0006 SiTrackerMultiRecHit::SiTrackerMultiRecHit(const LocalPoint& pos,
0007                                            const LocalError& err,
0008                                            GeomDet const& idet,
0009                                            const std::vector<std::pair<const TrackingRecHit*, float> >& aHitMap,
0010                                            double annealing)
0011     : BaseTrackerRecHit(pos, err, idet, trackerHitRTTI::multi) {
0012   for (std::vector<std::pair<const TrackingRecHit*, float> >::const_iterator ihit = aHitMap.begin();
0013        ihit != aHitMap.end();
0014        ihit++) {
0015     theHits.push_back(ihit->first->clone());
0016     theWeights.push_back(ihit->second);
0017   }
0018   annealing_ = annealing;
0019 }
0020 
0021 bool SiTrackerMultiRecHit::sharesInput(const TrackingRecHit* other, SharedInputType what) const {
0022   if (geographicalId() != other->geographicalId() && what == all)
0023     return false;
0024   vector<const TrackingRecHit*> otherhits = other->recHits();
0025   if (what == all) {
0026     if (theHits.size() != other->recHits().size())
0027       return false;
0028     for (vector<const TrackingRecHit*>::iterator otherhit = otherhits.begin(); otherhit != otherhits.end();
0029          ++otherhit) {
0030       bool found = false;
0031       for (OwnVector<TrackingRecHit>::const_iterator hit = theHits.begin(); hit != theHits.end(); ++hit) {
0032         if ((hit)->sharesInput(*otherhit, all)) {
0033           found = true;
0034           break;
0035         }
0036       }
0037       if (found == false) {
0038         return false;
0039       }
0040     }
0041     return true;
0042   } else {
0043     for (OwnVector<TrackingRecHit>::const_iterator hit = theHits.begin(); hit != theHits.end(); ++hit) {
0044       if (!otherhits.empty()) {
0045         for (vector<const TrackingRecHit*>::iterator otherhit = otherhits.begin(); otherhit != otherhits.end();
0046              ++otherhit) {
0047           if ((hit)->sharesInput(*otherhit, some))
0048             return true;
0049         }
0050       } else {  //otherwise it should be a single rechit
0051         if ((hit)->sharesInput(other, some))
0052           return true;
0053       }
0054     }
0055     return false;
0056   }
0057 }
0058 
0059 vector<const TrackingRecHit*> SiTrackerMultiRecHit::recHits() const {
0060   vector<const TrackingRecHit*> myhits;
0061   for (edm::OwnVector<TrackingRecHit>::const_iterator ihit = theHits.begin(); ihit != theHits.end(); ihit++) {
0062     myhits.push_back(&*ihit);
0063   }
0064   return myhits;
0065 }
0066 
0067 vector<TrackingRecHit*> SiTrackerMultiRecHit::recHits() { return theHits.data(); }
0068 
0069 int SiTrackerMultiRecHit::dimension() const {
0070   //supposing all the hits inside of a MRH have the same id == same type
0071   int randomComponent = 0;
0072   if (theHits[randomComponent].dimension() == 1) {
0073     return 1;
0074   } else if (theHits[randomComponent].dimension() == 2) {
0075     return 2;
0076   } else {
0077     return 0;
0078   }
0079 }
0080 
0081 void SiTrackerMultiRecHit::getKfComponents(KfComponentsHolder& holder) const {
0082   if (dimension() == 1)
0083     getKfComponents1D(holder);
0084   if (dimension() == 2)
0085     getKfComponents2D(holder);
0086 }