Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:11

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/MakerMacros.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 
0013 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0014 #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
0015 #include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
0016 #include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"
0017 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0018 
0019 class HGCalGeometryCornerTester : public edm::one::EDAnalyzer<> {
0020 public:
0021   explicit HGCalGeometryCornerTester(const edm::ParameterSet&);
0022   ~HGCalGeometryCornerTester() override = default;
0023 
0024   void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0025 
0026 private:
0027   void doTest(const HGCalGeometry* geom);
0028   const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> geomToken_;
0029   const int cornerType_;
0030 };
0031 
0032 HGCalGeometryCornerTester::HGCalGeometryCornerTester(const edm::ParameterSet& iC)
0033     : geomToken_{esConsumes<HGCalGeometry, IdealGeometryRecord>(
0034           edm::ESInputTag{"", iC.getParameter<std::string>("detector")})},
0035       cornerType_(iC.getParameter<int>("cornerType")) {}
0036 
0037 void HGCalGeometryCornerTester::analyze(const edm::Event&, const edm::EventSetup& iSetup) {
0038   const HGCalGeometry& geom = iSetup.getData(geomToken_);
0039   doTest(&geom);
0040 }
0041 
0042 void HGCalGeometryCornerTester::doTest(const HGCalGeometry* geom) {
0043   const std::vector<DetId>& ids = geom->getValidDetIds();
0044   edm::LogVerbatim("HGCalGeomX") << "doTest: " << ids.size() << " valid ids for " << geom->cellElement();
0045   unsigned int kount(0);
0046   for (auto const& id : ids) {
0047     std::ostringstream st1;
0048     st1 << "[" << kount << "] ";
0049     if (id.det() == DetId::Forward)
0050       st1 << HGCalDetId(id);
0051     else if (id.det() == DetId::HGCalHSc)
0052       st1 << HGCScintillatorDetId(id);
0053     else
0054       st1 << HGCSiliconDetId(id);
0055     edm::LogVerbatim("HGCalGeomX") << st1.str();
0056     const auto cor = ((cornerType_ > 0) ? geom->getCorners(id)
0057                                         : ((cornerType_ < 0) ? geom->get8Corners(id) : geom->getNewCorners(id)));
0058     GlobalPoint gp = geom->getPosition(id);
0059     std::ostringstream st2;
0060     st2 << "Center" << gp << "with " << cor.size() << " Corners: ";
0061     for (unsigned k = 0; k < cor.size(); ++k)
0062       st2 << "[" << k << "]" << cor[k];
0063     st2 << " Area " << geom->getArea(id);
0064     edm::LogVerbatim("HGCalGeomX") << st2.str();
0065     ++kount;
0066   }
0067 }
0068 
0069 //define this as a plug-in
0070 DEFINE_FWK_MODULE(HGCalGeometryCornerTester);