CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ProbeTreeProducer Class Reference

#include <ProbeTreeProducer.cc>

Inheritance diagram for ProbeTreeProducer:
edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 ProbeTreeProducer (const edm::ParameterSet &)
 ~ProbeTreeProducer ()

Private Member Functions

virtual void endJob ()
virtual bool filter (edm::Event &, const edm::EventSetup &)

Private Attributes

StringCutObjectSelector
< reco::Candidate, true > 
cut_
 The selector object.
bool filter_
 Specifies whether this module should filter.
int32_t maxProbes_
 The number of first probes used to fill the tree.
std::auto_ptr
< tnp::BaseTreeFiller
probeFiller_
 The object that actually computes variables and fills the tree for the probe.
edm::InputTag probesTag_
 InputTag to the collection of all probes.
std::string sortDescendingBy_
 Name of the reco::Candidate function used for sorting.
StringObjectFunction
< reco::Candidate, true > 
sortFunction_
 The StringObjectFunction itself.

Detailed Description

Description: TTree producer based on input probe parameters

Implementation: <Notes on="" implementation>="">

Definition at line 28 of file ProbeTreeProducer.cc.


Constructor & Destructor Documentation

ProbeTreeProducer::ProbeTreeProducer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 59 of file ProbeTreeProducer.cc.

                                                                   :
  probesTag_(iConfig.getParameter<edm::InputTag>("src")),
  cut_(iConfig.existsAs<std::string>("cut") ? iConfig.getParameter<std::string>("cut") : ""),
  filter_(iConfig.existsAs<bool>("filter") ? iConfig.getParameter<bool>("filter") : false),
  sortDescendingBy_(iConfig.existsAs<std::string>("sortDescendingBy") ? iConfig.getParameter<std::string>("sortDescendingBy") : ""),
  sortFunction_(sortDescendingBy_.size()>0 ? sortDescendingBy_ : "pt"), //need to pass a valid default
  maxProbes_(iConfig.existsAs<int32_t>("maxProbes") ? iConfig.getParameter<int32_t>("maxProbes") : -1),
  probeFiller_(new tnp::BaseTreeFiller("probe_tree", iConfig))
{
}
ProbeTreeProducer::~ProbeTreeProducer ( )

Definition at line 70 of file ProbeTreeProducer.cc.

                                     {
}

Member Function Documentation

void ProbeTreeProducer::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDFilter.

Definition at line 98 of file ProbeTreeProducer.cc.

References edm::getProcessParameterSet(), and probeFiller_.

                              {
    // ask to write the current PSet info into the TTree header
    probeFiller_->writeProvenance(edm::getProcessParameterSet());
}
bool ProbeTreeProducer::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDFilter.

Definition at line 73 of file ProbeTreeProducer.cc.

References cut_, filter_, first, edm::Event::getByLabel(), i, edm::HandleBase::isValid(), maxProbes_, min, probeFiller_, probesTag_, query::result, edm::second(), python::multivaluedict::sort(), sortDescendingBy_, and sortFunction_.

                                                                           {
  bool result = !filter_;
  edm::Handle<reco::CandidateView> probes;
  iEvent.getByLabel(probesTag_, probes);
  if(!probes.isValid()) return result;
  probeFiller_->init(iEvent);
  // select probes and calculate the sorting value
  typedef std::pair<reco::CandidateBaseRef, double> Pair;
  std::vector<Pair> selectedProbes;
  for (size_t i = 0; i < probes->size(); ++i){
    const reco::CandidateBaseRef &probe = probes->refAt(i);
    if(cut_(*probe)){
      selectedProbes.push_back(Pair(probe, sortFunction_(*probe)));
    }
  }
  // sort only if a function was provided
  if(sortDescendingBy_.size()>0) sort(selectedProbes.begin(), selectedProbes.end(), boost::bind(&Pair::second, _1) > boost::bind(&Pair::second, _2));
  // fill the first maxProbes_ into the tree
  for (size_t i = 0; i < (maxProbes_<0 ? selectedProbes.size() : std::min((size_t)maxProbes_, selectedProbes.size())); ++i){
    probeFiller_->fill(selectedProbes[i].first);
    result = true;
  }
  return result;
}

Member Data Documentation

The selector object.

Definition at line 41 of file ProbeTreeProducer.cc.

Referenced by filter().

Specifies whether this module should filter.

Definition at line 44 of file ProbeTreeProducer.cc.

Referenced by filter().

int32_t ProbeTreeProducer::maxProbes_ [private]

The number of first probes used to fill the tree.

Definition at line 53 of file ProbeTreeProducer.cc.

Referenced by filter().

The object that actually computes variables and fills the tree for the probe.

Definition at line 56 of file ProbeTreeProducer.cc.

Referenced by endJob(), and filter().

InputTag to the collection of all probes.

Definition at line 38 of file ProbeTreeProducer.cc.

Referenced by filter().

std::string ProbeTreeProducer::sortDescendingBy_ [private]

Name of the reco::Candidate function used for sorting.

Definition at line 47 of file ProbeTreeProducer.cc.

Referenced by filter().

The StringObjectFunction itself.

Definition at line 50 of file ProbeTreeProducer.cc.

Referenced by filter().