File indexing completed on 2024-04-06 12:04:55
0001 #ifndef DataFormats_PatCandidates_Tau_h
0002 #define DataFormats_PatCandidates_Tau_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include "DataFormats/TauReco/interface/BaseTau.h"
0019 #include "DataFormats/TauReco/interface/PFTauTransverseImpactParameter.h"
0020 #include "DataFormats/TrackReco/interface/Track.h"
0021 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0022 #include "DataFormats/PatCandidates/interface/Lepton.h"
0023 #include "DataFormats/JetReco/interface/GenJetCollection.h"
0024 #include "DataFormats/Candidate/interface/Candidate.h"
0025 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0026
0027 #include "DataFormats/PatCandidates/interface/TauPFSpecific.h"
0028 #include "DataFormats/PatCandidates/interface/TauJetCorrFactors.h"
0029 #include "DataFormats/PatCandidates/interface/TauPFEssential.h"
0030
0031 #include "DataFormats/Common/interface/AtomicPtrCache.h"
0032
0033
0034 namespace pat {
0035 class Tau;
0036 typedef std::vector<Tau> TauCollection;
0037 typedef edm::Ref<TauCollection> TauRef;
0038 typedef edm::RefProd<TauCollection> TauRefProd;
0039 typedef edm::RefVector<TauCollection> TauRefVector;
0040 }
0041
0042 namespace reco {
0043
0044 std::ostream& operator<<(std::ostream& out, const pat::Tau& obj);
0045
0046 }
0047
0048
0049 namespace pat {
0050
0051 class PATTauSlimmer;
0052
0053 class Tau : public Lepton<reco::BaseTau> {
0054
0055
0056
0057 friend class PATTauProducer;
0058
0059 public:
0060 typedef std::pair<std::string, float> IdPair;
0061
0062
0063 Tau();
0064
0065 Tau(const reco::BaseTau& aTau);
0066
0067 Tau(const edm::RefToBase<reco::BaseTau>& aTauRef);
0068
0069 Tau(const edm::Ptr<reco::BaseTau>& aTauRef);
0070
0071 ~Tau() override;
0072
0073
0074 Tau* clone() const override { return new Tau(*this); }
0075
0076
0077
0078 const reco::TrackRefVector& isolationTracks() const override;
0079
0080 reco::TrackRef leadTrack() const override;
0081
0082 const reco::TrackRefVector& signalTracks() const override;
0083
0084 void embedIsolationTracks();
0085
0086 void embedLeadTrack();
0087
0088 void embedSignalTracks();
0089
0090
0091 void embedLeadPFCand();
0092
0093 void embedLeadPFChargedHadrCand();
0094
0095 void embedLeadPFNeutralCand();
0096
0097 void embedSignalPFCands();
0098
0099 void embedSignalPFChargedHadrCands();
0100
0101 void embedSignalPFNeutralHadrCands();
0102
0103 void embedSignalPFGammaCands();
0104
0105 void embedIsolationPFCands();
0106
0107 void embedIsolationPFChargedHadrCands();
0108
0109 void embedIsolationPFNeutralHadrCands();
0110
0111 void embedIsolationPFGammaCands();
0112
0113
0114
0115 const reco::GenJet* genJet() const;
0116
0117 void setGenJet(const reco::GenJetRef& ref);
0118
0119
0120
0121 bool isPFTau() const { return !pfSpecific_.empty(); }
0122
0123 const pat::tau::TauPFSpecific& pfSpecific() const;
0124 const pat::tau::TauPFEssential& pfEssential() const;
0125
0126
0127 const reco::JetBaseRef& pfJetRef() const { return pfSpecific().pfJetRef_; }
0128
0129
0130 reco::PFRecoTauChargedHadronRef leadTauChargedHadronCandidate() const;
0131
0132
0133 const reco::PFCandidatePtr leadPFChargedHadrCand() const;
0134
0135
0136 float leadPFChargedHadrCandsignedSipt() const { return pfSpecific().leadPFChargedHadrCandsignedSipt_; }
0137
0138
0139 const reco::PFCandidatePtr leadPFNeutralCand() const;
0140
0141
0142 const reco::PFCandidatePtr leadPFCand() const;
0143
0144
0145 const std::vector<reco::PFCandidatePtr>& signalPFCands() const;
0146
0147
0148 const std::vector<reco::PFCandidatePtr>& signalPFChargedHadrCands() const;
0149
0150
0151 const std::vector<reco::PFCandidatePtr>& signalPFNeutrHadrCands() const;
0152
0153
0154 const std::vector<reco::PFCandidatePtr>& signalPFGammaCands() const;
0155
0156
0157 const std::vector<reco::PFRecoTauChargedHadron>& signalTauChargedHadronCandidates() const;
0158
0159
0160 const std::vector<reco::RecoTauPiZero>& signalPiZeroCandidates() const;
0161
0162
0163 const std::vector<reco::PFCandidatePtr>& isolationPFCands() const;
0164
0165
0166 const std::vector<reco::PFCandidatePtr>& isolationPFChargedHadrCands() const;
0167
0168
0169 const std::vector<reco::PFCandidatePtr>& isolationPFNeutrHadrCands() const;
0170
0171
0172 const std::vector<reco::PFCandidatePtr>& isolationPFGammaCands() const;
0173
0174
0175 const std::vector<reco::PFRecoTauChargedHadron>& isolationTauChargedHadronCandidates() const;
0176
0177
0178 const std::vector<reco::RecoTauPiZero>& isolationPiZeroCandidates() const;
0179
0180
0181 float isolationPFChargedHadrCandsPtSum() const { return pfSpecific().isolationPFChargedHadrCandsPtSum_; }
0182
0183
0184 float isolationPFGammaCandsEtSum() const { return pfSpecific().isolationPFGammaCandsEtSum_; }
0185
0186
0187 float maximumHCALPFClusterEt() const { return pfSpecific().maximumHCALPFClusterEt_; }
0188
0189
0190 float emFraction() const { return pfSpecific().emFraction_; }
0191
0192
0193 float hcalTotOverPLead() const { return pfSpecific().hcalTotOverPLead_; }
0194
0195
0196 float hcalMaxOverPLead() const { return pfSpecific().hcalMaxOverPLead_; }
0197
0198
0199 float hcal3x3OverPLead() const { return pfSpecific().hcal3x3OverPLead_; }
0200
0201
0202 float ecalStripSumEOverPLead() const { return pfSpecific().ecalStripSumEOverPLead_; }
0203
0204
0205 float bremsRecoveryEOverPLead() const { return pfSpecific().bremsRecoveryEOverPLead_; }
0206
0207
0208 const reco::TrackRef& electronPreIDTrack() const { return pfSpecific().electronPreIDTrack_; }
0209
0210
0211 float electronPreIDOutput() const { return pfSpecific().electronPreIDOutput_; }
0212
0213
0214 bool electronPreIDDecision() const { return pfSpecific().electronPreIDDecision_; }
0215
0216
0217 float caloComp() const { return pfSpecific().caloComp_; }
0218
0219
0220 float segComp() const { return pfSpecific().segComp_; }
0221
0222
0223 bool muonDecision() const { return pfSpecific().muonDecision_; }
0224
0225
0226
0227 const reco::CandidatePtr leadChargedHadrCand() const;
0228
0229 const reco::CandidatePtr leadNeutralCand() const;
0230
0231 const reco::CandidatePtr leadCand() const;
0232
0233
0234 bool ExistSignalCands() const;
0235 bool ExistIsolationCands() const;
0236 reco::CandidatePtrVector signalCands() const;
0237
0238
0239 reco::CandidatePtrVector signalChargedHadrCands() const;
0240
0241
0242 reco::CandidatePtrVector signalNeutrHadrCands() const;
0243
0244
0245 reco::CandidatePtrVector signalGammaCands() const;
0246
0247
0248 reco::CandidatePtrVector isolationCands() const;
0249
0250
0251 reco::CandidatePtrVector isolationChargedHadrCands() const;
0252
0253
0254 reco::CandidatePtrVector isolationNeutrHadrCands() const;
0255
0256
0257 reco::CandidatePtrVector isolationGammaCands() const;
0258
0259
0260
0261 std::vector<reco::CandidatePtr> signalLostTracks() const;
0262
0263
0264 void setSignalChargedHadrCands(const reco::CandidatePtrVector& ptrs) { signalChargedHadrCandPtrs_ = ptrs; }
0265 void setSignalNeutralHadrCands(const reco::CandidatePtrVector& ptrs) { signalNeutralHadrCandPtrs_ = ptrs; }
0266 void setSignalGammaCands(const reco::CandidatePtrVector& ptrs) { signalGammaCandPtrs_ = ptrs; }
0267 void setIsolationChargedHadrCands(const reco::CandidatePtrVector& ptrs) { isolationChargedHadrCandPtrs_ = ptrs; }
0268 void setIsolationNeutralHadrCands(const reco::CandidatePtrVector& ptrs) { isolationNeutralHadrCandPtrs_ = ptrs; }
0269 void setIsolationGammaCands(const reco::CandidatePtrVector& ptrs) { isolationGammaCandPtrs_ = ptrs; }
0270 void setSignalLostTracks(const std::vector<reco::CandidatePtr>& ptrs);
0271
0272
0273
0274 size_t numberOfSourceCandidatePtrs() const override;
0275
0276 reco::CandidatePtr sourceCandidatePtr(size_type i) const override;
0277
0278
0279
0280
0281 const pat::tau::TauPFEssential::Point& dxy_PCA() const { return pfEssential().dxy_PCA_; }
0282 float dxy() const { return pfEssential().dxy_; }
0283 float dxy_error() const { return pfEssential().dxy_error_; }
0284 float dxy_Sig() const;
0285 const reco::VertexRef& primaryVertex() const { return pfEssential().pv_; }
0286 const pat::tau::TauPFEssential::Point& primaryVertexPos() const { return pfEssential().pvPos_; }
0287 const pat::tau::TauPFEssential::CovMatrix& primaryVertexCov() const { return pfEssential().pvCov_; }
0288 bool hasSecondaryVertex() const { return pfEssential().hasSV_; }
0289 const pat::tau::TauPFEssential::Vector& flightLength() const { return pfEssential().flightLength_; }
0290 float flightLengthSig() const { return pfEssential().flightLengthSig_; }
0291 pat::tau::TauPFEssential::CovMatrix flightLengthCov() const;
0292 const reco::VertexRef& secondaryVertex() const { return pfEssential().sv_; }
0293 const pat::tau::TauPFEssential::Point& secondaryVertexPos() const { return pfEssential().svPos_; }
0294 const pat::tau::TauPFEssential::CovMatrix& secondaryVertexCov() const { return pfEssential().svCov_; }
0295 float ip3d() const { return pfEssential().ip3d_; }
0296 float ip3d_error() const { return pfEssential().ip3d_error_; }
0297 float ip3d_Sig() const;
0298
0299
0300
0301
0302 float ecalEnergy() const { return pfEssential().ecalEnergy_; }
0303
0304 float hcalEnergy() const { return pfEssential().hcalEnergy_; }
0305
0306 float leadingTrackNormChi2() const { return pfEssential().leadingTrackNormChi2_; }
0307
0308
0309
0310
0311 float ecalEnergyLeadChargedHadrCand() const { return pfEssential().ecalEnergyLeadChargedHadrCand_; }
0312
0313 float hcalEnergyLeadChargedHadrCand() const { return pfEssential().hcalEnergyLeadChargedHadrCand_; }
0314
0315 float phiAtEcalEntrance() const { return pfEssential().phiAtEcalEntrance_; }
0316
0317 float etaAtEcalEntrance() const { return pfEssential().etaAtEcalEntrance_; }
0318
0319 float etaAtEcalEntranceLeadChargedCand() const { return pfEssential().etaAtEcalEntranceLeadChargedCand_; }
0320
0321 float ptLeadChargedCand() const { return pfEssential().ptLeadChargedCand_; }
0322
0323 float emFraction_MVA() const { return pfEssential().emFraction_; }
0324
0325
0326
0327 reco::Candidate::LorentzVector p4Jet() const;
0328 float etaetaMoment() const;
0329 float phiphiMoment() const;
0330 float etaphiMoment() const;
0331
0332
0333 int decayMode() const { return pfEssential().decayMode_; }
0334
0335 void setDecayMode(int);
0336
0337
0338
0339
0340
0341
0342
0343 float tauID(const std::string& name) const;
0344 float tauID(const char* name) const { return tauID(std::string(name)); }
0345
0346 bool isTauIDAvailable(const std::string& name) const;
0347
0348
0349 const std::vector<IdPair>& tauIDs() const { return tauIDs_; }
0350
0351
0352 void setTauIDs(const std::vector<IdPair>& ids) { tauIDs_ = ids; }
0353
0354
0355 friend std::ostream& reco::operator<<(std::ostream& out, const Tau& obj);
0356
0357
0358
0359 const std::vector<std::string> availableJECSets() const;
0360
0361 const std::vector<std::string> availableJECLevels(const int& set = 0) const;
0362
0363 const std::vector<std::string> availableJECLevels(const std::string& set) const {
0364 return availableJECLevels(jecSet(set));
0365 };
0366
0367
0368 bool jecSetsAvailable() const { return !jec_.empty(); }
0369
0370
0371 bool jecSetAvailable(const std::string& set) const { return (jecSet(set) >= 0); };
0372
0373
0374 bool jecSetAvailable(const unsigned int& set) const { return (set < jec_.size()); };
0375
0376 std::string currentJECSet() const {
0377 return currentJECSet_ < jec_.size() ? jec_.at(currentJECSet_).jecSet() : std::string("ERROR");
0378 }
0379
0380 std::string currentJECLevel() const {
0381 return currentJECSet_ < jec_.size() ? jec_.at(currentJECSet_).jecLevel(currentJECLevel_) : std::string("ERROR");
0382 }
0383
0384
0385 float jecFactor(const std::string& level, const std::string& set = "") const;
0386
0387
0388 float jecFactor(const unsigned int& level, const unsigned int& set = 0) const;
0389
0390
0391 Tau correctedTauJet(const std::string& level, const std::string& set = "") const;
0392
0393
0394 Tau correctedTauJet(const unsigned int& level, const unsigned int& set = 0) const;
0395
0396
0397 const LorentzVector& correctedP4(const std::string& level, const std::string& set = "") const {
0398 return correctedTauJet(level, set).p4();
0399 }
0400
0401
0402 const LorentzVector& correctedP4(const unsigned int& level, const unsigned int& set = 0) const {
0403 return correctedTauJet(level, set).p4();
0404 }
0405
0406 friend class PATTauSlimmer;
0407
0408 protected:
0409
0410
0411 int jecSet(const std::string& label) const;
0412
0413 void currentJECSet(const unsigned int& set) { currentJECSet_ = set; };
0414
0415 void currentJECLevel(const unsigned int& level) { currentJECLevel_ = level; };
0416
0417 void addJECFactors(const TauJetCorrFactors& jec) { jec_.push_back(jec); };
0418
0419 void initializeJEC(unsigned int level, const unsigned int set = 0);
0420
0421 private:
0422
0423 void initFromBaseTau(const reco::BaseTau& aTau);
0424
0425 bool embeddedIsolationTracks_;
0426 std::vector<reco::Track> isolationTracks_;
0427 edm::AtomicPtrCache<reco::TrackRefVector> isolationTracksTransientRefVector_;
0428 bool embeddedLeadTrack_;
0429 std::vector<reco::Track> leadTrack_;
0430 bool embeddedSignalTracks_;
0431 std::vector<reco::Track> signalTracks_;
0432 edm::AtomicPtrCache<reco::TrackRefVector> signalTracksTransientRefVector_;
0433
0434 std::vector<reco::PFCandidate> leadPFCand_;
0435 bool embeddedLeadPFCand_;
0436 std::vector<reco::PFCandidate> leadPFChargedHadrCand_;
0437 bool embeddedLeadPFChargedHadrCand_;
0438 std::vector<reco::PFCandidate> leadPFNeutralCand_;
0439 bool embeddedLeadPFNeutralCand_;
0440
0441 std::vector<reco::PFCandidate> signalPFCands_;
0442 bool embeddedSignalPFCands_;
0443 edm::AtomicPtrCache<std::vector<reco::PFCandidatePtr> > signalPFCandsTransientPtrs_;
0444 std::vector<reco::PFCandidate> signalPFChargedHadrCands_;
0445 bool embeddedSignalPFChargedHadrCands_;
0446 edm::AtomicPtrCache<std::vector<reco::PFCandidatePtr> > signalPFChargedHadrCandsTransientPtrs_;
0447 std::vector<reco::PFCandidate> signalPFNeutralHadrCands_;
0448 bool embeddedSignalPFNeutralHadrCands_;
0449 edm::AtomicPtrCache<std::vector<reco::PFCandidatePtr> > signalPFNeutralHadrCandsTransientPtrs_;
0450 std::vector<reco::PFCandidate> signalPFGammaCands_;
0451 bool embeddedSignalPFGammaCands_;
0452 edm::AtomicPtrCache<std::vector<reco::PFCandidatePtr> > signalPFGammaCandsTransientPtrs_;
0453 std::vector<reco::PFCandidate> isolationPFCands_;
0454 bool embeddedIsolationPFCands_;
0455 edm::AtomicPtrCache<std::vector<reco::PFCandidatePtr> > isolationPFCandsTransientPtrs_;
0456 std::vector<reco::PFCandidate> isolationPFChargedHadrCands_;
0457 bool embeddedIsolationPFChargedHadrCands_;
0458 edm::AtomicPtrCache<std::vector<reco::PFCandidatePtr> > isolationPFChargedHadrCandsTransientPtrs_;
0459 std::vector<reco::PFCandidate> isolationPFNeutralHadrCands_;
0460 bool embeddedIsolationPFNeutralHadrCands_;
0461 edm::AtomicPtrCache<std::vector<reco::PFCandidatePtr> > isolationPFNeutralHadrCandsTransientPtrs_;
0462 std::vector<reco::PFCandidate> isolationPFGammaCands_;
0463 bool embeddedIsolationPFGammaCands_;
0464 edm::AtomicPtrCache<std::vector<reco::PFCandidatePtr> > isolationPFGammaCandsTransientPtrs_;
0465
0466
0467 std::vector<reco::GenJet> genJet_;
0468
0469
0470 std::vector<IdPair> tauIDs_;
0471
0472
0473
0474 std::vector<pat::tau::TauPFSpecific> pfSpecific_;
0475
0476
0477
0478
0479
0480 std::vector<pat::TauJetCorrFactors> jec_;
0481
0482
0483 unsigned int currentJECSet_;
0484
0485 unsigned int currentJECLevel_;
0486
0487
0488 reco::CandidatePtrVector signalChargedHadrCandPtrs_;
0489 reco::CandidatePtrVector signalNeutralHadrCandPtrs_;
0490 reco::CandidatePtrVector signalGammaCandPtrs_;
0491
0492 reco::CandidatePtrVector isolationChargedHadrCandPtrs_;
0493 reco::CandidatePtrVector isolationNeutralHadrCandPtrs_;
0494 reco::CandidatePtrVector isolationGammaCandPtrs_;
0495
0496
0497
0498 std::vector<pat::tau::TauPFEssential> pfEssential_;
0499 };
0500 }
0501
0502 #endif