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  int i=0,j=0;
43 
44  for (thehit=track->recHitsBegin();thehit!=track->recHitsEnd();thehit++){
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  thehitref=(*thehit);
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 
63  const ProjectedSiStripRecHit2D* phit=dynamic_cast<const ProjectedSiStripRecHit2D*>( &*(thehitref));
64  const SiStripMatchedRecHit2D* matchedhit=dynamic_cast<const SiStripMatchedRecHit2D*>( &*(thehitref));
65 
67  LocalVector monofwd, stereofwd;
68  LocalVector monobwd, stereobwd;
69  LocalVector monoco, stereoco;
70  LocalVector monoup, stereoup;
71 
72  LocalPoint pmonofwd, pstereofwd;
73  LocalPoint pmonobwd, pstereobwd;
74  LocalPoint pmonoco, pstereoco;
75  LocalPoint pmonoup, pstereoup;
76  if(matchedhit){
77  type=Matched;
78  GluedGeomDet * gdet=(GluedGeomDet *)tracker->idToDet(matchedhit->geographicalId());
79 
80  GlobalVector gtrkdirfwd=gdet->toGlobal(fwdptsod.parameters().momentum());
81  GlobalVector gtrkdirbwd=gdet->toGlobal(bwdptsod.parameters().momentum());
82  GlobalVector gtrkdirup=gdet->toGlobal(updatedptsod.parameters().momentum());
83  GlobalVector gtrkdirco=gdet->toGlobal(combinedptsod.parameters().momentum());
84 
85 
86 
87  const GeomDetUnit * monodet=gdet->monoDet();
88 
89  monofwd=monodet->toLocal(gtrkdirfwd);
90  monobwd=monodet->toLocal(gtrkdirbwd);
91  monoup=monodet->toLocal(gtrkdirup);
92  monoco=monodet->toLocal(gtrkdirco);
93 
94  pmonofwd=project(gdet,monodet,fwdptsod.parameters().position(),monofwd);
95  pmonobwd=project(gdet,monodet,bwdptsod.parameters().position(),monobwd);
96  pmonoup=project(gdet,monodet,updatedptsod.parameters().position(),monoup);
97  pmonoco=project(gdet,monodet,combinedptsod.parameters().position(),monoco);
98 
99 
100  const GeomDetUnit * stereodet=gdet->stereoDet();
101 
102  stereofwd=stereodet->toLocal(gtrkdirfwd);
103  stereobwd=stereodet->toLocal(gtrkdirbwd);
104  stereoup=stereodet->toLocal(gtrkdirup);
105  stereoco=stereodet->toLocal(gtrkdirco);
106 
107  pstereofwd=project(gdet,stereodet,fwdptsod.parameters().position(),stereofwd);
108  pstereobwd=project(gdet,stereodet,bwdptsod.parameters().position(),stereobwd);
109  pstereoup=project(gdet,stereodet,updatedptsod.parameters().position(),stereoup);
110  pstereoco=project(gdet,stereodet,combinedptsod.parameters().position(),stereoco);
111 
112 
113  }
114  else if(phit){
115  type=Projected;
116  GluedGeomDet * gdet=(GluedGeomDet *)tracker->idToDet(phit->geographicalId());
117 
118  GlobalVector gtrkdirfwd=gdet->toGlobal(fwdptsod.parameters().momentum());
119  GlobalVector gtrkdirbwd=gdet->toGlobal(bwdptsod.parameters().momentum());
120  GlobalVector gtrkdirup=gdet->toGlobal(updatedptsod.parameters().momentum());
121  GlobalVector gtrkdirco=gdet->toGlobal(combinedptsod.parameters().momentum());
122  const SiStripRecHit2D& originalhit=phit->originalHit();
123  const GeomDetUnit * det;
124  if(!StripSubdetector(originalhit.geographicalId().rawId()).stereo()){
125  det=gdet->monoDet();
126  monofwd= det->toLocal(gtrkdirfwd);
127  monobwd= det->toLocal(gtrkdirbwd);
128  monoup= det->toLocal(gtrkdirup);
129  monoco= det->toLocal(gtrkdirco);
130  pmonofwd=project(gdet,det,fwdptsod.parameters().position(),monofwd);
131  pmonobwd=project(gdet,det,bwdptsod.parameters().position(),monobwd);
132  pmonoup=project(gdet,det,updatedptsod.parameters().position(),monoup);
133  pmonoco=project(gdet,det,combinedptsod.parameters().position(),monoco);
134  }
135  else{
136  det=gdet->stereoDet();
137  stereofwd= det->toLocal(gtrkdirfwd);
138  stereobwd= det->toLocal(gtrkdirbwd);
139  stereoup= det->toLocal(gtrkdirup);
140  stereoco= det->toLocal(gtrkdirco);
141  pstereofwd=project(gdet,det,fwdptsod.parameters().position(),stereofwd);
142  pstereobwd=project(gdet,det,bwdptsod.parameters().position(),stereobwd);
143  pstereoup=project(gdet,det,updatedptsod.parameters().position(),stereoup);
144  pstereoco=project(gdet,det,combinedptsod.parameters().position(),stereoco);
145  }
146  }
148  if(forwardPredictedStateTag_!="") states.insert(std::make_pair(FwPredicted, TrackingStateInfo(std::make_pair(monofwd,stereofwd), std::make_pair(pmonofwd,pstereofwd), fwdptsod)));
149  if(backwardPredictedStateTag_!="")states.insert(std::make_pair(BwPredicted, TrackingStateInfo(std::make_pair(monobwd,stereobwd), std::make_pair(pmonobwd,pstereobwd), bwdptsod)));
150  if(updatedStateTag_!="")states.insert(std::make_pair(Updated, TrackingStateInfo(std::make_pair(monoup,stereoup), std::make_pair(pmonoup,pstereoup), updatedptsod)));
151  if(combinedStateTag_!="")states.insert(std::make_pair(Combined, TrackingStateInfo(std::make_pair(monoco,stereoco), std::make_pair(pmonoco,pstereoco), combinedptsod)));
152 
153  TrackingRecHitInfo tkRecHitInfo(type, states);
154 
155 
156 
157  if(j!=0){
158  trajinfo.insert(std::make_pair(thehitref,tkRecHitInfo));
159  }
160  // else edm::LogInfo("TrackInfoProducer") << "RecHit not associated ";
161  }
162  //edm::LogInfo("TrackInfoProducer") << "Found "<<nhit<< " hits";
163  //if(fwdtrajinfo.size()!=nhit) edm::LogInfo("TrackInfoProducer") << "Number of trackinfos "<<fwdtrajinfo.size()<< " doesn't match!";
164  output=TrackInfo((traj_iterator->seed()),trajinfo);
165 
166 }
167 
169 {
170 
171  GlobalPoint globalpoint=(det->surface()).toGlobal(position);
172 
173  // position of the initial and final point of the strip in glued local coordinates
174  LocalPoint projposition=(projdet->surface()).toLocal(globalpoint);
175 
176  //correct the position with the track direction
177 
178  float scale=-projposition.z()/trackdirection.z();
179 
180  projposition+= scale*trackdirection;
181 
182  return projposition;
183 }
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:47
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:62
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
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.
virtual const GeomDet * idToDet(DetId) const
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
std::map< TrackingRecHitRef, TrackingRecHitInfo > TrajectoryInfo
default constructor
Definition: TrackInfo.h:26