Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:13

0001 /****************************************************************************
0002  *
0003  * This is a part of CTPPS offline software.
0004  * Authors:
0005  *   Laurent Forthomme (laurent.forthomme@cern.ch)
0006  *   Nicola Minafra (nicola.minafra@cern.ch)
0007  *   Mateusz Szpyrka (mateusz.szpyrka@cern.ch)
0008  *
0009  ****************************************************************************/
0010 
0011 #include "DataFormats/CTPPSReco/interface/CTPPSTimingLocalTrack.h"
0012 #include <cmath>
0013 
0014 //----------------------------------------------------------------------------------------------------
0015 
0016 //--- constructors
0017 
0018 CTPPSTimingLocalTrack::CTPPSTimingLocalTrack() : num_hits_(0), num_planes_(0), valid_(true), t_(0.), t_sigma_(0.) {}
0019 
0020 CTPPSTimingLocalTrack::CTPPSTimingLocalTrack(const math::XYZPoint& pos0,
0021                                              const math::XYZPoint& pos0_sigma,
0022                                              float t,
0023                                              float t_sigma)
0024     : pos0_(pos0), pos0_sigma_(pos0_sigma), num_hits_(0), num_planes_(0), valid_(false), t_(t), t_sigma_(t_sigma) {}
0025 
0026 //--- interface member functions
0027 
0028 bool CTPPSTimingLocalTrack::containsHit(const CTPPSTimingRecHit& recHit, float tolerance, CheckDimension check) const {
0029   float xTolerance = pos0_sigma_.x() + (0.5 * recHit.xWidth()) + tolerance;
0030   float yTolerance = pos0_sigma_.y() + (0.5 * recHit.yWidth()) + tolerance;
0031   float zTolerance = pos0_sigma_.z() + (0.5 * recHit.zWidth()) + tolerance;
0032 
0033   float xDiff = std::abs(pos0_.x() - recHit.x());
0034   float yDiff = std::abs(pos0_.y() - recHit.y());
0035   float zDiff = std::abs(pos0_.z() - recHit.z());
0036 
0037   switch (check) {
0038     case CheckDimension::x:
0039       return xDiff < xTolerance;
0040     case CheckDimension::y:
0041       return yDiff < yTolerance;
0042     case CheckDimension::all:
0043       return xDiff < xTolerance && yDiff < yTolerance && zDiff < zTolerance;
0044   }
0045   return false;
0046 }
0047 
0048 //====================================================================================================
0049 // Other methods implementation
0050 //====================================================================================================
0051 
0052 bool operator<(const CTPPSTimingLocalTrack& lhs, const CTPPSTimingLocalTrack& rhs) {
0053   // start to sort by temporal coordinate
0054   if (lhs.time() < rhs.time())
0055     return true;
0056   if (lhs.time() > rhs.time())
0057     return false;
0058   // then sort by x-position
0059   if (lhs.x0() < rhs.x0())
0060     return true;
0061   if (lhs.x0() > rhs.x0())
0062     return false;
0063   // ...and y-position
0064   if (lhs.y0() < rhs.y0())
0065     return true;
0066   if (lhs.y0() > rhs.y0())
0067     return false;
0068   // ...and z-position
0069   return (lhs.z0() < rhs.z0());
0070 }