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

Public Member Functions

void produce (edm::Event &evt, const edm::EventSetup &es) override
 
 RecoTauProducer (const edm::ParameterSet &pset)
 
 ~RecoTauProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
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 ()
 
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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

BuilderList builders_
 
bool buildNullTaus_
 
edm::EDGetTokenT
< reco::PFJetChargedHadronAssociation
chargedHadron_token
 
edm::InputTag chargedHadronSrc_
 
edm::EDGetTokenT
< reco::CandidateView
jet_token
 
edm::EDGetTokenT
< edm::Association
< reco::PFJetCollection > > 
jetRegion_token
 
edm::InputTag jetRegionSrc_
 
edm::InputTag jetSrc_
 
ModifierList modifiers_
 
std::auto_ptr
< StringCutObjectSelector
< reco::PFTau > > 
outputSelector_
 
edm::EDGetTokenT
< reco::JetPiZeroAssociation
piZero_token
 
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::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 44 of file RecoTauProducer.cc.

Member Typedef Documentation

Definition at line 47 of file RecoTauProducer.cc.

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

Definition at line 49 of file RecoTauProducer.cc.

Definition at line 48 of file RecoTauProducer.cc.

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

Definition at line 50 of file RecoTauProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 77 of file RecoTauProducer.cc.

References builders_, buildNullTaus_, chargedHadron_token, chargedHadronSrc_, edm::EDConsumerBase::consumesCollector(), SurfaceDeformationFactory::create(), edm::ParameterSet::exists(), reco::get(), edm::ParameterSet::getParameter(), jet_token, jetRegion_token, jetRegionSrc_, jetSrc_, modifiers_, outputSelector_, piZero_token, piZeroSrc_, fwrapper::plugin, corrVsCorr::selection, and AlCaHLTBitMon_QueryRunRegistry::string.

78 {
79  jetSrc_ = pset.getParameter<edm::InputTag>("jetSrc");
80  jetRegionSrc_ = pset.getParameter<edm::InputTag>("jetRegionSrc");
81  chargedHadronSrc_ = pset.getParameter<edm::InputTag>("chargedHadronSrc");
82  piZeroSrc_ = pset.getParameter<edm::InputTag>("piZeroSrc");
83 
84  //consumes definition
85  jet_token=consumes<reco::CandidateView>(jetSrc_);
86  jetRegion_token = consumes<edm::Association<reco::PFJetCollection> >(jetRegionSrc_);
87  chargedHadron_token = consumes<reco::PFJetChargedHadronAssociation>(chargedHadronSrc_);
88  piZero_token = consumes<reco::JetPiZeroAssociation>(piZeroSrc_);
89 
90  typedef std::vector<edm::ParameterSet> VPSet;
91  // Get each of our tau builders
92  const VPSet& builders = pset.getParameter<VPSet>("builders");
93  for ( VPSet::const_iterator builderPSet = builders.begin();
94  builderPSet != builders.end(); ++builderPSet ) {
95  // Get plugin name
96  const std::string& pluginType = builderPSet->getParameter<std::string>("plugin");
97  // Build the plugin
98  builders_.push_back(RecoTauBuilderPluginFactory::get()->create(pluginType, *builderPSet, consumesCollector()));
99  }
100 
101  const VPSet& modfiers = pset.getParameter<VPSet>("modifiers");
102  for ( VPSet::const_iterator modfierPSet = modfiers.begin();
103  modfierPSet != modfiers.end(); ++modfierPSet) {
104  // Get plugin name
105  const std::string& pluginType = modfierPSet->getParameter<std::string>("plugin");
106  // Build the plugin
108  plugin = RecoTauModifierPluginFactory::get()->create(pluginType, *modfierPSet, consumesCollector());
109  plugin->beginJob(this);
110  modifiers_.push_back(plugin);
111  }
112 
113  // Check if we want to apply a final output selection
114  if ( pset.exists("outputSelection") ) {
115  std::string selection = pset.getParameter<std::string>("outputSelection");
116  if ( selection != "" ) {
118  }
119  }
120  buildNullTaus_ = pset.getParameter<bool>("buildNullTaus");
121 
122  produces<reco::PFTauCollection>();
123 }
T getParameter(std::string const &) const
edm::InputTag piZeroSrc_
edm::EDGetTokenT< reco::CandidateView > jet_token
auto_ptr< JetDefinition::Plugin > plugin
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_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::InputTag chargedHadronSrc_
edm::InputTag jetSrc_
edm::EDGetTokenT< reco::JetPiZeroAssociation > piZero_token
edm::EDGetTokenT< reco::PFJetChargedHadronAssociation > chargedHadron_token
edm::EDGetTokenT< edm::Association< reco::PFJetCollection > > jetRegion_token
edm::InputTag jetRegionSrc_
SurfaceDeformation * create(int type, const std::vector< double > &params)
T get(const Candidate &c)
Definition: component.h:55
RecoTauProducer::~RecoTauProducer ( )
inline

Definition at line 53 of file RecoTauProducer.cc.

53 {}

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 125 of file RecoTauProducer.cc.

References builders_, buildNullTaus_, chargedHadron_token, edm::hlt::Exception, edm::Event::getByToken(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::isNull(), jet_token, jetRegion_token, fwrapper::jets, modifiers_, convertSQLitetoXML_cfg::output, outputSelector_, piZero_token, edm::Event::put(), reco::PFTau::setjetRef(), edm::RefVector< C, T, F >::size(), python.multivaluedict::sort(), and metsig::tau.

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

Member Data Documentation

BuilderList RecoTauProducer::builders_
private

Definition at line 67 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

bool RecoTauProducer::buildNullTaus_
private

Definition at line 74 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

edm::EDGetTokenT<reco::PFJetChargedHadronAssociation> RecoTauProducer::chargedHadron_token
private

Definition at line 64 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

edm::InputTag RecoTauProducer::chargedHadronSrc_
private

Definition at line 59 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().

edm::EDGetTokenT<reco::CandidateView> RecoTauProducer::jet_token
private

Definition at line 62 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

edm::EDGetTokenT<edm::Association<reco::PFJetCollection> > RecoTauProducer::jetRegion_token
private

Definition at line 63 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

edm::InputTag RecoTauProducer::jetRegionSrc_
private

Definition at line 58 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().

edm::InputTag RecoTauProducer::jetSrc_
private

Definition at line 57 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().

ModifierList RecoTauProducer::modifiers_
private

Definition at line 68 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

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

Definition at line 70 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

edm::EDGetTokenT<reco::JetPiZeroAssociation> RecoTauProducer::piZero_token
private

Definition at line 65 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

edm::InputTag RecoTauProducer::piZeroSrc_
private

Definition at line 60 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().