#include <TauDiscriminationProducerBase.h>
Classes | |
struct | TauDiscInfo |
Public Types | |
typedef std::vector< TauType > | TauCollection |
typedef edm::Ref< TauCollection > | TauRef |
typedef edm::RefProd < TauCollection > | TauRefProd |
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 () | |
TauDiscriminationProducerBase (const edm::ParameterSet &iConfig) | |
virtual | ~TauDiscriminationProducerBase () |
Protected Attributes | |
double | prediscriminantFailValue_ |
edm::InputTag | TauProducer_ |
Private Attributes | |
uint8_t | andPrediscriminants_ |
std::vector< TauDiscInfo > | prediscriminants_ |
Definition at line 47 of file TauDiscriminationProducerBase.h.
typedef std::vector<TauType> TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauCollection |
Reimplemented in TauDiscriminationAgainstCaloMuon< TauType, TauDiscriminator >, TauDiscriminationAgainstMuon< TauType, TauDiscriminator >, and TauDiscriminationByStringCut< TauType, TauDiscriminator >.
Definition at line 50 of file TauDiscriminationProducerBase.h.
typedef edm::Ref<TauCollection> TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauRef |
Reimplemented in TauDiscriminationAgainstCaloMuon< TauType, TauDiscriminator >, TauDiscriminationAgainstMuon< TauType, TauDiscriminator >, and TauDiscriminationByStringCut< TauType, TauDiscriminator >.
Definition at line 51 of file TauDiscriminationProducerBase.h.
typedef edm::RefProd<TauCollection> TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauRefProd |
Definition at line 52 of file TauDiscriminationProducerBase.h.
TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauDiscriminationProducerBase | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 15 of file TauDiscriminationProducerBase.cc.
References GOODCOLL_filter_cfg::cut, Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), diffTwoXMLs::label, TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauDiscInfo::label, and AlCaHLTBitMon_QueryRunRegistry::string.
{ // tau collection to discriminate TauProducer_ = iConfig.getParameter<edm::InputTag>(getProducerString<TauType>()); // prediscriminant operator // require the tau to pass the following prediscriminants const edm::ParameterSet& prediscriminantConfig = iConfig.getParameter<edm::ParameterSet>("Prediscriminants"); // determine boolean operator used on the prediscriminants std::string pdBoolOperator = prediscriminantConfig.getParameter<std::string>("BooleanOperator"); // convert string to lowercase transform(pdBoolOperator.begin(), pdBoolOperator.end(), pdBoolOperator.begin(), ::tolower); if( pdBoolOperator == "and" ) { andPrediscriminants_ = 0x1; //use chars instead of bools so we can do a bitwise trick later } else if ( pdBoolOperator == "or" ) { andPrediscriminants_ = 0x0; } else { throw cms::Exception("TauDiscriminationProducerBase") << "PrediscriminantBooleanOperator defined incorrectly, options are: AND,OR"; } // get the list of prediscriminants std::vector<std::string> prediscriminantsNames = prediscriminantConfig.getParameterNamesForType<edm::ParameterSet>(); for( std::vector<std::string>::const_iterator iDisc = prediscriminantsNames.begin(); iDisc != prediscriminantsNames.end(); ++iDisc ) { const edm::ParameterSet& iPredisc = prediscriminantConfig.getParameter<edm::ParameterSet>(*iDisc); const edm::InputTag& label = iPredisc.getParameter<edm::InputTag>("Producer"); double cut = iPredisc.getParameter<double>("cut"); TauDiscInfo thisDiscriminator; thisDiscriminator.label = label; thisDiscriminator.cut = cut; prediscriminants_.push_back(thisDiscriminator); } prediscriminantFailValue_ = 0.; // register product produces<TauDiscriminator>(); }
TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauDiscriminationProducerBase | ( | ) |
Definition at line 7 of file TauDiscriminationProducerBase.cc.
References Exception.
{ throw cms::Exception("TauDiscriminationProducerBase") << " -- default ctor called; derived classes must call " << "TauDiscriminationProducerBase(const ParameterSet&)"; }
virtual TauDiscriminationProducerBase< TauType, TauDiscriminator >::~TauDiscriminationProducerBase | ( | ) | [inline, virtual] |
Definition at line 61 of file TauDiscriminationProducerBase.h.
{}
virtual void TauDiscriminationProducerBase< TauType, TauDiscriminator >::beginEvent | ( | const edm::Event & | evt, |
const edm::EventSetup & | evtSetup | ||
) | [inline, virtual] |
Reimplemented in TCRecoTauDiscriminationAgainstHadronicJets, TCRecoTauDiscriminationAlgoComponent, CaloRecoTauDiscriminationAgainstElectron, CaloRecoTauDiscriminationAgainstHadronicJets, CaloRecoTauDiscriminationByDeltaE, CaloRecoTauDiscriminationByFlightPathSignificance, PFRecoTauCorrectedInvariantMassProducer, PFRecoTauDecayModeIndexProducer, PFRecoTauDiscriminationAgainstElectronDeadECAL, PFRecoTauDiscriminationAgainstElectronMVA2, PFRecoTauDiscriminationAgainstElectronMVA3, PFRecoTauDiscriminationByDeltaE, PFRecoTauDiscriminationByFlightPathSignificance, PFRecoTauDiscriminationByIsolation, PFRecoTauDiscriminationByMVAIsolation, PFRecoTauDiscriminationByNProngs, PFRecoTauDiscriminationByTauPolarization, PFTauDecayModeCutMultiplexer, PFTauMVADiscriminator, RecoTauDecayModeCutMultiplexer, RecoTauDiscriminantCutMultiplexer, PFRecoTauDiscriminationByFlight, RecoTauMVADiscriminator, RecoTauMVATransform, TauDiscriminationAgainstCaloMuon< TauType, TauDiscriminator >, TauDiscriminationAgainstMuon< TauType, TauDiscriminator >, RecoTauDiscriminationByGenMatch, and RecoTauIndexDiscriminatorProducer.
Definition at line 66 of file TauDiscriminationProducerBase.h.
{}
virtual double TauDiscriminationProducerBase< TauType, TauDiscriminator >::discriminate | ( | const TauRef & | tau | ) | [pure virtual] |
Implemented in TCRecoTauDiscriminationAgainstHadronicJets, TCRecoTauDiscriminationAlgoComponent, CaloRecoTauDiscriminationAgainstElectron, CaloRecoTauDiscriminationAgainstHadronicJets, CaloRecoTauDiscriminationByCharge, CaloRecoTauDiscriminationByDeltaE, CaloRecoTauDiscriminationByFlightPathSignificance, CaloRecoTauDiscriminationByInvMass, CaloRecoTauDiscriminationByIsolation, CaloRecoTauDiscriminationByLeadingTrackPtCut, CaloRecoTauDiscriminationByNProngs, CaloRecoTauDiscriminationByTauPolarization, TauDiscriminationAgainstCaloMuon< TauType, TauDiscriminator >, TauDiscriminationAgainstMuon< TauType, TauDiscriminator >, and TauDiscriminationByStringCut< TauType, TauDiscriminator >.
virtual void TauDiscriminationProducerBase< TauType, TauDiscriminator >::endEvent | ( | edm::Event & | evt | ) | [inline, virtual] |
Reimplemented in PFRecoTauDiscriminationAgainstElectronMVA2, and PFRecoTauDiscriminationAgainstElectronMVA3.
Definition at line 73 of file TauDiscriminationProducerBase.h.
{}
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 Exception, edm::HandleBase::id(), edm::ProductID::id(), convertSQLitetoXML_cfg::output, and query::result.
{ // setup function - does nothing in base, but can be overridden to retrieve PV or other stuff beginEvent(event, eventSetup); // retrieve the tau collection to discriminate edm::Handle<TauCollection> taus; event.getByLabel(TauProducer_, taus); edm::ProductID tauProductID = taus.id(); // output product std::auto_ptr<TauDiscriminator> output(new TauDiscriminator(TauRefProd(taus))); size_t nTaus = taus->size(); // load prediscriminators size_t nPrediscriminants = prediscriminants_.size(); for( size_t iDisc = 0; iDisc < nPrediscriminants; ++iDisc ) { prediscriminants_[iDisc].fill(event); // Check to make sure the product is correct for the discriminator. // If not, throw a more informative exception. edm::ProductID discKeyId = prediscriminants_[iDisc].handle->keyProduct().id(); if (tauProductID != discKeyId) { throw cms::Exception("MisconfiguredPrediscriminant") << "The tau collection with input tag " << TauProducer_ << " has product ID: " << tauProductID << " but the pre-discriminator with input tag " << prediscriminants_[iDisc].label << " is keyed with product ID: " << discKeyId << std::endl; } } // loop over taus for( size_t iTau = 0; iTau < nTaus; ++iTau ) { // get reference to tau TauRef tauRef(taus, iTau); bool passesPrediscriminants = true; // check tau passes prediscriminants for( size_t iDisc = 0; iDisc < nPrediscriminants; ++iDisc ) { // current discriminant result for this tau double discResult = (*prediscriminants_[iDisc].handle)[tauRef]; uint8_t thisPasses = ( discResult > prediscriminants_[iDisc].cut ) ? 1 : 0; // if we are using the AND option, as soon as one fails, // the result is FAIL and we can quit looping. // if we are using the OR option as soon as one passes, // the result is pass and we can quit looping // truth table // | result (thisPasses) // | F | T //----------------------------------- // AND(T) | res=fails | continue // | break | //----------------------------------- // OR (F) | continue | res=passes // | | break if( thisPasses ^ andPrediscriminants_ ) //XOR { passesPrediscriminants = ( andPrediscriminants_ ? 0 : 1 ); //NOR break; } } double result = prediscriminantFailValue_; if( passesPrediscriminants ) { // this tau passes the prereqs, call our implemented discrimination function result = discriminate(tauRef); } // store the result of this tau into our new discriminator output->setValue(iTau, result); } event.put(output); // function to put additional information into the event - does nothing in base, but can be overridden in derived classes endEvent(event); }
uint8_t TauDiscriminationProducerBase< TauType, TauDiscriminator >::andPrediscriminants_ [private] |
Definition at line 91 of file TauDiscriminationProducerBase.h.
double TauDiscriminationProducerBase< TauType, TauDiscriminator >::prediscriminantFailValue_ [protected] |
Definition at line 84 of file TauDiscriminationProducerBase.h.
Referenced by PFRecoTauDiscriminationByFlight::discriminate(), PFTauMVADiscriminator::discriminate(), RecoTauDiscriminantCutMultiplexer::discriminate(), RecoTauDecayModeCutMultiplexer::discriminate(), RecoTauMVATransform::discriminate(), PFTauDiscriminatorLogicalAndProducer::PFTauDiscriminatorLogicalAndProducer(), PFTauMVADiscriminator::PFTauMVADiscriminator(), RecoTauMVADiscriminator::RecoTauMVADiscriminator(), RecoTauMVATransform::RecoTauMVATransform(), and TauDiscriminationByStringCut< TauType, TauDiscriminator >::TauDiscriminationByStringCut().
std::vector<TauDiscInfo> TauDiscriminationProducerBase< TauType, TauDiscriminator >::prediscriminants_ [private] |
Definition at line 89 of file TauDiscriminationProducerBase.h.
edm::InputTag TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauProducer_ [protected] |
Definition at line 86 of file TauDiscriminationProducerBase.h.