Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include <iostream>
0002 #include <string>
0003 #include <vector>
0004 
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/EventSetup.h"
0009 #include "FWCore/Framework/interface/ESTransientHandle.h"
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0013 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0014 
0015 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0016 #include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h"
0017 #include "Geometry/CaloTopology/interface/HGCalTopology.h"
0018 #include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"
0019 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0020 
0021 class HGCalTopologyTester : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
0022 public:
0023   explicit HGCalTopologyTester(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 HGCalTopology& topology);
0033 
0034   // ----------member data ---------------------------
0035   const std::string detectorName_;
0036   const std::vector<int> type_, layer_, sec1_, sec2_, cell1_, cell2_;
0037   const edm::ESGetToken<HGCalTopology, IdealGeometryRecord> tokTopo_;
0038 };
0039 
0040 HGCalTopologyTester::HGCalTopologyTester(const edm::ParameterSet& iC)
0041     : detectorName_(iC.getParameter<std::string>("detectorName")),
0042       type_(iC.getParameter<std::vector<int> >("types")),
0043       layer_(iC.getParameter<std::vector<int> >("layers")),
0044       sec1_(iC.getParameter<std::vector<int> >("sector1")),
0045       sec2_(iC.getParameter<std::vector<int> >("sector2")),
0046       cell1_(iC.getParameter<std::vector<int> >("cell1")),
0047       cell2_(iC.getParameter<std::vector<int> >("cell2")),
0048       tokTopo_{esConsumes<HGCalTopology, IdealGeometryRecord>(edm::ESInputTag{"", detectorName_})} {}
0049 
0050 void HGCalTopologyTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0051   edm::ParameterSetDescription desc;
0052   std::vector<int> types = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2};
0053   std::vector<int> layer = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18};
0054   std::vector<int> sec1 = {1, 1, 2, 2, 3, 3, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10};
0055   std::vector<int> sec2 = {3, 3, 3, 3, 2, 2, 6, 6, 6, 6, 3, 3, 8, 8, 9, 9, 3, 3};
0056   std::vector<int> cell1 = {0, 4, 12, 14, 18, 23, 1, 4, 7, 10, 13, 16, 0, 3, 6, 9, 12, 15};
0057   std::vector<int> cell2 = {0, 4, 0, 2, 23, 18, 1, 4, 7, 10, 13, 16, 0, 3, 6, 9, 12, 15};
0058   desc.add<std::string>("detectorName", "HGCalEESensitive");
0059   desc.add<std::vector<int> >("types", types);
0060   desc.add<std::vector<int> >("layers", layer);
0061   desc.add<std::vector<int> >("sector1", sec1);
0062   desc.add<std::vector<int> >("sector2", sec2);
0063   desc.add<std::vector<int> >("cell1", cell1);
0064   desc.add<std::vector<int> >("cell2", cell2);
0065   descriptions.add("hgcalTopologyTesterEE", desc);
0066 }
0067 
0068 void HGCalTopologyTester::analyze(edm::Event const&, edm::EventSetup const& iSetup) {
0069   doTest(iSetup.getData(tokTopo_));
0070 }
0071 
0072 void HGCalTopologyTester::doTest(const HGCalTopology& topology) {
0073   if (topology.waferHexagon8() || topology.tileTrapezoid()) {
0074     for (unsigned int i = 0; i < type_.size(); ++i) {
0075       DetId id;
0076       if (detectorName_ == "HGCalEESensitive") {
0077         id = HGCSiliconDetId(DetId::HGCalEE, 1, type_[i], layer_[i], sec1_[i], sec2_[i], cell1_[i], cell2_[i]);
0078       } else if (detectorName_ == "HGCalHESiliconSensitive") {
0079         id = HGCSiliconDetId(DetId::HGCalHSi, 1, type_[i], layer_[i], sec1_[i], sec2_[i], cell1_[i], cell2_[i]);
0080       } else if (detectorName_ == "HGCalHEScintillatorSensitive") {
0081         id = HGCScintillatorDetId(type_[i], layer_[i], sec1_[i], cell1_[i]);
0082       } else {
0083         break;
0084       }
0085       std::vector<DetId> ids = topology.neighbors(id);
0086       unsigned int k(0);
0087       if (id.det() == DetId::HGCalEE || id.det() == DetId::HGCalHSi) {
0088         edm::LogVerbatim("HGCalGeom") << (HGCSiliconDetId)(id) << " has " << ids.size() << " neighbours:";
0089         for (const auto& idn : ids) {
0090           edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << (HGCSiliconDetId)(idn);
0091           ++k;
0092         }
0093       } else {
0094         edm::LogVerbatim("HGCalGeom") << (HGCScintillatorDetId)(id) << " has " << ids.size() << " neighbours:";
0095         for (const auto& idn : ids) {
0096           edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << (HGCScintillatorDetId)(idn);
0097           ++k;
0098         }
0099       }
0100     }
0101   }
0102 }
0103 
0104 //define this as a plug-in
0105 DEFINE_FWK_MODULE(HGCalTopologyTester);