Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:51

0001 #ifndef __PFBlockElementTrack__
0002 #define __PFBlockElementTrack__
0003 
0004 #include <iostream>
0005 
0006 #include "DataFormats/Math/interface/Point3D.h"
0007 
0008 #include "DataFormats/ParticleFlowReco/interface/PFBlockElement.h"
0009 #include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h"
0010 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0011 
0012 namespace reco {
0013 
0014   /// \brief Track Element.
0015   ///
0016   /// this class contains a reference to a PFRecTrack
0017   class PFBlockElementTrack final : public PFBlockElement {
0018   public:
0019     PFBlockElementTrack() {}
0020 
0021     PFBlockElementTrack(const PFRecTrackRef& ref);
0022 
0023     PFBlockElement* clone() const override { return new PFBlockElementTrack(*this); }
0024 
0025     void Dump(std::ostream& out = std::cout, const char* tab = " ") const override;
0026 
0027     /// \return tracktype
0028     bool trackType(TrackType trType) const override { return (trackType_ >> trType) & 1; }
0029 
0030     /// \set the trackType
0031     void setTrackType(TrackType trType, bool value) override {
0032       if (value)
0033         trackType_ = trackType_ | (1 << trType);
0034       else
0035         trackType_ = trackType_ ^ (1 << trType);
0036     }
0037 
0038     /// set position at ECAL entrance
0039     void setPositionAtECALEntrance(float x, float y, float z) { positionAtECALEntrance_.SetCoordinates(x, y, z); }
0040 
0041     /// \return position at ECAL entrance
0042     const math::XYZPointF& positionAtECALEntrance() const { return positionAtECALEntrance_; }
0043 
0044     /// \return reference to the corresponding PFRecTrack
0045     /// please do not use this function after the block production stage!
0046     const PFRecTrackRef& trackRefPF() const override { return trackRefPF_; }
0047 
0048     /// \return reference to the corresponding Track
0049     const reco::TrackRef& trackRef() const override { return trackRef_; }
0050 
0051     static constexpr unsigned int kPrimaryMask = 1 << T_TO_DISP;
0052 
0053     static constexpr unsigned int kSecondaryMask = (1 << T_FROM_DISP) | (1 << T_FROM_GAMMACONV) | (1 << T_FROM_V0);
0054 
0055     static constexpr unsigned int kLinkedToDisplacedVertexMask = kPrimaryMask | kSecondaryMask;
0056 
0057     /// check if the track is secondary
0058     bool isSecondary() const override { return trackType_ & kSecondaryMask; }
0059 
0060     bool isPrimary() const override { return trackType_ & kPrimaryMask; }
0061 
0062     bool isLinkedToDisplacedVertex() const override { return trackType_ & kLinkedToDisplacedVertexMask; }
0063 
0064     /// \return the displaced vertex associated
0065     const PFDisplacedTrackerVertexRef& displacedVertexRef(TrackType trType) const override {
0066       if (trType == T_TO_DISP)
0067         return displacedVertexDaughterRef_;
0068       else if (trType == T_FROM_DISP)
0069         return displacedVertexMotherRef_;
0070       else
0071         return nullPFDispVertex_;
0072     }
0073 
0074     /// \set the ref to the displaced vertex interaction
0075     void setDisplacedVertexRef(const PFDisplacedTrackerVertexRef& niref, TrackType trType) override {
0076       if (trType == T_TO_DISP) {
0077         displacedVertexDaughterRef_ = niref;
0078         setTrackType(trType, true);
0079       } else if (trType == T_FROM_DISP) {
0080         displacedVertexMotherRef_ = niref;
0081         setTrackType(trType, true);
0082       }
0083     }
0084 
0085     /// \return reference to the corresponding Muon
0086     const reco::MuonRef& muonRef() const override { return muonRef_; }
0087 
0088     /// \set reference to the Muon
0089     void setMuonRef(const MuonRef& muref) override {
0090       muonRef_ = muref;
0091       setTrackType(MUON, true);
0092     }
0093 
0094     /// \return ref to original recoConversion
0095     const ConversionRefVector& convRefs() const override { return convRefs_; }
0096 
0097     /// \set the ref to  gamma conversion
0098     void setConversionRef(const ConversionRef& convRef, TrackType trType) override {
0099       convRefs_.push_back(convRef);
0100       setTrackType(trType, true);
0101     }
0102 
0103     /// \return ref to original V0
0104     const VertexCompositeCandidateRef& V0Ref() const override { return v0Ref_; }
0105 
0106     /// \set the ref to  V0
0107     void setV0Ref(const VertexCompositeCandidateRef& V0Ref, TrackType trType) override {
0108       v0Ref_ = V0Ref;
0109       setTrackType(trType, true);
0110     }
0111 
0112   private:
0113     /// reference to the corresponding track (transient)
0114     PFRecTrackRef trackRefPF_;
0115 
0116     /// reference to the corresponding track
0117     reco::TrackRef trackRef_;
0118 
0119     unsigned int trackType_;
0120 
0121     /// position at ECAL entrance
0122     math::XYZPointF positionAtECALEntrance_;
0123 
0124     /// reference to the corresponding pf displaced vertex where this track was created
0125     PFDisplacedTrackerVertexRef displacedVertexMotherRef_;
0126 
0127     /// reference to the corresponding pf displaced vertex which this track was created
0128     PFDisplacedTrackerVertexRef displacedVertexDaughterRef_;
0129 
0130     /// reference to the corresponding muon
0131     reco::MuonRef muonRef_;
0132 
0133     /// reference to reco conversion
0134     ConversionRefVector convRefs_;
0135 
0136     /// reference to V0
0137     VertexCompositeCandidateRef v0Ref_;
0138   };
0139 }  // namespace reco
0140 
0141 #endif