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::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 &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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_, and corrVsCorr::selection.

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  const std::string& pluginName =
80  builderPSet->getParameter<std::string>("name");
81  // Build the plugin
82  try {
83  builders_.push_back(
85  pluginType, *builderPSet));
86  } catch (...) {
87  edm::LogError("RecoTauBuilderException")
88  << "Exception when building a RecoTauBuilder plugin of type: "
89  << pluginType << " name: " << pluginName << std::endl;
90  throw; // rethrow
91  }
92  }
93 
94  const VPSet& modfiers = pset.getParameter<VPSet>("modifiers");
95  for (VPSet::const_iterator modfierPSet = modfiers.begin();
96  modfierPSet != modfiers.end(); ++modfierPSet) {
97  // Get plugin name
98  const std::string& pluginType =
99  modfierPSet->getParameter<std::string>("plugin");
100  const std::string& pluginName =
101  modfierPSet->getParameter<std::string>("name");
102  // Build the plugin
103  try {
104  modifiers_.push_back(
106  pluginType, *modfierPSet));
107  } catch (...) {
108  edm::LogError("RecoTauModifierException")
109  << "Exception when building a RecoTauModifier plugin of type: "
110  << pluginType << " name: " << pluginName << std::endl;
111  throw; // rethrow
112  }
113  }
114 
115  // Check if we want to apply a final output selection
116  if (pset.exists("outputSelection")) {
117  std::string selection = pset.getParameter<std::string>("outputSelection");
118  if (selection != "") {
119  outputSelector_.reset(
120  new StringCutObjectSelector<reco::PFTau>(selection));
121  }
122  }
123  buildNullTaus_ = pset.getParameter<bool>("buildNullTaus");
124  produces<reco::PFTauCollection>();
125 }
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 127 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.

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