CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Protected Attributes | Private Attributes

TauDiscriminationProducerBase< TauType, TauDiscriminator > Class Template Reference

#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 PFRecoTauDiscriminationAgainstElectronMVA PFRecoTauDiscriminationAgainstMuon PFRecoTauDiscriminationByCharge PFRecoTauDiscriminationByDeltaE PFRecoTauDiscriminationByFlight PFRecoTauDiscriminationByFlightPathSignificance PFRecoTauDiscriminationByHPSSelection PFRecoTauDiscriminationByInvMass PFRecoTauDiscriminationByIsolation PFRecoTauDiscriminationByLeadingObjectPtCut PFRecoTauDiscriminationByNProngs PFRecoTauDiscriminationByTauPolarization PFTauDecayModeCutMultiplexer PFTauDiscriminatorLogicalAndProducer PFTauMVADiscriminator PFTauRandomDiscriminator RecoTauDecayModeCutMultiplexer RecoTauDiscriminationByGenMatch RecoTauIndexDiscriminatorProducer RecoTauMVADiscriminator RecoTauMVATransform TauDiscriminationAgainstCaloMuon< TauType, TauDiscriminator > TauDiscriminationAgainstMuon< TauType, TauDiscriminator > TauDiscriminationByStringCut< TauType, TauDiscriminator > TCRecoTauDiscriminationAgainstHadronicJets TCRecoTauDiscriminationAlgoComponent

List of all members.

Classes

struct  TauDiscInfo

Public Types

typedef std::vector< TauType > TauCollection
typedef edm::Ref< TauCollectionTauRef
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
void produce (edm::Event &, const edm::EventSetup &)
 TauDiscriminationProducerBase ()
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
virtual ~TauDiscriminationProducerBase ()

Protected Attributes

double prediscriminantFailValue_

Private Attributes

uint8_t andPrediscriminants_
std::vector< TauDiscInfoprediscriminants_
edm::InputTag TauProducer_

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
template<class TauType , class TauDiscriminator >
typedef edm::Ref<TauCollection> TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauRef
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, Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), label, TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauDiscInfo::label, and create_public_pileup_plots::transform.

{
   // 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>();
}
template<class TauType , class 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&)";
}
template<class TauType , class TauDiscriminator >
virtual TauDiscriminationProducerBase< TauType, TauDiscriminator >::~TauDiscriminationProducerBase ( ) [inline, virtual]

Definition at line 61 of file TauDiscriminationProducerBase.h.

{}

Member Function Documentation

template<class TauType , class TauDiscriminator >
virtual void TauDiscriminationProducerBase< TauType, TauDiscriminator >::beginEvent ( const edm::Event evt,
const edm::EventSetup evtSetup 
) [inline, virtual]
template<class TauType , class TauDiscriminator >
virtual double TauDiscriminationProducerBase< TauType, TauDiscriminator >::discriminate ( const TauRef tau) [pure virtual]
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 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);
}

Member Data Documentation

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

Definition at line 87 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 85 of file TauDiscriminationProducerBase.h.

template<class TauType , class TauDiscriminator >
edm::InputTag TauDiscriminationProducerBase< TauType, TauDiscriminator >::TauProducer_ [private]

Definition at line 84 of file TauDiscriminationProducerBase.h.