00001
00002
00003
00004
00005 #ifndef INDETTRACKSELECTIONTOOL_INDETTRACKACCESSOR_H
00006 #define INDETTRACKSELECTIONTOOL_INDETTRACKACCESSOR_H
00007
00008 #include "AsgTools/StatusCode.h"
00009 #include "AsgTools/AsgMessaging.h"
00010 #include "xAODTracking/TrackingPrimitives.h"
00011 #include "xAODTracking/TrackParticle.h"
00012 #include "xAODTracking/Vertex.h"
00013
00014 #ifndef XAOD_ANALYSIS
00015 #include "TrkTrackSummary/TrackSummary.h"
00016 namespace Trk {
00017 class Track;
00018 class Vertex;
00019 }
00020 #endif
00021
00022 namespace InDet {
00023
00024
00025
00026 class TrackAccessor : public asg::AsgMessaging {
00027 public:
00028 TrackAccessor(const asg::IAsgTool*);
00029 virtual ~TrackAccessor() = 0;
00030
00031 virtual StatusCode access( const xAOD::TrackParticle& track,
00032 const xAOD::Vertex* vertex = 0 ) = 0;
00033 #ifndef XAOD_ANALYSIS
00034
00035 virtual StatusCode access( const Trk::Track& track,
00036 const Trk::TrackParameters* perigee = 0,
00037 const Trk::TrackSummary* summary = 0) = 0;
00038 #endif
00039 };
00040
00041
00042
00043
00044 class SummaryAccessor : public virtual TrackAccessor {
00045 public:
00046 SummaryAccessor(const asg::IAsgTool*);
00047 void setSummaryType(xAOD::SummaryType);
00048 StatusCode access( const xAOD::TrackParticle& track,
00049 const xAOD::Vertex* vertex = 0 );
00050 #ifndef XAOD_ANALYSIS
00051 StatusCode access( const Trk::Track& track,
00052 const Trk::TrackParameters* perigee = 0,
00053 const Trk::TrackSummary* summary = 0 );
00054 #endif
00055 uint8_t getValue() const {return m_summaryValue;}
00056 private:
00057 uint8_t m_summaryValue;
00058 xAOD::SummaryType m_summaryType;
00059 };
00060
00061
00062
00063
00064
00065 template <size_t index>
00066 class ParamAccessor : public virtual TrackAccessor {
00067 public:
00068 ParamAccessor(const asg::IAsgTool*);
00069 StatusCode access ( const xAOD::TrackParticle& track,
00070 const xAOD::Vertex* vertex = 0 );
00071 #ifndef XAOD_ANALYSIS
00072 StatusCode access ( const Trk::Track& track,
00073 const Trk::TrackParameters* perigee = 0,
00074 const Trk::TrackSummary* summary = 0 );
00075 #endif
00076 Double_t getValue() const {return m_paramValue;}
00077
00078 private:
00079 Double_t m_paramValue;
00080 };
00081
00082
00083 template <size_t index_i, size_t index_j>
00084 class ParamCovAccessor : public virtual TrackAccessor {
00085 public:
00086 ParamCovAccessor<index_i, index_j>(const asg::IAsgTool*);
00087 StatusCode access ( const xAOD::TrackParticle& track,
00088 const xAOD::Vertex* vertex = 0 );
00089 #ifndef XAOD_ANALYSIS
00090 StatusCode access ( const Trk::Track& track,
00091 const Trk::TrackParameters* perigee = 0,
00092 const Trk::TrackSummary* summary = 0 );
00093 #endif
00094 Double_t getValue() const {return m_paramCovValue;}
00095
00096 private:
00097 Double_t m_paramCovValue;
00098 };
00099
00100
00101
00102 class FitQualityAccessor : public virtual TrackAccessor {
00103 public:
00104 FitQualityAccessor(const asg::IAsgTool*);
00105 StatusCode access ( const xAOD::TrackParticle& track,
00106 const xAOD::Vertex* = 0 );
00107 #ifndef XAOD_ANALYSIS
00108 StatusCode access ( const Trk::Track& track,
00109 const Trk::TrackParameters* perigee = 0,
00110 const Trk::TrackSummary* summary = 0 );
00111 #endif
00112 Double_t getChiSq() const {return m_chiSq;}
00113 Double_t getNumberDoF() const {return m_nDoF;}
00114 Double_t getProb() const {return TMath::Prob( m_chiSq, m_nDoF );}
00115 private:
00116 Double_t m_chiSq;
00117 Double_t m_nDoF;
00118 };
00119
00120
00121
00122
00123 template <typename T, T (xAOD::TrackParticle::*Func)() const>
00124 class FuncAccessor : public virtual TrackAccessor {
00125 public:
00126 FuncAccessor(const asg::IAsgTool*);
00127 StatusCode access ( const xAOD::TrackParticle& track,
00128 const xAOD::Vertex* = 0 );
00129 #ifndef XAOD_ANALYSIS
00130
00131 StatusCode access ( const Trk::Track& track,
00132 const Trk::TrackParameters* perigee = 0,
00133 const Trk::TrackSummary* summary = 0 );
00134 #endif
00135 T getValue() const {return m_value;}
00136 private:
00137 T m_value;
00138 };
00139
00140
00141
00142
00143
00144
00145
00146 class eProbabilityHTAccessor : public virtual TrackAccessor {
00147 public:
00148 eProbabilityHTAccessor(const asg::IAsgTool*);
00149 StatusCode access ( const xAOD::TrackParticle& track,
00150 const xAOD::Vertex* = 0 );
00151 #ifndef XAOD_ANALYSIS
00152 StatusCode access ( const Trk::Track& track,
00153 const Trk::TrackParameters* perigee = 0,
00154 const Trk::TrackSummary* summary = 0 );
00155 #endif
00156 float getValue() const {return m_eProbHT;}
00157 private:
00158 float m_eProbHT;
00159 };
00160
00161 #ifndef XAOD_ANALYSIS
00162
00163 class SiHitsTopBottomAccessor : public virtual TrackAccessor {
00164 public:
00165 SiHitsTopBottomAccessor(const asg::IAsgTool*);
00166 StatusCode access ( const xAOD::TrackParticle& track,
00167 const xAOD::Vertex* = 0 );
00168 StatusCode access ( const Trk::Track& track,
00169 const Trk::TrackParameters* perigee = 0,
00170 const Trk::TrackSummary* summary = 0 );
00171 uint8_t getHitsTop() const {return m_top;}
00172 uint8_t getHitsBottom() const {return m_bottom;}
00173 private:
00174 uint8_t m_top;
00175 uint8_t m_bottom;
00176 };
00177 #endif
00178
00179 }
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 template <size_t index>
00190 InDet::ParamAccessor<index>::ParamAccessor(const asg::IAsgTool* tool)
00191 : InDet::TrackAccessor(tool)
00192 , m_paramValue(0)
00193 {
00194 static_assert(index < 5, "Index for parameter accessor must be less than 5");
00195 }
00196
00197 template <size_t index>
00198 StatusCode InDet::ParamAccessor<index>::access( const xAOD::TrackParticle& track,
00199 const xAOD::Vertex* vertex )
00200 {
00201 m_paramValue = track.definingParameters()[index];
00202 if (index == 1) {
00203 if (vertex != nullptr) {
00204
00205 m_paramValue += track.vz() - vertex->z();
00206 }
00207 }
00208 return StatusCode::SUCCESS;
00209 }
00210
00211 #ifndef XAOD_ANALYSIS
00212 template <size_t index>
00213 StatusCode InDet::ParamAccessor<index>::access( const Trk::Track&,
00214 const Trk::TrackParameters* perigee,
00215 const Trk::TrackSummary* )
00216 {
00217 if (perigee==nullptr) {
00218 ATH_MSG_ERROR( "Zero pointer to perigee." );
00219 m_paramValue = std::nan("");
00220 return StatusCode::FAILURE;
00221 }
00222 m_paramValue = perigee->parameters()[index];
00223 return StatusCode::SUCCESS;
00224 }
00225 #endif
00226
00227
00228 template <size_t index_i, size_t index_j>
00229 InDet::ParamCovAccessor<index_i, index_j>::ParamCovAccessor(const asg::IAsgTool* tool)
00230 : InDet::TrackAccessor(tool)
00231 , m_paramCovValue(0)
00232 {
00233 static_assert(index_i < 5, "Index for parameter covariance accessor must be less than 5");
00234 static_assert(index_j < 5, "Index for parameter covariance accessor must be less than 5");
00235 }
00236
00237 template <size_t index_i, size_t index_j>
00238 StatusCode InDet::ParamCovAccessor<index_i, index_j>::access( const xAOD::TrackParticle& track,
00239 const xAOD::Vertex* )
00240 {
00241 m_paramCovValue = track.definingParametersCovMatrix()(index_i, index_j);
00242 return StatusCode::SUCCESS;
00243 }
00244
00245 #ifndef XAOD_ANALYSIS
00246 template <size_t index_i, size_t index_j>
00247 StatusCode InDet::ParamCovAccessor<index_i, index_j>::
00248 access( const Trk::Track&,
00249 const Trk::TrackParameters* perigee,
00250 const Trk::TrackSummary* )
00251 {
00252 if (!perigee) {
00253 ATH_MSG_ERROR( "Recieved zero pointer to perigee." );
00254 m_paramCovValue = std::nan("");
00255 return StatusCode::FAILURE;
00256 }
00257 m_paramCovValue = (*perigee->covariance())(index_i, index_j);
00258 return StatusCode::SUCCESS;
00259 }
00260 #endif
00261
00262
00263
00264 template <typename T, T (xAOD::TrackParticle::*Func)() const>
00265 InDet::FuncAccessor<T,Func>::FuncAccessor(const asg::IAsgTool* tool)
00266 : TrackAccessor(tool)
00267 , m_value(false)
00268 {
00269 }
00270
00271 template <typename T, T (xAOD::TrackParticle::*Func)() const>
00272 StatusCode InDet::FuncAccessor<T,Func>::access( const xAOD::TrackParticle& track,
00273 const xAOD::Vertex* )
00274 {
00275 m_value = (track.*Func)();
00276 return StatusCode::SUCCESS;
00277 }
00278
00279
00280 #endif // INDETTRACKSELECTIONTOOL_INDETTRACKACCESSOR_H