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_
std::vector< int > flagsexclEB_
std::vector< int > flagsexclEE_
double innerRadius_
std::string interestingDetIdCollection_
double outerRadius_
edm::InputTag recHitsLabel_
std::vector< int > severitiesexclEB_
std::vector< int > severitiesexclEE_

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 flagsexclEB_, flagsexclEE_, edm::ParameterSet::getParameter(), interestingDetIdCollection_, severitiesexclEB_, and severitiesexclEE_.

                                                                                           :
            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"))
 {

   const std::vector<std::string> flagnamesEB = 
     iConfig.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEB");
   
   const std::vector<std::string> flagnamesEE =
     iConfig.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEE");
   
   flagsexclEB_= 
     StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
   
   flagsexclEE_=
     StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
   
   const std::vector<std::string> severitynamesEB = 
     iConfig.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEB");
   
   severitiesexclEB_= 
     StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);

   const std::vector<std::string> severitynamesEE = 
     iConfig.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEE");
   
   severitiesexclEE_= 
     StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
   
   //register your products
   produces< DetIdCollection > (interestingDetIdCollection_) ;
}
EleIsoDetIdCollectionProducer::~EleIsoDetIdCollectionProducer ( )

Definition at line 71 of file EleIsoDetIdCollectionProducer.cc.

{}

Member Function Documentation

void EleIsoDetIdCollectionProducer::beginJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 74 of file EleIsoDetIdCollectionProducer.cc.

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

producer

Implements edm::EDProducer.

Definition at line 79 of file EleIsoDetIdCollectionProducer.cc.

References DetId::Ecal, EcalBarrel, EcalEndcap, emObjectLabel_, energyCut_, eta(), etCandCut_, etCut_, spr::find(), flagsexclEB_, flagsexclEE_, edm::EventSetup::get(), edm::Event::getByLabel(), innerRadius_, edm::InputTag::instance(), interestingDetIdCollection_, EcalRecHit::kGood, mag(), outerRadius_, perp(), edm::Event::put(), recHitsLabel_, severitiesexclEB_, and severitiesexclEE_.

                                                                                     {
    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 (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();

              bool isBarrel = false;
              if (fabs(caloGeom->getPosition(recIt->detid()).eta() < 1.479)) 
                isBarrel = true;
              
              if (et < etCut_) 
                continue;  //dont fill if below ET noise value

              std::vector<int>::const_iterator sit;
              int severityFlag = sevLevel->severityLevel(recIt->detid(), *recHitsH);
              if (isBarrel) {
                sit = std::find(severitiesexclEB_.begin(), severitiesexclEB_.end(), severityFlag);
                if (sit != severitiesexclEB_.end())
                  continue;
              } else {
                sit = std::find(severitiesexclEE_.begin(), severitiesexclEE_.end(), severityFlag);
                if (sit != severitiesexclEE_.end())
                  continue;
              }

              std::vector<int>::const_iterator vit;
              if (isBarrel) {
                // new rechit flag checks
                //vit = std::find(flagsexclEB_.begin(), flagsexclEB_.end(), ((EcalRecHit*)(&*recIt))->recoFlag());
                //if (vit != flagsexclEB_.end())
                //  continue;
                if (!((EcalRecHit*)(&*recIt))->checkFlag(EcalRecHit::kGood)) {
                  if (((EcalRecHit*)(&*recIt))->checkFlags(flagsexclEB_)) {                
                    continue;
                  }
                }
              } else {
                // new rechit flag checks
                //vit = std::find(flagsexclEE_.begin(), flagsexclEE_.end(), ((EcalRecHit*)(&*recIt))->recoFlag());
                //if (vit != flagsexclEE_.end())
                //  continue;
                if (!((EcalRecHit*)(&*recIt))->checkFlag(EcalRecHit::kGood)) {
                  if (((EcalRecHit*)(&*recIt))->checkFlags(flagsexclEE_)) {                
                    continue;
                  }
                }
              }

              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().

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

Definition at line 57 of file EleIsoDetIdCollectionProducer.h.

Referenced by EleIsoDetIdCollectionProducer(), and produce().

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

Definition at line 58 of file EleIsoDetIdCollectionProducer.h.

Referenced by EleIsoDetIdCollectionProducer(), and 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 55 of file EleIsoDetIdCollectionProducer.h.

Referenced by EleIsoDetIdCollectionProducer(), and produce().

Definition at line 56 of file EleIsoDetIdCollectionProducer.h.

Referenced by EleIsoDetIdCollectionProducer(), and produce().