CMS 3D CMS Logo

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

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 Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

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 ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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::CandidateViewcand_token
 
double maxJetAbsEta_
 
double minJetPt_
 
std::auto_ptr< StringCutObjectSelector< reco::RecoTauPiZero > > outputSelector_
 
double piZeroMass_
 
std::auto_ptr< PiZeroPredicatepredicate_
 
rankerList rankers_
 
int verbosity_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 40 of file RecoTauPiZeroProducer.cc.

Member Typedef Documentation

Definition at line 42 of file RecoTauPiZeroProducer.cc.

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

Definition at line 52 of file RecoTauPiZeroProducer.cc.

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

Definition at line 55 of file RecoTauPiZeroProducer.cc.

Definition at line 58 of file RecoTauPiZeroProducer.cc.

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

Definition at line 54 of file RecoTauPiZeroProducer.cc.

Definition at line 43 of file RecoTauPiZeroProducer.cc.

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

Definition at line 53 of file RecoTauPiZeroProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 78 of file RecoTauPiZeroProducer.cc.

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

79 {
80  cand_token = consumes<reco::CandidateView>( pset.getParameter<edm::InputTag>("jetSrc"));
81  minJetPt_ = ( pset.exists("minJetPt") ) ? pset.getParameter<double>("minJetPt") : -1.0;
82  maxJetAbsEta_ = ( pset.exists("maxJetAbsEta") ) ? pset.getParameter<double>("maxJetAbsEta") : 99.0;
83 
84  typedef std::vector<edm::ParameterSet> VPSet;
85  // Get the mass hypothesis for the pizeros
86  piZeroMass_ = pset.getParameter<double>("massHypothesis");
87 
88  // Get each of our PiZero builders
89  const VPSet& builders = pset.getParameter<VPSet>("builders");
90 
91  for (VPSet::const_iterator builderPSet = builders.begin();
92  builderPSet != builders.end(); ++builderPSet) {
93  // Get plugin name
94  const std::string& pluginType =
95  builderPSet->getParameter<std::string>("plugin");
96  // Build the plugin
98  pluginType, *builderPSet, consumesCollector()));
99  }
100 
101  // Get each of our quality rankers
102  const VPSet& rankers = pset.getParameter<VPSet>("ranking");
103  for (VPSet::const_iterator rankerPSet = rankers.begin();
104  rankerPSet != rankers.end(); ++rankerPSet) {
105  const std::string& pluginType =
106  rankerPSet->getParameter<std::string>("plugin");
108  pluginType, *rankerPSet));
109  }
110 
111  // Build the sorting predicate
112  predicate_ = std::auto_ptr<PiZeroPredicate>(new PiZeroPredicate(rankers_));
113 
114  // Check if we want to apply a final output selection
115  if (pset.exists("outputSelection")) {
116  std::string selection = pset.getParameter<std::string>("outputSelection");
117  if (selection != "") {
118  outputSelector_.reset(
120  }
121  }
122 
123  verbosity_ = ( pset.exists("verbosity") ) ?
124  pset.getParameter<int>("verbosity") : 0;
125 
126  produces<reco::JetPiZeroAssociation>();
127 }
T getParameter(std::string const &) const
def create(alignables, pedeDump, additionalData, outputFile, config)
edm::EDGetTokenT< reco::CandidateView > cand_token
selection
main part
Definition: corrVsCorr.py:98
bool exists(std::string const &parameterName) const
checks if a parameter exists
reco::tau::RecoTauLexicographicalRanking< rankerList, reco::RecoTauPiZero > PiZeroPredicate
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::auto_ptr< StringCutObjectSelector< reco::RecoTauPiZero > > outputSelector_
T get(const Candidate &c)
Definition: component.h:55
std::auto_ptr< PiZeroPredicate > predicate_
RecoTauPiZeroProducer::~RecoTauPiZeroProducer ( )
inline

Definition at line 46 of file RecoTauPiZeroProducer.cc.

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

46 {}

Member Function Documentation

void RecoTauPiZeroProducer::print ( const std::vector< reco::RecoTauPiZero > &  piZeros,
std::ostream &  out 
)

Definition at line 239 of file RecoTauPiZeroProducer.cc.

References DEFINE_FWK_MODULE, rankers_, and ApeEstimator_cff::width.

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

240  {
241  const unsigned int width = 25;
242  BOOST_FOREACH(const reco::RecoTauPiZero& piZero, piZeros) {
243  out << piZero;
244  out << "* Rankers:" << std::endl;
245  for (rankerList::const_iterator ranker = rankers_.begin();
246  ranker != rankers_.end(); ++ranker) {
247  out << "* " << std::setiosflags(std::ios::left)
248  << std::setw(width) << ranker->name()
249  << " " << std::resetiosflags(std::ios::left)
250  << std::setprecision(3) << (*ranker)(piZero);
251  out << std::endl;
252  }
253  }
254 }
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::get(), edm::Event::getByToken(), edm::RefVector< C, T, F >::id(), metsig::jet, edm::Ref< C, T, F >::key(), maxJetAbsEta_, minJetPt_, eostools::move(), reco::tau::RecoTauNamedPlugin::name(), outputSelector_, piZeroMass_, predicate_, print(), edm::Event::put(), mps_fire::result, AddFourMomenta::set(), reco::LeafCandidate::setMass(), reco::tau::RecoTauEventHolderPlugin::setup(), edm::RefVector< C, T, F >::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  BOOST_FOREACH(Builder& builder, builders_) {
137  builder.setup(evt, es);
138  }
139 
140  // Convert the view to a RefVector of actual PFJets
141  reco::PFJetRefVector jetRefs =
142  reco::tau::castView<reco::PFJetRefVector>(jetView);
143  // Make our association
144  std::unique_ptr<reco::JetPiZeroAssociation> association;
145 
146  if (jetRefs.size()) {
147  edm::Handle<reco::PFJetCollection> pfJetCollectionHandle;
148  evt.get(jetRefs.id(), pfJetCollectionHandle);
149  association = std::make_unique<reco::JetPiZeroAssociation>(reco::PFJetRefProd(pfJetCollectionHandle));
150  } else {
151  association = std::make_unique<reco::JetPiZeroAssociation>();
152  }
153 
154  // Loop over our jets
155  BOOST_FOREACH(const reco::PFJetRef& jet, jetRefs) {
156 
157  if(jet->pt() - minJetPt_ < 1e-5) continue;
158  if(std::abs(jet->eta()) - maxJetAbsEta_ > -1e-5) continue;
159  // Build our global list of RecoTauPiZero
160  PiZeroList dirtyPiZeros;
161 
162  // Compute the pi zeros from this jet for all the desired algorithms
163  BOOST_FOREACH(const Builder& builder, builders_) {
164  try {
165  PiZeroVector result(builder(*jet));
166  dirtyPiZeros.transfer(dirtyPiZeros.end(), result);
167  } catch ( cms::Exception &exception) {
168  edm::LogError("BuilderPluginException")
169  << "Exception caught in builder plugin " << builder.name()
170  << ", rethrowing" << std::endl;
171  throw exception;
172  }
173  }
174  // Rank the candidates according to our quality plugins
175  dirtyPiZeros.sort(*predicate_);
176 
177  // Keep track of the photons in the clean collection
178  std::vector<reco::RecoTauPiZero> cleanPiZeros;
179  std::set<reco::CandidatePtr> photonsInCleanCollection;
180  while (dirtyPiZeros.size()) {
181  // Pull our candidate pi zero from the front of the list
182  std::auto_ptr<reco::RecoTauPiZero> toAdd(
183  dirtyPiZeros.pop_front().release());
184  // If this doesn't pass our basic selection, discard it.
185  if (!(*outputSelector_)(*toAdd)) {
186  continue;
187  }
188  // Find the sub-gammas that are not already in the cleaned collection
189  std::vector<reco::CandidatePtr> uniqueGammas;
190  std::set_difference(toAdd->daughterPtrVector().begin(),
191  toAdd->daughterPtrVector().end(),
192  photonsInCleanCollection.begin(),
193  photonsInCleanCollection.end(),
194  std::back_inserter(uniqueGammas));
195  // If the pi zero has no unique gammas, discard it. Note toAdd is deleted
196  // when it goes out of scope.
197  if (!uniqueGammas.size()) {
198  continue;
199  } else if (uniqueGammas.size() == toAdd->daughterPtrVector().size()) {
200  // Check if it is composed entirely of unique gammas. In this case
201  // immediately add it to the clean collection.
202  photonsInCleanCollection.insert(toAdd->daughterPtrVector().begin(),
203  toAdd->daughterPtrVector().end());
204  cleanPiZeros.push_back(*toAdd);
205  } else {
206  // Otherwise update the pizero that contains only the unique gammas and
207  // add it back into the sorted list of dirty PiZeros
208  toAdd->clearDaughters();
209  // Add each of the unique daughters back to the pizero
210  BOOST_FOREACH(const reco::CandidatePtr& gamma, uniqueGammas) {
211  toAdd->addDaughter(gamma);
212  }
213  // Update the four vector
214  AddFourMomenta p4Builder_;
215  p4Builder_.set(*toAdd);
216  // Put this pi zero back into the collection of sorted dirty pizeros
217  PiZeroList::iterator insertionPoint = std::lower_bound(
218  dirtyPiZeros.begin(), dirtyPiZeros.end(), *toAdd, *predicate_);
219  dirtyPiZeros.insert(insertionPoint, toAdd);
220  }
221  }
222  // Apply the mass hypothesis if desired
223  if (piZeroMass_ >= 0) {
224  std::for_each(
225  cleanPiZeros.begin(), cleanPiZeros.end(),
226  std::bind2nd(
227  std::mem_fun_ref(&reco::RecoTauPiZero::setMass), piZeroMass_));
228  }
229  // Add to association
230  if ( verbosity_ >= 2 ) {
231  print(cleanPiZeros, std::cout);
232  }
233  association->setValue(jet.key(), cleanPiZeros);
234  }
235  evt.put(std::move(association));
236 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
edm::EDGetTokenT< reco::CandidateView > cand_token
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
key_type key() const
Accessor for product key.
Definition: Ref.h:265
void print(const std::vector< reco::RecoTauPiZero > &piZeros, std::ostream &out)
reco::tau::RecoTauPiZeroBuilderPlugin Builder
ProductID id() const
Accessor for product ID.
Definition: RefVector.h:122
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:334
edm::RefProd< PFJetCollection > PFJetRefProd
boost::ptr_vector< reco::RecoTauPiZero > PiZeroVector
boost::ptr_list< reco::RecoTauPiZero > PiZeroList
size_type size() const
Size of the RefVector.
Definition: RefVector.h:107
virtual void setMass(double m) final
set particle mass
void set(reco::Candidate &c) const
set up a candidate
std::auto_ptr< StringCutObjectSelector< reco::RecoTauPiZero > > outputSelector_
def move(src, dest)
Definition: eostools.py:510
std::auto_ptr< PiZeroPredicate > predicate_

Member Data Documentation

builderList RecoTauPiZeroProducer::builders_
private

Definition at line 60 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

edm::EDGetTokenT<reco::CandidateView> 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::auto_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 63 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

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

Definition at line 62 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

rankerList RecoTauPiZeroProducer::rankers_
private

Definition at line 61 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().