CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
31 
33 
34 using namespace std;
35 using namespace edm;
36 
37 //
38 // inizialization
39 //
41  theProxyService = service;
42 
43  theRedundantCleaner = new RedundantSeedCleaner();
44 }
45 
46 //
47 //
48 //
49 void TrackerSeedCleaner::setEvent(const edm::Event& event) { event.getByToken(beamspotToken_, bsHandle_); }
50 
51 //
52 // clean seeds
53 //
56  tkSeeds& seeds) {
57  // call the shared input cleaner
58  if (cleanBySharedHits)
59  theRedundantCleaner->define(seeds);
60 
61  theTTRHBuilder = theProxyService->eventSetup().getHandle(theTTRHBuilderToken);
62 
63  LogDebug("TrackerSeedCleaner") << seeds.size() << " trajectory seeds to the events before cleaning" << endl;
64 
65  //check the validity otherwise vertexing
66  const reco::BeamSpot& bs = *bsHandle_;
67  /*reco track and seeds as arguments. Seeds eta and phi are checked and
68  based on deviation from L2 eta and phi seed is accepted or not*/
69 
70  std::vector<TrajectorySeed> result;
71 
72  TSCBLBuilderNoMaterial tscblBuilder;
73  // PerigeeConversions tspConverter;
74  for (TrajectorySeedCollection::iterator seed = seeds.begin(); seed < seeds.end(); ++seed) {
75  if (seed->nHits() < 2)
76  continue;
77  //get parameters and errors from the seed state
78  TransientTrackingRecHit::RecHitPointer recHit = theTTRHBuilder->build(&*(seed->recHits().end() - 1));
80  seed->startingState(), recHit->surface(), theProxyService->magneticField().product());
81 
82  TrajectoryStateClosestToBeamLine tsAtClosestApproachSeed =
83  tscblBuilder(*state.freeState(), bs); //as in TrackProducerAlgorithms
84  if (!tsAtClosestApproachSeed.isValid())
85  continue;
86  GlobalPoint vSeed1 = tsAtClosestApproachSeed.trackStateAtPCA().position();
87  GlobalVector pSeed = tsAtClosestApproachSeed.trackStateAtPCA().momentum();
88  GlobalPoint vSeed(vSeed1.x() - bs.x0(), vSeed1.y() - bs.y0(), vSeed1.z() - bs.z0());
89 
90  //eta,phi info from seeds
91  double etaSeed = state.globalMomentum().eta();
92  double phiSeed = pSeed.phi();
93 
94  //if the limits are too stringent rescale limits
96  typedef TkTrackingRegionsMargin<float> Margin;
97 
98  Range etaRange = region.etaRange();
99  double etaLimit = (fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) < 0.1)
100  ? 0.1
101  : fabs(fabs(etaRange.max()) - fabs(etaRange.mean()));
102 
103  Margin phiMargin = region.phiMargin();
104  double phiLimit = (phiMargin.right() < 0.1) ? 0.1 : phiMargin.right();
105 
106  double ptSeed = pSeed.perp();
107  double ptMin = (region.ptMin() > 3.5) ? 3.5 : region.ptMin();
108  // Clean
109  bool inEtaRange = etaSeed >= (etaRange.mean() - etaLimit) && etaSeed <= (etaRange.mean() + etaLimit);
110  bool inPhiRange = (fabs(deltaPhi(phiSeed, double(region.direction().phi()))) < phiLimit);
111  // pt cleaner
112  bool inPtRange = ptSeed >= ptMin && ptSeed <= 2 * (muR->pt());
113 
114  // save efficiency don't clean triplets with pt cleaner
115  if (seed->nHits() == 3)
116  inPtRange = true;
117 
118  // use pt and angle cleaners
119  if (inPtRange && usePt_Cleaner && !useDirection_Cleaner) {
120  result.push_back(*seed);
121  LogDebug("TrackerSeedCleaner") << " Keeping the seed : this seed passed pt selection";
122  }
123 
124  // use only angle default option
125  if (inEtaRange && inPhiRange && !usePt_Cleaner && useDirection_Cleaner) {
126  result.push_back(*seed);
127  LogDebug("TrackerSeedCleaner") << " Keeping the seed : this seed passed direction selection";
128  }
129 
130  // use all the cleaners
131  if (inEtaRange && inPhiRange && inPtRange && usePt_Cleaner && useDirection_Cleaner) {
132  result.push_back(*seed);
133  LogDebug("TrackerSeedCleaner") << " Keeping the seed : this seed passed direction and pt selection";
134  }
135 
136  LogDebug("TrackerSeedCleaner") << " eta for current seed " << etaSeed << "\n"
137  << " phi for current seed " << phiSeed << "\n"
138  << " eta for L2 track " << muR->eta() << "\n"
139  << " phi for L2 track " << muR->phi() << "\n";
140  }
141 
142  //the new seeds collection
143  if (!result.empty() && (useDirection_Cleaner || usePt_Cleaner))
144  seeds.swap(result);
145 
146  LogDebug("TrackerSeedCleaner") << seeds.size() << " trajectory seeds to the events after cleaning" << endl;
147 
148  return;
149 }
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
constexpr float ptMin
T y() const
Definition: PV3DBase.h:60
virtual void setEvent(const edm::Event &)
setEvent
tuple result
Definition: mps_fire.py:311
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
GlobalVector globalMomentum() const
double y0() const
y coordinate
Definition: BeamSpot.h:63
tuple RedundantSeedCleaner
virtual void init(const MuonServiceProxy *service)
intizialization
T x() const
Definition: PV3DBase.h:59
virtual void clean(const reco::TrackRef &, const RectangularEtaPhiTrackingRegion &region, tkSeeds &)
the cleaner
#define LogDebug(id)
double x0() const
x coordinate
Definition: BeamSpot.h:61
const Range & etaRange() const
allowed eta range [eta_min, eta_max] interval