CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/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.getParameterSet(
00048           "qualityCuts").getParameterSet("signalQualityCuts")) {
00049   minMass_ = pset.getParameter<double>("minMass");
00050   maxMass_ = pset.getParameter<double>("maxMass");
00051   maxInputGammas_ = pset.getParameter<unsigned int>("maxInputGammas");
00052   choose_ = pset.getParameter<unsigned int>("choose");
00053 }
00054 
00055 RecoTauPiZeroCombinatoricPlugin::return_type
00056 RecoTauPiZeroCombinatoricPlugin::operator()(
00057     const reco::PFJet& jet) const {
00058   // Get list of gamma candidates
00059   typedef std::vector<reco::PFCandidatePtr> PFCandPtrs;
00060   typedef PFCandPtrs::const_iterator PFCandIter;
00061   PiZeroVector output;
00062 
00063   PFCandPtrs pfGammaCands = qcuts_.filterRefs(pfGammas(jet));
00064   // Check if we have anything to do...
00065   if (pfGammaCands.size() < choose_)
00066     return output.release();
00067 
00068   // Define the valid range of gammas to use
00069   PFCandIter start_iter = pfGammaCands.begin();
00070   PFCandIter end_iter = pfGammaCands.end();
00071 
00072   // Only take the desired number of piZeros
00073   end_iter = takeNElements(start_iter, end_iter, maxInputGammas_);
00074 
00075   // Build the combinatoric generator
00076   typedef CombinatoricGenerator<PFCandPtrs> ComboGenerator;
00077   ComboGenerator generator(start_iter, end_iter, choose_);
00078 
00079   // Find all possible combinations
00080   for (ComboGenerator::iterator combo = generator.begin();
00081       combo != generator.end(); ++combo) {
00082     const Candidate::LorentzVector totalP4;
00083     std::auto_ptr<RecoTauPiZero> piZero(
00084         new RecoTauPiZero(0, totalP4, Candidate::Point(0, 0, 0),
00085                           111, 10001, true, RecoTauPiZero::kCombinatoric));
00086     // Add our daughters from this combination
00087     for (ComboGenerator::combo_iterator candidate = combo->combo_begin();
00088         candidate != combo->combo_end();  ++candidate) {
00089       piZero->addDaughter(*candidate);
00090     }
00091     p4Builder_.set(*piZero);
00092 
00093     if (piZero->daughterPtr(0).isNonnull())
00094       piZero->setVertex(piZero->daughterPtr(0)->vertex());
00095 
00096     if ((maxMass_ < 0 || piZero->mass() < maxMass_) &&
00097         piZero->mass() > minMass_)
00098       output.push_back(piZero);
00099   }
00100   return output.release();
00101 }
00102 
00103 }}  // end namespace reco::tau
00104 
00105 #include "FWCore/Framework/interface/MakerMacros.h"
00106 DEFINE_EDM_PLUGIN(RecoTauPiZeroBuilderPluginFactory,
00107     reco::tau::RecoTauPiZeroCombinatoricPlugin,
00108     "RecoTauPiZeroCombinatoricPlugin");