CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

RecoTauProducer Class Reference

Inheritance diagram for RecoTauProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Types

typedef
reco::tau::RecoTauBuilderPlugin 
Builder
typedef boost::ptr_vector
< Builder
BuilderList
typedef
reco::tau::RecoTauModifierPlugin 
Modifier
typedef boost::ptr_vector
< Modifier
ModifierList

Public Member Functions

void produce (edm::Event &evt, const edm::EventSetup &es)
 RecoTauProducer (const edm::ParameterSet &pset)
 ~RecoTauProducer ()

Private Attributes

BuilderList builders_
bool buildNullTaus_
edm::InputTag jetSrc_
ModifierList modifiers_
std::auto_ptr
< StringCutObjectSelector
< reco::PFTau > > 
outputSelector_
edm::InputTag piZeroSrc_

Detailed Description

Definition at line 40 of file RecoTauProducer.cc.


Member Typedef Documentation

Definition at line 42 of file RecoTauProducer.cc.

typedef boost::ptr_vector<Builder> RecoTauProducer::BuilderList

Definition at line 44 of file RecoTauProducer.cc.

Definition at line 43 of file RecoTauProducer.cc.

typedef boost::ptr_vector<Modifier> RecoTauProducer::ModifierList

Definition at line 45 of file RecoTauProducer.cc.


Constructor & Destructor Documentation

RecoTauProducer::RecoTauProducer ( const edm::ParameterSet pset) [explicit]

Definition at line 64 of file RecoTauProducer.cc.

References builders_, buildNullTaus_, SurfaceDeformationFactory::create(), edm::ParameterSet::exists(), reco::get(), edm::ParameterSet::getParameter(), jetSrc_, modifiers_, outputSelector_, piZeroSrc_, and elec_selection::selection().

                                                            {
  jetSrc_ = pset.getParameter<edm::InputTag>("jetSrc");
  piZeroSrc_ = pset.getParameter<edm::InputTag>("piZeroSrc");

  typedef std::vector<edm::ParameterSet> VPSet;
  // Get each of our tau builders
  const VPSet& builders = pset.getParameter<VPSet>("builders");
  for (VPSet::const_iterator builderPSet = builders.begin();
      builderPSet != builders.end(); ++builderPSet) {
    // Get plugin name
    const std::string& pluginType =
        builderPSet->getParameter<std::string>("plugin");
    // Build the plugin
    builders_.push_back(
        RecoTauBuilderPluginFactory::get()->create(pluginType, *builderPSet));
  }

  const VPSet& modfiers = pset.getParameter<VPSet>("modifiers");
  for (VPSet::const_iterator modfierPSet = modfiers.begin();
      modfierPSet != modfiers.end(); ++modfierPSet) {
    // Get plugin name
    const std::string& pluginType =
        modfierPSet->getParameter<std::string>("plugin");
    // Build the plugin
    modifiers_.push_back(
        RecoTauModifierPluginFactory::get()->create(pluginType, *modfierPSet));
  }

  // Check if we want to apply a final output selection
  if (pset.exists("outputSelection")) {
    std::string selection = pset.getParameter<std::string>("outputSelection");
    if (selection != "") {
      outputSelector_.reset(
          new StringCutObjectSelector<reco::PFTau>(selection));
    }
  }
  buildNullTaus_ = pset.getParameter<bool>("buildNullTaus");
  produces<reco::PFTauCollection>();
}
RecoTauProducer::~RecoTauProducer ( ) [inline]

Definition at line 48 of file RecoTauProducer.cc.

{}

Member Function Documentation

void RecoTauProducer::produce ( edm::Event evt,
const edm::EventSetup es 
) [virtual]

Implements edm::EDProducer.

Definition at line 104 of file RecoTauProducer.cc.

References builders_, buildNullTaus_, edm::Event::getByLabel(), analyzePatCleaning_cfg::jets, jetSrc_, modifiers_, convertSQLitetoXML_cfg::output, outputSelector_, piZeroSrc_, edm::Event::put(), reco::PFTau::setjetRef(), and metsig::tau.

                                                                    {
  // Get the jet input collection via a view of Candidates
  edm::Handle<reco::CandidateView> jetView;
  evt.getByLabel(jetSrc_, jetView);

  // Convert to a vector of PFJetRefs
  reco::PFJetRefVector jets =
      reco::tau::castView<reco::PFJetRefVector>(jetView);

  // Get the pizero input collection
  edm::Handle<reco::JetPiZeroAssociation> piZeroAssoc;
  evt.getByLabel(piZeroSrc_, piZeroAssoc);

  // Update all our builders and modifiers with the event info
  for (BuilderList::iterator builder = builders_.begin();
      builder != builders_.end(); ++builder) {
    builder->setup(evt, es);
  }
  for (ModifierList::iterator modifier = modifiers_.begin();
      modifier != modifiers_.end(); ++modifier) {
    modifier->setup(evt, es);
  }

  // Create output collection
  std::auto_ptr<reco::PFTauCollection> output(new reco::PFTauCollection());

  // Loop over the jets and build the taus for each jet
  BOOST_FOREACH(reco::PFJetRef jetRef, jets) {
    // Get the PiZeros associated with this jet
    const std::vector<reco::RecoTauPiZero>& piZeros = (*piZeroAssoc)[jetRef];
    // Loop over our builders and create the set of taus for this jet
    unsigned int nTausBuilt = 0;
    for (BuilderList::const_iterator builder = builders_.begin();
        builder != builders_.end(); ++builder) {
      // Get a ptr_vector of taus from the builder
      reco::tau::RecoTauBuilderPlugin::output_type taus(
          (*builder)(jetRef, piZeros));
      // Check this size of the taus built.
      // Grow the vector if necessary
      output->reserve(output->size() + taus.size());
      // Copy without selection
      if (!outputSelector_.get()) {
        output->insert(output->end(), taus.begin(), taus.end());
        nTausBuilt += taus.size();
      } else {
        // Copy only those that pass the selection.
        BOOST_FOREACH(const reco::PFTau& tau, taus) {
          if ((*outputSelector_)(tau)) {
            nTausBuilt++;
            output->push_back(tau);
          }
        }
      }
    }
    // If we didn't build *any* taus for this jet, build a null tau if desired.
    // The null PFTau has no content, but it's four vector is set to that of the
    // jet.
    if (!nTausBuilt && buildNullTaus_) {
      reco::PFTau nullTau(std::numeric_limits<int>::quiet_NaN(), jetRef->p4());
      nullTau.setjetRef(jetRef);
      output->push_back(nullTau);
    }
  }

  // Loop over the taus we have created and apply our modifiers to the taus
  for (reco::PFTauCollection::iterator tau = output->begin();
      tau != output->end(); ++tau) {
    for (ModifierList::const_iterator modifier = modifiers_.begin();
        modifier != modifiers_.end(); ++modifier) {
      (*modifier)(*tau);
    }
  }
  evt.put(output);
}

Member Data Documentation

Definition at line 54 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

Definition at line 61 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

Definition at line 52 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

Definition at line 55 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

Definition at line 57 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

Definition at line 53 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().