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,TrackRef track,
18 {
19 
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  int nhit=0;
26  for(traj_mes_iterator=measurements.begin();traj_mes_iterator!=measurements.end();++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())pos=ttrh->hit()->localPosition() ;
37  nhit++;
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())hitpos=thehit->localPosition();
48  if(thehit->geographicalId().rawId()==detid&&
49  (hitpos - pos).mag() < 1e-4)
50  {
51  thehitptr= thehit;
52  thehitref = track->extra()->recHitRef(i-1);
53  j++;
54  break;
55  }
56  }
57 
60  PTrajectoryStateOnDet const & updatedptsod=trajectoryStateTransform::persistentState( updatedtsos,detid);
61  PTrajectoryStateOnDet const & combinedptsod=trajectoryStateTransform::persistentState( combinedtsos,detid);
62 
63 
64  const ProjectedSiStripRecHit2D* phit=dynamic_cast<const ProjectedSiStripRecHit2D*>( thehitptr);
65  const SiStripMatchedRecHit2D* matchedhit=dynamic_cast<const SiStripMatchedRecHit2D*>( thehitptr);
66 
68  LocalVector monofwd, stereofwd;
69  LocalVector monobwd, stereobwd;
70  LocalVector monoco, stereoco;
71  LocalVector monoup, stereoup;
72 
73  LocalPoint pmonofwd, pstereofwd;
74  LocalPoint pmonobwd, pstereobwd;
75  LocalPoint pmonoco, pstereoco;
76  LocalPoint pmonoup, pstereoup;
77  if(matchedhit){
78  type=Matched;
79  const GluedGeomDet * gdet=static_cast<const GluedGeomDet *>(tracker->idToDet(matchedhit->geographicalId()));
80 
81  GlobalVector gtrkdirfwd=gdet->toGlobal(fwdptsod.parameters().momentum());
82  GlobalVector gtrkdirbwd=gdet->toGlobal(bwdptsod.parameters().momentum());
83  GlobalVector gtrkdirup=gdet->toGlobal(updatedptsod.parameters().momentum());
84  GlobalVector gtrkdirco=gdet->toGlobal(combinedptsod.parameters().momentum());
85 
86 
87 
88  const GeomDetUnit * monodet=gdet->monoDet();
89 
90  monofwd=monodet->toLocal(gtrkdirfwd);
91  monobwd=monodet->toLocal(gtrkdirbwd);
92  monoup=monodet->toLocal(gtrkdirup);
93  monoco=monodet->toLocal(gtrkdirco);
94 
95  pmonofwd=project(gdet,monodet,fwdptsod.parameters().position(),monofwd);
96  pmonobwd=project(gdet,monodet,bwdptsod.parameters().position(),monobwd);
97  pmonoup=project(gdet,monodet,updatedptsod.parameters().position(),monoup);
98  pmonoco=project(gdet,monodet,combinedptsod.parameters().position(),monoco);
99 
100 
101  const GeomDetUnit * stereodet=gdet->stereoDet();
102 
103  stereofwd=stereodet->toLocal(gtrkdirfwd);
104  stereobwd=stereodet->toLocal(gtrkdirbwd);
105  stereoup=stereodet->toLocal(gtrkdirup);
106  stereoco=stereodet->toLocal(gtrkdirco);
107 
108  pstereofwd=project(gdet,stereodet,fwdptsod.parameters().position(),stereofwd);
109  pstereobwd=project(gdet,stereodet,bwdptsod.parameters().position(),stereobwd);
110  pstereoup=project(gdet,stereodet,updatedptsod.parameters().position(),stereoup);
111  pstereoco=project(gdet,stereodet,combinedptsod.parameters().position(),stereoco);
112 
113 
114  }
115  else if(phit){
116  type=Projected;
117  const GluedGeomDet * gdet=static_cast<const GluedGeomDet *>(tracker->idToDet(phit->geographicalId()));
118 
119  GlobalVector gtrkdirfwd=gdet->toGlobal(fwdptsod.parameters().momentum());
120  GlobalVector gtrkdirbwd=gdet->toGlobal(bwdptsod.parameters().momentum());
121  GlobalVector gtrkdirup=gdet->toGlobal(updatedptsod.parameters().momentum());
122  GlobalVector gtrkdirco=gdet->toGlobal(combinedptsod.parameters().momentum());
123  const SiStripRecHit2D& originalhit=phit->originalHit();
124  const GeomDetUnit * det;
125  if(!StripSubdetector(originalhit.geographicalId().rawId()).stereo()){
126  det=gdet->monoDet();
127  monofwd= det->toLocal(gtrkdirfwd);
128  monobwd= det->toLocal(gtrkdirbwd);
129  monoup= det->toLocal(gtrkdirup);
130  monoco= det->toLocal(gtrkdirco);
131  pmonofwd=project(gdet,det,fwdptsod.parameters().position(),monofwd);
132  pmonobwd=project(gdet,det,bwdptsod.parameters().position(),monobwd);
133  pmonoup=project(gdet,det,updatedptsod.parameters().position(),monoup);
134  pmonoco=project(gdet,det,combinedptsod.parameters().position(),monoco);
135  }
136  else{
137  det=gdet->stereoDet();
138  stereofwd= det->toLocal(gtrkdirfwd);
139  stereobwd= det->toLocal(gtrkdirbwd);
140  stereoup= det->toLocal(gtrkdirup);
141  stereoco= det->toLocal(gtrkdirco);
142  pstereofwd=project(gdet,det,fwdptsod.parameters().position(),stereofwd);
143  pstereobwd=project(gdet,det,bwdptsod.parameters().position(),stereobwd);
144  pstereoup=project(gdet,det,updatedptsod.parameters().position(),stereoup);
145  pstereoco=project(gdet,det,combinedptsod.parameters().position(),stereoco);
146  }
147  }
149  if(!forwardPredictedStateTag_.empty()) states.insert(std::make_pair(FwPredicted, TrackingStateInfo(std::make_pair(monofwd,stereofwd), std::make_pair(pmonofwd,pstereofwd), fwdptsod)));
150  if(!backwardPredictedStateTag_.empty())states.insert(std::make_pair(BwPredicted, TrackingStateInfo(std::make_pair(monobwd,stereobwd), std::make_pair(pmonobwd,pstereobwd), bwdptsod)));
151  if(!updatedStateTag_.empty())states.insert(std::make_pair(Updated, TrackingStateInfo(std::make_pair(monoup,stereoup), std::make_pair(pmonoup,pstereoup), updatedptsod)));
152  if(!combinedStateTag_.empty())states.insert(std::make_pair(Combined, TrackingStateInfo(std::make_pair(monoco,stereoco), std::make_pair(pmonoco,pstereoco), combinedptsod)));
153 
154  TrackingRecHitInfo tkRecHitInfo(type, states);
155 
156 
157 
158  if(j!=0){
159  trajinfo.insert(std::make_pair(thehitref,tkRecHitInfo));
160  }
161  // else edm::LogInfo("TrackInfoProducer") << "RecHit not associated ";
162  }
163  //edm::LogInfo("TrackInfoProducer") << "Found "<<nhit<< " hits";
164  //if(fwdtrajinfo.size()!=nhit) edm::LogInfo("TrackInfoProducer") << "Number of trackinfos "<<fwdtrajinfo.size()<< " doesn't match!";
165  output=TrackInfo((traj_iterator->seed()),trajinfo);
166 
167 }
168 
170 {
171 
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 }
type
Definition: HCALResponse.h:21
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const
LocalPoint position() const
Local x and y position coordinates.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:69
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
std::map< StateType, TrackingStateInfo > TrackingStates
T z() const
Definition: PV3DBase.h:64
TrackingRecHit::ConstRecHitPointer ConstRecHitPointer
LocalVector momentum() const
Momentum vector in the local frame.
SiStripRecHit2D originalHit() const
fixed size matrix
static int position[264][3]
Definition: ReadPGInfo.cc:509
void run(const edm::Ref< std::vector< Trajectory > > traj_iterator, reco::TrackRef track, reco::TrackInfo &output, const TrackerGeometry *tracker)
const TrackerGeomDet * idToDet(DetId) const override
DetId geographicalId() const
LocalPoint project(const GeomDet *det, const GeomDet *projdet, LocalPoint position, LocalVector trackdirection) const
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
const LocalTrajectoryParameters & parameters() const
std::map< TrackingRecHitRef, TrackingRecHitInfo > TrajectoryInfo
default constructor
Definition: TrackInfo.h:26