File indexing completed on 2024-04-06 12:14:20
0001 #include <iostream>
0002 #include <sstream>
0003 #include <string>
0004 #include <vector>
0005
0006 #include "FWCore/Framework/interface/Frameworkfwd.h"
0007 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0008 #include "FWCore/Framework/interface/Event.h"
0009 #include "FWCore/Framework/interface/EventSetup.h"
0010 #include "FWCore/Framework/interface/ESTransientHandle.h"
0011 #include "FWCore/Framework/interface/MakerMacros.h"
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0015
0016 #include "DetectorDescription/Core/interface/DDCompactView.h"
0017 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0018 #include "Geometry/Records/interface/HcalRecNumberingRecord.h"
0019 #include "Geometry/HcalCommonData/interface/HcalDDDRecConstants.h"
0020 #include "Geometry/CaloTopology/interface/CaloTowerTopology.h"
0021 #include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
0022
0023 class CaloTowerTopologyTester : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
0024 public:
0025 explicit CaloTowerTopologyTester(const edm::ParameterSet&);
0026
0027 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0028
0029 private:
0030 void analyze(edm::Event const&, edm::EventSetup const&) override;
0031 void beginJob() override {}
0032 void beginRun(edm::Run const&, edm::EventSetup const&) override {}
0033 void endRun(edm::Run const&, edm::EventSetup const&) override {}
0034 void doTest(const CaloTowerTopology& topology);
0035
0036
0037 const edm::ESGetToken<CaloTowerTopology, HcalRecNumberingRecord> tokTopo_;
0038 };
0039
0040 CaloTowerTopologyTester::CaloTowerTopologyTester(const edm::ParameterSet&)
0041 : tokTopo_{esConsumes<CaloTowerTopology, HcalRecNumberingRecord>(edm::ESInputTag{})} {}
0042
0043 void CaloTowerTopologyTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0044 edm::ParameterSetDescription desc;
0045 desc.setUnknown();
0046 descriptions.add("caloTowerTopologyTester", desc);
0047 }
0048
0049 void CaloTowerTopologyTester::analyze(edm::Event const&, edm::EventSetup const& iSetup) {
0050 doTest(iSetup.getData(tokTopo_));
0051 }
0052
0053 void CaloTowerTopologyTester::doTest(const CaloTowerTopology& topology) {
0054 for (int ieta = -topology.lastHFRing(); ieta <= topology.lastHFRing(); ieta++) {
0055 for (int iphi = 1; iphi <= 72; iphi++) {
0056 const CaloTowerDetId id(ieta, iphi);
0057 if (topology.validDetId(id)) {
0058 std::vector<DetId> idE = topology.east(id);
0059 std::vector<DetId> idW = topology.west(id);
0060 std::vector<DetId> idN = topology.north(id);
0061 std::vector<DetId> idS = topology.south(id);
0062 edm::LogVerbatim("CaloTower") << "Neighbours for : Tower " << id << std::endl;
0063 std::ostringstream st1;
0064 st1 << " " << idE.size() << " sets along East:";
0065 for (auto& i : idE)
0066 st1 << " " << static_cast<CaloTowerDetId>(i());
0067 edm::LogVerbatim("CaloTower") << st1.str();
0068 std::ostringstream st2;
0069 st2 << " " << idW.size() << " sets along West:";
0070 for (auto& i : idW)
0071 st2 << " " << static_cast<CaloTowerDetId>(i());
0072 edm::LogVerbatim("CaloTower") << st2.str();
0073 std::ostringstream st3;
0074 st3 << " " << idN.size() << " sets along North:";
0075 for (auto& i : idN)
0076 st3 << " " << static_cast<CaloTowerDetId>(i());
0077 edm::LogVerbatim("CaloTower") << st3.str();
0078 std::ostringstream st4;
0079 st4 << " " << idS.size() << " sets along South:";
0080 for (auto& i : idS)
0081 st4 << " " << static_cast<CaloTowerDetId>(i());
0082 edm::LogVerbatim("CaloTower") << st4.str();
0083 }
0084 }
0085 }
0086 }
0087
0088
0089 DEFINE_FWK_MODULE(CaloTowerTopologyTester);