CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RecoTauPiZeroCombinatoricPlugin.cc
Go to the documentation of this file.
1 /*
2  * RecoTauPiZeroCombinatoricPlugin
3  *
4  * Author: Evan K. Friis, UC Davis
5  *
6  * Build PiZero candidates out of all possible sets of <choose> gammas that are
7  * contained in the input PFJet. Optionally, the pi zero candidates are
8  * filtered by a min and max selection on their invariant mass.
9  *
10  */
11 
12 #include <algorithm>
13 
19 
23 
25 
26 namespace reco {
27  namespace tau {
28 
30  public:
33  // Return type is unique_ptr<PiZeroVector>
34  return_type operator()(const reco::Jet& jet) const override;
35 
36  private:
38  double minMass_;
39  double maxMass_;
40  unsigned int maxInputGammas_;
41  unsigned int choose_;
43  };
44 
47  : RecoTauPiZeroBuilderPlugin(pset, std::move(iC)),
48  qcuts_(pset.getParameterSet("qualityCuts").getParameterSet("signalQualityCuts")) {
49  minMass_ = pset.getParameter<double>("minMass");
50  maxMass_ = pset.getParameter<double>("maxMass");
51  maxInputGammas_ = pset.getParameter<unsigned int>("maxInputGammas");
52  choose_ = pset.getParameter<unsigned int>("choose");
53  }
54 
56  const reco::Jet& jet) const {
57  // Get list of gamma candidates
58  typedef std::vector<reco::CandidatePtr> CandPtrs;
59  typedef CandPtrs::const_iterator CandIter;
61 
62  CandPtrs pfGammaCands = qcuts_.filterCandRefs(pfGammas(jet));
63  // Check if we have anything to do...
64  if (pfGammaCands.size() < choose_)
65  return output;
66 
67  // Define the valid range of gammas to use
68  CandIter start_iter = pfGammaCands.begin();
69  CandIter end_iter = pfGammaCands.end();
70 
71  // Only take the desired number of piZeros
72  end_iter = takeNElements(start_iter, end_iter, maxInputGammas_);
73 
74  // Build the combinatoric generator
75  typedef CombinatoricGenerator<CandPtrs> ComboGenerator;
76  ComboGenerator generator(start_iter, end_iter, choose_);
77 
78  // Find all possible combinations
79  for (ComboGenerator::iterator combo = generator.begin(); combo != generator.end(); ++combo) {
80  const Candidate::LorentzVector totalP4;
81  std::unique_ptr<RecoTauPiZero> piZero(
82  new RecoTauPiZero(0, totalP4, Candidate::Point(0, 0, 0), 111, 10001, true, RecoTauPiZero::kCombinatoric));
83  // Add our daughters from this combination
84  for (auto candidate = combo->combo_begin(); candidate != combo->combo_end(); ++candidate) {
85  piZero->addDaughter(*candidate);
86  }
87  p4Builder_.set(*piZero);
88 
89  if (piZero->daughterPtr(0).isNonnull())
90  piZero->setVertex(piZero->daughterPtr(0)->vertex());
91 
92  if ((maxMass_ < 0 || piZero->mass() < maxMass_) && piZero->mass() > minMass_)
93  output.emplace_back(piZero.release());
94  }
95  return output;
96  }
97 
98  } // namespace tau
99 } // namespace reco
100 
104  "RecoTauPiZeroCombinatoricPlugin");
InputIterator takeNElements(const InputIterator &begin, const InputIterator &end, size_t N)
RecoTauPiZeroCombinatoricPlugin(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
Coll filterCandRefs(const Coll &refcoll, bool invert=false) const
Filter a ref vector of Candidates.
Base class for all types of Jets.
Definition: Jet.h:20
ParameterSet const & getParameterSet(ParameterSetID const &id)
std::vector< reco::CandidatePtr > CandPtrs
return_type operator()(const reco::Jet &jet) const override
Build a collection of piZeros from objects in the input jet.
def move
Definition: eostools.py:511
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< std::unique_ptr< RecoTauPiZero > > PiZeroVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
math::XYZPoint Point
point in the space
Definition: Candidate.h:40
#define DEFINE_EDM_PLUGIN(factory, type, name)
void set(reco::Candidate &c) const
set up a candidate
CandPtrs::iterator CandIter
std::vector< CandidatePtr > pfGammas(const Jet &jet, bool sort=true)
Extract all pfGammas from a PFJet.