CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

PhotonIsoProducer Class Reference

Inheritance diagram for PhotonIsoProducer:
edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 PhotonIsoProducer (const edm::ParameterSet &)
 ~PhotonIsoProducer ()

Private Member Functions

virtual bool filter (edm::Event &, const edm::EventSetup &)

Private Attributes

PFIsolationEstimator isolator
std::string nameIsoCh_
std::string nameIsoNh_
std::string nameIsoPh_
edm::InputTag particleFlowTag_
edm::InputTag photonTag_
bool verbose_
edm::InputTag vertexTag_

Detailed Description

Definition at line 27 of file PhotonIsoProducer.cc.


Constructor & Destructor Documentation

PhotonIsoProducer::PhotonIsoProducer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 57 of file PhotonIsoProducer.cc.

References edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

                                                                   {
        verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
        vertexTag_ = iConfig.getParameter<edm::InputTag>("vertexTag");
        photonTag_ = iConfig.getParameter<edm::InputTag>("photonTag");
        particleFlowTag_ = iConfig.getParameter<edm::InputTag>("particleFlowTag");
  
        nameIsoCh_ = iConfig.getParameter<std::string>("nameValueMapIsoCh");
        nameIsoPh_ = iConfig.getParameter<std::string>("nameValueMapIsoPh");
        nameIsoNh_ = iConfig.getParameter<std::string>("nameValueMapIsoNh");
  
  
        produces<edm::ValueMap<double> >(nameIsoCh_);
        produces<edm::ValueMap<double> >(nameIsoPh_);
        produces<edm::ValueMap<double> >(nameIsoNh_);
  
        isolator.initializePhotonIsolation(kTRUE); //NOTE: this automatically set all the correct defaul veto values
        isolator.setConeSize(0.3); 
  
}
PhotonIsoProducer::~PhotonIsoProducer ( )

Definition at line 78 of file PhotonIsoProducer.cc.

{
  
  // do anything here that needs to be done at desctruction time
  // (e.g. close files, deallocate resources etc.)

}

Member Function Documentation

bool PhotonIsoProducer::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDFilter.

Definition at line 92 of file PhotonIsoProducer.cc.

References gather_cfg::cout, edm::EventID::event(), edm::helper::Filler< Map >::fill(), edm::Event::getByLabel(), edm::EventBase::id(), edm::helper::Filler< Map >::insert(), edm::EventID::luminosityBlock(), edm::Event::put(), edm::EventID::run(), and GoodVertex_cfg::vertexCollection.

                                                                            {
        using namespace edm;

        std::auto_ptr<edm::ValueMap<double> > chIsoMap(new edm::ValueMap<double>() );
        edm::ValueMap<double>::Filler chFiller(*chIsoMap);

        std::auto_ptr<edm::ValueMap<double> > phIsoMap(new edm::ValueMap<double>() );
        edm::ValueMap<double>::Filler phFiller(*phIsoMap);

        std::auto_ptr<edm::ValueMap<double> > nhIsoMap(new edm::ValueMap<double>() );
        edm::ValueMap<double>::Filler nhFiller(*nhIsoMap);

        Handle<reco::VertexCollection>  vertexCollection;
        iEvent.getByLabel(vertexTag_, vertexCollection);

        Handle<reco::PhotonCollection> phoCollection;
        iEvent.getByLabel(photonTag_, phoCollection);
        const reco::PhotonCollection *recoPho = phoCollection.product();

        // All PF Candidate for alternate isolation
        Handle<reco::PFCandidateCollection> pfCandidatesH;
        iEvent.getByLabel(particleFlowTag_, pfCandidatesH);
        const  PFCandidateCollection thePfColl = *(pfCandidatesH.product());

        std::vector<double> chIsoValues;
        std::vector<double> phIsoValues;
        std::vector<double> nhIsoValues;
        chIsoValues.reserve(phoCollection->size());
        phIsoValues.reserve(phoCollection->size());
        nhIsoValues.reserve(phoCollection->size());
   
        unsigned int ivtx = 0;
        VertexRef myVtxRef(vertexCollection, ivtx);


        for (reco::PhotonCollection::const_iterator aPho = recoPho->begin(); aPho != recoPho->end(); ++aPho) {

          isolator.fGetIsolation(&*aPho, 
                                 &thePfColl, 
                                 myVtxRef, 
                                 vertexCollection);

          if(verbose_) {
            std::cout << " run " << iEvent.id().run() << " lumi " << iEvent.id().luminosityBlock() << " event " << iEvent.id().event();
            std::cout << " pt " <<  aPho->pt() << " eta " << aPho->eta() << " phi " << aPho->phi() 
                      << " charge " << aPho->charge()<< " : " << std::endl;;
            
            std::cout << " ChargedIso " << isolator.getIsolationCharged() << std::endl;
            std::cout << " PhotonIso " << isolator.getIsolationPhoton() << std::endl;
            std::cout << " NeutralHadron Iso " << isolator.getIsolationNeutral()  << std::endl;
          }

          chIsoValues.push_back(isolator.getIsolationCharged());
          phIsoValues.push_back(isolator.getIsolationPhoton());
          nhIsoValues.push_back(isolator.getIsolationNeutral());

        }

        chFiller.insert(phoCollection, chIsoValues.begin(), chIsoValues.end() );
        chFiller.fill();
        
        phFiller.insert(phoCollection, phIsoValues.begin(), phIsoValues.end() );
        phFiller.fill();
        
        nhFiller.insert(phoCollection, nhIsoValues.begin(), nhIsoValues.end() );
        nhFiller.fill();
        
        
        iEvent.put(chIsoMap,nameIsoCh_);
        iEvent.put(phIsoMap,nameIsoPh_);
        iEvent.put(nhIsoMap,nameIsoNh_);
        
          
        return true;
}

Member Data Documentation

Definition at line 43 of file PhotonIsoProducer.cc.

std::string PhotonIsoProducer::nameIsoCh_ [private]

Definition at line 39 of file PhotonIsoProducer.cc.

std::string PhotonIsoProducer::nameIsoNh_ [private]

Definition at line 41 of file PhotonIsoProducer.cc.

std::string PhotonIsoProducer::nameIsoPh_ [private]

Definition at line 40 of file PhotonIsoProducer.cc.

Definition at line 38 of file PhotonIsoProducer.cc.

Definition at line 37 of file PhotonIsoProducer.cc.

Definition at line 35 of file PhotonIsoProducer.cc.

Definition at line 36 of file PhotonIsoProducer.cc.