Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-23 04:29:06

0001 #include <algorithm>
0002 #include <set>
0003 #include <vector>
0004 
0005 #include "SeedingRegionByHF.h"
0006 
0007 using namespace ticl;
0008 
0009 SeedingRegionByHF::SeedingRegionByHF(const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)
0010     : SeedingRegionAlgoBase(conf, sumes),
0011       hfhits_token_(sumes.consumes<HFRecHitCollection>(conf.getParameter<edm::InputTag>("hits"))),
0012       minAbsEta_(conf.getParameter<double>("minAbsEta")),
0013       maxAbsEta_(conf.getParameter<double>("maxAbsEta")),
0014       minEt_(conf.getParameter<double>("minEt")) {
0015   geo_token_ = sumes.esConsumes<CaloGeometry, CaloGeometryRecord, edm::Transition::BeginRun>();
0016 }
0017 
0018 SeedingRegionByHF::~SeedingRegionByHF() {}
0019 
0020 void SeedingRegionByHF::initialize(const edm::EventSetup &es) { geometry_ = &es.getData(geo_token_); }
0021 
0022 void SeedingRegionByHF::makeRegions(const edm::Event &ev,
0023                                     const edm::EventSetup &es,
0024                                     std::vector<TICLSeedingRegion> &result) {
0025   const auto &recHits = ev.get(hfhits_token_);
0026 
0027   for (const auto &erh : recHits) {
0028     const HcalDetId &detid = (HcalDetId)erh.detid();
0029     if (erh.energy() < minEt_)
0030       continue;
0031 
0032     const GlobalPoint &globalPosition =
0033         geometry_->getSubdetectorGeometry(DetId::Hcal, HcalForward)->getGeometry(detid)->getPosition(detid);
0034     auto eta = globalPosition.eta();
0035 
0036     if (std::abs(eta) < minAbsEta_ || std::abs(eta) > maxAbsEta_)
0037       continue;
0038 
0039     int iSide = int(eta > 0);
0040     int idx = 0;
0041     edm::ProductID hfSeedId = edm::ProductID(detid.rawId());
0042 
0043     auto phi = globalPosition.phi();
0044     double theta = 2 * atan(exp(eta));
0045     result.emplace_back(
0046         globalPosition, GlobalVector(GlobalVector::Polar(theta, phi, erh.energy())), iSide, idx, hfSeedId);
0047   }
0048 
0049   // sorting seeding region by descending momentum
0050   std::sort(result.begin(), result.end(), [](const TICLSeedingRegion &a, const TICLSeedingRegion &b) {
0051     return a.directionAtOrigin.perp2() > b.directionAtOrigin.perp2();
0052   });
0053 }
0054 
0055 void SeedingRegionByHF::fillPSetDescription(edm::ParameterSetDescription &desc) {
0056   desc.add<edm::InputTag>("hits", edm::InputTag("hfreco"));
0057   desc.add<int>("algo_verbosity", 0);
0058   desc.add<double>("minAbsEta", 3.0);
0059   desc.add<double>("maxAbsEta", 4.0);
0060   desc.add<double>("minEt", 5);
0061   SeedingRegionAlgoBase::fillPSetDescription(desc);
0062 }