CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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();
35  LocalPoint pos;
36  if (ttrh->isValid())pos=ttrh->hit()->localPosition() ;
37  nhit++;
38  unsigned int detid=ttrh->hit()->geographicalId().rawId();
39 
41  TrackingRecHitRef thehitref;
42  TrackingRecHit const * thehitptr=nullptr;
43  int i=0,j=0;
44 
45  for (thehit=track->recHitsBegin();thehit!=track->recHitsEnd();thehit++){
46  i++;
47  LocalPoint hitpos;
48  if ((*thehit)->isValid())hitpos=(*thehit)->localPosition();
49  if((*thehit)->geographicalId().rawId()==detid&&
50  (hitpos - pos).mag() < 1e-4)
51  {
52  thehitptr=(*thehit);
53  thehitref = track->extra()->recHitRef(i-1);
54  j++;
55  break;
56  }
57  }
58 
61  PTrajectoryStateOnDet const & updatedptsod=trajectoryStateTransform::persistentState( updatedtsos,detid);
62  PTrajectoryStateOnDet const & combinedptsod=trajectoryStateTransform::persistentState( combinedtsos,detid);
63 
64 
65  const ProjectedSiStripRecHit2D* phit=dynamic_cast<const ProjectedSiStripRecHit2D*>( thehitptr);
66  const SiStripMatchedRecHit2D* matchedhit=dynamic_cast<const SiStripMatchedRecHit2D*>( thehitptr);
67 
69  LocalVector monofwd, stereofwd;
70  LocalVector monobwd, stereobwd;
71  LocalVector monoco, stereoco;
72  LocalVector monoup, stereoup;
73 
74  LocalPoint pmonofwd, pstereofwd;
75  LocalPoint pmonobwd, pstereobwd;
76  LocalPoint pmonoco, pstereoco;
77  LocalPoint pmonoup, pstereoup;
78  if(matchedhit){
79  type=Matched;
80  GluedGeomDet * gdet=(GluedGeomDet *)tracker->idToDet(matchedhit->geographicalId());
81 
82  GlobalVector gtrkdirfwd=gdet->toGlobal(fwdptsod.parameters().momentum());
83  GlobalVector gtrkdirbwd=gdet->toGlobal(bwdptsod.parameters().momentum());
84  GlobalVector gtrkdirup=gdet->toGlobal(updatedptsod.parameters().momentum());
85  GlobalVector gtrkdirco=gdet->toGlobal(combinedptsod.parameters().momentum());
86 
87 
88 
89  const GeomDetUnit * monodet=gdet->monoDet();
90 
91  monofwd=monodet->toLocal(gtrkdirfwd);
92  monobwd=monodet->toLocal(gtrkdirbwd);
93  monoup=monodet->toLocal(gtrkdirup);
94  monoco=monodet->toLocal(gtrkdirco);
95 
96  pmonofwd=project(gdet,monodet,fwdptsod.parameters().position(),monofwd);
97  pmonobwd=project(gdet,monodet,bwdptsod.parameters().position(),monobwd);
98  pmonoup=project(gdet,monodet,updatedptsod.parameters().position(),monoup);
99  pmonoco=project(gdet,monodet,combinedptsod.parameters().position(),monoco);
100 
101 
102  const GeomDetUnit * stereodet=gdet->stereoDet();
103 
104  stereofwd=stereodet->toLocal(gtrkdirfwd);
105  stereobwd=stereodet->toLocal(gtrkdirbwd);
106  stereoup=stereodet->toLocal(gtrkdirup);
107  stereoco=stereodet->toLocal(gtrkdirco);
108 
109  pstereofwd=project(gdet,stereodet,fwdptsod.parameters().position(),stereofwd);
110  pstereobwd=project(gdet,stereodet,bwdptsod.parameters().position(),stereobwd);
111  pstereoup=project(gdet,stereodet,updatedptsod.parameters().position(),stereoup);
112  pstereoco=project(gdet,stereodet,combinedptsod.parameters().position(),stereoco);
113 
114 
115  }
116  else if(phit){
117  type=Projected;
118  GluedGeomDet * gdet=(GluedGeomDet *)tracker->idToDet(phit->geographicalId());
119 
120  GlobalVector gtrkdirfwd=gdet->toGlobal(fwdptsod.parameters().momentum());
121  GlobalVector gtrkdirbwd=gdet->toGlobal(bwdptsod.parameters().momentum());
122  GlobalVector gtrkdirup=gdet->toGlobal(updatedptsod.parameters().momentum());
123  GlobalVector gtrkdirco=gdet->toGlobal(combinedptsod.parameters().momentum());
124  const SiStripRecHit2D& originalhit=phit->originalHit();
125  const GeomDetUnit * det;
126  if(!StripSubdetector(originalhit.geographicalId().rawId()).stereo()){
127  det=gdet->monoDet();
128  monofwd= det->toLocal(gtrkdirfwd);
129  monobwd= det->toLocal(gtrkdirbwd);
130  monoup= det->toLocal(gtrkdirup);
131  monoco= det->toLocal(gtrkdirco);
132  pmonofwd=project(gdet,det,fwdptsod.parameters().position(),monofwd);
133  pmonobwd=project(gdet,det,bwdptsod.parameters().position(),monobwd);
134  pmonoup=project(gdet,det,updatedptsod.parameters().position(),monoup);
135  pmonoco=project(gdet,det,combinedptsod.parameters().position(),monoco);
136  }
137  else{
138  det=gdet->stereoDet();
139  stereofwd= det->toLocal(gtrkdirfwd);
140  stereobwd= det->toLocal(gtrkdirbwd);
141  stereoup= det->toLocal(gtrkdirup);
142  stereoco= det->toLocal(gtrkdirco);
143  pstereofwd=project(gdet,det,fwdptsod.parameters().position(),stereofwd);
144  pstereobwd=project(gdet,det,bwdptsod.parameters().position(),stereobwd);
145  pstereoup=project(gdet,det,updatedptsod.parameters().position(),stereoup);
146  pstereoco=project(gdet,det,combinedptsod.parameters().position(),stereoco);
147  }
148  }
150  if(forwardPredictedStateTag_!="") states.insert(std::make_pair(FwPredicted, TrackingStateInfo(std::make_pair(monofwd,stereofwd), std::make_pair(pmonofwd,pstereofwd), fwdptsod)));
151  if(backwardPredictedStateTag_!="")states.insert(std::make_pair(BwPredicted, TrackingStateInfo(std::make_pair(monobwd,stereobwd), std::make_pair(pmonobwd,pstereobwd), bwdptsod)));
152  if(updatedStateTag_!="")states.insert(std::make_pair(Updated, TrackingStateInfo(std::make_pair(monoup,stereoup), std::make_pair(pmonoup,pstereoup), updatedptsod)));
153  if(combinedStateTag_!="")states.insert(std::make_pair(Combined, TrackingStateInfo(std::make_pair(monoco,stereoco), std::make_pair(pmonoco,pstereoco), combinedptsod)));
154 
155  TrackingRecHitInfo tkRecHitInfo(type, states);
156 
157 
158 
159  if(j!=0){
160  trajinfo.insert(std::make_pair(thehitref,tkRecHitInfo));
161  }
162  // else edm::LogInfo("TrackInfoProducer") << "RecHit not associated ";
163  }
164  //edm::LogInfo("TrackInfoProducer") << "Found "<<nhit<< " hits";
165  //if(fwdtrajinfo.size()!=nhit) edm::LogInfo("TrackInfoProducer") << "Number of trackinfos "<<fwdtrajinfo.size()<< " doesn't match!";
166  output=TrackInfo((traj_iterator->seed()),trajinfo);
167 
168 }
169 
171 {
172 
173  GlobalPoint globalpoint=(det->surface()).toGlobal(position);
174 
175  // position of the initial and final point of the strip in glued local coordinates
176  LocalPoint projposition=(projdet->surface()).toLocal(globalpoint);
177 
178  //correct the position with the track direction
179 
180  float scale=-projposition.z()/trackdirection.z();
181 
182  projposition+= scale*trackdirection;
183 
184  return projposition;
185 }
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
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:52
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:67
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::map< StateType, TrackingStateInfo > TrackingStates
T z() const
Definition: PV3DBase.h:64
TrackingRecHit::ConstRecHitPointer ConstRecHitPointer
int j
Definition: DBlmapReader.cc:9
LocalVector momentum() const
Momentum vector in the local frame.
SiStripRecHit2D originalHit() const
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)
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
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
std::map< TrackingRecHitRef, TrackingRecHitInfo > TrajectoryInfo
default constructor
Definition: TrackInfo.h:26
virtual const TrackerGeomDet * idToDet(DetId) const