CMS 3D CMS Logo

Public Member Functions | Private Attributes

PhotonIDProducer Class Reference

#include <PhotonIDProducer.h>

Inheritance diagram for PhotonIDProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 PhotonIDProducer (const edm::ParameterSet &conf)
virtual void produce (edm::Event &e, const edm::EventSetup &c)
virtual ~PhotonIDProducer ()

Private Attributes

edm::ParameterSet conf_
CutBasedPhotonIDAlgocutBasedAlgo_
bool doCutBased_
std::string photonCutBasedIDLooseEMLabel_
std::string photonCutBasedIDLooseLabel_
std::string photonCutBasedIDTightLabel_
std::string photonLabel_
std::string photonProducer_

Detailed Description

Definition at line 15 of file PhotonIDProducer.h.


Constructor & Destructor Documentation

PhotonIDProducer::PhotonIDProducer ( const edm::ParameterSet conf) [explicit]

Definition at line 8 of file PhotonIDProducer.cc.

References conf_, cutBasedAlgo_, doCutBased_, edm::ParameterSet::getParameter(), photonCutBasedIDLooseEMLabel_, photonCutBasedIDLooseLabel_, photonCutBasedIDTightLabel_, photonLabel_, and photonProducer_.

                                                              : conf_(conf) {

  photonProducer_ = conf_.getParameter<std::string>("photonProducer");
  photonLabel_ = conf_.getParameter<std::string>("photonLabel");
 
  photonCutBasedIDLooseLabel_ = conf.getParameter<std::string>("photonCutBasedIDLooseLabel");
  photonCutBasedIDTightLabel_ = conf.getParameter<std::string>("photonCutBasedIDTightLabel");
  photonCutBasedIDLooseEMLabel_ = conf.getParameter<std::string>("photonCutBasedIDLooseEMLabel");

  doCutBased_ = conf_.getParameter<bool>("doCutBased");
  cutBasedAlgo_ = new CutBasedPhotonIDAlgo();
  cutBasedAlgo_->setup(conf);
  produces<edm::ValueMap<Bool_t> > (photonCutBasedIDLooseLabel_);
  produces<edm::ValueMap<Bool_t> > (photonCutBasedIDTightLabel_);
  produces<edm::ValueMap<Bool_t> > (photonCutBasedIDLooseEMLabel_);

}
PhotonIDProducer::~PhotonIDProducer ( ) [virtual]

Definition at line 26 of file PhotonIDProducer.cc.

References cutBasedAlgo_.

                                    {

  //if (doCutBased_)
  delete cutBasedAlgo_;

}

Member Function Documentation

void PhotonIDProducer::produce ( edm::Event e,
const edm::EventSetup c 
) [virtual]

Implements edm::EDProducer.

Definition at line 33 of file PhotonIDProducer.cc.

References cutBasedAlgo_, CutBasedPhotonIDAlgo::decideEB(), CutBasedPhotonIDAlgo::decideEE(), edm::helper::Filler< Map >::fill(), edm::Event::getByLabel(), edm::helper::Filler< Map >::insert(), photonCutBasedIDLooseEMLabel_, photonCutBasedIDLooseLabel_, photonCutBasedIDTightLabel_, photonLabel_, photonProducer_, ExpressReco_HICollisions_FallBack::photons, and edm::Event::put().

                                                                  {

   // Read in photons
  edm::Handle<reco::PhotonCollection> photons;
  e.getByLabel(photonProducer_,photonLabel_,photons);


  // Loop over photons and calculate photon ID using specified technique(s)
  reco::PhotonCollection::const_iterator photon;
  std::vector <Bool_t> Loose;
  std::vector <Bool_t> Tight;
  std::vector <Bool_t> LooseEM;
  for (photon = (*photons).begin();
       photon != (*photons).end(); ++photon) {
    bool LooseQual;
    bool TightQual;
    bool LooseEMQual;
    if (photon->isEB())
      cutBasedAlgo_->decideEB(&(*photon),LooseEMQual,LooseQual, TightQual);
    else
      cutBasedAlgo_->decideEE(&(*photon),LooseEMQual,LooseQual, TightQual);
    LooseEM.push_back(LooseEMQual);
    Loose.push_back(LooseQual);
    Tight.push_back(TightQual);
    
  }
  

  std::auto_ptr<edm::ValueMap<Bool_t> > outlooseEM(new edm::ValueMap<Bool_t>());
  edm::ValueMap<Bool_t>::Filler fillerlooseEM(*outlooseEM);
  fillerlooseEM.insert(photons, LooseEM.begin(), LooseEM.end());
  fillerlooseEM.fill();
  // and put it into the event
  e.put(outlooseEM, photonCutBasedIDLooseEMLabel_);

  std::auto_ptr<edm::ValueMap<Bool_t> > outloose(new edm::ValueMap<Bool_t>());
  edm::ValueMap<Bool_t>::Filler fillerloose(*outloose);
  fillerloose.insert(photons, Loose.begin(), Loose.end());
  fillerloose.fill();
  // and put it into the event
  e.put(outloose, photonCutBasedIDLooseLabel_);
  
  std::auto_ptr<edm::ValueMap<Bool_t> > outtight(new edm::ValueMap<Bool_t>());
  edm::ValueMap<Bool_t>::Filler fillertight(*outtight);
  fillertight.insert(photons, Tight.begin(), Tight.end());
  fillertight.fill();
  // and put it into the event
  e.put(outtight, photonCutBasedIDTightLabel_);
  
  
}

Member Data Documentation

Definition at line 28 of file PhotonIDProducer.h.

Referenced by PhotonIDProducer().

Definition at line 26 of file PhotonIDProducer.h.

Referenced by PhotonIDProducer(), produce(), and ~PhotonIDProducer().

Definition at line 36 of file PhotonIDProducer.h.

Referenced by PhotonIDProducer().

Definition at line 32 of file PhotonIDProducer.h.

Referenced by PhotonIDProducer(), and produce().

Definition at line 33 of file PhotonIDProducer.h.

Referenced by PhotonIDProducer(), and produce().

Definition at line 34 of file PhotonIDProducer.h.

Referenced by PhotonIDProducer(), and produce().

std::string PhotonIDProducer::photonLabel_ [private]

Definition at line 31 of file PhotonIDProducer.h.

Referenced by PhotonIDProducer(), and produce().

std::string PhotonIDProducer::photonProducer_ [private]

Definition at line 30 of file PhotonIDProducer.h.

Referenced by PhotonIDProducer(), and produce().