File indexing completed on 2024-04-06 12:27:46
0001 #ifndef RecoTauTag_RecoTau_RecoTauConstructor_h
0002 #define RecoTauTag_RecoTau_RecoTauConstructor_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #include "DataFormats/Common/interface/Handle.h"
0027 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0028 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
0029 #include "DataFormats/TauReco/interface/PFTau.h"
0030 #include "DataFormats/JetReco/interface/JetCollection.h"
0031 #include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h"
0032 #include "DataFormats/TauReco/interface/RecoTauPiZero.h"
0033 #include "CommonTools/Utils/interface/StringObjectFunction.h"
0034
0035 #include <vector>
0036
0037 namespace reco {
0038 namespace tau {
0039
0040 class RecoTauConstructor {
0041 public:
0042 enum Region { kSignal, kIsolation };
0043
0044 enum ParticleType { kChargedHadron, kGamma, kNeutralHadron, kAll };
0045
0046
0047 RecoTauConstructor(const JetBaseRef& jetRef,
0048 const edm::Handle<edm::View<reco::Candidate> >& pfCands,
0049 bool copyGammasFromPiZeros = false,
0050 const StringObjectFunction<reco::PFTau>* signalConeSize = nullptr,
0051 double minAbsPhotonSumPt_insideSignalCone = 2.5,
0052 double minRelPhotonSumPt_insideSignalCone = 0.,
0053 double minAbsPhotonSumPt_outsideSignalCone = 1.e+9,
0054 double minRelPhotonSumPt_outsideSignalCone = 1.e+9);
0055
0056
0057
0058
0059
0060
0061
0062
0063 template <typename T>
0064 void setleadChargedHadrCand(const T& cand) {
0065 tau_->setleadChargedHadrCand(convertToPtr(cand));
0066 }
0067
0068
0069 template <typename T>
0070 void setleadNeutralCand(const T& cand) {
0071 tau_->setleadNeutralCand(convertToPtr(cand));
0072 }
0073
0074
0075 template <typename T>
0076 void setleadCand(const T& cand) {
0077 tau_->setleadCand(convertToPtr(cand));
0078 }
0079
0080
0081 void addPFCand(Region region, ParticleType type, const CandidatePtr& ptr, bool skipAddToP4 = false);
0082
0083
0084 void reserve(Region region, ParticleType type, size_t size);
0085
0086
0087 template <typename InputIterator>
0088 void addPFCands(Region region, ParticleType type, const InputIterator& begin, const InputIterator& end) {
0089 for (InputIterator iter = begin; iter != end; ++iter) {
0090 addPFCand(region, type, convertToPtr(*iter));
0091 }
0092 }
0093
0094
0095 void reserveTauChargedHadron(Region region, size_t size);
0096
0097
0098 void addTauChargedHadron(Region region, const PFRecoTauChargedHadron& chargedHadron);
0099
0100
0101 template <typename InputIterator>
0102 void addTauChargedHadrons(Region region, const InputIterator& begin, const InputIterator& end) {
0103 for (InputIterator iter = begin; iter != end; ++iter) {
0104 addTauChargedHadron(region, *iter);
0105 }
0106 }
0107
0108
0109 void reservePiZero(Region region, size_t size);
0110
0111
0112 void addPiZero(Region region, const RecoTauPiZero& piZero);
0113
0114
0115 template <typename InputIterator>
0116 void addPiZeros(Region region, const InputIterator& begin, const InputIterator& end) {
0117 for (InputIterator iter = begin; iter != end; ++iter) {
0118 addPiZero(region, *iter);
0119 }
0120 }
0121
0122
0123 std::unique_ptr<reco::PFTau> get(bool setupLeadingCandidates = true);
0124
0125
0126 const reco::Candidate::LorentzVector& p4() const { return p4_; }
0127
0128 private:
0129 typedef std::pair<Region, ParticleType> CollectionKey;
0130 typedef std::map<CollectionKey, std::vector<CandidatePtr>*> CollectionMap;
0131 typedef std::shared_ptr<std::vector<CandidatePtr> > SortedListPtr;
0132 typedef std::map<CollectionKey, SortedListPtr> SortedCollectionMap;
0133
0134 bool copyGammas_;
0135
0136 const StringObjectFunction<reco::PFTau>* signalConeSize_;
0137 double minAbsPhotonSumPt_insideSignalCone_;
0138 double minRelPhotonSumPt_insideSignalCone_;
0139 double minAbsPhotonSumPt_outsideSignalCone_;
0140 double minRelPhotonSumPt_outsideSignalCone_;
0141
0142
0143 std::vector<CandidatePtr>* getCollection(Region region, ParticleType type);
0144 SortedListPtr getSortedCollection(Region region, ParticleType type);
0145
0146
0147 void sortAndCopyIntoTau();
0148
0149
0150 CandidatePtr convertToPtr(const PFCandidatePtr& pfPtr) const;
0151 CandidatePtr convertToPtr(const CandidatePtr& candPtr) const;
0152
0153 const edm::Handle<edm::View<reco::Candidate> >& pfCands_;
0154 std::unique_ptr<reco::PFTau> tau_;
0155 CollectionMap collections_;
0156
0157
0158 SortedCollectionMap sortedCollections_;
0159
0160
0161 reco::Candidate::LorentzVector p4_;
0162 };
0163 }
0164 }
0165 #endif