Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:59:57

0001 #include "CalibTracker/SiStripHitResolution/interface/SiStripOverlapHit.h"
0002 #include <cmath>
0003 
0004 SiStripOverlapHit::SiStripOverlapHit(TrajectoryMeasurement const& measA, TrajectoryMeasurement const& measB) {
0005   // check which hit is closer to the IP
0006   // assign it to hitA_, the other to hitB_
0007   double rA = measA.recHit()->globalPosition().perp();
0008   double rB = measB.recHit()->globalPosition().perp();
0009   if (rA < rB) {
0010     measA_ = measA;
0011     measB_ = measB;
0012   } else {
0013     measA_ = measB;
0014     measB_ = measA;
0015   }
0016 }
0017 
0018 TrajectoryStateOnSurface const& SiStripOverlapHit::trajectoryStateOnSurface(unsigned int hit, bool updated) const {
0019   assert(hit < 2);
0020   switch (hit) {
0021     case 0:
0022       return updated ? measA_.updatedState() : measA_.predictedState();
0023     case 1:
0024       return updated ? measB_.updatedState() : measB_.predictedState();
0025     default:
0026       return measA_.updatedState();
0027   }
0028 }
0029 
0030 double SiStripOverlapHit::getTrackLocalAngle(unsigned int hit) const {
0031   // since x is the precise coordinate and z is pointing out, we want the angle between z and x
0032   return hit ? atan(trajectoryStateOnSurface(hit - 1).localDirection().x() /
0033                     trajectoryStateOnSurface(hit - 1).localDirection().z())
0034              : (getTrackLocalAngle(1) + getTrackLocalAngle(2)) / 2.;
0035 }
0036 
0037 double SiStripOverlapHit::offset(unsigned int hit) const {
0038   assert(hit < 2);
0039   // x is the precise coordinate
0040   return this->hit(hit)->localPosition().x() - trajectoryStateOnSurface(hit, false).localPosition().x();
0041 }
0042 
0043 double SiStripOverlapHit::shift() const {
0044   // so this is the double difference
0045   return offset(0) - offset(1);
0046 }
0047 
0048 double SiStripOverlapHit::distance(bool fromTrajectory) const {
0049   if (fromTrajectory) {
0050     return (trajectoryStateOnSurface(0, true).globalPosition().basicVector() -
0051             trajectoryStateOnSurface(1, true).globalPosition().basicVector())
0052         .mag();
0053   } else {
0054     return (hitA()->globalPosition().basicVector() - hitB()->globalPosition().basicVector()).mag();
0055   }
0056 }
0057 
0058 GlobalPoint SiStripOverlapHit::position() const {
0059   auto vector = (hitA()->globalPosition().basicVector() + hitB()->globalPosition().basicVector()) / 2.;
0060   return GlobalPoint(vector);
0061 }