Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef __PFBlockElement__
0002 #define __PFBlockElement__
0003 
0004 #include "DataFormats/ParticleFlowReco/interface/PFRecTrackFwd.h"
0005 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedTrackerVertex.h"
0006 #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
0007 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0008 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0009 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
0010 #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
0011 #include "DataFormats/Candidate/interface/VertexCompositeCandidate.h"
0012 #include "DataFormats/Candidate/interface/VertexCompositeCandidateFwd.h"
0013 
0014 #include "DataFormats/ParticleFlowReco/interface/PFMultilinksTC.h"  // Glowinski & Gouzevitch
0015 
0016 #include <iostream>
0017 
0018 namespace reco {
0019   class PFBlockElementCluster;
0020   class PFBlockElementTrack;
0021 
0022   /// \brief Abstract base class for a PFBlock element (track, cluster...)
0023   ///
0024   /// this class contains a PFRecTrackRef of a
0025   /// PFClusterRef, depending on the type of the element
0026   class PFBlockElement {
0027   public:
0028     /// possible types for the element
0029     /// do not modify this enum if you don't know what you're doing!!!
0030     enum Type {
0031       NONE = 0,
0032       TRACK = 1,
0033       PS1 = 2,
0034       PS2 = 3,
0035       ECAL = 4,
0036       HCAL = 5,
0037       GSF = 6,
0038       BREM = 7,
0039       HFEM = 8,
0040       HFHAD = 9,
0041       SC = 10,
0042       HO = 11,
0043       HGCAL = 12,
0044       kNBETypes = 13
0045     };
0046 
0047     enum TrackType { DEFAULT = 0, T_FROM_DISP, T_TO_DISP, T_FROM_GAMMACONV, MUON, T_FROM_V0 };
0048 
0049     /// standard constructor
0050     PFBlockElement(Type type = NONE)
0051         : type_(type), locked_(false), index_(static_cast<unsigned>(-1)), time_(0.f), timeError_(-1.f) {}
0052 
0053     /// destructor
0054     virtual ~PFBlockElement() {}
0055 
0056     /// print the object inside the element
0057     virtual void Dump(std::ostream& out = std::cout, const char* tab = " ") const;
0058 
0059     /// necessary to have the edm::OwnVector<PFBlockElement> working
0060     virtual PFBlockElement* clone() const = 0;
0061 
0062     /// lock element
0063     void lock() { locked_ = true; }
0064 
0065     /// unlock element
0066     void unLock() { locked_ = false; }
0067 
0068     /// \return type
0069     Type type() const { return type_; }
0070 
0071     /// \return tracktype
0072     virtual bool trackType(TrackType trType) const { return false; }
0073 
0074     /// \set the trackType
0075     virtual void setTrackType(TrackType trType, bool value) {
0076       std::cout << "Error in PFBlockElement::setTrackType : this base class method is not implemented" << std::endl;
0077     }
0078 
0079     /// locked ?
0080     bool locked() const { return locked_; }
0081 
0082     /// set index
0083     void setIndex(unsigned index) { index_ = index; }
0084 
0085     /// \return index
0086     unsigned index() const { return index_; }
0087 
0088     virtual const reco::TrackRef& trackRef() const { return nullTrack_; }
0089     virtual const PFRecTrackRef& trackRefPF() const { return nullPFRecTrack_; }
0090     virtual const PFClusterRef& clusterRef() const { return nullPFCluster_; }
0091     virtual const PFDisplacedTrackerVertexRef& displacedVertexRef(TrackType trType) const { return nullPFDispVertex_; }
0092     virtual const ConversionRefVector& convRefs() const { return nullConv_; }
0093     virtual const MuonRef& muonRef() const { return nullMuon_; }
0094     virtual const VertexCompositeCandidateRef& V0Ref() const { return nullVertex_; }
0095     virtual void setDisplacedVertexRef(const PFDisplacedTrackerVertexRef& niref, TrackType trType) {
0096       std::cout << "Error in PFBlockElement::setDisplacedVertexRef : this base class method is not implemented"
0097                 << std::endl;
0098     }
0099     virtual void setConversionRef(const ConversionRef& convRef, TrackType trType) {
0100       std::cout << "Error in PFBlockElement::setConversionRef : this base class method is not implemented" << std::endl;
0101     }
0102     virtual void setMuonRef(const MuonRef& muref) {
0103       std::cout << "Error in PFBlockElement::setMuonRef : this base class method is not implemented" << std::endl;
0104     }
0105     virtual void setV0Ref(const VertexCompositeCandidateRef& v0ref, TrackType trType) {
0106       std::cout << "Error in PFBlockElement::setV0Ref : this base class method is not implemented" << std::endl;
0107     }
0108 
0109     virtual bool isSecondary() const { return false; }
0110     virtual bool isPrimary() const { return false; }
0111     virtual bool isLinkedToDisplacedVertex() const { return false; }
0112 
0113     // Glowinski & Gouzevitch
0114     void setMultilinks(const PFMultiLinksTC& ml, Type type) { multilinks_[type] = ml; }
0115     void setIsValidMultilinks(bool isVal, Type type) { multilinks_[type].isValid = isVal; }
0116 
0117     bool isMultilinksValide(Type type) const {
0118       const auto& it = multilinks_.find(type);
0119       if (it != multilinks_.end())
0120         return it->second.isValid;
0121       else
0122         return false;  // no multilinks_ for the specified type
0123     }
0124     const PFMultilinksType& getMultilinks(Type type) const { return multilinks_.at(type).linkedPFObjects; }
0125     // ! Glowinski & Gouzevitch
0126 
0127     /// do we have a valid time information
0128     bool isTimeValid() const { return timeError_ >= 0.f; }
0129     /// \return the timing
0130     float time() const { return time_; }
0131     /// \return the timing uncertainty
0132     float timeError() const { return timeError_; }
0133     /// \set the timing information
0134     void setTime(float time, float timeError = 0.f) {
0135       time_ = time;
0136       timeError_ = timeError;
0137     }
0138 
0139   protected:
0140     /// type, see PFBlockElementType
0141     /// \todo replace by a char ?
0142     Type type_;
0143 
0144     /// locked flag.
0145     /// \todo can probably be transient. Could be replaced by a
0146     /// "remaining energy". IS THIS STILL USED ?
0147     bool locked_;
0148 
0149     /// index in block vector
0150     unsigned index_;
0151 
0152     // Glowinski & Gouzevitch
0153     // PFMultiLinks for each different link target type
0154     std::map<reco::PFBlockElement::Type, PFMultiLinksTC> multilinks_;
0155     // ! Glowinski & Gouzevitch
0156 
0157     /// timing information (valid if timeError_ >= 0)
0158     float time_;
0159     /// timing information uncertainty (<0 if timing not available)
0160     float timeError_;
0161 
0162     const static reco::TrackRef nullTrack_;
0163     const static PFRecTrackRef nullPFRecTrack_;
0164     const static PFClusterRef nullPFCluster_;
0165     const static PFDisplacedTrackerVertexRef nullPFDispVertex_;
0166     const static ConversionRefVector nullConv_;
0167     const static MuonRef nullMuon_;
0168     const static VertexCompositeCandidateRef nullVertex_;
0169   };
0170 
0171   std::ostream& operator<<(std::ostream& out, const PFBlockElement& element);
0172 
0173 }  // namespace reco
0174 #endif