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::EDConsumerBase edm::ProductRegistryHelper CaloRecoTauDiscriminationAgainstElectron CaloRecoTauDiscriminationAgainstHadronicJets CaloRecoTauDiscriminationByCharge CaloRecoTauDiscriminationByDeltaE CaloRecoTauDiscriminationByFlightPathSignificance CaloRecoTauDiscriminationByInvMass CaloRecoTauDiscriminationByIsolation CaloRecoTauDiscriminationByLeadingTrackPtCut CaloRecoTauDiscriminationByNProngs CaloRecoTauDiscriminationByTauPolarization PFRecoTauCorrectedInvariantMassProducer PFRecoTauDiscriminationAgainstElectron PFRecoTauDiscriminationAgainstElectronDeadECAL PFRecoTauDiscriminationAgainstElectronMVA5GBR PFRecoTauDiscriminationAgainstMuon PFRecoTauDiscriminationAgainstMuon2 PFRecoTauDiscriminationAgainstMuonMVA PFRecoTauDiscriminationByCharge PFRecoTauDiscriminationByDeltaE PFRecoTauDiscriminationByFlight PFRecoTauDiscriminationByFlightPathSignificance PFRecoTauDiscriminationByHPSSelection PFRecoTauDiscriminationByInvMass PFRecoTauDiscriminationByIsolation PFRecoTauDiscriminationByIsolationMVA2 PFRecoTauDiscriminationByLeadingObjectPtCut PFRecoTauDiscriminationByNProngs PFRecoTauDiscriminationByTauPolarization PFTauDecayModeCutMultiplexer PFTauDiscriminatorLogicalAndProducer PFTauRandomDiscriminator RecoTauDecayModeCutMultiplexer RecoTauDiscriminantCutMultiplexer RecoTauDiscriminationByGenMatch RecoTauIndexDiscriminatorProducer 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
 
- 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 ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Attributes

std::string moduleLabel_
 
double prediscriminantFailValue_
 
edm::EDGetTokenT< TauCollectionTau_token
 
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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

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

Definition at line 48 of file TauDiscriminationProducerBase.h.

Member Typedef Documentation

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

Definition at line 51 of file TauDiscriminationProducerBase.h.

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

Definition at line 52 of file TauDiscriminationProducerBase.h.

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

Definition at line 53 of file TauDiscriminationProducerBase.h.

Constructor & Destructor Documentation

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

Definition at line 17 of file TauDiscriminationProducerBase.cc.

References TauDiscriminationProducerBase< TauType, TauDiscriminator >::andPrediscriminants_, GOODCOLL_filter_cfg::cut, edm::hlt::Exception, edm::ParameterSet::getParameter(), diffTwoXMLs::label, TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauDiscInfo::label, TauDiscriminationProducerBase< TauType, TauDiscriminator >::prediscriminantFailValue_, TauDiscriminationProducerBase< TauType, TauDiscriminator >::prediscriminants_, AlCaHLTBitMon_QueryRunRegistry::string, TauDiscriminationProducerBase< TauType, TauDiscriminator >::Tau_token, TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauProducer_, and create_public_lumi_plots::transform.

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

Definition at line 9 of file TauDiscriminationProducerBase.cc.

References edm::hlt::Exception.

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

Definition at line 62 of file TauDiscriminationProducerBase.h.

62 {}

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 70 of file TauDiscriminationProducerBase.cc.

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

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