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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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::auto_ptr< StringCutObjectSelector< reco::RecoTauPiZero > > outputSelector_
 
double piZeroMass_
 
std::auto_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 55 of file RecoTauPiZeroProducer.cc.

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

Definition at line 58 of file RecoTauPiZeroProducer.cc.

Definition at line 61 of file RecoTauPiZeroProducer.cc.

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

Definition at line 57 of file RecoTauPiZeroProducer.cc.

Definition at line 44 of file RecoTauPiZeroProducer.cc.

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

Definition at line 56 of file RecoTauPiZeroProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 81 of file RecoTauPiZeroProducer.cc.

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

82 {
83  cand_token = consumes<reco::JetView>( pset.getParameter<edm::InputTag>("jetSrc"));
84  minJetPt_ = pset.getParameter<double>("minJetPt");
85  maxJetAbsEta_ = pset.getParameter<double>("maxJetAbsEta");
86 
87  typedef std::vector<edm::ParameterSet> VPSet;
88  // Get the mass hypothesis for the pizeros
89  piZeroMass_ = pset.getParameter<double>("massHypothesis");
90 
91  // Get each of our PiZero builders
92  const VPSet& builders = pset.getParameter<VPSet>("builders");
93 
94  for (VPSet::const_iterator builderPSet = builders.begin();
95  builderPSet != builders.end(); ++builderPSet) {
96  // Get plugin name
97  const std::string& pluginType =
98  builderPSet->getParameter<std::string>("plugin");
99  // Build the plugin
101  pluginType, *builderPSet, consumesCollector()));
102  }
103 
104  // Get each of our quality rankers
105  const VPSet& rankers = pset.getParameter<VPSet>("ranking");
106  for (VPSet::const_iterator rankerPSet = rankers.begin();
107  rankerPSet != rankers.end(); ++rankerPSet) {
108  const std::string& pluginType =
109  rankerPSet->getParameter<std::string>("plugin");
111  pluginType, *rankerPSet));
112  }
113 
114  // Build the sorting predicate
115  predicate_ = std::auto_ptr<PiZeroPredicate>(new PiZeroPredicate(rankers_));
116 
117  // now all producers apply a final output selection
118  std::string selection = pset.getParameter<std::string>("outputSelection");
119  if (!selection.empty()) {
120  outputSelector_.reset(
122  }
123 
124  verbosity_ = pset.getParameter<int>("verbosity");
125 
126  produces<reco::JetPiZeroAssociation>();
127 }
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
edm::EDGetTokenT< reco::JetView > cand_token
std::auto_ptr< StringCutObjectSelector< reco::RecoTauPiZero > > outputSelector_
T get(const Candidate &c)
Definition: component.h:55
std::auto_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 248 of file RecoTauPiZeroProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), edm::ParameterSet::addParameter(), edm::ParameterSetDescription::addVPSet(), DEFINE_FWK_MODULE, CaloRecoTauDiscriminationByFlightPathSignificance_cfi::qualityCuts, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ~RecoTauPiZeroProducer().

248  {
249  // common parameter descriptions
250  edm::ParameterSetDescription desc_ranking;
251  desc_ranking.add<std::string>("selectionPassFunction","Func");
252  desc_ranking.add<double>("selectionFailValue",1000);
253  desc_ranking.add<std::string>("selection","Sel");
254  desc_ranking.add<std::string>("name","name");
255  desc_ranking.add<std::string>("plugin","plugin");
256  edm::ParameterSet pset_ranking;
257  pset_ranking.addParameter<std::string>("selectionPassFunction","");
258  pset_ranking.addParameter<double>("selectionFailValue",1000);
259  pset_ranking.addParameter<std::string>("selection","");
260  pset_ranking.addParameter<std::string>("name","");
261  pset_ranking.addParameter<std::string>("plugin","");
262  std::vector<edm::ParameterSet> vpsd_ranking;
263  vpsd_ranking.push_back(pset_ranking);
264 
265  edm::ParameterSetDescription desc_signalQualityCuts;
266  desc_signalQualityCuts.add<double>("maxDeltaZ", 0.4);
267  desc_signalQualityCuts.add<double>("minTrackPt", 0.5);
268  desc_signalQualityCuts.add<double>("minTrackVertexWeight", -1.0);
269  desc_signalQualityCuts.add<double>("maxTrackChi2", 100.0);
270  desc_signalQualityCuts.add<unsigned int>("minTrackPixelHits", 0);
271  desc_signalQualityCuts.add<double>("minGammaEt", 1.0);
272  desc_signalQualityCuts.add<unsigned int>("minTrackHits", 3);
273  desc_signalQualityCuts.addOptional<double>("minNeutralHadronEt");
274  desc_signalQualityCuts.add<double>("maxTransverseImpactParameter", 0.1);
275  desc_signalQualityCuts.addOptional<bool>("useTracksInsteadOfPFHadrons");
276 
277  edm::ParameterSetDescription desc_vxAssocQualityCuts;
278  desc_vxAssocQualityCuts.add<double>("minTrackPt", 0.5);
279  desc_vxAssocQualityCuts.add<double>("minTrackVertexWeight", -1.0);
280  desc_vxAssocQualityCuts.add<double>("maxTrackChi2", 100.0);
281  desc_vxAssocQualityCuts.add<unsigned int>("minTrackPixelHits", 0);
282  desc_vxAssocQualityCuts.add<double>("minGammaEt", 1.0);
283  desc_vxAssocQualityCuts.add<unsigned int>("minTrackHits", 3);
284  desc_vxAssocQualityCuts.add<double>("maxTransverseImpactParameter", 0.1);
285  desc_vxAssocQualityCuts.addOptional<bool>("useTracksInsteadOfPFHadrons");
286 
287  edm::ParameterSetDescription desc_isolationQualityCuts;
288  desc_isolationQualityCuts.add<double>("maxDeltaZ", 0.2);
289  desc_isolationQualityCuts.add<double>("minTrackPt", 1.0);
290  desc_isolationQualityCuts.add<double>("minTrackVertexWeight", -1.0);
291  desc_isolationQualityCuts.add<double>("maxTrackChi2", 100.0);
292  desc_isolationQualityCuts.add<unsigned int>("minTrackPixelHits", 0);
293  desc_isolationQualityCuts.add<double>("minGammaEt", 1.5);
294  desc_isolationQualityCuts.add<unsigned int>("minTrackHits", 8);
295  desc_isolationQualityCuts.add<double>("maxTransverseImpactParameter", 0.03);
296  desc_isolationQualityCuts.addOptional<bool>("useTracksInsteadOfPFHadrons");
297 
298  edm::ParameterSetDescription desc_qualityCuts;
299  desc_qualityCuts.add<edm::ParameterSetDescription>("signalQualityCuts", desc_signalQualityCuts);
300  desc_qualityCuts.add<edm::ParameterSetDescription>("vxAssocQualityCuts", desc_vxAssocQualityCuts);
301  desc_qualityCuts.add<edm::ParameterSetDescription>("isolationQualityCuts", desc_isolationQualityCuts);
302  desc_qualityCuts.add<std::string>("leadingTrkOrPFCandOption", "leadPFCand");
303  desc_qualityCuts.add<std::string>("pvFindingAlgo", "closestInDeltaZ");
304  desc_qualityCuts.add<edm::InputTag>("primaryVertexSrc", edm::InputTag("offlinePrimaryVertices"));
305  desc_qualityCuts.add<bool>("vertexTrackFiltering", false);
306  desc_qualityCuts.add<bool>("recoverLeadingTrk", false);
307 
308  edm::ParameterSet pset_builders;
309  pset_builders.addParameter<std::string>("name","");
310  pset_builders.addParameter<std::string>("plugin","");
312  pset_builders.addParameter<edm::ParameterSet>("qualityCuts",qualityCuts);
313  pset_builders.addParameter<int>("verbosity",0);
314 
315  {
316  // Tailored on ak4PFJetsLegacyHPSPiZeros
318  desc.add<double>("massHypothesis", 0.136);
319  desc.addVPSet("ranking", desc_ranking, vpsd_ranking);
320  desc.add<int>("verbosity", 0);
321  desc.add<double>("maxJetAbsEta", 2.5);
322  desc.add<std::string>("outputSelection", "pt > 0");
323  desc.add<double>("minJetPt", 14.0);
324  desc.add<edm::InputTag>("jetSrc", edm::InputTag("ak4PFJets"));
325 
326  edm::ParameterSetDescription desc_builders;
327  {
329  psd0.add<std::string>("function", "TMath::Min(0.3, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))");
330  psd0.add<double>("par1", 0.707716);
331  psd0.add<double>("par0", 0.352476);
332  desc_builders.addOptional<edm::ParameterSetDescription>("stripPhiAssociationDistanceFunc", psd0);
333  }
334  {
336  psd0.add<std::string>("function", "TMath::Min(0.15, TMath::Max(0.05, [0]*TMath::Power(pT, -[1])))");
337  psd0.add<double>("par1", 0.658701);
338  psd0.add<double>("par0", 0.197077);
339  desc_builders.addOptional<edm::ParameterSetDescription>("stripEtaAssociationDistanceFunc", psd0);
340  }
341  desc_builders.addOptional<double>("stripEtaAssociationDistance", 0.05);
342  desc_builders.addOptional<double>("stripPhiAssociationDistance", 0.2);
343 
344  desc_builders.add<edm::ParameterSetDescription>("qualityCuts", desc_qualityCuts);
345 
346  desc_builders.add<std::string>("name");
347  desc_builders.add<std::string>("plugin");
348  desc_builders.add<int>("verbosity", 0);
349 
350  desc_builders.addOptional<bool>("makeCombinatoricStrips");
351  desc_builders.addOptional<int>("maxStripBuildIterations");
352  desc_builders.addOptional<double>("minGammaEtStripAdd");
353  desc_builders.addOptional<double>("minGammaEtStripSeed");
354  desc_builders.addOptional<double>("minStripEt");
355  desc_builders.addOptional<std::vector<int>>("stripCandidatesParticleIds");
356  desc_builders.addOptional<bool>("updateStripAfterEachDaughter");
357  desc_builders.addOptional<bool>("applyElecTrackQcuts");
358 
359  std::vector<edm::ParameterSet> vpsd_builders;
360  vpsd_builders.push_back(pset_builders);
361  desc.addVPSet("builders", desc_builders, vpsd_builders);
362 
363  descriptions.add("recoTauPiZeroProducer", desc);
364 
365  }
366 
367 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:125
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 230 of file RecoTauPiZeroProducer.cc.

References rankers_, and ApeEstimator_cff::width.

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

231  {
232  const unsigned int width = 25;
233  for(auto const& piZero : piZeros) {
234  out << piZero;
235  out << "* Rankers:" << std::endl;
236  for (rankerList::const_iterator ranker = rankers_.begin();
237  ranker != rankers_.end(); ++ranker) {
238  out << "* " << std::setiosflags(std::ios::left)
239  << std::setw(width) << ranker->name()
240  << " " << std::resetiosflags(std::ios::left)
241  << std::setprecision(3) << (*ranker)(piZero);
242  out << std::endl;
243  }
244  }
245 }
void RecoTauPiZeroProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 129 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, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, maxJetAbsEta_, minJetPt_, eostools::move(), outputSelector_, piZeroMass_, predicate_, print(), edm::Event::put(), edm::View< T >::refAt(), mps_fire::result, AddFourMomenta::set(), edm::View< T >::size(), pfDeepCMVAJetTags_cfi::toAdd, and verbosity_.

Referenced by ~RecoTauPiZeroProducer().

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

Member Data Documentation

builderList RecoTauPiZeroProducer::builders_
private

Definition at line 63 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

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

Definition at line 73 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

double RecoTauPiZeroProducer::maxJetAbsEta_
private

Definition at line 76 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

double RecoTauPiZeroProducer::minJetPt_
private

Definition at line 75 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

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

Definition at line 70 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

double RecoTauPiZeroProducer::piZeroMass_
private

Definition at line 66 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

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

Definition at line 65 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

rankerList RecoTauPiZeroProducer::rankers_
private

Definition at line 64 of file RecoTauPiZeroProducer.cc.

Referenced by print(), and RecoTauPiZeroProducer().

int RecoTauPiZeroProducer::verbosity_
private

Definition at line 78 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().