CMS 3D CMS Logo

TrackerSeedCleaner.cc
Go to the documentation of this file.
1 /*
2  * \class TrackerSeedCleaner
3  * Reference class for seeds cleaning
4  * Seeds Cleaner based on sharedHits cleaning, direction cleaning and pt cleaning
5  \author A. Grelli - Purdue University, Pavia University
6  */
7 
9 
10 //---------------
11 // C++ Headers --
12 //---------------
13 #include <vector>
14 
15 //-------------------------------
16 // Collaborating Class Headers --
17 //-------------------------------
20 
24 
32 
36 
37 using namespace std;
38 using namespace edm;
39 
40 //
41 // inizialization
42 //
44  theProxyService = service;
45 
46  theRedundantCleaner = new RedundantSeedCleaner();
47 }
48 
49 //
50 //
51 //
52 void TrackerSeedCleaner::setEvent(const edm::Event& event) { event.getByToken(beamspotToken_, bsHandle_); }
53 
54 //
55 // clean seeds
56 //
59  tkSeeds& seeds) {
60  // call the shared input cleaner
61  if (cleanBySharedHits)
62  theRedundantCleaner->define(seeds);
63 
64  theProxyService->eventSetup().get<TransientRecHitRecord>().get(builderName_, theTTRHBuilder);
65 
66  LogDebug("TrackerSeedCleaner") << seeds.size() << " trajectory seeds to the events before cleaning" << endl;
67 
68  //check the validity otherwise vertexing
69  const reco::BeamSpot& bs = *bsHandle_;
70  /*reco track and seeds as arguments. Seeds eta and phi are checked and
71  based on deviation from L2 eta and phi seed is accepted or not*/
72 
73  std::vector<TrajectorySeed> result;
74 
75  TSCBLBuilderNoMaterial tscblBuilder;
76  // PerigeeConversions tspConverter;
77  for (TrajectorySeedCollection::iterator seed = seeds.begin(); seed < seeds.end(); ++seed) {
78  if (seed->nHits() < 2)
79  continue;
80  //get parameters and errors from the seed state
81  TransientTrackingRecHit::RecHitPointer recHit = theTTRHBuilder->build(&*(seed->recHits().second - 1));
83  seed->startingState(), recHit->surface(), theProxyService->magneticField().product());
84 
85  TrajectoryStateClosestToBeamLine tsAtClosestApproachSeed =
86  tscblBuilder(*state.freeState(), bs); //as in TrackProducerAlgorithms
87  if (!tsAtClosestApproachSeed.isValid())
88  continue;
89  GlobalPoint vSeed1 = tsAtClosestApproachSeed.trackStateAtPCA().position();
90  GlobalVector pSeed = tsAtClosestApproachSeed.trackStateAtPCA().momentum();
91  GlobalPoint vSeed(vSeed1.x() - bs.x0(), vSeed1.y() - bs.y0(), vSeed1.z() - bs.z0());
92 
93  //eta,phi info from seeds
94  double etaSeed = state.globalMomentum().eta();
95  double phiSeed = pSeed.phi();
96 
97  //if the limits are too stringent rescale limits
99  typedef TkTrackingRegionsMargin<float> Margin;
100 
101  Range etaRange = region.etaRange();
102  double etaLimit = (fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) < 0.1)
103  ? 0.1
104  : fabs(fabs(etaRange.max()) - fabs(etaRange.mean()));
105 
106  Margin phiMargin = region.phiMargin();
107  double phiLimit = (phiMargin.right() < 0.1) ? 0.1 : phiMargin.right();
108 
109  double ptSeed = pSeed.perp();
110  double ptMin = (region.ptMin() > 3.5) ? 3.5 : region.ptMin();
111  // Clean
112  bool inEtaRange = etaSeed >= (etaRange.mean() - etaLimit) && etaSeed <= (etaRange.mean() + etaLimit);
113  bool inPhiRange = (fabs(deltaPhi(phiSeed, double(region.direction().phi()))) < phiLimit);
114  // pt cleaner
115  bool inPtRange = ptSeed >= ptMin && ptSeed <= 2 * (muR->pt());
116 
117  // save efficiency don't clean triplets with pt cleaner
118  if (seed->nHits() == 3)
119  inPtRange = true;
120 
121  // use pt and angle cleaners
122  if (inPtRange && usePt_Cleaner && !useDirection_Cleaner) {
123  result.push_back(*seed);
124  LogDebug("TrackerSeedCleaner") << " Keeping the seed : this seed passed pt selection";
125  }
126 
127  // use only angle default option
128  if (inEtaRange && inPhiRange && !usePt_Cleaner && useDirection_Cleaner) {
129  result.push_back(*seed);
130  LogDebug("TrackerSeedCleaner") << " Keeping the seed : this seed passed direction selection";
131  }
132 
133  // use all the cleaners
134  if (inEtaRange && inPhiRange && inPtRange && usePt_Cleaner && useDirection_Cleaner) {
135  result.push_back(*seed);
136  LogDebug("TrackerSeedCleaner") << " Keeping the seed : this seed passed direction and pt selection";
137  }
138 
139  LogDebug("TrackerSeedCleaner") << " eta for current seed " << etaSeed << "\n"
140  << " phi for current seed " << phiSeed << "\n"
141  << " eta for L2 track " << muR->eta() << "\n"
142  << " phi for L2 track " << muR->phi() << "\n";
143  }
144 
145  //the new seeds collection
146  if (!result.empty() && (useDirection_Cleaner || usePt_Cleaner))
147  seeds.swap(result);
148 
149  LogDebug("TrackerSeedCleaner") << seeds.size() << " trajectory seeds to the events after cleaning" << endl;
150 
151  return;
152 }
#define LogDebug(id)
double z0() const
z coordinate
Definition: BeamSpot.h:65
T perp() const
Definition: PV3DBase.h:69
PixelRecoRange< float > Range
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T y() const
Definition: PV3DBase.h:60
virtual void setEvent(const edm::Event &)
setEvent
GlobalVector const & direction() const
the direction around which region is constructed
FreeTrajectoryState const * freeState(bool withErrors=true) const
std::vector< TrajectorySeed > tkSeeds
T z() const
Definition: PV3DBase.h:61
std::shared_ptr< TrackingRecHit const > RecHitPointer
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
float ptMin() const
minimal pt of interest
T eta() const
Definition: PV3DBase.h:73
HLT enums.
GlobalVector globalMomentum() const
double y0() const
y coordinate
Definition: BeamSpot.h:63
virtual void init(const MuonServiceProxy *service)
intizialization
T x() const
Definition: PV3DBase.h:59
Definition: event.py:1
virtual void clean(const reco::TrackRef &, const RectangularEtaPhiTrackingRegion &region, tkSeeds &)
the cleaner
double x0() const
x coordinate
Definition: BeamSpot.h:61
const Range & etaRange() const
allowed eta range [eta_min, eta_max] interval