Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "RecoMuon/TrackerSeedGenerator/interface/TrackerSeedCleaner.h"
00011
00012
00013
00014
00015 #include <vector>
00016
00017
00018
00019
00020 #include "FWCore/Framework/interface/Event.h"
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022
00023 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
00024 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00025 #include "DataFormats/Math/interface/deltaPhi.h"
00026
00027 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00028 #include "TrackingTools/PatternTools/interface/TSCBLBuilderNoMaterial.h"
00029 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
00030 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00031 #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h"
00032 #include "RecoTracker/TkTrackingRegions/interface/TkTrackingRegionsMargin.h"
00033 #include "RecoTracker/TkMSParametrization/interface/PixelRecoRange.h"
00034
00035 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
00036 #include "RecoMuon/TrackerSeedGenerator/interface/TrackerSeedGenerator.h"
00037 #include "RecoMuon/TrackerSeedGenerator/interface/TrackerSeedGeneratorFactory.h"
00038
00039 using namespace std;
00040 using namespace edm;
00041
00042
00043
00044
00045 void TrackerSeedCleaner::init(const MuonServiceProxy *service){
00046
00047 theProxyService = service;
00048
00049 theRedundantCleaner = new RedundantSeedCleaner();
00050 }
00051
00052
00053
00054
00055 void TrackerSeedCleaner::setEvent(const edm::Event& event)
00056 {
00057 event.getByLabel(theBeamSpotTag, bsHandle_);
00058 }
00059
00060
00061
00062
00063 void TrackerSeedCleaner::clean( const reco::TrackRef& muR, const RectangularEtaPhiTrackingRegion& region, tkSeeds& seeds ) {
00064
00065
00066
00067 if(cleanBySharedHits) theRedundantCleaner->define(seeds);
00068
00069 theProxyService->eventSetup().get<TransientRecHitRecord>().get(builderName_,theTTRHBuilder);
00070
00071 LogDebug("TrackerSeedCleaner")<<seeds.size()<<" trajectory seeds to the events before cleaning"<<endl;
00072
00073
00074 const reco::BeamSpot & bs = *bsHandle_;
00075
00076
00077
00078 std::vector<TrajectorySeed > result;
00079
00080 TrajectoryStateTransform tsTransform;
00081 TSCBLBuilderNoMaterial tscblBuilder;
00082
00083 for(TrajectorySeedCollection::iterator seed = seeds.begin(); seed<seeds.end(); ++seed){
00084 if(seed->nHits() < 2) continue;
00085
00086 TransientTrackingRecHit::RecHitPointer recHit = theTTRHBuilder->build(&*(seed->recHits().second-1));
00087 TrajectoryStateOnSurface state = tsTransform.transientState( seed->startingState(), recHit->surface(), theProxyService->magneticField().product());
00088
00089 TrajectoryStateClosestToBeamLine tsAtClosestApproachSeed = tscblBuilder(*state.freeState(),bs);
00090 if (!tsAtClosestApproachSeed.isValid()) continue;
00091 GlobalPoint vSeed1 = tsAtClosestApproachSeed.trackStateAtPCA().position();
00092 GlobalVector pSeed = tsAtClosestApproachSeed.trackStateAtPCA().momentum();
00093 GlobalPoint vSeed(vSeed1.x()-bs.x0(),vSeed1.y()-bs.y0(),vSeed1.z()-bs.z0());
00094
00095
00096
00097 double etaSeed = state.globalMomentum().eta();
00098 double phiSeed = pSeed.phi();
00099
00100
00101 typedef PixelRecoRange< float > Range;
00102 typedef TkTrackingRegionsMargin< float > Margin;
00103
00104 Range etaRange = region.etaRange();
00105 double etaLimit = (fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) <0.1) ? 0.1 : fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) ;
00106
00107 Margin phiMargin = region.phiMargin();
00108 double phiLimit = (phiMargin.right() < 0.1 ) ? 0.1 : phiMargin.right();
00109
00110 double ptSeed = pSeed.perp();
00111 double ptMin = (region.ptMin()>3.5) ? 3.5: region.ptMin();
00112
00113 bool inEtaRange = etaSeed >= (etaRange.mean() - etaLimit) && etaSeed <= (etaRange.mean() + etaLimit) ;
00114 bool inPhiRange = (fabs(deltaPhi(phiSeed,double(region.direction().phi()))) < phiLimit );
00115
00116 bool inPtRange = ptSeed >= ptMin && ptSeed<= 2*(muR->pt());
00117
00118
00119 if(seed->nHits()==3) inPtRange = true;
00120
00121
00122 if(inPtRange && usePt_Cleaner && !useDirection_Cleaner) {
00123
00124 result.push_back(*seed);
00125 LogDebug("TrackerSeedCleaner")<<" Keeping the seed : this seed passed pt selection";
00126 }
00127
00128
00129 if( inEtaRange && inPhiRange && !usePt_Cleaner && useDirection_Cleaner) {
00130
00131 result.push_back(*seed);
00132 LogDebug("TrackerSeedCleaner")<<" Keeping the seed : this seed passed direction selection";
00133
00134 }
00135
00136
00137 if( inEtaRange && inPhiRange && inPtRange && usePt_Cleaner && useDirection_Cleaner) {
00138
00139 result.push_back(*seed);
00140 LogDebug("TrackerSeedCleaner")<<" Keeping the seed : this seed passed direction and pt selection";
00141
00142 }
00143
00144
00145 LogDebug("TrackerSeedCleaner")<<" eta for current seed "<<etaSeed<<"\n"
00146 <<" phi for current seed "<<phiSeed<<"\n"
00147 <<" eta for L2 track "<<muR->eta()<<"\n"
00148 <<" phi for L2 track "<<muR->phi()<<"\n";
00149
00150
00151 }
00152
00153
00154 if(result.size()!=0 && (useDirection_Cleaner || usePt_Cleaner)) seeds.swap(result);
00155
00156 LogDebug("TrackerSeedCleaner")<<seeds.size()<<" trajectory seeds to the events after cleaning"<<endl;
00157
00158 return;
00159
00160 }
00161