CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Protected Attributes | Private Attributes
TauDiscriminationProducerBase< TauType, TauDiscriminator > Class Template Referenceabstract

#include <TauDiscriminationProducerBase.h>

Inheritance diagram for TauDiscriminationProducerBase< TauType, TauDiscriminator >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper CaloRecoTauDiscriminationAgainstElectron CaloRecoTauDiscriminationAgainstHadronicJets CaloRecoTauDiscriminationByCharge CaloRecoTauDiscriminationByDeltaE CaloRecoTauDiscriminationByFlightPathSignificance CaloRecoTauDiscriminationByInvMass CaloRecoTauDiscriminationByIsolation CaloRecoTauDiscriminationByLeadingTrackPtCut CaloRecoTauDiscriminationByNProngs CaloRecoTauDiscriminationByTauPolarization PFRecoTauCorrectedInvariantMassProducer PFRecoTauDecayModeIndexProducer PFRecoTauDiscriminationAgainstElectron PFRecoTauDiscriminationAgainstElectronDeadECAL PFRecoTauDiscriminationAgainstElectronMVA PFRecoTauDiscriminationAgainstElectronMVA2 PFRecoTauDiscriminationAgainstElectronMVA3 PFRecoTauDiscriminationAgainstMuon PFRecoTauDiscriminationAgainstMuon2 PFRecoTauDiscriminationByCharge PFRecoTauDiscriminationByDeltaE PFRecoTauDiscriminationByFlight PFRecoTauDiscriminationByFlightPathSignificance PFRecoTauDiscriminationByHPSSelection PFRecoTauDiscriminationByInvMass PFRecoTauDiscriminationByIsolation PFRecoTauDiscriminationByLeadingObjectPtCut PFRecoTauDiscriminationByMVAIsolation PFRecoTauDiscriminationByNProngs PFRecoTauDiscriminationByTauPolarization PFTauDecayModeCutMultiplexer PFTauDiscriminatorLogicalAndProducer PFTauMVADiscriminator PFTauRandomDiscriminator RecoTauDecayModeCutMultiplexer RecoTauDiscriminantCutMultiplexer RecoTauDiscriminationByGenMatch RecoTauIndexDiscriminatorProducer RecoTauMVADiscriminator RecoTauMVATransform TauDiscriminationAgainstCaloMuon< TauType, TauDiscriminator > TauDiscriminationAgainstMuon< TauType, TauDiscriminator > TauDiscriminationByStringCut< TauType, TauDiscriminator > TCRecoTauDiscriminationAgainstHadronicJets TCRecoTauDiscriminationAlgoComponent

Classes

struct  TauDiscInfo
 

Public Types

typedef std::vector< TauType > TauCollection
 
typedef edm::Ref< TauCollectionTauRef
 
typedef edm::RefProd
< TauCollection
TauRefProd
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

virtual void beginEvent (const edm::Event &evt, const edm::EventSetup &evtSetup)
 
virtual double discriminate (const TauRef &tau)=0
 
virtual void endEvent (edm::Event &evt)
 
void produce (edm::Event &, const edm::EventSetup &)
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 TauDiscriminationProducerBase ()
 
virtual ~TauDiscriminationProducerBase ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Protected Attributes

double prediscriminantFailValue_
 
edm::InputTag TauProducer_
 

Private Attributes

uint8_t andPrediscriminants_
 
std::vector< TauDiscInfoprediscriminants_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

template<class TauType, class TauDiscriminator>
class TauDiscriminationProducerBase< TauType, TauDiscriminator >

Definition at line 47 of file TauDiscriminationProducerBase.h.

Member Typedef Documentation

template<class TauType , class TauDiscriminator >
typedef std::vector<TauType> TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauCollection

Definition at line 50 of file TauDiscriminationProducerBase.h.

template<class TauType , class TauDiscriminator >
typedef edm::Ref<TauCollection> TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauRef

Definition at line 51 of file TauDiscriminationProducerBase.h.

template<class TauType , class TauDiscriminator >
typedef edm::RefProd<TauCollection> TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauRefProd

Definition at line 52 of file TauDiscriminationProducerBase.h.

Constructor & Destructor Documentation

template<class TauType , class TauDiscriminator >
TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauDiscriminationProducerBase ( const edm::ParameterSet iConfig)
explicit

Definition at line 15 of file TauDiscriminationProducerBase.cc.

References GOODCOLL_filter_cfg::cut, edm::hlt::Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), diffTwoXMLs::label, TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauDiscInfo::label, and create_public_pileup_plots::transform.

16 {
17  // tau collection to discriminate
18  TauProducer_ = iConfig.getParameter<edm::InputTag>(getProducerString<TauType>());
19 
20  // prediscriminant operator
21  // require the tau to pass the following prediscriminants
22  const edm::ParameterSet& prediscriminantConfig = iConfig.getParameter<edm::ParameterSet>("Prediscriminants");
23 
24  // determine boolean operator used on the prediscriminants
25  std::string pdBoolOperator = prediscriminantConfig.getParameter<std::string>("BooleanOperator");
26  // convert string to lowercase
27  transform(pdBoolOperator.begin(), pdBoolOperator.end(), pdBoolOperator.begin(), ::tolower);
28 
29  if( pdBoolOperator == "and" )
30  {
31  andPrediscriminants_ = 0x1; //use chars instead of bools so we can do a bitwise trick later
32  }
33  else if ( pdBoolOperator == "or" )
34  {
36  }
37  else
38  {
39  throw cms::Exception("TauDiscriminationProducerBase") << "PrediscriminantBooleanOperator defined incorrectly, options are: AND,OR";
40  }
41 
42  // get the list of prediscriminants
43  std::vector<std::string> prediscriminantsNames = prediscriminantConfig.getParameterNamesForType<edm::ParameterSet>();
44 
45  for( std::vector<std::string>::const_iterator iDisc = prediscriminantsNames.begin();
46  iDisc != prediscriminantsNames.end(); ++iDisc )
47  {
48  const edm::ParameterSet& iPredisc = prediscriminantConfig.getParameter<edm::ParameterSet>(*iDisc);
49  const edm::InputTag& label = iPredisc.getParameter<edm::InputTag>("Producer");
50  double cut = iPredisc.getParameter<double>("cut");
51 
52  TauDiscInfo thisDiscriminator;
53  thisDiscriminator.label = label;
54  thisDiscriminator.cut = cut;
55  prediscriminants_.push_back(thisDiscriminator);
56  }
57 
59 
60  // register product
61  produces<TauDiscriminator>();
62 }
T getParameter(std::string const &) const
std::vector< TauDiscInfo > prediscriminants_
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:195
template<class TauType , class TauDiscriminator >
TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauDiscriminationProducerBase ( )

Definition at line 7 of file TauDiscriminationProducerBase.cc.

References edm::hlt::Exception.

8 {
9  throw cms::Exception("TauDiscriminationProducerBase") << " -- default ctor called; derived classes must call " <<
10  "TauDiscriminationProducerBase(const ParameterSet&)";
11 }
template<class TauType , class TauDiscriminator >
virtual TauDiscriminationProducerBase< TauType, TauDiscriminator >::~TauDiscriminationProducerBase ( )
inlinevirtual

Definition at line 61 of file TauDiscriminationProducerBase.h.

61 {}

Member Function Documentation

template<class TauType , class TauDiscriminator >
virtual void TauDiscriminationProducerBase< TauType, TauDiscriminator >::beginEvent ( const edm::Event evt,
const edm::EventSetup evtSetup 
)
inlinevirtual
template<class TauType , class TauDiscriminator >
virtual double TauDiscriminationProducerBase< TauType, TauDiscriminator >::discriminate ( const TauRef tau)
pure virtual
template<class TauType , class TauDiscriminator >
virtual void TauDiscriminationProducerBase< TauType, TauDiscriminator >::endEvent ( edm::Event evt)
inlinevirtual
template<class TauType , class TauDiscriminator >
void TauDiscriminationProducerBase< TauType, TauDiscriminator >::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 65 of file TauDiscriminationProducerBase.cc.

References edm::hlt::Exception, edm::ProductID::id(), edm::HandleBase::id(), convertSQLitetoXML_cfg::output, and query::result.

66 {
67  // setup function - does nothing in base, but can be overridden to retrieve PV or other stuff
68  beginEvent(event, eventSetup);
69 
70  // retrieve the tau collection to discriminate
72  event.getByLabel(TauProducer_, taus);
73 
74  edm::ProductID tauProductID = taus.id();
75 
76  // output product
77  std::auto_ptr<TauDiscriminator> output(new TauDiscriminator(TauRefProd(taus)));
78 
79  size_t nTaus = taus->size();
80 
81  // load prediscriminators
82  size_t nPrediscriminants = prediscriminants_.size();
83  for( size_t iDisc = 0; iDisc < nPrediscriminants; ++iDisc )
84  {
85  prediscriminants_[iDisc].fill(event);
86 
87  // Check to make sure the product is correct for the discriminator.
88  // If not, throw a more informative exception.
89  edm::ProductID discKeyId =
90  prediscriminants_[iDisc].handle->keyProduct().id();
91  if (tauProductID != discKeyId) {
92  throw cms::Exception("MisconfiguredPrediscriminant")
93  << "The tau collection with input tag " << TauProducer_
94  << " has product ID: " << tauProductID
95  << " but the pre-discriminator with input tag "
96  << prediscriminants_[iDisc].label
97  << " is keyed with product ID: " << discKeyId << std::endl;
98  }
99  }
100 
101  // loop over taus
102  for( size_t iTau = 0; iTau < nTaus; ++iTau )
103  {
104  // get reference to tau
105  TauRef tauRef(taus, iTau);
106 
107  bool passesPrediscriminants = true;
108  // check tau passes prediscriminants
109  for( size_t iDisc = 0; iDisc < nPrediscriminants; ++iDisc )
110  {
111  // current discriminant result for this tau
112  double discResult = (*prediscriminants_[iDisc].handle)[tauRef];
113  uint8_t thisPasses = ( discResult > prediscriminants_[iDisc].cut ) ? 1 : 0;
114 
115  // if we are using the AND option, as soon as one fails,
116  // the result is FAIL and we can quit looping.
117  // if we are using the OR option as soon as one passes,
118  // the result is pass and we can quit looping
119 
120  // truth table
121  // | result (thisPasses)
122  // | F | T
123  //-----------------------------------
124  // AND(T) | res=fails | continue
125  // | break |
126  //-----------------------------------
127  // OR (F) | continue | res=passes
128  // | | break
129 
130  if( thisPasses ^ andPrediscriminants_ ) //XOR
131  {
132  passesPrediscriminants = ( andPrediscriminants_ ? 0 : 1 ); //NOR
133  break;
134  }
135  }
136 
138  if( passesPrediscriminants )
139  {
140  // this tau passes the prereqs, call our implemented discrimination function
141  result = discriminate(tauRef);
142  }
143 
144  // store the result of this tau into our new discriminator
145  output->setValue(iTau, result);
146  }
147  event.put(output);
148 
149  // function to put additional information into the event - does nothing in base, but can be overridden in derived classes
150  endEvent(event);
151 }
virtual double discriminate(const TauRef &tau)=0
edm::RefProd< TauCollection > TauRefProd
ProductID id() const
Definition: HandleBase.cc:15
std::vector< TauDiscInfo > prediscriminants_
virtual void endEvent(edm::Event &evt)
tuple result
Definition: query.py:137
virtual void beginEvent(const edm::Event &evt, const edm::EventSetup &evtSetup)

Member Data Documentation

template<class TauType , class TauDiscriminator >
uint8_t TauDiscriminationProducerBase< TauType, TauDiscriminator >::andPrediscriminants_
private

Definition at line 91 of file TauDiscriminationProducerBase.h.

template<class TauType , class TauDiscriminator >
double TauDiscriminationProducerBase< TauType, TauDiscriminator >::prediscriminantFailValue_
protected
template<class TauType , class TauDiscriminator >
std::vector<TauDiscInfo> TauDiscriminationProducerBase< TauType, TauDiscriminator >::prediscriminants_
private

Definition at line 89 of file TauDiscriminationProducerBase.h.

template<class TauType , class TauDiscriminator >
edm::InputTag TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauProducer_
protected

Definition at line 86 of file TauDiscriminationProducerBase.h.