CMS 3D CMS Logo

TauDiscriminationProducerBase.h
Go to the documentation of this file.
1 #ifndef RecoTauTag_RecoTau_TauDiscriminationProducerBase_H_
2 #define RecoTauTag_RecoTau_TauDiscriminationProducerBase_H_
3 
4 /* class TauDiscriminationProducerBase
5  *
6  * Base classes for producing Calo and PFTau discriminators
7  *
8  * PFTaus - inherit from PFTauDiscriminationProducerBase
9  * CaloTaus - inherit from CaloTauDiscriminationProducerBase
10  *
11  * The base class takes a (Calo/PF)Tau collection and a collection of
12  * associated (Calo/PF)TauDiscriminators. Each tau is required to pass the given
13  * set of prediscriminants. Taus that pass these are then passed to the
14  * pure virtual function
15  *
16  * double discriminate(const TauRef&);
17  *
18  * The derived classes should implement this function and return a double
19  * giving the specific discriminant result for this tau.
20  *
21  * The edm::Event and EventSetup are available to the derived classes
22  * at the beginning of the event w/ the virtual function
23  *
24  * void beginEvent(...)
25  *
26  * The derived classes can set the desired value for taus that fail the
27  * prediscriminants by setting the protected variable prediscriminantFailValue_
28  *
29  * created : Wed Aug 12 16:58:37 PDT 2009
30  * Authors : Evan Friis (UC Davis), Simone Gennai (SNS)
31  */
32 
40 
43 
46 
49 
50 template<class TauType, class TauDiscriminator>
52  public:
53  // setup framework types for this tautype
54  typedef std::vector<TauType> TauCollection;
57 
58  // standard constructor from PSet
59  explicit TauDiscriminationProducerBase(const edm::ParameterSet& iConfig);
60 
61  // default constructor must not be called - it will throw an exception
62  // derived! classes must call the parameterset constructor.
64 
66 
67  void produce(edm::Event&, const edm::EventSetup&) override;
68 
69  // called at the beginning of every event - override if necessary.
70  virtual void beginEvent(const edm::Event&, const edm::EventSetup&) {}
71 
72  // abstract functions implemented in derived classes.
73  virtual double discriminate(const TauRef& tau) const = 0;
74 
75  // called at the end of event processing - override if necessary.
76  virtual void endEvent(edm::Event&) {}
77 
78  struct TauDiscInfo {
82  // = consumes<TauDiscriminator>(label);
83  double cut;
84  void fill(const edm::Event& evt) {
85  // disc_token = consumes<TauDiscriminator>(label);
86  evt.getByToken(disc_token, handle);
87  };
88  };
89 
90 
91  protected:
92  //value given to taus that fail prediscriminants
94 
96 
99 
100  // current tau
101  size_t tauIndex_;
102 
103  private:
104  std::vector<TauDiscInfo> prediscriminants_;
105  // select boolean operation on prediscriminants (and = 0x01, or = 0x00)
107 };
108 
109 // define our implementations
116 
117 
119 //for this tau type
120 template<class TauType> std::string getProducerString()
121 {
122  // this generic one shoudl never be called.
123  // these are specialized in TauDiscriminationProducerBase.cc
124  throw cms::Exception("TauDiscriminationProducerBase")
125  << "Unsupported TauType used. You must use either PFTau, PATTau or CaloTaus.";
126 }
127 #endif
edm::EDGetTokenT< TauDiscriminator > disc_token
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
TauDiscriminationProducerBase< reco::CaloTau, reco::CaloTauDiscriminator > CaloTauDiscriminationProducerBase
std::vector< TauDiscInfo > prediscriminants_
void produce(edm::Event &, const edm::EventSetup &) override
TauDiscriminationProducerBase< pat::Tau, pat::PATTauDiscriminator > PATTauDiscriminationProducerBase
virtual void beginEvent(const edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< TauCollection > Tau_token
std::string getProducerString()
helper function retrieve the correct cfi getter string (ie PFTauProducer)
virtual double discriminate(const TauRef &tau) const =0
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase