CMS 3D CMS Logo

CosmicTrackingRegion.cc
Go to the documentation of this file.
5 
13 
15 
17 
18 namespace {
19  template <class T>
20  T sqr(T t) {
21  return t * t;
22  }
23 } // namespace
24 
25 using namespace std;
26 
27 void CosmicTrackingRegion::checkTracks(reco::TrackCollection const& tracks, std::vector<bool>& mask) const {
28  const math::XYZPoint regOrigin(origin().x(), origin().y(), origin().z());
29 
30  assert(mask.size() == tracks.size());
31  int i = -1;
32  for (auto const& track : tracks) {
33  i++;
34  if (mask[i])
35  continue;
36 
37  if (track.pt() < ptMin()) {
38  continue;
39  }
40  if (std::abs(track.dxy(regOrigin)) > originRBound()) {
41  continue;
42  }
43  if (std::abs(track.dz(regOrigin)) > originZBound()) {
44  continue;
45  }
46 
47  mask[i] = true;
48  }
49 }
50 
52  const SeedingLayerSetsHits::SeedingLayer& layer) const {
54  hits_(es, layer, result);
55  return result;
56 }
57 
58 template <typename T>
60  //get and name collections
61  //++++++++++++++++++++++++
62 
63  //detector layer
64  const DetLayer* detLayer = layer.detLayer();
65  LogDebug("CosmicTrackingRegion") << "Looking at hits on subdet/layer " << layer.name();
66  EtaPhiMeasurementEstimator est(0.3, 0.3);
67 
68  //magnetic field
70  es.get<IdealMagneticFieldRecord>().get(field);
71  const MagneticField* magField = field.product();
72 
73  //region
74  const GlobalPoint vtx = origin();
75  GlobalVector dir = direction();
76  LogDebug("CosmicTrackingRegion") << "The initial region characteristics are:"
77  << "\n"
78  << " Origin = " << origin() << "\n"
79  << " Direction = " << direction() << "\n"
80  << " Eta = " << origin().eta() << "\n"
81  << " Phi = " << origin().phi();
82 
83  //trajectory state on surface
84  float phi = dir.phi();
85  Surface::RotationType rot(sin(phi), -cos(phi), 0, 0, 0, -1, cos(phi), sin(phi), 0);
86 
89  TrajectoryStateOnSurface tsos(fts, *surface);
90  LogDebug("CosmicTrackingRegion") << "The state used to find measurement with the measurement tracker is:\n" << tsos;
91 
92  //propagator
93  AnalyticalPropagator prop(magField, alongMomentum);
94 
95  //propagation verification (debug)
96  //++++++++++++++++++++++++++++++++
97 
98  //creation of the state
99  TrajectoryStateOnSurface stateOnLayer = prop.propagate(*tsos.freeState(), detLayer->surface());
100 
101  //verification of the state
102  if (stateOnLayer.isValid()) {
103  LogDebug("CosmicTrackingRegion") << "The initial state propagates to the layer surface: \n"
104  << stateOnLayer << "R = " << stateOnLayer.globalPosition().perp() << "\n"
105  << "Eta = " << stateOnLayer.globalPosition().eta() << "\n"
106  << "Phi = " << stateOnLayer.globalPosition().phi();
107 
108  } else {
109  LogDebug("CosmicTrackingRegion") << "The initial state does not propagate to the layer surface.";
110  }
111 
112  //number of compatible dets
114  vector<DetWithState> compatDets = detLayer->compatibleDets(tsos, prop, est);
115  LogDebug("CosmicTrackingRegion") << "Compatible dets = " << compatDets.size();
116 
117  //get hits
118  //++++++++
119 
120  //measurement tracker (find hits)
121  LayerMeasurements lm(theMeasurementTracker_->measurementTracker(), *theMeasurementTracker_);
122  vector<TrajectoryMeasurement> meas = lm.measurements(*detLayer, tsos, prop, est);
123  LogDebug("CosmicTrackingRegion") << "Number of Trajectory measurements = " << meas.size()
124  << " but the last one is always an invalid hit, by construction.";
125 
126  //trajectory measurement
127 
128  // std::cout <<"CRegion b " << cache.size() << std::endl;
129 
130  // waiting for a migration at LayerMeasurements level and at seed builder level
131  for (auto const& im : meas) {
132  if (!im.recHit()->isValid())
133  continue;
134  assert(!trackerHitRTTI::isUndef(*im.recHit()->hit()));
135  auto ptrHit = (BaseTrackerRecHit*)(im.recHit()->hit()->clone());
136  cache.emplace_back(ptrHit);
137  result.emplace_back(ptrHit);
138  }
139 
140  // std::cout <<"CRegion a " << cache.size() << std::endl;
141 }
Vector3DBase
Definition: Vector3DBase.h:8
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
TkRotation< float >
CosmicTrackingRegion::checkTracks
void checkTracks(reco::TrackCollection const &tracks, std::vector< bool > &mask) const override
Definition: CosmicTrackingRegion.cc:27
TrajectoryStateOnSurface.h
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
LayerMeasurements::measurements
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Definition: LayerMeasurements.cc:122
mps_fire.i
i
Definition: mps_fire.py:428
FreeTrajectoryState.h
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
GlobalTrajectoryParameters.h
CosmicTrackingRegion.h
ESHandle.h
DetLayer
Definition: DetLayer.h:21
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
CosmicTrackingRegion::hits
TrackingRegion::Hits hits(const edm::EventSetup &es, const SeedingLayerSetsHits::SeedingLayer &layer) const override
get hits from layer compatible with region constraints
Definition: CosmicTrackingRegion.cc:51
ptMin
constexpr float ptMin
Definition: PhotonIDValueMapProducer.cc:155
sqr
int sqr(const T &t)
Definition: pfalgo_common_ref.h:9
cms::cuda::assert
assert(be >=bs)
trackerHitRTTI::isUndef
bool isUndef(TrackingRecHit const &hit)
Definition: trackerHitRTTI.h:24
CosmicTrackingRegion::hits_
void hits_(const edm::EventSetup &es, const T &layer, TrackingRegion::Hits &result) const
Definition: CosmicTrackingRegion.cc:59
TrajectoryMeasurement.h
GeometricSearchDet::compatibleDets
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Definition: GeometricSearchDet.cc:35
ReferenceCountingPointer< Plane >
CkfComponentsRecord.h
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
LayerMeasurements
Definition: LayerMeasurements.h:18
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TrajectoryStateOnSurface::freeState
FreeTrajectoryState const * freeState(bool withErrors=true) const
Definition: TrajectoryStateOnSurface.h:58
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
EtaPhiMeasurementEstimator.h
TrackingRegion::Hits
SeedingLayerSetsHits::Hits Hits
Definition: TrackingRegion.h:47
BaseTrackerRecHit
Definition: BaseTrackerRecHit.h:15
LayerMeasurements.h
edm::ESHandle< MagneticField >
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
Point3DBase< float, GlobalTag >
utilities.cache
def cache(function)
Definition: utilities.py:3
AnalyticalPropagator_cfi.AnalyticalPropagator
AnalyticalPropagator
Definition: AnalyticalPropagator_cfi.py:3
Plane::build
static PlanePointer build(Args &&... args)
Definition: Plane.h:33
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
EtaPhiMeasurementEstimator
Definition: EtaPhiMeasurementEstimator.h:15
edm::EventSetup
Definition: EventSetup.h:57
AnalyticalPropagator.h
DetWithState
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
Definition: RPCRecHitFilter.h:58
GeometricSearchDet::DetWithState
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
Definition: GeometricSearchDet.h:19
get
#define get
SeedingLayerSetsHits::SeedingLayer
Definition: SeedingLayerSetsHits.h:37
std
Definition: JetResolutionObject.h:76
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
T
long double T
Definition: Basic3DVectorLD.h:48
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
GeometricSearchDet::surface
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
DetLayer.h
BoundPlane.h
mps_fire.result
result
Definition: mps_fire.py:311
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
MagneticField
Definition: MagneticField.h:19
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
alongMomentum
Definition: PropagationDirection.h:4
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
MeasurementTracker.h
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23