CMS 3D CMS Logo

SiStripFineDelayTLA.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <string>
3 #include <iostream>
4 #include <TMath.h>
6 
24 
25 using namespace std;
27 
29  // get geometry
31  es.get<TrackerDigiGeometryRecord>().get(estracker);
32  tracker = &(*estracker);
33 }
34 
35 // Virtual destructor needed.
37 
38 std::vector<std::pair<std::pair<DetId, LocalPoint>, float> > SiStripFineDelayTLA::findtrackangle(
39  const std::vector<Trajectory>& trajVec) {
40  if (!trajVec.empty()) {
41  return findtrackangle(trajVec.front());
42  }
43  std::vector<std::pair<std::pair<DetId, LocalPoint>, float> > hitangleassociation;
44  return hitangleassociation;
45 }
46 
47 std::vector<std::pair<std::pair<DetId, LocalPoint>, float> > SiStripFineDelayTLA::findtrackangle(
48  const Trajectory& traj) {
49  std::vector<std::pair<std::pair<DetId, LocalPoint>, float> > hitangleassociation;
50  std::vector<TrajectoryMeasurement> TMeas = traj.measurements();
51  std::vector<TrajectoryMeasurement>::iterator itm;
52  for (itm = TMeas.begin(); itm != TMeas.end(); itm++) {
53  TrajectoryStateOnSurface tsos = itm->updatedState();
54  auto thit = itm->recHit();
55  const SiStripMatchedRecHit2D* matchedhit = dynamic_cast<const SiStripMatchedRecHit2D*>((*thit).hit());
56  const SiStripRecHit2D* hit = dynamic_cast<const SiStripRecHit2D*>((*thit).hit());
57  LocalVector trackdirection = tsos.localDirection();
58  if (matchedhit) { //if matched hit...
59  const GluedGeomDet* gdet = static_cast<const GluedGeomDet*>(tracker->idToDet(matchedhit->geographicalId()));
60  GlobalVector gtrkdir = gdet->toGlobal(trackdirection);
61  // trackdirection on mono det
62  // this the pointer to the mono hit of a matched hit
63  const SiStripRecHit2D monohit = matchedhit->monoHit();
64  const GeomDetUnit* monodet = gdet->monoDet();
65  LocalVector monotkdir = monodet->toLocal(gtrkdir);
66  if (monotkdir.z() != 0) {
67  // the local angle (mono)
68  float localpitch = static_cast<const StripTopology&>(monodet->topology()).localPitch(tsos.localPosition());
69  float thickness = ((((((monohit.geographicalId()) >> 25) & 0x7f) == 0xd) ||
70  ((((monohit.geographicalId()) >> 25) & 0x7f) == 0xe)) &&
71  ((((monohit.geographicalId()) >> 5) & 0x7) > 4))
72  ? 0.0500
73  : 0.0320;
74  float angle = computeAngleCorr(monotkdir, localpitch, thickness);
75  hitangleassociation.push_back(make_pair(make_pair(monohit.geographicalId(), monohit.localPosition()), angle));
76  // trackdirection on stereo det
77  // this the pointer to the stereo hit of a matched hit
78  const SiStripRecHit2D stereohit = matchedhit->stereoHit();
79  const GeomDetUnit* stereodet = gdet->stereoDet();
80  LocalVector stereotkdir = stereodet->toLocal(gtrkdir);
81  if (stereotkdir.z() != 0) {
82  // the local angle (stereo)
83  float localpitch = static_cast<const StripTopology&>(stereodet->topology()).localPitch(tsos.localPosition());
84  float thickness = ((((((stereohit.geographicalId()) >> 25) & 0x7f) == 0xd) ||
85  ((((stereohit.geographicalId()) >> 25) & 0x7f) == 0xe)) &&
86  ((((stereohit.geographicalId()) >> 5) & 0x7) > 4))
87  ? 0.0500
88  : 0.0320;
89  float angle = computeAngleCorr(stereotkdir, localpitch, thickness);
90  hitangleassociation.push_back(
91  make_pair(make_pair(stereohit.geographicalId(), stereohit.localPosition()), angle));
92  }
93  }
94  } else if (hit) {
95  const GeomDetUnit* det = tracker->idToDet(hit->geographicalId());
96  // hit= pointer to the rechit
97  if (trackdirection.z() != 0) {
98  // the local angle (single hit)
99  float localpitch = static_cast<const StripTopology&>(det->topology()).localPitch(tsos.localPosition());
100  float thickness =
101  ((((((hit->geographicalId()) >> 25) & 0x7f) == 0xd) || ((((hit->geographicalId()) >> 25) & 0x7f) == 0xe)) &&
102  ((((hit->geographicalId()) >> 5) & 0x7) > 4))
103  ? 0.0500
104  : 0.0320;
105  float angle = computeAngleCorr(trackdirection, localpitch, thickness);
106  hitangleassociation.push_back(make_pair(make_pair(hit->geographicalId(), hit->localPosition()), angle));
107  }
108  }
109  }
110  return hitangleassociation;
111 }
112 
113 double SiStripFineDelayTLA::computeAngleCorr(const LocalVector& v, double pitch, double thickness) {
114  double v_xy = sqrt(v.x() * v.x() + v.y() * v.y());
115  double L = fabs(thickness * v_xy / v.z());
116  double Lmax = fabs(pitch / v.x() * v_xy);
117  if (L < Lmax) {
118  LogDebug("SiStripFineDelayTLA ") << L << " vs " << Lmax << " Signal contained in strip. Correction is "
119  << v.z() / v.mag();
120  return v.z() / v.mag();
121  } else {
122  LogDebug("SiStripFineDelayTLA ") << L << " vs " << Lmax << " Signal not contained in strip. Correction is "
123  << thickness / pitch * v.x() / v_xy * v.z() / v.mag() << " instead of "
124  << v.z() / v.mag();
125  return thickness / pitch * v.x() / v_xy * v.z() / v.mag();
126  }
127 }
#define LogDebug(id)
SiStripFineDelayTLA(const edm::ParameterSet &conf)
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:19
virtual const Topology & topology() const
Definition: GeomDet.cc:67
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:60
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:58
std::vector< std::pair< std::pair< DetId, LocalPoint >, float > > findtrackangle(const std::vector< Trajectory > &traj)
DataContainer const & measurements() const
Definition: Trajectory.h:178
T mag() const
Definition: PV3DBase.h:64
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
SiStripRecHit2D stereoHit() const
SiStripRecHit2D monoHit() const
T get() const
Definition: EventSetup.h:73
const TrackerGeomDet * idToDet(DetId) const override
LocalPoint localPosition() const final
DetId geographicalId() const
const TrackerGeometry * tracker
T x() const
Definition: PV3DBase.h:59
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:20
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11