Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-30 23:47:26

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/HGCalCommonData/interface/FastTimeDDDConstants.h"
0019 #include "Geometry/CaloTopology/interface/FastTimeTopology.h"
0020 
0021 class FastTimeTopologyTester : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
0022 public:
0023   explicit FastTimeTopologyTester(const edm::ParameterSet&);
0024 
0025   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0026 
0027 private:
0028   void analyze(edm::Event const&, edm::EventSetup const&) override;
0029   void beginJob() override {}
0030   void beginRun(edm::Run const&, edm::EventSetup const&) override {}
0031   void endRun(edm::Run const&, edm::EventSetup const&) override {}
0032   void doTest(const FastTimeTopology& topology);
0033 
0034   // ----------member data ---------------------------
0035   const edm::ESGetToken<FastTimeTopology, IdealGeometryRecord> tokTopo_;
0036 };
0037 
0038 FastTimeTopologyTester::FastTimeTopologyTester(const edm::ParameterSet&)
0039     : tokTopo_{esConsumes<FastTimeTopology, IdealGeometryRecord>(edm::ESInputTag{"", "FastTimeBarrel"})} {}
0040 
0041 void FastTimeTopologyTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0042   edm::ParameterSetDescription desc;
0043   desc.setUnknown();
0044   descriptions.add("fastTimeTopologyTester", desc);
0045 }
0046 
0047 void FastTimeTopologyTester::analyze(edm::Event const&, edm::EventSetup const& iSetup) {
0048   doTest(iSetup.getData(tokTopo_));
0049 }
0050 
0051 void FastTimeTopologyTester::doTest(const FastTimeTopology& topology) {
0052   for (int izz = 0; izz <= 1; izz++) {
0053     int iz = (2 * izz - 1);
0054     for (int eta = 1; eta <= 265; ++eta) {
0055       for (int phi = 1; phi <= 720; ++phi) {
0056         const FastTimeDetId id(1, eta, phi, iz);
0057         if (topology.valid(id)) {
0058           edm::LogVerbatim("FastTime") << "Neighbours for Tower " << id;
0059           std::vector<DetId> idE = topology.east(id);
0060           std::vector<DetId> idW = topology.west(id);
0061           std::vector<DetId> idN = topology.north(id);
0062           std::vector<DetId> idS = topology.south(id);
0063           std::ostringstream st1;
0064           st1 << "          " << idE.size() << " sets along East:";
0065           for (auto& i : idE)
0066             st1 << " " << static_cast<FastTimeDetId>(i());
0067           edm::LogVerbatim("FastTime") << st1.str();
0068           std::ostringstream st2;
0069           st2 << "          " << idW.size() << " sets along West:";
0070           for (auto& i : idW)
0071             st2 << " " << static_cast<FastTimeDetId>(i());
0072           edm::LogVerbatim("FastTime") << st2.str();
0073           std::ostringstream st3;
0074           st3 << "          " << idN.size() << " sets along North:";
0075           for (auto& i : idN)
0076             st3 << " " << static_cast<FastTimeDetId>(i());
0077           edm::LogVerbatim("FastTime") << st3.str();
0078           std::ostringstream st4;
0079           st4 << "          " << idS.size() << " sets along South:";
0080           for (auto& i : idS)
0081             st4 << " " << static_cast<FastTimeDetId>(i());
0082           edm::LogVerbatim("FastTime") << st4.str();
0083         }
0084         phi += 10;
0085       }
0086       eta += 5;
0087     }
0088   }
0089 }
0090 
0091 //define this as a plug-in
0092 DEFINE_FWK_MODULE(FastTimeTopologyTester);