File indexing completed on 2024-04-06 12:27:47
0001 #ifndef RecoTauTag_RecoTau_TauDiscriminationProducerBase_H_
0002 #define RecoTauTag_RecoTau_TauDiscriminationProducerBase_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
0027
0028
0029
0030
0031
0032
0033 #include "FWCore/Framework/interface/stream/EDProducer.h"
0034 #include "FWCore/Framework/interface/Event.h"
0035 #include "FWCore/Framework/interface/EventSetup.h"
0036 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0037 #include "FWCore/Framework/interface/MakerMacros.h"
0038 #include "FWCore/Framework/interface/ConsumesCollector.h"
0039
0040 #include <FWCore/ParameterSet/interface/ConfigurationDescriptions.h>
0041 #include <FWCore/ParameterSet/interface/ParameterSetDescription.h>
0042
0043 #include "DataFormats/TauReco/interface/PFTau.h"
0044 #include "DataFormats/TauReco/interface/PFTauDiscriminator.h"
0045 #include "DataFormats/TauReco/interface/TauDiscriminatorContainer.h"
0046
0047 #include "DataFormats/PatCandidates/interface/Tau.h"
0048 #include "DataFormats/PatCandidates/interface/PATTauDiscriminator.h"
0049
0050 template <class TauType,
0051 class TauDiscriminator,
0052 class TauDiscriminatorDataType = double,
0053 class ConsumeType = TauDiscriminator>
0054 class TauDiscriminationProducerBase : public edm::stream::EDProducer<> {
0055 public:
0056
0057 typedef std::vector<TauType> TauCollection;
0058 typedef edm::Ref<TauCollection> TauRef;
0059 typedef edm::RefProd<TauCollection> TauRefProd;
0060
0061
0062 explicit TauDiscriminationProducerBase(const edm::ParameterSet& iConfig);
0063
0064
0065
0066 TauDiscriminationProducerBase();
0067
0068 ~TauDiscriminationProducerBase() override {}
0069
0070 void produce(edm::Event&, const edm::EventSetup&) override;
0071
0072
0073 virtual void beginEvent(const edm::Event&, const edm::EventSetup&) {}
0074
0075
0076 virtual TauDiscriminatorDataType discriminate(const TauRef& tau) const = 0;
0077
0078
0079 virtual void endEvent(edm::Event&) {}
0080
0081 struct TauDiscInfo {
0082 edm::InputTag label;
0083 edm::Handle<ConsumeType> handle;
0084 edm::EDGetTokenT<ConsumeType> disc_token;
0085
0086 double cut;
0087 void fill(const edm::Event& evt) {
0088
0089 evt.getByToken(disc_token, handle);
0090 };
0091 };
0092
0093 static void fillProducerDescriptions(edm::ParameterSetDescription& desc);
0094
0095
0096
0097 static std::string getTauTypeString();
0098
0099 protected:
0100
0101 double prediscriminantFailValue_;
0102
0103 edm::InputTag TauProducer_;
0104
0105 std::string moduleLabel_;
0106 edm::EDGetTokenT<TauCollection> Tau_token;
0107
0108
0109 size_t tauIndex_;
0110
0111 private:
0112 std::vector<TauDiscInfo> prediscriminants_;
0113
0114 uint8_t andPrediscriminants_;
0115 };
0116
0117
0118 typedef TauDiscriminationProducerBase<reco::PFTau,
0119 reco::TauDiscriminatorContainer,
0120 reco::SingleTauDiscriminatorContainer,
0121 reco::PFTauDiscriminator>
0122 PFTauDiscriminationContainerProducerBase;
0123 typedef TauDiscriminationProducerBase<reco::PFTau, reco::PFTauDiscriminator> PFTauDiscriminationProducerBase;
0124 typedef TauDiscriminationProducerBase<pat::Tau,
0125 reco::TauDiscriminatorContainer,
0126 reco::SingleTauDiscriminatorContainer,
0127 pat::PATTauDiscriminator>
0128 PATTauDiscriminationContainerProducerBase;
0129 typedef TauDiscriminationProducerBase<pat::Tau, pat::PATTauDiscriminator> PATTauDiscriminationProducerBase;
0130
0131 #endif