CMS 3D CMS Logo

Classes | Public Member Functions | Private Attributes

TopElectronHLTOfflineSource Class Reference

#include <TopElectronHLTOfflineSource.h>

Inheritance diagram for TopElectronHLTOfflineSource:
edm::EDAnalyzer edm::EDConsumerBase

List of all members.

Classes

class  EleMEs

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob ()
virtual void beginRun (const edm::Run &run, const edm::EventSetup &c)
virtual void endJob ()
virtual void endRun (const edm::Run &run, const edm::EventSetup &c)
void fill (EleMEs &eleMEs, const edm::Event &iEvent, size_t eleIndex, const std::vector< const trigger::TriggerObject * > &triggerJets, const std::vector< const trigger::TriggerObject * > &triggerElectrons, const reco::Vertex::Point &vertexPoint)
virtual void setupHistos (const std::vector< EleMEs >)
 TopElectronHLTOfflineSource (const edm::ParameterSet &conf)
virtual ~TopElectronHLTOfflineSource ()

Private Attributes

bool addExtraId_
edm::InputTag beamSpot_
DQMStoredbe_
std::string dirName_
std::vector< std::string > electronIdNames_
edm::InputTag electronLabel_
double electronMaxEta_
double electronMinEt_
std::vector< std::string > electronTriggerNames_
edm::Handle
< reco::GsfElectronCollection
eleHandle_
std::vector< EleMEseleMEs_
bool excludeCloseJets_
double extraIdCutsDzPV_
double extraIdCutsSigmaEta_
double extraIdCutsSigmaPhi_
HLTConfigProvider hltConfig_
bool hltConfigChanged_
bool hltConfigValid_
std::string hltTag_
edm::InputTag primaryVertexLabel_
bool requireTriggerMatch_
std::vector< std::string > superTriggerNames_
edm::InputTag triggerElectronFilterLabel_
edm::Handle
< trigger::TriggerEvent
triggerEvent_
edm::InputTag triggerJetFilterLabel_
edm::InputTag triggerJetLabel_
edm::InputTag triggerResultsLabel_
edm::InputTag triggerSummaryLabel_

Detailed Description

Definition at line 27 of file TopElectronHLTOfflineSource.h.


Constructor & Destructor Documentation

TopElectronHLTOfflineSource::TopElectronHLTOfflineSource ( const edm::ParameterSet conf)

Definition at line 25 of file TopElectronHLTOfflineSource.cc.

References addExtraId_, dbe_, dirName_, electronIdNames_, electronLabel_, electronMaxEta_, electronMinEt_, electronTriggerNames_, excludeCloseJets_, extraIdCutsDzPV_, extraIdCutsSigmaEta_, extraIdCutsSigmaPhi_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hltTag_, cppFunctionSkipper::operator, primaryVertexLabel_, requireTriggerMatch_, DQMStore::setVerbose(), AlCaHLTBitMon_QueryRunRegistry::string, superTriggerNames_, triggerElectronFilterLabel_, triggerJetFilterLabel_, triggerResultsLabel_, and triggerSummaryLabel_.

                                                                                    :
  beamSpot_(conf.getParameter<edm::InputTag>("beamSpot")) {

        dbe_ = edm::Service<DQMStore>().operator->();
        
        if (!dbe_) 
        {
                edm::LogInfo("TopElectronHLTOfflineSource") << "unable to get DQMStore service?";
        }
        
        if(conf.getUntrackedParameter<bool>("DQMStore", false)) 
        {
          if(!dbe_) dbe_->setVerbose(0);
        }

        dirName_ = conf.getParameter<std::string>("DQMDirName");
        
        electronIdNames_ = conf.getParameter<std::vector<std::string> >("electronIdNames");
        hltTag_ = conf.getParameter<std::string>("hltTag");
        superTriggerNames_ = conf.getParameter<std::vector<std::string> >("superTriggerNames");
        electronTriggerNames_ = conf.getParameter<std::vector<std::string> >("electronTriggerNames");
        
        triggerResultsLabel_ = conf.getParameter<edm::InputTag>("triggerResultsLabel");
        triggerSummaryLabel_ = conf.getParameter<edm::InputTag>("triggerSummaryLabel");
        electronLabel_ = conf.getParameter<edm::InputTag>("electronCollection");
        primaryVertexLabel_ = conf.getParameter<edm::InputTag>("primaryVertexCollection");
        triggerJetFilterLabel_  = conf.getParameter<edm::InputTag>("triggerJetFilterLabel");
        triggerElectronFilterLabel_ = conf.getParameter<edm::InputTag>("triggerElectronFilterLabel");

        excludeCloseJets_ = conf.getParameter<bool>("excludeCloseJets");
        requireTriggerMatch_ = conf.getParameter<bool>("requireTriggerMatch");
        electronMinEt_ = conf.getParameter<double>("electronMinEt");
        electronMaxEta_ = conf.getParameter<double>("electronMaxEta");
                
        addExtraId_ = conf.getParameter<bool>("addExtraId");
        extraIdCutsSigmaEta_ = conf.getParameter<double>("extraIdCutsSigmaEta");
        extraIdCutsSigmaPhi_ = conf.getParameter<double>("extraIdCutsSigmaPhi");
        extraIdCutsDzPV_ = conf.getParameter<double>("extraIdCutsDzPV");

}
TopElectronHLTOfflineSource::~TopElectronHLTOfflineSource ( ) [virtual]

Definition at line 65 of file TopElectronHLTOfflineSource.cc.

{
}

Member Function Documentation

void TopElectronHLTOfflineSource::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 103 of file TopElectronHLTOfflineSource.cc.

References abs, accept(), beamSpot_, dbe_, electronLabel_, electronMaxEta_, electronMinEt_, electronTriggerNames_, eleHandle_, eleMEs_, reco::LeafCandidate::et(), reco::LeafCandidate::eta(), fill(), edm::Event::getByLabel(), hltConfig_, hltConfigValid_, JetPDSkim_cfg::hltResults, i, getHLTprescales::index, j, reco::Vertex::position(), primaryVertexLabel_, edm::Handle< T >::product(), findQualityFiles::size, superTriggerNames_, triggerElectronFilterLabel_, triggerEvent_, HLTConfigProvider::triggerIndex(), triggerJetFilterLabel_, triggerResultsLabel_, and triggerSummaryLabel_.

{
        if(!dbe_) return;
        // ---- Get Trigger Decisions for all triggers under investigation ----
        edm::Handle<edm::TriggerResults> hltResults;
        if(!iEvent.getByLabel(triggerResultsLabel_, hltResults) || !hltResults.product()) return; //bail if we didnt get trigger results
      

        
        if (!hltConfigValid_) return;
        
        std::vector<bool> superTriggerAccepts;
        std::vector<bool> electronTriggerAccepts;
        
        for (size_t i = 0; i < superTriggerNames_.size(); ++i)
        {
                unsigned int triggerIndex( hltConfig_.triggerIndex(superTriggerNames_[i]) );
                bool accept = false;
                
                if (triggerIndex < hltResults->size())
                {
                        accept = hltResults->accept(triggerIndex);
                }
                
                superTriggerAccepts.push_back(accept);
        }
        
        for (size_t i = 0; i < electronTriggerNames_.size(); ++i)
        {
                unsigned int triggerIndex( hltConfig_.triggerIndex(electronTriggerNames_[i]) );
                bool accept = false;
                
                if (triggerIndex < hltResults->size())
                {
                        accept = hltResults->accept(triggerIndex);
                } 
                
                electronTriggerAccepts.push_back(accept);
        }
        
        // get reconstructed electron collection
        if(!iEvent.getByLabel(electronLabel_, eleHandle_) || !eleHandle_.product()) return;
        
        // Get Trigger Event, providing the information about trigger objects   
        if(!iEvent.getByLabel(triggerSummaryLabel_, triggerEvent_) || !triggerEvent_.product()) return; 
        
        edm::Handle<reco::VertexCollection> vertexHandle;
        if(!iEvent.getByLabel(primaryVertexLabel_, vertexHandle) || !vertexHandle.product()) return;

        reco::Vertex::Point vertexPoint(0., 0., 0.);
        if (vertexHandle.product()->size() != 0)
        {
                const reco::Vertex& theVertex = vertexHandle.product()->front();
                vertexPoint = theVertex.position();
        }
        else
        {
                edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
                if(!iEvent.getByLabel(beamSpot_, recoBeamSpotHandle) ||  !recoBeamSpotHandle.product()) return;

                vertexPoint = recoBeamSpotHandle->position();
        }
        
        trigger::size_type jetFilterPos = triggerEvent_->filterIndex(triggerJetFilterLabel_);
        std::vector<const trigger::TriggerObject*> triggerJets;
        
        if (jetFilterPos != triggerEvent_->sizeFilters())
        {
                for (size_t i = 0; i < triggerEvent_->filterKeys(jetFilterPos).size(); ++i)
                {
                        size_t objNr = triggerEvent_->filterKeys(jetFilterPos)[i];
                        if(objNr<triggerEvent_->sizeObjects()){
                          triggerJets.push_back(& triggerEvent_->getObjects()[objNr]);
                        }
                }       
        }
        
        trigger::size_type eleFilterPos = triggerEvent_->filterIndex(triggerElectronFilterLabel_);
        std::vector<const trigger::TriggerObject*> triggerElectrons;
 
        if (eleFilterPos != triggerEvent_->sizeFilters())
        {
                for (size_t i = 0; i < triggerEvent_->filterKeys(eleFilterPos).size(); ++i)
                {
                        size_t objNr = triggerEvent_->filterKeys(eleFilterPos)[i];
                        if(objNr<triggerEvent_->sizeObjects()){
                          triggerElectrons.push_back(& triggerEvent_->getObjects()[objNr]);
                        }
                }
        }
        
        const reco::GsfElectronCollection& eles = *eleHandle_;
        
        for(size_t eleNr=0; eleNr < eles.size(); ++eleNr)
        {
                
                const reco::GsfElectron& ele = eles[eleNr];
                
                // electron selection
                
                if(ele.et() > electronMinEt_ && std::abs(ele.eta()) < electronMaxEta_)
                {
                        size_t index = 0;
                        for (size_t i = 0; i < superTriggerNames_.size(); ++i)
                        {
                                if (superTriggerAccepts[i])
                                        fill(eleMEs_[index], iEvent, eleNr, triggerJets, triggerElectrons, vertexPoint);
                                index++;
                                
                                for (size_t j = 0; j < electronTriggerNames_.size(); ++j)
                                {
                                        if (superTriggerAccepts[i] && electronTriggerAccepts[j]) 
                                                fill(eleMEs_[index], iEvent, eleNr, triggerJets, triggerElectrons, vertexPoint);
                                        index++;
                                }
                        }
                }
        }
}
void TopElectronHLTOfflineSource::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 69 of file TopElectronHLTOfflineSource.cc.

References addExtraId_, dbe_, dirName_, electronIdNames_, electronTriggerNames_, eleMEs_, i, j, DQMStore::setCurrentFolder(), and superTriggerNames_.

{
  if(!dbe_) return;
        dbe_->setCurrentFolder(dirName_);
        for (size_t i = 0; i < superTriggerNames_.size(); ++i)
        {
                eleMEs_.push_back(EleMEs(dbe_, electronIdNames_, addExtraId_, superTriggerNames_[i]));
                for (size_t j = 0; j < electronTriggerNames_.size(); ++j)
                {
                        eleMEs_.push_back(EleMEs(dbe_, electronIdNames_, addExtraId_, superTriggerNames_[i]+"_"+electronTriggerNames_[j]));
                        //std::cout <<superTriggerNames_[i]+"_"+electronTriggerNames_[j]<<std::endl;
                        
                }
        }
        //std::cout <<"done"<<std::endl;
}
void TopElectronHLTOfflineSource::beginRun ( const edm::Run run,
const edm::EventSetup c 
) [virtual]
void TopElectronHLTOfflineSource::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 92 of file TopElectronHLTOfflineSource.cc.

{
}
void TopElectronHLTOfflineSource::endRun ( const edm::Run run,
const edm::EventSetup c 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 99 of file TopElectronHLTOfflineSource.cc.

{
}
void TopElectronHLTOfflineSource::fill ( EleMEs eleMEs,
const edm::Event iEvent,
size_t  eleIndex,
const std::vector< const trigger::TriggerObject * > &  triggerJets,
const std::vector< const trigger::TriggerObject * > &  triggerElectrons,
const reco::Vertex::Point vertexPoint 
)

Definition at line 267 of file TopElectronHLTOfflineSource.cc.

References abs, addExtraId_, deltaR(), eleHandle_, TopElectronHLTOfflineSource::EleMEs::eleIdNames(), TopElectronHLTOfflineSource::EleMEs::eleMENames(), trigger::TriggerObject::et(), excludeCloseJets_, extraIdCutsDzPV_, extraIdCutsSigmaEta_, extraIdCutsSigmaPhi_, TopElectronHLTOfflineSource::EleMEs::fill(), edm::Event::getByLabel(), TopElectronHLTOfflineSource::EleMEs::getMESet(), reco::GsfElectron::gsfTrack(), i, reco::GsfElectron::isEB(), reco::GsfElectron::isEE(), reco::GsfElectron::isGap(), j, metsig::jet, reco::GsfElectron::p4(), requireTriggerMatch_, and reco::Candidate::size.

Referenced by analyze().

{
        const reco::GsfElectron& ele = (*eleHandle_)[eleIndex];
        
        float dzPV = std::abs(ele.gsfTrack()->dz(vertexPoint));
        
        bool isTriggerMatched = false;
        for (size_t i = 0; i < triggerElectrons.size(); ++i)
        {
                if (deltaR(*(triggerElectrons[i]), ele.p4()) < 0.3)
                         isTriggerMatched = true;
        }
        
        if (requireTriggerMatch_ && !isTriggerMatched)
                return;
        
        // Calculate minimum deltaR to closest jet and sumEt (all jets)
        float minDeltaR = 999.;
        float sumEt = 0.;
        
        for (size_t jetNr = 0; jetNr < triggerJets.size(); ++jetNr)
        {
                const trigger::TriggerObject& jet = *triggerJets[jetNr];

                sumEt += jet.et();
                
                float dr = deltaR(jet, ele.p4());
                
                if (!excludeCloseJets_ && dr < minDeltaR)
                        minDeltaR = dr;
                if (excludeCloseJets_ && dr > 0.1 && dr < minDeltaR)
                        minDeltaR = dr;
        }
        
        for (size_t j = 0; j < eleMEs.eleIdNames().size(); ++j)
        {
                bool eId = true;

                edm::Handle<edm::ValueMap<float> > eIdMapHandle;
                iEvent.getByLabel(eleMEs.eleIdNames()[j], eIdMapHandle);
                const edm::ValueMap<float>& eIdMap = *eIdMapHandle;
                eId = eIdMap[edm::Ref<reco::GsfElectronCollection>(eleHandle_, eleIndex)];
                
                bool extraId = true;
                if (addExtraId_)
                {
                        if (ele.gsfTrack()->etaError() > extraIdCutsSigmaEta_)
                                extraId = false;
                        if (ele.gsfTrack()->phiError() > extraIdCutsSigmaPhi_)
                                extraId = false;
                        if (dzPV > extraIdCutsDzPV_)
                                extraId = false;
                }
                
                for (size_t i = 0; i < eleMEs.eleMENames().size(); ++i)
                {
                        if (eId && eleMEs.eleMENames()[i] == "EB" && ele.isEB()&& !ele.isGap())
                                eleMEs.fill(eleMEs.getMESet(i, j), ele, minDeltaR, sumEt, triggerJets.size(), dzPV);
                        if (eId && eleMEs.eleMENames()[i] == "EE" && ele.isEE()&& !ele.isGap())
                                eleMEs.fill(eleMEs.getMESet(i, j), ele, minDeltaR, sumEt, triggerJets.size(), dzPV);
                        if (addExtraId_)
                        {
                                if (eId && extraId && eleMEs.eleMENames()[i] == "EB" && ele.isEB()&& !ele.isGap())
                                        eleMEs.fill(eleMEs.getMESet(i, j+1), ele, minDeltaR, sumEt, triggerJets.size(), dzPV);
                                if (eId && extraId && eleMEs.eleMENames()[i] == "EE" && ele.isEE()&& !ele.isGap())
                                        eleMEs.fill(eleMEs.getMESet(i, j+1), ele, minDeltaR, sumEt, triggerJets.size(), dzPV);
                        }
                }
                if (addExtraId_)
                        ++j;

        }
}
void TopElectronHLTOfflineSource::setupHistos ( const std::vector< EleMEs topEleHists) [virtual]

Definition at line 85 of file TopElectronHLTOfflineSource.cc.

References eleMEs_, and i.

{
        for (size_t i = 0; i < eleMEs_.size(); ++i)
        {
                topEleHists.push_back(eleMEs_[i]);
        }
}

Member Data Documentation

Definition at line 172 of file TopElectronHLTOfflineSource.h.

Referenced by beginJob(), fill(), and TopElectronHLTOfflineSource().

Definition at line 157 of file TopElectronHLTOfflineSource.h.

Referenced by analyze().

Definition at line 138 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), beginJob(), and TopElectronHLTOfflineSource().

Definition at line 140 of file TopElectronHLTOfflineSource.h.

Referenced by beginJob(), and TopElectronHLTOfflineSource().

std::vector<std::string> TopElectronHLTOfflineSource::electronIdNames_ [private]

Definition at line 144 of file TopElectronHLTOfflineSource.h.

Referenced by beginJob(), and TopElectronHLTOfflineSource().

Definition at line 155 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), and TopElectronHLTOfflineSource().

Definition at line 169 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), and TopElectronHLTOfflineSource().

Definition at line 168 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), and TopElectronHLTOfflineSource().

std::vector<std::string> TopElectronHLTOfflineSource::electronTriggerNames_ [private]

Definition at line 148 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), beginJob(), and TopElectronHLTOfflineSource().

Definition at line 161 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), and fill().

Definition at line 142 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), beginJob(), and setupHistos().

Definition at line 164 of file TopElectronHLTOfflineSource.h.

Referenced by fill(), and TopElectronHLTOfflineSource().

Definition at line 177 of file TopElectronHLTOfflineSource.h.

Referenced by fill(), and TopElectronHLTOfflineSource().

Definition at line 175 of file TopElectronHLTOfflineSource.h.

Referenced by fill(), and TopElectronHLTOfflineSource().

Definition at line 176 of file TopElectronHLTOfflineSource.h.

Referenced by fill(), and TopElectronHLTOfflineSource().

Definition at line 181 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), and beginRun().

Definition at line 179 of file TopElectronHLTOfflineSource.h.

Referenced by beginRun().

Definition at line 180 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), and beginRun().

std::string TopElectronHLTOfflineSource::hltTag_ [private]

Definition at line 145 of file TopElectronHLTOfflineSource.h.

Referenced by beginRun(), and TopElectronHLTOfflineSource().

Definition at line 156 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), and TopElectronHLTOfflineSource().

Definition at line 166 of file TopElectronHLTOfflineSource.h.

Referenced by fill(), and TopElectronHLTOfflineSource().

std::vector<std::string> TopElectronHLTOfflineSource::superTriggerNames_ [private]

Definition at line 147 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), beginJob(), and TopElectronHLTOfflineSource().

Definition at line 154 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), and TopElectronHLTOfflineSource().

Definition at line 159 of file TopElectronHLTOfflineSource.h.

Referenced by analyze().

Definition at line 153 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), and TopElectronHLTOfflineSource().

Definition at line 152 of file TopElectronHLTOfflineSource.h.

Definition at line 151 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), and TopElectronHLTOfflineSource().

Definition at line 150 of file TopElectronHLTOfflineSource.h.

Referenced by analyze(), and TopElectronHLTOfflineSource().