CMS 3D CMS Logo

PhotonIDProducer.cc

Go to the documentation of this file.
00001 #include "RecoEgamma/PhotonIdentification/plugins/PhotonIDProducer.h"
00002 #include "DataFormats/EgammaCandidates/interface/PhotonID.h"
00003 #include "DataFormats/EgammaCandidates/interface/PhotonIDAssociation.h"
00004 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00005 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
00006 
00007 //void PhotonIDProducer::beginJob(edm::EventSetup const& iSetup) {
00008   //Otherwise we're just going to do our calculations.  This will
00009   //set a bool for passing the cut based criteria, nothing else.
00010   // if (doCutBased_) cutBasedAlgo_->setup(conf_);
00011 
00012 //}
00013 
00014 
00015 PhotonIDProducer::PhotonIDProducer(const edm::ParameterSet& conf) : conf_(conf) {
00016 
00017   photonProducer_ = conf_.getParameter<std::string>("photonProducer");
00018   photonLabel_ = conf_.getParameter<std::string>("photonLabel");
00019   photonIDLabel_ = conf_.getParameter<std::string>("photonIDLabel");
00020   photonIDAssociation_ = conf_.getParameter<std::string>("photonIDAssociationLabel");
00021 
00022   doCutBased_ = conf_.getParameter<bool>("doCutBased");
00023   cutBasedAlgo_ = new CutBasedPhotonIDAlgo();
00024   cutBasedAlgo_->setup(conf);
00025   produces<reco::PhotonIDCollection>(photonIDLabel_);
00026   produces<reco::PhotonIDAssociationCollection>(photonIDAssociation_);
00027 
00028 }
00029 
00030 PhotonIDProducer::~PhotonIDProducer() {
00031 
00032   //if (doCutBased_)
00033   delete cutBasedAlgo_;
00034 
00035 }
00036 
00037 void PhotonIDProducer::produce(edm::Event& e, const edm::EventSetup& c) {
00038 
00039   // Read in photons
00040   edm::Handle<reco::PhotonCollection> photons;
00041   e.getByLabel(photonProducer_,photonLabel_,photons);
00042 
00043   // Initialize output photon ID collection
00044   reco::PhotonIDCollection photonIDCollection;
00045   std::auto_ptr<reco::PhotonIDCollection> photonIDCollection_p(new reco::PhotonIDCollection);
00046 
00047   // Loop over photons and calculate photon ID using specified technique(s)
00048   reco::PhotonCollection::const_iterator photon;
00049   for (photon = (*photons).begin();
00050        photon != (*photons).end(); ++photon) {
00051     reco::PhotonID phoID = cutBasedAlgo_->calculate(&(*photon),e, c);
00052     photonIDCollection.push_back(phoID);
00053   }
00054   
00055   // Add output electron ID collection to the event
00056   photonIDCollection_p->assign(photonIDCollection.begin(),
00057                                photonIDCollection.end());
00058   edm::OrphanHandle<reco::PhotonIDCollection> PhotonIDHandle = e.put(photonIDCollection_p,photonIDLabel_);
00059   
00060   // Add photon ID AssociationMap to the event
00061   std::auto_ptr<reco::PhotonIDAssociationCollection> photonIDAssocs_p(new reco::PhotonIDAssociationCollection);
00062   for (unsigned int i = 0; i < photons->size(); i++){
00063     photonIDAssocs_p->insert(edm::Ref<reco::PhotonCollection>(photons,i),edm::Ref<reco::PhotonIDCollection>(PhotonIDHandle,i));
00064   }
00065   e.put(photonIDAssocs_p,photonIDAssociation_);
00066   
00067 }

Generated on Tue Jun 9 17:43:34 2009 for CMSSW by  doxygen 1.5.4