Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:34:24

0001 #include "RecoEgamma/EgammaTools/interface/HGCalEgammaIDHelper.h"
0002 
0003 #include <iostream>
0004 
0005 HGCalEgammaIDHelper::HGCalEgammaIDHelper(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iC)
0006     : eeRecHitInputTag_(iConfig.getParameter<edm::InputTag>("EERecHits")),
0007       fhRecHitInputTag_(iConfig.getParameter<edm::InputTag>("FHRecHits")),
0008       bhRecHitInputTag_(iConfig.getParameter<edm::InputTag>("BHRecHits")),
0009       hitMapInputTag_(iConfig.getParameter<edm::InputTag>("hitMapTag")),
0010       dEdXWeights_(iConfig.getParameter<std::vector<double>>("dEdXWeights")) {
0011   isoHelper_.setDeltaR(iConfig.getParameter<double>("isoDeltaR"));
0012   isoHelper_.setNRings(iConfig.getParameter<unsigned int>("isoNRings"));
0013   isoHelper_.setMinDeltaR(iConfig.getParameter<double>("isoDeltaRmin"));
0014 
0015   recHitsEE_ = iC.consumes<HGCRecHitCollection>(eeRecHitInputTag_);
0016   recHitsFH_ = iC.consumes<HGCRecHitCollection>(fhRecHitInputTag_);
0017   recHitsBH_ = iC.consumes<HGCRecHitCollection>(bhRecHitInputTag_);
0018   hitMap_ = iC.consumes<std::unordered_map<DetId, const HGCRecHit*>>(hitMapInputTag_);
0019   caloGeometry_ = iC.esConsumes();
0020   pcaHelper_.setdEdXWeights(dEdXWeights_);
0021   debug_ = iConfig.getUntrackedParameter<bool>("debug", false);
0022 }
0023 
0024 void HGCalEgammaIDHelper::eventInit(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0025   auto recHitHandleEE = iEvent.getHandle(recHitsEE_);
0026   auto recHitHandleFH = iEvent.getHandle(recHitsFH_);
0027   auto recHitHandleBH = iEvent.getHandle(recHitsBH_);
0028 
0029   recHitTools_.setGeometry(iSetup.getData(caloGeometry_));
0030   pcaHelper_.setRecHitTools(&recHitTools_);
0031   isoHelper_.setRecHitTools(&recHitTools_);
0032   pcaHelper_.setHitMap(&iEvent.get(hitMap_));
0033   isoHelper_.setRecHits(recHitHandleEE, recHitHandleFH, recHitHandleBH);
0034 }
0035 
0036 void HGCalEgammaIDHelper::computeHGCAL(const reco::Photon& thePhoton, float radius) {
0037   if (thePhoton.isEB()) {
0038     if (debug_)
0039       std::cout << "The photon is in the barrel" << std::endl;
0040     pcaHelper_.clear();
0041     return;
0042   }
0043 
0044   pcaHelper_.storeRecHits(*thePhoton.superCluster()->seed());
0045   if (debug_)
0046     std::cout << " Stored the hits belonging to the photon superCluster seed " << std::endl;
0047 
0048   // initial computation, no radius cut, but halo hits not taken
0049   if (debug_)
0050     std::cout << " Calling PCA initial computation" << std::endl;
0051   pcaHelper_.pcaInitialComputation();
0052   // first computation within cylinder, halo hits included
0053   pcaHelper_.computePCA(radius);
0054   // second computation within cylinder, halo hits included
0055   pcaHelper_.computePCA(radius);
0056   pcaHelper_.computeShowerWidth(radius);
0057 
0058   // isolation
0059   isoHelper_.produceHGCalIso(thePhoton.superCluster()->seed());
0060 }
0061 
0062 void HGCalEgammaIDHelper::computeHGCAL(const reco::GsfElectron& theElectron, float radius) {
0063   if (theElectron.isEB()) {
0064     if (debug_)
0065       std::cout << "The electron is in the barrel" << std::endl;
0066     pcaHelper_.clear();
0067     return;
0068   }
0069 
0070   pcaHelper_.storeRecHits(*theElectron.electronCluster());
0071   if (debug_)
0072     std::cout << " Stored the hits belonging to the electronCluster " << std::endl;
0073 
0074   // initial computation, no radius cut, but halo hits not taken
0075   if (debug_)
0076     std::cout << " Calling PCA initial computation" << std::endl;
0077   pcaHelper_.pcaInitialComputation();
0078   // first computation within cylinder, halo hits included
0079   pcaHelper_.computePCA(radius);
0080   // second computation within cylinder, halo hits included
0081   pcaHelper_.computePCA(radius);
0082   pcaHelper_.computeShowerWidth(radius);
0083   isoHelper_.produceHGCalIso(theElectron.electronCluster());
0084 }