Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-25 04:55:29

0001 /*
0002  * RecoTauPiZeroCombinatoricPlugin
0003  *
0004  * Author: Evan K. Friis, UC Davis
0005  *
0006  * Build PiZero candidates out of all possible sets of <choose> gammas that are
0007  * contained in the input PFJet.  Optionally, the pi zero candidates are
0008  * filtered by a min and max selection on their invariant mass.
0009  *
0010  */
0011 
0012 #include <algorithm>
0013 
0014 #include "RecoTauTag/RecoTau/interface/RecoTauPiZeroPlugins.h"
0015 #include "DataFormats/TauReco/interface/RecoTauPiZero.h"
0016 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0017 #include "DataFormats/Candidate/interface/Candidate.h"
0018 #include "DataFormats/JetReco/interface/PFJet.h"
0019 
0020 #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h"
0021 #include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h"
0022 #include "RecoTauTag/RecoTau/interface/CombinatoricGenerator.h"
0023 
0024 #include "CommonTools/CandUtils/interface/AddFourMomenta.h"
0025 
0026 namespace reco {
0027   namespace tau {
0028 
0029     class RecoTauPiZeroCombinatoricPlugin : public RecoTauPiZeroBuilderPlugin {
0030     public:
0031       explicit RecoTauPiZeroCombinatoricPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector&& iC);
0032       ~RecoTauPiZeroCombinatoricPlugin() override {}
0033       // Return type is unique_ptr<PiZeroVector>
0034       return_type operator()(const reco::Jet& jet) const override;
0035 
0036     private:
0037       RecoTauQualityCuts qcuts_;
0038       double minMass_;
0039       double maxMass_;
0040       unsigned int maxInputGammas_;
0041       unsigned int choose_;
0042       AddFourMomenta p4Builder_;
0043     };
0044 
0045     RecoTauPiZeroCombinatoricPlugin::RecoTauPiZeroCombinatoricPlugin(const edm::ParameterSet& pset,
0046                                                                      edm::ConsumesCollector&& iC)
0047         : RecoTauPiZeroBuilderPlugin(pset, std::move(iC)),
0048           qcuts_(pset.getParameterSet("qualityCuts").getParameterSet("signalQualityCuts")) {
0049       minMass_ = pset.getParameter<double>("minMass");
0050       maxMass_ = pset.getParameter<double>("maxMass");
0051       maxInputGammas_ = pset.getParameter<unsigned int>("maxInputGammas");
0052       choose_ = pset.getParameter<unsigned int>("choose");
0053     }
0054 
0055     RecoTauPiZeroCombinatoricPlugin::return_type RecoTauPiZeroCombinatoricPlugin::operator()(
0056         const reco::Jet& jet) const {
0057       // Get list of gamma candidates
0058       typedef std::vector<reco::CandidatePtr> CandPtrs;
0059       typedef CandPtrs::const_iterator CandIter;
0060       PiZeroVector output;
0061 
0062       CandPtrs pfGammaCands = qcuts_.filterCandRefs(pfGammas(jet));
0063       // Check if we have anything to do...
0064       if (pfGammaCands.size() < choose_)
0065         return output;
0066 
0067       // Define the valid range of gammas to use
0068       CandIter start_iter = pfGammaCands.begin();
0069       CandIter end_iter = pfGammaCands.end();
0070 
0071       // Only take the desired number of piZeros
0072       end_iter = takeNElements(start_iter, end_iter, maxInputGammas_);
0073 
0074       // Build the combinatoric generator
0075       typedef CombinatoricGenerator<CandPtrs> ComboGenerator;
0076       ComboGenerator generator(start_iter, end_iter, choose_);
0077 
0078       // Find all possible combinations
0079       for (ComboGenerator::iterator combo = generator.begin(); combo != generator.end(); ++combo) {
0080         const Candidate::LorentzVector totalP4;
0081         std::unique_ptr<RecoTauPiZero> piZero(
0082             new RecoTauPiZero(0, totalP4, Candidate::Point(0, 0, 0), 111, 10001, true, RecoTauPiZero::kCombinatoric));
0083         // Add our daughters from this combination
0084         for (auto candidate = combo->combo_begin(); candidate != combo->combo_end(); ++candidate) {
0085           piZero->addDaughter(*candidate);
0086         }
0087         p4Builder_.set(*piZero);
0088 
0089         if (piZero->daughterPtr(0).isNonnull())
0090           piZero->setVertex(piZero->daughterPtr(0)->vertex());
0091 
0092         if ((maxMass_ < 0 || piZero->mass() < maxMass_) && piZero->mass() > minMass_)
0093           output.emplace_back(piZero.release());
0094       }
0095       return output;
0096     }
0097 
0098   }  // namespace tau
0099 }  // namespace reco
0100 
0101 #include "FWCore/Framework/interface/MakerMacros.h"
0102 DEFINE_EDM_PLUGIN(RecoTauPiZeroBuilderPluginFactory,
0103                   reco::tau::RecoTauPiZeroCombinatoricPlugin,
0104                   "RecoTauPiZeroCombinatoricPlugin");