CMS 3D CMS Logo

DTHitPairForFit.cc
Go to the documentation of this file.
1 
7 /* This Class Header */
9 
10 /* Collaborating Class Header */
12 
13 /* C++ Headers */
14 #include <iostream>
15 using namespace std;
16 
17 /* ====================================================================== */
18 
21  const DTSuperLayer& sl,
22  const edm::ESHandle<DTGeometry>& dtGeom) {
23  theWireId = pair.wireId();
24  theDigiTime = pair.digiTime();
25 
26  const DTLayer* layer = dtGeom->layer(theWireId.layerId());
27 
28  // transform the Local position in Layer-rf in a SL local position
29  theLeftPos = sl.toLocal(layer->toGlobal(pair.componentRecHit(DTEnums::Left)->localPosition()));
30  theRightPos = sl.toLocal(layer->toGlobal(pair.componentRecHit(DTEnums::Right)->localPosition()));
31 
32  // TODO how do I transform an error from local to global?
34  // theError =
35  // layer->surface().toLocal(sl.surface().toGlobal(pair.componentRecHit(DTEnums::Left)->localPositionError()));
36 }
37 
40 
41 /* Operations */
43  if (s == DTEnums::Left)
44  return theLeftPos;
45  else if (s == DTEnums::Right)
46  return theRightPos;
47  else {
48  throw cms::Exception("DTHitPairForFit") << " localPosition called with undef LR code" << endl;
49  return LocalPoint();
50  }
51 }
52 
53 pair<bool, bool> DTHitPairForFit::isCompatible(const LocalPoint& posIni, const LocalVector& dirIni) const {
54  pair<bool, bool> ret;
55  LocalPoint segPosAtZLeft = posIni + dirIni * (theLeftPos.z() - posIni.z()) / dirIni.z();
56  LocalPoint segPosAtZRight = posIni + dirIni * (theRightPos.z() - posIni.z()) / dirIni.z();
57  float dxLeft = fabs(theLeftPos.x() - segPosAtZLeft.x());
58  float dxRight = fabs(theRightPos.x() - segPosAtZRight.x());
59  float exx = sqrt(theError.xx());
60  // if both below 3 sigma, return both
61  // if both at 10 sigma or above, return none
62  // if one is below N sigma and one above, for 10>=N>=3, match only that one, otherwise none
63  if (std::max(dxLeft, dxRight) < 3 * exx) {
64  ret = make_pair(true, true);
65  } else if (std::min(dxLeft, dxRight) >= 10 * exx) {
66  ret = make_pair(false, false);
67  } else {
68  float sigmasL = floorf(dxLeft / exx), sigmasR = floorf(dxRight / exx);
69  ret.first = (sigmasL < sigmasR);
70  ret.second = (sigmasR < sigmasL);
71  }
72  return ret;
73 }
74 
76  //SL if same layer use x() for strict ordering
77  if (id() == hit.id())
78  return (theLeftPos.x() < hit.localPosition(DTEnums::Left).x());
79  return (id() < hit.id());
80 }
81 
83  return (id() == hit.id() && fabs(digiTime() - hit.digiTime()) < 0.1);
84 }
85 
86 ostream& operator<<(ostream& out, const DTHitPairForFit& hit) {
87  out << hit.leftPos() << " " << hit.rightPos();
88  return out;
89 }
LocalPoint localPosition() const override
Return the 3-dimensional local position.
Definition: DTRecHit1D.h:47
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
bool operator<(const DTHitPairForFit &hit) const
define the order by increasing z
LocalPoint localPosition(DTEnums::DTCellSide s) const
Returns the local position in the layer.
const DTWireId & id() const
Returns the Id of the wire on which the rechit rely.
float digiTime() const
Return the digi time (ns) used to build the rechits.
ret
prodAgent to be discontinued
LocalError localPositionError() const override
Return the 3-dimensional error on the local position.
Definition: DTRecHit1D.h:50
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
std::pair< bool, bool > isCompatible(const LocalPoint &posIni, const LocalVector &dirIni) const
DTCellSide
Which side of the DT cell.
Definition: DTEnums.h:15
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:58
const DTRecHit1D * componentRecHit(DTEnums::DTCellSide lrSide) const
Return the left/right DTRecHit1D.
~DTHitPairForFit()
Destructor.
float digiTime() const
Returns the time of the corresponding digi.
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
DTHitPairForFit(const DTRecHit1DPair &pair, const DTSuperLayer &sl, const edm::ESHandle< DTGeometry > &dtGeom)
Constructor.
T min(T a, T b)
Definition: MathUtil.h:58
std::ostream & operator<<(std::ostream &out, const std::tuple< Types... > &value)
Definition: Utilities.h:32
LocalPoint leftPos() const
Returns the position in the layer r.f. of the left rechit.
bool operator==(const DTHitPairForFit &hit) const
LocalPoint rightPos() const
Returns the position in the layer r.f. of the right rechit.
DTWireId wireId() const
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96
T x() const
Definition: PV3DBase.h:59