File indexing completed on 2024-04-06 12:24:37
0001 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0002 #include "RecoCaloTools/Selectors/interface/CaloConeSelector.h"
0003 #include "RecoCaloTools/Selectors/interface/CaloDualConeSelector.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "DataFormats/Common/interface/Handle.h"
0007 #include "FWCore/Framework/interface/ESHandle.h"
0008 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/Utilities/interface/InputTag.h"
0011 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0012 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0013 #include <iostream>
0014 #include <functional>
0015
0016 class TestCaloSelectors : public edm::one::EDAnalyzer<> {
0017 public:
0018 TestCaloSelectors(const edm::ParameterSet& ps)
0019 : token_(consumes(ps.getParameter<edm::InputTag>("inputTag"))), caloToken_(esConsumes()) {}
0020 void analyze(const edm::Event& evt, const edm::EventSetup& es) override;
0021
0022 private:
0023 edm::EDGetTokenT<HBHERecHitCollection> token_;
0024 edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloToken_;
0025 };
0026
0027 void TestCaloSelectors::analyze(const edm::Event& evt, const edm::EventSetup& c) {
0028 edm::ESHandle<CaloGeometry> pG = c.getHandle(caloToken_);
0029
0030 const HBHERecHitCollection& mhbhe = evt.get(token_);
0031
0032 double maxEt = -1;
0033 GlobalPoint pMax;
0034 for (HBHERecHitCollection::const_iterator i = mhbhe.begin(); i != mhbhe.end(); i++) {
0035 GlobalPoint p = pG->getPosition(i->detid());
0036 double et = i->energy() / cosh(p.eta());
0037 if (et > maxEt) {
0038 pMax = p;
0039 maxEt = et;
0040 }
0041 }
0042
0043 CaloConeSelector<HBHERecHit> sel(0.3, pG.product(), DetId::Hcal);
0044 CaloDualConeSelector<HBHERecHit> sel2(0.3, 0.5, pG.product(), DetId::Hcal);
0045
0046 std::cout << "Center at " << pMax.eta() << "," << pMax.phi() << " (ET=" << maxEt << ")" << std::endl;
0047
0048 sel.selectCallback(
0049 pMax, mhbhe, [&](const HBHERecHit& i) { std::cout << HcalDetId(i.detid()) << " : " << i << std::endl; });
0050
0051 std::cout << "Dual cone\n";
0052
0053 sel2.selectCallback(
0054 pMax, mhbhe, [&](const HBHERecHit& i) { std::cout << HcalDetId(i.detid()) << " : " << i << std::endl; });
0055
0056 std::cout << std::endl;
0057 }
0058
0059 #include "FWCore/PluginManager/interface/ModuleDef.h"
0060 #include "FWCore/Framework/interface/MakerMacros.h"
0061
0062 DEFINE_FWK_MODULE(TestCaloSelectors);