CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
RecoTauProducer Class Reference
Inheritance diagram for RecoTauProducer:
edm::stream::EDProducer<>

Public Types

typedef reco::tau::RecoTauBuilderPlugin Builder
 
typedef boost::ptr_vector< BuilderBuilderList
 
typedef reco::tau::RecoTauModifierPlugin Modifier
 
typedef boost::ptr_vector< ModifierModifierList
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Public Member Functions

void produce (edm::Event &evt, const edm::EventSetup &es) override
 
 RecoTauProducer (const edm::ParameterSet &pset)
 
 ~RecoTauProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Attributes

BuilderList builders_
 
bool buildNullTaus_
 
edm::EDGetTokenT< reco::PFJetChargedHadronAssociationchargedHadron_token
 
edm::InputTag chargedHadronSrc_
 
edm::EDGetTokenT< reco::CandidateViewjet_token
 
edm::EDGetTokenT< edm::Association< reco::PFJetCollection > > jetRegion_token
 
edm::InputTag jetRegionSrc_
 
edm::InputTag jetSrc_
 
double maxJetAbsEta_
 
double minJetPt_
 
ModifierList modifiers_
 
std::auto_ptr< StringCutObjectSelector< reco::PFTau > > outputSelector_
 
edm::EDGetTokenT< reco::JetPiZeroAssociationpiZero_token
 
edm::InputTag piZeroSrc_
 

Detailed Description

Definition at line 45 of file RecoTauProducer.cc.

Member Typedef Documentation

Definition at line 48 of file RecoTauProducer.cc.

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

Definition at line 50 of file RecoTauProducer.cc.

Definition at line 49 of file RecoTauProducer.cc.

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

Definition at line 51 of file RecoTauProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 81 of file RecoTauProducer.cc.

References PFRecoTauChargedHadronProducer_cfi::builders, builders_, buildNullTaus_, chargedHadron_token, chargedHadronSrc_, beamerCreator::create(), edm::ParameterSet::exists(), reco::get(), edm::ParameterSet::getParameter(), jet_token, jetRegion_token, jetRegionSrc_, jetSrc_, maxJetAbsEta_, minJetPt_, modifiers_, outputSelector_, piZero_token, piZeroSrc_, fwrapper::plugin, corrVsCorr::selection, AlCaHLTBitMon_QueryRunRegistry::string, and HistogramManager_cfi::VPSet().

82 {
83  jetSrc_ = pset.getParameter<edm::InputTag>("jetSrc");
84  jetRegionSrc_ = pset.getParameter<edm::InputTag>("jetRegionSrc");
85  chargedHadronSrc_ = pset.getParameter<edm::InputTag>("chargedHadronSrc");
86  piZeroSrc_ = pset.getParameter<edm::InputTag>("piZeroSrc");
87 
88  minJetPt_ = ( pset.exists("minJetPt") ) ? pset.getParameter<double>("minJetPt") : -1.0;
89  maxJetAbsEta_ = ( pset.exists("maxJetAbsEta") ) ? pset.getParameter<double>("maxJetAbsEta") : 99.0;
90  //consumes definition
91  jet_token=consumes<reco::CandidateView>(jetSrc_);
92  jetRegion_token = consumes<edm::Association<reco::PFJetCollection> >(jetRegionSrc_);
93  chargedHadron_token = consumes<reco::PFJetChargedHadronAssociation>(chargedHadronSrc_);
94  piZero_token = consumes<reco::JetPiZeroAssociation>(piZeroSrc_);
95 
96  typedef std::vector<edm::ParameterSet> VPSet;
97  // Get each of our tau builders
98  const VPSet& builders = pset.getParameter<VPSet>("builders");
99  for ( VPSet::const_iterator builderPSet = builders.begin();
100  builderPSet != builders.end(); ++builderPSet ) {
101  // Get plugin name
102  const std::string& pluginType = builderPSet->getParameter<std::string>("plugin");
103  // Build the plugin
104  builders_.push_back(RecoTauBuilderPluginFactory::get()->create(pluginType, *builderPSet, consumesCollector()));
105  }
106 
107  const VPSet& modfiers = pset.getParameter<VPSet>("modifiers");
108  for ( VPSet::const_iterator modfierPSet = modfiers.begin();
109  modfierPSet != modfiers.end(); ++modfierPSet) {
110  // Get plugin name
111  const std::string& pluginType = modfierPSet->getParameter<std::string>("plugin");
112  // Build the plugin
114  plugin = RecoTauModifierPluginFactory::get()->create(pluginType, *modfierPSet, consumesCollector());
115  modifiers_.push_back(plugin);
116  }
117 
118  // Check if we want to apply a final output selection
119  if ( pset.exists("outputSelection") ) {
120  std::string selection = pset.getParameter<std::string>("outputSelection");
121  if ( selection != "" ) {
123  }
124  }
125  buildNullTaus_ = pset.getParameter<bool>("buildNullTaus");
126 
127  produces<reco::PFTauCollection>();
128 }
T getParameter(std::string const &) const
edm::InputTag piZeroSrc_
edm::EDGetTokenT< reco::CandidateView > jet_token
auto_ptr< JetDefinition::Plugin > plugin
def create(alignables, pedeDump, additionalData, outputFile, config)
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 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_
T get(const Candidate &c)
Definition: component.h:55
RecoTauProducer::~RecoTauProducer ( )
inlineoverride

Definition at line 54 of file RecoTauProducer.cc.

References produce().

54 {}

Member Function Documentation

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

Definition at line 130 of file RecoTauProducer.cc.

References funct::abs(), builders_, buildNullTaus_, chargedHadron_token, DEFINE_FWK_MODULE, MillePedeFileConverter_cfg::e, Exception, edm::Event::getByToken(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::isNull(), jet_token, jetRegion_token, fwrapper::jets, maxJetAbsEta_, minJetPt_, modifiers_, eostools::move(), convertSQLitetoXML_cfg::output, outputSelector_, piZero_token, edm::Event::put(), reco::PFTau::setjetRef(), edm::RefVector< C, T, F >::size(), metsig::tau, and nano_cff::taus.

Referenced by ~RecoTauProducer().

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

Member Data Documentation

BuilderList RecoTauProducer::builders_
private

Definition at line 71 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

bool RecoTauProducer::buildNullTaus_
private

Definition at line 78 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

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

Definition at line 68 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

edm::InputTag RecoTauProducer::chargedHadronSrc_
private

Definition at line 60 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().

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

Definition at line 66 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

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

Definition at line 67 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

edm::InputTag RecoTauProducer::jetRegionSrc_
private

Definition at line 59 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().

edm::InputTag RecoTauProducer::jetSrc_
private

Definition at line 58 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().

double RecoTauProducer::maxJetAbsEta_
private

Definition at line 64 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

double RecoTauProducer::minJetPt_
private

Definition at line 63 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

ModifierList RecoTauProducer::modifiers_
private

Definition at line 72 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

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

Definition at line 74 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

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

Definition at line 69 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

edm::InputTag RecoTauProducer::piZeroSrc_
private

Definition at line 61 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().