CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/RecoMET/METAlgorithms/src/SignPFSpecificAlgo.cc

Go to the documentation of this file.
00001 /*
00002  class: SignPFSpecificAlgo.cc
00003  description:  add the infrastructure to compute the jet-based significance for MET computed with particle flow
00004  authors: A. Khukhunaishvili (Cornell), L. Gibbons (Cornell)
00005  date: 11/11/10
00006  */
00007 
00008 #include "RecoMET/METAlgorithms/interface/SignPFSpecificAlgo.h"
00009 
00010 metsig::SignPFSpecificAlgo::SignPFSpecificAlgo(): 
00011 resolutions_(0),
00012 algo_()
00013 {clusteredParticlePtrs_.clear();}
00014 
00015 metsig::SignPFSpecificAlgo::~SignPFSpecificAlgo(){}
00016 
00017 void 
00018 metsig::SignPFSpecificAlgo::setResolutions( metsig::SignAlgoResolutions *resolutions) {
00019   resolutions_ = resolutions;
00020 }
00021 
00022 
00023 void 
00024 metsig::SignPFSpecificAlgo::addPFJets(edm::Handle<edm::View<reco::PFJet> > PFJets){
00025     std::vector<metsig::SigInputObj> vobj;
00026     for(edm::View<reco::PFJet>::const_iterator jet = PFJets->begin(); jet != PFJets->end(); ++jet){
00027         vobj.push_back(resolutions_->evalPFJet(&(*jet)));
00028         std::vector<reco::PFCandidatePtr> pfs = jet->getPFConstituents();
00029         for(std::vector<reco::PFCandidatePtr>::const_iterator it=pfs.begin(); it!=pfs.end(); ++it){
00030             reco::CandidatePtr ptr(*it);
00031             clusteredParticlePtrs_.insert(ptr);
00032         }
00033     }
00034     algo_.addObjects(vobj);
00035 }
00036 
00037 void 
00038 metsig::SignPFSpecificAlgo::useOriginalPtrs(const edm::ProductID& productID){
00039     std::set<reco::CandidatePtr>::const_iterator it=clusteredParticlePtrs_.begin();
00040     reco::CandidatePtr ptr(*it);
00041     if(ptr.id()==productID) return; //If the first element is from the right product, return
00042 
00043     std::set<reco::CandidatePtr> temp;
00044     for(; it!=clusteredParticlePtrs_.end(); ++it){
00045         reco::CandidatePtr ptr(*it);
00046         while(ptr.id()!=productID){
00047             ptr = ptr->sourceCandidatePtr(0);
00048             if(ptr.isNull()) return; //if it does not get to the correct product, return
00049         }
00050         temp.insert(ptr);
00051     }
00052     clusteredParticlePtrs_.clear();
00053     clusteredParticlePtrs_ = temp;
00054 }
00055 
00056 void
00057 metsig::SignPFSpecificAlgo::addPFCandidate(reco::PFCandidatePtr pf){
00058     if(clusteredParticlePtrs_.find(pf) != clusteredParticlePtrs_.end()) {
00059         return; //pf candidate already added in jet collection
00060     }
00061     std::vector<metsig::SigInputObj> vobj;
00062     vobj.push_back(resolutions_->evalPF(&(*pf)));
00063     algo_.addObjects(vobj);
00064 }
00065