CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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  * $Date: 2011/12/22 21:08:03 $
6  * $Revision: 1.10 $
7  \author A. Grelli - Purdue University, Pavia University
8  */
9 
11 
12 //---------------
13 // C++ Headers --
14 //---------------
15 #include <vector>
16 
17 //-------------------------------
18 // Collaborating Class Headers --
19 //-------------------------------
22 
26 
34 
38 
39 using namespace std;
40 using namespace edm;
41 
42 //
43 // inizialization
44 //
46 
47  theProxyService = service;
48 
49  theRedundantCleaner = new RedundantSeedCleaner();
50 }
51 
52 //
53 //
54 //
56 {
57  event.getByLabel(theBeamSpotTag, bsHandle_);
58 }
59 
60 //
61 // clean seeds
62 //
64 
65 
66  // call the shared input cleaner
67  if(cleanBySharedHits) theRedundantCleaner->define(seeds);
68 
69  theProxyService->eventSetup().get<TransientRecHitRecord>().get(builderName_,theTTRHBuilder);
70 
71  LogDebug("TrackerSeedCleaner")<<seeds.size()<<" trajectory seeds to the events before cleaning"<<endl;
72 
73  //check the validity otherwise vertexing
74  const reco::BeamSpot & bs = *bsHandle_;
75  /*reco track and seeds as arguments. Seeds eta and phi are checked and
76  based on deviation from L2 eta and phi seed is accepted or not*/
77 
78  std::vector<TrajectorySeed > result;
79 
80 
81  TSCBLBuilderNoMaterial tscblBuilder;
82  // PerigeeConversions tspConverter;
83  for(TrajectorySeedCollection::iterator seed = seeds.begin(); seed<seeds.end(); ++seed){
84  if(seed->nHits() < 2) continue;
85  //get parameters and errors from the seed state
86  TransientTrackingRecHit::RecHitPointer recHit = theTTRHBuilder->build(&*(seed->recHits().second-1));
87  TrajectoryStateOnSurface state = trajectoryStateTransform::transientState( seed->startingState(), recHit->surface(), theProxyService->magneticField().product());
88 
89  TrajectoryStateClosestToBeamLine tsAtClosestApproachSeed = tscblBuilder(*state.freeState(),bs);//as in TrackProducerAlgorithms
90  if (!tsAtClosestApproachSeed.isValid()) continue;
91  GlobalPoint vSeed1 = tsAtClosestApproachSeed.trackStateAtPCA().position();
92  GlobalVector pSeed = tsAtClosestApproachSeed.trackStateAtPCA().momentum();
93  GlobalPoint vSeed(vSeed1.x()-bs.x0(),vSeed1.y()-bs.y0(),vSeed1.z()-bs.z0());
94 
95 
96  //eta,phi info from seeds
97  double etaSeed = state.globalMomentum().eta();
98  double phiSeed = pSeed.phi();
99 
100  //if the limits are too stringent rescale limits
102  typedef TkTrackingRegionsMargin< float > Margin;
103 
104  Range etaRange = region.etaRange();
105  double etaLimit = (fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) <0.1) ? 0.1 : fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) ;
106 
107  Margin phiMargin = region.phiMargin();
108  double phiLimit = (phiMargin.right() < 0.1 ) ? 0.1 : phiMargin.right();
109 
110  double ptSeed = pSeed.perp();
111  double ptMin = (region.ptMin()>3.5) ? 3.5: region.ptMin();
112  // Clean
113  bool inEtaRange = etaSeed >= (etaRange.mean() - etaLimit) && etaSeed <= (etaRange.mean() + etaLimit) ;
114  bool inPhiRange = (fabs(deltaPhi(phiSeed,double(region.direction().phi()))) < phiLimit );
115  // pt cleaner
116  bool inPtRange = ptSeed >= ptMin && ptSeed<= 2*(muR->pt());
117 
118  // save efficiency don't clean triplets with pt cleaner
119  if(seed->nHits()==3) inPtRange = true;
120 
121  // use pt and angle cleaners
122  if(inPtRange && usePt_Cleaner && !useDirection_Cleaner) {
123 
124  result.push_back(*seed);
125  LogDebug("TrackerSeedCleaner")<<" Keeping the seed : this seed passed pt selection";
126  }
127 
128  // use only angle default option
129  if( inEtaRange && inPhiRange && !usePt_Cleaner && useDirection_Cleaner) {
130 
131  result.push_back(*seed);
132  LogDebug("TrackerSeedCleaner")<<" Keeping the seed : this seed passed direction selection";
133 
134  }
135 
136  // use all the cleaners
137  if( inEtaRange && inPhiRange && inPtRange && usePt_Cleaner && useDirection_Cleaner) {
138 
139  result.push_back(*seed);
140  LogDebug("TrackerSeedCleaner")<<" Keeping the seed : this seed passed direction and pt selection";
141 
142  }
143 
144 
145  LogDebug("TrackerSeedCleaner")<<" eta for current seed "<<etaSeed<<"\n"
146  <<" phi for current seed "<<phiSeed<<"\n"
147  <<" eta for L2 track "<<muR->eta()<<"\n"
148  <<" phi for L2 track "<<muR->phi()<<"\n";
149 
150 
151  }
152 
153  //the new seeds collection
154  if(result.size()!=0 && (useDirection_Cleaner || usePt_Cleaner)) seeds.swap(result);
155 
156  LogDebug("TrackerSeedCleaner")<<seeds.size()<<" trajectory seeds to the events after cleaning"<<endl;
157 
158  return;
159 
160 }
161 
#define LogDebug(id)
double z0() const
z coordinate
Definition: BeamSpot.h:69
T perp() const
Definition: PV3DBase.h:71
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
T y() const
Definition: PV3DBase.h:62
virtual GlobalVector direction() const
the direction around which region is constructed
virtual void setEvent(const edm::Event &)
setEvent
FreeTrajectoryState * freeState(bool withErrors=true) const
virtual float ptMin() const
minimal pt of interest
std::vector< TrajectorySeed > tkSeeds
T z() const
Definition: PV3DBase.h:63
tuple result
Definition: query.py:137
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
PixelRecoRange< float > Range
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
char state
Definition: procUtils.cc:75
T eta() const
Definition: PV3DBase.h:75
GlobalVector globalMomentum() const
double y0() const
y coordinate
Definition: BeamSpot.h:67
virtual void init(const MuonServiceProxy *service)
intizialization
T x() const
Definition: PV3DBase.h:61
virtual void clean(const reco::TrackRef &, const RectangularEtaPhiTrackingRegion &region, tkSeeds &)
the cleaner
double x0() const
x coordinate
Definition: BeamSpot.h:65
const Range & etaRange() const
allowed eta range [eta_min, eta_max] interval