CMS 3D CMS Logo

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.release();
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 (ComboGenerator::combo_iterator candidate = combo->combo_begin(); candidate != combo->combo_end();
85  ++candidate) {
86  piZero->addDaughter(*candidate);
87  }
88  p4Builder_.set(*piZero);
89 
90  if (piZero->daughterPtr(0).isNonnull())
91  piZero->setVertex(piZero->daughterPtr(0)->vertex());
92 
93  if ((maxMass_ < 0 || piZero->mass() < maxMass_) && piZero->mass() > minMass_)
94  output.push_back(piZero.get());
95  }
96  return output.release();
97  }
98 
99  } // namespace tau
100 } // namespace reco
101 
105  "RecoTauPiZeroCombinatoricPlugin");
T getParameter(std::string const &) const
InputIterator takeNElements(const InputIterator &begin, const InputIterator &end, size_t N)
RecoTauPiZeroCombinatoricPlugin(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
return_type operator()(const reco::Jet &jet) const override
Build a collection of piZeros from objects in the input jet.
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
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
fixed size matrix
boost::ptr_vector< RecoTauPiZero > PiZeroVector
math::XYZPoint Point
point in the space
Definition: Candidate.h:41
#define DEFINE_EDM_PLUGIN(factory, type, name)
void set(reco::Candidate &c) const
set up a candidate
CandPtrs::iterator CandIter
def move(src, dest)
Definition: eostools.py:511
std::vector< CandidatePtr > pfGammas(const Jet &jet, bool sort=true)
Extract all pfGammas from a PFJet.
std::unique_ptr< PiZeroVector > return_type