00001 #ifndef RecoTauTag_RecoTau_TauDiscriminationProducerBase_H_ 00002 #define RecoTauTag_RecoTau_TauDiscriminationProducerBase_H_ 00003 00004 /* class TauDiscriminationProducerBase 00005 * 00006 * Base classes for producing Calo and PFTau discriminators 00007 * 00008 * PFTaus - inherit from PFTauDiscriminationProducerBase 00009 * CaloTaus - inherit from CaloTauDiscriminationProducerBase 00010 * 00011 * The base class takes a (Calo/PF)Tau collection and a collection of 00012 * associated (Calo/PF)TauDiscriminators. Each tau is required to pass the given 00013 * set of prediscriminants. Taus that pass these are then passed to the 00014 * pure virtual function 00015 * 00016 * double discriminate(const TauRef&); 00017 * 00018 * The derived classes should implement this function and return a double 00019 * giving the specific discriminant result for this tau. 00020 * 00021 * The edm::Event and EventSetup are available to the derived classes 00022 * at the beginning of the event w/ the virtual function 00023 * 00024 * void beginEvent(...) 00025 * 00026 * The derived classes can set the desired value for taus that fail the 00027 * prediscriminants by setting the protected variable prediscriminantFailValue_ 00028 * 00029 * created : Wed Aug 12 16:58:37 PDT 2009 00030 * Authors : Evan Friis (UC Davis), Simone Gennai (SNS) 00031 */ 00032 00033 #include "FWCore/Framework/interface/EDProducer.h" 00034 #include "FWCore/Framework/interface/ESHandle.h" 00035 #include "FWCore/Framework/interface/Event.h" 00036 #include "FWCore/Framework/interface/EventSetup.h" 00037 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00038 #include "FWCore/Framework/interface/MakerMacros.h" 00039 00040 #include "DataFormats/TauReco/interface/PFTau.h" 00041 #include "DataFormats/TauReco/interface/PFTauDiscriminator.h" 00042 00043 #include "DataFormats/TauReco/interface/CaloTau.h" 00044 #include "DataFormats/TauReco/interface/CaloTauDiscriminator.h" 00045 00046 template<class TauType, class TauDiscriminator> 00047 class TauDiscriminationProducerBase : public edm::EDProducer { 00048 public: 00049 // setup framework types for this tautype 00050 typedef std::vector<TauType> TauCollection; 00051 typedef edm::Ref<TauCollection> TauRef; 00052 typedef edm::RefProd<TauCollection> TauRefProd; 00053 00054 // standard constructor from PSet 00055 explicit TauDiscriminationProducerBase(const edm::ParameterSet& iConfig); 00056 00057 // default constructor must not be called - it will throw an exception 00058 // derived! classes must call the parameterset constructor. 00059 TauDiscriminationProducerBase(); 00060 00061 virtual ~TauDiscriminationProducerBase(){} 00062 00063 void produce(edm::Event&, const edm::EventSetup&); 00064 00065 // called at the beginning of every event - override if necessary. 00066 virtual void beginEvent(const edm::Event& evt, 00067 const edm::EventSetup& evtSetup) {} 00068 00069 // abstract functions implemented in derived classes. 00070 virtual double discriminate(const TauRef& tau) = 0; 00071 00072 struct TauDiscInfo { 00073 edm::InputTag label; 00074 edm::Handle<TauDiscriminator> handle; 00075 double cut; 00076 void fill(const edm::Event& evt) { evt.getByLabel(label, handle); }; 00077 }; 00078 00079 protected: 00080 //value given to taus that fail prediscriminants 00081 double prediscriminantFailValue_; 00082 00083 private: 00084 edm::InputTag TauProducer_; 00085 std::vector<TauDiscInfo> prediscriminants_; 00086 // select boolean operation on prediscriminants (and = 0x01, or = 0x00) 00087 uint8_t andPrediscriminants_; 00088 }; 00089 00090 // define our implementations 00091 typedef TauDiscriminationProducerBase<reco::PFTau, reco::PFTauDiscriminator> 00092 PFTauDiscriminationProducerBase; 00093 typedef TauDiscriminationProducerBase<reco::CaloTau, reco::CaloTauDiscriminator> 00094 CaloTauDiscriminationProducerBase; 00095 00097 //for this tau type 00098 template<class TauType> std::string getProducerString() 00099 { 00100 // this generic one shoudl never be called. 00101 // these are specialized in TauDiscriminationProducerBase.cc 00102 throw cms::Exception("TauDiscriminationProducerBase") 00103 << "Unsupported TauType used. You must use either PFTau or CaloTaus."; 00104 } 00105 #endif