CMS 3D CMS Logo

MTDDetLayerMeasurements.cc
Go to the documentation of this file.
1 
10 
13 
17 
18 typedef std::shared_ptr<GenericTransientTrackingRecHit> MTDRecHitPointer;
19 typedef std::vector<GenericTransientTrackingRecHit::RecHitPointer> MTDRecHitContainer;
21 
22 
25  theMTDRecHits(),
26  theMTDEventCacheID(0),
27  theEvent(nullptr)
28 {
29  mtdToken_ = iC.consumes<MTDTrackingRecHit>(mtdlabel);
30 }
31 
33 
35  const edm::Event& iEvent)
36 {
37  DetId geoId = geomDet->geographicalId();
38  theEvent = &iEvent;
40 
42 
43  // Create the ChamberId
44  DetId detId(geoId.rawId());
45  LogDebug("Track|RecoMTD|MTDDetLayerMeasurements") << "(MTD): "<<detId<<std::endl;
46 
47  // Get the MTD-Segment which relies on this chamber
48  //auto cmp = [](const unsigned one, const unsigned two) -> bool { return one < two; };
49  auto detset = (*theMTDRecHits)[detId];
50 
51  for (const auto & rechit : detset)
52  result.push_back(GenericTransientTrackingRecHit::build(geomDet, &rechit));
53 
54  return result;
55 }
56 
58 {
59  LogDebug("Track|RecoMTD|MTDDetLayerMeasurements") << "Checking MTD RecHits";
60  checkEvent();
61  auto cacheID = theEvent->cacheIdentifier();
62  if (cacheID == theMTDEventCacheID) return;
63 
64  {
66  theMTDEventCacheID = cacheID;
67  }
68  if(!theMTDRecHits.isValid())
69  {
70  throw cms::Exception("MTDDetLayerMeasurements") << "Cannot get MTD RecHits";
71  LogDebug("Track|RecoMTD|MTDDetLayerMeasurements") << "Cannot get MTD RecHits";
72  }
73 }
74 
78  const TrajectoryStateOnSurface& startingState,
79  const Propagator& prop,
80  const MeasurementEstimator& est) {
81  checkEvent();
82  return measurements(layer, startingState, prop, est, *theEvent);
83 }
84 
85 
88  const TrajectoryStateOnSurface& startingState,
89  const Propagator& prop,
90  const MeasurementEstimator& est,
91  const edm::Event& iEvent) {
92 
94 
95  std::vector<DetWithState> dss = layer->compatibleDets(startingState, prop, est);
96  LogDebug("RecoMTD")<<"compatibleDets: "<<dss.size()<<std::endl;
97 
98  for(const auto& dws: dss) {
99 
100  MeasurementContainer detMeasurements
101  = measurements(layer, dws.first, dws.second, est, iEvent);
102  result.insert(result.end(), detMeasurements.begin(), detMeasurements.end());
103  }
104 
105  if (!result.empty()) sort( result.begin(), result.end(), TrajMeasLessEstim());
106 
107  return result;
108 }
109 
110 
113  const GeomDet* det,
114  const TrajectoryStateOnSurface& stateOnDet,
115  const MeasurementEstimator& est,
116  const edm::Event& iEvent) {
118 
119  // Get the Segments which relies on the GeomDet given by compatibleDets
120  MTDRecHitContainer mtdRecHits = recHits(det, iEvent);
121 
122  // Create the Trajectory Measurement
123  for(auto rechit = mtdRecHits.begin();
124  rechit != mtdRecHits.end(); ++rechit) {
125 
126  MeasurementEstimator::HitReturnType estimate = est.estimate(stateOnDet,**rechit);
127  LogDebug("RecoMTD")<<"Dimension: "<<(*rechit)->dimension()
128  <<" Chi2: "<<estimate.second<<std::endl;
129  if (estimate.first) {
130  result.push_back(TrajectoryMeasurement(stateOnDet, *rechit,
131  estimate.second,layer));
132  }
133  }
134 
135  if (!result.empty()) sort( result.begin(), result.end(), TrajMeasLessEstim());
136 
137  return result;
138 }
139 
140 
141 
144  const TrajectoryStateOnSurface& theStateOnDet,
145  const TrajectoryStateOnSurface& startingState,
146  const Propagator& prop,
147  const MeasurementEstimator& est,
148  const edm::Event& iEvent) {
150  MTDRecHitContainer rhs = recHits(layer, iEvent);
151  for (MTDRecHitContainer::value_type irh: rhs) {
152  MeasurementEstimator::HitReturnType estimate = est.estimate(theStateOnDet, (*irh));
153  if (estimate.first)
154  {
155  result.push_back(TrajectoryMeasurement(theStateOnDet,irh,
156  estimate.second,layer));
157  }
158  }
159 
160  if (!result.empty()) {
161  sort( result.begin(), result.end(), TrajMeasLessEstim());
162  }
163 
164  return result;
165 }
166 
170  const TrajectoryStateOnSurface& theStateOnDet,
171  const TrajectoryStateOnSurface& startingState,
172  const Propagator& prop,
173  const MeasurementEstimator& est) {
174  checkEvent();
175  return fastMeasurements(layer, theStateOnDet, startingState, prop, est, *theEvent);
176 }
177 
178 
179 std::vector<TrajectoryMeasurementGroup>
181  const TrajectoryStateOnSurface& startingState,
182  const Propagator& prop,
183  const MeasurementEstimator& est) {
184  checkEvent();
185  return groupedMeasurements(layer, startingState, prop, est, *theEvent);
186 }
187 
188 
189 std::vector<TrajectoryMeasurementGroup>
191  const TrajectoryStateOnSurface& startingState,
192  const Propagator& prop,
193  const MeasurementEstimator& est,
194  const edm::Event& iEvent) {
195 
196  std::vector<TrajectoryMeasurementGroup> result;
197  // if we want to use the concept of InvalidRecHits,
198  // we can reuse LayerMeasurements from TrackingTools/MeasurementDet
199  std::vector<DetGroup> groups(layer->groupedCompatibleDets(startingState, prop, est));
200 
201  for (const auto& grp : groups) {
202 
203  std::vector<TrajectoryMeasurement> groupMeasurements;
204  for (const auto& detAndStateItr : grp) {
205 
206  std::vector<TrajectoryMeasurement> detMeasurements
207  = measurements(layer, detAndStateItr.det(), detAndStateItr.trajectoryState(), est, iEvent);
208  groupMeasurements.insert(groupMeasurements.end(), detMeasurements.begin(), detMeasurements.end());
209  }
210 
211  if (!groupMeasurements.empty())
212  std::sort( groupMeasurements.begin(), groupMeasurements.end(), TrajMeasLessEstim());
213 
214  result.push_back(TrajectoryMeasurementGroup(groupMeasurements, grp));
215  }
216 
217  return result;
218 }
219 
222  theEvent = &event;
223 }
224 
225 
227  if(!theEvent)
228  throw cms::Exception("MTDDetLayerMeasurements") << "The event has not been set";
229 }
230 
232  const edm::Event& iEvent) {
233  MTDRecHitContainer rhs;
234 
235  std::vector <const GeomDet*> gds = layer->basicComponents();
236 
237  for (const GeomDet* igd : gds) {
238  MTDRecHitContainer detHits = recHits(igd, iEvent);
239  rhs.insert(rhs.end(), detHits.begin(), detHits.end());
240  }
241  return rhs;
242 }
243 
245 {
246  checkEvent();
247  return recHits(layer, *theEvent);
248 }
249 
#define LogDebug(id)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
MTDRecHitContainer recHits(const DetLayer *layer, const edm::Event &iEvent)
returns the rechits which are on the layer
std::vector< TrajectoryMeasurement > MeasurementContainer
void checkEvent() const
check that the event is set, and throw otherwise
virtual std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
virtual const std::vector< const GeomDet * > & basicComponents() const =0
edm::Event::CacheIdentifier_t theMTDEventCacheID
#define nullptr
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
MTDDetLayerMeasurements::MeasurementContainer MeasurementContainer
std::vector< TrajectoryMeasurementGroup > groupedMeasurements(const DetLayer *layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est, const edm::Event &iEvent)
std::vector< GenericTransientTrackingRecHit::RecHitPointer > MTDRecHitContainer
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
void setEvent(const edm::Event &)
set event
MeasurementContainer fastMeasurements(const DetLayer *layer, const TrajectoryStateOnSurface &theStateOnDet, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est, const edm::Event &iEvent)
faster version in case the TrajectoryState on the surface of the GeomDet is already available ...
int iEvent
Definition: GenABIO.cc:224
static RecHitPointer build(const GeomDet *geom, const TrackingRecHit *rh)
CacheIdentifier_t cacheIdentifier() const
Definition: Event.cc:35
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
MeasurementContainer measurements(const DetLayer *layer, const GeomDet *det, const TrajectoryStateOnSurface &stateOnDet, const MeasurementEstimator &est, const edm::Event &iEvent)
edm::Handle< edmNew::DetSetVector< MTDTrackingRecHit > > theMTDRecHits
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
bool isValid() const
Definition: HandleBase.h:74
std::pair< bool, double > HitReturnType
edm::EDGetTokenT< MTDTrackingRecHit > mtdToken_
Definition: DetId.h:18
MTDDetLayerMeasurements(edm::InputTag mtdlabel, edm::ConsumesCollector &iC)
A 2D TrackerRecHit with time and time error information.
std::vector< GenericTransientTrackingRecHit::RecHitPointer > MTDRecHitContainer
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
std::shared_ptr< GenericTransientTrackingRecHit > MTDRecHitPointer
Definition: event.py:1