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::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Types

typedef
reco::tau::RecoTauPiZeroBuilderPlugin 
Builder
 
typedef
reco::tau::RecoTauPiZeroQualityPlugin 
Ranker
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

void print (const std::vector< reco::RecoTauPiZero > &piZeros, std::ostream &out)
 
void produce (edm::Event &evt, const edm::EventSetup &es)
 
 RecoTauPiZeroProducer (const edm::ParameterSet &pset)
 
 ~RecoTauPiZeroProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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_
 
std::auto_ptr
< StringCutObjectSelector
< reco::RecoTauPiZero > > 
outputSelector_
 
double piZeroMass_
 
std::auto_ptr< PiZeroPredicatepredicate_
 
rankerList rankers_
 
edm::InputTag src_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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

References builders_, SurfaceDeformationFactory::create(), edm::ParameterSet::exists(), reco::get(), edm::ParameterSet::getParameter(), outputSelector_, piZeroMass_, predicate_, rankers_, corrVsCorr::selection, and src_.

71  {
72  src_ = pset.getParameter<edm::InputTag>("jetSrc");
73 
74  typedef std::vector<edm::ParameterSet> VPSet;
75  // Get the mass hypothesis for the pizeros
76  piZeroMass_ = pset.getParameter<double>("massHypothesis");
77 
78  // Get each of our PiZero builders
79  const VPSet& builders = pset.getParameter<VPSet>("builders");
80 
81  for (VPSet::const_iterator builderPSet = builders.begin();
82  builderPSet != builders.end(); ++builderPSet) {
83  // Get plugin name
84  const std::string& pluginType =
85  builderPSet->getParameter<std::string>("plugin");
86  // Build the plugin
88  pluginType, *builderPSet));
89  }
90 
91  // Get each of our quality rankers
92  const VPSet& rankers = pset.getParameter<VPSet>("ranking");
93  for (VPSet::const_iterator rankerPSet = rankers.begin();
94  rankerPSet != rankers.end(); ++rankerPSet) {
95  const std::string& pluginType =
96  rankerPSet->getParameter<std::string>("plugin");
98  pluginType, *rankerPSet));
99  }
100 
101  // Build the sorting predicate
102  predicate_ = std::auto_ptr<PiZeroPredicate>(new PiZeroPredicate(rankers_));
103 
104  // Check if we want to apply a final output selection
105  if (pset.exists("outputSelection")) {
106  std::string selection = pset.getParameter<std::string>("outputSelection");
107  if (selection != "") {
108  outputSelector_.reset(
110  }
111  }
112 
113  produces<reco::JetPiZeroAssociation>();
114 }
T getParameter(std::string const &) const
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
std::auto_ptr< StringCutObjectSelector< reco::RecoTauPiZero > > outputSelector_
SurfaceDeformation * create(int type, const std::vector< double > &params)
T get(const Candidate &c)
Definition: component.h:56
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 220 of file RecoTauPiZeroProducer.cc.

References rankers_, and tablePrinter::width.

221  {
222  const unsigned int width = 25;
223  BOOST_FOREACH(const reco::RecoTauPiZero& piZero, piZeros) {
224  out << piZero;
225  out << "* Rankers:" << std::endl;
226  for (rankerList::const_iterator ranker = rankers_.begin();
227  ranker != rankers_.end(); ++ranker) {
228  out << "* " << std::setiosflags(std::ios::left)
229  << std::setw(width) << ranker->name()
230  << " " << std::resetiosflags(std::ios::left)
231  << std::setprecision(3) << (*ranker)(piZero);
232  out << std::endl;
233  }
234  }
235 }
tuple out
Definition: dbtoconf.py:99
void RecoTauPiZeroProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 116 of file RecoTauPiZeroProducer.cc.

References builders_, cppFunctionSkipper::exception, edm::Event::getByLabel(), metsig::jet, edm::Ref< C, T, F >::key(), reco::tau::RecoTauNamedPlugin::name(), outputSelector_, piZeroMass_, predicate_, edm::Event::put(), query::result, AddFourMomenta::set(), reco::LeafCandidate::setMass(), reco::tau::RecoTauEventHolderPlugin::setup(), edm::RefVector< C, T, F >::size(), src_, and makeLayoutFileForGui::toAdd.

117  {
118  // Get a view of our jets via the base candidates
120  evt.getByLabel(src_, jetView);
121 
122  // Give each of our plugins a chance at doing something with the edm::Event
123  BOOST_FOREACH(Builder& builder, builders_) {
124  builder.setup(evt, es);
125  }
126 
127  // Convert the view to a RefVector of actual PFJets
128  reco::PFJetRefVector jetRefs =
129  reco::tau::castView<reco::PFJetRefVector>(jetView);
130  // Make our association
131  std::auto_ptr<reco::JetPiZeroAssociation> association;
132 
133  if (jetRefs.size()) {
134  association.reset(
136  } else {
137  association.reset(new reco::JetPiZeroAssociation);
138  }
139 
140  // Loop over our jets
141  BOOST_FOREACH(const reco::PFJetRef& jet, jetRefs) {
142  // Build our global list of RecoTauPiZero
143  PiZeroList dirtyPiZeros;
144 
145  // Compute the pi zeros from this jet for all the desired algorithms
146  BOOST_FOREACH(const Builder& builder, builders_) {
147  try {
148  PiZeroVector result(builder(*jet));
149  dirtyPiZeros.transfer(dirtyPiZeros.end(), result);
150  } catch ( cms::Exception &exception) {
151  edm::LogError("BuilderPluginException")
152  << "Exception caught in builder plugin " << builder.name()
153  << ", 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.size()) {
164  // Pull our candidate pi zero from the front of the list
165  std::auto_ptr<reco::RecoTauPiZero> toAdd(
166  dirtyPiZeros.pop_front().release());
167  // If this doesn't pass our basic selection, discard it.
168  if (!(*outputSelector_)(*toAdd)) {
169  continue;
170  }
171  // Find the sub-gammas that are not already in the cleaned collection
172  std::vector<reco::CandidatePtr> uniqueGammas;
173  std::set_difference(toAdd->daughterPtrVector().begin(),
174  toAdd->daughterPtrVector().end(),
175  photonsInCleanCollection.begin(),
176  photonsInCleanCollection.end(),
177  std::back_inserter(uniqueGammas));
178  // If the pi zero has no unique gammas, discard it. Note toAdd is deleted
179  // when it goes out of scope.
180  if (!uniqueGammas.size()) {
181  continue;
182  } else if (uniqueGammas.size() == toAdd->daughterPtrVector().size()) {
183  // Check if it is composed entirely of unique gammas. In this case
184  // immediately add it to the clean collection.
185  photonsInCleanCollection.insert(toAdd->daughterPtrVector().begin(),
186  toAdd->daughterPtrVector().end());
187  cleanPiZeros.push_back(*toAdd);
188  } else {
189  // Otherwise update the pizero that contains only the unique gammas and
190  // add it back into the sorted list of dirty PiZeros
191  toAdd->clearDaughters();
192  // Add each of the unique daughters back to the pizero
193  BOOST_FOREACH(const reco::CandidatePtr& gamma, uniqueGammas) {
194  toAdd->addDaughter(gamma);
195  }
196  // Update the four vector
197  AddFourMomenta p4Builder_;
198  p4Builder_.set(*toAdd);
199  // Put this pi zero back into the collection of sorted dirty pizeros
200  PiZeroList::iterator insertionPoint = std::lower_bound(
201  dirtyPiZeros.begin(), dirtyPiZeros.end(), *toAdd, *predicate_);
202  dirtyPiZeros.insert(insertionPoint, toAdd);
203  }
204  }
205  // Apply the mass hypothesis if desired
206  if (piZeroMass_ >= 0) {
207  std::for_each(
208  cleanPiZeros.begin(), cleanPiZeros.end(),
209  std::bind2nd(
210  std::mem_fun_ref(&reco::RecoTauPiZero::setMass), piZeroMass_));
211  }
212  // Add to association
213  //print(cleanPiZeros, std::cout);
214  association->setValue(jet.key(), cleanPiZeros);
215  }
216  evt.put(association);
217 }
reco::tau::RecoTauPiZeroBuilderPlugin Builder
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
tuple result
Definition: query.py:137
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
boost::ptr_vector< reco::RecoTauPiZero > PiZeroVector
boost::ptr_list< reco::RecoTauPiZero > PiZeroList
key_type key() const
Accessor for product key.
Definition: Ref.h:266
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
void set(reco::Candidate &c) const
set up a candidate
std::auto_ptr< StringCutObjectSelector< reco::RecoTauPiZero > > outputSelector_
virtual void setMass(double m)
set particle mass
std::auto_ptr< PiZeroPredicate > predicate_

Member Data Documentation

builderList RecoTauPiZeroProducer::builders_
private

Definition at line 61 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().

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

Definition at line 68 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::auto_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().

edm::InputTag RecoTauPiZeroProducer::src_
private

Definition at line 60 of file RecoTauPiZeroProducer.cc.

Referenced by produce(), and RecoTauPiZeroProducer().