CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripFineDelayTLA.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <string>
3 #include <iostream>
4 #include <TMath.h>
6 
25 
26 using namespace std;
28  conf_(conf)
29 {
30  refitter_ = new SimpleTrackRefitter(conf);
31 }
32 
34 {
35  // get geometry
37  es.get<TrackerDigiGeometryRecord>().get(estracker);
38  tracker=&(*estracker);
39  // the refitter
41 }
42 
43 // Virtual destructor needed.
45 {
46  delete refitter_;
47 }
48 
49 std::vector<std::pair< std::pair<DetId, LocalPoint> ,float> > SiStripFineDelayTLA::findtrackangle(const reco::Track& theT)
50 {
51  std::vector<Trajectory> traj = refitter_->refitTrack(theT);
52  return findtrackangle(traj);
53 }
54 
55 std::vector<std::pair< std::pair<DetId, LocalPoint> ,float> > SiStripFineDelayTLA::findtrackangle(const TrajectorySeed& seed, const reco::Track& theT){
56  vector<Trajectory> traj = refitter_->refitTrack(seed,theT);
57  return findtrackangle(traj);
58 }
59 
60 std::vector<std::pair< std::pair<DetId, LocalPoint> ,float> > SiStripFineDelayTLA::findtrackangle(const std::vector<Trajectory>& trajVec)
61 {
62  if (trajVec.size()) {
63  return findtrackangle(trajVec.front()); }
64  std::vector<std::pair< std::pair<DetId, LocalPoint> ,float> > hitangleassociation;
65  return hitangleassociation;
66 }
67 
68 std::vector<std::pair< std::pair<DetId, LocalPoint> ,float> > SiStripFineDelayTLA::findtrackangle(const Trajectory& traj)
69 {
70  std::vector<std::pair< std::pair<DetId, LocalPoint> ,float> >hitangleassociation;
71  std::vector<TrajectoryMeasurement> TMeas=traj.measurements();
72  std::vector<TrajectoryMeasurement>::iterator itm;
73  for (itm=TMeas.begin();itm!=TMeas.end();itm++){
74  TrajectoryStateOnSurface tsos=itm->updatedState();
75  const TransientTrackingRecHit::ConstRecHitPointer thit=itm->recHit();
76  const SiStripMatchedRecHit2D* matchedhit=dynamic_cast<const SiStripMatchedRecHit2D*>((*thit).hit());
77  const SiStripRecHit2D* hit=dynamic_cast<const SiStripRecHit2D*>((*thit).hit());
78  LocalVector trackdirection=tsos.localDirection();
79  if(matchedhit){//if matched hit...
80  GluedGeomDet * gdet=(GluedGeomDet *)tracker->idToDet(matchedhit->geographicalId());
81  GlobalVector gtrkdir=gdet->toGlobal(trackdirection);
82  // trackdirection on mono det
83  // this the pointer to the mono hit of a matched hit
84  const SiStripRecHit2D *monohit=matchedhit->monoHit();
85  const GeomDetUnit * monodet=gdet->monoDet();
86  LocalVector monotkdir=monodet->toLocal(gtrkdir);
87  if(monotkdir.z()!=0){
88  // the local angle (mono)
89  float localpitch = ((StripTopology*)(&monodet->topology()))->localPitch(tsos.localPosition());
90  float thickness = ((((((monohit->geographicalId())>>25)&0x7f)==0xd)||
91  ((((monohit->geographicalId())>>25)&0x7f)==0xe))&&
92  ((((monohit->geographicalId())>>5)&0x7)>4)) ? 0.0500 : 0.0320;
93  float angle = computeAngleCorr(monotkdir, localpitch, thickness);
94  hitangleassociation.push_back(make_pair(make_pair(monohit->geographicalId(),monohit->localPosition()), angle));
95  // trackdirection on stereo det
96  // this the pointer to the stereo hit of a matched hit
97  const SiStripRecHit2D *stereohit=matchedhit->stereoHit();
98  const GeomDetUnit * stereodet=gdet->stereoDet();
99  LocalVector stereotkdir=stereodet->toLocal(gtrkdir);
100  if(stereotkdir.z()!=0){
101  // the local angle (stereo)
102  float localpitch = ((StripTopology*)(&stereodet->topology()))->localPitch(tsos.localPosition());
103  float thickness = ((((((stereohit->geographicalId())>>25)&0x7f)==0xd)||
104  ((((stereohit->geographicalId())>>25)&0x7f)==0xe))&&
105  ((((stereohit->geographicalId())>>5)&0x7)>4)) ? 0.0500 : 0.0320;
106  float angle = computeAngleCorr(stereotkdir, localpitch, thickness);
107  hitangleassociation.push_back(make_pair(make_pair(stereohit->geographicalId(),stereohit->localPosition()), angle));
108  }
109  }
110  }
111  else if(hit){
113  // hit= pointer to the rechit
114  if(trackdirection.z()!=0){
115  // the local angle (single hit)
116  float localpitch = ((StripTopology*)(&det->topology()))->localPitch(tsos.localPosition());
117  float thickness = ((((((hit->geographicalId())>>25)&0x7f)==0xd)||
118  ((((hit->geographicalId())>>25)&0x7f)==0xe))&&
119  ((((hit->geographicalId())>>5)&0x7)>4)) ? 0.0500 : 0.0320;
120  float angle = computeAngleCorr(trackdirection, localpitch, thickness);
121  hitangleassociation.push_back(make_pair(make_pair(hit->geographicalId(),hit->localPosition()), angle));
122  }
123  }
124  }
125  return hitangleassociation;
126 }
127 
128 double SiStripFineDelayTLA::computeAngleCorr(const LocalVector& v, double pitch, double thickness)
129 {
130  double v_xy = sqrt(v.x()*v.x()+v.y()*v.y());
131  double L = fabs(thickness*v_xy/v.z());
132  double Lmax = fabs(pitch/v.x()*v_xy);
133  if(L<Lmax) {
134  LogDebug("SiStripFineDelayTLA ") << L << " vs " << Lmax
135  << " Signal contained in strip. Correction is " << v.z()/v.mag();
136  return v.z()/v.mag();
137  } else {
138  LogDebug("SiStripFineDelayTLA ") << L << " vs " << Lmax
139  << " Signal not contained in strip. Correction is " << thickness/pitch*v.x()/v_xy*v.z()/v.mag()
140  << " instead of " << v.z()/v.mag();
141  return thickness/pitch*v.x()/v_xy*v.z()/v.mag();
142  }
143 }
144 
#define LogDebug(id)
SiStripFineDelayTLA(const edm::ParameterSet &conf)
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
SimpleTrackRefitter * refitter_
std::vector< Trajectory > refitTrack(const reco::Track &newTrack, const uint32_t ExcludedDetId=0)
The main methods.
const SiStripRecHit2D * stereoHit() const
LocalVector localDirection() const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
void init(const edm::Event &e, const edm::EventSetup &c)
T y() const
Definition: PV3DBase.h:57
double computeAngleCorr(const LocalVector &v, double pitch, double thickness)
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:64
virtual LocalPoint localPosition() const
DataContainer const & measurements() const
Definition: Trajectory.h:169
virtual const Topology & topology() const =0
T mag() const
Definition: PV3DBase.h:61
void setServices(const edm::EventSetup &es)
T sqrt(T t)
Definition: SSEVec.h:28
T z() const
Definition: PV3DBase.h:58
virtual const GeomDet * idToDet(DetId) const
tuple conf
Definition: dbtoconf.py:185
const T & get() const
Definition: EventSetup.h:55
std::vector< std::pair< std::pair< DetId, LocalPoint >,float > > findtrackangle(const TrajectorySeed &seed, const reco::Track &theT)
DetId geographicalId() const
const SiStripRecHit2D * monoHit() const
const TrackerGeometry * tracker
T x() const
Definition: PV3DBase.h:56
mathSSE::Vec4< T > v
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11