CMS 3D CMS Logo

Public Member Functions | Private Attributes

EleIsoDetIdCollectionProducer Class Reference

#include <EleIsoDetIdCollectionProducer.h>

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

List of all members.

Public Member Functions

void beginJob ()
 EleIsoDetIdCollectionProducer (const edm::ParameterSet &)
 ctor
virtual void produce (edm::Event &, const edm::EventSetup &)
 producer
 ~EleIsoDetIdCollectionProducer ()

Private Attributes

edm::InputTag emObjectLabel_
double energyCut_
double etCandCut_
double etCut_
double innerRadius_
std::string interestingDetIdCollection_
double outerRadius_
edm::InputTag recHitsLabel_
int severityLevelCut_
std::vector< int > v_chstatus_

Detailed Description

Original author: Matthew LeBourgeois PH/CMG Modified from : RecoEcal/EgammaClusterProducers/{src,interface}/InterestingDetIdCollectionProducer.{h,cc} by Paolo Meridiani PH/CMG

Implementation: <Notes on="" implementation>="">

Definition at line 35 of file EleIsoDetIdCollectionProducer.h.


Constructor & Destructor Documentation

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

ctor

Definition at line 32 of file EleIsoDetIdCollectionProducer.cc.

References edm::ParameterSet::getParameter(), interestingDetIdCollection_, and v_chstatus_.

                                                                                           :
            recHitsLabel_(iConfig.getParameter< edm::InputTag > ("recHitsLabel")),
            emObjectLabel_(iConfig.getParameter< edm::InputTag > ("emObjectLabel")),
            energyCut_(iConfig.getParameter<double>("energyCut")),
            etCut_(iConfig.getParameter<double>("etCut")),
            etCandCut_(iConfig.getParameter<double> ("etCandCut")),
            outerRadius_(iConfig.getParameter<double>("outerRadius")),
            innerRadius_(iConfig.getParameter<double>("innerRadius")),
            interestingDetIdCollection_(iConfig.getParameter<std::string>("interestingDetIdCollection")),
            severityLevelCut_(iConfig.getParameter<int>("severityLevelCut"))
            //severityRecHitThreshold_(iConfig.getParameter<double>("severityRecHitThreshold")),
            //spIdString_(iConfig.getParameter<std::string>("spikeIdString")),
            //spIdThreshold_(iConfig.getParameter<double>("spikeIdThreshold")),
 {

   const std::vector<std::string> flagnames = 
    iConfig.getParameter<std::vector<std::string> >("recHitFlagsToBeExcluded");

   v_chstatus_= StringToEnumValue<EcalRecHit::Flags>(flagnames);

//     if     ( !spIdString_.compare("kE1OverE9") )                  spId_ = EcalSeverityLevelAlgo::kE1OverE9;
//     else if( !spIdString_.compare("kSwissCross") )                spId_ = EcalSeverityLevelAlgo::kSwissCross;
//     else if( !spIdString_.compare("kSwissCrossBordersIncluded") ) spId_ = EcalSeverityLevelAlgo::kSwissCrossBordersIncluded;
//     else                                                          spId_ = EcalSeverityLevelAlgo::kSwissCross;
    
    //register your products
    produces< DetIdCollection > (interestingDetIdCollection_) ;
}
EleIsoDetIdCollectionProducer::~EleIsoDetIdCollectionProducer ( )

Definition at line 61 of file EleIsoDetIdCollectionProducer.cc.

{}

Member Function Documentation

void EleIsoDetIdCollectionProducer::beginJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 63 of file EleIsoDetIdCollectionProducer.cc.

{}
void EleIsoDetIdCollectionProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

producer

Implements edm::EDProducer.

Definition at line 68 of file EleIsoDetIdCollectionProducer.cc.

References DetId::Ecal, EcalBarrel, EcalEndcap, emObjectLabel_, energyCut_, etCandCut_, etCut_, spr::find(), edm::EventSetup::get(), edm::Event::getByLabel(), innerRadius_, edm::InputTag::instance(), interestingDetIdCollection_, mag(), outerRadius_, perp(), edm::Event::put(), recHitsLabel_, severityLevelCut_, and v_chstatus_.

{
    using namespace edm;
    using namespace std;

    //Get EM Object
    Handle<reco::GsfElectronCollection> emObjectH;
    iEvent.getByLabel(emObjectLabel_,emObjectH);

    // take EcalRecHits
    Handle<EcalRecHitCollection> recHitsH;
    iEvent.getByLabel(recHitsLabel_,recHitsH);
    std::auto_ptr<CaloRecHitMetaCollectionV> recHits_(0); 
    recHits_ = std::auto_ptr<CaloRecHitMetaCollectionV>(new EcalRecHitMetaCollection(*recHitsH));

    edm::ESHandle<CaloGeometry> pG;
    iSetup.get<CaloGeometryRecord>().get(pG);    
    const CaloGeometry* caloGeom = pG.product();

    //Get the channel status from the db
    edm::ESHandle<EcalChannelStatus> chStatus;
    iSetup.get<EcalChannelStatusRcd>().get(chStatus);

    edm::ESHandle<EcalSeverityLevelAlgo> sevlv;
    iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
    const EcalSeverityLevelAlgo* sevLevel = sevlv.product();

    CaloDualConeSelector *doubleConeSel_ = 0;
    if(recHitsLabel_.instance() == "EcalRecHitsEB")
        doubleConeSel_= new CaloDualConeSelector(innerRadius_,outerRadius_, &*pG, DetId::Ecal, EcalBarrel);
    else if(recHitsLabel_.instance() == "EcalRecHitsEE")
        doubleConeSel_= new CaloDualConeSelector(innerRadius_,outerRadius_, &*pG, DetId::Ecal, EcalEndcap);

    //Create empty output collections
    std::auto_ptr< DetIdCollection > detIdCollection (new DetIdCollection() ) ;

    reco::GsfElectronCollection::const_iterator emObj;
    if(doubleConeSel_) { //if cone selector was created
        for (emObj = emObjectH->begin(); emObj != emObjectH->end();  emObj++) { //Loop over candidates

            if(emObj->et() < etCandCut_) continue; //don't calculate if object hasn't enough energy
            
            GlobalPoint pclu (emObj->caloPosition().x(),emObj->caloPosition().y(),emObj->caloPosition().z());
            std::auto_ptr<CaloRecHitMetaCollectionV> chosen = doubleConeSel_->select(pclu,*recHits_);

            CaloRecHitMetaCollectionV::const_iterator recIt;
            for (recIt = chosen->begin(); recIt!= chosen->end () ; ++recIt) { // Select RecHits 

                if ( fabs(recIt->energy()) < energyCut_) continue;  //dont fill if below E noise value


                double et = recIt->energy() * 
                            caloGeom->getPosition(recIt->detid()).perp() / 
                            caloGeom->getPosition(recIt->detid()).mag();

                if ( fabs(et) < etCut_) continue;  //dont fill if below ET noise value

                //make sure we have a barrel rechit                                     
                //call the severity level method                                        
                //passing the EBDetId                                                   
                //the rechit collection in order to calculate the swiss crss            
                //and the EcalChannelRecHitRcd                                          
                //only consider rechits with ET >                                       
                //the SpikeId method (currently kE1OverE9 or kSwissCross)               
                //cut value for above                                                   
                //then if the severity level is too high, we continue to the next rechit
                
                if(recHitsLabel_.instance() == "EcalRecHitsEB" && 
                   sevLevel->severityLevel(EBDetId(recIt->detid()), *recHitsH)  >= severityLevelCut_) continue;
                //                       *chStatus,                                 
                  //      severityRecHitThreshold_,                 
                //    spId_,                                    
                //      spIdThreshold_                            
                  // ) >= severityLevelCut_) continue;              

                //Check based on flags to protect from recovered channels from non-read towers
                //Assumption is that v_chstatus_ is empty unless doFlagChecks() has been called
                std::vector<int>::const_iterator vit = std::find( v_chstatus_.begin(), v_chstatus_.end(),  ((EcalRecHit*)(&*recIt))->recoFlag() );
                if ( vit != v_chstatus_.end() ) continue; // the recHit has to be excluded from the iso sum


                if(std::find(detIdCollection->begin(),detIdCollection->end(),recIt->detid()) == detIdCollection->end()) 
                            detIdCollection->push_back(recIt->detid()); 
            } //end rechits

        } //end candidates

        delete doubleConeSel_;
    } //end if cone selector was created
    
    iEvent.put( detIdCollection, interestingDetIdCollection_ );
}

Member Data Documentation

Definition at line 47 of file EleIsoDetIdCollectionProducer.h.

Referenced by produce().

Definition at line 48 of file EleIsoDetIdCollectionProducer.h.

Referenced by produce().

Definition at line 50 of file EleIsoDetIdCollectionProducer.h.

Referenced by produce().

Definition at line 49 of file EleIsoDetIdCollectionProducer.h.

Referenced by produce().

Definition at line 52 of file EleIsoDetIdCollectionProducer.h.

Referenced by produce().

Definition at line 53 of file EleIsoDetIdCollectionProducer.h.

Referenced by EleIsoDetIdCollectionProducer(), and produce().

Definition at line 51 of file EleIsoDetIdCollectionProducer.h.

Referenced by produce().

Definition at line 46 of file EleIsoDetIdCollectionProducer.h.

Referenced by produce().

Definition at line 54 of file EleIsoDetIdCollectionProducer.h.

Referenced by produce().

std::vector<int> EleIsoDetIdCollectionProducer::v_chstatus_ [private]

Definition at line 59 of file EleIsoDetIdCollectionProducer.h.

Referenced by EleIsoDetIdCollectionProducer(), and produce().