CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
RecoTauProducer Class Reference
Inheritance diagram for RecoTauProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

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 Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

void produce (edm::Event &evt, const edm::EventSetup &es)
 
 RecoTauProducer (const edm::ParameterSet &pset)
 
 ~RecoTauProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- 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 ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- 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

Definition at line 41 of file RecoTauProducer.cc.

Member Typedef Documentation

Definition at line 43 of file RecoTauProducer.cc.

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

Definition at line 45 of file RecoTauProducer.cc.

Definition at line 44 of file RecoTauProducer.cc.

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

Definition at line 46 of file RecoTauProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 66 of file RecoTauProducer.cc.

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

66  {
67  jetSrc_ = pset.getParameter<edm::InputTag>("jetSrc");
68  jetRegionSrc_ = pset.getParameter<edm::InputTag>("jetRegionSrc");
69  piZeroSrc_ = pset.getParameter<edm::InputTag>("piZeroSrc");
70 
71  typedef std::vector<edm::ParameterSet> VPSet;
72  // Get each of our tau builders
73  const VPSet& builders = pset.getParameter<VPSet>("builders");
74  for (VPSet::const_iterator builderPSet = builders.begin();
75  builderPSet != builders.end(); ++builderPSet) {
76  // Get plugin name
77  const std::string& pluginType =
78  builderPSet->getParameter<std::string>("plugin");
79  // Build the plugin
80  builders_.push_back(
82  pluginType, *builderPSet));
83 
84  }
85 
86  const VPSet& modfiers = pset.getParameter<VPSet>("modifiers");
87  for (VPSet::const_iterator modfierPSet = modfiers.begin();
88  modfierPSet != modfiers.end(); ++modfierPSet) {
89  // Get plugin name
90  const std::string& pluginType =
91  modfierPSet->getParameter<std::string>("plugin");
92  // Build the plugin
93  modifiers_.push_back(
95  pluginType, *modfierPSet));
96 
97  }
98 
99  // Check if we want to apply a final output selection
100  if (pset.exists("outputSelection")) {
101  std::string selection = pset.getParameter<std::string>("outputSelection");
102  if (selection != "") {
103  outputSelector_.reset(
104  new StringCutObjectSelector<reco::PFTau>(selection));
105  }
106  }
107  buildNullTaus_ = pset.getParameter<bool>("buildNullTaus");
108  produces<reco::PFTauCollection>();
109 }
T getParameter(std::string const &) const
edm::InputTag piZeroSrc_
BuilderList builders_
selection
main part
Definition: corrVsCorr.py:98
bool exists(std::string const &parameterName) const
checks if a parameter exists
ModifierList modifiers_
std::auto_ptr< StringCutObjectSelector< reco::PFTau > > outputSelector_
edm::InputTag jetSrc_
edm::InputTag jetRegionSrc_
SurfaceDeformation * create(int type, const std::vector< double > &params)
T get(const Candidate &c)
Definition: component.h:56
RecoTauProducer::~RecoTauProducer ( )
inline

Definition at line 49 of file RecoTauProducer.cc.

49 {}

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 111 of file RecoTauProducer.cc.

References builders_, buildNullTaus_, edm::hlt::Exception, edm::Event::getByLabel(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::isNull(), jetRegionSrc_, fwrapper::jets, jetSrc_, modifiers_, convertSQLitetoXML_cfg::output, outputSelector_, piZeroSrc_, edm::Event::put(), reco::PFTau::setjetRef(), python.multivaluedict::sort(), and metsig::tau.

111  {
112  // Get the jet input collection via a view of Candidates
114  evt.getByLabel(jetSrc_, jetView);
115 
116  // Convert to a vector of PFJetRefs
118  reco::tau::castView<reco::PFJetRefVector>(jetView);
119 
120  // Get the jet region producer
122  evt.getByLabel(jetRegionSrc_, jetRegionHandle);
123 
124  // Get the pizero input collection
126  evt.getByLabel(piZeroSrc_, piZeroAssoc);
127 
128  // Update all our builders and modifiers with the event info
129  for (BuilderList::iterator builder = builders_.begin();
130  builder != builders_.end(); ++builder) {
131  builder->setup(evt, es);
132  }
133  for (ModifierList::iterator modifier = modifiers_.begin();
134  modifier != modifiers_.end(); ++modifier) {
135  modifier->setup(evt, es);
136  }
137 
138  // Create output collection
139  std::auto_ptr<reco::PFTauCollection> output(new reco::PFTauCollection());
140 
141  // Loop over the jets and build the taus for each jet
142  BOOST_FOREACH(reco::PFJetRef jetRef, jets) {
143  // Get the jet with extra constituents from an area around the jet
144  reco::PFJetRef jetRegionRef = (*jetRegionHandle)[jetRef];
145  if (jetRegionRef.isNull()) {
146  throw cms::Exception("BadJetRegionRef") << "No jet region can be"
147  << " found for the current jet: " << jetRef.id();
148  }
149  // Remove all the jet constituents from the jet extras
150  std::vector<reco::PFCandidatePtr> jetCands = jetRef->getPFConstituents();
151  std::vector<reco::PFCandidatePtr> allRegionalCands =
152  jetRegionRef->getPFConstituents();
153  // Sort both by ref key
154  std::sort(jetCands.begin(), jetCands.end());
155  std::sort(allRegionalCands.begin(), allRegionalCands.end());
156  // Get the regional junk candidates not in the jet.
157  std::vector<reco::PFCandidatePtr> uniqueRegionalCands;
158 
159  // This can actually be less than zero, if the jet has really crazy soft
160  // stuff really far away from the jet axis.
161  if (allRegionalCands.size() > jetCands.size())
162  uniqueRegionalCands.reserve(allRegionalCands.size() - jetCands.size());
163 
164  // Subtract the jet cands from the regional cands
165  std::set_difference(allRegionalCands.begin(), allRegionalCands.end(),
166  jetCands.begin(), jetCands.end(),
167  std::back_inserter(uniqueRegionalCands));
168 
169  // Get the PiZeros associated with this jet
170  const std::vector<reco::RecoTauPiZero>& piZeros = (*piZeroAssoc)[jetRef];
171  // Loop over our builders and create the set of taus for this jet
172  unsigned int nTausBuilt = 0;
173  for (BuilderList::const_iterator builder = builders_.begin();
174  builder != builders_.end(); ++builder) {
175  // Get a ptr_vector of taus from the builder
177  (*builder)(jetRef, piZeros, uniqueRegionalCands));
178  // Make sure all taus have their jetref set correctly
179  std::for_each(taus.begin(), taus.end(),
180  boost::bind(&reco::PFTau::setjetRef, _1, jetRef));
181  // Check this size of the taus built.
182  // Grow the vector if necessary
183  output->reserve(output->size() + taus.size());
184  // Copy without selection
185  if (!outputSelector_.get()) {
186  output->insert(output->end(), taus.begin(), taus.end());
187  nTausBuilt += taus.size();
188  } else {
189  // Copy only those that pass the selection.
190  BOOST_FOREACH(const reco::PFTau& tau, taus) {
191  if ((*outputSelector_)(tau)) {
192  nTausBuilt++;
193  output->push_back(tau);
194  }
195  }
196  }
197  }
198  // If we didn't build *any* taus for this jet, build a null tau if desired.
199  // The null PFTau has no content, but it's four vector is set to that of the
200  // jet.
201  if (!nTausBuilt && buildNullTaus_) {
202  reco::PFTau nullTau(std::numeric_limits<int>::quiet_NaN(), jetRef->p4());
203  nullTau.setjetRef(jetRef);
204  output->push_back(nullTau);
205  }
206  }
207 
208  // Loop over the taus we have created and apply our modifiers to the taus
209  for (reco::PFTauCollection::iterator tau = output->begin();
210  tau != output->end(); ++tau) {
211  for (ModifierList::const_iterator modifier = modifiers_.begin();
212  modifier != modifiers_.end(); ++modifier) {
213  (*modifier)(*tau);
214  }
215  }
216  evt.put(output);
217 }
edm::InputTag piZeroSrc_
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
BuilderList builders_
boost::ptr_vector< reco::PFTau > output_type
ModifierList modifiers_
std::auto_ptr< StringCutObjectSelector< reco::PFTau > > outputSelector_
void setjetRef(const PFJetRef &)
Definition: PFTau.cc:51
bool isNull() const
Checks for null.
Definition: Ref.h:247
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
vector< PseudoJet > jets
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
edm::InputTag jetSrc_
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
edm::InputTag jetRegionSrc_

Member Data Documentation

BuilderList RecoTauProducer::builders_
private

Definition at line 56 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

bool RecoTauProducer::buildNullTaus_
private

Definition at line 63 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

edm::InputTag RecoTauProducer::jetRegionSrc_
private

Definition at line 54 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

edm::InputTag RecoTauProducer::jetSrc_
private

Definition at line 53 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

ModifierList RecoTauProducer::modifiers_
private

Definition at line 57 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

std::auto_ptr<StringCutObjectSelector<reco::PFTau> > RecoTauProducer::outputSelector_
private

Definition at line 59 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

edm::InputTag RecoTauProducer::piZeroSrc_
private

Definition at line 55 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().