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 // called at the end of event processing - override if necessary. 00073 virtual void endEvent(edm::Event& evt) {} 00074 00075 struct TauDiscInfo { 00076 edm::InputTag label; 00077 edm::Handle<TauDiscriminator> handle; 00078 double cut; 00079 void fill(const edm::Event& evt) { evt.getByLabel(label, handle); }; 00080 }; 00081 00082 protected: 00083 //value given to taus that fail prediscriminants 00084 double prediscriminantFailValue_; 00085 00086 edm::InputTag TauProducer_; 00087 00088 std::string moduleLabel_; 00089 00090 private: 00091 std::vector<TauDiscInfo> prediscriminants_; 00092 // select boolean operation on prediscriminants (and = 0x01, or = 0x00) 00093 uint8_t andPrediscriminants_; 00094 }; 00095 00096 // define our implementations 00097 typedef TauDiscriminationProducerBase<reco::PFTau, reco::PFTauDiscriminator> 00098 PFTauDiscriminationProducerBase; 00099 typedef TauDiscriminationProducerBase<reco::CaloTau, reco::CaloTauDiscriminator> 00100 CaloTauDiscriminationProducerBase; 00101 00103 //for this tau type 00104 template<class TauType> std::string getProducerString() 00105 { 00106 // this generic one shoudl never be called. 00107 // these are specialized in TauDiscriminationProducerBase.cc 00108 throw cms::Exception("TauDiscriminationProducerBase") 00109 << "Unsupported TauType used. You must use either PFTau or CaloTaus."; 00110 } 00111 #endif