CMS 3D CMS Logo

TrackInfoProducerAlgorithm.cc
Go to the documentation of this file.
7 
13 
14 using namespace reco;
15 
16 void TrackInfoProducerAlgorithm::run(const edm::Ref<std::vector<Trajectory> > traj_iterator,
19  const TrackerGeometry* tracker) {
20  std::vector<TrajectoryMeasurement> measurements = traj_iterator->measurements();
21 
22  std::vector<TrajectoryMeasurement>::iterator traj_mes_iterator;
23  //edm::LogInfo("TrackInfoProducer") << "Number of Measurements: "<<measurements.size();
25  for (traj_mes_iterator = measurements.begin(); traj_mes_iterator != measurements.end();
26  ++traj_mes_iterator) { //loop on measurements
27 
28  TrajectoryStateOnSurface fwdtsos = traj_mes_iterator->forwardPredictedState();
29  TrajectoryStateOnSurface bwdtsos = traj_mes_iterator->backwardPredictedState();
30  TrajectoryStateOnSurface updatedtsos = traj_mes_iterator->updatedState();
31  TrajectoryStateCombiner statecombiner;
32  TrajectoryStateOnSurface combinedtsos = statecombiner.combine(fwdtsos, bwdtsos);
33 
34  ConstRecHitPointer ttrh = traj_mes_iterator->recHit();
36  if (ttrh->isValid())
37  pos = ttrh->hit()->localPosition();
38  unsigned int detid = ttrh->hit()->geographicalId().rawId();
39 
40  TrackingRecHitRef thehitref;
41  TrackingRecHit const* thehitptr = nullptr;
42  int i = 0, j = 0;
43 
44  for (auto const& thehit : track->recHits()) {
45  i++;
46  LocalPoint hitpos;
47  if (thehit->isValid())
48  hitpos = thehit->localPosition();
49  if (thehit->geographicalId().rawId() == detid && (hitpos - pos).mag() < 1e-4) {
50  thehitptr = thehit;
51  thehitref = track->extra()->recHitRef(i - 1);
52  j++;
53  break;
54  }
55  }
56 
59  PTrajectoryStateOnDet const& updatedptsod = trajectoryStateTransform::persistentState(updatedtsos, detid);
60  PTrajectoryStateOnDet const& combinedptsod = trajectoryStateTransform::persistentState(combinedtsos, detid);
61 
62  const ProjectedSiStripRecHit2D* phit = dynamic_cast<const ProjectedSiStripRecHit2D*>(thehitptr);
63  const SiStripMatchedRecHit2D* matchedhit = dynamic_cast<const SiStripMatchedRecHit2D*>(thehitptr);
64 
66  LocalVector monofwd, stereofwd;
67  LocalVector monobwd, stereobwd;
68  LocalVector monoco, stereoco;
69  LocalVector monoup, stereoup;
70 
71  LocalPoint pmonofwd, pstereofwd;
72  LocalPoint pmonobwd, pstereobwd;
73  LocalPoint pmonoco, pstereoco;
74  LocalPoint pmonoup, pstereoup;
75  if (matchedhit) {
76  type = Matched;
77  const GluedGeomDet* gdet = static_cast<const GluedGeomDet*>(tracker->idToDet(matchedhit->geographicalId()));
78 
79  GlobalVector gtrkdirfwd = gdet->toGlobal(fwdptsod.parameters().momentum());
80  GlobalVector gtrkdirbwd = gdet->toGlobal(bwdptsod.parameters().momentum());
81  GlobalVector gtrkdirup = gdet->toGlobal(updatedptsod.parameters().momentum());
82  GlobalVector gtrkdirco = gdet->toGlobal(combinedptsod.parameters().momentum());
83 
84  const GeomDetUnit* monodet = gdet->monoDet();
85 
86  monofwd = monodet->toLocal(gtrkdirfwd);
87  monobwd = monodet->toLocal(gtrkdirbwd);
88  monoup = monodet->toLocal(gtrkdirup);
89  monoco = monodet->toLocal(gtrkdirco);
90 
91  pmonofwd = project(gdet, monodet, fwdptsod.parameters().position(), monofwd);
92  pmonobwd = project(gdet, monodet, bwdptsod.parameters().position(), monobwd);
93  pmonoup = project(gdet, monodet, updatedptsod.parameters().position(), monoup);
94  pmonoco = project(gdet, monodet, combinedptsod.parameters().position(), monoco);
95 
96  const GeomDetUnit* stereodet = gdet->stereoDet();
97 
98  stereofwd = stereodet->toLocal(gtrkdirfwd);
99  stereobwd = stereodet->toLocal(gtrkdirbwd);
100  stereoup = stereodet->toLocal(gtrkdirup);
101  stereoco = stereodet->toLocal(gtrkdirco);
102 
103  pstereofwd = project(gdet, stereodet, fwdptsod.parameters().position(), stereofwd);
104  pstereobwd = project(gdet, stereodet, bwdptsod.parameters().position(), stereobwd);
105  pstereoup = project(gdet, stereodet, updatedptsod.parameters().position(), stereoup);
106  pstereoco = project(gdet, stereodet, combinedptsod.parameters().position(), stereoco);
107 
108  } else if (phit) {
109  type = Projected;
110  const GluedGeomDet* gdet = static_cast<const GluedGeomDet*>(tracker->idToDet(phit->geographicalId()));
111 
112  GlobalVector gtrkdirfwd = gdet->toGlobal(fwdptsod.parameters().momentum());
113  GlobalVector gtrkdirbwd = gdet->toGlobal(bwdptsod.parameters().momentum());
114  GlobalVector gtrkdirup = gdet->toGlobal(updatedptsod.parameters().momentum());
115  GlobalVector gtrkdirco = gdet->toGlobal(combinedptsod.parameters().momentum());
116  const SiStripRecHit2D& originalhit = phit->originalHit();
117  const GeomDetUnit* det;
118  if (!StripSubdetector(originalhit.geographicalId().rawId()).stereo()) {
119  det = gdet->monoDet();
120  monofwd = det->toLocal(gtrkdirfwd);
121  monobwd = det->toLocal(gtrkdirbwd);
122  monoup = det->toLocal(gtrkdirup);
123  monoco = det->toLocal(gtrkdirco);
124  pmonofwd = project(gdet, det, fwdptsod.parameters().position(), monofwd);
125  pmonobwd = project(gdet, det, bwdptsod.parameters().position(), monobwd);
126  pmonoup = project(gdet, det, updatedptsod.parameters().position(), monoup);
127  pmonoco = project(gdet, det, combinedptsod.parameters().position(), monoco);
128  } else {
129  det = gdet->stereoDet();
130  stereofwd = det->toLocal(gtrkdirfwd);
131  stereobwd = det->toLocal(gtrkdirbwd);
132  stereoup = det->toLocal(gtrkdirup);
133  stereoco = det->toLocal(gtrkdirco);
134  pstereofwd = project(gdet, det, fwdptsod.parameters().position(), stereofwd);
135  pstereobwd = project(gdet, det, bwdptsod.parameters().position(), stereobwd);
136  pstereoup = project(gdet, det, updatedptsod.parameters().position(), stereoup);
137  pstereoco = project(gdet, det, combinedptsod.parameters().position(), stereoco);
138  }
139  }
141  if (!forwardPredictedStateTag_.empty())
142  states.insert(std::make_pair(
143  FwPredicted,
144  TrackingStateInfo(std::make_pair(monofwd, stereofwd), std::make_pair(pmonofwd, pstereofwd), fwdptsod)));
145  if (!backwardPredictedStateTag_.empty())
146  states.insert(std::make_pair(
147  BwPredicted,
148  TrackingStateInfo(std::make_pair(monobwd, stereobwd), std::make_pair(pmonobwd, pstereobwd), bwdptsod)));
149  if (!updatedStateTag_.empty())
150  states.insert(std::make_pair(
151  Updated,
152  TrackingStateInfo(std::make_pair(monoup, stereoup), std::make_pair(pmonoup, pstereoup), updatedptsod)));
153  if (!combinedStateTag_.empty())
154  states.insert(std::make_pair(
155  Combined,
156  TrackingStateInfo(std::make_pair(monoco, stereoco), std::make_pair(pmonoco, pstereoco), combinedptsod)));
157 
158  TrackingRecHitInfo tkRecHitInfo(type, states);
159 
160  if (j != 0) {
161  trajinfo.insert(std::make_pair(thehitref, tkRecHitInfo));
162  }
163  // else edm::LogInfo("TrackInfoProducer") << "RecHit not associated ";
164  }
165  output = TrackInfo((traj_iterator->seed()), trajinfo);
166 }
167 
169  const GeomDet* projdet,
171  LocalVector trackdirection) const {
172  GlobalPoint globalpoint = (det->surface()).toGlobal(position);
173 
174  // position of the initial and final point of the strip in glued local coordinates
175  LocalPoint projposition = (projdet->surface()).toLocal(globalpoint);
176 
177  //correct the position with the track direction
178 
179  float scale = -projposition.z() / trackdirection.z();
180 
181  projposition += scale * trackdirection;
182 
183  return projposition;
184 }
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
T z() const
Definition: PV3DBase.h:61
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
LocalPoint project(const GeomDet *det, const GeomDet *projdet, LocalPoint position, LocalVector trackdirection) const
std::map< StateType, TrackingStateInfo > TrackingStates
LocalVector momentum() const
Momentum vector in the local frame.
TrackingRecHit::ConstRecHitPointer ConstRecHitPointer
const LocalTrajectoryParameters & parameters() const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:19
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
DetId geographicalId() const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:20
std::map< TrackingRecHitRef, TrackingRecHitInfo > TrajectoryInfo
default constructor
Definition: TrackInfo.h:26
fixed size matrix
SiStripRecHit2D originalHit() const
static int position[264][3]
Definition: ReadPGInfo.cc:289
void run(const edm::Ref< std::vector< Trajectory > > traj_iterator, reco::TrackRef track, reco::TrackInfo &output, const TrackerGeometry *tracker)
Definition: output.py:1
LocalPoint position() const
Local x and y position coordinates.
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const