CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
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
 
 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 & 
itemsToGetFromEvent () 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
< Builder
builderList
 
typedef boost::ptr_list
< reco::RecoTauPiZero
PiZeroList
 
typedef
reco::tau::RecoTauLexicographicalRanking
< rankerList,
reco::RecoTauPiZero
PiZeroPredicate
 
typedef boost::ptr_vector
< reco::RecoTauPiZero
PiZeroVector
 
typedef boost::ptr_vector< RankerrankerList
 

Private Attributes

builderList builders_
 
edm::EDGetTokenT
< reco::CandidateView
cand_token
 
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 75 of file RecoTauPiZeroProducer.cc.

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

76 {
77  cand_token = consumes<reco::CandidateView>( pset.getParameter<edm::InputTag>("jetSrc"));
78 
79  typedef std::vector<edm::ParameterSet> VPSet;
80  // Get the mass hypothesis for the pizeros
81  piZeroMass_ = pset.getParameter<double>("massHypothesis");
82 
83  // Get each of our PiZero builders
84  const VPSet& builders = pset.getParameter<VPSet>("builders");
85 
86  for (VPSet::const_iterator builderPSet = builders.begin();
87  builderPSet != builders.end(); ++builderPSet) {
88  // Get plugin name
89  const std::string& pluginType =
90  builderPSet->getParameter<std::string>("plugin");
91  // Build the plugin
93  pluginType, *builderPSet, consumesCollector()));
94  }
95 
96  // Get each of our quality rankers
97  const VPSet& rankers = pset.getParameter<VPSet>("ranking");
98  for (VPSet::const_iterator rankerPSet = rankers.begin();
99  rankerPSet != rankers.end(); ++rankerPSet) {
100  const std::string& pluginType =
101  rankerPSet->getParameter<std::string>("plugin");
103  pluginType, *rankerPSet));
104  }
105 
106  // Build the sorting predicate
107  predicate_ = std::auto_ptr<PiZeroPredicate>(new PiZeroPredicate(rankers_));
108 
109  // Check if we want to apply a final output selection
110  if (pset.exists("outputSelection")) {
111  std::string selection = pset.getParameter<std::string>("outputSelection");
112  if (selection != "") {
113  outputSelector_.reset(
115  }
116  }
117 
118  verbosity_ = ( pset.exists("verbosity") ) ?
119  pset.getParameter<int>("verbosity") : 0;
120 
121  produces<reco::JetPiZeroAssociation>();
122 }
T getParameter(std::string const &) const
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.

46 {}

Member Function Documentation

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

Definition at line 231 of file RecoTauPiZeroProducer.cc.

References rankers_, and create_public_lumi_plots::width.

Referenced by produce().

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

Implements edm::stream::EDProducerBase.

Definition at line 124 of file RecoTauPiZeroProducer.cc.

References builders_, cand_token, gather_cfg::cout, cppFunctionSkipper::exception, edm::Event::get(), edm::Event::getByToken(), edm::RefVector< C, T, F >::id(), metsig::jet, edm::Ref< C, T, F >::key(), 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(), makeLayoutFileForGui::toAdd, and verbosity_.

125 {
126  // Get a view of our jets via the base candidates
128  evt.getByToken(cand_token, jetView);
129 
130  // Give each of our plugins a chance at doing something with the edm::Event
131  BOOST_FOREACH(Builder& builder, builders_) {
132  builder.setup(evt, es);
133  }
134 
135  // Convert the view to a RefVector of actual PFJets
136  reco::PFJetRefVector jetRefs =
137  reco::tau::castView<reco::PFJetRefVector>(jetView);
138  // Make our association
139  std::unique_ptr<reco::JetPiZeroAssociation> association;
140 
141  if (jetRefs.size()) {
142  edm::Handle<reco::PFJetCollection> pfJetCollectionHandle;
143  evt.get(jetRefs.id(), pfJetCollectionHandle);
144  association = std::make_unique<reco::JetPiZeroAssociation>(reco::PFJetRefProd(pfJetCollectionHandle));
145  } else {
146  association = std::make_unique<reco::JetPiZeroAssociation>();
147  }
148 
149  // Loop over our jets
150  BOOST_FOREACH(const reco::PFJetRef& jet, jetRefs) {
151  // Build our global list of RecoTauPiZero
152  PiZeroList dirtyPiZeros;
153 
154  // Compute the pi zeros from this jet for all the desired algorithms
155  BOOST_FOREACH(const Builder& builder, builders_) {
156  try {
157  PiZeroVector result(builder(*jet));
158  dirtyPiZeros.transfer(dirtyPiZeros.end(), result);
159  } catch ( cms::Exception &exception) {
160  edm::LogError("BuilderPluginException")
161  << "Exception caught in builder plugin " << builder.name()
162  << ", rethrowing" << std::endl;
163  throw exception;
164  }
165  }
166  // Rank the candidates according to our quality plugins
167  dirtyPiZeros.sort(*predicate_);
168 
169  // Keep track of the photons in the clean collection
170  std::vector<reco::RecoTauPiZero> cleanPiZeros;
171  std::set<reco::CandidatePtr> photonsInCleanCollection;
172  while (dirtyPiZeros.size()) {
173  // Pull our candidate pi zero from the front of the list
174  std::auto_ptr<reco::RecoTauPiZero> toAdd(
175  dirtyPiZeros.pop_front().release());
176  // If this doesn't pass our basic selection, discard it.
177  if (!(*outputSelector_)(*toAdd)) {
178  continue;
179  }
180  // Find the sub-gammas that are not already in the cleaned collection
181  std::vector<reco::CandidatePtr> uniqueGammas;
182  std::set_difference(toAdd->daughterPtrVector().begin(),
183  toAdd->daughterPtrVector().end(),
184  photonsInCleanCollection.begin(),
185  photonsInCleanCollection.end(),
186  std::back_inserter(uniqueGammas));
187  // If the pi zero has no unique gammas, discard it. Note toAdd is deleted
188  // when it goes out of scope.
189  if (!uniqueGammas.size()) {
190  continue;
191  } else if (uniqueGammas.size() == toAdd->daughterPtrVector().size()) {
192  // Check if it is composed entirely of unique gammas. In this case
193  // immediately add it to the clean collection.
194  photonsInCleanCollection.insert(toAdd->daughterPtrVector().begin(),
195  toAdd->daughterPtrVector().end());
196  cleanPiZeros.push_back(*toAdd);
197  } else {
198  // Otherwise update the pizero that contains only the unique gammas and
199  // add it back into the sorted list of dirty PiZeros
200  toAdd->clearDaughters();
201  // Add each of the unique daughters back to the pizero
202  BOOST_FOREACH(const reco::CandidatePtr& gamma, uniqueGammas) {
203  toAdd->addDaughter(gamma);
204  }
205  // Update the four vector
206  AddFourMomenta p4Builder_;
207  p4Builder_.set(*toAdd);
208  // Put this pi zero back into the collection of sorted dirty pizeros
209  PiZeroList::iterator insertionPoint = std::lower_bound(
210  dirtyPiZeros.begin(), dirtyPiZeros.end(), *toAdd, *predicate_);
211  dirtyPiZeros.insert(insertionPoint, toAdd);
212  }
213  }
214  // Apply the mass hypothesis if desired
215  if (piZeroMass_ >= 0) {
216  std::for_each(
217  cleanPiZeros.begin(), cleanPiZeros.end(),
218  std::bind2nd(
219  std::mem_fun_ref(&reco::RecoTauPiZero::setMass), piZeroMass_));
220  }
221  // Add to association
222  if ( verbosity_ >= 2 ) {
223  print(cleanPiZeros, std::cout);
224  }
225  association->setValue(jet.key(), cleanPiZeros);
226  }
227  evt.put(std::move(association));
228 }
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:457
key_type key() const
Accessor for product key.
Definition: Ref.h:264
void print(const std::vector< reco::RecoTauPiZero > &piZeros, std::ostream &out)
tuple result
Definition: mps_fire.py:84
reco::tau::RecoTauPiZeroBuilderPlugin Builder
ProductID id() const
Accessor for product ID.
Definition: RefVector.h:122
def move
Definition: eostools.py:510
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:331
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
tuple cout
Definition: gather_cfg.py:145
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_
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().

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 72 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().