CMS 3D CMS Logo

ClusterShapeTrajectoryFilter.cc
Go to the documentation of this file.
1 // VI January 2012: needs to be migrated to use cluster directly
2 
3 
5 
7 
13 
16 
24 
27 
29 
32 
34 
35 #include <vector>
36 using namespace std;
37 
38 /*****************************************************************************/
40  theCacheToken(iC.consumes<SiPixelClusterShapeCache>(iConfig.getParameter<edm::InputTag>("cacheSrc"))),
41  theFilter(nullptr)
42 {}
43 
45 {
46 }
47 
50  iSetup.get<TrajectoryFilter::Record>().get("ClusterShapeHitFilter", shape);
51  theFilter = shape.product();
52 
54  iEvent.getByToken(theCacheToken, cache);
55  theCache = cache.product();
56 }
57 
58 /*****************************************************************************/
60  (Trajectory& trajectory) const
61 {
62  assert(theCache);
63  vector<TrajectoryMeasurement> tms = trajectory.measurements();
64 
65  for(vector<TrajectoryMeasurement>::const_iterator
66  tm = tms.begin(); tm!= tms.end(); tm++)
67  {
68  const TrackingRecHit* ttRecHit = &(*((*tm).recHit()));
69 
70  if(ttRecHit->isValid())
71  {
72  const TrackingRecHit * tRecHit = ttRecHit->hit();
73 
74  TrajectoryStateOnSurface ts = (*tm).updatedState();
75  const GlobalVector gdir = ts.globalDirection();
76 
83  { // pixel
84  const SiPixelRecHit* recHit =
85  dynamic_cast<const SiPixelRecHit *>(tRecHit);
86 
87  if(recHit != nullptr)
88  return theFilter->isCompatible(*recHit, gdir, *theCache);
89  }
90  else if(GeomDetEnumerators::isTrackerStrip(ttRecHit->det()->subDetector()))
91  { // strip
92  if(dynamic_cast<const SiStripMatchedRecHit2D *>(tRecHit) != nullptr)
93  { // glued
95  dynamic_cast<const SiStripMatchedRecHit2D *>(tRecHit);
96 
97  if(recHit != nullptr)
98  {
99  return (theFilter->isCompatible(recHit->monoHit() , gdir) &&
100  theFilter->isCompatible(recHit->stereoHit(), gdir));
101  }
102  }
103  else
104  { // single
105  if(dynamic_cast<const SiStripRecHit2D *>(tRecHit) != nullptr)
106  { // normal
107  const SiStripRecHit2D* recHit =
108  dynamic_cast<const SiStripRecHit2D *>(tRecHit);
109 
110  if(recHit != nullptr)
111  return theFilter->isCompatible(*recHit, gdir);
112  }
113  else
114  { // projected
116  dynamic_cast<const ProjectedSiStripRecHit2D *>(tRecHit);
117 
118  if(recHit != nullptr)
119  return theFilter->isCompatible(recHit->originalHit(), gdir);
120  }
121  }
122  }
123  }
124  }
125 
126  return true;
127 }
128 
129 /*****************************************************************************/
131  (TempTrajectory& trajectory) const
132 {
133  assert(theCache);
134  const TempTrajectory::DataContainer& tms = trajectory.measurements();
135 
137  tm = tms.rbegin(); tm!= tms.rend(); --tm)
138  {
139  const TrackingRecHit* ttRecHit = &(*((*tm).recHit()));
140 
141  if(ttRecHit->isValid())
142  {
143  const TrackingRecHit * tRecHit = ttRecHit->hit();
144 
145  TrajectoryStateOnSurface ts = (*tm).updatedState();
146  GlobalVector gdir = ts.globalDirection();
147 
154  { // pixel
155  const SiPixelRecHit* recHit =
156  dynamic_cast<const SiPixelRecHit *>(tRecHit);
157 
158  if(recHit != nullptr)
159  if(! theFilter->isCompatible(*recHit, gdir, *theCache))
160  {
161  LogTrace("TrajectFilter")
162  << " [TrajectFilter] fail pixel";
163  return false;
164  }
165  }
166  else if(GeomDetEnumerators::isTrackerStrip(ttRecHit->det()->subDetector()))
167  { // strip
168  if(dynamic_cast<const SiStripMatchedRecHit2D *>(tRecHit) != nullptr)
169  { // glued
171  dynamic_cast<const SiStripMatchedRecHit2D *>(tRecHit);
172 
173  if(recHit != nullptr)
174  {
175  if(! theFilter->isCompatible(recHit->monoHit(), gdir))
176  {
177  LogTrace("TrajectFilter")
178  << " [TrajectFilter] fail strip matched 1st";
179  return false;
180  }
181 
182  if(! theFilter->isCompatible(recHit->stereoHit(), gdir))
183  {
184  LogTrace("TrajectFilter")
185  << " [TrajectFilter] fail strip matched 2nd";
186  return false;
187  }
188  }
189  }
190  else
191  { // single
192  if(dynamic_cast<const SiStripRecHit2D *>(tRecHit) != nullptr)
193  { // normal
194  const SiStripRecHit2D* recHit =
195  dynamic_cast<const SiStripRecHit2D *>(tRecHit);
196 
197  if(recHit != nullptr)
198  if(! theFilter->isCompatible(*recHit, gdir))
199  {
200  LogTrace("TrajectFilter")
201  << " [TrajectFilter] fail strip single";
202  return false;
203  }
204  }
205  else
206  { // projected
208  dynamic_cast<const ProjectedSiStripRecHit2D *>(tRecHit);
209 
210  if(recHit != nullptr)
211  if(! theFilter->isCompatible(recHit->originalHit(), gdir))
212  {
213  LogTrace("TrajectFilter")
214  << " [TrajectFilter] fail strip projected";
215  return false;
216  }
217  }
218  }
219  }
220  }
221  }
222 
223  return true;
224 }
225 
226 /*****************************************************************************/
228  (const Trajectory& trajectory) const
229 {
230  return true;
231 }
232 
233 /*****************************************************************************/
235  (const TempTrajectory& trajectory) const
236 {
237  TempTrajectory t = trajectory;
238 
239  // Check if ok
240  if(toBeContinued(t)) return true;
241 
242  // Should take out last
243  if(t.measurements().size() <= 3) return false;
244 
245  return true;
246 }
247 
edm::EDGetTokenT< SiPixelClusterShapeCache > theCacheToken
const_iterator rend() const
Definition: bqueue.h:164
ClusterShapeTrajectoryFilter(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
void setEvent(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
const DataContainer & measurements() const
#define nullptr
bool toBeContinued(TempTrajectory &) const override
const ClusterShapeHitFilter * theFilter
DataContainer const & measurements() const
Definition: Trajectory.h:196
int iEvent
Definition: GenABIO.cc:224
const GeomDet * det() const
bool qualityFilter(const TempTrajectory &) const override
const SiPixelClusterShapeCache * theCache
#define LogTrace(id)
bool isCompatible(const SiPixelRecHit &recHit, const LocalVector &ldir, const SiPixelClusterShapeCache &clusterShapeCache, PixelData const *pd=0) const
bool isTrackerStrip(GeomDetEnumerators::SubDetector m)
const_iterator rbegin() const
Definition: bqueue.h:163
SiStripRecHit2D originalHit() const
virtual TrackingRecHit const * hit() const
SiStripRecHit2D stereoHit() const
T const * product() const
Definition: Handle.h:74
bool isValid() const
SiStripRecHit2D monoHit() const
HLT enums.
def cache(function)
Definition: utilities.py:3
T get() const
Definition: EventSetup.h:71
size_type size() const
Definition: bqueue.h:167
virtual SubDetector subDetector() const
Which subdetector.
Definition: GeomDet.cc:44
T const * product() const
Definition: ESHandle.h:86
GlobalVector globalDirection() const
Our base class.
Definition: SiPixelRecHit.h:23