CMS 3D CMS Logo

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

Public Types

typedef reco::tau::RecoTauBuilderPlugin Builder
 
typedef std::vector< std::unique_ptr< Builder > > BuilderList
 
typedef reco::tau::RecoTauModifierPlugin Modifier
 
typedef std::vector< std::unique_ptr< Modifier > > ModifierList
 
- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

BuilderList builders_
 
bool buildNullTaus_
 
edm::EDGetTokenT< reco::PFJetChargedHadronAssociationchargedHadron_token
 
edm::InputTag chargedHadronSrc_
 
edm::EDGetTokenT< reco::JetViewjet_token
 
edm::EDGetTokenT< edm::AssociationMap< edm::OneToOne< reco::JetView, reco::JetView > > > jetRegion_token
 
edm::InputTag jetRegionSrc_
 
edm::InputTag jetSrc_
 
double maxJetAbsEta_
 
double minJetPt_
 
ModifierList modifiers_
 
std::unique_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

◆ Builder

Definition at line 47 of file RecoTauProducer.cc.

◆ BuilderList

typedef std::vector<std::unique_ptr<Builder> > RecoTauProducer::BuilderList

Definition at line 49 of file RecoTauProducer.cc.

◆ Modifier

Definition at line 48 of file RecoTauProducer.cc.

◆ ModifierList

typedef std::vector<std::unique_ptr<Modifier> > RecoTauProducer::ModifierList

Definition at line 50 of file RecoTauProducer.cc.

Constructor & Destructor Documentation

◆ RecoTauProducer()

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

Definition at line 82 of file RecoTauProducer.cc.

References HLT_2023v12_cff::builders, builders_, buildNullTaus_, chargedHadron_token, chargedHadronSrc_, beamerCreator::create(), get, jet_token, jetRegion_token, jetRegionSrc_, jetSrc_, maxJetAbsEta_, minJetPt_, modifiers_, outputSelector_, piZero_token, piZeroSrc_, muonDTDigis_cfi::pset, 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.getParameter<double>("minJetPt");
89  maxJetAbsEta_ = pset.getParameter<double>("maxJetAbsEta");
90  //consumes definition
91  jet_token = consumes<reco::JetView>(jetSrc_);
92  jetRegion_token = consumes<edm::AssociationMap<edm::OneToOne<reco::JetView, reco::JetView>>>(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(); builderPSet != builders.end(); ++builderPSet) {
100  // Get plugin name
101  const std::string& pluginType = builderPSet->getParameter<std::string>("plugin");
102  // Build the plugin
103  builders_.emplace_back(RecoTauBuilderPluginFactory::get()->create(pluginType, *builderPSet, consumesCollector()));
104  }
105 
106  const VPSet& modfiers = pset.getParameter<VPSet>("modifiers");
107  for (VPSet::const_iterator modfierPSet = modfiers.begin(); modfierPSet != modfiers.end(); ++modfierPSet) {
108  // Get plugin name
109  const std::string& pluginType = modfierPSet->getParameter<std::string>("plugin");
110  // Build the plugin
111  modifiers_.emplace_back(RecoTauModifierPluginFactory::get()->create(pluginType, *modfierPSet, consumesCollector()));
112  }
113 
114  // Check if we want to apply a final output selection
115  std::string selection = pset.getParameter<std::string>("outputSelection");
116  if (!selection.empty()) {
117  outputSelector_ = std::make_unique<StringCutObjectSelector<reco::PFTau>>(selection);
118  }
119  buildNullTaus_ = pset.getParameter<bool>("buildNullTaus");
120 
121  produces<reco::PFTauCollection>();
122 }
edm::InputTag piZeroSrc_
def create(alignables, pedeDump, additionalData, outputFile, config)
BuilderList builders_
edm::EDGetTokenT< reco::JetView > jet_token
selection
main part
Definition: corrVsCorr.py:100
ModifierList modifiers_
edm::EDGetTokenT< edm::AssociationMap< edm::OneToOne< reco::JetView, reco::JetView > > > jetRegion_token
edm::InputTag chargedHadronSrc_
edm::InputTag jetSrc_
edm::EDGetTokenT< reco::JetPiZeroAssociation > piZero_token
edm::EDGetTokenT< reco::PFJetChargedHadronAssociation > chargedHadron_token
#define get
edm::InputTag jetRegionSrc_
std::unique_ptr< StringCutObjectSelector< reco::PFTau > > outputSelector_

◆ ~RecoTauProducer()

RecoTauProducer::~RecoTauProducer ( )
inlineoverride

Definition at line 53 of file RecoTauProducer.cc.

53 {}

Member Function Documentation

◆ fillDescriptions()

void RecoTauProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 241 of file RecoTauProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), edm::ParameterSet::addParameter(), edm::ParameterSetDescription::addVPSetOptional(), submitPVResolutionJobs::desc, reco::tau::RecoTauQualityCuts::fillDescriptions(), ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

241  {
242  // combinatoricRecoTaus
244  desc.add<edm::InputTag>("piZeroSrc", edm::InputTag("ak4PFJetsRecoTauPiZeros"));
245 
246  edm::ParameterSetDescription desc_qualityCuts;
248 
249  {
250  edm::ParameterSetDescription vpsd_modifiers;
251  vpsd_modifiers.add<std::string>("name");
252  vpsd_modifiers.add<std::string>("plugin");
253  vpsd_modifiers.add<int>("verbosity", 0);
254 
255  vpsd_modifiers.add<edm::ParameterSetDescription>("qualityCuts", desc_qualityCuts);
256  vpsd_modifiers.addOptional<edm::InputTag>("ElectronPreIDProducer");
257  vpsd_modifiers.addOptional<std::string>("DataType");
258  vpsd_modifiers.addOptional<double>("maximumForElectrionPreIDOutput");
259  vpsd_modifiers.addOptional<double>("ElecPreIDLeadTkMatch_maxDR");
260  vpsd_modifiers.addOptional<double>("EcalStripSumE_minClusEnergy");
261  vpsd_modifiers.addOptional<double>("EcalStripSumE_deltaPhiOverQ_minValue");
262  vpsd_modifiers.addOptional<double>("EcalStripSumE_deltaPhiOverQ_maxValue");
263  vpsd_modifiers.addOptional<double>("EcalStripSumE_deltaEta");
264  vpsd_modifiers.addOptional<double>("dRaddNeutralHadron");
265  vpsd_modifiers.addOptional<double>("minGammaEt");
266  vpsd_modifiers.addOptional<double>("dRaddPhoton");
267  vpsd_modifiers.addOptional<double>("minNeutralHadronEt");
268  vpsd_modifiers.addOptional<edm::InputTag>("pfTauTagInfoSrc");
269  vpsd_modifiers.addOptional<edm::InputTag>("trackSrc");
270 
271  desc.addVPSet("modifiers", vpsd_modifiers);
272  }
273 
274  desc.add<edm::InputTag>("jetRegionSrc", edm::InputTag("recoTauAK4PFJets08Region"));
275  desc.add<double>("maxJetAbsEta", 2.5);
276  desc.add<std::string>("outputSelection", "leadPFChargedHadrCand().isNonnull()");
277  desc.add<edm::InputTag>("chargedHadronSrc", edm::InputTag("ak4PFJetsRecoTauChargedHadrons"));
278  desc.add<double>("minJetPt", 14.0);
279  desc.add<edm::InputTag>("jetSrc", edm::InputTag("ak4PFJets"));
280 
281  {
282  edm::ParameterSetDescription desc_builders;
283  desc_builders.add<std::string>("name");
284  desc_builders.add<std::string>("plugin");
285  desc_builders.add<int>("verbosity", 0);
286 
287  desc_builders.add<edm::ParameterSetDescription>("qualityCuts", desc_qualityCuts);
288  {
289  edm::ParameterSetDescription desc_decayModes;
290  desc_decayModes.add<unsigned int>("nPiZeros", 0);
291  desc_decayModes.add<unsigned int>("maxPiZeros", 0);
292  desc_decayModes.add<unsigned int>("nCharged", 1);
293  desc_decayModes.add<unsigned int>("maxTracks", 6);
294  desc_builders.addVPSetOptional("decayModes", desc_decayModes);
295  }
296  desc_builders.add<double>("minAbsPhotonSumPt_insideSignalCone", 2.5);
297  desc_builders.add<double>("minRelPhotonSumPt_insideSignalCone", 0.1);
298  desc_builders.add<edm::InputTag>("pfCandSrc", edm::InputTag("particleFlow"));
299 
300  desc_builders.addOptional<std::string>("signalConeSize");
301  desc_builders.addOptional<double>("isolationConeSize");
302  desc_builders.addOptional<double>("minAbsPhotonSumPt_outsideSignalCone");
303  desc_builders.addOptional<double>("minRelPhotonSumPt_outsideSignalCone");
304  desc_builders.addOptional<std::string>("isoConeChargedHadrons");
305  desc_builders.addOptional<std::string>("isoConeNeutralHadrons");
306  desc_builders.addOptional<std::string>("isoConePiZeros");
307  desc_builders.addOptional<double>("leadObjectPt");
308  desc_builders.addOptional<std::string>("matchingCone");
309  desc_builders.addOptional<int>("maxSignalConeChargedHadrons");
310  desc_builders.addOptional<std::string>("signalConeChargedHadrons");
311  desc_builders.addOptional<std::string>("signalConeNeutralHadrons");
312  desc_builders.addOptional<std::string>("signalConePiZeros");
313  desc_builders.addOptional<bool>("usePFLeptons");
314 
315  std::vector<edm::ParameterSet> vpset_default;
316  {
317  edm::ParameterSet pset_default_builders;
318  pset_default_builders.addParameter<std::string>("name", "");
319  pset_default_builders.addParameter<std::string>("plugin", "");
320  pset_default_builders.addParameter<int>("verbosity", 0);
321  pset_default_builders.addParameter<double>("minAbsPhotonSumPt_insideSignalCone", 2.5);
322  pset_default_builders.addParameter<double>("minRelPhotonSumPt_insideSignalCone", 0.1);
323  pset_default_builders.addParameter<edm::InputTag>("pfCandSrc", edm::InputTag("particleFlow"));
324  vpset_default.push_back(pset_default_builders);
325  }
326  desc.addVPSet("builders", desc_builders, vpset_default);
327  }
328 
329  desc.add<bool>("buildNullTaus", false);
330  desc.add<int>("verbosity", 0);
331  descriptions.add("combinatoricRecoTaus", desc);
332 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
static void fillDescriptions(edm::ParameterSetDescription &descriptions)
Declare all parameters read from python config file.
ParameterDescriptionBase * addVPSetOptional(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:135
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

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

Definition at line 124 of file RecoTauProducer.cc.

References funct::abs(), builders_, buildNullTaus_, chargedHadron_token, MillePedeFileConverter_cfg::e, Exception, edm::Event::getByToken(), edm::RefToBase< T >::isNull(), jet_token, jetRegion_token, maxJetAbsEta_, minJetPt_, modifiers_, eostools::move(), convertSQLitetoXML_cfg::output, outputSelector_, piZero_token, edm::Event::put(), edm::View< T >::refAt(), DBoxMetadataHelper::set_difference(), reco::PFTau::setjetRef(), edm::View< T >::size(), jetUpdater_cfi::sort, metsig::tau, and Tau3MuMonitor_cff::taus.

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

Member Data Documentation

◆ builders_

BuilderList RecoTauProducer::builders_
private

Definition at line 72 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

◆ buildNullTaus_

bool RecoTauProducer::buildNullTaus_
private

Definition at line 79 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

◆ chargedHadron_token

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

Definition at line 69 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

◆ chargedHadronSrc_

edm::InputTag RecoTauProducer::chargedHadronSrc_
private

Definition at line 61 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().

◆ jet_token

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

Definition at line 67 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

◆ jetRegion_token

edm::EDGetTokenT<edm::AssociationMap<edm::OneToOne<reco::JetView, reco::JetView> > > RecoTauProducer::jetRegion_token
private

Definition at line 68 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

◆ jetRegionSrc_

edm::InputTag RecoTauProducer::jetRegionSrc_
private

Definition at line 60 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().

◆ jetSrc_

edm::InputTag RecoTauProducer::jetSrc_
private

Definition at line 59 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().

◆ maxJetAbsEta_

double RecoTauProducer::maxJetAbsEta_
private

Definition at line 65 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

◆ minJetPt_

double RecoTauProducer::minJetPt_
private

Definition at line 64 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

◆ modifiers_

ModifierList RecoTauProducer::modifiers_
private

Definition at line 73 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

◆ outputSelector_

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

Definition at line 75 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

◆ piZero_token

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

Definition at line 70 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

◆ piZeroSrc_

edm::InputTag RecoTauProducer::piZeroSrc_
private

Definition at line 62 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().