CMS 3D CMS Logo

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

Public Types

typedef reco::tau::RecoTauPiZeroBuilderPlugin Builder
 
typedef reco::tau::RecoTauPiZeroQualityPlugin Ranker
 
- 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 print (const std::vector< reco::RecoTauPiZero > &piZeros, std::ostream &out)
 
void produce (edm::Event &evt, const edm::EventSetup &es) override
 
 RecoTauPiZeroProducer (const edm::ParameterSet &pset)
 
 ~RecoTauPiZeroProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Types

typedef boost::ptr_vector< BuilderbuilderList
 
typedef boost::ptr_list< reco::RecoTauPiZeroPiZeroList
 
typedef reco::tau::RecoTauLexicographicalRanking< rankerList, reco::RecoTauPiZeroPiZeroPredicate
 
typedef boost::ptr_vector< reco::RecoTauPiZeroPiZeroVector
 
typedef boost::ptr_vector< RankerrankerList
 

Private Attributes

builderList builders_
 
edm::EDGetTokenT< reco::JetViewcand_token
 
double maxJetAbsEta_
 
double minJetPt_
 
std::unique_ptr< StringCutObjectSelector< reco::RecoTauPiZero > > outputSelector_
 
double piZeroMass_
 
std::unique_ptr< PiZeroPredicatepredicate_
 
rankerList rankers_
 
int verbosity_
 

Detailed Description

Definition at line 41 of file RecoTauPiZeroProducer.cc.

Member Typedef Documentation

Definition at line 43 of file RecoTauPiZeroProducer.cc.

typedef boost::ptr_vector<Builder> RecoTauPiZeroProducer::builderList
private

Definition at line 54 of file RecoTauPiZeroProducer.cc.

typedef boost::ptr_list<reco::RecoTauPiZero> RecoTauPiZeroProducer::PiZeroList
private

Definition at line 57 of file RecoTauPiZeroProducer.cc.

Definition at line 59 of file RecoTauPiZeroProducer.cc.

typedef boost::ptr_vector<reco::RecoTauPiZero> RecoTauPiZeroProducer::PiZeroVector
private

Definition at line 56 of file RecoTauPiZeroProducer.cc.

Definition at line 44 of file RecoTauPiZeroProducer.cc.

typedef boost::ptr_vector<Ranker> RecoTauPiZeroProducer::rankerList
private

Definition at line 55 of file RecoTauPiZeroProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 78 of file RecoTauPiZeroProducer.cc.

References HLT_2018_cff::builders, builders_, cand_token, beamerCreator::create(), timingPdfMaker::get, edm::ParameterSet::getParameter(), maxJetAbsEta_, minJetPt_, outputSelector_, piZeroMass_, predicate_, rankers_, corrVsCorr::selection, AlCaHLTBitMon_QueryRunRegistry::string, verbosity_, and HistogramManager_cfi::VPSet().

78  {
79  cand_token = consumes<reco::JetView>(pset.getParameter<edm::InputTag>("jetSrc"));
80  minJetPt_ = pset.getParameter<double>("minJetPt");
81  maxJetAbsEta_ = pset.getParameter<double>("maxJetAbsEta");
82 
83  typedef std::vector<edm::ParameterSet> VPSet;
84  // Get the mass hypothesis for the pizeros
85  piZeroMass_ = pset.getParameter<double>("massHypothesis");
86 
87  // Get each of our PiZero builders
88  const VPSet& builders = pset.getParameter<VPSet>("builders");
89 
90  for (VPSet::const_iterator builderPSet = builders.begin(); builderPSet != builders.end(); ++builderPSet) {
91  // Get plugin name
92  const std::string& pluginType = builderPSet->getParameter<std::string>("plugin");
93  // Build the plugin
94  builders_.push_back(
95  RecoTauPiZeroBuilderPluginFactory::get()->create(pluginType, *builderPSet, consumesCollector()));
96  }
97 
98  // Get each of our quality rankers
99  const VPSet& rankers = pset.getParameter<VPSet>("ranking");
100  for (VPSet::const_iterator rankerPSet = rankers.begin(); rankerPSet != rankers.end(); ++rankerPSet) {
101  const std::string& pluginType = rankerPSet->getParameter<std::string>("plugin");
102  rankers_.push_back(RecoTauPiZeroQualityPluginFactory::get()->create(pluginType, *rankerPSet));
103  }
104 
105  // Build the sorting predicate
106  predicate_ = std::unique_ptr<PiZeroPredicate>(new PiZeroPredicate(rankers_));
107 
108  // now all producers apply a final output selection
109  std::string selection = pset.getParameter<std::string>("outputSelection");
110  if (!selection.empty()) {
112  }
113 
114  verbosity_ = pset.getParameter<int>("verbosity");
115 
116  produces<reco::JetPiZeroAssociation>();
117 }
T getParameter(std::string const &) const
def create(alignables, pedeDump, additionalData, outputFile, config)
selection
main part
Definition: corrVsCorr.py:100
reco::tau::RecoTauLexicographicalRanking< rankerList, reco::RecoTauPiZero > PiZeroPredicate
std::unique_ptr< StringCutObjectSelector< reco::RecoTauPiZero > > outputSelector_
edm::EDGetTokenT< reco::JetView > cand_token
std::unique_ptr< PiZeroPredicate > predicate_
RecoTauPiZeroProducer::~RecoTauPiZeroProducer ( )
inlineoverride

Definition at line 47 of file RecoTauPiZeroProducer.cc.

References fillDescriptions(), MillePedeFileConverter_cfg::out, print(), and produce().

47 {}

Member Function Documentation

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

Definition at line 232 of file RecoTauPiZeroProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), edm::ParameterSet::addParameter(), edm::ParameterSetDescription::addVPSet(), DEFINE_FWK_MODULE, HLT_2018_cff::InputTag, beam_dqm_sourceclient-live_cfg::qualityCuts, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ~RecoTauPiZeroProducer().

232  {
233  // common parameter descriptions
234  edm::ParameterSetDescription desc_ranking;
235  desc_ranking.add<std::string>("selectionPassFunction", "Func");
236  desc_ranking.add<double>("selectionFailValue", 1000);
237  desc_ranking.add<std::string>("selection", "Sel");
238  desc_ranking.add<std::string>("name", "name");
239  desc_ranking.add<std::string>("plugin", "plugin");
240  edm::ParameterSet pset_ranking;
241  pset_ranking.addParameter<std::string>("selectionPassFunction", "");
242  pset_ranking.addParameter<double>("selectionFailValue", 1000);
243  pset_ranking.addParameter<std::string>("selection", "");
244  pset_ranking.addParameter<std::string>("name", "");
245  pset_ranking.addParameter<std::string>("plugin", "");
246  std::vector<edm::ParameterSet> vpsd_ranking;
247  vpsd_ranking.push_back(pset_ranking);
248 
249  edm::ParameterSetDescription desc_signalQualityCuts;
250  desc_signalQualityCuts.add<double>("maxDeltaZ", 0.4);
251  desc_signalQualityCuts.add<double>("minTrackPt", 0.5);
252  desc_signalQualityCuts.add<double>("minTrackVertexWeight", -1.0);
253  desc_signalQualityCuts.add<double>("maxTrackChi2", 100.0);
254  desc_signalQualityCuts.add<unsigned int>("minTrackPixelHits", 0);
255  desc_signalQualityCuts.add<double>("minGammaEt", 1.0);
256  desc_signalQualityCuts.add<unsigned int>("minTrackHits", 3);
257  desc_signalQualityCuts.addOptional<double>("minNeutralHadronEt");
258  desc_signalQualityCuts.add<double>("maxTransverseImpactParameter", 0.1);
259  desc_signalQualityCuts.addOptional<bool>("useTracksInsteadOfPFHadrons");
260 
261  edm::ParameterSetDescription desc_vxAssocQualityCuts;
262  desc_vxAssocQualityCuts.add<double>("minTrackPt", 0.5);
263  desc_vxAssocQualityCuts.add<double>("minTrackVertexWeight", -1.0);
264  desc_vxAssocQualityCuts.add<double>("maxTrackChi2", 100.0);
265  desc_vxAssocQualityCuts.add<unsigned int>("minTrackPixelHits", 0);
266  desc_vxAssocQualityCuts.add<double>("minGammaEt", 1.0);
267  desc_vxAssocQualityCuts.add<unsigned int>("minTrackHits", 3);
268  desc_vxAssocQualityCuts.add<double>("maxTransverseImpactParameter", 0.1);
269  desc_vxAssocQualityCuts.addOptional<bool>("useTracksInsteadOfPFHadrons");
270 
271  edm::ParameterSetDescription desc_isolationQualityCuts;
272  desc_isolationQualityCuts.add<double>("maxDeltaZ", 0.2);
273  desc_isolationQualityCuts.add<double>("minTrackPt", 1.0);
274  desc_isolationQualityCuts.add<double>("minTrackVertexWeight", -1.0);
275  desc_isolationQualityCuts.add<double>("maxTrackChi2", 100.0);
276  desc_isolationQualityCuts.add<unsigned int>("minTrackPixelHits", 0);
277  desc_isolationQualityCuts.add<double>("minGammaEt", 1.5);
278  desc_isolationQualityCuts.add<unsigned int>("minTrackHits", 8);
279  desc_isolationQualityCuts.add<double>("maxTransverseImpactParameter", 0.03);
280  desc_isolationQualityCuts.addOptional<bool>("useTracksInsteadOfPFHadrons");
281 
282  edm::ParameterSetDescription desc_qualityCuts;
283  desc_qualityCuts.add<edm::ParameterSetDescription>("signalQualityCuts", desc_signalQualityCuts);
284  desc_qualityCuts.add<edm::ParameterSetDescription>("vxAssocQualityCuts", desc_vxAssocQualityCuts);
285  desc_qualityCuts.add<edm::ParameterSetDescription>("isolationQualityCuts", desc_isolationQualityCuts);
286  desc_qualityCuts.add<std::string>("leadingTrkOrPFCandOption", "leadPFCand");
287  desc_qualityCuts.add<std::string>("pvFindingAlgo", "closestInDeltaZ");
288  desc_qualityCuts.add<edm::InputTag>("primaryVertexSrc", edm::InputTag("offlinePrimaryVertices"));
289  desc_qualityCuts.add<bool>("vertexTrackFiltering", false);
290  desc_qualityCuts.add<bool>("recoverLeadingTrk", false);
291 
292  edm::ParameterSet pset_builders;
293  pset_builders.addParameter<std::string>("name", "");
294  pset_builders.addParameter<std::string>("plugin", "");
296  pset_builders.addParameter<edm::ParameterSet>("qualityCuts", qualityCuts);
297  pset_builders.addParameter<int>("verbosity", 0);
298 
299  {
300  // Tailored on ak4PFJetsLegacyHPSPiZeros
302  desc.add<double>("massHypothesis", 0.136);
303  desc.addVPSet("ranking", desc_ranking, vpsd_ranking);
304  desc.add<int>("verbosity", 0);
305  desc.add<double>("maxJetAbsEta", 2.5);
306  desc.add<std::string>("outputSelection", "pt > 0");
307  desc.add<double>("minJetPt", 14.0);
308  desc.add<edm::InputTag>("jetSrc", edm::InputTag("ak4PFJets"));
309 
310  edm::ParameterSetDescription desc_builders;
311  {
313  psd0.add<std::string>("function", "TMath::Min(0.3, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))");
314  psd0.add<double>("par1", 0.707716);
315  psd0.add<double>("par0", 0.352476);
316  desc_builders.addOptional<edm::ParameterSetDescription>("stripPhiAssociationDistanceFunc", psd0);
317  }
318  {
320  psd0.add<std::string>("function", "TMath::Min(0.15, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))");
321  psd0.add<double>("par1", 0.658701);
322  psd0.add<double>("par0", 0.197077);
323  desc_builders.addOptional<edm::ParameterSetDescription>("stripEtaAssociationDistanceFunc", psd0);
324  }
325  desc_builders.addOptional<double>("stripEtaAssociationDistance", 0.05);
326  desc_builders.addOptional<double>("stripPhiAssociationDistance", 0.2);
327 
328  desc_builders.add<edm::ParameterSetDescription>("qualityCuts", desc_qualityCuts);
329 
330  desc_builders.add<std::string>("name");
331  desc_builders.add<std::string>("plugin");
332  desc_builders.add<int>("verbosity", 0);
333 
334  desc_builders.addOptional<bool>("makeCombinatoricStrips");
335  desc_builders.addOptional<int>("maxStripBuildIterations");
336  desc_builders.addOptional<double>("minGammaEtStripAdd");
337  desc_builders.addOptional<double>("minGammaEtStripSeed");
338  desc_builders.addOptional<double>("minStripEt");
339  desc_builders.addOptional<std::vector<int>>("stripCandidatesParticleIds");
340  desc_builders.addOptional<bool>("updateStripAfterEachDaughter");
341  desc_builders.addOptional<bool>("applyElecTrackQcuts");
342 
343  std::vector<edm::ParameterSet> vpsd_builders;
344  vpsd_builders.push_back(pset_builders);
345  desc.addVPSet("builders", desc_builders, vpsd_builders);
346 
347  descriptions.add("recoTauPiZeroProducer", desc);
348  }
349 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:124
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void RecoTauPiZeroProducer::print ( const std::vector< reco::RecoTauPiZero > &  piZeros,
std::ostream &  out 
)

Definition at line 219 of file RecoTauPiZeroProducer.cc.

References rankers_, and ApeEstimator_cff::width.

Referenced by produce(), and ~RecoTauPiZeroProducer().

219  {
220  const unsigned int width = 25;
221  for (auto const& piZero : piZeros) {
222  out << piZero;
223  out << "* Rankers:" << std::endl;
224  for (rankerList::const_iterator ranker = rankers_.begin(); ranker != rankers_.end(); ++ranker) {
225  out << "* " << std::setiosflags(std::ios::left) << std::setw(width) << ranker->name() << " "
226  << std::resetiosflags(std::ios::left) << std::setprecision(3) << (*ranker)(piZero);
227  out << std::endl;
228  }
229  }
230 }
void RecoTauPiZeroProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 119 of file RecoTauPiZeroProducer.cc.

References funct::abs(), TrackValidation_cff::association, builders_, cand_token, gather_cfg::cout, MillePedeFileConverter_cfg::e, cppFunctionSkipper::exception, CustomPhysics_cfi::gamma, edm::Event::getByToken(), mps_fire::i, metsig::jet, maxJetAbsEta_, minJetPt_, eostools::move(), outputSelector_, piZeroMass_, predicate_, print(), edm::Event::put(), edm::View< T >::refAt(), mps_fire::result, AddFourMomenta::set(), edm::View< T >::size(), HLT_2018_cff::toAdd, and verbosity_.

Referenced by ~RecoTauPiZeroProducer().

119  {
120  // Get a view of our jets via the base candidates
122  evt.getByToken(cand_token, jetView);
123 
124  // Give each of our plugins a chance at doing something with the edm::Event
125  for (auto& builder : builders_) {
126  builder.setup(evt, es);
127  }
128 
129  // Make our association
130  std::unique_ptr<reco::JetPiZeroAssociation> association;
131 
132  association = std::make_unique<reco::JetPiZeroAssociation>(reco::JetRefBaseProd(jetView));
133 
134  // Loop over our jets
135  size_t nJets = jetView->size();
136  for (size_t i = 0; i < nJets; ++i) {
137  const reco::JetBaseRef jet(jetView->refAt(i));
138 
139  if (jet->pt() - minJetPt_ < 1e-5)
140  continue;
141  if (std::abs(jet->eta()) - maxJetAbsEta_ > -1e-5)
142  continue;
143  // Build our global list of RecoTauPiZero
144  PiZeroList dirtyPiZeros;
145 
146  // Compute the pi zeros from this jet for all the desired algorithms
147  for (auto const& builder : builders_) {
148  try {
149  PiZeroVector result(builder(*jet));
150  dirtyPiZeros.transfer(dirtyPiZeros.end(), result);
151  } catch (cms::Exception& exception) {
152  edm::LogError("BuilderPluginException")
153  << "Exception caught in builder plugin " << builder.name() << ", rethrowing" << std::endl;
154  throw exception;
155  }
156  }
157  // Rank the candidates according to our quality plugins
158  dirtyPiZeros.sort(*predicate_);
159 
160  // Keep track of the photons in the clean collection
161  std::vector<reco::RecoTauPiZero> cleanPiZeros;
162  std::set<reco::CandidatePtr> photonsInCleanCollection;
163  while (!dirtyPiZeros.empty()) {
164  // Pull our candidate pi zero from the front of the list
165  std::unique_ptr<reco::RecoTauPiZero> toAdd(dirtyPiZeros.pop_front().release());
166  // If this doesn't pass our basic selection, discard it.
167  if (!(*outputSelector_)(*toAdd)) {
168  continue;
169  }
170  // Find the sub-gammas that are not already in the cleaned collection
171  std::vector<reco::CandidatePtr> uniqueGammas;
172  std::set_difference(toAdd->daughterPtrVector().begin(),
173  toAdd->daughterPtrVector().end(),
174  photonsInCleanCollection.begin(),
175  photonsInCleanCollection.end(),
176  std::back_inserter(uniqueGammas));
177  // If the pi zero has no unique gammas, discard it. Note toAdd is deleted
178  // when it goes out of scope.
179  if (uniqueGammas.empty()) {
180  continue;
181  } else if (uniqueGammas.size() == toAdd->daughterPtrVector().size()) {
182  // Check if it is composed entirely of unique gammas. In this case
183  // immediately add it to the clean collection.
184  photonsInCleanCollection.insert(toAdd->daughterPtrVector().begin(), toAdd->daughterPtrVector().end());
185  cleanPiZeros.push_back(*toAdd);
186  } else {
187  // Otherwise update the pizero that contains only the unique gammas and
188  // add it back into the sorted list of dirty PiZeros
189  toAdd->clearDaughters();
190  // Add each of the unique daughters back to the pizero
191  for (auto const& gamma : uniqueGammas) {
192  toAdd->addDaughter(gamma);
193  }
194  // Update the four vector
195  AddFourMomenta p4Builder_;
196  p4Builder_.set(*toAdd);
197  // Put this pi zero back into the collection of sorted dirty pizeros
198  PiZeroList::iterator insertionPoint =
199  std::lower_bound(dirtyPiZeros.begin(), dirtyPiZeros.end(), *toAdd, *predicate_);
200  dirtyPiZeros.insert(insertionPoint, std::move(toAdd));
201  }
202  }
203  // Apply the mass hypothesis if desired
204  if (piZeroMass_ >= 0) {
205  for (auto& cleanPiZero : cleanPiZeros) {
206  cleanPiZero.setMass(this->piZeroMass_);
207  };
208  }
209  // Add to association
210  if (verbosity_ >= 2) {
211  print(cleanPiZeros, std::cout);
212  }
213  association->setValue(jet.key(), cleanPiZeros);
214  }
215  evt.put(std::move(association));
216 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
size_type size() const
void print(const std::vector< reco::RecoTauPiZero > &piZeros, std::ostream &out)
RefToBase< value_type > refAt(size_type i) const
edm::RefToBaseProd< reco::Jet > JetRefBaseProd
Definition: JetCollection.h:13
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
boost::ptr_vector< reco::RecoTauPiZero > PiZeroVector
boost::ptr_list< reco::RecoTauPiZero > PiZeroList
std::unique_ptr< StringCutObjectSelector< reco::RecoTauPiZero > > outputSelector_
edm::EDGetTokenT< reco::JetView > cand_token
void set(reco::Candidate &c) const
set up a candidate
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< PiZeroPredicate > predicate_

Member Data Documentation

builderList RecoTauPiZeroProducer::builders_
private

Definition at line 61 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

edm::EDGetTokenT<reco::JetView> RecoTauPiZeroProducer::cand_token
private

Definition at line 70 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

double RecoTauPiZeroProducer::maxJetAbsEta_
private

Definition at line 73 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

double RecoTauPiZeroProducer::minJetPt_
private

Definition at line 72 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

std::unique_ptr<StringCutObjectSelector<reco::RecoTauPiZero> > RecoTauPiZeroProducer::outputSelector_
private

Definition at line 67 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

double RecoTauPiZeroProducer::piZeroMass_
private

Definition at line 64 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

std::unique_ptr<PiZeroPredicate> RecoTauPiZeroProducer::predicate_
private

Definition at line 63 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

rankerList RecoTauPiZeroProducer::rankers_
private

Definition at line 62 of file RecoTauPiZeroProducer.cc.

Referenced by print(), and RecoTauPiZeroProducer().

int RecoTauPiZeroProducer::verbosity_
private

Definition at line 75 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().