CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoTauTag/RecoTau/plugins/RecoTauPiZeroCombinatoricPlugin.cc

Go to the documentation of this file.
00001 /*
00002  * RecoTauPiZeroCombinatoricPlugin
00003  *
00004  * Author: Evan K. Friis, UC Davis
00005  *
00006  * Build PiZero candidates out of all possible sets of <choose> gammas that are
00007  * contained in the input PFJet.  Optionally, the pi zero candidates are
00008  * filtered by a min and max selection on their invariant mass.
00009  *
00010  * $Id $
00011  */
00012 
00013 #include <algorithm>
00014 
00015 #include "RecoTauTag/RecoTau/interface/RecoTauPiZeroPlugins.h"
00016 #include "DataFormats/TauReco/interface/RecoTauPiZero.h"
00017 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
00018 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00019 #include "DataFormats/JetReco/interface/PFJet.h"
00020 
00021 #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h"
00022 #include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h"
00023 #include "RecoTauTag/RecoTau/interface/CombinatoricGenerator.h"
00024 
00025 #include "CommonTools/CandUtils/interface/AddFourMomenta.h"
00026 
00027 namespace reco { namespace tau {
00028 
00029 class RecoTauPiZeroCombinatoricPlugin : public RecoTauPiZeroBuilderPlugin {
00030   public:
00031     explicit RecoTauPiZeroCombinatoricPlugin(const edm::ParameterSet& pset);
00032     ~RecoTauPiZeroCombinatoricPlugin() {}
00033     // Return type is auto_ptr<PiZeroVector>
00034     return_type operator()(const reco::PFJet& jet) const;
00035 
00036   private:
00037     RecoTauQualityCuts qcuts_;
00038     double minMass_;
00039     double maxMass_;
00040     unsigned int maxInputGammas_;
00041     unsigned int choose_;
00042     AddFourMomenta p4Builder_;
00043 };
00044 
00045 RecoTauPiZeroCombinatoricPlugin::RecoTauPiZeroCombinatoricPlugin(
00046     const edm::ParameterSet& pset):RecoTauPiZeroBuilderPlugin(pset),
00047     qcuts_(pset.getParameter<edm::ParameterSet>("qualityCuts")) {
00048   minMass_ = pset.getParameter<double>("minMass");
00049   maxMass_ = pset.getParameter<double>("maxMass");
00050   maxInputGammas_ = pset.getParameter<unsigned int>("maxInputGammas");
00051   choose_ = pset.getParameter<unsigned int>("choose");
00052 }
00053 
00054 RecoTauPiZeroCombinatoricPlugin::return_type
00055 RecoTauPiZeroCombinatoricPlugin::operator()(
00056     const reco::PFJet& jet) const {
00057   // Get list of gamma candidates
00058   typedef std::vector<reco::PFCandidatePtr> PFCandPtrs;
00059   typedef PFCandPtrs::const_iterator PFCandIter;
00060   PiZeroVector output;
00061 
00062   PFCandPtrs pfGammaCands = qcuts_.filterRefs(pfGammas(jet));
00063   // Check if we have anything to do...
00064   if (pfGammaCands.size() < choose_)
00065     return output.release();
00066 
00067   // Define the valid range of gammas to use
00068   PFCandIter start_iter = pfGammaCands.begin();
00069   PFCandIter end_iter = pfGammaCands.end();
00070 
00071   // Only take the desired number of piZeros
00072   end_iter = takeNElements(start_iter, end_iter, maxInputGammas_);
00073 
00074   // Build the combinatoric generator
00075   typedef CombinatoricGenerator<PFCandPtrs> ComboGenerator;
00076   ComboGenerator generator(start_iter, end_iter, choose_);
00077 
00078   // Find all possible combinations
00079   for (ComboGenerator::iterator combo = generator.begin();
00080       combo != generator.end(); ++combo) {
00081     const Candidate::LorentzVector totalP4;
00082     std::auto_ptr<RecoTauPiZero> piZero(
00083         new RecoTauPiZero(0, totalP4, Candidate::Point(0, 0, 0),
00084                           111, 10001, true, RecoTauPiZero::kCombinatoric));
00085     // Add our daughters from this combination
00086     for (ComboGenerator::combo_iterator candidate = combo->combo_begin();
00087         candidate != combo->combo_end();  ++candidate) {
00088       piZero->addDaughter(*candidate);
00089     }
00090     p4Builder_.set(*piZero);
00091 
00092     if (piZero->daughterPtr(0).isNonnull())
00093       piZero->setVertex(piZero->daughterPtr(0)->vertex());
00094 
00095     if ((maxMass_ < 0 || piZero->mass() < maxMass_) &&
00096         piZero->mass() > minMass_)
00097       output.push_back(piZero);
00098   }
00099   return output.release();
00100 }
00101 
00102 }}  // end namespace reco::tau
00103 
00104 #include "FWCore/Framework/interface/MakerMacros.h"
00105 DEFINE_EDM_PLUGIN(RecoTauPiZeroBuilderPluginFactory,
00106     reco::tau::RecoTauPiZeroCombinatoricPlugin,
00107     "RecoTauPiZeroCombinatoricPlugin");