Go to the documentation of this file.00001 #include "RecoTracker/TkHitPairs/interface/HitPairGeneratorFromLayerPair.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003
00004 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00005 #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
00006 #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
00007
00008 #include "RecoTracker/TkTrackingRegions/interface/HitRZCompatibility.h"
00009 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
00010 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionBase.h"
00011 #include "RecoTracker/TkHitPairs/interface/OrderedHitPairs.h"
00012 #include "RecoTracker/TkHitPairs/src/InnerDeltaPhi.h"
00013
00014 #include "FWCore/Framework/interface/Event.h"
00015 #include "FWCore/Framework/interface/EventSetup.h"
00016 #include "RecoTracker/TkSeedingLayers/interface/SeedingLayer.h"
00017
00018 using namespace GeomDetEnumerators;
00019 using namespace ctfseeding;
00020 using namespace std;
00021
00022 typedef PixelRecoRange<float> Range;
00023 template<class T> inline T sqr( T t) {return t*t;}
00024
00025
00026
00027 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"
00028 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
00029 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00030 #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
00031 #include "FWCore/Framework/interface/ESHandle.h"
00032
00033 HitPairGeneratorFromLayerPair::HitPairGeneratorFromLayerPair(
00034 const Layer& inner,
00035 const Layer& outer,
00036 LayerCacheType* layerCache,
00037 unsigned int nSize,
00038 unsigned int max)
00039 : HitPairGenerator(nSize),
00040 theLayerCache(*layerCache), theOuterLayer(outer), theInnerLayer(inner)
00041 {
00042 theMaxElement=max;
00043 }
00044
00045 void HitPairGeneratorFromLayerPair::hitPairs(
00046 const TrackingRegion & region, OrderedHitPairs & result,
00047 const edm::Event& iEvent, const edm::EventSetup& iSetup)
00048 {
00049
00050 typedef OrderedHitPair::InnerRecHit InnerHit;
00051 typedef OrderedHitPair::OuterRecHit OuterHit;
00052 typedef RecHitsSortedInPhi::Hit Hit;
00053
00054 const RecHitsSortedInPhi & innerHitsMap = theLayerCache(&theInnerLayer, region, iEvent, iSetup);
00055 if (innerHitsMap.empty()) return;
00056
00057 const RecHitsSortedInPhi& outerHitsMap = theLayerCache(&theOuterLayer, region, iEvent, iSetup);
00058 if (outerHitsMap.empty()) return;
00059
00060 InnerDeltaPhi deltaPhi(*theInnerLayer.detLayer(), region, iSetup);
00061
00062 RecHitsSortedInPhi::Range outerHits = outerHitsMap.all();
00063
00064 static const float nSigmaRZ = std::sqrt(12.f);
00065 static const float nSigmaPhi = 3.f;
00066 vector<Hit> innerHits;
00067 for (RecHitsSortedInPhi::HitIter oh = outerHits.first; oh!= outerHits.second; ++oh) {
00068 Hit ohit = (*oh).hit();
00069 GlobalPoint oPos = ohit->globalPosition();
00070 PixelRecoRange<float> phiRange = deltaPhi( oPos.perp(), oPos.phi(), oPos.z(), nSigmaPhi*(ohit->errorGlobalRPhi()));
00071
00072 if (phiRange.empty()) continue;
00073
00074 const HitRZCompatibility *checkRZ = region.checkRZ(theInnerLayer.detLayer(), ohit, iSetup);
00075 if(!checkRZ) continue;
00076
00077 innerHits.clear();
00078 innerHitsMap.hits(phiRange.min(), phiRange.max(), innerHits);
00079 LogDebug("HitPairGeneratorFromLayerPair")<<
00080 "preparing for combination of: "<<innerHits.size()<<" inner and: "<<outerHits.second-outerHits.first<<" outter";
00081 for ( vector<Hit>::const_iterator ih=innerHits.begin(), ieh = innerHits.end(); ih < ieh; ++ih) {
00082 GlobalPoint innPos = (*ih)->globalPosition();
00083 float r_reduced = std::sqrt( sqr(innPos.x()-region.origin().x())+sqr(innPos.y()-region.origin().y()));
00084 Range allowed;
00085 Range hitRZ;
00086 if (theInnerLayer.detLayer()->location() == barrel) {
00087 allowed = checkRZ->range(r_reduced);
00088 float zErr = nSigmaRZ * (*ih)->errorGlobalZ();
00089 hitRZ = Range(innPos.z()-zErr, innPos.z()+zErr);
00090 } else {
00091 allowed = checkRZ->range(innPos.z());
00092 float rErr = nSigmaRZ * (*ih)->errorGlobalR();
00093 hitRZ = Range(r_reduced-rErr, r_reduced+rErr);
00094 }
00095 Range crossRange = allowed.intersection(hitRZ);
00096 if (! crossRange.empty() ) {
00097 if (theMaxElement!=0 && result.size() >= theMaxElement){
00098 result.clear();
00099 edm::LogError("TooManyPairs")<<"number of pairs exceed maximum, no pairs produced";
00100 delete checkRZ;
00101 return;
00102 }
00103 result.push_back( OrderedHitPair( *ih, ohit) );
00104 }
00105 }
00106 delete checkRZ;
00107 }
00108 LogDebug("HitPairGeneratorFromLayerPair")<<" total number of pairs provided back: "<<result.size();
00109 }