CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/RecoTracker/TkHitPairs/interface/CosmicHitPairGeneratorFromLayerPair.h

Go to the documentation of this file.
00001 #ifndef CosmicHitPairGeneratorFromLayerPair_h
00002 #define CosmicHitPairGeneratorFromLayerPair_h
00003 
00004 #include "RecoTracker/TkHitPairs/interface/HitPairGenerator.h"
00005 #include "RecoTracker/TkHitPairs/interface/LayerWithHits.h"
00006 #include "FWCore/Framework/interface/ESHandle.h"
00007 #include "FWCore/Framework/interface/EventSetup.h"
00008 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00009 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00010 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"
00011 class DetLayer;
00012 class TrackingRegion;
00013 class LayerWithHits;
00014  class CompareHitPairsY {
00015  public:
00016    CompareHitPairsY(const edm::EventSetup& iSetup){    
00017 
00018      iSetup.get<TrackerDigiGeometryRecord>().get(tracker);};
00019    bool operator()( OrderedHitPair h1,
00020                     OrderedHitPair h2)
00021    {      
00022      const TrackingRecHit * trh1i = h1.inner()->hit();
00023      const TrackingRecHit * trh2i = h2.inner()->hit();
00024      const TrackingRecHit * trh1o = h1.outer()->hit();
00025      const TrackingRecHit * trh2o = h2.outer()->hit();
00026      GlobalPoint in1p=tracker->idToDet(trh1i->geographicalId())->surface().toGlobal(trh1i->localPosition());
00027      GlobalPoint in2p=tracker->idToDet(trh2i->geographicalId())->surface().toGlobal(trh2i->localPosition());
00028      GlobalPoint ou1p=tracker->idToDet(trh1o->geographicalId())->surface().toGlobal(trh1o->localPosition());
00029      GlobalPoint ou2p=tracker->idToDet(trh2o->geographicalId())->surface().toGlobal(trh2o->localPosition());
00030      if (ou1p.y()*ou2p.y()<0) return ou1p.y()>ou2p.y();
00031      else{
00032        float dist1=100*std::abs(ou1p.z()-in1p.z())-std::abs(ou1p.y())-0.1*std::abs(in1p.y());
00033        float dist2=100*std::abs(ou2p.z()-in2p.z())-std::abs(ou2p.y())-0.1*std::abs(in2p.y());
00034        return dist1 < dist2;
00035      }
00036    }
00037  private:
00038    edm::ESHandle<TrackerGeometry> tracker;
00039  };
00040 class CosmicHitPairGeneratorFromLayerPair : public HitPairGenerator {
00041 
00042 public:
00043 
00044 
00045   CosmicHitPairGeneratorFromLayerPair( 
00046                                 const LayerWithHits* inner, 
00047                                 const LayerWithHits* outer, 
00048                                 const edm::EventSetup& iSetup);
00049   virtual ~CosmicHitPairGeneratorFromLayerPair() { }
00050 
00051 //  virtual OrderedHitPairs hitPairs( const TrackingRegion& region,const edm::EventSetup& iSetup ) {
00052 //    return HitPairGenerator::hitPairs(region, iSetup);
00053 //  }
00054   virtual void hitPairs( const TrackingRegion& ar, OrderedHitPairs & ap, const edm::EventSetup& iSetup);
00055 
00056   virtual void hitPairs( const TrackingRegion& ar, OrderedHitPairs & ap, const edm::Event & ev, const edm::EventSetup& iSetup) {}
00057 
00058   virtual CosmicHitPairGeneratorFromLayerPair* clone() const {
00059     return new CosmicHitPairGeneratorFromLayerPair(*this);
00060   }
00061 
00062   const LayerWithHits* innerLayer() const { return theInnerLayer; }
00063   const LayerWithHits* outerLayer() const { return theOuterLayer; }
00064 
00065 private:
00066   const TransientTrackingRecHitBuilder * TTRHbuilder;
00067   const TrackerGeometry* trackerGeometry;
00068   const LayerWithHits* theOuterLayer;  
00069   const LayerWithHits* theInnerLayer; 
00070   const DetLayer* innerlay;
00071   const DetLayer* outerlay;
00072 
00073 };
00074 
00075 #endif