CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
ProbeTreeProducer Class Reference

#include <ProbeTreeProducer.cc>

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

Public Member Functions

 ProbeTreeProducer (const edm::ParameterSet &)
 
 ~ProbeTreeProducer ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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

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.

59  :
60  probesToken_(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("src"))),
61  cut_(iConfig.existsAs<std::string>("cut") ? iConfig.getParameter<std::string>("cut") : ""),
62  filter_(iConfig.existsAs<bool>("filter") ? iConfig.getParameter<bool>("filter") : false),
63  sortDescendingBy_(iConfig.existsAs<std::string>("sortDescendingBy") ? iConfig.getParameter<std::string>("sortDescendingBy") : ""),
64  sortFunction_(sortDescendingBy_.size()>0 ? sortDescendingBy_ : "pt"), //need to pass a valid default
65  maxProbes_(iConfig.existsAs<int32_t>("maxProbes") ? iConfig.getParameter<int32_t>("maxProbes") : -1),
66  probeFiller_(new tnp::BaseTreeFiller("probe_tree", iConfig, consumesCollector()))
67 {
68 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
StringObjectFunction< reco::Candidate, true > sortFunction_
The StringObjectFunction itself.
int32_t maxProbes_
The number of first probes used to fill the tree.
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
StringCutObjectSelector< reco::Candidate, true > cut_
The selector object.
std::auto_ptr< tnp::BaseTreeFiller > probeFiller_
The object that actually computes variables and fills the tree for the probe.
std::string sortDescendingBy_
Name of the reco::Candidate function used for sorting.
bool filter_
Specifies whether this module should filter.
edm::EDGetTokenT< reco::CandidateView > probesToken_
InputTag to the collection of all probes.
ProbeTreeProducer::~ProbeTreeProducer ( )

Definition at line 70 of file ProbeTreeProducer.cc.

70  {
71 }

Member Function Documentation

void ProbeTreeProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 98 of file ProbeTreeProducer.cc.

References edm::getProcessParameterSet(), and probeFiller_.

98  {
99  // ask to write the current PSet info into the TTree header
100  probeFiller_->writeProvenance(edm::getProcessParameterSet());
101 }
ParameterSet const & getProcessParameterSet()
Definition: Registry.cc:82
std::auto_ptr< tnp::BaseTreeFiller > probeFiller_
The object that actually computes variables and fills the tree for the probe.
bool ProbeTreeProducer::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDFilter.

Definition at line 73 of file ProbeTreeProducer.cc.

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

73  {
74  bool result = !filter_;
76  iEvent.getByToken(probesToken_, probes);
77  if(!probes.isValid()) return result;
78  probeFiller_->init(iEvent);
79  // select probes and calculate the sorting value
80  typedef std::pair<reco::CandidateBaseRef, double> Pair;
81  std::vector<Pair> selectedProbes;
82  for (size_t i = 0; i < probes->size(); ++i){
83  const reco::CandidateBaseRef &probe = probes->refAt(i);
84  if(cut_(*probe)){
85  selectedProbes.push_back(Pair(probe, sortFunction_(*probe)));
86  }
87  }
88  // sort only if a function was provided
89  if(sortDescendingBy_.size()>0) sort(selectedProbes.begin(), selectedProbes.end(), boost::bind(&Pair::second, _1) > boost::bind(&Pair::second, _2));
90  // fill the first maxProbes_ into the tree
91  for (size_t i = 0; i < (maxProbes_<0 ? selectedProbes.size() : std::min((size_t)maxProbes_, selectedProbes.size())); ++i){
92  probeFiller_->fill(selectedProbes[i].first);
93  result = true;
94  }
95  return result;
96 }
int i
Definition: DBlmapReader.cc:9
StringObjectFunction< reco::Candidate, true > sortFunction_
The StringObjectFunction itself.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
int32_t maxProbes_
The number of first probes used to fill the tree.
U second(std::pair< T, U > const &p)
tuple result
Definition: query.py:137
bool first
Definition: L1TdeRCT.cc:75
bool isValid() const
Definition: HandleBase.h:76
StringCutObjectSelector< reco::Candidate, true > cut_
The selector object.
std::auto_ptr< tnp::BaseTreeFiller > probeFiller_
The object that actually computes variables and fills the tree for the probe.
std::string sortDescendingBy_
Name of the reco::Candidate function used for sorting.
bool filter_
Specifies whether this module should filter.
edm::EDGetTokenT< reco::CandidateView > probesToken_
InputTag to the collection of all probes.

Member Data Documentation

StringCutObjectSelector<reco::Candidate, true> ProbeTreeProducer::cut_
private

The selector object.

Definition at line 41 of file ProbeTreeProducer.cc.

Referenced by filter().

bool ProbeTreeProducer::filter_
private

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().

std::auto_ptr<tnp::BaseTreeFiller> ProbeTreeProducer::probeFiller_
private

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().

edm::EDGetTokenT<reco::CandidateView> ProbeTreeProducer::probesToken_
private

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().

StringObjectFunction<reco::Candidate, true> ProbeTreeProducer::sortFunction_
private

The StringObjectFunction itself.

Definition at line 50 of file ProbeTreeProducer.cc.

Referenced by filter().