Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:57

0001 #include "TrackingSeedCandidates.h"
0002 
0003 TrackingSeedCandidates::TrackingSeedCandidates(const edm::ParameterSet& regPSet, edm::ConsumesCollector& iC) {
0004   // operation mode
0005   //
0006   std::string seedingModeString = regPSet.getParameter<std::string>("seedingMode");
0007   if (seedingModeString == "Candidate")
0008     m_seedingMode = SeedingMode::CANDIDATE_SEEDED;
0009   else if (seedingModeString == "Global")
0010     m_seedingMode = SeedingMode::GLOBAL;
0011   else
0012     throw edm::Exception(edm::errors::Configuration) << "Unknown seeding mode string: " << seedingModeString;
0013 
0014   m_deltaEta_Cand = regPSet.getParameter<double>("deltaEta_Cand");
0015   m_deltaPhi_Cand = regPSet.getParameter<double>("deltaPhi_Cand");
0016 
0017   // basic inputs
0018   if (m_seedingMode == SeedingMode::CANDIDATE_SEEDED) {
0019     m_token_input = iC.consumes<reco::CandidateView>(regPSet.getParameter<edm::InputTag>("input"));
0020     if (m_deltaEta_Cand < 0 || m_deltaPhi_Cand < 0)
0021       throw edm::Exception(edm::errors::Configuration)
0022           << "Delta eta and phi parameters must be set for candidates in candidate seeding mode";
0023   }
0024 }
0025 
0026 void TrackingSeedCandidates::fillDescriptions(edm::ParameterSetDescription& desc) {
0027   desc.add<std::string>("seedingMode", "Global");
0028   desc.add<edm::InputTag>("input", edm::InputTag());
0029   desc.add<double>("deltaEta_Cand", -1.);
0030   desc.add<double>("deltaPhi_Cand", -1.);
0031 }
0032 
0033 TrackingSeedCandidates::Objects TrackingSeedCandidates::objects(const edm::Event& iEvent) const {
0034   Objects result;
0035   std::pair<float, float> dimensions = std::make_pair(m_deltaEta_Cand, m_deltaPhi_Cand);
0036   edm::Handle<reco::CandidateView> objects;
0037 
0038   if (m_seedingMode == SeedingMode::CANDIDATE_SEEDED) {
0039     iEvent.getByToken(m_token_input, objects);
0040     result = std::make_pair(objects.product(), dimensions);
0041   } else
0042     result = std::make_pair(nullptr, dimensions);
0043   return result;
0044 }