CMS 3D CMS Logo

LaserHitPairGeneratorFromLayerPair.cc

Go to the documentation of this file.
00001 
00009 #include "Alignment/LaserAlignment/interface/LaserHitPairGeneratorFromLayerPair.h"
00010 
00011 
00012 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
00013 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h" 
00014 
00015 
00016 
00017 typedef ctfseeding::SeedingHit TkHitPairsCachedHit;
00018 
00019 LaserHitPairGeneratorFromLayerPair::LaserHitPairGeneratorFromLayerPair(const LayerWithHits* inner, 
00020         const LayerWithHits* outer, const edm::EventSetup& iSetup) : trackerGeometry(0),
00021         theInnerLayer(inner), theOuterLayer(outer)
00022 {
00023 
00024   edm::ESHandle<TrackerGeometry> tracker;
00025   iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
00026   trackerGeometry = tracker.product();
00027 }
00028 
00029 void LaserHitPairGeneratorFromLayerPair::hitPairs(const TrackingRegion & region, OrderedLaserHitPairs & result, const edm::EventSetup & iSetup)
00030 {
00031         typedef OrderedLaserHitPair::InnerHit InnerHit;
00032         typedef OrderedLaserHitPair::OuterHit OuterHit;
00033 
00034         if (theInnerLayer->recHits().empty()) return;
00035         if (theOuterLayer->recHits().empty()) return;
00036 
00037         std::vector<OrderedLaserHitPair> allthepairs;
00038 
00039         std::vector<const TrackingRecHit*>::const_iterator ohh;
00040 
00041         for(ohh=theOuterLayer->recHits().begin();ohh!=theOuterLayer->recHits().end();ohh++){
00042     GlobalPoint oh = trackerGeometry->idToDet((*ohh)->geographicalId())->surface().toGlobal((*ohh)->localPosition());
00043           std::vector<const TrackingRecHit*>::const_iterator ihh;
00044           for(ihh=theInnerLayer->recHits().begin();ihh!=theInnerLayer->recHits().end();ihh++){
00045       GlobalPoint ih = trackerGeometry->idToDet((*ihh)->geographicalId())->surface().toGlobal((*ihh)->localPosition());
00046 
00047       double inny = ih.y();
00048       double outy = oh.y();
00049                         double innz = ih.z();
00050                         double outz = oh.z();
00051                         double innphi = ih.phi();
00052                         double outphi = oh.phi();
00053                         double phi_diff = innphi - outphi;
00054       double r_diff = sqrt(pow(ih.x(),2)+pow(ih.y(),2)) - sqrt(pow(oh.x(),2)+pow(oh.y(),2));
00055 
00056                         if ( ( inny * outy > 0.0 ) && ( innz * outz > 0.0 ) && ( fabs(phi_diff) < 0.005 ) && ( fabs(r_diff) < 0.5 ) )
00057                         {
00058                                 allthepairs.push_back( OrderedLaserHitPair(*ihh, *ohh ));
00059                         }
00060                 }
00061         }
00062         stable_sort(allthepairs.begin(),allthepairs.end(),CompareHitPairsZ(iSetup));
00063 
00064         if (allthepairs.size() > 0) 
00065         {
00066                 for (std::vector<OrderedLaserHitPair>::const_iterator it = allthepairs.begin(); it != allthepairs.end(); it++)
00067                 {
00068                         result.push_back(*it);
00069                 }
00070         }
00071 }

Generated on Tue Jun 9 17:24:09 2009 for CMSSW by  doxygen 1.5.4