CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::PFJetChargedHadronAssociation
chargedHadron_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::JetPiZeroAssociation
piZero_token
 
edm::InputTag piZeroSrc_
 

Detailed Description

Definition at line 45 of file RecoTauProducer.cc.

Member Typedef Documentation

Definition at line 47 of file RecoTauProducer.cc.

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

Definition at line 49 of file RecoTauProducer.cc.

Definition at line 48 of file RecoTauProducer.cc.

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

Definition at line 50 of file RecoTauProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 82 of file RecoTauProducer.cc.

References HLT_FULL_cff::builders, builders_, buildNullTaus_, chargedHadron_token, chargedHadronSrc_, beamerCreator::create(), get, edm::ParameterSet::getParameter(), jet_token, jetRegion_token, jetRegionSrc_, jetSrc_, maxJetAbsEta_, minJetPt_, modifiers_, outputSelector_, piZero_token, piZeroSrc_, 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_
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
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< reco::PFJetChargedHadronAssociation > chargedHadron_token
#define get
edm::InputTag jetRegionSrc_
std::unique_ptr< StringCutObjectSelector< reco::PFTau > > outputSelector_
RecoTauProducer::~RecoTauProducer ( )
inlineoverride

Definition at line 53 of file RecoTauProducer.cc.

53 {}

Member Function Documentation

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::addVPSet(), edm::ParameterSetDescription::addVPSetOptional(), submitPVResolutionJobs::desc, reco::tau::RecoTauQualityCuts::fillDescriptions(), HLT_FULL_cff::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 
270  desc.addVPSet("modifiers", vpsd_modifiers);
271  }
272 
273  desc.add<edm::InputTag>("jetRegionSrc", edm::InputTag("recoTauAK4PFJets08Region"));
274  desc.add<double>("maxJetAbsEta", 2.5);
275  desc.add<std::string>("outputSelection", "leadPFChargedHadrCand().isNonnull()");
276  desc.add<edm::InputTag>("chargedHadronSrc", edm::InputTag("ak4PFJetsRecoTauChargedHadrons"));
277  desc.add<double>("minJetPt", 14.0);
278  desc.add<edm::InputTag>("jetSrc", edm::InputTag("ak4PFJets"));
279 
280  {
281  edm::ParameterSetDescription desc_builders;
282  desc_builders.add<std::string>("name");
283  desc_builders.add<std::string>("plugin");
284  desc_builders.add<int>("verbosity", 0);
285 
286  desc_builders.add<edm::ParameterSetDescription>("qualityCuts", desc_qualityCuts);
287  {
288  edm::ParameterSetDescription desc_decayModes;
289  desc_decayModes.add<unsigned int>("nPiZeros", 0);
290  desc_decayModes.add<unsigned int>("maxPiZeros", 0);
291  desc_decayModes.add<unsigned int>("nCharged", 1);
292  desc_decayModes.add<unsigned int>("maxTracks", 6);
293  desc_builders.addVPSetOptional("decayModes", desc_decayModes);
294  }
295  desc_builders.add<double>("minAbsPhotonSumPt_insideSignalCone", 2.5);
296  desc_builders.add<double>("minRelPhotonSumPt_insideSignalCone", 0.1);
297  desc_builders.add<edm::InputTag>("pfCandSrc", edm::InputTag("particleFlow"));
298 
299  desc_builders.addOptional<std::string>("signalConeSize");
300  desc_builders.addOptional<double>("isolationConeSize");
301  desc_builders.addOptional<double>("minAbsPhotonSumPt_outsideSignalCone");
302  desc_builders.addOptional<double>("minRelPhotonSumPt_outsideSignalCone");
303  desc_builders.addOptional<std::string>("isoConeChargedHadrons");
304  desc_builders.addOptional<std::string>("isoConeNeutralHadrons");
305  desc_builders.addOptional<std::string>("isoConePiZeros");
306  desc_builders.addOptional<double>("leadObjectPt");
307  desc_builders.addOptional<std::string>("matchingCone");
308  desc_builders.addOptional<int>("maxSignalConeChargedHadrons");
309  desc_builders.addOptional<std::string>("signalConeChargedHadrons");
310  desc_builders.addOptional<std::string>("signalConeNeutralHadrons");
311  desc_builders.addOptional<std::string>("signalConePiZeros");
312  desc_builders.addOptional<bool>("usePFLeptons");
313 
314  std::vector<edm::ParameterSet> vpset_default;
315  {
316  edm::ParameterSet pset_default_builders;
317  pset_default_builders.addParameter<std::string>("name", "");
318  pset_default_builders.addParameter<std::string>("plugin", "");
319  pset_default_builders.addParameter<int>("verbosity", 0);
320  pset_default_builders.addParameter<double>("minAbsPhotonSumPt_insideSignalCone", 2.5);
321  pset_default_builders.addParameter<double>("minRelPhotonSumPt_insideSignalCone", 0.1);
322  pset_default_builders.addParameter<edm::InputTag>("pfCandSrc", edm::InputTag("particleFlow"));
323  vpset_default.push_back(pset_default_builders);
324  }
325  desc.addVPSet("builders", desc_builders, vpset_default);
326  }
327 
328  desc.add<bool>("buildNullTaus", false);
329  desc.add<int>("verbosity", 0);
330  descriptions.add("combinatoricRecoTaus", desc);
331 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
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)
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, alignCSCRings::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(), DBoxMetadataHelper::set_difference(), reco::PFTau::setjetRef(), metsig::tau, and runTauDisplay::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
std::vector< std::unique_ptr< reco::PFTau > > output_type
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
BuilderList builders_
edm::EDGetTokenT< reco::JetView > jet_token
ModifierList modifiers_
A arg
Definition: Factorize.h:31
edm::EDGetTokenT< edm::AssociationMap< edm::OneToOne< reco::JetView, reco::JetView > > > jetRegion_token
def move
Definition: eostools.py:511
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isNull() const
Checks for null.
Definition: RefToBase.h:295
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)
std::unique_ptr< StringCutObjectSelector< reco::PFTau > > outputSelector_

Member Data Documentation

BuilderList RecoTauProducer::builders_
private

Definition at line 72 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

bool RecoTauProducer::buildNullTaus_
private

Definition at line 79 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

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

Definition at line 69 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

edm::InputTag RecoTauProducer::chargedHadronSrc_
private

Definition at line 61 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().

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

Definition at line 67 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

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().

edm::InputTag RecoTauProducer::jetRegionSrc_
private

Definition at line 60 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().

edm::InputTag RecoTauProducer::jetSrc_
private

Definition at line 59 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().

double RecoTauProducer::maxJetAbsEta_
private

Definition at line 65 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

double RecoTauProducer::minJetPt_
private

Definition at line 64 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

ModifierList RecoTauProducer::modifiers_
private

Definition at line 73 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

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

Definition at line 75 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

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

Definition at line 70 of file RecoTauProducer.cc.

Referenced by produce(), and RecoTauProducer().

edm::InputTag RecoTauProducer::piZeroSrc_
private

Definition at line 62 of file RecoTauProducer.cc.

Referenced by RecoTauProducer().